11(** * LogRel.Syntax.Weakening: definition of well-formed weakenings, and some properties. *)
22From Stdlib Require Import Lia ssrbool.
3+ From Equations Require Import Equations.
34From LogRel Require Import Utils AutoSubst.Extra Notations.
45From LogRel.Syntax Require Import BasicAst Context NormalForms.
56
@@ -14,6 +15,8 @@ Inductive weakening : Set :=
1415 | _wk_step (w : weakening) : weakening
1516 | _wk_up (w : weakening) : weakening.
1617
18+ Equations Derive NoConfusion EqDec for weakening.
19+
1720Fixpoint _wk_id (Γ : context) : weakening :=
1821 match Γ with
1922 | nil => _wk_empty
@@ -87,6 +90,18 @@ Inductive well_weakening : weakening -> context -> context -> Type :=
8790 | well_up {Γ Δ : context} (A : term) (ρ : weakening) :
8891 well_weakening ρ Γ Δ -> well_weakening (_wk_up ρ) (Γ,, A⟨ρ⟩) (Δ,, A).
8992
93+ Derive Signature for well_weakening.
94+
95+ Lemma well_wk_irr : forall ρ Γ Δ (w1 w2 : well_weakening ρ Γ Δ), w1 = w2.
96+ Proof .
97+ induction w1.
98+ + now depelim w2.
99+ + now depelim w2; now f_equal.
100+ + depelim w2.
101+ replace e' with (@eq_refl _ (A⟨ρ⟩)) in H by apply eqdec_uip, term_EqDec.
102+ cbn in H; rewrite H; now f_equal.
103+ Qed .
104+
90105Lemma well_wk_id (Γ : context) : well_weakening (_wk_id Γ) Γ Γ.
91106Proof .
92107 induction Γ as [|d].
@@ -121,6 +136,13 @@ Arguments wk_well_wk : clear implicits.
121136Arguments Build_wk_well_wk : clear implicits.
122137Notation "Γ ≤ Δ" := (wk_well_wk Γ Δ).
123138
139+ Lemma wk_well_wk_wk_eq : forall Γ Δ (ρ1 ρ2 : Γ ≤ Δ),
140+ ρ1.(wk) = ρ2.(wk) -> ρ1 = ρ2.
141+ Proof .
142+ intros Γ Δ [ρ1 w1] [ρ2 w2]; cbn; intros <-.
143+ assert (e : w1 = w2) by apply well_wk_irr; now destruct e.
144+ Qed .
145+
124146#[global] Hint Resolve well_wk : core.
125147
126148(** ** Instance: how to rename by a well-formed weakening. *)
@@ -430,15 +452,46 @@ Lemma wk_idElim {A x P hr y e Δ Γ} (ρ : Δ ≤ Γ) :
430452 tIdElim A⟨ρ⟩ x⟨ρ⟩ P⟨wk_up (tId A⟨@wk1 Γ A⟩ x⟨@wk1 Γ A⟩ (tRel 0)) (wk_up A ρ)⟩ hr⟨ρ⟩ y⟨ρ⟩ e⟨ρ⟩ = (tIdElim A x P hr y e)⟨ρ⟩.
431453Proof . now cbn. Qed .
432454
433- Lemma wk_comp_lunit {Γ Δ} (ρ : Δ ≤ Γ) : wk_id ∘w ρ =1 ρ.
434- Proof . now bsimpl. Qed .
455+ Lemma wk_to_ren_inj : forall Γ Δ (ρ1 ρ2 : Γ ≤ Δ), wk_to_ren ρ1 =1 wk_to_ren ρ2 -> ρ1 = ρ2.
456+ Proof .
457+ intros * Heq; apply wk_well_wk_wk_eq.
458+ destruct ρ1 as [ρ1 wρ1], ρ2 as [ρ2 wρ2]; cbn in *.
459+ revert Γ Δ wρ1 ρ2 wρ2 Heq.
460+ induction ρ1; intros Γ Δ wρ1 ρ2 wρ2 Heq; cbn in *.
461+ + destruct ρ2; cbn in *; first [reflexivity|exfalso].
462+ - specialize (Heq 0); discriminate Heq.
463+ - depelim wρ1; depelim wρ2.
464+ + destruct ρ2; cbn in *; first [apply f_equal|exfalso].
465+ - specialize (Heq 0); discriminate Heq.
466+ - depelim wρ1; depelim wρ2.
467+ eapply IHρ1; tea.
468+ intros n; specialize (Heq n).
469+ now injection Heq.
470+ - specialize (Heq 0); discriminate Heq.
471+ + destruct ρ2; cbn in *; first [apply f_equal|exfalso].
472+ - depelim wρ1; depelim wρ2.
473+ - specialize (Heq 0); discriminate Heq.
474+ - depelim wρ1; depelim wρ2.
475+ eapply IHρ1; tea.
476+ intros n; specialize (Heq (S n)); cbn in Heq.
477+ now injection Heq.
478+ Qed .
435479
436- Lemma wk_comp_runit {Γ Δ} (ρ : Δ ≤ Γ) : ρ ∘w wk_id =1 ρ.
437- Proof . now bsimpl. Qed .
480+ Lemma wk_comp_lunit {Γ Δ} (ρ : Δ ≤ Γ) : wk_id ∘w ρ = ρ.
481+ Proof .
482+ apply wk_to_ren_inj; now bsimpl.
483+ Qed .
484+
485+ Lemma wk_comp_runit {Γ Δ} (ρ : Δ ≤ Γ) : ρ ∘w wk_id = ρ.
486+ Proof .
487+ apply wk_to_ren_inj; now bsimpl.
488+ Qed .
438489
439490Lemma wk_comp_assoc {Γ Δ Ξ ζ} (ρ : Δ ≤ Γ) (ρ' : Ξ ≤ Δ) (ρ'' : ζ ≤ Ξ) :
440- (ρ'' ∘w ρ') ∘w ρ =1 ρ'' ∘w (ρ' ∘w ρ).
441- Proof . now bsimpl. Qed .
491+ (ρ'' ∘w ρ') ∘w ρ = ρ'' ∘w (ρ' ∘w ρ).
492+ Proof .
493+ apply wk_to_ren_inj; now bsimpl.
494+ Qed .
442495
443496Lemma wk1_irr {Γ Γ' A A' t} : t⟨@wk1 Γ A⟩ = t⟨@wk1 Γ' A'⟩.
444497Proof . intros; now rewrite 2!wk1_ren_on. Qed .
0 commit comments