Skip to content

Commit 8a88c00

Browse files
committed
some ugly but (possibly) working proof
1 parent 68101ca commit 8a88c00

File tree

2 files changed

+158
-42
lines changed

2 files changed

+158
-42
lines changed

theories/Core/Syntactic/System/Lemmas.v

Lines changed: 157 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ Qed.
7777
#[export]
7878
Hint Resolve presup_ctx_eq presup_ctx_eq_left presup_ctx_eq_right : mctt.
7979

80+
Lemma presup_ctx_sub : forall {Δ Γ Γ'}, {{ Δ ⊢ Γ ⊆ Γ' }} -> {{ ⊢ Δ ;; Γ }} /\ {{ ⊢ Δ ;; Γ' }}.
81+
Proof with mautosolve.
82+
induction 1; destruct_pairs...
83+
Qed.
84+
85+
Corollary presup_ctx_sub_left : forall {Δ Γ Γ'}, {{ Δ ⊢ Γ ⊆ Γ' }} -> {{ ⊢ Δ ;; Γ }}.
86+
Proof with easy.
87+
intros * ?%presup_ctx_sub...
88+
Qed.
89+
90+
Corollary presup_ctx_sub_right : forall {Δ Γ Γ'}, {{ Δ ⊢ Γ ⊆ Γ' }} -> {{ ⊢ Δ ;; Γ' }}.
91+
Proof with easy.
92+
intros * ?%presup_ctx_sub...
93+
Qed.
94+
95+
#[export]
96+
Hint Resolve presup_ctx_sub presup_ctx_sub_left presup_ctx_sub_right : mctt.
97+
8098
Lemma presup_sub : forall {Δ Γ Γ' σ}, {{ Δ ;; Γ ⊢s σ : Γ' }} -> {{ ⊢ Δ ;; Γ }} /\ {{ ⊢ Δ ;; Γ' }}.
8199
Proof with mautosolve.
82100
induction 1; destruct_pairs...
@@ -1431,6 +1449,24 @@ Proof with mautosolve 4.
14311449
Qed.
14321450

14331451
(** *** Type Presuppositions *)
1452+
Lemma presub_exp_eq_helper: forall {Δ Γ A i},
1453+
{{ Δ ;; Γ ⊢ A : Type@i }} ->
1454+
{{ Δ ;; Γ, A ⊢ A[Wk] : Type@i }} /\
1455+
{{ Δ ;; Γ, A, A[Wk] ⊢s Wk : Γ, A }} /\
1456+
{{ Δ ;; Γ, A, A[Wk] ⊢ A[Wk∘Wk] : Type@i }} /\
1457+
{{ Δ ;; Γ, A, A[Wk] ⊢ Eq A[Wk∘Wk] #1 #0 : Type@i }}.
1458+
Proof.
1459+
intros.
1460+
assert {{ Δ ;; Γ, A ⊢s Wk : Γ }} by mauto 4.
1461+
assert {{ Δ ;; Γ, A ⊢ A[Wk] : Type@i }} by mauto 3.
1462+
assert {{ Δ ;; Γ, A, A[Wk] ⊢s Wk : Γ, A }} by mauto 4.
1463+
assert {{ Δ ;; Γ, A, A[Wk] ⊢ A[Wk∘Wk] : Type@i }} by mauto 3.
1464+
assert {{ Δ ;; Γ, A, A[Wk] ⊢ Eq A[Wk∘Wk] #1 #0 : Type@i }} by (econstructor; mauto 3; eapply wf_conv; mauto 4).
1465+
auto.
1466+
Qed.
1467+
1468+
#[local]
1469+
Hint Resolve presub_exp_eq_helper : mctt.
14341470

14351471
(* TODO: to prove this, we may need the weakening of both gctx and ctx, some of which
14361472
are stated below. the weakening of ctx, in the presence of explicit substitution,
@@ -1449,16 +1485,15 @@ Proof.
14491485

14501486
- eexists; mauto 4 using lift_exp_max_left, lift_exp_max_right.
14511487

1452-
- admit.
1488+
- inversion_clear H0. admit. admit.
14531489

14541490
- enough {{ Δ ;; Γ ⊢s Id,,M1,,M2,,^N : Γ, A, A[Wk], Eq A[Wk∘Wk] #1 #0 }} by mauto 3.
1455-
assert {{ Δ ;; Γ, A ⊢s Wk : Γ }} by mauto 3.
1456-
assert {{ Δ ;; Γ, A ⊢ A[Wk] : Type@i }} by mauto 3.
1491+
assert {{ Δ ;; Γ, A ⊢ A[Wk] : Type@i }} by mauto 4.
14571492
assert {{ Δ ;; Γ, A, A[Wk] ⊢s Wk : Γ, A }} by mauto 4.
1458-
assert {{ Δ ;; Γ, A, A[Wk] ⊢ A[Wk∘Wk] : Type@i }} by mauto 3.
1459-
assert {{ Δ ;; Γ, A, A[Wk] ⊢ Eq A[Wk∘Wk] #1 #0 : Type@i }} by (econstructor; mauto 3; eapply wf_conv; mauto 4).
1493+
assert {{ Δ ;; Γ, A, A[Wk] ⊢ A[Wk∘Wk] : Type@i }} by (eapply presub_exp_eq_helper; eauto 3).
1494+
assert {{ Δ ;; Γ, A, A[Wk] ⊢ Eq A[Wk∘Wk] #1 #0 : Type@i }} by (eapply presub_exp_eq_helper; eauto 3).
14601495
assert {{ Δ ;; Γ ⊢s Id,,M1 : Γ, A }} by mauto 3.
1461-
assert {{ Δ ;; Γ ⊢ M2 : A[Wk][Id,,M1] }} by (eapply wf_conv; [| | symmetry]; mauto 2).
1496+
assert {{ Δ ;; Γ ⊢ M2 : A[Wk][Id,,M1] }} by (eapply wf_conv; [| | symmetry]; mauto 3).
14621497
assert {{ Δ ;; Γ ⊢s Id,,M1,,M2 : Γ, A, A[Wk] }} by mauto 3.
14631498
econstructor; [mautosolve 3 | mautosolve 3 |].
14641499
eapply wf_conv; [| | symmetry]; mauto 3.
@@ -1560,48 +1595,128 @@ Proof.
15601595
try solve [econstructor; mauto 4].
15611596
Qed.
15621597

1563-
(* this cannot be proved by induction in this form, and generally not true *)
1564-
Lemma gctx_presup_weakening_ctx : forall {Δ Γ A M},
1565-
{{ Δ ;; ⋅ ⊢ M : A }} ->
1566-
{{ ⊢ Δ ;; Γ }} ->
1567-
{{ Δ ;; Γ ⊢ M : A }}.
1568-
Proof.
1569-
intros. dependent induction H; mauto 3.
1570-
Admitted.
1571-
1572-
Lemma presup_gctx_lookup_typ : forall {Δ Γ A x M},
1573-
{{ ⊢ Δ ;; Γ }} ->
1574-
{{ `#x := [M] :: A ∈ Δ }} ->
1575-
exists i, {{ Δ ;; Γ ⊢ A : Type@i }}.
1576-
Proof with mautosolve 4.
1577-
intros * HΔ.
1578-
induction 1; inversion_clear HΔ.
1579-
- eexists. admit.
1580-
- admit.
1581-
- admit. (* problematic, cannot use IH which requires ⊢ Δ;; Γ *)
1582-
- admit. (* problematic, cannot use IH which requires ⊢ Δ;; Γ *)
1583-
Abort.
1584-
15851598
Lemma presup_gctx_lookup_typ_nil : forall {Δ A x M},
15861599
{{ ⊢ Δ }} ->
15871600
{{ `#x := [ M ] :: A ∈ Δ }} ->
15881601
exists i, {{ Δ ;; ⋅ ⊢ A : Type@i }}.
15891602
Proof with mautosolve 4.
15901603
intros * HΔ.
15911604
induction 1; inversion_clear HΔ.
1592-
Admitted.
1605+
- eexists.
1606+
replace {{{ Δ, x:=M0::A }}} with {{{ Δ ,++ (^nil,x:=M0::A) }}} by mauto 3.
1607+
eapply wf_weakening_gctx; mauto 3.
1608+
econstructor; mauto 3.
1609+
- eexists.
1610+
replace {{{ Δ, x:=∅::A }}} with {{{ Δ ,++ (^nil,x:=∅::A) }}} by mauto 3.
1611+
eapply wf_weakening_gctx; mauto 3.
1612+
econstructor; mauto 3.
1613+
- apply IHgctx_lookup in H1 as H1'. destruct H1' as [i' HIH]. eexists.
1614+
replace {{{ Δ, x:=M0::B }}} with {{{ Δ ,++ (^nil,x:=M0::B) }}} by mauto 3.
1615+
eapply wf_weakening_gctx; mauto 3.
1616+
econstructor; mauto 3.
1617+
- apply IHgctx_lookup in H1 as H1'. destruct H1' as [i' HIH]. eexists.
1618+
replace {{{ Δ, x:=∅::B }}} with {{{ Δ ,++ (^nil,x:=∅::B) }}} by mauto 3.
1619+
eapply wf_weakening_gctx; mauto 3.
1620+
econstructor; mauto 3.
1621+
Qed.
15931622

1594-
(* I think this is the best form we can prove *)
1595-
Lemma presup_gctx_lookup_typ : forall {Δ Γ A x M},
1596-
{{ ⊢ Δ ;; Γ }} ->
1597-
{{ `#x := [ M ] :: A ∈ Δ }} ->
1598-
exists i, {{ Δ ;; Γ ⊢ ^(iter (S (length Γ)) (fun B => {{{ B[Wk] }}}) A) : Type@i }}.
1599-
Proof with mautosolve 4.
1600-
intros * Hctx.
1601-
induction 1.
1602-
- admit.
1603-
- admit.
1604-
Admitted.
1623+
Scheme
1624+
wf_ctx_sub_mut_ind3 := Induction for wf_ctx_sub Sort Prop
1625+
with wf_exp_mut_ind3 := Induction for wf_exp Sort Prop
1626+
with wf_exp_eq_mut_ind3 := Induction for wf_exp_eq Sort Prop
1627+
with wf_sub_mut_ind3 := Induction for wf_sub Sort Prop
1628+
with wf_sub_eq_mut_ind3 := Induction for wf_sub_eq Sort Prop
1629+
with wf_subtyp_mut_ind3 := Induction for wf_subtyp Sort Prop.
1630+
Combined Scheme syntactic_wf_mut_ind3 from
1631+
wf_ctx_sub_mut_ind3,
1632+
wf_exp_mut_ind3,
1633+
wf_exp_eq_mut_ind3,
1634+
wf_sub_mut_ind3,
1635+
wf_sub_eq_mut_ind3,
1636+
wf_subtyp_mut_ind3.
1637+
1638+
Lemma ctx_lookup_weakening : forall {Γ A x Γ'},
1639+
{{ # x : A ∈ Γ }} ->
1640+
{{ # x : A ∈ Γ',++Γ }}.
1641+
Proof.
1642+
induction 1; mauto 3.
1643+
Qed.
1644+
1645+
#[export]
1646+
Hint Resolve ctx_lookup_weakening : mctt.
1647+
1648+
Lemma wf_weakening_ctx :
1649+
(forall Δ Γ Γ', {{ Δ ⊢ Γ ⊆ Γ' }} -> forall Γ1, {{ ⊢ Δ ;; ^(Γ ++ Γ1) }} -> {{ Δ ⊢ ^(Γ ++ Γ1) ⊆ ^(Γ' ++ Γ1) }}) /\
1650+
(forall Δ Γ A M, {{ Δ ;; Γ ⊢ M : A }} -> forall Γ', {{ ⊢ Δ ;; ^(Γ ++ Γ') }} -> {{ Δ ;; ^(Γ ++ Γ') ⊢ M : A }}) /\
1651+
(forall Δ Γ A M M', {{ Δ ;; Γ ⊢ M ≈ M' : A }} -> forall Γ', {{ ⊢ Δ ;; ^(Γ ++ Γ') }} -> {{ Δ ;; ^(Γ ++ Γ') ⊢ M ≈ M' : A }}) /\
1652+
(forall Δ Γ Γ' σ, {{ Δ;; Γ ⊢s σ : Γ' }} -> forall Γ1, {{ ⊢ Δ ;; ^(Γ ++ Γ1) }} -> {{ Δ ;; ^(Γ ++ Γ1) ⊢s σ : ^(Γ' ++ Γ1)}}) /\
1653+
(forall Δ Γ Γ' σ σ', {{ Δ;; Γ ⊢s σ ≈ σ' : Γ' }} -> forall Γ1, {{ ⊢ Δ ;; ^(Γ ++ Γ1) }} -> {{ Δ ;; ^(Γ ++ Γ1) ⊢s σ ≈ σ' : ^(Γ' ++ Γ1) }}) /\
1654+
(forall Δ Γ A A', {{ Δ ;; Γ ⊢ A ⊆ A' }} -> forall Γ', {{ ⊢ Δ ;; ^(Γ ++ Γ') }} -> {{ Δ ;; ^(Γ ++ Γ') ⊢ A ⊆ A' }}).
1655+
Proof.
1656+
apply syntactic_wf_mut_ind3; intros; mauto 4;
1657+
try solve [econstructor; mauto 4].
1658+
- inversion_clear H3; simpl.
1659+
eapply wf_ctx_sub_extend with (i:=max i0 i); mauto 3.
1660+
eapply lift_exp_max_left; mauto 4.
1661+
eapply lift_exp_max_right; mauto 4.
1662+
- econstructor; mauto 4.
1663+
eapply H1; mauto 4.
1664+
simpl. mauto 4.
1665+
econstructor; mauto 4.
1666+
- econstructor; mauto 3.
1667+
assert {{ Δ;; Γ',++Γ, A, A[Wk] ⊢ Eq A[Wk∘Wk] #1 #0 : Type@i }} by (eapply presub_exp_eq_helper; eauto 3).
1668+
eapply H2; mauto 4.
1669+
eapply H3; mauto 4.
1670+
- econstructor; mauto 4.
1671+
simpl. eapply H2.
1672+
econstructor; mauto 4.
1673+
- econstructor; mauto 4.
1674+
eapply H2.
1675+
econstructor; mauto 4.
1676+
- econstructor; mauto 4.
1677+
eapply H1. econstructor; mauto 4.
1678+
- econstructor; mauto 4.
1679+
eapply H1. econstructor; mauto 4.
1680+
- econstructor; mauto 4.
1681+
eapply H1.
1682+
econstructor; mauto 4.
1683+
- econstructor; mauto 4.
1684+
eapply H1.
1685+
econstructor; mauto 4.
1686+
- econstructor; mauto 4.
1687+
eapply H1.
1688+
econstructor; mauto 4.
1689+
- econstructor; mauto 4.
1690+
eapply H1.
1691+
econstructor; mauto 4.
1692+
- econstructor; mauto 4.
1693+
eapply H1.
1694+
econstructor; mauto 4.
1695+
- econstructor; mauto 4.
1696+
assert {{ Δ;; Γ'0,++Γ', A, A[Wk] ⊢ Eq A[Wk∘Wk] #1 #0 : Type@i }} by (eapply presub_exp_eq_helper; mauto 5).
1697+
eapply H3; mauto 3.
1698+
eapply H4; mauto 4.
1699+
econstructor; mauto 4.
1700+
- econstructor; mauto 4.
1701+
assert {{ Δ;; Γ',++Γ, A, A[Wk] ⊢ Eq A[Wk∘Wk] #1 #0 : Type@i }} by (eapply presub_exp_eq_helper; mauto 5).
1702+
eapply H5; mauto 4.
1703+
- econstructor; mauto 3.
1704+
assert {{ Δ;; Γ',++Γ, A, A[Wk] ⊢ Eq A[Wk∘Wk] #1 #0 : Type@i }} by (eapply presub_exp_eq_helper; mauto 5).
1705+
eapply H1; mauto 3.
1706+
eapply H2; mauto 3.
1707+
- eapply wf_exp_eq_sub_cong with (Γ':=Γ' ++ Γ'0); mauto 4.
1708+
- eapply wf_exp_eq_sub_compose with (Γ'':=Γ''++Γ'0); mauto 3.
1709+
eapply H0; mauto 3.
1710+
eapply H1; mauto 5.
1711+
- econstructor; mauto 5.
1712+
- eapply wf_sub_eq_compose_assoc with (Γ3:=Γ3++Γ0); mauto 4.
1713+
assert {{ ⊢ Δ;; Γ0,++Γ3 }} by mauto 4.
1714+
assert {{ ⊢ Δ;; Γ0,++Γ2 }} by mauto 4.
1715+
mauto 4.
1716+
- econstructor; mauto 4. eapply H0.
1717+
apply H2 in H3 as H3'. mauto 4.
1718+
- eapply wf_sub_eq_subtyp; mauto 5.
1719+
Qed.
16051720

16061721
(** *** Consistency Helper *)
16071722

@@ -1616,7 +1731,8 @@ Proof.
16161731
autoinjections;
16171732
intuition.
16181733
inversion_by_head ctx_lookup.
1619-
Admitted.
1734+
inversion_by_head gctx_lookup.
1735+
Qed.
16201736

16211737
#[export]
16221738
Hint Resolve no_closed_neutral : mctt.

theories/_CoqProject

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# ./Algorithmic/Typing.v
99
# ./Algorithmic/Typing/Definitions.v
1010
# ./Algorithmic/Typing/Lemmas.v
11-
# ./Core/Base.v
11+
./Core/Base.v
1212
# ./Core/Completeness.v
1313
# ./Core/Completeness/Consequences/Rules.v
1414
# ./Core/Completeness/Consequences/Types.v

0 commit comments

Comments
 (0)