module Definition.Untyped.Properties.NotParametrised where
open import Definition.Untyped.NotParametrised
open import Tools.Fin
open import Tools.Function
open import Tools.Nat
open import Tools.Relation
open import Tools.PropositionalEquality
private variable
ℓ m n : Nat
ρ ρ′ : Wk _ _
x y : Fin _
wkVar-lift : (∀ x → wkVar ρ x ≡ wkVar ρ′ x)
→ (∀ x → wkVar (lift ρ) x ≡ wkVar (lift ρ′) x)
wkVar-lift eq x0 = refl
wkVar-lift eq (x +1) = cong _+1 (eq x)
wkVar-lifts : (∀ x → wkVar ρ x ≡ wkVar ρ′ x)
→ (∀ n x → wkVar (liftn ρ n) x ≡ wkVar (liftn ρ′ n) x)
wkVar-lifts eq 0 x = eq x
wkVar-lifts eq (1+ n) x = wkVar-lift (wkVar-lifts eq n) x
wkVar-lift-id : (x : Fin (1+ n)) → wkVar (lift id) x ≡ wkVar id x
wkVar-lift-id x0 = refl
wkVar-lift-id (x +1) = refl
wkVar-lifts-id : (n : Nat) (x : Fin (n + m)) → wkVar (liftn id n) x ≡ wkVar id x
wkVar-lifts-id 0 x = refl
wkVar-lifts-id (1+ n) x0 = refl
wkVar-lifts-id (1+ n) (x +1) = cong _+1 (wkVar-lifts-id n x)
wkVar-id : (x : Fin n) → wkVar id x ≡ x
wkVar-id x = refl
wkVar-comp : (ρ : Wk m ℓ) (ρ′ : Wk ℓ n) (x : Fin n) → wkVar ρ (wkVar ρ′ x) ≡ wkVar (ρ • ρ′) x
wkVar-comp id ρ′ x = refl
wkVar-comp (step ρ) ρ′ x = cong _+1 (wkVar-comp ρ ρ′ x)
wkVar-comp (lift ρ) id x = refl
wkVar-comp (lift ρ) (step ρ′) x = cong _+1 (wkVar-comp ρ ρ′ x)
wkVar-comp (lift ρ) (lift ρ′) x0 = refl
wkVar-comp (lift ρ) (lift ρ′) (x +1) = cong _+1 (wkVar-comp ρ ρ′ x)
wkVar-comps : ∀ k → (ρ : Wk m ℓ) (ρ′ : Wk ℓ n) (x : Fin (k + n))
→ wkVar (liftn ρ k • liftn ρ′ k) x
≡ wkVar (liftn (ρ • ρ′) k) x
wkVar-comps 0 ρ ρ′ x = refl
wkVar-comps (1+ n) ρ ρ′ x0 = refl
wkVar-comps (1+ n) ρ ρ′ (x +1) = cong _+1 (wkVar-comps n ρ ρ′ x)
opaque
•-id : ρ • id ≡ ρ
•-id {ρ = id} = refl
•-id {ρ = step _} = cong step •-id
•-id {ρ = lift _} = refl
opaque
liftn-wk₀-•-wk₀ : ∀ n → liftn {k = m} wk₀ n • wk₀ ≡ wk₀
liftn-wk₀-•-wk₀ 0 = •-id
liftn-wk₀-•-wk₀ (1+ n) = cong step $ liftn-wk₀-•-wk₀ n
lift-step-comp : (ρ : Wk m n) → step id • ρ ≡ lift ρ • step id
lift-step-comp id = refl
lift-step-comp (step ρ) = cong step (lift-step-comp ρ)
lift-step-comp (lift ρ) = refl
opaque
wkVar-injective : wkVar ρ x ≡ wkVar ρ y → x ≡ y
wkVar-injective = lemma _ _ _
where
lemma : ∀ (ρ : Wk m n) x y → wkVar ρ x ≡ wkVar ρ y → x ≡ y
lemma ρ x0 x0 =
wkVar ρ x0 ≡ wkVar ρ x0 →⟨ (λ _ → refl) ⟩
x0 ≡ x0 □
lemma id (x +1) (y +1) =
(x +1) ≡ (y +1) □
lemma (lift ρ) (x +1) (y +1) =
(wkVar ρ x +1) ≡ (wkVar ρ y +1) →⟨ suc-injective ⟩
wkVar ρ x ≡ wkVar ρ y →⟨ wkVar-injective ⟩
x ≡ y →⟨ cong _+1 ⟩
x +1 ≡ y +1 □
lemma (step ρ) x y =
(wkVar ρ x +1) ≡ (wkVar ρ y +1) →⟨ suc-injective ⟩
wkVar ρ x ≡ wkVar ρ y →⟨ wkVar-injective ⟩
x ≡ y □
lemma id x0 (_ +1) ()
lemma id (_ +1) x0 ()
lemma (lift _) x0 (_ +1) ()
lemma (lift _) (_ +1) x0 ()
decStrength : Decidable (_≡_ {A = Strength})
decStrength 𝕤 𝕤 = yes refl
decStrength 𝕤 𝕨 = no λ{()}
decStrength 𝕨 𝕤 = no λ{()}
decStrength 𝕨 𝕨 = yes refl
decBinderMode : Decidable (_≡_ {A = BinderMode})
decBinderMode = λ where
BMΠ BMΠ → yes refl
BMΠ (BMΣ _) → no (λ ())
(BMΣ _) BMΠ → no (λ ())
(BMΣ s₁) (BMΣ s₂) → case decStrength s₁ s₂ of λ where
(yes refl) → yes refl
(no s₁≢s₂) → no λ where
refl → s₁≢s₂ refl