-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename a constructor * Remove duplicated inversion theorems * Add an inversion theorem unexpectedly syntactic * Rearrange completeness consequences in a clearer structure
- Loading branch information
Showing
8 changed files
with
222 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
From Coq Require Import RelationClasses. | ||
From Mcltt Require Import Base LibTactics. | ||
From Mcltt.Core Require Import Completeness Completeness.FundamentalTheorem Completeness.LogicalRelation Semantic.Realizability. | ||
From Mcltt.Core Require Export SystemOpt. | ||
Import Domain_Notations. | ||
|
||
Lemma exp_eq_typ_implies_eq_level : forall {Γ i j k}, | ||
{{ Γ ⊢ Type@i ≈ Type@j : Type@k }} -> | ||
i = j. | ||
Proof with mautosolve. | ||
intros * H. | ||
assert {{ Γ ⊨ Type@i ≈ Type@j : Type@k }} as [env_relΓ] by eauto using completeness_fundamental_exp_eq. | ||
destruct_conjs. | ||
assert (exists p p', initial_env Γ p /\ initial_env Γ p' /\ {{ Dom p ≈ p' ∈ env_relΓ }}) as [p [? [? []]]] by eauto using per_ctx_then_per_env_initial_env. | ||
functional_initial_env_rewrite_clear. | ||
(on_all_hyp: destruct_rel_by_assumption env_relΓ). | ||
destruct_by_head rel_typ. | ||
invert_rel_typ_body. | ||
destruct_by_head rel_exp. | ||
invert_rel_typ_body. | ||
destruct_conjs. | ||
match_by_head1 per_univ_elem invert_per_univ_elem. | ||
reflexivity. | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve exp_eq_typ_implies_eq_level : mcltt. | ||
|
||
Theorem not_exp_eq_typ_nat : forall Γ i j, | ||
~ {{ Γ ⊢ ℕ ≈ Type@i : Type@j }}. | ||
Proof. | ||
intros ** ?. | ||
assert {{ Γ ⊨ ℕ ≈ Type@i : Type@j }} as [env_relΓ] by mauto using completeness_fundamental_exp_eq. | ||
destruct_conjs. | ||
assert (exists p p', initial_env Γ p /\ initial_env Γ p' /\ {{ Dom p ≈ p' ∈ env_relΓ }}) by mauto using per_ctx_then_per_env_initial_env. | ||
destruct_conjs. | ||
functional_initial_env_rewrite_clear. | ||
(on_all_hyp: destruct_rel_by_assumption env_relΓ). | ||
destruct_by_head rel_typ. | ||
invert_rel_typ_body. | ||
destruct_by_head rel_exp. | ||
invert_rel_typ_body. | ||
destruct_conjs. | ||
match_by_head1 per_univ_elem invert_per_univ_elem. | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve not_exp_eq_typ_nat : mcltt. | ||
|
||
Theorem not_exp_eq_typ_pi : forall Γ i A B j, | ||
~ {{ Γ ⊢ Π A B ≈ Type@i : Type@j }}. | ||
Proof. | ||
intros ** ?. | ||
assert {{ Γ ⊨ Π A B ≈ Type@i : Type@j }} as [env_relΓ] by mauto using completeness_fundamental_exp_eq. | ||
destruct_conjs. | ||
assert (exists p p', initial_env Γ p /\ initial_env Γ p' /\ {{ Dom p ≈ p' ∈ env_relΓ }}) by mauto using per_ctx_then_per_env_initial_env. | ||
destruct_conjs. | ||
functional_initial_env_rewrite_clear. | ||
(on_all_hyp: destruct_rel_by_assumption env_relΓ). | ||
destruct_by_head rel_typ. | ||
invert_rel_typ_body. | ||
destruct_by_head rel_exp. | ||
invert_rel_typ_body. | ||
destruct_conjs. | ||
match_by_head1 per_univ_elem invert_per_univ_elem. | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve not_exp_eq_typ_pi : mcltt. | ||
|
||
Lemma typ_subsumption_spec : forall {Γ A A'}, | ||
{{ Γ ⊢ A ⊆ A' }} -> | ||
{{ ⊢ Γ }} /\ exists j, {{ Γ ⊢ A ≈ A' : Type@j }} \/ exists i i', i < i' /\ {{ Γ ⊢ Type@i ≈ A : Type@j }} /\ {{ Γ ⊢ A' ≈ Type@i' : Type@j }}. | ||
Proof. | ||
intros * H. | ||
dependent induction H; split; mauto 3. | ||
- (* typ_subsumption_typ *) | ||
eexists. | ||
right. | ||
do 2 eexists. | ||
repeat split; revgoals; mauto. | ||
- (* typ_subsumption_trans *) | ||
destruct IHtyp_subsumption1 as [? [? [| [i1 [i1']]]]]; destruct IHtyp_subsumption2 as [? [? [| [i2 [i2']]]]]; | ||
destruct_conjs; | ||
only 1: mautosolve 4; | ||
eexists; right; do 2 eexists. | ||
+ (* left & right *) | ||
split; [eassumption |]. | ||
solve [mauto using lift_exp_eq_max_left]. | ||
+ (* right & left *) | ||
split; [eassumption |]. | ||
solve [mauto using lift_exp_eq_max_right]. | ||
+ exvar nat ltac:(fun j => assert {{ Γ ⊢ Type@i2 ≈ Type@i1' : Type@j }} by mauto). | ||
replace i2 with i1' in * by mauto. | ||
split; [etransitivity; revgoals; eassumption |]. | ||
mauto 4 using lift_exp_eq_max_left, lift_exp_eq_max_right. | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve typ_subsumption_spec : mcltt. | ||
|
||
Lemma typ_subsumption_typ_spec : forall {Γ i i'}, | ||
{{ Γ ⊢ Type@i ⊆ Type@i' }} -> | ||
{{ ⊢ Γ }} /\ i <= i'. | ||
Proof with mautosolve. | ||
intros * [? [j [| [i0 [i0']]]]]%typ_subsumption_spec. | ||
- (* when lhs is equivalent to rhs *) | ||
replace i with i' in *... | ||
- (* when lhs is (strictly) subsumed by rhs *) | ||
destruct_conjs. | ||
(on_all_hyp: fun H => apply exp_eq_typ_implies_eq_level in H); subst. | ||
split; [| lia]... | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve typ_subsumption_typ_spec : mcltt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
From Coq Require Import Setoid. | ||
From Mcltt Require Import Base LibTactics. | ||
From Mcltt.Core Require Export System. | ||
Import Syntax_Notations. | ||
|
||
Lemma wf_univ_inversion : forall {Γ i A}, | ||
{{ Γ ⊢ Type@i : A }} -> | ||
{{ Γ ⊢ Type@(S i) ⊆ A }}. | ||
Proof. | ||
intros * H. | ||
dependent induction H; mautosolve. | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve wf_univ_inversion : mcltt. | ||
|
||
Lemma wf_nat_inversion : forall Γ A, | ||
{{ Γ ⊢ ℕ : A }} -> | ||
{{ Γ ⊢ Type@0 ⊆ A }}. | ||
Proof. | ||
intros * H. | ||
assert (forall i, 0 <= i) by lia. | ||
dependent induction H; mautosolve 4. | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve wf_nat_inversion : mcltt. | ||
|
||
Lemma wf_pi_inversion : forall {Γ A B C}, | ||
{{ Γ ⊢ Π A B : C }} -> | ||
exists i, {{ Γ ⊢ A : Type@i }} /\ {{ Γ, A ⊢ B : Type@i }} /\ {{ Γ ⊢ Type@i ⊆ C }}. | ||
Proof. | ||
intros * H. | ||
dependent induction H; assert {{ ⊢ Γ }} by mauto 3; try solve [eexists; mauto 4]; | ||
specialize (IHwf_exp _ _ eq_refl); destruct_conjs; eexists; repeat split; mauto 3. | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve wf_pi_inversion : mcltt. | ||
|
||
Corollary wf_pi_inversion' : forall {Γ A B i}, | ||
{{ Γ ⊢ Π A B : Type@i }} -> | ||
{{ Γ ⊢ A : Type@i }} /\ {{ Γ, A ⊢ B : Type@i }}. | ||
Proof with mautosolve 4. | ||
intros * [j [? []]]%wf_pi_inversion. | ||
assert {{ Γ, A ⊢s Wk : Γ }} by mauto 4. | ||
assert {{ Γ, A ⊢ Type@j ⊆ Type@j[Wk] }} by mauto 4. | ||
assert {{ Γ, A ⊢ Type@j[Wk] ⊆ Type@i[Wk] }} by mauto 4. | ||
assert {{ Γ, A ⊢ Type@i[Wk] ⊆ Type@i }} by mauto 4. | ||
assert {{ Γ, A ⊢ Type@j ⊆ Type@i }}... | ||
Qed. | ||
|
||
#[export] | ||
Hint Resolve wf_pi_inversion' : mcltt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.