diff --git a/out/StlcProp.md b/out/StlcProp.md index 627f6b79..d98d62e2 100644 --- a/out/StlcProp.md +++ b/out/StlcProp.md @@ -554,226 +554,226 @@ while for boolean types they are values `true` and `false`. canonicalFormsLemmacanonical-forms : ∀ : ∀ {L A} → ∅ →⊢ ∅L ⊢∶ LA ∶→ A → Value L → L → canonical L for for A canonicalFormsLemmacanonical-forms (Ax ()) (Ax ()) () canonicalFormsLemmacanonical-forms (⇒-I ⊢N) value-λ ⊢N) value-λ = canonical-λ canonicalFormsLemmacanonical-forms (⇒-E ⊢L ⊢M) () +canonical-forms -canonicalFormsLemma 𝔹-I₁ value-true = canonical-true canonicalFormsLemmacanonical-forms 𝔹-I₂ value-false = canonical-false canonicalFormsLemmacanonical-forms (𝔹-E ⊢L ⊢M ⊢N) () @@ -787,191 +787,191 @@ step or it is a value.
-data Progress : Term → Set where + steps : ∀ {M N} Set→ M where⟹ N → Progress M steps : ∀ {M N}done : →∀ {M} ⟹ N → ProgressValue M M→ - done : ∀ {M} → Value M → Progress M progress : ∀ {M A} → ∅ ⊢ M ∶ A → Progress M @@ -1028,451 +1028,451 @@ This completes the proof.-progress (Ax ()) +progress (⇒-I ⊢N) = (Axdone ())value-λ progress (⇒-I ⊢N(⇒-E ⊢L ⊢M) =with doneprogress value-λ⊢L progress (⇒-E... ⊢L| ⊢M)steps withL⟹L′ progress= steps ⊢L(ξ·₁ L⟹L′) ... | steps L⟹L′| =done stepsvalueL (ξ·₁with L⟹L′) -...progress | done⊢M +... valueL| withsteps progressM⟹M′ = steps ⊢M(ξ·₂ valueL M⟹M′) ... | steps M⟹M′ = steps (ξ·₂ valueL M⟹M′) -... | done valueM with canonical-forms valueM with canonicalFormsLemma ⊢L valueL ... | canonical-λ = steps (βλ· valueM) +progress 𝔹-I₁ = done value-true progress 𝔹-I₁𝔹-I₂ = done value-truevalue-false progress 𝔹-I₂(𝔹-E =⊢L done⊢M value-false -progress (𝔹-E ⊢L ⊢M ⊢N) with progress ⊢L ... | steps L⟹L′ = steps (ξif L⟹L′) ... | done valueL with canonical-forms ⊢L valueL +... | canonicalFormsLemmacanonical-true ⊢L= steps valueLβif-true ... | canonical-true = steps βif-true -... | canonical-false = steps βif-false @@ -1493,68 +1493,68 @@ instead of induction on typing derivations.-postulate progress′ : ∀ M {A} → ∅ ⊢ M ∶ A → Progress M @@ -1616,598 +1616,598 @@ Formally:-data _∈_ : Id → Term → Set where + free-` : :∀ Id{x} → Termx ∈ →` Set wherex free-`free-λ : ∀ {x y A N} → →y x≢ ∈x `→ x - free-λ : ∀∈ N → x ∈ (λ[ {x y A N} → y ≢ x → x ∈ N → x ∈ (λ[ y ∶ A ] N) free-·₁ : ∀ {x L M} → x ∈ L → x ∈ (L · M) + free-·₂ : ∀ → {x ∈ L M} → x ∈ (L · M) → x ∈ (L · M) free-·₂ : ∀ {x Lfree-if₁ M}: →∀ {x ∈L M N} → x ∈ (L ·L → x ∈ (if L then M else N) free-if₁ : ∀ {x L M N} → x ∈ L →free-if₂ x: ∈∀ (if{x L then M elseN} → x ∈ M → x ∈ (if L then M else N) free-if₂ : ∀ {x L M N} → x ∈ M →free-if₃ x: ∈∀ (if{x L then M elseN} → x ∈ N N) - free-if₃ : ∀ {x L M N} → x ∈ N → x ∈ (if L then M else N) @@ -2217,131 +2217,131 @@ A term in which no variables appear free is said to be _closed_.-_∉_ : Id → Term → Set x ∉ M = ¬ (x ∈ M) closed : Term → Set closed M = ∀ {x} → x ∉ M @@ -2351,240 +2351,240 @@ Here are proofs corresponding to the first two examples above.-f≢x : f ≢ x +f≢x () + +example-free₁ : x ∈ : f(λ[ ≢f x -f≢x () - -example-free₁ : x ∈ (λ[ f ∶ (𝔹 ⇒ 𝔹) ] ` f · ` x) +example-free₁ = free-λ ] `f≢x f · ` x) -example-free₁ = free-λ f≢x (free-·₂ free-`) example-free₂ : f ∉ (λ[ f ∶ (𝔹 ⇒ 𝔹) ] ` f · ` x) example-free₂ (free-λ f≢f _) = f≢f refl @@ -2596,367 +2596,367 @@ Prove formally the remaining examples given above.-postulate example-free₃ : x ∈ ((λ[ f ∶ (𝔹 ⇒ 𝔹) ] ` f · ` x) :· x` ∈ ((λ[ f ∶ (𝔹 ⇒ 𝔹) + example-free₄ ]: `f f∈ ·((λ[ ` x)f ·∶ `(𝔹 f)⇒ - example-free₄ 𝔹) ] ` f · ` x) :· f` ∈ ((λ[ f ∶ (𝔹 ⇒ 𝔹) + example-free₅ ]: `x f∉ · `(λ[ x)f ·∶ `(𝔹 f⇒ 𝔹) ] λ[ x ∶ 𝔹 ] ` f · ` x) example-free₅example-free₆ : xf ∉ (λ[ f ∶ (𝔹 ⇒ 𝔹) ] λ[ x ∶ 𝔹 ]λ[ ` f ·∶ `(𝔹 x) - example-free₆ : f ∉ (λ[ f ∶ (𝔹 ⇒ 𝔹) ] λ[ x ∶ 𝔹 ] ` f · ` x) @@ -2975,115 +2975,115 @@ then `Γ` must assign a type to `x`.-freeLemmafree-lemma : ∀ {x M A Γ} → x ∈ M → Γ ⊢ M ∶ A → ∃ λ B M→ AΓ Γ} → x ∈≡ just M → Γ ⊢ M ∶ A → ∃ λ B → Γ x ≡ just B @@ -3119,364 +3119,393 @@ _Proof_: We show, by induction on the proof that `x` appears-freeLemmafree-lemma free-` (Ax Γx≡A) = (_ , Γx≡A) +free-lemma (Ax Γx≡A) =free-·₁ x∈L(_ , Γx≡A) (⇒-E ⊢L ⊢M) = free-lemma x∈L ⊢L freeLemmafree-lemma (free-·₁ x∈L) (⇒-E ⊢L ⊢M(free-·₂ x∈M) = freeLemma x∈L(⇒-E ⊢L ⊢M) = free-lemma x∈M ⊢M freeLemma (free-·₂ x∈M) (⇒-E ⊢L ⊢M)free-lemma =(free-if₁ freeLemmax∈L) x∈M(𝔹-E ⊢L ⊢M ⊢N) = free-lemma x∈L ⊢L freeLemma (free-if₁ x∈L) (𝔹-E ⊢L ⊢M ⊢N) =free-lemma freeLemma(free-if₂ x∈L ⊢L -freeLemma (free-if₂ x∈M) (𝔹-E ⊢L ⊢M ⊢N) = free-lemma x∈M ⊢L⊢M ⊢M ⊢N) = freeLemma x∈M ⊢M freeLemmafree-lemma (free-if₃ x∈N) (𝔹-E ⊢L ⊢M ⊢N) = freeLemmafree-lemma x∈N ⊢N freeLemmafree-lemma (free-λ {x} {y} y≢x x∈N) (⇒-I ⊢N) with y≢xfree-lemma x∈N) (⇒-I ⊢N) +... | Γx≡C with freeLemmay x∈N≟ ⊢Nx | Γx≡Cyes withy≡x = y⊥-elim ≟ x -... |(y≢x yes y≡x = ⊥-elim (y≢x y≡x) ... | no _ = Γx≡C @@ -3584,68 +3584,68 @@ typed in the empty context is closed (has no free variables).-postulate ∅⊢-closed : ∀ {M A} → ∅ ⊢ M ∶ A :→ ∀ {M A} → ∅ ⊢ M ∶ A → closed M @@ -3654,294 +3654,294 @@ typed in the empty context is closed (has no free variables).-contradiction : ∀ {X : Set} → ∀ {x : X} {X : Set} → ¬ (_≡_ {A ∀= {x : X} → ¬ (_≡_ {A = Maybe X} (just x) nothing) contradiction () ∅⊢-closed′ : ∀ {M A} → ∅ ⊢ M ∶ A :→ ∀closed {M A} → ∅ ⊢ M ∶ A +∅⊢-closed′ → closed {M} {A} ⊢M {x} x∈M with free-lemma x∈M ⊢M ∅⊢-closed′ {M} {A} ⊢M {x} x∈M with... freeLemma x∈M ⊢M -... | (B , ∅x≡B) = contradiction (trans contradiction (trans (sym ∅x≡B) (apply-∅ x)) @@ -3957,144 +3957,144 @@ exchanged for the other.-contextLemmacontext-lemma : ∀ {Γ Γ′ M A} + → (∀ {x} A} - → (∀x ∈ M → Γ x ≡ {x}Γ′ x→) x ∈ M + → Γ xΓ ⊢ ≡ Γ′M x) - → Γ ⊢ M ∶ A → Γ′ ⊢ M ∶ A @@ -4146,200 +4146,232 @@ _Proof_: By induction on the derivation of `Γ ⊢ M ∶ A`.-contextLemmacontext-lemma Γ~Γ′ (Ax Γx≡A) rewrite (Γ~Γ′ free-`) = Ax (Γ~Γ′ free-`) = Ax Γx≡A contextLemmacontext-lemma {Γ} {Γ′} {λ[ x ∶ A ] N} Γ~Γ′ (⇒-I ⊢N) = ⇒-I (contextLemmacontext-lemma Γx~Γ′x ⊢N) where Γx~Γ′x : ∀ {y} → y ∈ N → (Γ {y}, x →∶ A) y ∈≡ N → (ΓΓ′ , x ∶ A) y ≡ (Γ′ , x ∶ A) y Γx~Γ′x {y} y∈N with x ≟ {y} y∈N + ... with x ≟ y - ... | yes refl = refl ... | no x≢y = Γ~Γ′ (free-λ x≢y Γ~Γ′ (free-λ x≢y y∈N) contextLemmacontext-lemma Γ~Γ′ (⇒-E ⊢L ⊢M) = ⇒-E (contextLemmacontext-lemma (Γ~Γ′ ∘ free-·₁) ⊢L) (context-lemma (contextLemma (Γ~Γ′ ∘ free-·₂) ⊢M) contextLemmacontext-lemma Γ~Γ′ 𝔹-I₁ = 𝔹-I₁ contextLemmacontext-lemma Γ~Γ′ 𝔹-I₂ = Γ~Γ′𝔹-I₂ 𝔹-I₂ = 𝔹-I₂ contextLemmacontext-lemma Γ~Γ′ (𝔹-E ⊢L ⊢M (𝔹-E ⊢L ⊢M ⊢N) = 𝔹-E (contextLemmacontext-lemma (Γ~Γ′ ∘ free-if₁) free-if₁) ⊢L) (contextLemmacontext-lemma (Γ~Γ′ ∘ free-if₂) ⊢M) (contextLemmacontext-lemma (Γ~Γ′ ∘ (Γ~Γ′ ∘ free-if₃) ⊢N) @@ -4762,162 +4762,162 @@ _Lemma_: If `Γ , x ∶ A ⊢ N ∶ B` and `∅ ⊢ V ∶ A`, then-preservation-[:=] : ∀ {Γ x A N B x A N B V} → (Γ , x ∶ A) ⊢ N ∶ B → ∅ ⊢ V ∶ ∅ ⊢ V ∶ A → Γ ⊢ (N [ x := V ]) := V ]) ∶ B @@ -4991,1363 +4991,1363 @@ we show that if `∅ ⊢ V ∶ A` then `Γ ⊢ N [ x := V ] ∶ B`. We need a couple of lemmas. A closed term can be weakened to any context, and `just` is injective.-weaken-closed : ∀ {V A Γ} {→ ∅ ⊢ V A Γ} →∶ ∅A ⊢→ VΓ ∶⊢ AV →∶ Γ ⊢ V ∶ A weaken-closed {V} {A} {VΓ} {A} {Γ} ⊢V = contextLemmacontext-lemma Γ~Γ′ ⊢V where + Γ~Γ′ - Γ~Γ′ : ∀ {x} → x ∈ V → ∅ x ≡ Γ x Γ~Γ′ {x} x∈V = ⊥-elim ⊥-elim (x∉V x∈V) where x∉V : ¬ (x :∈ ¬ (x ∈ V) x∉V = ∅⊢-closed ⊢V {x} just-injective : ∀ {X : ∀ {XSet} :{x y Set}: {xX} y→ :_≡_ X} →{A _≡_ {A = Maybe X} (just x) (just y) → x y) → x ≡ y just-injective refl = refl = refl-preservation-[:=] {Γ} {x} {A} (Ax {Γ,x∶A} {x′} {B} [Γ,x∶A]x′≡B) ⊢V with x with x ≟ x′ ...| yes x≡x′ rewrite just-injective [Γ,x∶A]x′≡B = weaken-closed ⊢V ...| no x≢x′ = Ax [Γ,x∶A]x′≡B preservation-[:=] {Γ} {x} {A} {λ[ x′ {λ[∶ x′A′ ] ∶ A′ ] N′} {.A′ ⇒ {.A′ ⇒ B′} {V} (⇒-I ⊢N′) ⊢V with x with x ≟ x′ ...| yes x≡x′ rewrite x≡x′ = x≡x′context-lemma = contextLemma Γ′~Γ (⇒-I ⊢N′) where Γ′~Γ : ∀ {y} ∀→ {y} ∈ → y(λ[ ∈ (λ[ x′ ∶ A′ ] N′) ]→ N′) → (Γ , x′ ∶ A) y ≡ Γ y ≡ Γ y Γ′~Γ {y} (free-λ x′≢y y∈N′) y∈N′) with x′ ≟ y ...| yes x′≡y = ⊥-elim (x′≢y (x′≢y x′≡y) ...| no _ = refl ...| no x≢x′ = ⇒-I = ⇒-I ⊢N′V where x′x⊢N′ : Γ , : Γ , x′ ∶ A′ , x ∶ ,A x⊢ ∶ A ⊢ N′ ∶ B′ x′x⊢N′ rewrite update-permute Γ x A Γx′ x AA′ x′ A′ x≢x′ = ⊢N′ ⊢N′V : (Γ , x′ ∶ A′) ∶⊢ A′) ⊢ N′ [ x := V ] ∶ V ] ∶ B′ ⊢N′V = preservation-[:=] x′x⊢N′ ⊢V preservation-[:=] (⇒-E ⊢L ⊢M) ⊢V = ⇒-E = ⇒-E (preservation-[:=] ⊢L ⊢V) (preservation-[:=] ⊢M ⊢V) preservation-[:=] 𝔹-I₁ ⊢V = 𝔹-I₁ preservation-[:=] 𝔹-I₂ ⊢V = 𝔹-I₂ preservation-[:=] (𝔹-E ⊢L ⊢M ⊢L ⊢M ⊢N) ⊢V = 𝔹-E (preservation-[:=] ⊢L ⊢V) (preservation-[:=] ⊢M ⊢V) (preservation-[:=] ⊢N ⊢V) @@ -6363,95 +6363,95 @@ reduction preserves types.-preservation : ∀ {M N A} → ∅ ⊢ →M ∅∶ ⊢A M→ ∶M A⟹ →N M→ ⟹∅ N⊢ →N ∅∶ ⊢ N ∶ A @@ -6489,435 +6489,435 @@ _Proof_: By induction on the derivation of `∅ ⊢ M ∶ A`.-preservation (Ax Γx≡A) Γx≡A) () preservation (⇒-I ⊢N) () preservation (⇒-E (⇒-I ⊢N) ⊢V) ) ⊢V) (βλ· valueV) = preservation-[:=] ⊢N ⊢V preservation (⇒-E ⊢L ⊢M) (ξ·₁ L⟹L′) L⟹L′) with preservation ⊢L L⟹L′ ...| ⊢L′ = ⊢L′⇒-E = ⇒-E ⊢L′ ⊢M preservation (⇒-E ⊢L ⊢M) (ξ·₂ valueL M⟹M′) M⟹M′) with preservation ⊢M M⟹M′ ...| ⊢M′ = ⊢M′⇒-E = ⇒-E ⊢L ⊢M′ preservation 𝔹-I₁ () preservation 𝔹-I₂ () preservation (𝔹-E 𝔹-I₁ ⊢M ⊢N) βif-true = ⊢M preservation (𝔹-E 𝔹-I₂ ⊢M ⊢N) βif-false = ⊢N preservation (𝔹-E ⊢L ⊢M ⊢L ⊢M ⊢N) (ξif L⟹L′) L⟹L′) with preservation ⊢L L⟹L′ ...| ⊢L′ = ⊢L′𝔹-E = 𝔹-E ⊢L′ ⊢M ⊢N @@ -6941,226 +6941,226 @@ term can _never_ reach a stuck state.-Normal : Term → Set Normal M = ∀ M {N=} ∀→ {N} → ¬ (M ⟹ N) Stuck : Term → Set Stuck M = Normal M × ¬ M × ¬Value Value M postulate Soundness : ∀ {M N A} → ∅ ⊢ →M ∅∶ ⊢A M→ ∶M A → M ⟹* N → ¬ N → ¬ (Stuck N) @@ -7169,342 +7169,342 @@ term can _never_ reach a stuck state.@@ -336,7 +336,7 @@ as the two contexts agree on those variables, one can be exchanged for the other. \begin{code} -contextLemma : ∀ {Γ Γ′ M A} +context-lemma : ∀ {Γ Γ′ M A} → (∀ {x} → x ∈ M → Γ x ≡ Γ′ x) → Γ ⊢ M ∶ A → Γ′ ⊢ M ∶ A @@ -387,18 +387,18 @@ _Proof_: By induction on the derivation of `Γ ⊢ M ∶ A`. - The remaining cases are similar to `⇒-E`. \begin{code} -contextLemma Γ~Γ′ (Ax Γx≡A) rewrite (Γ~Γ′ free-`) = Ax Γx≡A -contextLemma {Γ} {Γ′} {λ[ x ∶ A ] N} Γ~Γ′ (⇒-I ⊢N) = ⇒-I (contextLemma Γx~Γ′x ⊢N) +context-lemma Γ~Γ′ (Ax Γx≡A) rewrite (Γ~Γ′ free-`) = Ax Γx≡A +context-lemma {Γ} {Γ′} {λ[ x ∶ A ] N} Γ~Γ′ (⇒-I ⊢N) = ⇒-I (context-lemma Γx~Γ′x ⊢N) where Γx~Γ′x : ∀ {y} → y ∈ N → (Γ , x ∶ A) y ≡ (Γ′ , x ∶ A) y Γx~Γ′x {y} y∈N with x ≟ y ... | yes refl = refl ... | no x≢y = Γ~Γ′ (free-λ x≢y y∈N) -contextLemma Γ~Γ′ (⇒-E ⊢L ⊢M) = ⇒-E (contextLemma (Γ~Γ′ ∘ free-·₁) ⊢L) (contextLemma (Γ~Γ′ ∘ free-·₂) ⊢M) -contextLemma Γ~Γ′ 𝔹-I₁ = 𝔹-I₁ -contextLemma Γ~Γ′ 𝔹-I₂ = 𝔹-I₂ -contextLemma Γ~Γ′ (𝔹-E ⊢L ⊢M ⊢N) - = 𝔹-E (contextLemma (Γ~Γ′ ∘ free-if₁) ⊢L) (contextLemma (Γ~Γ′ ∘ free-if₂) ⊢M) (contextLemma (Γ~Γ′ ∘ free-if₃) ⊢N) +context-lemma Γ~Γ′ (⇒-E ⊢L ⊢M) = ⇒-E (context-lemma (Γ~Γ′ ∘ free-·₁) ⊢L) (context-lemma (Γ~Γ′ ∘ free-·₂) ⊢M) +context-lemma Γ~Γ′ 𝔹-I₁ = 𝔹-I₁ +context-lemma Γ~Γ′ 𝔹-I₂ = 𝔹-I₂ +context-lemma Γ~Γ′ (𝔹-E ⊢L ⊢M ⊢N) + = 𝔹-E (context-lemma (Γ~Γ′ ∘ free-if₁) ⊢L) (context-lemma (Γ~Γ′ ∘ free-if₂) ⊢M) (context-lemma (Γ~Γ′ ∘ free-if₃) ⊢N) \end{code} @@ -493,7 +493,7 @@ we show that if `∅ ⊢ V ∶ A` then `Γ ⊢ N [ x := V ] ∶ B`. We need a couple of lemmas. A closed term can be weakened to any context, and `just` is injective. \begin{code} weaken-closed : ∀ {V A Γ} → ∅ ⊢ V ∶ A → Γ ⊢ V ∶ A -weaken-closed {V} {A} {Γ} ⊢V = contextLemma Γ~Γ′ ⊢V +weaken-closed {V} {A} {Γ} ⊢V = context-lemma Γ~Γ′ ⊢V where Γ~Γ′ : ∀ {x} → x ∈ V → ∅ x ≡ Γ x Γ~Γ′ {x} x∈V = ⊥-elim (x∉V x∈V) @@ -510,7 +510,7 @@ preservation-[:=] {Γ} {x} {A} (Ax {Γ,x∶A} {x′} {B} [Γ,x∶A]x′≡B) ⊢ ...| yes x≡x′ rewrite just-injective [Γ,x∶A]x′≡B = weaken-closed ⊢V ...| no x≢x′ = Ax [Γ,x∶A]x′≡B preservation-[:=] {Γ} {x} {A} {λ[ x′ ∶ A′ ] N′} {.A′ ⇒ B′} {V} (⇒-I ⊢N′) ⊢V with x ≟ x′ -...| yes x≡x′ rewrite x≡x′ = contextLemma Γ′~Γ (⇒-I ⊢N′) +...| yes x≡x′ rewrite x≡x′ = context-lemma Γ′~Γ (⇒-I ⊢N′) where Γ′~Γ : ∀ {y} → y ∈ (λ[ x′ ∶ A′ ] N′) → (Γ , x′ ∶ A) y ≡ Γ y Γ′~Γ {y} (free-λ x′≢y y∈N′) with x′ ≟ y-Soundness′ : ∀ {M N A} → ∅ ⊢ →M ∅∶ ⊢A M→ ∶M A → M ⟹* N → ¬ N → ¬ (Stuck N) Soundness′ ⊢M (M ⊢M∎) (M ∎)¬M⟹N (¬M⟹N , ¬ValueM) with progress ⊢M ... | steps steps M⟹N = ¬M⟹N M⟹N ... | done ValueM = ¬ValueM ValueM Soundness′ {L} {N{L} } {N} {A} ⊢L (_⟹⟨_⟩_ .L {M} {.N} L⟹M M⟹*N) M⟹*N) = Soundness′ ⊢M M⟹*N where ⊢M : ∅ ⊢ :M ∅∶ ⊢ M ∶ A ⊢M = preservation ⊢L L⟹M diff --git a/src/StlcProp.lagda b/src/StlcProp.lagda index cfb75eae..fb0e6267 100644 --- a/src/StlcProp.lagda +++ b/src/StlcProp.lagda @@ -38,13 +38,13 @@ data canonical_for_ : Term → Type → Set where canonical-true : canonical true for 𝔹 canonical-false : canonical false for 𝔹 -canonicalFormsLemma : ∀ {L A} → ∅ ⊢ L ∶ A → Value L → canonical L for A -canonicalFormsLemma (Ax ()) () -canonicalFormsLemma (⇒-I ⊢N) value-λ = canonical-λ -canonicalFormsLemma (⇒-E ⊢L ⊢M) () -canonicalFormsLemma 𝔹-I₁ value-true = canonical-true -canonicalFormsLemma 𝔹-I₂ value-false = canonical-false -canonicalFormsLemma (𝔹-E ⊢L ⊢M ⊢N) () +canonical-forms : ∀ {L A} → ∅ ⊢ L ∶ A → Value L → canonical L for A +canonical-forms (Ax ()) () +canonical-forms (⇒-I ⊢N) value-λ = canonical-λ +canonical-forms (⇒-E ⊢L ⊢M) () +canonical-forms 𝔹-I₁ value-true = canonical-true +canonical-forms 𝔹-I₂ value-false = canonical-false +canonical-forms (𝔹-E ⊢L ⊢M ⊢N) () \end{code} ## Progress @@ -117,13 +117,13 @@ progress (⇒-E ⊢L ⊢M) with progress ⊢L ... | steps L⟹L′ = steps (ξ·₁ L⟹L′) ... | done valueL with progress ⊢M ... | steps M⟹M′ = steps (ξ·₂ valueL M⟹M′) -... | done valueM with canonicalFormsLemma ⊢L valueL +... | done valueM with canonical-forms ⊢L valueL ... | canonical-λ = steps (βλ· valueM) progress 𝔹-I₁ = done value-true progress 𝔹-I₂ = done value-false progress (𝔹-E ⊢L ⊢M ⊢N) with progress ⊢L ... | steps L⟹L′ = steps (ξif L⟹L′) -... | done valueL with canonicalFormsLemma ⊢L valueL +... | done valueL with canonical-forms ⊢L valueL ... | canonical-true = steps βif-true ... | canonical-false = steps βif-false \end{code} @@ -258,7 +258,7 @@ appears free in term `M`, and if `M` is well typed in context `Γ`, then `Γ` must assign a type to `x`. \begin{code} -freeLemma : ∀ {x M A Γ} → x ∈ M → Γ ⊢ M ∶ A → ∃ λ B → Γ x ≡ just B +free-lemma : ∀ {x M A Γ} → x ∈ M → Γ ⊢ M ∶ A → ∃ λ B → Γ x ≡ just B \end{code} _Proof_: We show, by induction on the proof that `x` appears @@ -290,13 +290,13 @@ _Proof_: We show, by induction on the proof that `x` appears `_≟_`, and note that `x` and `y` are different variables. \begin{code} -freeLemma free-` (Ax Γx≡A) = (_ , Γx≡A) -freeLemma (free-·₁ x∈L) (⇒-E ⊢L ⊢M) = freeLemma x∈L ⊢L -freeLemma (free-·₂ x∈M) (⇒-E ⊢L ⊢M) = freeLemma x∈M ⊢M -freeLemma (free-if₁ x∈L) (𝔹-E ⊢L ⊢M ⊢N) = freeLemma x∈L ⊢L -freeLemma (free-if₂ x∈M) (𝔹-E ⊢L ⊢M ⊢N) = freeLemma x∈M ⊢M -freeLemma (free-if₃ x∈N) (𝔹-E ⊢L ⊢M ⊢N) = freeLemma x∈N ⊢N -freeLemma (free-λ {x} {y} y≢x x∈N) (⇒-I ⊢N) with freeLemma x∈N ⊢N +free-lemma free-` (Ax Γx≡A) = (_ , Γx≡A) +free-lemma (free-·₁ x∈L) (⇒-E ⊢L ⊢M) = free-lemma x∈L ⊢L +free-lemma (free-·₂ x∈M) (⇒-E ⊢L ⊢M) = free-lemma x∈M ⊢M +free-lemma (free-if₁ x∈L) (𝔹-E ⊢L ⊢M ⊢N) = free-lemma x∈L ⊢L +free-lemma (free-if₂ x∈M) (𝔹-E ⊢L ⊢M ⊢N) = free-lemma x∈M ⊢M +free-lemma (free-if₃ x∈N) (𝔹-E ⊢L ⊢M ⊢N) = free-lemma x∈N ⊢N +free-lemma (free-λ {x} {y} y≢x x∈N) (⇒-I ⊢N) with free-lemma x∈N ⊢N ... | Γx≡C with y ≟ x ... | yes y≡x = ⊥-elim (y≢x y≡x) ... | no _ = Γx≡C @@ -323,7 +323,7 @@ contradiction : ∀ {X : Set} → ∀ {x : X} → ¬ (_≡_ {A = Maybe X} (just contradiction () ∅⊢-closed′ : ∀ {M A} → ∅ ⊢ M ∶ A → closed M -∅⊢-closed′ {M} {A} ⊢M {x} x∈M with freeLemma x∈M ⊢M +∅⊢-closed′ {M} {A} ⊢M {x} x∈M with free-lemma x∈M ⊢M ... | (B , ∅x≡B) = contradiction (trans (sym ∅x≡B) (apply-∅ x)) \end{code}