LogRel.Algorithmic.Strengthening: proof of the strengthening property for algorithmic conversions.
From LogRel Require Import Utils Syntax.All GenericTyping DeclarativeTyping AlgorithmicJudgments.
From LogRel.TypingProperties Require Import DeclarativeProperties PropertiesDefinition SubstConsequences TypeInjectivityConsequences NeutralConvProperties NormalisationDefinition.
From LogRel.Algorithmic Require Import Bundled.
Import DeclarativeTypingProperties AlgorithmicTypedConvData BundledTypingData.
From LogRel.TypingProperties Require Import DeclarativeProperties PropertiesDefinition SubstConsequences TypeInjectivityConsequences NeutralConvProperties NormalisationDefinition.
From LogRel.Algorithmic Require Import Bundled.
Import DeclarativeTypingProperties AlgorithmicTypedConvData BundledTypingData.
Section ConvStr.
Let PTyEq (Γ : context) (A B : term) := forall Δ (ρ : Γ ≤ Δ) A' B',
A = A'⟨ρ⟩ -> B = B'⟨ρ⟩ ->
[Δ |-[al] A' ≅ B'].
Let PTyRedEq (Γ : context) (A B : term) := forall Δ (ρ : Γ ≤ Δ) A' B',
A = A'⟨ρ⟩ -> B = B'⟨ρ⟩ ->
[Δ |-[al] A' ≅h B'].
Let PNeEq (Γ : context) (A t u : term) := forall Δ (ρ : Γ ≤ Δ) t' u',
t = t'⟨ρ⟩ -> u = u'⟨ρ⟩ ->
∑ A', A = A'⟨ρ⟩ × [Δ |-[al] t' ~ u' ▹ A'].
Let PNeRedEq (Γ : context) (A t u : term) := forall Δ (ρ : Γ ≤ Δ) t' u',
t = t'⟨ρ⟩ -> u = u'⟨ρ⟩ ->
∑ A', A = A'⟨ρ⟩ × [Δ |-[al] t' ~h u' ▹ A'].
Let PTmEq (Γ : context) (A t u : term) := forall Δ (ρ : Γ ≤ Δ) t' u' A',
A = A'⟨ρ⟩ -> t = t'⟨ρ⟩ -> u = u'⟨ρ⟩ ->
[Δ |-[al] t' ≅ u' : A'].
Let PTmRedEq (Γ : context) (A t u : term) := forall Δ (ρ : Γ ≤ Δ) t' u' A',
A = A'⟨ρ⟩ -> t = t'⟨ρ⟩ -> u = u'⟨ρ⟩ ->
[Δ |-[al] t' ≅h u' : A'].
#[local] Ltac push_renaming :=
repeat match goal with
| eq : _ = ?t⟨_⟩ |- _ =>
destruct t ; cbn in * ; try solve [congruence] ;
inversion eq ; subst ; clear eq
end.
Theorem algo_conv_str :
AlgoConvInductionConcl PTyEq PTyRedEq
PNeEq PNeRedEq PTmEq PTmRedEq.
Proof.
subst PTyEq PTyRedEq PNeEq PNeRedEq PTmEq PTmRedEq.
apply AlgoConvInduction.
- intros * Hred Hred' ? IH * -> ->.
eapply credalg_str in Hred as [? [->]], Hred' as [? [->]].
econstructor ; tea.
now eapply IH.
- intros * ? IHA ? IHB ? **.
push_renaming.
econstructor.
+ now eapply IHA.
+ now eapply IHB with(ρ := wk_up _ ρ).
- intros ; push_renaming.
econstructor.
- intros ; push_renaming.
now econstructor.
- intros ; push_renaming.
now econstructor.
- intros * ? IHA ? IHB ? * ??.
push_renaming.
econstructor.
+ now eapply IHA.
+ now eapply IHB with (ρ := wk_up _ ρ).
- intros * ? IHA ? IHa ? IHa' **.
push_renaming.
econstructor.
+ eapply IHA ; reflexivity.
+ eapply IHa ; reflexivity.
+ eapply IHa' ; reflexivity.
- intros * ?? ? IH ** ; subst.
edestruct IH as [? [->]].
1-2 : reflexivity.
econstructor ; tea.
all: now eapply whne_ren.
- intros * Hin **.
push_renaming.
apply in_ctx_str in Hin as [? [-> ]].
eexists ; split.
1: reflexivity.
eapply section_inj in H1 as ->.
2: eapply section_wk.
now econstructor.
- intros * ? IHm ? IHt **.
push_renaming.
edestruct IHm as [? []].
1-2: reflexivity.
push_renaming.
eexists ; split.
2: econstructor ; tea.
2: eapply IHt.
2-4: reflexivity.
now bsimpl.
- intros * ? IHn ? IHP ? IHz ? IHs **.
push_renaming.
edestruct IHn as [? []].
1-2: reflexivity.
push_renaming.
eexists ; split ; cycle -1.
1: econstructor ; tea.
+ eapply IHP with (ρ := wk_up tNat ρ).
all: reflexivity.
+ eapply IHz.
2-3: reflexivity.
now bsimpl.
+ eapply IHs.
2-3: reflexivity.
unfold elimSuccHypTy ; cbn.
now bsimpl.
+ now bsimpl.
- intros * ? IHn ? IHP **.
push_renaming.
edestruct IHn as [? []].
1-2: reflexivity.
push_renaming.
eexists ; split ; cycle -1.
1: econstructor ; tea.
+ eapply IHP with (ρ := wk_up tEmpty ρ).
all: reflexivity.
+ now bsimpl.
- intros * ? IHm **.
push_renaming.
edestruct IHm as [? []].
1-2: reflexivity.
push_renaming.
eexists ; split.
2: econstructor ; tea.
reflexivity.
- intros * ? IHm **.
push_renaming.
edestruct IHm as [? []].
1-2: reflexivity.
push_renaming.
eexists ; split.
2: econstructor ; tea.
now bsimpl.
- intros * ? IHn ? IHP ? IHe **.
push_renaming.
edestruct IHn as [? []].
1-2: reflexivity.
push_renaming.
eexists ; split ; cycle -1.
1: econstructor ; tea.
+ unshelve eapply IHP.
* unshelve eexists.
1: exact (_wk_up (_wk_up ρ)).
evar (A : term) ; replace (tId _ _ _) with A ; subst A.
1: do 2 eapply well_up ; eauto.
now bsimpl.
* reflexivity.
* reflexivity.
+ eapply IHe.
2-3: reflexivity.
now bsimpl.
+ now bsimpl.
- intros * ? IH red ** ; subst.
edestruct IH as [? []].
1-2: reflexivity.
subst.
eapply credalg_str in red as [? [-> ]].
eexists ; split ; [reflexivity|..].
econstructor ; tea.
now eapply whnf_ren.
- intros * red red' red'' ? IH * -> -> ->.
eapply credalg_str in red as [? [->]], red' as [? [->]], red'' as [? [->]].
now econstructor.
- intros * ? IHA ? IHB **.
push_renaming.
econstructor.
+ eapply IHA ; reflexivity.
+ eapply IHB with (ρ := wk_up _ ρ).
all: reflexivity.
- intros ; push_renaming.
econstructor.
- intros ; push_renaming.
econstructor.
- intros * ? IH **.
push_renaming.
econstructor.
eapply IH.
all: reflexivity.
- intros ; push_renaming.
econstructor.
- intros * ?? ? IH **.
subst.
push_renaming.
econstructor.
1-2: now eapply whnf_ren.
eapply IH with (ρ := wk_up _ ρ).
all: now bsimpl.
- intros * ? IHA ? IHB **.
push_renaming.
econstructor.
+ eapply IHA ; reflexivity.
+ eapply IHB with (ρ := wk_up _ ρ).
all: reflexivity.
- intros * ?? ? IHf ? IHs **.
subst.
push_renaming.
econstructor.
1-2: now eapply whnf_ren.
+ eapply IHf ; reflexivity.
+ eapply IHs.
2-3: reflexivity.
now bsimpl.
- intros * ? IHA ? IHa ? IHa' **.
push_renaming.
econstructor.
+ eapply IHA ; reflexivity.
+ eapply IHa ; reflexivity.
+ eapply IHa' ; reflexivity.
- intros **.
push_renaming.
now econstructor.
- intros * ? IH **.
subst.
edestruct IH as [? [-> ]].
1-2: reflexivity.
econstructor ; tea.
now eapply isPosType_ren.
Qed.
End ConvStr.
Strengthening of untyped conversion
This will be useful in the coming implication, when we get an induction hypothesis that is weakened because of η-expansions.Section UConvStr.
Let PEq (A B : term) := forall Γ Δ (ρ : Γ ≤ Δ) A' B',
A = A'⟨ρ⟩ -> B = B'⟨ρ⟩ ->
[A' ≅ B'].
Let PRedEq (A B : term) := forall Γ Δ (ρ : Γ ≤ Δ) A' B',
A = A'⟨ρ⟩ -> B = B'⟨ρ⟩ ->
[A' ≅h B'].
Let PNeEq (t u : term) := forall Γ Δ (ρ : Γ ≤ Δ) t' u',
t = t'⟨ρ⟩ -> u = u'⟨ρ⟩ ->
[t' ~ u'].
#[local] Ltac push_renaming :=
repeat match goal with
| eq : _ = ?t⟨_⟩ |- _ =>
destruct t ; cbn in * ; try solve [congruence] ;
inversion eq ; subst ; clear eq
end.
Theorem algo_uconv_str :
UAlgoConvInductionConcl PEq PRedEq PNeEq.
Proof.
subst PEq PRedEq PNeEq.
apply UAlgoConvInduction.
- intros * Hred Hred' ? IH * -> ->.
eapply credalg_str in Hred as [? [->]] , Hred' as [? [->]].
now econstructor.
- solve [intros ; push_renaming ; now econstructor].
- intros * ? IHA ? IHB ? **.
push_renaming.
econstructor.
+ now eapply IHA.
+ now unshelve eapply IHB with(ρ := wk_up _ ρ).
- solve [intros ; push_renaming ; now econstructor].
- solve [intros ; push_renaming ; now econstructor].
- intros * ? IH ** ; push_renaming ; econstructor ; now eapply IH.
- solve [intros ; push_renaming ; now econstructor].
- intros * ? IH ** ; push_renaming ; econstructor ; now
unshelve eapply IH with (ρ := wk_up _ ρ).
- intros * ?? IH ** ; subst ; push_renaming ; econstructor.
+ now eapply whne_ren.
+ unshelve eapply IH with (ρ := wk_up _ ρ).
1: assumption.
all: now bsimpl.
- intros * ?? IH ** ; subst ; push_renaming ; econstructor.
+ now eapply whne_ren.
+ unshelve eapply IH with (ρ := wk_up _ ρ).
1: assumption.
all: now bsimpl.
- intros * ? IHA ? IHB ** ; push_renaming ; econstructor.
+ now eapply IHA.
+ unshelve eapply IHB with (ρ := wk_up _ ρ).
1: assumption.
all: now bsimpl.
- intros * ? IHf ? IHs ** ; push_renaming ; econstructor.
+ now eapply IHf.
+ now eapply IHs.
- intros * ?? IHf ? IHs ** ; subst ; push_renaming ; econstructor.
+ now eapply whne_ren.
+ now eapply IHf.
+ now eapply IHs.
- intros * ?? IHf ? IHs ** ; subst ; push_renaming ; econstructor.
+ now eapply whne_ren.
+ now eapply IHf.
+ now eapply IHs.
- intros * ? IHA ? IHa ? IHa' ** ; push_renaming ; econstructor.
+ now eapply IHA.
+ now eapply IHa.
+ now eapply IHa'.
- solve [intros ; push_renaming ; now econstructor].
- intros * ? IH ** ; subst.
econstructor.
now eapply IH.
- intros ; push_renaming.
eapply section_inj in H1 as ->.
2: eapply section_wk.
now econstructor.
- intros * ? IH ? IH' ** ; push_renaming.
econstructor.
+ now eapply IH.
+ now eapply IH'.
- intros * ? IHn ? IHP ? IHz ? IHs ** ; push_renaming.
econstructor.
+ now eapply IHn.
+ unshelve eapply IHP with (ρ := wk_up _ ρ).
1: assumption.
all: now bsimpl.
+ now eapply IHz.
+ now eapply IHs.
- intros * ? IHn ? IHP ** ; push_renaming.
econstructor.
+ now eapply IHn.
+ unshelve eapply IHP with (ρ := wk_up _ ρ).
1: assumption.
all: now bsimpl.
- intros * ? IH ** ; push_renaming.
econstructor.
now eapply IH.
- intros * ? IH ** ; push_renaming.
econstructor.
now eapply IH.
- intros * ? IHn ? IHP ? IHr ** ; push_renaming.
econstructor.
+ now eapply IHn.
+ unshelve eapply IHP with (ρ := wk_up _ (wk_up _ ρ)).
1-2: assumption.
all: now bsimpl.
+ now eapply IHr.
Qed.
End UConvStr.