You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prove termination of LMonoTy[s].resolveAliases (#354)
*Description of changes:*
Refactoring to prove the termination of `resolveAliases`.
`LMonoTy.aliasDef?` can now throw an exception indicating an
implementation error, instead of a panic. As such, `resolveAliases` can
now also throw an exception.
Minor fixes to proofs and formatting.
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
If a program typechecks successfully, then every identifier in the list of
310
310
program decls is not in the original `LContext`
311
311
-/
312
-
theoremProgram.typeCheckFunctionDisjoint : Program.typeCheck.go p C T decls acc = .ok (d', T') → (∀ x, x ∈ Program.getNames.go decls → ¬ C.idents.contains x) := by
312
+
theoremProgram.typeCheckFunctionDisjoint :
313
+
Program.typeCheck.go p C T decls acc = .ok (d', T') →
314
+
(∀ x, x ∈ Program.getNames.go decls → ¬ C.idents.contains x) := by
313
315
induction decls generalizing acc p d' T' T C with
314
316
| nil => simp[Program.getNames.go]
315
317
| cons r rs IH =>
@@ -382,7 +384,7 @@ theorem Program.typeCheckFunctionDisjoint : Program.typeCheck.go p C T decls acc
382
384
simp only[LContext.addFactoryFunction] at a_notin
383
385
grind
384
386
| type t =>
385
-
cases t with (simp only[] at Hty <;> split_contra_case Hty <;> rename_i Hty <;> split_contra_case Hty <;> rename_i Hty)
387
+
cases t with (simp only[] at Hty <;> split_contra_case Hty <;> rename_i Hty; split_contra Hty <;> rename_i Hty)
386
388
| con c =>
387
389
specialize (IH tcok)
388
390
match hx with
@@ -392,7 +394,7 @@ theorem Program.typeCheckFunctionDisjoint : Program.typeCheck.go p C T decls acc
392
394
grind
393
395
| Or.inr (Exists.intro a (And.intro a_in x_in)) =>
394
396
have Hcontains := Identifiers.addListWithErrorContains Hid x
395
-
have := addKnownTypeWithErrorIdents Hty
397
+
have := addKnownTypeWithErrorIdents (by assumption)
396
398
grind
397
399
| syn s =>
398
400
specialize (IH tcok)
@@ -413,7 +415,8 @@ theorem Program.typeCheckFunctionDisjoint : Program.typeCheck.go p C T decls acc
413
415
grind
414
416
| Or.inr (Exists.intro a (And.intro a_in x_in)) =>
415
417
have Hcontains := Identifiers.addListWithErrorContains Hid x
416
-
have := addMutualBlockIdents Hty;
418
+
split at Hty <;> simp_all
419
+
have := addMutualBlockIdents (by assumption);
417
420
grind
418
421
419
422
/--
@@ -477,14 +480,14 @@ theorem Program.typeCheckFunctionNoDup : Program.typeCheck.go p C T decls acc =
477
480
| type td =>
478
481
specialize (IH tcok)
479
482
apply List.nodup_append.mpr
480
-
cases td with (simp only[] at Hty <;> split_contra_case Hty <;> rename_i Hty <;> split_contra_case Hty <;> rename_i Hty)
483
+
cases td with (simp only[] at Hty <;> split_contra_case Hty <;> rename_i Hty <;> split_contra Hty <;> rename_i Hty)
481
484
| con c =>
482
485
constructor; simp[Decl.names, TypeDecl.names]; constructor; apply IH
483
486
intros a a_in; simp[Decl.names, TypeDecl.names] at a_in; subst_vars
484
487
intros x x_in;
485
488
have Hdisj:= Program.typeCheckFunctionDisjoint tcok _ x_in
486
489
have x_contains := (Identifiers.addListWithErrorContains Hid x)
487
-
have := addKnownTypeWithErrorIdents Hty
490
+
have := addKnownTypeWithErrorIdents (by assumption)
488
491
simp_all[Decl.names, TypeDecl.names];
489
492
grind
490
493
| syn s =>
@@ -504,7 +507,8 @@ theorem Program.typeCheckFunctionNoDup : Program.typeCheck.go p C T decls acc =
504
507
have Hdisj:= Program.typeCheckFunctionDisjoint tcok _ x_in
505
508
have x_contains := (Identifiers.addListWithErrorContains Hid x)
0 commit comments