Theorems 7–9 & Lemmas 3–5 (V5): Signature Encoding, Pattern/Spine Elaboration, and Rigid Variable Polarities
ProvedNishtAbel2024V5.theorems_7_8_9_and_lemmas_3_4_5Establishes the soundness and polarity invariants of signature encoding and (co)pattern spine elaboration in Chapter 6, Sections 6.1–6.2 (pp. 42–47) of Nisht and Abel (2024):\n\n1. Theorem 7 — Well-Kindedness of Signature Encoding: If an unsized type is well-kinded ( in EKinding) and , then is a well-formed size context (SizeCtxWf Ψ) and .\n2. Lemma 3 — Exclusive Polarity of Encoded Signature Parameters: For any signature encoding , every generated size parameter occurs exclusively either negatively as an inductive () size index with and no -occurrences, or positively as a coinductive () size index with and no -occurrences.\n3. Theorems 8 & 9 — Soundness of Pattern and Copattern Spine Elaboration: Algorithmic pattern inference InferPat implies declarative PatTy, and algorithmic copattern spine inference InferSpine implies declarative SpineTy.\n4. Lemmas 4 & 5 — Rigid Variable Polarities in Elaborated Contexts: Every size variable introduced by InferPat or InferSpine has a rigid (even) name; pattern elaboration introduces only -occurrences in the pattern context ; and for an encoded signature type whose parameters are disjoint from the spine-bound rigid variables , each preserves its exclusive -only or -only occurrence discipline across both the elaborated term context and the residual target type .
import Definitions.Def_NishtAbel2024V5_Syntax import Definitions.Def_NishtAbel2024V5_Semantics import Definitions.Def_NishtAbel2024V5_Inference
namespace NishtAbel2024V5
theorem theorems_7_8_9_and_lemmas_3_4_5 :
(∀ {πs : Pol} {ok : Nat → Prop} {π : Pol} {Δ : KCtx} {Δb : BCtx} {A A' : Ty} {Ψ : SizeCtx}
{κ : Kind},
EKinding Δ Δb A κ →
Encode πs ok π Δ Δb A Ψ A' →
SizeCtxWf Ψ ∧ Kinding Ψ Δ Δb 0 A' κ) ∧
(∀ {ok : Nat → Prop} {Δ : KCtx} {Δb : BCtx} {A A' : Ty} {Ψ : SizeCtx},
Encode .neg ok .pos Δ Δb A Ψ A' →
∀ i ∈ Ψ.dom,
(SizeOcc .mu i Δ Δb .neg A' ∧ paramPol A' i = .pos ∧
(∀ Δ' Δb' q, ¬ SizeOcc .nu i Δ' Δb' q A')) ∨
(SizeOcc .nu i Δ Δb .pos A' ∧ paramPol A' i = .neg ∧
(∀ Δ' Δb' q, ¬ SizeOcc .mu i Δ' Δb' q A'))) ∧
(∀ {Ψ : SizeCtx} {Θ : TyCtx} {p : Pat} {A : Ty} {Γ : TermCtx} {Ψ' : SizeCtx} {Θ' : TyCtx},
InferPat Ψ Θ p A Γ Ψ' Θ' →
PatTy Ψ Θ p A Γ Ψ' Θ') ∧
(∀ {Ψ : SizeCtx} {Θ : TyCtx} {qs : List Copat} {A : Ty} {Γ : TermCtx} {Ψ' : SizeCtx}
{Θ' : TyCtx} {C : Ty},
InferSpine Ψ Θ qs A Γ Ψ' Θ' C →
SpineTy Ψ Θ qs A Γ Ψ' Θ' C) ∧
(∀ {Ψ : SizeCtx} {Θ : TyCtx} {p : Pat} {A : Ty} {Γ : TermCtx} {Ψ' : SizeCtx} {Θ' : TyCtx},
InferPat Ψ Θ p A Γ Ψ' Θ' →
(∀ q ∈ Ψ', RigidName q.1) ∧
(∀ {fk : FixKind} {i : Nat} {Δ : KCtx} {Δb : BCtx} {π : Pol} {xB : Nat × Ty},
xB ∈ Γ → SizeOcc fk i Δ Δb π xB.2 → A.indexes fk i = true ∨ (fk = .mu ∧ i ∈ Ψ'.dom)) ∧
(∀ j ∈ Ψ'.dom, A.indexes .nu j = false →
∀ xB ∈ Γ, ∀ Δ Δb π, ¬ SizeOcc .nu j Δ Δb π xB.2)) ∧
(∀ {Ψ : SizeCtx} {Θ : TyCtx} {qs : List Copat} {A : Ty} {Γ : TermCtx} {Ψ' : SizeCtx}
{Θ' : TyCtx} {C : Ty},
InferSpine Ψ Θ qs A Γ Ψ' Θ' C →
(∀ i ∈ Ψ'.dom, RigidName i) ∧
(∀ {fk : FixKind} {i : Nat} {Δ : KCtx} {Δb : BCtx} {π : Pol},
((∃ xB ∈ Γ, SizeOcc fk i Δ Δb π xB.2) ∨ SizeOcc fk i Δ Δb π C) →
A.indexes fk i = true ∨ i ∈ Ψ'.dom) ∧
(∀ {ok : Nat → Prop} {Δ₀ : KCtx} {Δb₀ : BCtx} {A₀ : Ty},
Encode .neg ok .pos Δ₀ Δb₀ A₀ Ψ A →
NamesDisjoint Ψ.dom Ψ'.dom →
∀ i ∈ Ψ.dom,
(paramPol A i = .pos ∧
(∀ xB ∈ Γ, ∀ Δ Δb π, ¬ SizeOcc .nu i Δ Δb π xB.2) ∧
(∀ Δ Δb π, ¬ SizeOcc .nu i Δ Δb π C)) ∨
(paramPol A i = .neg ∧
(∀ xB ∈ Γ, ∀ Δ Δb π, ¬ SizeOcc .mu i Δ Δb π xB.2) ∧
(∀ Δ Δb π, ¬ SizeOcc .mu i Δ Δb π C)))) := by sorry
end NishtAbel2024V5