1 (*********************************************************************************************************************************)
2 (* HaskProofToStrong: convert HaskProof to HaskStrong *)
3 (*********************************************************************************************************************************)
5 Generalizable All Variables.
6 Require Import Preamble.
7 Require Import General.
8 Require Import NaturalDeduction.
9 Require Import Coq.Strings.String.
10 Require Import Coq.Lists.List.
11 Require Import Coq.Init.Specif.
12 Require Import HaskKinds.
13 Require Import HaskStrongTypes.
14 Require Import HaskStrong.
15 Require Import HaskProof.
17 Section HaskProofToStrong.
19 Context {VV:Type} {eqdec_vv:EqDecidable VV} {freshM:FreshMonad VV}.
21 Definition fresh := FMT_fresh freshM.
22 Definition FreshM := FMT freshM.
23 Definition FreshMon := FMT_Monad freshM.
24 Existing Instance FreshMon.
26 Definition ExprVarResolver Γ := VV -> LeveledHaskType Γ ★.
28 Definition judg2exprType (j:Judg) : Type :=
30 (Γ > Δ > Σ |- τ) => forall (ξ:ExprVarResolver Γ) vars, Σ = mapOptionTree ξ vars ->
31 FreshM (ITree _ (fun t => Expr Γ Δ ξ t) τ)
34 Definition justOne Γ Δ ξ τ : ITree _ (fun t => Expr Γ Δ ξ t) [τ] -> Expr Γ Δ ξ τ.
39 Definition ileaf `(it:ITree X F [t]) : F t.
44 Lemma update_branches : forall Γ (ξ:VV -> LeveledHaskType Γ ★) lev l1 l2 q,
45 update_xi ξ lev (app l1 l2) q = update_xi (update_xi ξ lev l2) lev l1 q.
55 Lemma quark {T} (l1:list T) l2 vf :
56 (In vf (app l1 l2)) <->
57 (In vf l1) \/ (In vf l2).
84 right; apply H0; auto.
85 right; apply H0; auto.
88 Lemma splitter {T} (l1:list T) l2 vf :
89 (In vf (app l1 l2) → False)
90 -> (In vf l1 → False) /\ (In vf l2 → False).
92 split; intros; apply H; rewrite quark.
98 : forall T Z {eqdt:EqDecidable T}(tl:Tree ??T)(vf:T) ξ (q:Z),
99 (In vf (leaves tl) -> False) ->
100 mapOptionTree (fun v' => if eqd_dec vf v' then q else ξ v') tl =
106 set (eqd_dec vf t) as x in *.
122 Lemma fresh_lemma'' Γ
123 : forall types ξ lev,
124 FreshM { varstypes : _
125 | mapOptionTree (update_xi(Γ:=Γ) ξ lev (leaves varstypes)) (mapOptionTree (@fst _ _) varstypes) = (types @@@ lev)
126 /\ distinct (leaves (mapOptionTree (@fst _ _) varstypes)) }.
131 : forall types vars Σ ξ lev, Σ = mapOptionTree ξ vars ->
132 FreshM { varstypes : _
133 | mapOptionTree (update_xi(Γ:=Γ) ξ lev (leaves varstypes)) vars = Σ
134 /\ mapOptionTree (update_xi ξ lev (leaves varstypes)) (mapOptionTree (@fst _ _) varstypes) = (types @@@ lev)
135 /\ distinct (leaves (mapOptionTree (@fst _ _) varstypes)) }.
138 refine (bind vf = fresh (leaves vars) ; return _).
140 destruct vf as [ vf vf_pf ].
144 set (helper VV _ vars vf ξ (h@@lev) vf_pf) as q.
148 destruct (eqd_dec vf vf); [ idtac | set (n (refl_equal _)) as n'; inversion n' ]; auto.
164 intros vars Σ ξ lev pf; refine (bind x2 = IHtypes2 vars Σ ξ lev pf; _).
166 destruct x2 as [vt2 [pf21 [pf22 pfdist]]].
167 refine (bind x1 = IHtypes1 (vars,,(mapOptionTree (@fst _ _) vt2)) (Σ,,(types2@@@lev)) (update_xi ξ lev
168 (leaves vt2)) _ _; return _).
174 clear IHtypes1 IHtypes2.
175 destruct x1 as [vt1 [pf11 pf12]].
176 exists (vt1,,vt2); split; auto.
178 set (update_branches Γ ξ lev (leaves vt1) (leaves vt2)) as q.
179 set (mapOptionTree_extensional _ _ q) as q'.
186 set (update_branches Γ ξ lev (leaves vt1) (leaves vt2)) as q.
187 set (mapOptionTree_extensional _ _ q) as q'.
191 rewrite <- mapOptionTree_compose.
192 rewrite <- mapOptionTree_compose.
193 rewrite <- mapOptionTree_compose in *.
198 rewrite <- mapOptionTree_compose.
204 Lemma fresh_lemma Γ ξ vars Σ Σ' lev
205 : Σ = mapOptionTree ξ vars ->
207 | mapOptionTree (update_xi(Γ:=Γ) ξ lev ((vars',Σ')::nil)) vars = Σ
208 /\ mapOptionTree (update_xi ξ lev ((vars',Σ')::nil)) [vars'] = [Σ' @@ lev] }.
210 set (fresh_lemma' Γ [Σ'] vars Σ ξ lev H) as q.
211 refine (q >>>= fun q' => return _).
214 destruct q' as [varstypes [pf1 [pf2 pfdist]]].
215 destruct varstypes; try destruct o; try destruct p; simpl in *.
216 destruct (eqd_dec v v); [ idtac | set (n (refl_equal _)) as n'; inversion n' ].
217 inversion pf2; subst.
219 destruct (eqd_dec v v); [ idtac | set (n (refl_equal _)) as n'; inversion n' ].
225 Definition ujudg2exprType Γ (ξ:ExprVarResolver Γ)(Δ:CoercionEnv Γ) Σ τ : Type :=
226 forall vars, Σ = mapOptionTree ξ vars -> FreshM (ITree _ (fun t => Expr Γ Δ ξ t) τ).
228 Definition urule2expr : forall Γ Δ h j t (r:@Arrange _ h j) (ξ:VV -> LeveledHaskType Γ ★),
229 ujudg2exprType Γ ξ Δ h t ->
230 ujudg2exprType Γ ξ Δ j t
233 refine (fix urule2expr h j t (r:@Arrange _ h j) ξ {struct r} :
234 ujudg2exprType Γ ξ Δ h t ->
235 ujudg2exprType Γ ξ Δ j t :=
236 match r as R in Arrange H C return
237 ujudg2exprType Γ ξ Δ H t ->
238 ujudg2exprType Γ ξ Δ C t
240 | RLeft h c ctx r => let case_RLeft := tt in (fun e => _) (urule2expr _ _ _ r)
241 | RRight h c ctx r => let case_RRight := tt in (fun e => _) (urule2expr _ _ _ r)
242 | RId a => let case_RId := tt in _
243 | RCanL a => let case_RCanL := tt in _
244 | RCanR a => let case_RCanR := tt in _
245 | RuCanL a => let case_RuCanL := tt in _
246 | RuCanR a => let case_RuCanR := tt in _
247 | RAssoc a b c => let case_RAssoc := tt in _
248 | RCossa a b c => let case_RCossa := tt in _
249 | RExch a b => let case_RExch := tt in _
250 | RWeak a => let case_RWeak := tt in _
251 | RCont a => let case_RCont := tt in _
252 | RComp a b c f g => let case_RComp := tt in (fun e1 e2 => _) (urule2expr _ _ _ f) (urule2expr _ _ _ g)
253 end); clear urule2expr; intros.
259 simpl; unfold ujudg2exprType; intros.
261 apply (X ([],,vars)).
262 simpl; rewrite <- H; auto.
265 simpl; unfold ujudg2exprType; intros.
267 apply (X (vars,,[])).
268 simpl; rewrite <- H; auto.
270 destruct case_RuCanL.
271 simpl; unfold ujudg2exprType; intros.
272 destruct vars; try destruct o; inversion H.
274 apply (X vars2); auto.
276 destruct case_RuCanR.
277 simpl; unfold ujudg2exprType; intros.
278 destruct vars; try destruct o; inversion H.
280 apply (X vars1); auto.
282 destruct case_RAssoc.
283 simpl; unfold ujudg2exprType; intros.
285 destruct vars; try destruct o; inversion H.
286 destruct vars1; try destruct o; inversion H.
287 apply (X (vars1_1,,(vars1_2,,vars2))).
290 destruct case_RCossa.
291 simpl; unfold ujudg2exprType; intros.
293 destruct vars; try destruct o; inversion H.
294 destruct vars2; try destruct o; inversion H.
295 apply (X ((vars1,,vars2_1),,vars2_2)).
299 simpl; unfold ujudg2exprType ; intros.
301 destruct vars; try destruct o; inversion H.
302 apply (X (vars2,,vars1)).
303 inversion H; subst; auto.
306 simpl; unfold ujudg2exprType; intros.
312 simpl; unfold ujudg2exprType ; intros.
314 apply (X (vars,,vars)).
320 intro vars; unfold ujudg2exprType; intro H.
321 destruct vars; try destruct o; inversion H.
322 apply (fun q => e ξ q vars2 H2).
326 unfold ujudg2exprType.
328 apply X with (vars:=vars1,,vars).
334 destruct case_RRight.
335 intro vars; unfold ujudg2exprType; intro H.
336 destruct vars; try destruct o; inversion H.
337 apply (fun q => e ξ q vars1 H1).
341 unfold ujudg2exprType.
343 apply X with (vars:=vars,,vars2).
355 Definition letrec_helper Γ Δ l (varstypes:Tree ??(VV * HaskType Γ ★)) ξ' :
356 ITree (LeveledHaskType Γ ★)
357 (fun t : LeveledHaskType Γ ★ => Expr Γ Δ ξ' t)
358 (mapOptionTree (ξ' ○ (@fst _ _)) varstypes)
359 -> ELetRecBindings Γ Δ ξ' l varstypes.
362 destruct a; simpl in *.
365 apply ileaf in X. simpl in X.
368 destruct (eqd_dec (unlev (ξ' v)) τ).
372 destruct (eqd_dec h0 l).
375 apply (Prelude_error "level mismatch; should never happen").
376 apply (Prelude_error "letrec type mismatch; should never happen").
380 apply IHvarstypes1; inversion X; auto.
381 apply IHvarstypes2; inversion X; auto.
384 Definition unindex_tree {V}{F} : forall {t:Tree ??V}, ITree V F t -> Tree ??{ v:V & F v }.
385 refine (fix rec t it := match it as IT return Tree ??{ v:V & F v } with
386 | INone => T_Leaf None
387 | ILeaf x y => T_Leaf (Some _)
388 | IBranch _ _ b1 b2 => (rec _ b1),,(rec _ b2)
393 Definition fix_indexing X (F:X->Type)(J:X->Type)(t:Tree ??{ x:X & F x })
394 : ITree { x:X & F x } (fun x => J (projT1 x)) t
395 -> ITree X (fun x:X => J x) (mapOptionTree (@projT1 _ _) t).
397 induction it; simpl in *.
401 simpl; apply IBranch; auto.
404 Definition fix2 {X}{F} : Tree ??{ x:X & FreshM (F x) } -> Tree ??(FreshM { x:X & F x }).
405 refine (fix rec t := match t with
406 | T_Leaf None => T_Leaf None
407 | T_Leaf (Some x) => T_Leaf (Some _)
408 | T_Branch b1 b2 => T_Branch (rec b1) (rec b2)
410 destruct x as [x fx].
411 refine (bind fx' = fx ; return _).
417 Definition case_helper tc Γ Δ lev tbranches avars ξ :
418 forall pcb:{sac : StrongAltCon & ProofCaseBranch tc Γ Δ lev tbranches avars sac},
419 prod (judg2exprType (pcb_judg (projT2 pcb))) {vars' : Tree ??VV & pcb_freevars (projT2 pcb) = mapOptionTree ξ vars'} ->
421 { scb : StrongCaseBranchWithVVs VV eqdec_vv tc avars sac
422 & Expr (sac_gamma sac Γ) (sac_delta sac Γ avars (weakCK'' Δ)) (scbwv_xi scb ξ lev) (weakLT' (tbranches @@ lev)) }) (projT1 pcb)).
427 destruct pcb as [sac pcb].
431 destruct s as [vars vars_pf].
433 refine (bind localvars = fresh_lemma' _ (unleaves (vec2list (sac_types sac _ avars))) vars
434 (mapOptionTree weakLT' (pcb_freevars pcb)) (weakLT' ○ ξ) (weakL' lev) _ ; _).
437 rewrite <- mapOptionTree_compose.
439 destruct localvars as [localvars [localvars_pf1 [localvars_pf2 localvars_dist ]]].
440 set (mapOptionTree (@fst _ _) localvars) as localvars'.
442 set (list2vec (leaves localvars')) as localvars''.
443 cut (length (leaves localvars') = sac_numExprVars sac). intro H''.
444 rewrite H'' in localvars''.
445 cut (distinct (vec2list localvars'')). intro H'''.
446 set (@Build_StrongCaseBranchWithVVs _ _ _ _ avars sac localvars'' H''') as scb.
448 refine (bind q = (f (scbwv_xi scb ξ lev) (vars,,(unleaves (vec2list (scbwv_exprvars scb)))) _) ; return _).
453 rewrite <- mapOptionTree_compose.
468 Definition gather_branch_variables
469 Γ Δ (ξ:VV -> LeveledHaskType Γ ★) tc avars tbranches lev (alts:Tree ?? {sac : StrongAltCon &
470 ProofCaseBranch tc Γ Δ lev tbranches avars sac})
473 mapOptionTreeAndFlatten (fun x => pcb_freevars(Γ:=Γ) (projT2 x)) alts = mapOptionTree ξ vars
474 -> ITree Judg judg2exprType (mapOptionTree (fun x => pcb_judg (projT2 x)) alts)
475 -> ITree _ (fun q => prod (judg2exprType (pcb_judg (projT2 q)))
476 { vars' : _ & pcb_freevars (projT2 q) = mapOptionTree ξ vars' })
482 destruct a; [ idtac | apply INone ].
484 apply ileaf in source.
486 destruct s as [sac pcb].
498 destruct vars; try destruct o; simpl in pf; inversion pf.
503 apply (IHalts1 vars1 H0 X); auto.
504 apply (IHalts2 vars2 H1 X0); auto.
509 Definition rule2expr : forall h j (r:Rule h j), ITree _ judg2exprType h -> ITree _ judg2exprType j.
513 refine (match r as R in Rule H C return ITree _ judg2exprType H -> ITree _ judg2exprType C with
514 | RArrange a b c d e r => let case_RURule := tt in _
515 | RNote Γ Δ Σ τ l n => let case_RNote := tt in _
516 | RLit Γ Δ l _ => let case_RLit := tt in _
517 | RVar Γ Δ σ p => let case_RVar := tt in _
518 | RGlobal Γ Δ σ l wev => let case_RGlobal := tt in _
519 | RLam Γ Δ Σ tx te x => let case_RLam := tt in _
520 | RCast Γ Δ Σ σ τ γ x => let case_RCast := tt in _
521 | RAbsT Γ Δ Σ κ σ a => let case_RAbsT := tt in _
522 | RAppT Γ Δ Σ κ σ τ y => let case_RAppT := tt in _
523 | RAppCo Γ Δ Σ κ σ₁ σ₂ γ σ l => let case_RAppCo := tt in _
524 | RAbsCo Γ Δ Σ κ σ σ₁ σ₂ y => let case_RAbsCo := tt in _
525 | RApp Γ Δ Σ₁ Σ₂ tx te p => let case_RApp := tt in _
526 | RLet Γ Δ Σ₁ Σ₂ σ₁ σ₂ p => let case_RLet := tt in _
527 | RWhere Γ Δ Σ₁ Σ₂ Σ₃ σ₁ σ₂ p => let case_RWhere := tt in _
528 | RJoin Γ p lri m x q => let case_RJoin := tt in _
529 | RVoid _ _ => let case_RVoid := tt in _
530 | RBrak Σ a b c n m => let case_RBrak := tt in _
531 | REsc Σ a b c n m => let case_REsc := tt in _
532 | RCase Γ Δ lev tc Σ avars tbranches alts => let case_RCase := tt in _
533 | RLetRec Γ Δ lri x y t => let case_RLetRec := tt in _
534 end); intro X_; try apply ileaf in X_; simpl in X_.
536 destruct case_RURule.
537 apply ILeaf. simpl. intros.
538 set (@urule2expr a b _ _ e r0 ξ) as q.
539 set (fun z => q z) as q'.
541 apply q' with (vars:=vars).
543 unfold ujudg2exprType.
545 apply X_ with (vars:=vars0).
550 apply ILeaf; simpl; intros; refine (X_ ξ vars H >>>= fun X => return ILeaf _ _). apply FreshMon.
555 apply ILeaf; simpl; intros; refine (X_ ξ vars H >>>= fun X => return ILeaf _ _). apply FreshMon.
560 apply ILeaf; simpl; intros; refine (X_ ξ vars H >>>= fun X => return ILeaf _ _). apply FreshMon.
565 apply ILeaf; simpl; intros; refine (return ILeaf _ _).
569 apply ILeaf; simpl; intros; refine (return ILeaf _ _).
570 destruct vars; simpl in H; inversion H; destruct o. inversion H1. rewrite H2.
574 destruct case_RGlobal.
575 apply ILeaf; simpl; intros; refine (return ILeaf _ _).
581 refine (fresh_lemma _ ξ vars _ tx x H >>>= (fun pf => _)).
583 destruct pf as [ vnew [ pf1 pf2 ]].
584 set (update_xi ξ x (((vnew, tx )) :: nil)) as ξ' in *.
585 refine (X_ ξ' (vars,,[vnew]) _ >>>= _).
595 apply ELam with (ev:=vnew).
602 apply ILeaf; simpl; intros; refine (X_ ξ vars H >>>= fun X => return ILeaf _ _). apply FreshMon.
605 apply ileaf in X. simpl in X.
609 apply ILeaf; simpl; intros.
614 destruct vars; inversion H.
615 destruct o; inversion H3.
616 refine (X ξ vars1 H3 >>>= fun X' => X0 ξ vars2 H4 >>>= fun X0' => return _).
628 destruct vars. try destruct o; inversion H.
631 set (X1 ξ vars1 H5) as q1.
632 set (X2 ξ vars2 H6) as q2.
633 refine (q1 >>>= fun q1' => q2 >>>= fun q2' => return _).
640 apply (EApp _ _ _ _ _ _ q1' q2').
645 destruct vars; try destruct o; inversion H.
647 refine (fresh_lemma _ ξ _ _ σ₁ p H2 >>>= (fun pf => _)).
650 destruct pf as [ vnew [ pf1 pf2 ]].
651 set (update_xi ξ p (((vnew, σ₁ )) :: nil)) as ξ' in *.
657 refine (X ξ vars1 _ >>>= fun X0' => _).
662 refine (X0 ξ' ([vnew],,vars2) _ >>>= fun X1' => _).
674 apply ELet with (ev:=vnew)(tv:=σ₁).
678 destruct case_RWhere.
681 destruct vars; try destruct o; inversion H.
682 destruct vars2; try destruct o; inversion H2.
685 assert ((Σ₁,,Σ₃) = mapOptionTree ξ (vars1,,vars2_2)) as H13; simpl; subst; auto.
686 refine (fresh_lemma _ ξ _ _ σ₁ p H13 >>>= (fun pf => _)).
689 destruct pf as [ vnew [ pf1 pf2 ]].
690 set (update_xi ξ p (((vnew, σ₁ )) :: nil)) as ξ' in *.
696 refine (X ξ' (vars1,,([vnew],,vars2_2)) _ >>>= fun X0' => _).
705 refine (X0 ξ vars2_1 _ >>>= fun X1' => _).
714 apply ELet with (ev:=vnew)(tv:=σ₁).
719 apply ILeaf; simpl; intros.
724 apply ILeaf; simpl; intros; refine (X_ ξ vars H >>>= fun X => return ILeaf _ _). apply FreshMon.
729 apply ILeaf; simpl; intros; refine (X_ (weakLT ○ ξ) vars _ >>>= fun X => return ILeaf _ _). apply FreshMon.
730 rewrite mapOptionTree_compose.
733 apply ileaf in X. simpl in *.
737 destruct case_RAppCo.
738 apply ILeaf; simpl; intros; refine (X_ ξ vars _ >>>= fun X => return ILeaf _ _). apply FreshMon.
744 destruct case_RAbsCo.
745 apply ILeaf; simpl; intros; refine (X_ ξ vars _ >>>= fun X => return ILeaf _ _). apply FreshMon.
750 destruct case_RLetRec.
751 apply ILeaf; simpl; intros.
752 refine (bind ξvars = fresh_lemma' _ y _ _ _ t H; _). apply FreshMon.
753 destruct ξvars as [ varstypes [ pf1[ pf2 pfdist]]].
754 refine (X_ ((update_xi ξ t (leaves varstypes)))
755 (vars,,(mapOptionTree (@fst _ _) varstypes)) _ >>>= fun X => return _); clear X_. apply FreshMon.
761 inversion X; subst; clear X.
763 apply (@ELetRec _ _ _ _ _ _ _ varstypes).
765 apply (@letrec_helper Γ Δ t varstypes).
766 rewrite <- pf2 in X0.
767 rewrite mapOptionTree_compose.
773 apply ILeaf; simpl; intros.
780 (* body_freevars and alts_freevars are the types of variables in the body and alternatives (respectively) which are free
781 * from the viewpoint just outside the case block -- i.e. not bound by any of the branches *)
782 rename Σ into body_freevars_types.
783 rename vars into all_freevars.
784 rename X0 into body_expr.
785 rename X into alts_exprs.
787 destruct all_freevars; try destruct o; inversion H.
788 rename all_freevars2 into body_freevars.
789 rename all_freevars1 into alts_freevars.
791 set (gather_branch_variables _ _ _ _ _ _ _ _ _ H1 alts_exprs) as q.
792 set (itmap (fun pcb alt_expr => case_helper tc Γ Δ lev tbranches avars ξ pcb alt_expr) q) as alts_exprs'.
793 apply fix_indexing in alts_exprs'.
794 simpl in alts_exprs'.
795 apply unindex_tree in alts_exprs'.
796 simpl in alts_exprs'.
797 apply fix2 in alts_exprs'.
798 apply treeM in alts_exprs'.
800 refine ( alts_exprs' >>>= fun Y =>
802 >>>= fun X => return ILeaf _ (@ECase _ _ _ _ _ _ _ _ _ (ileaf X) Y)); auto.
808 Fixpoint closed2expr h j (pn:@SIND _ Rule h j) {struct pn} : ITree _ judg2exprType h -> ITree _ judg2exprType j :=
809 match pn in @SIND _ _ H J return ITree _ judg2exprType H -> ITree _ judg2exprType J with
810 | scnd_weak _ => let case_nil := tt in fun _ => INone _ _
811 | scnd_comp x h c cnd' r => let case_rule := tt in fun q => rule2expr _ _ r (closed2expr _ _ cnd' q)
812 | scnd_branch _ _ _ c1 c2 => let case_branch := tt in fun q => IBranch _ _ (closed2expr _ _ c1 q) (closed2expr _ _ c2 q)
815 Lemma manyFresh : forall Γ Σ (ξ0:VV -> LeveledHaskType Γ ★),
816 FreshM { vars : _ & { ξ : VV -> LeveledHaskType Γ ★ & Σ = mapOptionTree ξ vars } }.
818 induction Σ; intro ξ.
821 set (fresh_lemma' Γ [τ] [] [] ξ l (refl_equal _)) as q.
822 refine (q >>>= fun q' => return _).
825 destruct q' as [varstypes [pf1 [pf2 distpf]]].
826 exists (mapOptionTree (@fst _ _) varstypes).
827 exists (update_xi ξ l (leaves varstypes)).
832 refine (bind f1 = IHΣ1 ξ ; _).
834 destruct f1 as [vars1 [ξ1 pf1]].
835 refine (bind f2 = IHΣ2 ξ1 ; _).
837 destruct f2 as [vars2 [ξ2 pf22]].
839 exists (vars1,,vars2).
847 Definition proof2expr Γ Δ τ Σ (ξ0: VV -> LeveledHaskType Γ ★)
848 {zz:ToString VV} : ND Rule [] [Γ > Δ > Σ |- [τ]] ->
849 FreshM (???{ ξ : _ & Expr Γ Δ ξ τ}).
851 set (mkSIND systemfc_all_rules_one_conclusion _ _ _ pf (scnd_weak [])) as cnd.
852 apply closed2expr in cnd.
856 refine (bind ξvars = manyFresh _ Σ ξ0; _).
858 destruct ξvars as [vars ξpf].
859 destruct ξpf as [ξ pf].
860 refine (cnd ξ vars _ >>>= fun it => _).
863 refine (return OK _).
869 End HaskProofToStrong.