Compare commits
33 Commits
first-orde
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b5b148b2f | |||
| 127d1fbc9a | |||
| d00a2d7816 | |||
| f20fca8392 | |||
| 66490abfb8 | |||
| 360dd1823c | |||
| 841f6e96f1 | |||
| eb80453ef2 | |||
| a10bcd6770 | |||
| 9be53b4f7f | |||
| b93ce31ab3 | |||
| 370daed594 | |||
| d70739091e | |||
|
|
2728c60633 | ||
|
|
a582f2555b | ||
| 2956b62cc1 | |||
| e9eedbff2d | |||
| 357e2a087d | |||
| 7d03f4d854 | |||
| 1d4cda091e | |||
| 91d7fd127d | |||
| 11a6742677 | |||
| 6829fe86c7 | |||
| 1dc1826f49 | |||
| a2e7689f58 | |||
| 2534ebf85e | |||
| bff7e48a12 | |||
| 29ee842db1 | |||
|
|
a85b9d7ad8 | ||
|
|
7cf08241b4 | ||
|
|
309ba6ab70 | ||
|
|
bd99520e35 | ||
|
|
00fd305f5f |
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,3 +3,7 @@
|
||||
\#*\#
|
||||
.\#*
|
||||
*.kate-swp
|
||||
/report/build/
|
||||
/report/agda/
|
||||
/report/agda.sty
|
||||
/latex
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module FinitaryFirstOrderLogic where
|
||||
module FFOL where
|
||||
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
@ -14,24 +15,28 @@ module FinitaryFirstOrderLogic where
|
||||
infixr 10 _∘_
|
||||
infixr 5 _⊢_
|
||||
field
|
||||
|
||||
--# We first make the base category with its terminal object
|
||||
Con : Set ℓ¹
|
||||
Sub : Con → Con → Set ℓ⁵ -- It makes a category
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
∘-ass : {Γ Δ Ξ Ψ : Con}{α : Sub Γ Δ}{β : Sub Δ Ξ}{γ : Sub Ξ Ψ} → (γ ∘ β) ∘ α ≡ γ ∘ (β ∘ α)
|
||||
∘-ass : {Γ Δ Ξ Ψ : Con}{α : Sub Γ Δ}{β : Sub Δ Ξ}{γ : Sub Ξ Ψ}
|
||||
→ (γ ∘ β) ∘ α ≡ γ ∘ (β ∘ α)
|
||||
id : {Γ : Con} → Sub Γ Γ
|
||||
idl : {Γ Δ : Con} {σ : Sub Γ Δ} → (id {Δ}) ∘ σ ≡ σ
|
||||
idr : {Γ Δ : Con} {σ : Sub Γ Δ} → σ ∘ (id {Γ}) ≡ σ
|
||||
◇ : Con -- The initial object of the category
|
||||
ε : {Γ : Con} → Sub Γ ◇ -- The morphism from the initial to any object
|
||||
◇ : Con -- The terminal object of the category
|
||||
ε : {Γ : Con} → Sub Γ ◇ -- The morphism from any object to the terminal
|
||||
ε-u : {Γ : Con} → {σ : Sub Γ ◇} → σ ≡ ε {Γ}
|
||||
|
||||
-- Functor Con → Set called Tm
|
||||
--# Functor Con → Set called Tm
|
||||
Tm : Con → Set ℓ²
|
||||
_[_]t : {Γ Δ : Con} → Tm Γ → Sub Δ Γ → Tm Δ -- The functor's action on morphisms
|
||||
_[_]t : {Γ Δ : Con} → Tm Γ → Sub Δ Γ → Tm Δ -- Action on morphisms
|
||||
[]t-id : {Γ : Con} → {x : Tm Γ} → x [ id {Γ} ]t ≡ x
|
||||
[]t-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {t : Tm Γ} → t [ β ∘ α ]t ≡ (t [ β ]t) [ α ]t
|
||||
[]t-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ}{β : Sub Δ Γ} → {t : Tm Γ}
|
||||
→ t [ β ∘ α ]t ≡ (t [ β ]t) [ α ]t
|
||||
|
||||
-- Tm : Set+
|
||||
--# Tm : Set⁺
|
||||
_▹ₜ : Con → Con
|
||||
πₜ¹ : {Γ Δ : Con} → Sub Δ (Γ ▹ₜ) → Sub Δ Γ
|
||||
πₜ² : {Γ Δ : Con} → Sub Δ (Γ ▹ₜ) → Tm Δ
|
||||
@ -39,56 +44,73 @@ module FinitaryFirstOrderLogic where
|
||||
πₜ²∘,ₜ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm Δ} → πₜ² (σ ,ₜ t) ≡ t
|
||||
πₜ¹∘,ₜ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm Δ} → πₜ¹ (σ ,ₜ t) ≡ σ
|
||||
,ₜ∘πₜ : {Γ Δ : Con} → {σ : Sub Δ (Γ ▹ₜ)} → (πₜ¹ σ) ,ₜ (πₜ² σ) ≡ σ
|
||||
,ₜ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{t : Tm Γ} → (σ ,ₜ t) ∘ δ ≡ (σ ∘ δ) ,ₜ (t [ δ ]t)
|
||||
,ₜ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{t : Tm Γ}
|
||||
→ (σ ,ₜ t) ∘ δ ≡ (σ ∘ δ) ,ₜ (t [ δ ]t)
|
||||
|
||||
-- Functor Con → Set called For
|
||||
--# Functor Con → Set called For
|
||||
For : Con → Set ℓ³
|
||||
_[_]f : {Γ Δ : Con} → For Γ → Sub Δ Γ → For Δ -- The functor's action on morphisms
|
||||
_[_]f : {Γ Δ : Con} → For Γ → Sub Δ Γ → For Δ -- Action on morphisms
|
||||
[]f-id : {Γ : Con} → {F : For Γ} → F [ id {Γ} ]f ≡ F
|
||||
[]f-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ} → F [ β ∘ α ]f ≡ (F [ β ]f) [ α ]f
|
||||
[]f-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ}
|
||||
→ F [ β ∘ α ]f ≡ (F [ β ]f) [ α ]f
|
||||
|
||||
-- Formulas with relation on terms
|
||||
R : {Γ : Con} → (t u : Tm Γ) → For Γ
|
||||
R[] : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t u : Tm Γ} → (R t u) [ σ ]f ≡ R (t [ σ ]t) (u [ σ ]t)
|
||||
|
||||
-- Proofs
|
||||
--# Functor Con × For → Prop called Pf or ⊢
|
||||
_⊢_ : (Γ : Con) → For Γ → Prop ℓ⁴
|
||||
_[_]p : {Γ Δ : Con} → {F : For Γ} → Γ ⊢ F → (σ : Sub Δ Γ) → Δ ⊢ (F [ σ ]f) -- The functor's action on morphisms
|
||||
-- Equalities below are useless because Γ ⊢ F is in prop
|
||||
-- []p-id : {Γ : Con} → {F : For Γ} → {prf : Γ ⊢ F} → prf [ id {Γ} ]p ≡ prf
|
||||
-- []p-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ} → {prf : Γ ⊢ F} → prf [ α ∘ β ]p ≡ (prf [ β ]p) [ α ]p
|
||||
-- Action on morphisms
|
||||
_[_]p : {Γ Δ : Con} → {F : For Γ} → Γ ⊢ F → (σ : Sub Δ Γ) → Δ ⊢ (F [ σ ]f)
|
||||
--# Equalities below are useless because Γ ⊢ F is in prop
|
||||
-- []p-id : {Γ : Con} → {F : For Γ} → {prf : Γ ⊢ F}
|
||||
-- → prf [ id {Γ} ]p ≡ prf
|
||||
-- []p-∘ : {Γ Δ Ξ : Con}{α : Sub Ξ Δ}{β : Sub Δ Γ}{F : For Γ}{prf : Γ ⊢ F}
|
||||
-- → prf [ α ∘ β ]p ≡ (prf [ β ]p) [ α ]p
|
||||
|
||||
-- → Prop⁺
|
||||
--# → Prop⁺
|
||||
_▹ₚ_ : (Γ : Con) → For Γ → Con
|
||||
πₚ¹ : {Γ Δ : Con} → {F : For Γ} → Sub Δ (Γ ▹ₚ F) → Sub Δ Γ
|
||||
πₚ² : {Γ Δ : Con} → {F : For Γ} → (σ : Sub Δ (Γ ▹ₚ F)) → Δ ⊢ (F [ πₚ¹ σ ]f)
|
||||
_,ₚ_ : {Γ Δ : Con} → {F : For Γ} → (σ : Sub Δ Γ) → Δ ⊢ (F [ σ ]f) → Sub Δ (Γ ▹ₚ F)
|
||||
-- Equalities below are useless because Γ ⊢ F is in Prop
|
||||
,ₚ∘πₚ : {Γ Δ : Con} → {F : For Γ} → {σ : Sub Δ (Γ ▹ₚ F)} → (πₚ¹ σ) ,ₚ (πₚ² σ) ≡ σ
|
||||
πₚ¹∘,ₚ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {F : For Γ} → {prf : Δ ⊢ (F [ σ ]f)} → πₚ¹ (σ ,ₚ prf) ≡ σ
|
||||
-- πₚ²∘,ₚ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {F : For Γ} → {prf : Δ ⊢ (F [ σ ]f)} → πₚ² (σ ,ₚ prf) ≡ prf
|
||||
,ₚ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{F : For Ξ}{prf : Γ ⊢ (F [ σ ]f)} → (σ ,ₚ prf) ∘ δ ≡ (σ ∘ δ) ,ₚ (substP (λ F → Δ ⊢ F) (≡sym []f-∘) (prf [ δ ]p))
|
||||
πₚ¹ : {Γ Δ : Con}{F : For Γ} → Sub Δ (Γ ▹ₚ F) → Sub Δ Γ
|
||||
πₚ² : {Γ Δ : Con}{F : For Γ} → (σ : Sub Δ (Γ ▹ₚ F)) → Δ ⊢ (F [ πₚ¹ σ ]f)
|
||||
_,ₚ_ : {Γ Δ : Con}{F : For Γ} → (σ : Sub Δ Γ) → Δ ⊢ (F [ σ ]f) → Sub Δ (Γ ▹ₚ F)
|
||||
--# And its equalities
|
||||
,ₚ∘πₚ : {Γ Δ : Con}{F : For Γ}{σ : Sub Δ (Γ ▹ₚ F)} → (πₚ¹ σ) ,ₚ (πₚ² σ) ≡ σ
|
||||
πₚ¹∘,ₚ : {Γ Δ : Con}{σ : Sub Δ Γ}{F : For Γ}{prf : Δ ⊢ (F [ σ ]f)}
|
||||
→ πₚ¹ (σ ,ₚ prf) ≡ σ
|
||||
-- Equality below is useless because Γ ⊢ F is in Prop
|
||||
-- πₚ²∘,ₚ : {Γ Δ : Con}{σ : Sub Δ Γ}{F : For Γ}{prf : Δ ⊢ (F [ σ ]f)}
|
||||
-- → πₚ² (σ ,ₚ prf) ≡ prf
|
||||
,ₚ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{F : For Ξ}{prf : Γ ⊢ (F [ σ ]f)}
|
||||
→ (σ ,ₚ prf) ∘ δ ≡ (σ ∘ δ) ,ₚ (substP (λ F → Δ ⊢ F) (≡sym []f-∘) (prf [ δ ]p))
|
||||
--#
|
||||
|
||||
|
||||
-- Implication
|
||||
{-- FORMULAE CONSTRUCTORS --}
|
||||
--# Formulas with relation on terms
|
||||
R : {Γ : Con} → (t u : Tm Γ) → For Γ
|
||||
R[] : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t u : Tm Γ}
|
||||
→ (R t u) [ σ ]f ≡ R (t [ σ ]t) (u [ σ ]t)
|
||||
|
||||
--# Implication
|
||||
_⇒_ : {Γ : Con} → For Γ → For Γ → For Γ
|
||||
[]f-⇒ : {Γ Δ : Con} → {F G : For Γ} → {σ : Sub Δ Γ} → (F ⇒ G) [ σ ]f ≡ (F [ σ ]f) ⇒ (G [ σ ]f)
|
||||
[]f-⇒ : {Γ Δ : Con} → {F G : For Γ} → {σ : Sub Δ Γ}
|
||||
→ (F ⇒ G) [ σ ]f ≡ (F [ σ ]f) ⇒ (G [ σ ]f)
|
||||
|
||||
-- Forall
|
||||
--# Forall
|
||||
∀∀ : {Γ : Con} → For (Γ ▹ₜ) → For Γ
|
||||
[]f-∀∀ : {Γ Δ : Con} → {F : For (Γ ▹ₜ)} → {σ : Sub Δ Γ} → (∀∀ F) [ σ ]f ≡ (∀∀ (F [ (σ ∘ πₜ¹ id) ,ₜ πₜ² id ]f))
|
||||
[]f-∀∀ : {Γ Δ : Con} → {F : For (Γ ▹ₜ)} → {σ : Sub Δ Γ}
|
||||
→ (∀∀ F) [ σ ]f ≡ (∀∀ (F [ (σ ∘ πₜ¹ id) ,ₜ πₜ² id ]f))
|
||||
|
||||
-- Lam & App
|
||||
lam : {Γ : Con} → {F : For Γ} → {G : For Γ} → (Γ ▹ₚ F) ⊢ (G [ πₚ¹ id ]f) → Γ ⊢ (F ⇒ G)
|
||||
app : {Γ : Con} → {F G : For Γ} → Γ ⊢ (F ⇒ G) → Γ ⊢ F → Γ ⊢ G
|
||||
-- Again, we don't write the _[_]p equalities as everything is in Prop
|
||||
--#
|
||||
{-- PROOFS CONSTRUCTORS --}
|
||||
-- Again, we don't have to write the _[_]p equalities as Proofs are in Prop
|
||||
|
||||
-- ∀i and ∀e
|
||||
∀i : {Γ : Con} → {F : For (Γ ▹ₜ)} → (Γ ▹ₜ) ⊢ F → Γ ⊢ (∀∀ F)
|
||||
∀e : {Γ : Con} → {F : For (Γ ▹ₜ)} → Γ ⊢ (∀∀ F) → {t : Tm Γ} → Γ ⊢ ( F [(id {Γ}) ,ₜ t ]f)
|
||||
--# Lam & App
|
||||
lam : {Γ : Con}{F G : For Γ} → (Γ ▹ₚ F) ⊢ (G [ πₚ¹ id ]f) → Γ ⊢ (F ⇒ G)
|
||||
app : {Γ : Con}{F G : For Γ} → Γ ⊢ (F ⇒ G) → Γ ⊢ F → Γ ⊢ G
|
||||
|
||||
--# ∀i and ∀e
|
||||
∀i : {Γ : Con}{F : For (Γ ▹ₜ)} → (Γ ▹ₜ) ⊢ F → Γ ⊢ (∀∀ F)
|
||||
∀e : {Γ : Con}{F : For (Γ ▹ₜ)} → Γ ⊢ (∀∀ F) → {t : Tm Γ} → Γ ⊢ ( F [(id {Γ}) ,ₜ t ]f)
|
||||
|
||||
|
||||
-- Examples
|
||||
--# Examples
|
||||
-- Proof utils
|
||||
forall-in : {Γ Δ : Con} {σ : Sub Γ Δ} {A : For (Δ ▹ₜ)} → Γ ⊢ ∀∀ (A [ (σ ∘ πₜ¹ id) ,ₜ πₜ² id ]f) → Γ ⊢ (∀∀ A [ σ ]f)
|
||||
forall-in {Γ = Γ} f = substP (λ F → Γ ⊢ F) (≡sym ([]f-∀∀)) f
|
||||
@ -129,6 +151,47 @@ module FinitaryFirstOrderLogic where
|
||||
ex5 = {!!}
|
||||
-}
|
||||
|
||||
record Mapping (S : FFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} {ℓ⁵}) (D : FFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} {ℓ⁵}) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ⁵)) where
|
||||
field
|
||||
|
||||
-- We first make the base category with its final object
|
||||
mCon : (FFOL.Con S) → (FFOL.Con D)
|
||||
mSub : {Δ : (FFOL.Con S)}{Γ : (FFOL.Con S)} → (FFOL.Sub S Δ Γ) → (FFOL.Sub D (mCon Δ) (mCon Γ))
|
||||
mTm : {Γ : (FFOL.Con S)} → (FFOL.Tm S Γ) → (FFOL.Tm D (mCon Γ))
|
||||
mFor : {Γ : (FFOL.Con S)} → (FFOL.For S Γ) → (FFOL.For D (mCon Γ))
|
||||
m⊢ : {Γ : (FFOL.Con S)} {A : FFOL.For S Γ} → FFOL._⊢_ S Γ A → FFOL._⊢_ D (mCon Γ) (mFor A)
|
||||
|
||||
|
||||
record Morphism (S : FFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} {ℓ⁵}) (D : FFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} {ℓ⁵}) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ⁵)) where
|
||||
field m : Mapping S D
|
||||
mCon = Mapping.mCon m
|
||||
mSub = Mapping.mSub m
|
||||
mTm = Mapping.mTm m
|
||||
mFor = Mapping.mFor m
|
||||
m⊢ = Mapping.m⊢ m
|
||||
field
|
||||
e∘ : {Γ Δ Ξ : FFOL.Con S}{δ : FFOL.Sub S Δ Ξ}{σ : FFOL.Sub S Γ Δ} → mSub (FFOL._∘_ S δ σ) ≡ FFOL._∘_ D (mSub δ) (mSub σ)
|
||||
eid : {Γ : FFOL.Con S} → mSub (FFOL.id S {Γ}) ≡ FFOL.id D {mCon Γ}
|
||||
e◇ : mCon (FFOL.◇ S) ≡ FFOL.◇ D
|
||||
eε : {Γ : FFOL.Con S} → mSub (FFOL.ε S {Γ}) ≡ subst (FFOL.Sub D (mCon Γ)) (≡sym e◇) (FFOL.ε D {mCon Γ})
|
||||
e[]t : {Γ Δ : FFOL.Con S}{t : FFOL.Tm S Γ}{σ : FFOL.Sub S Δ Γ} → mTm (FFOL._[_]t S t σ) ≡ FFOL._[_]t D (mTm t) (mSub σ)
|
||||
e▹ₜ : {Γ : FFOL.Con S} → mCon (FFOL._▹ₜ S Γ) ≡ FFOL._▹ₜ D (mCon Γ)
|
||||
eπₜ¹ : {Γ Δ : FFOL.Con S}{σ : FFOL.Sub S Δ (FFOL._▹ₜ S Γ)} → mSub (FFOL.πₜ¹ S σ) ≡ FFOL.πₜ¹ D (subst (FFOL.Sub D (mCon Δ)) e▹ₜ (mSub σ))
|
||||
eπₜ² : {Γ Δ : FFOL.Con S}{σ : FFOL.Sub S Δ (FFOL._▹ₜ S Γ)} → mTm (FFOL.πₜ² S σ) ≡ FFOL.πₜ² D (subst (FFOL.Sub D (mCon Δ)) e▹ₜ (mSub σ))
|
||||
e,ₜ : {Γ Δ : FFOL.Con S}{σ : FFOL.Sub S Δ Γ}{t : FFOL.Tm S Δ} → mSub (FFOL._,ₜ_ S σ t) ≡ subst (FFOL.Sub D (mCon Δ)) (≡sym e▹ₜ) (FFOL._,ₜ_ D (mSub σ) (mTm t))
|
||||
e[]f : {Γ Δ : FFOL.Con S}{A : FFOL.For S Γ}{σ : FFOL.Sub S Δ Γ} → mFor (FFOL._[_]f S A σ) ≡ FFOL._[_]f D (mFor A) (mSub σ)
|
||||
-- Proofs are in prop, so no equation needed
|
||||
--[]p : {Γ Δ : FFOL.Con S}{A : FFOL.For S Γ}{pf : FFOL._⊢_ S Γ A}{σ : FFOL.Sub S Δ Γ} → m⊢ (FFOL._[_]p S pf σ) ≡ FFOL._[_]p D (m⊢ pf) (mSub σ)
|
||||
e▹ₚ : {Γ : FFOL.Con S}{A : FFOL.For S Γ} → mCon (FFOL._▹ₚ_ S Γ A) ≡ FFOL._▹ₚ_ D (mCon Γ) (mFor A)
|
||||
eπₚ¹ : {Γ Δ : FFOL.Con S}{A : FFOL.For S Γ}{σ : FFOL.Sub S Δ (FFOL._▹ₚ_ S Γ A)} → mSub (FFOL.πₚ¹ S σ) ≡ FFOL.πₚ¹ D (subst (FFOL.Sub D (mCon Δ)) e▹ₚ (mSub σ))
|
||||
--πₚ² : {Γ Δ : FFOL.Con S}{A : FFOL.For S Γ}{σ : FFOL.Sub S Δ (FFOL._▹ₚ_ S Γ A)} → m⊢ (FFOL.πₚ² S σ) ≡ FFOL.πₚ¹ D (subst (FFOL.Sub D (mCon Δ)) ▹ₚ (mSub σ))
|
||||
e,ₚ : {Γ Δ : FFOL.Con S}{A : FFOL.For S Γ}{σ : FFOL.Sub S Δ Γ}{pf : FFOL._⊢_ S Δ (FFOL._[_]f S A σ)}
|
||||
→ mSub (FFOL._,ₚ_ S σ pf) ≡ subst (FFOL.Sub D (mCon Δ)) (≡sym e▹ₚ) (FFOL._,ₚ_ D (mSub σ) (substP (FFOL._⊢_ D (mCon Δ)) e[]f (m⊢ pf)))
|
||||
eR : {Γ : FFOL.Con S}{t u : FFOL.Tm S Γ} → mFor (FFOL.R S t u) ≡ FFOL.R D (mTm t) (mTm u)
|
||||
e⇒ : {Γ : FFOL.Con S}{A B : FFOL.For S Γ} → mFor (FFOL._⇒_ S A B) ≡ FFOL._⇒_ D (mFor A) (mFor B)
|
||||
e∀∀ : {Γ : FFOL.Con S}{A : FFOL.For S (FFOL._▹ₜ S Γ)} → mFor (FFOL.∀∀ S A) ≡ FFOL.∀∀ D (subst (FFOL.For D) e▹ₜ (mFor A))
|
||||
-- No equation needed for lam, app, ∀i, ∀e as their output are in prop
|
||||
|
||||
record Tarski : Set₁ where
|
||||
field
|
||||
TM : Set
|
||||
@ -317,214 +380,4 @@ module FinitaryFirstOrderLogic where
|
||||
-- (((∀ x . A (x)) ⇒ B)⇒ B) ⇒ ∀ x . ((A (x) ⇒ B) ⇒ B)
|
||||
ex5 : {A : For (⊤ₛ ▹ₜ)} → {B : For ⊤ₛ} → ⊤ₛ ⊢ ((((∀∀ A) ⇒ B) ⇒ B) ⇒ (∀∀ ((A ⇒ (B [ πₜ¹ id ]f)) ⇒ (B [ πₜ¹ id ]f))))
|
||||
ex5 ◇◇ h t h' = h (λ h'' → h' (h'' t))
|
||||
|
||||
record Kripke : Set (lsuc (ℓ¹)) where
|
||||
field
|
||||
World : Set ℓ¹
|
||||
_≤_ : World → World → Prop
|
||||
≤refl : {w : World} → w ≤ w
|
||||
≤tran : {w w' w'' : World} → w ≤ w' → w' ≤ w'' → w ≤ w'
|
||||
TM : World → Set ℓ¹
|
||||
TM≤ : {w w' : World} → w ≤ w' → TM w → TM w'
|
||||
REL : (w : World) → TM w → TM w → Prop ℓ¹
|
||||
REL≤ : {w w' : World} → {t u : TM w} → (eq : w ≤ w') → REL w t u → REL w' (TM≤ eq t) (TM≤ eq u)
|
||||
infixr 10 _∘_
|
||||
Con = World → Set ℓ¹
|
||||
Sub : Con → Con → Set ℓ¹
|
||||
Sub Δ Γ = (w : World) → Δ w → Γ w
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
α ∘ β = λ w γ → α w (β w γ)
|
||||
id : {Γ : Con} → Sub Γ Γ
|
||||
id = λ w γ → γ
|
||||
◇ : Con -- The initial object of the category
|
||||
◇ = λ w → ⊤ₛ
|
||||
ε : {Γ : Con} → Sub Γ ◇ -- The morphism from the initial to any object
|
||||
ε w Γ = ttₛ
|
||||
|
||||
-- Functor Con → Set called Tm
|
||||
Tm : Con → Set ℓ¹
|
||||
Tm Γ = (w : World) → (Γ w) → TM w
|
||||
_[_]t : {Γ Δ : Con} → Tm Γ → Sub Δ Γ → Tm Δ -- The functor's action on morphisms
|
||||
t [ σ ]t = λ w → λ γ → t w (σ w γ)
|
||||
[]t-id : {Γ : Con} → {x : Tm Γ} → x [ id {Γ} ]t ≡ x
|
||||
[]t-id = refl
|
||||
[]t-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {t : Tm Γ} → t [ β ∘ α ]t ≡ (t [ β ]t) [ α ]t
|
||||
[]t-∘ = refl
|
||||
|
||||
|
||||
-- We simply define « bulk _[σ]t » (that acts on *n* terms from *Tm Γ*)
|
||||
_[_]tz : {Γ Δ : Con} → {n : Nat} → Array (Tm Γ) n → Sub Δ Γ → Array (Tm Δ) n
|
||||
tz [ σ ]tz = map (λ s → s [ σ ]t) tz
|
||||
[]tz-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {n : Nat} → {tz : Array (Tm Γ) n} → tz [ β ∘ α ]tz ≡ tz [ β ]tz [ α ]tz
|
||||
[]tz-∘ {tz = zero} = refl
|
||||
[]tz-∘ {α = α} {β = β} {tz = next x tz} = substP (λ tz' → (next ((x [ β ]t) [ α ]t) tz') ≡ (((next x tz) [ β ]tz) [ α ]tz)) (≡sym ([]tz-∘ {α = α} {β = β} {tz = tz})) refl
|
||||
[]tz-id : {Γ : Con} → {n : Nat} → {tz : Array (Tm Γ) n} → tz [ id ]tz ≡ tz
|
||||
[]tz-id {tz = zero} = refl
|
||||
[]tz-id {tz = next x tz} = substP (λ tz' → next x tz' ≡ next x tz) (≡sym ([]tz-id {tz = tz})) refl
|
||||
|
||||
-- Tm⁺
|
||||
_▹ₜ : Con → Con
|
||||
Γ ▹ₜ = λ w → (Γ w) × (TM w)
|
||||
πₜ¹ : {Γ Δ : Con} → Sub Δ (Γ ▹ₜ) → Sub Δ Γ
|
||||
πₜ¹ σ = λ w → λ x → proj×₁ (σ w x)
|
||||
πₜ² : {Γ Δ : Con} → Sub Δ (Γ ▹ₜ) → Tm Δ
|
||||
πₜ² σ = λ w → λ x → proj×₂ (σ w x)
|
||||
_,ₜ_ : {Γ Δ : Con} → Sub Δ Γ → Tm Δ → Sub Δ (Γ ▹ₜ)
|
||||
σ ,ₜ t = λ w → λ x → (σ w x) ,× (t w x)
|
||||
πₜ²∘,ₜ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm Δ} → πₜ² (σ ,ₜ t) ≡ t
|
||||
πₜ²∘,ₜ {σ = σ} {t} = refl {a = t}
|
||||
πₜ¹∘,ₜ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm Δ} → πₜ¹ (σ ,ₜ t) ≡ σ
|
||||
πₜ¹∘,ₜ = refl
|
||||
,ₜ∘πₜ : {Γ Δ : Con} → {σ : Sub Δ (Γ ▹ₜ)} → (πₜ¹ σ) ,ₜ (πₜ² σ) ≡ σ
|
||||
,ₜ∘πₜ = refl
|
||||
,ₜ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{t : Tm Γ} → (σ ,ₜ t) ∘ δ ≡ (σ ∘ δ) ,ₜ (t [ δ ]t)
|
||||
,ₜ∘ = refl
|
||||
|
||||
-- Functor Con → Set called For
|
||||
For : Con → Set (lsuc ℓ¹)
|
||||
For Γ = (w : World) → (Γ w) → Prop ℓ¹
|
||||
_[_]f : {Γ Δ : Con} → For Γ → Sub Δ Γ → For Δ -- The functor's action on morphisms
|
||||
F [ σ ]f = λ w → λ x → F w (σ w x)
|
||||
[]f-id : {Γ : Con} → {F : For Γ} → F [ id {Γ} ]f ≡ F
|
||||
[]f-id = refl
|
||||
[]f-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ} → F [ β ∘ α ]f ≡ (F [ β ]f) [ α ]f
|
||||
[]f-∘ = refl
|
||||
|
||||
-- Formulas with relation on terms
|
||||
R : {Γ : Con} → Tm Γ → Tm Γ → For Γ
|
||||
R t u = λ w → λ γ → REL w (t w γ) (u w γ)
|
||||
R[] : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t u : Tm Γ} → (R t u) [ σ ]f ≡ R (t [ σ ]t) (u [ σ ]t)
|
||||
R[] {σ = σ} = cong₂ R refl refl
|
||||
|
||||
|
||||
-- Proofs
|
||||
_⊢_ : (Γ : Con) → For Γ → Prop ℓ¹
|
||||
Γ ⊢ F = ∀ w (γ : Γ w) → F w γ
|
||||
_[_]p : {Γ Δ : Con} → {F : For Γ} → Γ ⊢ F → (σ : Sub Δ Γ) → Δ ⊢ (F [ σ ]f) -- The functor's action on morphisms
|
||||
prf [ σ ]p = λ w → λ γ → prf w (σ w γ)
|
||||
-- Equalities below are useless because Γ ⊢ F is in prop
|
||||
-- []p-id : {Γ : Con} → {F : For Γ} → {prf : Γ ⊢ F} → prf [ id {Γ} ]p ≡ prf
|
||||
-- []p-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ} → {prf : Γ ⊢ F} → prf [ α ∘ β ]p ≡ (prf [ β ]p) [ α ]p
|
||||
|
||||
-- → Prop⁺
|
||||
_▹ₚ_ : (Γ : Con) → For Γ → Con
|
||||
Γ ▹ₚ F = λ w → (Γ w) ×'' (F w)
|
||||
πₚ¹ : {Γ Δ : Con} → {F : For Γ} → Sub Δ (Γ ▹ₚ F) → Sub Δ Γ
|
||||
πₚ¹ σ w δ = proj×''₁ (σ w δ)
|
||||
πₚ² : {Γ Δ : Con} → {F : For Γ} → (σ : Sub Δ (Γ ▹ₚ F)) → Δ ⊢ (F [ πₚ¹ σ ]f)
|
||||
πₚ² σ w δ = proj×''₂ (σ w δ)
|
||||
_,ₚ_ : {Γ Δ : Con} → {F : For Γ} → (σ : Sub Δ Γ) → Δ ⊢ (F [ σ ]f) → Sub Δ (Γ ▹ₚ F)
|
||||
_,ₚ_ {F = F} σ pf w δ = (σ w δ) ,×'' pf w δ
|
||||
,ₚ∘πₚ : {Γ Δ : Con} → {F : For Γ} → {σ : Sub Δ (Γ ▹ₚ F)} → (πₚ¹ σ) ,ₚ (πₚ² σ) ≡ σ
|
||||
,ₚ∘πₚ = refl
|
||||
πₚ¹∘,ₚ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {F : For Γ} → {prf : Δ ⊢ (F [ σ ]f)} → πₚ¹ {Γ} {Δ} {F} (σ ,ₚ prf) ≡ σ
|
||||
πₚ¹∘,ₚ = refl
|
||||
,ₚ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{F : For Ξ}{prf : Γ ⊢ (F [ σ ]f)} →
|
||||
(_,ₚ_ {F = F} σ prf) ∘ δ ≡ (σ ∘ δ) ,ₚ (substP (λ F → Δ ⊢ F) (≡sym ([]f-∘ {α = δ} {β = σ} {F = F})) (prf [ δ ]p))
|
||||
,ₚ∘ {Γ} {Δ} {Ξ} {σ} {δ} {F} {prf} = refl
|
||||
|
||||
|
||||
|
||||
-- Implication
|
||||
_⇒_ : {Γ : Con} → For Γ → For Γ → For Γ
|
||||
F ⇒ G = λ w → λ γ → (∀ w' → w ≤ w' → (F w γ) → (G w γ))
|
||||
[]f-⇒ : {Γ Δ : Con} → {F G : For Γ} → {σ : Sub Δ Γ} → (F ⇒ G) [ σ ]f ≡ (F [ σ ]f) ⇒ (G [ σ ]f)
|
||||
[]f-⇒ = refl
|
||||
|
||||
-- Forall
|
||||
∀∀ : {Γ : Con} → For (Γ ▹ₜ) → For Γ
|
||||
∀∀ F = λ w → λ γ → ∀ t → F w (γ ,× t)
|
||||
[]f-∀∀ : {Γ Δ : Con} → {F : For (Γ ▹ₜ)} → {σ : Sub Δ Γ} → (∀∀ F) [ σ ]f ≡ (∀∀ (F [ (σ ∘ πₜ¹ id) ,ₜ πₜ² id ]f))
|
||||
[]f-∀∀ = refl
|
||||
|
||||
-- Lam & App
|
||||
lam : {Γ : Con} → {F : For Γ} → {G : For Γ} → (Γ ▹ₚ F) ⊢ (G [ πₚ¹ id ]f) → Γ ⊢ (F ⇒ G)
|
||||
lam prf = λ w γ w' s h → prf w (γ ,×'' h)
|
||||
app : {Γ : Con} → {F G : For Γ} → Γ ⊢ (F ⇒ G) → Γ ⊢ F → Γ ⊢ G
|
||||
app prf prf' = λ w γ → prf w γ w ≤refl (prf' w γ)
|
||||
-- Again, we don't write the _[_]p equalities as everything is in Prop
|
||||
|
||||
-- ∀i and ∀e
|
||||
∀i : {Γ : Con} → {F : For (Γ ▹ₜ)} → (Γ ▹ₜ) ⊢ F → Γ ⊢ (∀∀ F)
|
||||
∀i p w γ = λ t → p w (γ ,× t)
|
||||
∀e : {Γ : Con} → {F : For (Γ ▹ₜ)} → Γ ⊢ (∀∀ F) → {t : Tm Γ} → Γ ⊢ ( F [(id {Γ}) ,ₜ t ]f)
|
||||
∀e p {t} w γ = p w γ (t w γ)
|
||||
|
||||
|
||||
tod : FFOL
|
||||
tod = record
|
||||
{ Con = Con
|
||||
; Sub = Sub
|
||||
; _∘_ = _∘_
|
||||
; ∘-ass = refl
|
||||
; id = id
|
||||
; idl = refl
|
||||
; idr = refl
|
||||
; ◇ = ◇
|
||||
; ε = ε
|
||||
; ε-u = refl
|
||||
; Tm = Tm
|
||||
; _[_]t = _[_]t
|
||||
; []t-id = []t-id
|
||||
; []t-∘ = λ {Γ} {Δ} {Ξ} {α} {β} {t} → []t-∘ {Γ} {Δ} {Ξ} {α} {β} {t}
|
||||
; _▹ₜ = _▹ₜ
|
||||
; πₜ¹ = πₜ¹
|
||||
; πₜ² = πₜ²
|
||||
; _,ₜ_ = _,ₜ_
|
||||
; πₜ²∘,ₜ = λ {Γ} {Δ} {σ} → πₜ²∘,ₜ {Γ} {Δ} {σ}
|
||||
; πₜ¹∘,ₜ = λ {Γ} {Δ} {σ} {t} → πₜ¹∘,ₜ {Γ} {Δ} {σ} {t}
|
||||
; ,ₜ∘πₜ = ,ₜ∘πₜ
|
||||
; ,ₜ∘ = λ {Γ} {Δ} {Ξ} {σ} {δ} {t} → ,ₜ∘ {Γ} {Δ} {Ξ} {σ} {δ} {t}
|
||||
; For = For
|
||||
; _[_]f = _[_]f
|
||||
; []f-id = []f-id
|
||||
; []f-∘ = λ {Γ} {Δ} {Ξ} {α} {β} {F} → []f-∘ {Γ} {Δ} {Ξ} {α} {β} {F}
|
||||
; _⊢_ = _⊢_
|
||||
; _[_]p = _[_]p
|
||||
; _▹ₚ_ = _▹ₚ_
|
||||
; πₚ¹ = πₚ¹
|
||||
; πₚ² = πₚ²
|
||||
; _,ₚ_ = _,ₚ_
|
||||
; ,ₚ∘πₚ = ,ₚ∘πₚ
|
||||
; πₚ¹∘,ₚ = λ {Γ} {Δ} {F} {σ} {p} → πₚ¹∘,ₚ {Γ} {Δ} {F} {σ} {p}
|
||||
; ,ₚ∘ = λ {Γ} {Δ} {Ξ} {σ} {δ} {F} {prf} → ,ₚ∘ {Γ} {Δ} {Ξ} {σ} {δ} {F} {prf}
|
||||
; _⇒_ = _⇒_
|
||||
; []f-⇒ = λ {Γ} {F} {G} {σ} → []f-⇒ {Γ} {F} {G} {σ}
|
||||
; ∀∀ = ∀∀
|
||||
; []f-∀∀ = λ {Γ} {Δ} {F} {σ} → []f-∀∀ {Γ} {Δ} {F} {σ}
|
||||
; lam = lam
|
||||
; app = app
|
||||
; ∀i = ∀i
|
||||
; ∀e = ∀e
|
||||
; R = R
|
||||
; R[] = λ {Γ} {Δ} {σ} {t} {u} → R[] {Γ} {Δ} {σ} {t} {u}
|
||||
}
|
||||
|
||||
|
||||
{-
|
||||
-- Completeness proof
|
||||
|
||||
-- We first build our universal Kripke model
|
||||
|
||||
module ComplenessProof (M : FFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} {ℓ⁵}) where
|
||||
|
||||
-- We have a model, we construct the Universal Kripke model of this model
|
||||
|
||||
World : Set ℓ¹
|
||||
World = FFOL.Con M
|
||||
|
||||
_≤_ : World → World → Prop
|
||||
Γ ≤ Δ = {!FFOL.Sub M Δ Γ!}
|
||||
|
||||
UK : Kripke
|
||||
UK = record
|
||||
{ World = World
|
||||
; _≤_ = λ Δ Γ → {!FFOL.Sub M Δ Γ!}
|
||||
; ≤refl = {!FFOL.id M!}
|
||||
; ≤tran = {!FFOL.∘ M!}
|
||||
; TM = {!!}
|
||||
; TM≤ = {!!}
|
||||
; REL = {!!}
|
||||
; REL≤ = {!!}
|
||||
}
|
||||
-}
|
||||
\end{code}
|
||||
@ -5,7 +5,7 @@ open import PropUtil
|
||||
module FFOLCompleteness where
|
||||
|
||||
open import Agda.Primitive
|
||||
open import FinitaryFirstOrderLogic
|
||||
open import FFOL
|
||||
open import ListUtil
|
||||
|
||||
record Family : Set (lsuc (ℓ¹)) where
|
||||
@ -153,17 +153,17 @@ module FFOLCompleteness where
|
||||
record Presheaf : Set (lsuc (ℓ¹)) where
|
||||
field
|
||||
World : Set ℓ¹
|
||||
Arr : World → World → Set ℓ¹ -- arrows
|
||||
id-a : {w : World} → Arr w w -- id arrow
|
||||
_∘a_ : {w w' w'' : World} → Arr w w' → Arr w' w'' → Arr w w'' -- arrow composition
|
||||
∘a-ass : {w w' w'' w''' : World}{a : Arr w w'}{b : Arr w' w''}{c : Arr w'' w'''}
|
||||
→ ((a ∘a b) ∘a c) ≡ (a ∘a (b ∘a c))
|
||||
idl-a : {w w' : World} → {a : Arr w w'} → (id-a {w}) ∘a a ≡ a
|
||||
idr-a : {w w' : World} → {a : Arr w w'} → a ∘a (id-a {w'}) ≡ a
|
||||
_-w->_ : World → World → Set ℓ¹ -- arrows
|
||||
-w->id : {w : World} → w -w-> w -- id arrow
|
||||
_∘-w->_ : {w w' w'' : World} → w -w-> w' → w' -w-> w'' → w -w-> w'' -- arrow composition
|
||||
-w->ass : {w w' w'' w''' : World}{a : w -w-> w'}{b : w' -w-> w''}{c : w'' -w-> w'''}
|
||||
→ ((a ∘-w-> b) ∘-w-> c) ≡ (a ∘-w-> (b ∘-w-> c))
|
||||
-w->idl : {w w' : World} → {a : w -w-> w'} → (-w->id {w}) ∘-w-> a ≡ a
|
||||
-w->idr : {w w' : World} → {a : w -w-> w'} → a ∘-w-> (-w->id {w'}) ≡ a
|
||||
TM : World → Set ℓ¹
|
||||
TM≤ : {w w' : World} → Arr w w' → TM w' → TM w
|
||||
TM≤ : {w w' : World} → w -w-> w' → TM w' → TM w
|
||||
REL : (w : World) → TM w → TM w → Prop ℓ¹
|
||||
REL≤ : {w w' : World} → {t u : TM w'} → (eq : Arr w w') → REL w' t u → REL w (TM≤ eq t) (TM≤ eq u)
|
||||
REL≤ : {w w' : World} → {t u : TM w'} → (eq : w -w-> w') → REL w' t u → REL w (TM≤ eq t) (TM≤ eq u)
|
||||
infixr 10 _∘_
|
||||
Con = World → Set ℓ¹
|
||||
Sub : Con → Con → Set ℓ¹
|
||||
@ -227,7 +227,7 @@ module FFOLCompleteness where
|
||||
|
||||
-- Implication
|
||||
_⇒_ : {Γ : Con} → For Γ → For Γ → For Γ
|
||||
F ⇒ G = λ w → λ γ → (∀ w' → Arr w w' → (F w γ) → (G w γ))
|
||||
F ⇒ G = λ w → λ γ → (∀ w' → w -w-> w' → (F w γ) → (G w γ))
|
||||
|
||||
-- Forall
|
||||
∀∀ : {Γ : Con} → For (Γ ▹ₜ) → For Γ
|
||||
@ -237,7 +237,7 @@ module FFOLCompleteness where
|
||||
lam : {Γ : Con} → {F : For Γ} → {G : For Γ} → (Γ ▹ₚ F) ⊢ (G [ πₚ¹ id ]f) → Γ ⊢ (F ⇒ G)
|
||||
lam prf = λ w γ w' s h → prf w (γ ,×'' h)
|
||||
app : {Γ : Con} → {F G : For Γ} → Γ ⊢ (F ⇒ G) → Γ ⊢ F → Γ ⊢ G
|
||||
app prf prf' = λ w γ → prf w γ w id-a (prf' w γ)
|
||||
app prf prf' = λ w γ → prf w γ w -w->id (prf' w γ)
|
||||
-- Again, we don't write the _[_]p equalities as everything is in Prop
|
||||
|
||||
-- ∀i and ∀e
|
||||
@ -296,6 +296,28 @@ module FFOLCompleteness where
|
||||
; R[] = refl
|
||||
}
|
||||
|
||||
module U where
|
||||
|
||||
import FFOLInitial as I
|
||||
|
||||
psh : Presheaf
|
||||
psh = record
|
||||
{ World = I.Con
|
||||
; _-w->_ = I.Sub
|
||||
; -w->id = I.id
|
||||
; _∘-w->_ = λ σ σ' → σ' I.∘ σ
|
||||
; -w->ass = ≡sym I.∘-ass
|
||||
; -w->idl = I.idr
|
||||
; -w->idr = I.idl
|
||||
; TM = λ Γ → I.Tm (I.Con.t Γ)
|
||||
; TM≤ = λ σ t → t I.[ I.Sub.t σ ]t
|
||||
; REL = λ Γ t u → I.Pf (I.Con.t Γ) (I.Con.p Γ) (I.R t u)
|
||||
; REL≤ = λ s pf → (pf I.[ I.Sub.t s ]pₜ) I.[ I.Sub.p s ]p
|
||||
}
|
||||
|
||||
open Presheaf psh public
|
||||
|
||||
|
||||
-- Completeness proof
|
||||
|
||||
-- We first build our universal Kripke model
|
||||
@ -305,26 +327,4 @@ module FFOLCompleteness where
|
||||
-- We have a model, we construct the Universal Presheaf model of this model
|
||||
import FFOLInitial as I
|
||||
|
||||
UniversalPresheaf : Presheaf
|
||||
UniversalPresheaf = record
|
||||
{ World = I.Con
|
||||
; Arr = I.Sub
|
||||
; id-a = I.id
|
||||
; _∘a_ = λ σ σ' → σ' I.∘ σ
|
||||
; ∘a-ass = ≡sym I.∘-ass
|
||||
; idl-a = I.idr
|
||||
; idr-a = I.idl
|
||||
; TM = λ Γ → I.Tm (I.Con.t Γ)
|
||||
; TM≤ = λ σ t → t I.[ I.Sub.t σ ]t
|
||||
; REL = λ Γ t u → I.Pf Γ (I.r t u)
|
||||
; REL≤ = λ σ pf → (pf I.[ I.Sub.t σ ]pₜ) I.[ I.Sub.p σ ]p
|
||||
}
|
||||
|
||||
-- I.xx are from initial, xx are from up
|
||||
open Presheaf UniversalPresheaf
|
||||
|
||||
-- Now we want to show universality of this model, that is
|
||||
-- if you have a proof in UP, you have the same in I.
|
||||
|
||||
q : {Γ : Con}{A : For Γ} → Γ ⊢ A → I.Pf {!!} {!!}
|
||||
u : {Γ : Con}{A : For Γ} → I.Pf {!!} {!!} → Γ ⊢ A
|
||||
|
||||
550
FFOLInitial.agda
550
FFOLInitial.agda
@ -1,550 +0,0 @@
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module FFOLInitial where
|
||||
|
||||
open import FinitaryFirstOrderLogic
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
|
||||
-- First definition of terms and term contexts --
|
||||
data Cont : Set₁ where
|
||||
◇t : Cont
|
||||
_▹t⁰ : Cont → Cont
|
||||
variable
|
||||
Γₜ Δₜ Ξₜ : Cont
|
||||
data TmVar : Cont → Set₁ where
|
||||
tvzero : TmVar (Γₜ ▹t⁰)
|
||||
tvnext : TmVar Γₜ → TmVar (Γₜ ▹t⁰)
|
||||
|
||||
data Tm : Cont → Set₁ where
|
||||
var : TmVar Γₜ → Tm Γₜ
|
||||
|
||||
-- Now we can define formulæ
|
||||
data For : Cont → Set₁ where
|
||||
r : Tm Γₜ → Tm Γₜ → For Γₜ
|
||||
_⇒_ : For Γₜ → For Γₜ → For Γₜ
|
||||
∀∀ : For (Γₜ ▹t⁰) → For Γₜ
|
||||
|
||||
-- Then we define term substitutions, and the application of them on terms and formulæ
|
||||
data Subt : Cont → Cont → Set₁ where
|
||||
εₜ : Subt Γₜ ◇t
|
||||
_,ₜ_ : Subt Δₜ Γₜ → Tm Δₜ → Subt Δₜ (Γₜ ▹t⁰)
|
||||
|
||||
-- We subst on terms
|
||||
_[_]t : Tm Γₜ → Subt Δₜ Γₜ → Tm Δₜ
|
||||
var tvzero [ σ ,ₜ t ]t = t
|
||||
var (tvnext tv) [ σ ,ₜ t ]t = var tv [ σ ]t
|
||||
|
||||
-- We define liftings on term variables
|
||||
-- A term of n variables is a term of n+1 variables
|
||||
-- Same for a term array
|
||||
wkₜt : Tm Γₜ → Tm (Γₜ ▹t⁰)
|
||||
|
||||
wkₜt (var tv) = var (tvnext tv)
|
||||
|
||||
-- From a substition into n variables, we get a substitution into n+1 variables which don't use the last one
|
||||
wkₜσt : Subt Δₜ Γₜ → Subt (Δₜ ▹t⁰) Γₜ
|
||||
wkₜσt εₜ = εₜ
|
||||
wkₜσt (σ ,ₜ t) = (wkₜσt σ) ,ₜ (wkₜt t)
|
||||
wkₜσt-wkₜt : {tv : TmVar Γₜ} → {σ : Subt Δₜ Γₜ} → wkₜt (var tv [ σ ]t) ≡ var tv [ wkₜσt σ ]t
|
||||
wkₜσt-wkₜt {tv = tvzero} {σ = σ ,ₜ x} = refl
|
||||
wkₜσt-wkₜt {tv = tvnext tv} {σ = σ ,ₜ x} = wkₜσt-wkₜt {tv = tv} {σ = σ}
|
||||
|
||||
-- From a substitution into n variables, we construct a substitution from n+1 variables to n+1 variables which maps it to itself
|
||||
-- i.e. 0 -> 0 and for all i ->(old) σ(i) we get i+1 -> σ(i)+1
|
||||
liftₜσ : Subt Δₜ Γₜ → Subt (Δₜ ▹t⁰) (Γₜ ▹t⁰)
|
||||
liftₜσ σ = (wkₜσt σ) ,ₜ (var tvzero)
|
||||
|
||||
|
||||
-- We subst on formulæ
|
||||
_[_]f : For Γₜ → Subt Δₜ Γₜ → For Δₜ
|
||||
(r t u) [ σ ]f = r (t [ σ ]t) (u [ σ ]t)
|
||||
(A ⇒ B) [ σ ]f = (A [ σ ]f) ⇒ (B [ σ ]f)
|
||||
(∀∀ A) [ σ ]f = ∀∀ (A [ liftₜσ σ ]f)
|
||||
|
||||
-- We now can define identity on term substitutions
|
||||
idₜ : Subt Γₜ Γₜ
|
||||
idₜ {◇t} = εₜ
|
||||
idₜ {Γₜ ▹t⁰} = liftₜσ (idₜ {Γₜ})
|
||||
|
||||
_∘ₜ_ : Subt Δₜ Γₜ → Subt Ξₜ Δₜ → Subt Ξₜ Γₜ
|
||||
εₜ ∘ₜ β = εₜ
|
||||
(α ,ₜ x) ∘ₜ β = (α ∘ₜ β) ,ₜ (x [ β ]t)
|
||||
|
||||
|
||||
-- We have the access functions from the algebra, in restricted versions
|
||||
πₜ¹ : Subt Δₜ (Γₜ ▹t⁰) → Subt Δₜ Γₜ
|
||||
πₜ¹ (σₜ ,ₜ t) = σₜ
|
||||
πₜ² : Subt Δₜ (Γₜ ▹t⁰) → Tm Δₜ
|
||||
πₜ² (σₜ ,ₜ t) = t
|
||||
|
||||
-- And their equalities (the fact that there are reciprocical)
|
||||
πₜ²∘,ₜ : {σₜ : Subt Δₜ Γₜ} → {t : Tm Δₜ} → πₜ² (σₜ ,ₜ t) ≡ t
|
||||
πₜ²∘,ₜ = refl
|
||||
πₜ¹∘,ₜ : {σₜ : Subt Δₜ Γₜ} → {t : Tm Δₜ} → πₜ¹ (σₜ ,ₜ t) ≡ σₜ
|
||||
πₜ¹∘,ₜ = refl
|
||||
,ₜ∘πₜ : {σₜ : Subt Δₜ (Γₜ ▹t⁰)} → (πₜ¹ σₜ) ,ₜ (πₜ² σₜ) ≡ σₜ
|
||||
,ₜ∘πₜ {σₜ = σₜ ,ₜ t} = refl
|
||||
|
||||
-- We can also prove the substitution equalities
|
||||
[]t-id : {t : Tm Γₜ} → t [ idₜ {Γₜ} ]t ≡ t
|
||||
[]t-id {Γₜ ▹t⁰} {var tvzero} = refl
|
||||
[]t-id {Γₜ ▹t⁰} {var (tvnext tv)} = substP (λ t → t ≡ var (tvnext tv)) (wkₜσt-wkₜt {tv = tv} {σ = idₜ}) (substP (λ t → wkₜt t ≡ var (tvnext tv)) (≡sym ([]t-id {t = var tv})) refl)
|
||||
[]t-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → {t : Tm Γₜ} → t [ β ∘ₜ α ]t ≡ (t [ β ]t) [ α ]t
|
||||
[]t-∘ {α = α} {β = β ,ₜ t} {t = var tvzero} = refl
|
||||
[]t-∘ {α = α} {β = β ,ₜ t} {t = var (tvnext tv)} = []t-∘ {t = var tv}
|
||||
[]f-id : {F : For Γₜ} → F [ idₜ {Γₜ} ]f ≡ F
|
||||
[]f-id {F = r t u} = cong₂ r []t-id []t-id
|
||||
[]f-id {F = F ⇒ G} = cong₂ _⇒_ []f-id []f-id
|
||||
[]f-id {F = ∀∀ F} = cong ∀∀ []f-id
|
||||
wkₜσt-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → wkₜσt (β ∘ₜ α) ≡ (wkₜσt β ∘ₜ liftₜσ α)
|
||||
wkₜt[] : {α : Subt Δₜ Γₜ} → {t : Tm Γₜ} → wkₜt (t [ α ]t) ≡ (wkₜt t [ liftₜσ α ]t)
|
||||
wkₜσt-∘ {β = εₜ} = refl
|
||||
wkₜσt-∘ {β = β ,ₜ t} = cong₂ _,ₜ_ wkₜσt-∘ (wkₜt[] {t = t})
|
||||
wkₜt[] {α = α ,ₜ t} {var tvzero} = refl
|
||||
wkₜt[] {α = α ,ₜ t} {var (tvnext tv)} = wkₜt[] {t = var tv}
|
||||
liftₜσ-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → liftₜσ (β ∘ₜ α) ≡ (liftₜσ β) ∘ₜ (liftₜσ α)
|
||||
liftₜσ-∘ {α = α} {β = εₜ} = refl
|
||||
liftₜσ-∘ {α = α} {β = β ,ₜ t} = cong₂ _,ₜ_ (cong₂ _,ₜ_ wkₜσt-∘ (wkₜt[] {t = t})) refl
|
||||
[]f-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → {F : For Γₜ} → F [ β ∘ₜ α ]f ≡ (F [ β ]f) [ α ]f
|
||||
[]f-∘ {α = α} {β = β} {F = r t u} = cong₂ r ([]t-∘ {α = α} {β = β} {t = t}) ([]t-∘ {α = α} {β = β} {t = u})
|
||||
[]f-∘ {F = F ⇒ G} = cong₂ _⇒_ []f-∘ []f-∘
|
||||
[]f-∘ {F = ∀∀ F} = cong ∀∀ (≡tran (cong (λ σ → F [ σ ]f) liftₜσ-∘) []f-∘)
|
||||
R[] : {σ : Subt Δₜ Γₜ} → {t u : Tm Γₜ} → (r t u) [ σ ]f ≡ r (t [ σ ]t) (u [ σ ]t)
|
||||
R[] = refl
|
||||
lem3 : {α : Subt Γₜ Δₜ} → {β : Subt Ξₜ Γₜ} → α ∘ₜ (wkₜσt β) ≡ wkₜσt (α ∘ₜ β)
|
||||
lem3 {α = εₜ} = refl
|
||||
lem3 {α = α ,ₜ var tv} = cong₂ _,ₜ_ (lem3 {α = α}) (≡sym (wkₜσt-wkₜt {tv = tv}))
|
||||
wk[,] : {t : Tm Γₜ}{u : Tm Δₜ}{β : Subt Δₜ Γₜ} → (wkₜt t) [ β ,ₜ u ]t ≡ t [ β ]t
|
||||
wk[,] {t = var tvzero} = refl
|
||||
wk[,] {t = var (tvnext tv)} = refl
|
||||
wk∘, : {α : Subt Γₜ Δₜ}{β : Subt Ξₜ Γₜ}{t : Tm Ξₜ} → (wkₜσt α) ∘ₜ (β ,ₜ t) ≡ (α ∘ₜ β)
|
||||
wk∘, {α = εₜ} = refl
|
||||
wk∘, {α = α ,ₜ t} {β = β} = cong₂ _,ₜ_ (wk∘, {α = α}) (wk[,] {t = t} {β = β})
|
||||
σ-idl : {α : Subt Δₜ Γₜ} → idₜ ∘ₜ α ≡ α
|
||||
σ-idl {α = εₜ} = refl
|
||||
σ-idl {α = α ,ₜ x} = cong₂ _,ₜ_ (≡tran wk∘, σ-idl) refl
|
||||
σ-idr : {α : Subt Δₜ Γₜ} → α ∘ₜ idₜ ≡ α
|
||||
σ-idr {α = εₜ} = refl
|
||||
σ-idr {α = α ,ₜ x} = cong₂ _,ₜ_ σ-idr []t-id
|
||||
∘ₜ-ass : {Γₜ Δₜ Ξₜ Ψₜ : Cont}{α : Subt Γₜ Δₜ}{β : Subt Δₜ Ξₜ}{γ : Subt Ξₜ Ψₜ} → (γ ∘ₜ β) ∘ₜ α ≡ γ ∘ₜ (β ∘ₜ α)
|
||||
∘ₜ-ass {α = α} {β} {εₜ} = refl
|
||||
∘ₜ-ass {α = α} {β} {γ ,ₜ x} = cong₂ _,ₜ_ ∘ₜ-ass (≡sym ([]t-∘ {t = x}))
|
||||
[]f-∀∀ : {A : For (Γₜ ▹t⁰)} → {σₜ : Subt Δₜ Γₜ} → (∀∀ A) [ σₜ ]f ≡ (∀∀ (A [ (σₜ ∘ₜ πₜ¹ idₜ) ,ₜ πₜ² idₜ ]f))
|
||||
[]f-∀∀ {A = A} = cong ∀∀ (cong (_[_]f A) (cong₂ _,ₜ_ (≡tran (cong wkₜσt (≡sym σ-idr)) (≡sym lem3)) refl))
|
||||
εₜ-u : {σₜ : Subt Γₜ ◇t} → σₜ ≡ εₜ
|
||||
εₜ-u {σₜ = εₜ} = refl
|
||||
|
||||
data Conp : Cont → Set₁ -- pu tit in Prop
|
||||
variable
|
||||
Γₚ Γₚ' : Conp Γₜ
|
||||
Δₚ Δₚ' : Conp Δₜ
|
||||
Ξₚ : Conp Ξₜ
|
||||
|
||||
data Conp where
|
||||
◇p : Conp Γₜ
|
||||
_▹p⁰_ : Conp Γₜ → For Γₜ → Conp Γₜ
|
||||
|
||||
record Con : Set₁ where
|
||||
constructor con
|
||||
field
|
||||
t : Cont
|
||||
p : Conp t
|
||||
|
||||
◇ : Con
|
||||
◇ = con ◇t ◇p
|
||||
|
||||
|
||||
_▹p_ : (Γ : Con) → For (Con.t Γ) → Con
|
||||
Γ ▹p A = con (Con.t Γ) (Con.p Γ ▹p⁰ A)
|
||||
|
||||
variable
|
||||
Γ Δ Ξ : Con
|
||||
|
||||
|
||||
|
||||
-- We can add term, that will not be used in the formulæ already present
|
||||
-- (that's why we use wkₜσt)
|
||||
_▹tp : Conp Γₜ → Conp (Γₜ ▹t⁰)
|
||||
◇p ▹tp = ◇p
|
||||
(Γₚ ▹p⁰ A) ▹tp = (Γₚ ▹tp) ▹p⁰ (A [ wkₜσt idₜ ]f)
|
||||
|
||||
_▹t : Con → Con
|
||||
Γ ▹t = con ((Con.t Γ) ▹t⁰) (Con.p Γ ▹tp)
|
||||
|
||||
data PfVar : (Γ : Con) → For (Con.t Γ) → Set₁ where
|
||||
pvzero : {A : For (Con.t Γ)} → PfVar (Γ ▹p A) A
|
||||
pvnext : {A B : For (Con.t Γ)} → PfVar Γ A → PfVar (Γ ▹p B) A
|
||||
|
||||
data Pf : (Γ : Con) → For (Con.t Γ) → Prop₁ where
|
||||
var : {A : For (Con.t Γ)} → PfVar Γ A → Pf Γ A
|
||||
app : {A B : For (Con.t Γ)} → Pf Γ (A ⇒ B) → Pf Γ A → Pf Γ B
|
||||
lam : {A B : For (Con.t Γ)} → Pf (Γ ▹p A) B → Pf Γ (A ⇒ B)
|
||||
p∀∀e : {A : For ((Con.t Γ) ▹t⁰)} → {t : Tm (Con.t Γ)} → Pf Γ (∀∀ A) → Pf Γ (A [ idₜ ,ₜ t ]f)
|
||||
p∀∀i : {A : For (Con.t (Γ ▹t))} → Pf (Γ ▹t) A → Pf Γ (∀∀ A)
|
||||
|
||||
|
||||
data Subp : {Δₜ : Cont} → Conp Δₜ → Conp Δₜ → Set₁ where
|
||||
εₚ : Subp Δₚ ◇p
|
||||
_,ₚ_ : {A : For Δₜ} → (σ : Subp Δₚ Δₚ') → Pf (con Δₜ Δₚ) A → Subp Δₚ (Δₚ' ▹p⁰ A)
|
||||
|
||||
|
||||
_[_]c : Conp Γₜ → Subt Δₜ Γₜ → Conp Δₜ
|
||||
◇p [ σₜ ]c = ◇p
|
||||
(Γₚ ▹p⁰ A) [ σₜ ]c = (Γₚ [ σₜ ]c) ▹p⁰ (A [ σₜ ]f)
|
||||
|
||||
[]c-id : Γₚ [ idₜ ]c ≡ Γₚ
|
||||
[]c-id {Γₚ = ◇p} = refl
|
||||
[]c-id {Γₚ = Γₚ ▹p⁰ x} = cong₂ _▹p⁰_ []c-id []f-id
|
||||
|
||||
[]c-∘ : {α : Subt Δₜ Ξₜ} {β : Subt Γₜ Δₜ} {Ξₚ : Conp Ξₜ} → Ξₚ [ α ∘ₜ β ]c ≡ (Ξₚ [ α ]c) [ β ]c
|
||||
[]c-∘ {α = α} {β = β} {◇p} = refl
|
||||
[]c-∘ {α = α} {β = β} {Ξₚ ▹p⁰ A} = cong₂ _▹p⁰_ []c-∘ []f-∘
|
||||
|
||||
|
||||
record Sub (Γ : Con) (Δ : Con) : Set₁ where
|
||||
constructor sub
|
||||
field
|
||||
t : Subt (Con.t Γ) (Con.t Δ)
|
||||
p : Subp {Con.t Γ} (Con.p Γ) ((Con.p Δ) [ t ]c)
|
||||
|
||||
-- An order on contexts, where we can only change positions
|
||||
infixr 5 _∈ₚ*_
|
||||
data _∈ₚ*_ : Conp Γₜ → Conp Γₜ → Set₁ where
|
||||
zero∈ₚ* : ◇p ∈ₚ* Γₚ
|
||||
next∈ₚ* : {A : For Δₜ} → PfVar (con Δₜ Δₚ) A → Δₚ' ∈ₚ* Δₚ → (Δₚ' ▹p⁰ A) ∈ₚ* Δₚ
|
||||
-- Allows to grow ∈ₚ* to the right
|
||||
right∈ₚ* :{A : For Δₜ} → Γₚ ∈ₚ* Δₚ → Γₚ ∈ₚ* (Δₚ ▹p⁰ A)
|
||||
right∈ₚ* zero∈ₚ* = zero∈ₚ*
|
||||
right∈ₚ* (next∈ₚ* x h) = next∈ₚ* (pvnext x) (right∈ₚ* h)
|
||||
both∈ₚ* : {A : For Γₜ} → Γₚ ∈ₚ* Δₚ → (Γₚ ▹p⁰ A) ∈ₚ* (Δₚ ▹p⁰ A)
|
||||
both∈ₚ* zero∈ₚ* = next∈ₚ* pvzero zero∈ₚ*
|
||||
both∈ₚ* (next∈ₚ* x h) = next∈ₚ* pvzero (next∈ₚ* (pvnext x) (right∈ₚ* h))
|
||||
refl∈ₚ* : Γₚ ∈ₚ* Γₚ
|
||||
refl∈ₚ* {Γₚ = ◇p} = zero∈ₚ*
|
||||
refl∈ₚ* {Γₚ = Γₚ ▹p⁰ x} = both∈ₚ* refl∈ₚ*
|
||||
|
||||
∈ₚ▹tp : {A : For Δₜ} → PfVar (con Δₜ Δₚ) A → PfVar (con Δₜ Δₚ ▹t) (A [ wkₜσt idₜ ]f)
|
||||
∈ₚ▹tp pvzero = pvzero
|
||||
∈ₚ▹tp (pvnext x) = pvnext (∈ₚ▹tp x)
|
||||
∈ₚ*▹tp : Γₚ ∈ₚ* Δₚ → (Γₚ ▹tp) ∈ₚ* (Δₚ ▹tp)
|
||||
∈ₚ*▹tp zero∈ₚ* = zero∈ₚ*
|
||||
∈ₚ*▹tp (next∈ₚ* x s) = next∈ₚ* (∈ₚ▹tp x) (∈ₚ*▹tp s)
|
||||
|
||||
mon∈ₚ∈ₚ* : {A : For Δₜ} → PfVar (con Δₜ Δₚ') A → Δₚ' ∈ₚ* Δₚ → PfVar (con Δₜ Δₚ) A
|
||||
mon∈ₚ∈ₚ* pvzero (next∈ₚ* x x₁) = x
|
||||
mon∈ₚ∈ₚ* (pvnext s) (next∈ₚ* x x₁) = mon∈ₚ∈ₚ* s x₁
|
||||
|
||||
∈ₚ*→Sub : Δₚ ∈ₚ* Δₚ' → Subp {Δₜ} Δₚ' Δₚ
|
||||
∈ₚ*→Sub zero∈ₚ* = εₚ
|
||||
∈ₚ*→Sub (next∈ₚ* x s) = ∈ₚ*→Sub s ,ₚ var x
|
||||
|
||||
|
||||
wkₚp : {A : For Δₜ} → Δₚ ∈ₚ* Δₚ' → Pf (con Δₜ Δₚ) A → Pf (con Δₜ Δₚ') A
|
||||
wkₚp s (var pv) = var (mon∈ₚ∈ₚ* pv s)
|
||||
wkₚp s (app pf pf₁) = app (wkₚp s pf) (wkₚp s pf₁)
|
||||
wkₚp s (lam {A = A} pf) = lam (wkₚp (both∈ₚ* s) pf)
|
||||
wkₚp s (p∀∀e pf) = p∀∀e (wkₚp s pf)
|
||||
wkₚp s (p∀∀i pf) = p∀∀i (wkₚp (∈ₚ*▹tp s) pf)
|
||||
lliftₚ : {Γₚ : Conp Δₜ} → Δₚ ∈ₚ* Δₚ' → Subp {Δₜ} Δₚ Γₚ → Subp {Δₜ} Δₚ' Γₚ
|
||||
lliftₚ s εₚ = εₚ
|
||||
lliftₚ s (σₚ ,ₚ pf) = lliftₚ s σₚ ,ₚ wkₚp s pf
|
||||
|
||||
wkₚσt : {Δₜ : Cont} {Δₚ Γₚ : Conp Δₜ}{A : For Δₜ} → Subp {Δₜ} Δₚ Γₚ → Subp {Δₜ} (Δₚ ▹p⁰ A) Γₚ
|
||||
wkₚσt εₚ = εₚ
|
||||
wkₚσt (σₚ ,ₚ pf) = (wkₚσt σₚ) ,ₚ wkₚp (right∈ₚ* refl∈ₚ*) pf
|
||||
--wkₜσt-wkₜt : {tv : TmVar Γₜ} → {σ : Subt Δₜ Γₜ} → wkₜt (var tv [ σ ]t) ≡ var tv [ wkₜσt σ ]t
|
||||
--wkₜσt-wkₜt {tv = tvzero} {σ = σ ,ₜ x} = refl
|
||||
--wkₜσt-wkₜt {tv = tvnext tv} {σ = σ ,ₜ x} = wkₜσt-wkₜt {tv = tv} {σ = σ}
|
||||
|
||||
-- From a substitution into n variables, we construct a substitution from n+1 variables to n+1 variables which maps it to itself
|
||||
-- i.e. 0 -> 0 and for all i ->(old) σ(i) we get i+1 -> σ(i)+1
|
||||
liftₚσ : {Δₜ : Cont}{Δₚ Γₚ : Conp Δₜ}{A : For Δₜ} → Subp {Δₜ} Δₚ Γₚ → Subp {Δₜ} (Δₚ ▹p⁰ A) (Γₚ ▹p⁰ A)
|
||||
liftₚσ σ = (wkₚσt σ) ,ₚ (var pvzero)
|
||||
|
||||
idₚ : Subp {Δₜ} Δₚ Δₚ
|
||||
idₚ {Δₚ = ◇p} = εₚ
|
||||
idₚ {Δₚ = Δₚ ▹p⁰ x} = liftₚσ (idₚ {Δₚ = Δₚ})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
lem7 : {σ : Subt Δₜ Γₜ} → ((Δₚ ▹tp) [ liftₜσ σ ]c) ≡ ((Δₚ [ σ ]c) ▹tp)
|
||||
lem7 {Δₚ = ◇p} = refl
|
||||
lem7 {Δₚ = Δₚ ▹p⁰ A} = cong₂ _▹p⁰_ lem7 (≡tran² (≡sym []f-∘) (cong (λ σ → A [ σ ]f) (≡tran² (≡sym wkₜσt-∘) (cong wkₜσt (≡tran σ-idl (≡sym σ-idr))) (≡sym lem3))) []f-∘)
|
||||
lem8 : {σ : Subt Δₜ Γₜ} {t : Tm Γₜ} → ((wkₜσt σ ∘ₜ (idₜ ,ₜ (t [ σ ]t))) ,ₜ (t [ σ ]t)) ≡ ((idₜ ∘ₜ σ) ,ₜ (t [ σ ]t))
|
||||
lem8 = cong₂ _,ₜ_ (≡tran² wk∘, σ-idr (≡sym σ-idl)) refl
|
||||
|
||||
_[_]pvₜ : {A : For Δₜ} → PfVar (con Δₜ Δₚ) A → (σ : Subt Γₜ Δₜ) → PfVar (con Γₜ (Δₚ [ σ ]c)) (A [ σ ]f)
|
||||
_[_]pₜ : {A : For Δₜ} → Pf (con Δₜ Δₚ) A → (σ : Subt Γₜ Δₜ) → Pf (con Γₜ (Δₚ [ σ ]c)) (A [ σ ]f)
|
||||
pvzero [ σ ]pvₜ = pvzero
|
||||
pvnext pv [ σ ]pvₜ = pvnext (pv [ σ ]pvₜ)
|
||||
var pv [ σ ]pₜ = var (pv [ σ ]pvₜ)
|
||||
app pf pf' [ σ ]pₜ = app (pf [ σ ]pₜ) (pf' [ σ ]pₜ)
|
||||
lam pf [ σ ]pₜ = lam (pf [ σ ]pₜ)
|
||||
_[_]pₜ {Δₚ = Δₚ} {Γₜ = Γₜ} (p∀∀e {A = A} {t = t} pf) σ = substP (λ F → Pf (con Γₜ (Δₚ [ σ ]c)) F) (≡tran² (≡sym []f-∘) (cong (λ σ → A [ σ ]f) (lem8 {t = t})) ([]f-∘)) (p∀∀e {t = t [ σ ]t} (pf [ σ ]pₜ))
|
||||
_[_]pₜ {Γₜ = Γₜ} (p∀∀i pf) σ = p∀∀i (substP (λ Ξₚ → Pf (con (Γₜ ▹t⁰) (Ξₚ)) _) lem7 (pf [ liftₜσ σ ]pₜ))
|
||||
|
||||
_[_]σₚ : Subp {Δₜ} Δₚ Δₚ' → (σ : Subt Γₜ Δₜ) → Subp {Γₜ} (Δₚ [ σ ]c) (Δₚ' [ σ ]c)
|
||||
εₚ [ σₜ ]σₚ = εₚ
|
||||
(σₚ ,ₚ pf) [ σₜ ]σₚ = (σₚ [ σₜ ]σₚ) ,ₚ (pf [ σₜ ]pₜ)
|
||||
|
||||
lem9 : (Δₚ [ wkₜσt idₜ ]c) ≡ (Δₚ ▹tp)
|
||||
lem9 {Δₚ = ◇p} = refl
|
||||
lem9 {Δₚ = Δₚ ▹p⁰ x} = cong₂ _▹p⁰_ lem9 refl
|
||||
wkₜσₚ : Subp {Δₜ} Δₚ' Δₚ → Subp {Δₜ ▹t⁰} (Δₚ' ▹tp) (Δₚ ▹tp)
|
||||
wkₜσₚ εₚ = εₚ
|
||||
wkₜσₚ {Δₜ = Δₜ} (_,ₚ_ {A = A} σₚ pf) = (wkₜσₚ σₚ) ,ₚ substP (λ Ξₚ → Pf (con (Δₜ ▹t⁰) Ξₚ) (A [ wkₜσt idₜ ]f)) lem9 (_[_]pₜ {Γₜ = Δₜ ▹t⁰} pf (wkₜσt idₜ))
|
||||
|
||||
_[_]p : {A : For Δₜ} → Pf (con Δₜ Δₚ) A → (σ : Subp {Δₜ} Δₚ' Δₚ) → Pf (con Δₜ Δₚ') A
|
||||
var pvzero [ σ ,ₚ pf ]p = pf
|
||||
var (pvnext pv) [ σ ,ₚ pf ]p = var pv [ σ ]p
|
||||
app pf pf₁ [ σ ]p = app (pf [ σ ]p) (pf₁ [ σ ]p)
|
||||
lam pf [ σ ]p = lam (pf [ lliftₚ (right∈ₚ* refl∈ₚ*) σ ,ₚ var pvzero ]p)
|
||||
p∀∀e pf [ σ ]p = p∀∀e (pf [ σ ]p)
|
||||
p∀∀i pf [ σ ]p = p∀∀i (pf [ wkₜσₚ σ ]p)
|
||||
|
||||
|
||||
_∘ₚ_ : {Γₚ Δₚ Ξₚ : Conp Δₜ} → Subp {Δₜ} Δₚ Ξₚ → Subp {Δₜ} Γₚ Δₚ → Subp {Δₜ} Γₚ Ξₚ
|
||||
εₚ ∘ₚ β = εₚ
|
||||
(α ,ₚ pf) ∘ₚ β = (α ∘ₚ β) ,ₚ (pf [ β ]p)
|
||||
ε-u : {Γₚ : Conp Γₜ} → {σ : Subp Γₚ ◇p} → σ ≡ εₚ {Δₚ = Γₚ}
|
||||
ε-u {σ = εₚ} = refl
|
||||
lemJ : {Δₜ : Cont}{Δₚ : Conp Δₜ}{A : For Δₜ} → Pf (con Δₜ Δₚ) A → (Pf (con Δₜ (Δₚ [ idₜ ]c)) (A [ idₜ ]f))
|
||||
lemJ {Δₜ}{Δₚ}{A} pf = substP (Pf (con Δₜ (Δₚ [ idₜ ]c))) (≡sym []f-id) (substP (λ Ξₚ → Pf (con Δₜ Ξₚ) A) (≡sym []c-id) pf)
|
||||
[]σₚ-id : {σₚ : Subp {Δₜ} Δₚ Δₚ'} → coe (cong₂ Subp []c-id []c-id) (σₚ [ idₜ ]σₚ) ≡ σₚ
|
||||
[]σₚ-id {σₚ = εₚ} = ε-u
|
||||
[]σₚ-id {Δₜ}{Δₚ}{Δₚ' ▹p⁰ A} {σₚ = σₚ ,ₚ x} = substP (λ ξ → coe (cong₂ Subp []c-id []c-id) (ξ ,ₚ (x [ idₜ ]pₜ)) ≡ (σₚ ,ₚ x)) (≡sym (coeshift ([]σₚ-id)))
|
||||
(≡sym (coeshift {eq = cong₂ Subp (≡sym []c-id) (≡sym []c-id)}
|
||||
(substfpoly'' {A = (Conp Δₜ) × (Conp Δₜ)}{P = λ W F → Subp (proj×₁ W) ((proj×₂ W) ▹p⁰ F)}{R = λ W → Subp (proj×₁ W) (proj×₂ W)}{Q = λ W F → Pf (con Δₜ (proj×₁ W)) F}{α = Δₚ ,× Δₚ'}{ε = A}{eq = ×≡ (≡sym []c-id) (≡sym []c-id)}{eq'' = ≡sym []f-id}{f = λ {W} {F} ξ pf → _,ₚ_ ξ pf}{x = σₚ}{y = x})))
|
||||
[]σₚ-∘ : {Ξₚ Ξₚ' : Conp Ξₜ}{α : Subt Δₜ Ξₜ} {β : Subt Γₜ Δₜ} {σₚ : Subp {Ξₜ} Ξₚ Ξₚ'}
|
||||
--{eq₅ : Subp (Ξₚ [ βₜ ]c) ((Ψₚ [ γₜ ]c) [ βₜ ]c) ≡ Subp (Ξₚ [ βₜ ]c) (Ψₚ [ γₜ ∘ₜ βₜ ]c)}
|
||||
→ coe (cong₂ Subp (≡sym []c-∘) (≡sym []c-∘)) ((σₚ [ α ]σₚ) [ β ]σₚ) ≡ σₚ [ α ∘ₜ β ]σₚ
|
||||
[]σₚ-∘ {σₚ = εₚ} = ε-u
|
||||
[]σₚ-∘ {Ξₜ}{Δₜ}{Γₜ}{Ξₚ}{Δₚ' ▹p⁰ A}{α}{β}{σₚ = σₚ ,ₚ pf} =
|
||||
substP (λ ξ → coe (cong₂ Subp (≡sym []c-∘) (≡sym []c-∘)) (ξ ,ₚ ((pf [ α ]pₜ) [ β ]pₜ)) ≡ ((σₚ [ α ∘ₜ β ]σₚ) ,ₚ (pf [ α ∘ₜ β ]pₜ))) (≡sym (coeshift []σₚ-∘))
|
||||
(≡sym (coeshift {eq = cong₂ Subp []c-∘ []c-∘}
|
||||
(substfpoly''
|
||||
{A = (Conp Γₜ) × (Conp Γₜ)}
|
||||
{P = λ W F → Subp (proj×₁ W) ((proj×₂ W) ▹p⁰ F)}
|
||||
{R = λ W → Subp (proj×₁ W) (proj×₂ W)}
|
||||
{Q = λ W F → Pf (con Γₜ (proj×₁ W)) F}
|
||||
{eq = cong₂ _,×_ []c-∘ []c-∘}
|
||||
{eq'' = []f-∘ {α = β} {β = α} {F = A}}
|
||||
{f = λ {W} {F} ξ pf → _,ₚ_ ξ pf}{x = σₚ [ α ∘ₜ β ]σₚ}{y = pf [ α ∘ₜ β ]pₜ})
|
||||
))
|
||||
wkₚ∘, : {Δₜ : Cont}{Γₚ Δₚ Ξₚ : Conp Δₜ}{α : Subp {Δₜ} Γₚ Δₚ}{β : Subp {Δₜ} Ξₚ Γₚ}{A : For Δₜ}{pf : Pf (con Δₜ Ξₚ) A} → (wkₚσt α) ∘ₚ (β ,ₚ pf) ≡ (α ∘ₚ β)
|
||||
wkₚ∘, {α = εₚ} = refl
|
||||
wkₚ∘, {α = α ,ₚ pf} {β = β} {pf = pf'} = cong (λ ξ → ξ ,ₚ (pf [ β ]p)) wkₚ∘,
|
||||
idlₚ : {Γₚ Δₚ : Conp Γₜ} {σₚ : Subp Γₚ Δₚ} → (idₚ {Δₚ = Δₚ}) ∘ₚ σₚ ≡ σₚ
|
||||
idlₚ {Δₚ = ◇p} {εₚ} = refl
|
||||
idlₚ {Δₚ = Δₚ ▹p⁰ pf} {σₚ ,ₚ pf'} = cong (λ ξ → ξ ,ₚ pf') (≡tran wkₚ∘, (idlₚ {σₚ = σₚ}))
|
||||
idrₚ : {Γₚ Δₚ : Conp Γₜ} {σₚ : Subp Γₚ Δₚ} → σₚ ∘ₚ (idₚ {Δₚ = Γₚ}) ≡ σₚ
|
||||
idrₚ {σₚ = εₚ} = refl
|
||||
idrₚ {σₚ = σₚ ,ₚ prf} = cong (λ X → X ,ₚ prf) (idrₚ {σₚ = σₚ})
|
||||
wkₚ[] : {σₜ : Subt Γₜ Δₜ} {σₚ : Subp Δₚ Δₚ'} {A : For Δₜ} → (wkₚσt {A = A} σₚ) [ σₜ ]σₚ ≡ wkₚσt (σₚ [ σₜ ]σₚ)
|
||||
wkₚ[] {σₚ = εₚ} = refl
|
||||
wkₚ[] {σₚ = σₚ ,ₚ x} = cong (λ ξ → ξ ,ₚ _) (wkₚ[] {σₚ = σₚ})
|
||||
idₚ[] : {σₜ : Subt Γₜ Δₜ} → ((idₚ {Δₜ} {Δₚ}) [ σₜ ]σₚ) ≡ idₚ {Γₜ} {Δₚ [ σₜ ]c}
|
||||
idₚ[] {Δₚ = ◇p} = refl
|
||||
idₚ[] {Δₚ = Δₚ ▹p⁰ A} = cong (λ ξ → ξ ,ₚ var pvzero) (≡tran wkₚ[] (cong wkₚσt idₚ[]))
|
||||
|
||||
|
||||
id : Sub Γ Γ
|
||||
id {Γ} = sub idₜ (subst (Subp _) (≡sym []c-id) idₚ)
|
||||
_∘_ : Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
sub αₜ αₚ ∘ sub βₜ βₚ = sub (αₜ ∘ₜ βₜ) (subst (Subp _) (≡sym []c-∘) (αₚ [ βₜ ]σₚ) ∘ₚ βₚ)
|
||||
idl : {Γ Δ : Con} {σ : Sub Γ Δ} → (id {Δ}) ∘ σ ≡ σ
|
||||
idl {Δ = Δ} {σ = sub σₜ σₚ} = cong₂' sub σ-idl (≡tran (substfpoly {α = ((Con.p Δ) [ idₜ ∘ₜ σₜ ]c)} {β = ((Con.p Δ) [ σₜ ]c)} {eq = cong (λ ξ → Con.p Δ [ ξ ]c) σ-idl} {f = λ {Ξₚ} ξ → _∘ₚ_ {Ξₚ = Ξₚ} ξ σₚ}) (≡tran (cong₂ _∘ₚ_ (≡tran³ coecoe-coe (substfpoly {eq = []c-id} {f = λ {Ξₚ} ξ → _[_]σₚ {Δₚ = Con.p Δ} {Δₚ' = Ξₚ} ξ σₜ}) (cong (λ ξ → ξ [ σₜ ]σₚ) coeaba) idₚ[]) refl) idlₚ))
|
||||
lemK : {Γ Δ : Con}{σₜ : Subt (Con.t Γ) (Con.t Δ)}{σₚ : Subp (Con.p Γ [ idₜ ]c) ((Con.p Δ [ σₜ ]c)[ idₜ ]c)}
|
||||
{eq1 : Subp (Con.p Γ) ((Con.p Δ [ σₜ ]c) [ idₜ ]c) ≡ Subp (Con.p Γ) (Con.p Δ [ σₜ ]c)}
|
||||
{eq2 : Subp (Con.p Γ) (Con.p Γ) ≡ Subp (Con.p Γ) (Con.p Γ [ idₜ ]c)}
|
||||
{eq3 : Subp (Con.p Γ [ idₜ ]c) ((Con.p Δ [ σₜ ]c)[ idₜ ]c) ≡ Subp (Con.p Γ) (Con.p Δ [ σₜ ]c)}
|
||||
→ coe eq1 (σₚ ∘ₚ coe eq2 idₚ)
|
||||
≡ (coe eq3 σₚ ∘ₚ idₚ)
|
||||
lemK {Γ}{Δ}{σₚ = σₚ}{eq1}{eq2}{eq3} = substP (λ X → coe eq1 (X ∘ₚ coe eq2 idₚ) ≡ (coe eq3 σₚ ∘ₚ idₚ)) (coeaba {eq1 = eq3}{eq2 = ≡sym eq3}) (coep∘ {p = λ {Γₚ}{Δₚ}{Ξₚ} x y → _∘ₚ_ {Δₚ = Γₚ} x y} {eq1 = refl}{eq2 = ≡sym []c-id}{eq3 = ≡sym []c-id})
|
||||
idr : {Γ Δ : Con} {σ : Sub Γ Δ} → σ ∘ (id {Γ}) ≡ σ
|
||||
idr {Γ} {Δ} {σ = sub σₜ σₚ} = cong₂' sub σ-idr (≡tran⁴ (cong (coe _) (≡sym (substfpoly {eq = ≡sym ([]c-∘ {α = σₜ} {β = idₜ}{Ξₚ = Con.p Δ})} {f = λ {Ξₚ} ξ → _∘ₚ_ {Ξₚ = Ξₚ} ξ (coe (cong (Subp (Con.p Γ)) (≡sym []c-id)) idₚ)} {x = σₚ [ idₜ ]σₚ}))) coecoe-coe lemK idrₚ []σₚ-id)
|
||||
∘ₚ-ass : {Γₚ Δₚ Ξₚ Ψₚ : Conp Γₜ}{αₚ : Subp Γₚ Δₚ}{βₚ : Subp Δₚ Ξₚ}{γₚ : Subp Ξₚ Ψₚ} → (γₚ ∘ₚ βₚ) ∘ₚ αₚ ≡ γₚ ∘ₚ (βₚ ∘ₚ αₚ)
|
||||
∘ₚ-ass {γₚ = εₚ} = refl
|
||||
∘ₚ-ass {αₚ = αₚ} {βₚ} {γₚ ,ₚ x} = cong (λ ξ → ξ ,ₚ (x [ βₚ ∘ₚ αₚ ]p)) ∘ₚ-ass
|
||||
|
||||
lemG' :
|
||||
{Γₜ Δₜ : Cont}{Γₚ : Conp Γₜ}{Δₚ : Conp Δₜ}{Ξₚ : Conp Δₜ}{Ψₚ : Conp Δₜ}
|
||||
{αₜ : Subt Γₜ Δₜ}{γₚ : Subp Ξₚ Ψₚ}{βₚ : Subp Δₚ Ξₚ}{αₚ : Subp Γₚ (Δₚ [ αₜ ]c)}
|
||||
→ ((γₚ ∘ₚ βₚ) [ αₜ ]σₚ) ∘ₚ αₚ ≡ (γₚ [ αₜ ]σₚ) ∘ₚ ((βₚ [ αₜ ]σₚ) ∘ₚ αₚ)
|
||||
lemG' {γₚ = εₚ} = refl
|
||||
lemG' {αₜ = αₜ}{γₚ ,ₚ x}{βₚ}{αₚ} = cong (λ ξ → ξ ,ₚ (((x [ βₚ ]p) [ αₜ ]pₜ) [ αₚ ]p)) (lemG' {γₚ = γₚ})
|
||||
lemG :
|
||||
{Γₜ Δₜ Ξₜ Ψₜ : Cont}{Γₚ : Conp Γₜ}{Δₚ : Conp Δₜ}{Ξₚ : Conp Ξₜ}{Ψₚ : Conp Ψₜ}
|
||||
{αₜ : Subt Γₜ Δₜ}{βₜ : Subt Δₜ Ξₜ}{γₜ : Subt Ξₜ Ψₜ}{γₚ : Subp Ξₚ (Ψₚ [ γₜ ]c)}{βₚ : Subp Δₚ (Ξₚ [ βₜ ]c)}{αₚ : Subp Γₚ (Δₚ [ αₜ ]c)}
|
||||
{eq₁ : Subp Γₚ (Ψₚ [ (γₜ ∘ₜ βₜ) ∘ₜ αₜ ]c) ≡ Subp Γₚ (Ψₚ [ γₜ ∘ₜ (βₜ ∘ₜ αₜ) ]c)}
|
||||
{eq₂ : Subp (Δₚ [ αₜ ]c) ((Ψₚ [ γₜ ∘ₜ βₜ ]c) [ αₜ ]c) ≡ Subp (Δₚ [ αₜ ]c) (Ψₚ [ (γₜ ∘ₜ βₜ) ∘ₜ αₜ ]c)}
|
||||
{eq₃ : Subp (Ξₚ [ βₜ ∘ₜ αₜ ]c) ((Ψₚ [ γₜ ]c) [ βₜ ∘ₜ αₜ ]c) ≡ Subp (Ξₚ [ βₜ ∘ₜ αₜ ]c) (Ψₚ [ γₜ ∘ₜ (βₜ ∘ₜ αₜ) ]c)}
|
||||
{eq₄ : Subp (Δₚ [ αₜ ]c) ((Ξₚ [ βₜ ]c) [ αₜ ]c) ≡ Subp (Δₚ [ αₜ ]c) (Ξₚ [ βₜ ∘ₜ αₜ ]c)}
|
||||
{eq₅ : Subp (Ξₚ [ βₜ ]c) ((Ψₚ [ γₜ ]c) [ βₜ ]c) ≡ Subp (Ξₚ [ βₜ ]c) (Ψₚ [ γₜ ∘ₜ βₜ ]c)}
|
||||
→ coe eq₁ ((coe eq₂ (((coe eq₅ (γₚ [ βₜ ]σₚ)) ∘ₚ βₚ) [ αₜ ]σₚ)) ∘ₚ αₚ) ≡ (coe eq₃ (γₚ [ βₜ ∘ₜ αₜ ]σₚ)) ∘ₚ ((coe eq₄ (βₚ [ αₜ ]σₚ)) ∘ₚ αₚ)
|
||||
lemG {Γₜ}{Δₜ}{Ξₜ}{Ψₜ}{Γₚ}{Δₚ}{Ξₚ}{Ψₚ}{αₜ = αₜ}{βₜ}{γₜ}{γₚ}{βₚ}{αₚ}{eq₁}{eq₂}{eq₃}{eq₄}{eq₅} =
|
||||
substP (λ X → coe eq₁ ((coe eq₂ (((coe eq₅ (γₚ [ βₜ ]σₚ)) ∘ₚ βₚ) [ αₜ ]σₚ)) ∘ₚ αₚ) ≡ (coe eq₃ X) ∘ₚ ((coe eq₄ (βₚ [ αₜ ]σₚ)) ∘ₚ αₚ)) []σₚ-∘ (
|
||||
≡tran⁵
|
||||
(cong (coe eq₁) (≡tran (
|
||||
≡sym (substfpoly
|
||||
{R = λ X → Subp (Δₚ [ αₜ ]c) X}
|
||||
{eq = ≡sym []c-∘}
|
||||
{f = λ ξ → ξ ∘ₚ αₚ}
|
||||
{x = ((coe eq₅ (γₚ [ βₜ ]σₚ)) ∘ₚ βₚ) [ αₜ ]σₚ}))
|
||||
(cong (coe (cong (λ z → Subp Γₚ z) (≡sym []c-∘)))
|
||||
(≡sym (substfpoly
|
||||
{R = λ X → Subp (Ξₚ [ βₜ ]c) X}
|
||||
{eq = ≡sym []c-∘}
|
||||
{f = λ ξ → ((ξ ∘ₚ βₚ) [ αₜ ]σₚ) ∘ₚ αₚ}
|
||||
{x = γₚ [ βₜ ]σₚ}
|
||||
)))
|
||||
))
|
||||
(≡tran coecoe-coe coecoe-coe)
|
||||
(cong (coe (≡tran (cong (λ z → Subp Γₚ (z [ αₜ ]c)) (≡sym []c-∘)) (≡tran (cong (λ z → Subp Γₚ z) (≡sym []c-∘)) eq₁))) lemG')
|
||||
(≡sym coecoe-coe)
|
||||
(cong (coe (cong (λ z → Subp Γₚ z) (≡sym []c-∘))) (substppoly
|
||||
{A = (Conp Γₜ) × (Conp Γₜ)}
|
||||
{R = λ W → Subp (proj×₁ W) (proj×₂ W)}
|
||||
{Q = λ W → Subp (Δₚ [ αₜ ]c) (proj×₁ W)}
|
||||
{eq = ×≡ (≡sym []c-∘) (≡sym []c-∘)}
|
||||
{f = λ x y → x ∘ₚ (y ∘ₚ αₚ)}
|
||||
{x = (γₚ [ βₜ ]σₚ) [ αₜ ]σₚ}
|
||||
{y = βₚ [ αₜ ]σₚ}
|
||||
))(substfpoly
|
||||
{R = λ X → Subp (Ξₚ [ βₜ ∘ₜ αₜ ]c) X}
|
||||
{eq = ≡sym []c-∘}
|
||||
{f = λ {τ} ξ → (ξ ∘ₚ ((coe eq₄ (βₚ [ αₜ ]σₚ)) ∘ₚ αₚ))}
|
||||
{x = (coe (cong₂ Subp (≡sym []c-∘) (≡sym []c-∘)) ((γₚ [ βₜ ]σₚ) [ αₜ ]σₚ))}
|
||||
))
|
||||
∘-ass : {Γ Δ Ξ Ψ : Con}{α : Sub Γ Δ}{β : Sub Δ Ξ}{γ : Sub Ξ Ψ} → (γ ∘ β) ∘ α ≡ γ ∘ (β ∘ α)
|
||||
∘-ass {Γ}{Δ}{Ξ}{Ψ}{α = sub αₜ αₚ} {β = sub βₜ βₚ} {γ = sub γₜ γₚ} = cong₂' sub ∘ₜ-ass lemG
|
||||
|
||||
-- SUB-ization
|
||||
|
||||
lemA : {σₜ : Subt Γₜ Δₜ}{t : Tm Γₜ} → (Γₚ ▹tp) [ σₜ ,ₜ t ]c ≡ Γₚ [ σₜ ]c
|
||||
lemA {Γₚ = ◇p} = refl
|
||||
lemA {Γₚ = Γₚ ▹p⁰ t} = cong₂ _▹p⁰_ lemA (≡tran (≡sym []f-∘) (cong (λ σ → t [ σ ]f) (≡tran wk∘, σ-idl)))
|
||||
πₜ¹* : {Γ Δ : Con} → Sub Δ (Γ ▹t) → Sub Δ Γ
|
||||
πₜ¹* (sub (σₜ ,ₜ t) σₚ) = sub σₜ (subst (Subp _) lemA σₚ)
|
||||
πₜ²* : {Γ Δ : Con} → Sub Δ (Γ ▹t) → Tm (Con.t Δ)
|
||||
πₜ²* (sub (σₜ ,ₜ t) σₚ) = t
|
||||
_,ₜ*_ : {Γ Δ : Con} → Sub Δ Γ → Tm (Con.t Δ) → Sub Δ (Γ ▹t)
|
||||
(sub σₜ σₚ) ,ₜ* t = sub (σₜ ,ₜ t) (subst (Subp _) (≡sym lemA) σₚ)
|
||||
πₜ²∘,ₜ* : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm (Con.t Δ)} → πₜ²* (σ ,ₜ* t) ≡ t
|
||||
πₜ²∘,ₜ* = refl
|
||||
πₜ¹∘,ₜ* : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm (Con.t Δ)} → πₜ¹* (σ ,ₜ* t) ≡ σ
|
||||
πₜ¹∘,ₜ* {Γ}{Δ}{σ}{t} = cong (sub (Sub.t σ)) coeaba
|
||||
,ₜ∘πₜ* : {Γ Δ : Con} → {σ : Sub Δ (Γ ▹t)} → (πₜ¹* σ) ,ₜ* (πₜ²* σ) ≡ σ
|
||||
,ₜ∘πₜ* {Γ} {Δ} {sub (σₜ ,ₜ t) σₚ} = cong (sub (σₜ ,ₜ t)) coeaba
|
||||
,ₜ∘* : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{t : Tm (Con.t Γ)} → (σ ,ₜ* t) ∘ δ ≡ (σ ∘ δ) ,ₜ* (t [ Sub.t δ ]t)
|
||||
lemE : {σₜ : Subt Γₜ Ξₜ}{σₚ : Subp Γₚ (Ξₚ [ σₜ ]c)} {δₜ : Subt Δₜ Γₜ} → (coe _ σₚ [ δₜ ]σₚ) ≡ coe _ (σₚ [ δₜ ]σₚ)
|
||||
lemE {δₜ = δₜ} = coecong {eq = refl} {eq' = refl} (λ ξₚ → ξₚ [ δₜ ]σₚ)
|
||||
lemF : {Γα Γβ : Conp Δₜ}{δₜ : Subt Δₜ Γₜ}{δₚ : Subp Δₚ (Γₚ [ δₜ ]c)} → (eq : Γβ ≡ Γα) → (ξ : Subp (Γₚ [ δₜ ]c) Γβ) → coe (cong (Subp Δₚ) eq) (ξ ∘ₚ δₚ) ≡ coe (cong (Subp _) eq) ξ ∘ₚ δₚ
|
||||
lemF refl ξ = ≡tran coerefl (cong₂ _∘ₚ_ (≡sym coerefl) refl)
|
||||
--lemG : {Γα Γβ : Conp Δₜ}{σₜ : Subt Γₜ Ξₜ}{δₜ : Subt Δₜ Γₜ} → (eq : Γβ ≡ Γα) → (ξ : Subp Γₚ (Ξₚ [ σₜ ]c)) → coe refl (ξ [ δₜ ]σₚ) ≡ (coe refl ξ) [ δₜ ]σₚ
|
||||
--lemG eq ε= {!!}
|
||||
substf : {ℓ ℓ' : Level}{A : Set ℓ}{P : A → Set ℓ'}{Q : A → Set ℓ'}{a b c d : A}{eqa : a ≡ a}{eqb : b ≡ b}{eqcd : c ≡ d}{eqdc : d ≡ c}{f : P a → P b}{g : P b → Q c}{x : P a} → g (subst P eqb (f (subst P eqa x))) ≡ subst Q eqdc (subst Q eqcd (g (f x)))
|
||||
substf {P = P} {Q = Q} {eqcd = refl} {f = f} {g = g} = ≡tran² (cong g (≡tran (substrefl {P = P} {e = refl}) (cong f (substrefl {P = P} {e = refl})))) (≡sym (substrefl {P = Q} {e = refl})) (≡sym (substrefl {P = Q} {e = refl}))
|
||||
|
||||
,ₜ∘* {Γ} {Δ} {Ξ} {sub σₜ σₚ} {sub δₜ δₚ} {t} = cong (sub ((σₜ ∘ₜ δₜ) ,ₜ (t [ δₜ ]t)))
|
||||
(substfgpoly
|
||||
{P = Subp {Con.t Δ} (Con.p Δ)}
|
||||
{Q = Subp {Con.t Δ} ((Con.p Γ) [ δₜ ]c)}
|
||||
{R = Subp {Con.t Γ} (Con.p Γ)}
|
||||
{F = λ X → X [ δₜ ]c}
|
||||
{eq₁ = ≡sym lemA}
|
||||
{eq₂ = ≡sym []c-∘}
|
||||
{eq₃ = ≡sym []c-∘}
|
||||
{eq₄ = ≡sym lemA}
|
||||
{g = λ σₚ → σₚ ∘ₚ δₚ}
|
||||
{f = λ σₚ → σₚ [ δₜ ]σₚ}
|
||||
{x = σₚ})
|
||||
|
||||
πₚ¹* : {Γ Δ : Con} {A : For (Con.t Γ)} → Sub Δ (Γ ▹p A) → Sub Δ Γ
|
||||
πₚ¹* (sub σₜ (σₚ ,ₚ pf)) = sub σₜ σₚ
|
||||
πₚ² : {Γ Δ : Con} {F : For (Con.t Γ)} (σ : Sub Δ (Γ ▹p F)) → Pf Δ (F [ Sub.t (πₚ¹* σ) ]f)
|
||||
πₚ² (sub σₜ (σₚ ,ₚ pf)) = pf
|
||||
_,ₚ*_ : {Γ Δ : Con} {F : For (Con.t Γ)} (σ : Sub Δ Γ) → Pf Δ (F [ Sub.t σ ]f) → Sub Δ (Γ ▹p F)
|
||||
sub σₜ σₚ ,ₚ* pf = sub σₜ (σₚ ,ₚ pf)
|
||||
|
||||
,ₚ∘πₚ : {Γ Δ : Con} → {F : For (Con.t Γ)} → {σ : Sub Δ (Γ ▹p F)} → (πₚ¹* σ) ,ₚ* (πₚ² σ) ≡ σ
|
||||
,ₚ∘πₚ {σ = sub σₜ (σₚ ,ₚ p)} = refl
|
||||
,ₚ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{F : For (Con.t Ξ)}{prf : Pf Γ (F [ Sub.t σ ]f)}
|
||||
→ (σ ,ₚ* prf) ∘ δ ≡ (σ ∘ δ) ,ₚ* (substP (λ F → Pf Δ F) (≡sym []f-∘) ((prf [ Sub.t δ ]pₜ) [ Sub.p δ ]p))
|
||||
,ₚ∘ {Γ}{Δ}{Ξ}{σ = sub σₜ σₚ} {sub δₜ δₚ} {F = A} {prf} = cong (sub (σₜ ∘ₜ δₜ)) (cong (λ ξ → ξ ∘ₚ δₚ)
|
||||
(substfpoly⁴ {P = λ W → Subp (Con.p Γ [ δₜ ]c) ((proj×₁ W) ▹p⁰ (proj×₂ W))}{R = λ W → Subp (Con.p Γ [ δₜ ]c) (proj×₁ W)}{Q = λ W → Pf (con (Con.t Δ) (Con.p Γ [ δₜ ]c)) (proj×₂ W)}{α = ((Con.p Ξ [ σₜ ]c) [ δₜ ]c) ,× ((A [ σₜ ]f) [ δₜ ]f)}{eq = cong₂ _,×_ (≡sym []c-∘) (≡sym []f-∘)}{f = λ ξ p → ξ ,ₚ p} {x = σₚ [ δₜ ]σₚ}{y = prf [ δₜ ]pₜ})) --
|
||||
|
||||
--_,ₜ_ : {Γ Δ : Con} → Sub Δ Γ → Tm Δ → Sub Δ (Γ ▹t)
|
||||
--πₜ²∘,ₜ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm Δ} → πₜ² (σ ,ₜ t) ≡ t
|
||||
--πₜ¹∘,ₜ : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm Δ} → πₜ¹ (σ ,ₜ t) ≡ σ
|
||||
--,ₜ∘πₜ : {Γ Δ : Con} → {σ : Sub Δ (Γ ▹ₜ)} → (πₜ¹ σ) ,ₜ (πₜ² σ) ≡ σ
|
||||
--,ₜ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{t : Tm Γ} → (σ ,ₜ t) ∘ δ ≡ (σ ∘ δ) ,ₜ (t [ δ ]t)
|
||||
|
||||
-- lemB : ∀{ℓ}{A : Set ℓ}{ℓ'}{P : A → Set ℓ'}{a a' : A}{e : a ≡ a'}{p : P a}{p' : P a'} → p' ≡ p → subst P e p' ≡ p
|
||||
|
||||
lemC : {σₜ : Subt Δₜ Γₜ}{t : Tm Δₜ} → (Γₚ ▹tp) [ σₜ ,ₜ t ]c ≡ Γₚ [ σₜ ]c
|
||||
lemC {Γₚ = ◇p} = refl
|
||||
lemC {Γₚ = Γₚ ▹p⁰ x} = cong₂ _▹p⁰_ lemC (≡tran (≡sym []f-∘) (cong (λ σ → x [ σ ]f) (≡tran wk∘, σ-idl)))
|
||||
|
||||
lemD : {A : For (Con.t Γ)}{σ : Sub Δ (Γ ▹p A)} → Sub.t (πₚ¹* σ) ≡ Sub.t σ
|
||||
lemD {σ = sub σₜ (σₚ ,ₚ pf)} = refl
|
||||
|
||||
|
||||
imod : FFOL {lsuc lzero} {lsuc lzero} {lsuc lzero} {lsuc lzero}
|
||||
imod = record
|
||||
{ Con = Con
|
||||
; Sub = Sub
|
||||
; _∘_ = _∘_
|
||||
; ∘-ass = ∘-ass
|
||||
; id = id
|
||||
; idl = idl
|
||||
; idr = idr
|
||||
; ◇ = ◇
|
||||
; ε = sub εₜ εₚ
|
||||
; ε-u = cong₂' sub εₜ-u ε-u
|
||||
; Tm = λ Γ → Tm (Con.t Γ)
|
||||
; _[_]t = λ t σ → t [ Sub.t σ ]t
|
||||
; []t-id = []t-id
|
||||
; []t-∘ = λ {Γ}{Δ}{Ξ}{α}{β}{t} → []t-∘ {α = Sub.t α} {β = Sub.t β} {t = t}
|
||||
; _▹ₜ = _▹t
|
||||
; πₜ¹ = πₜ¹*
|
||||
; πₜ² = πₜ²*
|
||||
; _,ₜ_ = _,ₜ*_
|
||||
; πₜ²∘,ₜ = refl
|
||||
; πₜ¹∘,ₜ = πₜ¹∘,ₜ*
|
||||
; ,ₜ∘πₜ = ,ₜ∘πₜ*
|
||||
; ,ₜ∘ = ,ₜ∘*
|
||||
; For = λ Γ → For (Con.t Γ)
|
||||
; _[_]f = λ A σ → A [ Sub.t σ ]f
|
||||
; []f-id = []f-id
|
||||
; []f-∘ = []f-∘
|
||||
; R = r
|
||||
; R[] = refl
|
||||
; _⊢_ = Pf
|
||||
; _[_]p = λ pf σ → (pf [ Sub.t σ ]pₜ) [ Sub.p σ ]p
|
||||
; _▹ₚ_ = _▹p_
|
||||
; πₚ¹ = πₚ¹*
|
||||
; πₚ² = πₚ²
|
||||
; _,ₚ_ = _,ₚ*_
|
||||
; ,ₚ∘πₚ = ,ₚ∘πₚ
|
||||
; πₚ¹∘,ₚ = refl
|
||||
; ,ₚ∘ = λ {Γ}{Δ}{Ξ}{σ}{δ}{F}{prf} → ,ₚ∘ {prf = prf}
|
||||
; _⇒_ = _⇒_
|
||||
; []f-⇒ = refl
|
||||
; ∀∀ = ∀∀
|
||||
; []f-∀∀ = []f-∀∀
|
||||
; lam = λ {Γ}{F}{G} pf → substP (λ H → Pf Γ (F ⇒ H)) (≡tran (cong (_[_]f G) (lemD {σ = id})) []f-id) (lam pf)
|
||||
; app = app
|
||||
; ∀i = p∀∀i
|
||||
; ∀e = λ {Γ} {F} pf {t} → p∀∀e pf
|
||||
}
|
||||
|
||||
675
FFOLInitial.lagda
Normal file
675
FFOLInitial.lagda
Normal file
@ -0,0 +1,675 @@
|
||||
git s\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module FFOLInitial where
|
||||
|
||||
open import FFOL
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
|
||||
{-- TERM CONTEXTS - TERMS - FORMULAE - TERM SUBSTITUTIONS --}
|
||||
|
||||
--# Term contexts are isomorphic to Nat
|
||||
data Cont : Set₁ where
|
||||
◇t : Cont
|
||||
_▹t⁰ : Cont → Cont
|
||||
|
||||
--#
|
||||
variable
|
||||
Γₜ Δₜ Ξₜ : Cont
|
||||
|
||||
--# A term variable is a de-bruijn variable, TmVar n ≈ ⟦0,n-1⟧
|
||||
data TmVar : Cont → Set₁ where
|
||||
tvzero : TmVar (Γₜ ▹t⁰)
|
||||
tvnext : TmVar Γₜ → TmVar (Γₜ ▹t⁰)
|
||||
|
||||
-- For now, we only have term variables (no function symbol)
|
||||
data Tm : Cont → Set₁ where
|
||||
var : TmVar Γₜ → Tm Γₜ
|
||||
|
||||
--# Now we can define formulæ
|
||||
data For : Cont → Set₁ where
|
||||
R : Tm Γₜ → Tm Γₜ → For Γₜ
|
||||
_⇒_ : For Γₜ → For Γₜ → For Γₜ
|
||||
∀∀ : For (Γₜ ▹t⁰) → For Γₜ
|
||||
|
||||
|
||||
|
||||
|
||||
--# Then we define term substitutions
|
||||
data Subt : Cont → Cont → Set₁ where
|
||||
εₜ : Subt Γₜ ◇t
|
||||
_,ₜ_ : Subt Δₜ Γₜ → Tm Δₜ → Subt Δₜ (Γₜ ▹t⁰)
|
||||
|
||||
--# We write down the access functions from the algebra, in restricted versions
|
||||
πₜ¹ : Subt Δₜ (Γₜ ▹t⁰) → Subt Δₜ Γₜ
|
||||
πₜ¹ (σₜ ,ₜ t) = σₜ
|
||||
πₜ² : Subt Δₜ (Γₜ ▹t⁰) → Tm Δₜ
|
||||
πₜ² (σₜ ,ₜ t) = t
|
||||
-- And their equalities (the fact that there are reciprocical)
|
||||
πₜ²∘,ₜ : {σₜ : Subt Δₜ Γₜ} → {t : Tm Δₜ} → πₜ² (σₜ ,ₜ t) ≡ t
|
||||
πₜ²∘,ₜ = refl
|
||||
πₜ¹∘,ₜ : {σₜ : Subt Δₜ Γₜ} → {t : Tm Δₜ} → πₜ¹ (σₜ ,ₜ t) ≡ σₜ
|
||||
πₜ¹∘,ₜ = refl
|
||||
,ₜ∘πₜ : {σₜ : Subt Δₜ (Γₜ ▹t⁰)} → (πₜ¹ σₜ) ,ₜ (πₜ² σₜ) ≡ σₜ
|
||||
,ₜ∘πₜ {σₜ = σₜ ,ₜ t} = refl
|
||||
|
||||
|
||||
--# We now define the action of term substitutions on terms
|
||||
_[_]t : Tm Γₜ → Subt Δₜ Γₜ → Tm Δₜ
|
||||
var tvzero [ σ ,ₜ t ]t = t
|
||||
var (tvnext tv) [ σ ,ₜ t ]t = var tv [ σ ]t
|
||||
|
||||
--# We define weakenings of the term-context for terms
|
||||
-- «A term of n variables can be seen as a term of n+1 variables»
|
||||
wkₜt : Tm Γₜ → Tm (Γₜ ▹t⁰)
|
||||
wkₜt (var tv) = var (tvnext tv)
|
||||
|
||||
-- From a substition into n variables, we get a substitution into n+1 variables which don't use the last one
|
||||
wkₜσₜ : Subt Δₜ Γₜ → Subt (Δₜ ▹t⁰) Γₜ
|
||||
wkₜσₜ εₜ = εₜ
|
||||
wkₜσₜ (σ ,ₜ t) = (wkₜσₜ σ) ,ₜ (wkₜt t)
|
||||
|
||||
-- From a substitution into n variables, we construct a substitution from n+1 variables to n+1 variables which maps it to itself
|
||||
-- i.e. 0 -> 0 and for all i ->(old) σ(i) we get i+1 -> σ(i)+1
|
||||
lfₜσₜ : Subt Δₜ Γₜ → Subt (Δₜ ▹t⁰) (Γₜ ▹t⁰)
|
||||
lfₜσₜ σ = (wkₜσₜ σ) ,ₜ (var tvzero)
|
||||
|
||||
-- We show how wkₜt and interacts with [_]t
|
||||
wkₜ[]t : {α : Subt Δₜ Γₜ} → {t : Tm Γₜ} → wkₜt (t [ α ]t) ≡ (wkₜt t [ lfₜσₜ α ]t)
|
||||
wkₜ[]t {α = α ,ₜ t} {var tvzero} = refl
|
||||
wkₜ[]t {α = α ,ₜ t} {var (tvnext tv)} = wkₜ[]t {t = var tv}
|
||||
|
||||
--# We can now subst on formulæ
|
||||
_[_]f : For Γₜ → Subt Δₜ Γₜ → For Δₜ
|
||||
(R t u) [ σ ]f = R (t [ σ ]t) (u [ σ ]t)
|
||||
(A ⇒ B) [ σ ]f = (A [ σ ]f) ⇒ (B [ σ ]f)
|
||||
(∀∀ A) [ σ ]f = ∀∀ (A [ lfₜσₜ σ ]f)
|
||||
|
||||
|
||||
|
||||
|
||||
--# We now can define identity and composition of term substitutions
|
||||
idₜ : Subt Γₜ Γₜ
|
||||
idₜ {◇t} = εₜ
|
||||
idₜ {Γₜ ▹t⁰} = lfₜσₜ (idₜ {Γₜ})
|
||||
_∘ₜ_ : Subt Δₜ Γₜ → Subt Ξₜ Δₜ → Subt Ξₜ Γₜ
|
||||
εₜ ∘ₜ β = εₜ
|
||||
(α ,ₜ x) ∘ₜ β = (α ∘ₜ β) ,ₜ (x [ β ]t)
|
||||
|
||||
--# We now have to show all their equalities (idₜ and ∘ₜ respect []t, []f, wkₜ, lfₜ, categorical rules
|
||||
|
||||
-- Substitution for terms
|
||||
[]t-id : {t : Tm Γₜ} → t [ idₜ {Γₜ} ]t ≡ t
|
||||
[]t-id {Γₜ ▹t⁰} {var tvzero} = refl
|
||||
[]t-id {Γₜ ▹t⁰} {var (tvnext tv)} = substP (λ t → t ≡ var (tvnext tv)) (wkₜ[]t {t = var tv}) (substP (λ t → wkₜt t ≡ var (tvnext tv)) (≡sym ([]t-id {t = var tv})) refl)
|
||||
[]t-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → {t : Tm Γₜ} → t [ β ∘ₜ α ]t ≡ (t [ β ]t) [ α ]t
|
||||
[]t-∘ {α = α} {β = β ,ₜ t} {t = var tvzero} = refl
|
||||
[]t-∘ {α = α} {β = β ,ₜ t} {t = var (tvnext tv)} = []t-∘ {t = var tv}
|
||||
|
||||
-- Weakenings and liftings of substitutions
|
||||
wkₜσₜ-∘ₜl : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → wkₜσₜ (β ∘ₜ α) ≡ (wkₜσₜ β ∘ₜ lfₜσₜ α)
|
||||
wkₜσₜ-∘ₜl {β = εₜ} = refl
|
||||
wkₜσₜ-∘ₜl {β = β ,ₜ t} = cong₂ _,ₜ_ wkₜσₜ-∘ₜl (wkₜ[]t {t = t})
|
||||
wkₜσₜ-∘ₜr : {α : Subt Γₜ Δₜ} → {β : Subt Ξₜ Γₜ} → α ∘ₜ (wkₜσₜ β) ≡ wkₜσₜ (α ∘ₜ β)
|
||||
wkₜσₜ-∘ₜr {α = εₜ} = refl
|
||||
wkₜσₜ-∘ₜr {α = α ,ₜ var tv} = cong₂ _,ₜ_ (wkₜσₜ-∘ₜr {α = α}) (≡sym (wkₜ[]t {t = var tv}))
|
||||
lfₜσₜ-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → lfₜσₜ (β ∘ₜ α) ≡ (lfₜσₜ β) ∘ₜ (lfₜσₜ α)
|
||||
lfₜσₜ-∘ {α = α} {β = εₜ} = refl
|
||||
lfₜσₜ-∘ {α = α} {β = β ,ₜ t} = cong₂ _,ₜ_ (cong₂ _,ₜ_ wkₜσₜ-∘ₜl (wkₜ[]t {t = t})) refl
|
||||
|
||||
-- Cancelling a weakening with a ,ₜ
|
||||
wkₜ[,]t : {t : Tm Γₜ}{u : Tm Δₜ}{β : Subt Δₜ Γₜ} → (wkₜt t) [ β ,ₜ u ]t ≡ t [ β ]t
|
||||
wkₜ[,]t {t = var tvzero} = refl
|
||||
wkₜ[,]t {t = var (tvnext tv)} = refl
|
||||
wkₜ∘ₜ,ₜ : {α : Subt Γₜ Δₜ}{β : Subt Ξₜ Γₜ}{t : Tm Ξₜ} → (wkₜσₜ α) ∘ₜ (β ,ₜ t) ≡ (α ∘ₜ β)
|
||||
wkₜ∘ₜ,ₜ {α = εₜ} = refl
|
||||
wkₜ∘ₜ,ₜ {α = α ,ₜ t} {β = β} = cong₂ _,ₜ_ (wkₜ∘ₜ,ₜ {α = α}) (wkₜ[,]t {t = t} {β = β})
|
||||
|
||||
-- Categorical rules are respected by idₜ and ∘ₜ
|
||||
idlₜ : {α : Subt Δₜ Γₜ} → idₜ ∘ₜ α ≡ α
|
||||
idlₜ {α = εₜ} = refl
|
||||
idlₜ {α = α ,ₜ x} = cong₂ _,ₜ_ (≡tran wkₜ∘ₜ,ₜ idlₜ) refl
|
||||
idrₜ : {α : Subt Δₜ Γₜ} → α ∘ₜ idₜ ≡ α
|
||||
idrₜ {α = εₜ} = refl
|
||||
idrₜ {α = α ,ₜ x} = cong₂ _,ₜ_ idrₜ []t-id
|
||||
∘ₜ-ass : {Γₜ Δₜ Ξₜ Ψₜ : Cont}{α : Subt Γₜ Δₜ}{β : Subt Δₜ Ξₜ}{γ : Subt Ξₜ Ψₜ} → (γ ∘ₜ β) ∘ₜ α ≡ γ ∘ₜ (β ∘ₜ α)
|
||||
∘ₜ-ass {α = α} {β} {εₜ} = refl
|
||||
∘ₜ-ass {α = α} {β} {γ ,ₜ x} = cong₂ _,ₜ_ ∘ₜ-ass (≡sym ([]t-∘ {t = x}))
|
||||
|
||||
-- Unicity of the terminal morphism
|
||||
εₜ-u : {σₜ : Subt Γₜ ◇t} → σₜ ≡ εₜ
|
||||
εₜ-u {σₜ = εₜ} = refl
|
||||
|
||||
-- Substitution for formulæ
|
||||
[]f-id : {F : For Γₜ} → F [ idₜ {Γₜ} ]f ≡ F
|
||||
[]f-id {F = R t u} = cong₂ R []t-id []t-id
|
||||
[]f-id {F = F ⇒ G} = cong₂ _⇒_ []f-id []f-id
|
||||
[]f-id {F = ∀∀ F} = cong ∀∀ []f-id
|
||||
[]f-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → {F : For Γₜ} → F [ β ∘ₜ α ]f ≡ (F [ β ]f) [ α ]f
|
||||
[]f-∘ {α = α} {β = β} {F = R t u} = cong₂ R ([]t-∘ {α = α} {β = β} {t = t}) ([]t-∘ {α = α} {β = β} {t = u})
|
||||
[]f-∘ {F = F ⇒ G} = cong₂ _⇒_ []f-∘ []f-∘
|
||||
[]f-∘ {F = ∀∀ F} = cong ∀∀ (≡tran (cong (λ σ → F [ σ ]f) lfₜσₜ-∘) []f-∘)
|
||||
|
||||
-- Substitution for formulæ constructors
|
||||
-- we omit []f-R and []f-⇒ as they are directly refl
|
||||
[]f-∀∀ : {A : For (Γₜ ▹t⁰)} → {σₜ : Subt Δₜ Γₜ} → (∀∀ A) [ σₜ ]f ≡ (∀∀ (A [ (σₜ ∘ₜ πₜ¹ idₜ) ,ₜ πₜ² idₜ ]f))
|
||||
[]f-∀∀ {A = A} = cong ∀∀ (cong (_[_]f A) (cong₂ _,ₜ_ (≡tran (cong wkₜσₜ (≡sym idrₜ)) (≡sym wkₜσₜ-∘ₜr)) refl))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--# We can now define proof contexts, which are indexed by a term context
|
||||
-- i.e. we know which terms a proof context can use
|
||||
data Conp : Cont → Set₁ where
|
||||
◇p : Conp Γₜ
|
||||
_▹p⁰_ : Conp Γₜ → For Γₜ → Conp Γₜ
|
||||
|
||||
--#
|
||||
variable
|
||||
Γₚ Γₚ' : Conp Γₜ
|
||||
Δₚ Δₚ' : Conp Δₜ
|
||||
Ξₚ Ξₚ' : Conp Ξₜ
|
||||
|
||||
--# The actions of Subt's is extended to contexts
|
||||
_[_]c : Conp Γₜ → Subt Δₜ Γₜ → Conp Δₜ
|
||||
◇p [ σₜ ]c = ◇p
|
||||
(Γₚ ▹p⁰ A) [ σₜ ]c = (Γₚ [ σₜ ]c) ▹p⁰ (A [ σₜ ]f)
|
||||
--# This Conp is indeed a functor
|
||||
[]c-id : Γₚ [ idₜ ]c ≡ Γₚ
|
||||
[]c-id {Γₚ = ◇p} = refl
|
||||
[]c-id {Γₚ = Γₚ ▹p⁰ x} = cong₂ _▹p⁰_ []c-id []f-id
|
||||
[]c-∘ : {α : Subt Δₜ Ξₜ} {β : Subt Γₜ Δₜ} {Ξₚ : Conp Ξₜ} → Ξₚ [ α ∘ₜ β ]c ≡ (Ξₚ [ α ]c) [ β ]c
|
||||
[]c-∘ {α = α} {β = β} {◇p} = refl
|
||||
[]c-∘ {α = α} {β = β} {Ξₚ ▹p⁰ A} = cong₂ _▹p⁰_ []c-∘ []f-∘
|
||||
|
||||
|
||||
--# We can also add a term that will not be used in the formulæ already present
|
||||
-- (that's why we use wkₜσₜ)
|
||||
_▹tp : Conp Γₜ → Conp (Γₜ ▹t⁰)
|
||||
Γ ▹tp = Γ [ wkₜσₜ idₜ ]c
|
||||
--# We show how it interacts with ,ₜ and lfₜσₜ
|
||||
▹tp,ₜ : {σₜ : Subt Γₜ Δₜ}{t : Tm Γₜ} → (Γₚ ▹tp) [ σₜ ,ₜ t ]c ≡ Γₚ [ σₜ ]c
|
||||
▹tp,ₜ {Γₚ = Γₚ} = ≡tran (≡sym []c-∘) (cong (λ ξ → Γₚ [ ξ ]c) (≡tran wkₜ∘ₜ,ₜ idlₜ))
|
||||
▹tp-lfₜ : {σ : Subt Δₜ Γₜ} → ((Δₚ ▹tp) [ lfₜσₜ σ ]c) ≡ ((Δₚ [ σ ]c) ▹tp)
|
||||
▹tp-lfₜ {Δₚ = Δₚ} = ≡tran² (≡sym []c-∘) (cong (λ ξ → Δₚ [ ξ ]c) (≡tran² (≡sym wkₜσₜ-∘ₜl) (cong wkₜσₜ (≡tran idlₜ (≡sym idrₜ))) (≡sym wkₜσₜ-∘ₜr))) []c-∘
|
||||
|
||||
|
||||
|
||||
--# With those contexts, we have everything to define proofs
|
||||
data PfVar : (Γₜ : Cont) → (Γₚ : Conp Γₜ) → For Γₜ → Prop₁ where
|
||||
pvzero : {A : For Γₜ} → PfVar Γₜ (Γₚ ▹p⁰ A) A
|
||||
pvnext : {A B : For Γₜ} → PfVar Γₜ Γₚ A → PfVar Γₜ (Γₚ ▹p⁰ B) A
|
||||
|
||||
data Pf : (Γₜ : Cont) → (Γₚ : Conp Γₜ) → For Γₜ → Prop₁ where
|
||||
var : {A : For Γₜ} → PfVar Γₜ Γₚ A → Pf Γₜ Γₚ A
|
||||
app : {A B : For Γₜ} → Pf Γₜ Γₚ (A ⇒ B) → Pf Γₜ Γₚ A → Pf Γₜ Γₚ B
|
||||
lam : {A B : For Γₜ} → Pf Γₜ (Γₚ ▹p⁰ A) B → Pf Γₜ Γₚ (A ⇒ B)
|
||||
p∀∀e : {A : For (Γₜ ▹t⁰)} → {t : Tm Γₜ} → Pf Γₜ Γₚ (∀∀ A) → Pf Γₜ Γₚ (A [ idₜ ,ₜ t ]f)
|
||||
p∀∀i : {A : For (Γₜ ▹t⁰)} → Pf (Γₜ ▹t⁰) (Γₚ ▹tp) A → Pf Γₜ Γₚ (∀∀ A)
|
||||
|
||||
|
||||
--# The action on Cont's morphisms of Pf functor
|
||||
_[_]pvₜ : {A : For Δₜ}→ PfVar Δₜ Δₚ A → (σ : Subt Γₜ Δₜ)→ PfVar Γₜ (Δₚ [ σ ]c) (A [ σ ]f)
|
||||
pvzero [ σ ]pvₜ = pvzero
|
||||
pvnext pv [ σ ]pvₜ = pvnext (pv [ σ ]pvₜ)
|
||||
_[_]pₜ : {A : For Δₜ} → Pf Δₜ Δₚ A → (σ : Subt Γₜ Δₜ) → Pf Γₜ (Δₚ [ σ ]c) (A [ σ ]f)
|
||||
var pv [ σ ]pₜ = var (pv [ σ ]pvₜ)
|
||||
app pf pf' [ σ ]pₜ = app (pf [ σ ]pₜ) (pf' [ σ ]pₜ)
|
||||
lam pf [ σ ]pₜ = lam (pf [ σ ]pₜ)
|
||||
_[_]pₜ {Δₚ = Δₚ} {Γₜ = Γₜ} (p∀∀e {A = A} {t = t} pf) σ =
|
||||
substP (λ F → Pf Γₜ (Δₚ [ σ ]c) F) (≡tran² (≡sym []f-∘) (cong (λ σ → A [ σ ]f)
|
||||
(cong₂ _,ₜ_ (≡tran² wkₜ∘ₜ,ₜ idrₜ (≡sym idlₜ)) refl)) ([]f-∘))
|
||||
(p∀∀e {t = t [ σ ]t} (pf [ σ ]pₜ))
|
||||
_[_]pₜ {Γₜ = Γₜ} (p∀∀i pf) σ
|
||||
= p∀∀i (substP (λ Ξₚ → Pf (Γₜ ▹t⁰) (Ξₚ) _) ▹tp-lfₜ (pf [ lfₜσₜ σ ]pₜ))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--# We now can create Renamings, a subcategory from (Conp,Subp) that
|
||||
-- A renaming from a context Γₚ to a context Δₚ means when they are seen
|
||||
-- as lists, that every element of Γₚ is an element of Δₚ
|
||||
-- In other words, we can prove Γₚ from Δₚ using only proof variables (var)
|
||||
data Ren : Conp Γₜ → Conp Γₜ → Set₁ where
|
||||
zeroRen : Ren ◇p Γₚ
|
||||
leftRen : {A : For Δₜ} → PfVar Δₜ Δₚ A → Ren Δₚ' Δₚ → Ren (Δₚ' ▹p⁰ A) Δₚ
|
||||
|
||||
--# We now show how we can extend renamings
|
||||
rightRen :{A : For Δₜ} → Ren Γₚ Δₚ → Ren Γₚ (Δₚ ▹p⁰ A)
|
||||
rightRen zeroRen = zeroRen
|
||||
rightRen (leftRen x h) = leftRen (pvnext x) (rightRen h)
|
||||
bothRen : {A : For Γₜ} → Ren Γₚ Δₚ → Ren (Γₚ ▹p⁰ A) (Δₚ ▹p⁰ A)
|
||||
bothRen zeroRen = leftRen pvzero zeroRen
|
||||
bothRen (leftRen x h) = leftRen pvzero (leftRen (pvnext x) (rightRen h))
|
||||
reflRen : Ren Γₚ Γₚ
|
||||
reflRen {Γₚ = ◇p} = zeroRen
|
||||
reflRen {Γₚ = Γₚ ▹p⁰ x} = bothRen reflRen
|
||||
|
||||
-- We can extend renamings with term variables
|
||||
PfVar▹tp : {A : For Δₜ} → PfVar Δₜ Δₚ A → PfVar (Δₜ ▹t⁰) (Δₚ ▹tp) (A [ wkₜσₜ idₜ ]f)
|
||||
PfVar▹tp pvzero = pvzero
|
||||
PfVar▹tp (pvnext x) = pvnext (PfVar▹tp x)
|
||||
Ren▹tp : Ren Γₚ Δₚ → Ren (Γₚ ▹tp) (Δₚ ▹tp)
|
||||
Ren▹tp zeroRen = zeroRen
|
||||
Ren▹tp (leftRen x s) = leftRen (PfVar▹tp x) (Ren▹tp s)
|
||||
|
||||
-- Renamings can be used to (strongly) weaken proofs
|
||||
wkᵣpv : {A : For Δₜ} → Ren Δₚ' Δₚ → PfVar Δₜ Δₚ' A → PfVar Δₜ Δₚ A
|
||||
wkᵣpv (leftRen x x₁) pvzero = x
|
||||
wkᵣpv (leftRen x x₁) (pvnext s) = wkᵣpv x₁ s
|
||||
wkᵣp : {A : For Δₜ} → Ren Δₚ Δₚ' → Pf Δₜ Δₚ A → Pf Δₜ Δₚ' A
|
||||
wkᵣp s (var pv) = var (wkᵣpv s pv)
|
||||
wkᵣp s (app pf pf₁) = app (wkᵣp s pf) (wkᵣp s pf₁)
|
||||
wkᵣp s (lam {A = A} pf) = lam (wkᵣp (bothRen s) pf)
|
||||
wkᵣp s (p∀∀e pf) = p∀∀e (wkᵣp s pf)
|
||||
wkᵣp s (p∀∀i pf) = p∀∀i (wkᵣp (Ren▹tp s) pf)
|
||||
|
||||
|
||||
--# But we need something stronger than just renamings
|
||||
-- introducing: Proof substitutions
|
||||
-- They are basicly a list of proofs for the formulæ contained in
|
||||
-- the goal context.
|
||||
-- It is not defined between all contexts, only those with the same term context
|
||||
data Subp : {Δₜ : Cont} → Conp Δₜ → Conp Δₜ → Prop₁ where
|
||||
εₚ : Subp Δₚ ◇p
|
||||
_,ₚ_ : {A : For Δₜ} → (σ : Subp Δₚ Δₚ') → Pf Δₜ Δₚ A → Subp Δₚ (Δₚ' ▹p⁰ A)
|
||||
|
||||
--# We write down the access functions from the algebra, in restricted versions
|
||||
πₚ¹ : ∀{Γₜ}{Γₚ Δₚ : Conp Γₜ} {A : For Γₜ} → Subp Δₚ (Γₚ ▹p⁰ A) → Subp Δₚ Γₚ
|
||||
πₚ¹ (σₚ ,ₚ pf) = σₚ
|
||||
πₚ² : ∀{Γₜ}{Γₚ Δₚ : Conp Γₜ} {A : For Γₜ} → Subp Δₚ (Γₚ ▹p⁰ A) → Pf Γₜ Δₚ A
|
||||
πₚ² (σₚ ,ₚ pf) = pf
|
||||
|
||||
--# The action of Cont's morphisms on Subp
|
||||
_[_]σₚ : Subp {Δₜ} Δₚ Δₚ' → (σ : Subt Γₜ Δₜ) → Subp {Γₜ} (Δₚ [ σ ]c) (Δₚ' [ σ ]c)
|
||||
εₚ [ σₜ ]σₚ = εₚ
|
||||
(σₚ ,ₚ pf) [ σₜ ]σₚ = (σₚ [ σₜ ]σₚ) ,ₚ (pf [ σₜ ]pₜ)
|
||||
|
||||
--# They are indeed stronger than renamings
|
||||
Ren→Sub : Ren Δₚ Δₚ' → Subp {Δₜ} Δₚ' Δₚ
|
||||
Ren→Sub zeroRen = εₚ
|
||||
Ren→Sub (leftRen x s) = Ren→Sub s ,ₚ var x
|
||||
|
||||
|
||||
-- From a substition into n variables, we get a substitution into n+1 variables which don't use the last one
|
||||
wkₚσₚ : {Δₜ : Cont} {Δₚ Γₚ : Conp Δₜ}{A : For Δₜ} → Subp {Δₜ} Δₚ Γₚ → Subp {Δₜ} (Δₚ ▹p⁰ A) Γₚ
|
||||
wkₚσₚ εₚ = εₚ
|
||||
wkₚσₚ (σₚ ,ₚ pf) = (wkₚσₚ σₚ) ,ₚ wkᵣp (rightRen reflRen) pf
|
||||
|
||||
-- From a substitution into n variables, we construct a substitution from n+1 variables to n+1 variables which maps it to itself
|
||||
-- i.e. 0 -> 0 and for all i ->(old) σ(i) we get i+1 -> σ(i)+1
|
||||
lfₚσₚ : {Δₜ : Cont}{Δₚ Γₚ : Conp Δₜ}{A : For Δₜ} → Subp {Δₜ} Δₚ Γₚ → Subp {Δₜ} (Δₚ ▹p⁰ A) (Γₚ ▹p⁰ A)
|
||||
lfₚσₚ σ = (wkₚσₚ σ) ,ₚ (var pvzero)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
wkₜσₚ : Subp {Δₜ} Δₚ' Δₚ → Subp {Δₜ ▹t⁰} (Δₚ' ▹tp) (Δₚ ▹tp)
|
||||
wkₜσₚ εₚ = εₚ
|
||||
wkₜσₚ {Δₜ = Δₜ} (_,ₚ_ {A = A} σₚ pf) = (wkₜσₚ σₚ) ,ₚ substP (λ Ξₚ → Pf (Δₜ ▹t⁰) Ξₚ (A [ wkₜσₜ idₜ ]f)) refl (_[_]pₜ {Γₜ = Δₜ ▹t⁰} pf (wkₜσₜ idₜ))
|
||||
|
||||
--#
|
||||
_[_]p : {A : For Δₜ} → Pf Δₜ Δₚ A → (σ : Subp {Δₜ} Δₚ' Δₚ) → Pf Δₜ Δₚ' A
|
||||
var pvzero [ σ ,ₚ pf ]p = pf
|
||||
var (pvnext pv) [ σ ,ₚ pf ]p = var pv [ σ ]p
|
||||
app pf pf₁ [ σ ]p = app (pf [ σ ]p) (pf₁ [ σ ]p)
|
||||
lam pf [ σ ]p = lam (pf [ wkₚσₚ σ ,ₚ var pvzero ]p)
|
||||
p∀∀e pf [ σ ]p = p∀∀e (pf [ σ ]p)
|
||||
p∀∀i pf [ σ ]p = p∀∀i (pf [ wkₜσₚ σ ]p)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--# We can now define identity and composition on proof substitutions
|
||||
idₚ : Subp {Δₜ} Δₚ Δₚ
|
||||
idₚ {Δₚ = ◇p} = εₚ
|
||||
idₚ {Δₚ = Δₚ ▹p⁰ x} = lfₚσₚ (idₚ {Δₚ = Δₚ})
|
||||
_∘ₚ_ : {Γₚ Δₚ Ξₚ : Conp Δₜ} → Subp {Δₜ} Δₚ Ξₚ → Subp {Δₜ} Γₚ Δₚ → Subp {Δₜ} Γₚ Ξₚ
|
||||
εₚ ∘ₚ β = εₚ
|
||||
(α ,ₚ pf) ∘ₚ β = (α ∘ₚ β) ,ₚ (pf [ β ]p)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--# We can now merge the two notions of contexts, substitutions, and everything
|
||||
record Con : Set₁ where
|
||||
constructor con
|
||||
field
|
||||
t : Cont
|
||||
p : Conp t
|
||||
|
||||
--#
|
||||
variable
|
||||
Γ Δ Ξ : Con
|
||||
|
||||
--#
|
||||
record Sub (Γ : Con) (Δ : Con) : Set₁ where
|
||||
constructor sub
|
||||
field
|
||||
t : Subt (Con.t Γ) (Con.t Δ)
|
||||
p : Subp {Con.t Γ} (Con.p Γ) ((Con.p Δ) [ t ]c)
|
||||
|
||||
--# We need this to apply term-substitution theorems to global substitutions
|
||||
sub= : {Γ Δ : Con}{σₜ σₜ' : Subt (Con.t Γ) (Con.t Δ)} →
|
||||
σₜ ≡ σₜ' →
|
||||
{σₚ : Subp {Con.t Γ} (Con.p Γ) ((Con.p Δ) [ σₜ ]c)}
|
||||
{σₚ' : Subp {Con.t Γ} (Con.p Γ) ((Con.p Δ) [ σₜ' ]c)} →
|
||||
sub σₜ σₚ ≡ sub σₜ' σₚ'
|
||||
sub= refl = refl
|
||||
|
||||
--# (Con,Sub) is a category with an initial object
|
||||
id : Sub Γ Γ
|
||||
id {Γ} = sub idₜ (substP (Subp _) (≡sym []c-id) idₚ)
|
||||
_∘_ : Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
sub αₜ αₚ ∘ sub βₜ βₚ = sub (αₜ ∘ₜ βₜ) (substP (Subp _) (≡sym []c-∘) (αₚ [ βₜ ]σₚ) ∘ₚ βₚ)
|
||||
|
||||
|
||||
--# We have our two context extension operators
|
||||
_▹t : Con → Con
|
||||
Γ ▹t = con ((Con.t Γ) ▹t⁰) (Con.p Γ ▹tp)
|
||||
_▹p_ : (Γ : Con) → For (Con.t Γ) → Con
|
||||
Γ ▹p A = con (Con.t Γ) (Con.p Γ ▹p⁰ A)
|
||||
|
||||
--# We define the access function from the algebra, but defined for fully-featured substitutions
|
||||
-- For term substitutions
|
||||
πₜ¹* : {Γ Δ : Con} → Sub Δ (Γ ▹t) → Sub Δ Γ
|
||||
πₜ¹* (sub (σₜ ,ₜ t) σₚ) = sub σₜ (substP (Subp _) ▹tp,ₜ σₚ)
|
||||
πₜ²* : {Γ Δ : Con} → Sub Δ (Γ ▹t) → Tm (Con.t Δ)
|
||||
πₜ²* (sub (σₜ ,ₜ t) σₚ) = t
|
||||
_,ₜ*_ : {Γ Δ : Con} → Sub Δ Γ → Tm (Con.t Δ) → Sub Δ (Γ ▹t)
|
||||
(sub σₜ σₚ) ,ₜ* t = sub (σₜ ,ₜ t) (substP (Subp _) (≡sym ▹tp,ₜ) σₚ)
|
||||
-- And the equations
|
||||
πₜ²∘,ₜ* : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm (Con.t Δ)} → πₜ²* (σ ,ₜ* t) ≡ t
|
||||
πₜ²∘,ₜ* = refl
|
||||
πₜ¹∘,ₜ* : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm (Con.t Δ)} → πₜ¹* (σ ,ₜ* t) ≡ σ
|
||||
πₜ¹∘,ₜ* {Γ}{Δ}{σ}{t} = sub= refl
|
||||
,ₜ∘πₜ* : {Γ Δ : Con} → {σ : Sub Δ (Γ ▹t)} → (πₜ¹* σ) ,ₜ* (πₜ²* σ) ≡ σ
|
||||
,ₜ∘πₜ* {Γ} {Δ} {sub (σₜ ,ₜ t) σₚ} = sub= refl
|
||||
,ₜ∘* : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{t : Tm (Con.t Γ)} → (σ ,ₜ* t) ∘ δ ≡ (σ ∘ δ) ,ₜ* (t [ Sub.t δ ]t)
|
||||
,ₜ∘* {Γ} {Δ} {Ξ} {sub σₜ σₚ} {sub δₜ δₚ} {t} = sub= refl
|
||||
|
||||
|
||||
-- And for proof substitutions
|
||||
πₚ¹* : {Γ Δ : Con} {A : For (Con.t Γ)} → Sub Δ (Γ ▹p A) → Sub Δ Γ
|
||||
πₚ¹* (sub σₜ σaₚ) = sub σₜ (πₚ¹ σaₚ)
|
||||
πₚ²* : {Γ Δ : Con} {F : For (Con.t Γ)} (σ : Sub Δ (Γ ▹p F)) → Pf (Con.t Δ) (Con.p Δ) (F [ Sub.t (πₚ¹* σ) ]f)
|
||||
πₚ²* (sub σₜ (σₚ ,ₚ pf)) = pf
|
||||
_,ₚ*_ : {Γ Δ : Con} {F : For (Con.t Γ)} (σ : Sub Δ Γ) → Pf (Con.t Δ) (Con.p Δ) (F [ Sub.t σ ]f) → Sub Δ (Γ ▹p F)
|
||||
sub σₜ σₚ ,ₚ* pf = sub σₜ (σₚ ,ₚ pf)
|
||||
-- And the equations
|
||||
,ₚ∘πₚ : {Γ Δ : Con} → {F : For (Con.t Γ)} → {σ : Sub Δ (Γ ▹p F)} → (πₚ¹* σ) ,ₚ* (πₚ²* σ) ≡ σ
|
||||
,ₚ∘πₚ {σ = sub σₜ (σₚ ,ₚ p)} = refl
|
||||
,ₚ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{F : For (Con.t Ξ)}{prf : Pf (Con.t Γ) (Con.p Γ) (F [ Sub.t σ ]f)}
|
||||
→ (σ ,ₚ* prf) ∘ δ ≡ (σ ∘ δ) ,ₚ* (substP (λ F → Pf (Con.t Δ) (Con.p Δ) F) (≡sym []f-∘) ((prf [ Sub.t δ ]pₜ) [ Sub.p δ ]p))
|
||||
,ₚ∘ {Γ}{Δ}{Ξ}{σ = sub σₜ σₚ} {sub δₜ δₚ} {F = A} {prf} = sub= refl
|
||||
|
||||
-- and FINALLY, we compile everything into an implementation of the FFOL record
|
||||
|
||||
ffol : FFOL {lsuc lzero} {lsuc lzero} {lsuc lzero} {lsuc lzero}
|
||||
ffol = record
|
||||
{ Con = Con
|
||||
; Sub = Sub
|
||||
; _∘_ = _∘_
|
||||
; ∘-ass = sub= ∘ₜ-ass
|
||||
; id = id
|
||||
; idl = sub= idlₜ
|
||||
; idr = sub= idrₜ
|
||||
; ◇ = con ◇t ◇p
|
||||
; ε = sub εₜ εₚ
|
||||
; ε-u = sub= εₜ-u
|
||||
; Tm = λ Γ → Tm (Con.t Γ)
|
||||
; _[_]t = λ t σ → t [ Sub.t σ ]t
|
||||
; []t-id = []t-id
|
||||
; []t-∘ = λ {Γ}{Δ}{Ξ}{α}{β}{t} → []t-∘ {α = Sub.t α} {β = Sub.t β} {t = t}
|
||||
; _▹ₜ = _▹t
|
||||
; πₜ¹ = πₜ¹*
|
||||
; πₜ² = πₜ²*
|
||||
; _,ₜ_ = _,ₜ*_
|
||||
; πₜ²∘,ₜ = refl
|
||||
; πₜ¹∘,ₜ = λ {Γ}{Δ}{σ}{t} → πₜ¹∘,ₜ* {Γ}{Δ}{σ}{t}
|
||||
; ,ₜ∘πₜ = ,ₜ∘πₜ*
|
||||
; ,ₜ∘ = λ {Γ}{Δ}{Ξ}{σ}{δ}{t} → ,ₜ∘* {Γ}{Δ}{Ξ}{σ}{δ}{t}
|
||||
; For = λ Γ → For (Con.t Γ)
|
||||
; _[_]f = λ A σ → A [ Sub.t σ ]f
|
||||
; []f-id = []f-id
|
||||
; []f-∘ = []f-∘
|
||||
; R = R
|
||||
; R[] = refl
|
||||
; _⊢_ = λ Γ A → Pf (Con.t Γ) (Con.p Γ) A
|
||||
; _[_]p = λ pf σ → (pf [ Sub.t σ ]pₜ) [ Sub.p σ ]p
|
||||
; _▹ₚ_ = _▹p_
|
||||
; πₚ¹ = πₚ¹*
|
||||
; πₚ² = πₚ²*
|
||||
; _,ₚ_ = _,ₚ*_
|
||||
; ,ₚ∘πₚ = ,ₚ∘πₚ
|
||||
; πₚ¹∘,ₚ = refl
|
||||
; ,ₚ∘ = λ {Γ}{Δ}{Ξ}{σ}{δ}{F}{prf} → ,ₚ∘ {Γ}{Δ}{Ξ}{σ}{δ}{F}{prf}
|
||||
; _⇒_ = _⇒_
|
||||
; []f-⇒ = refl
|
||||
; ∀∀ = ∀∀
|
||||
; []f-∀∀ = []f-∀∀
|
||||
; lam = λ {Γ}{F}{G} pf → substP (λ H → Pf (Con.t Γ) (Con.p Γ) (F ⇒ H)) []f-id (lam pf)
|
||||
; app = app
|
||||
; ∀i = p∀∀i
|
||||
; ∀e = λ {Γ} {F} pf {t} → p∀∀e pf
|
||||
}
|
||||
|
||||
|
||||
-- We define normal and neutral forms
|
||||
data Ne : (Γₜ : Cont) → (Γₚ : Conp Γₜ) → For Γₜ → Prop₁
|
||||
data Nf : (Γₜ : Cont) → (Γₚ : Conp Γₜ) → For Γₜ → Prop₁
|
||||
data Ne where
|
||||
var : {A : For Γₜ} → PfVar Γₜ Γₚ A → Ne Γₜ Γₚ A
|
||||
app : {A B : For Γₜ} → Ne Γₜ Γₚ (A ⇒ B) → Nf Γₜ Γₚ A → Ne Γₜ Γₚ B
|
||||
p∀∀e : {A : For (Γₜ ▹t⁰)} → {t : Tm Γₜ} → Ne Γₜ Γₚ (∀∀ A) → Ne Γₜ Γₚ (A [ idₜ ,ₜ t ]f)
|
||||
data Nf where
|
||||
R : {t u : Tm Γₜ} → Ne Γₜ Γₚ (R t u) → Nf Γₜ Γₚ (R t u)
|
||||
lam : {A B : For Γₜ} → Nf Γₜ (Γₚ ▹p⁰ A) B → Nf Γₜ Γₚ (A ⇒ B)
|
||||
p∀∀i : {A : For (Γₜ ▹t⁰)} → Nf (Γₜ ▹t⁰) (Γₚ ▹tp) A → Nf Γₜ Γₚ (∀∀ A)
|
||||
|
||||
|
||||
Pf* : (Γₜ : Cont) → Conp Γₜ → Conp Γₜ → Prop₁
|
||||
Pf* Γₜ Γₚ ◇p = ⊤
|
||||
Pf* Γₜ Γₚ (Γₚ' ▹p⁰ A) = (Pf* Γₜ Γₚ Γₚ') ∧ (Pf Γₜ Γₚ A)
|
||||
|
||||
Sub→Pf* : {Γₜ : Cont} {Γₚ Γₚ' : Conp Γₜ} → Subp {Γₜ} Γₚ Γₚ' → Pf* Γₜ Γₚ Γₚ'
|
||||
Sub→Pf* εₚ = tt
|
||||
Sub→Pf* (σₚ ,ₚ pf) = ⟨ (Sub→Pf* σₚ) , pf ⟩
|
||||
Pf*-id : {Γₜ : Cont} {Γₚ : Conp Γₜ} → Pf* Γₜ Γₚ Γₚ
|
||||
Pf*-id = Sub→Pf* idₚ
|
||||
|
||||
Pf*▹p : {Γₜ : Cont}{Γₚ Γₚ' : Conp Γₜ}{A : For Γₜ} → Pf* Γₜ Γₚ Γₚ' → Pf* Γₜ (Γₚ ▹p⁰ A) Γₚ'
|
||||
Pf*▹p {Γₚ' = ◇p} s = tt
|
||||
Pf*▹p {Γₚ' = Γₚ' ▹p⁰ x} s = ⟨ (Pf*▹p (proj₁ s)) , (wkᵣp (rightRen reflRen) (proj₂ s)) ⟩
|
||||
Pf*▹tp : {Γₜ : Cont}{Γₚ Γₚ' : Conp Γₜ} → Pf* Γₜ Γₚ Γₚ' → Pf* (Γₜ ▹t⁰) (Γₚ ▹tp) (Γₚ' ▹tp)
|
||||
Pf*▹tp {Γₚ' = ◇p} s = tt
|
||||
Pf*▹tp {Γₚ' = Γₚ' ▹p⁰ A} s = ⟨ Pf*▹tp (proj₁ s) , (proj₂ s) [ wkₜσₜ idₜ ]pₜ ⟩
|
||||
|
||||
Pf*Pf : {Γₜ : Cont} {Γₚ Γₚ' : Conp Γₜ} {A : For Γₜ} → Pf* Γₜ Γₚ Γₚ' → Pf Γₜ Γₚ' A → Pf Γₜ Γₚ A
|
||||
Pf*Pf s (var pvzero) = proj₂ s
|
||||
Pf*Pf s (var (pvnext pv)) = Pf*Pf (proj₁ s) (var pv)
|
||||
Pf*Pf s (app p p') = app (Pf*Pf s p) (Pf*Pf s p')
|
||||
Pf*Pf s (lam p) = lam (Pf*Pf (⟨ (Pf*▹p s) , (var pvzero) ⟩) p)
|
||||
Pf*Pf s (p∀∀e p) = p∀∀e (Pf*Pf s p)
|
||||
Pf*Pf s (p∀∀i p) = p∀∀i (Pf*Pf (Pf*▹tp s) p)
|
||||
|
||||
Pf*-∘ : {Γₜ : Cont} {Γₚ Δₚ Ξₚ : Conp Γₜ} → Pf* Γₜ Δₚ Ξₚ → Pf* Γₜ Γₚ Δₚ → Pf* Γₜ Γₚ Ξₚ
|
||||
Pf*-∘ {Ξₚ = ◇p} α β = tt
|
||||
Pf*-∘ {Ξₚ = Ξₚ ▹p⁰ A} α β = ⟨ Pf*-∘ (proj₁ α) β , Pf*Pf β (proj₂ α) ⟩
|
||||
|
||||
module InitialMorphism (M : FFOL {lsuc lzero} {lsuc lzero} {lsuc lzero} {lsuc lzero} {lsuc lzero}) where
|
||||
{-# TERMINATING #-}
|
||||
|
||||
mCont : Cont → (FFOL.Con M)
|
||||
mCont ◇t = FFOL.◇ M
|
||||
mCont (Γₜ ▹t⁰) = FFOL._▹ₜ M (mCont Γₜ)
|
||||
mTmT : {Γₜ : Cont} → Tm Γₜ → (FFOL.Tm M (mCont Γₜ))
|
||||
-- Zero is (πₜ² id)
|
||||
mTmT {Γₜ ▹t⁰} (var tvzero) = FFOL.πₜ² M (FFOL.id M)
|
||||
-- N+1 is wk[tm N]
|
||||
mTmT {Γₜ ▹t⁰} (var (tvnext tv)) = (FFOL._[_]t M (mTmT (var tv)) (FFOL.πₜ¹ M (FFOL.id M)))
|
||||
|
||||
mForT : {Γₜ : Cont} → (For Γₜ) → (FFOL.For M (mCont Γₜ))
|
||||
mForT (R t u) = FFOL.R M (mTmT t) (mTmT u)
|
||||
mForT (A ⇒ B) = FFOL._⇒_ M (mForT A) (mForT B)
|
||||
mForT {Γ} (∀∀ A) = FFOL.∀∀ M (mForT A)
|
||||
|
||||
mSubt : {Δₜ : Cont}{Γₜ : Cont} → Subt Δₜ Γₜ → (FFOL.Sub M (mCont Δₜ) (mCont Γₜ))
|
||||
mSubt εₜ = FFOL.ε M
|
||||
mSubt (σₜ ,ₜ t) = FFOL._,ₜ_ M (mSubt σₜ) (mTmT t)
|
||||
|
||||
|
||||
|
||||
|
||||
mConp : {Γₜ : Cont} → Conp Γₜ → (FFOL.Con M)
|
||||
mForP : {Γₜ : Cont} {Γₚ : Conp Γₜ} → (For Γₜ) → (FFOL.For M (mConp Γₚ))
|
||||
mConp {Γₜ} ◇p = mCont Γₜ
|
||||
mConp {Γₜ} (Γₚ ▹p⁰ A) = FFOL._▹ₚ_ M (mConp Γₚ) (mForP {Γₚ = Γₚ} A)
|
||||
mForP {Γₜ} {Γₚ = ◇p} A = mForT {Γₜ} A
|
||||
mForP {Γₚ = Γₚ ▹p⁰ B} A = FFOL._[_]f M (mForP {Γₚ = Γₚ} A) (FFOL.πₚ¹ M (FFOL.id M))
|
||||
|
||||
mTmP : {Γₜ : Cont}{Γₚ : Conp Γₜ} → Tm Γₜ → (FFOL.Tm M (mConp Γₚ))
|
||||
mTmP {Γₜ}{Γₚ = ◇p} t = mTmT {Γₜ} t
|
||||
mTmP {Γₚ = Γₚ ▹p⁰ x} t = FFOL._[_]t M (mTmP {Γₚ = Γₚ} t) (FFOL.πₚ¹ M (FFOL.id M))
|
||||
|
||||
mCon : Con → (FFOL.Con M)
|
||||
mCon Γ = mConp {Con.t Γ} (Con.p Γ)
|
||||
|
||||
mFor : {Γ : Con} → (For (Con.t Γ)) → (FFOL.For M (mCon Γ))
|
||||
mFor {Γ} A = mForP {Con.t Γ} {Con.p Γ} A
|
||||
|
||||
mTm : {Γ : Con} → Tm (Con.t Γ) → (FFOL.Tm M (mCon Γ))
|
||||
mTm {Γ} t = mTmP {Con.t Γ} {Con.p Γ} t
|
||||
|
||||
e▹ₜT : {Γₜ : Cont} → mCont (Γₜ ▹t⁰) ≡ FFOL._▹ₜ M (mCont Γₜ)
|
||||
e▹ₜT = refl
|
||||
e▹ₜP : {Γₜ : Cont}{Γₚ : Conp Γₜ} → mConp {Γₜ ▹t⁰} (Γₚ [ wkₜσₜ idₜ ]c) ≡ FFOL._▹ₜ M (mConp Γₚ)
|
||||
e▹ₜP {Γₜ = Γₜ} {Γₚ = ◇p} = e▹ₜT {Γₜ = Γₜ}
|
||||
e▹ₜP {Γₚ = Γₚ ▹p⁰ A} = {!!}
|
||||
e▹ₜ : {Γ : Con} → mCon (con (Con.t Γ ▹t⁰) (Con.p Γ [ wkₜσₜ idₜ ]c)) ≡ FFOL._▹ₜ M (mCon Γ)
|
||||
e▹ₜ {Γ} = e▹ₜP {Γₜ = Con.t Γ} {Γₚ = Con.p Γ}
|
||||
|
||||
mForT⇒ : {Γₜ : Cont}{A B : For Γₜ} → mForT {Γₜ} (A ⇒ B) ≡ FFOL._⇒_ M (mForT {Γₜ} A) (mForT {Γₜ} B)
|
||||
mForT⇒ = refl
|
||||
mForP⇒ : {Γₜ : Cont}{Γₚ : Conp Γₜ}{A B : For Γₜ} → mForP {Γₜ} {Γₚ} (A ⇒ B) ≡ FFOL._⇒_ M (mForP {Γₜ} {Γₚ} A) (mForP {Γₜ} {Γₚ} B)
|
||||
mForP⇒ {Γₜ} {Γₚ = ◇p}{A}{B} = mForT⇒ {Γₜ}{A}{B}
|
||||
mForP⇒ {Γₚ = Γₚ ▹p⁰ C}{A}{B} = ≡tran (cong (λ X → (M FFOL.[ X ]f) _) (mForP⇒ {Γₚ = Γₚ})) (FFOL.[]f-⇒ M {F = mForP {Γₚ = Γₚ} A} {G = mForP {Γₚ = Γₚ} B} {σ = (FFOL.πₚ¹ M (FFOL.id M))})
|
||||
mFor⇒ : {Γ : Con}{A B : For (Con.t Γ)} → mFor {Γ} (A ⇒ B) ≡ FFOL._⇒_ M (mFor {Γ} A) (mFor {Γ} B)
|
||||
mFor⇒ {Γ} = mForP⇒ {Con.t Γ} {Con.p Γ}
|
||||
|
||||
mForT∀∀ : {Γₜ : Cont}{A : For (Γₜ ▹t⁰)} → mForT {Γₜ} (∀∀ A) ≡ FFOL.∀∀ M (mForT {Γₜ ▹t⁰} A)
|
||||
mForT∀∀ = refl
|
||||
mForP∀∀ : {Γₜ : Cont}{Γₚ : Conp Γₜ}{A : For (Γₜ ▹t⁰)} → mForP {Γₜ} {Γₚ} (∀∀ A) ≡ FFOL.∀∀ M (subst (FFOL.For M) (e▹ₜP {Γₜ} {Γₚ}) (mForP {Γₜ ▹t⁰} {Γₚ ▹tp} A))
|
||||
mForP∀∀ = {!!}
|
||||
-- mFor∀∀ : {Γ : Con}{A : For ((Con.t Γ) ▹t⁰)} → mFor {Γ} (∀∀ A) ≡ FFOL.∀∀ M (mFor {Γ ▹t} A)
|
||||
|
||||
--mForL : {Γ : Con}{A : For (Con.t Γ ▹t⁰)}{t : Tm (Con.t Γ)} → FFOL._[_]f M (mFor {Γ = {!Γ ▹t!}} A) (FFOL._,ₜ_ M (FFOL.id M) (mTm {Γ = Γ} t)) ≡ mFor {Γ = Γ} (A [ idₜ ,ₜ t ]f)
|
||||
|
||||
m⊢ : {Γ : Con} {A : For (Con.t Γ)} → Pf (Con.t Γ) (Con.p Γ) A → FFOL._⊢_ M (mCon Γ) (mFor {Γ = Γ} A)
|
||||
m⊢ (var pvzero) = FFOL.πₚ² M (FFOL.id M)
|
||||
m⊢ (var (pvnext pv)) = FFOL._[_]p M (m⊢ (var pv)) (FFOL.πₚ¹ M (FFOL.id M))
|
||||
m⊢ {Γ} {B} (app {A = A} pf pf') = FFOL.app M (substP (FFOL._⊢_ M _) (mFor⇒ {Γ}{A}{B}) (m⊢ pf)) (m⊢ pf')
|
||||
m⊢ {Γ} {A ⇒ B} (lam pf) = substP (FFOL._⊢_ M _) (≡sym (mFor⇒ {Γ}{A}{B})) (FFOL.lam M (m⊢ pf))
|
||||
m⊢ {Γ} (p∀∀e {A = A} {t = t} pf) = substP (FFOL._⊢_ M _) {!!} (FFOL.∀e M {F = mFor {{!!}} A} (substP (FFOL._⊢_ M _) {!!} (m⊢ pf)) {t = mTm {Γ} t})
|
||||
m⊢ {Γ} (p∀∀i {A = A} pf) = substP (FFOL._⊢_ M _) (≡sym mForP∀∀) (FFOL.∀i M (substP (λ Ξ → FFOL._⊢_ M Ξ (mFor A)) e▹ₜ (m⊢ pf)))
|
||||
|
||||
|
||||
mSubp : {Γₜ : Cont}{Δₚ Γₚ : Conp Γₜ} → Subp {Γₜ} Δₚ Γₚ → (FFOL.Sub M (mConp Δₚ) (mConp Γₚ))
|
||||
mSubp {Γₜ} {Γₚ = ◇p} σₚ = {!FFOL.ε M!}
|
||||
mSubp {Γₚ = Γₚ ▹p⁰ A} σₚ = FFOL._,ₚ_ M (mSubp (πₚ¹ σₚ)) {!m⊢ (πₚ² σₚ)!}
|
||||
|
||||
|
||||
mSub : {Δ : Con}{Γ : Con} → Sub Δ Γ → (FFOL.Sub M (mCon Δ) (mCon Γ))
|
||||
mSub {Δ}{Γ} σ = FFOL._∘_ M (subst (FFOL.Sub M (mCont (Con.t Δ))) {!!} (mSubt (Sub.t σ))) ({!mSubp (Sub.p σ)!})
|
||||
|
||||
|
||||
e▹ₚ : {Γ : Con}{A : For (Con.t Γ)} → mCon (Γ ▹p A) ≡ FFOL._▹ₚ_ M (mCon Γ) (mFor {Γ} A)
|
||||
e[]f : {Γ Δ : Con}{A : For (Con.t Γ)}{σ : Sub Δ Γ} → mFor {Δ} (A [ Sub.t σ ]f) ≡ FFOL._[_]f M (mFor {Γ} A) (mSub σ)
|
||||
|
||||
|
||||
{-
|
||||
e▹ₜ {con Γₜ ◇p} = refl
|
||||
e▹ₜ {con Γₜ (Γₚ ▹p⁰ A)} = ≡tran²
|
||||
(cong₂' (FFOL._▹ₚ_ M) (e▹ₜ {con Γₜ Γₚ}) (cong (subst (FFOL.For M) (e▹ₜ {Γ = con Γₜ Γₚ})) (e[]f {A = A}{σ = πₜ¹* id})))
|
||||
(substP (λ X → (M FFOL.▹ₚ (M FFOL.▹ₜ) (mCon (con Γₜ Γₚ))) X ≡ (M FFOL.▹ₜ) ((M FFOL.▹ₚ mCon (con Γₜ Γₚ)) (mFor A)))
|
||||
(≡tran
|
||||
(coeshift {!!})
|
||||
(cong (λ X → subst (FFOL.For M) _ (FFOL._[_]f M (mFor A) (mSub (sub (wkₜσₜ idₜ) X)))) (≡sym (coecoe-coe {eq1 = {!!}} {x = idₚ {Δₚ = Γₚ}}))))
|
||||
{!!})
|
||||
(cong (M FFOL.▹ₜ) (≡sym (e▹ₚ {con Γₜ Γₚ})))
|
||||
-- substP (λ X → FFOL._▹ₚ_ M X (mFor {Γ = ?} (A [ wkₜσₜ idₜ ]f)) ≡ (FFOL._▹ₜ M (mCon (con Γₜ (Γₚ ▹p⁰ A))))) (≡sym (e▹ₜ {Γ = con Γₜ Γₚ})) ?
|
||||
-}
|
||||
|
||||
|
||||
e[]f = {!!}
|
||||
e▹ₚ = {!!}
|
||||
|
||||
|
||||
{-
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
e∘ : {Γ Δ Ξ : Con}{δ : Sub Δ Ξ}{σ : Sub Γ Δ} → mSub (δ ∘ σ) ≡ FFOL._∘_ M (mSub δ) (mSub σ)
|
||||
e∘ = {!!}
|
||||
eid : {Γ : Con} → mSub (id {Γ}) ≡ FFOL.id M {mCon Γ}
|
||||
eid = {!!}
|
||||
e◇ : mCon ◇ ≡ FFOL.◇ M
|
||||
e◇ = {!!}
|
||||
eε : {Γ : Con} → mSub (sub (εₜ {Con.t Γ}) (εₚ {Con.t Γ} {Con.p Γ})) ≡ subst (FFOL.Sub M (mCon Γ)) (≡sym e◇) (FFOL.ε M {mCon Γ})
|
||||
eε = {!!}
|
||||
e[]t : {Γ Δ : Con}{t : Tm (Con.t Γ)}{σ : Sub Δ Γ} → mTm (t [ Sub.t σ ]t) ≡ FFOL._[_]t M (mTm t) (mSub σ)
|
||||
e[]t = {!!}
|
||||
eπₜ¹ : {Γ Δ : Con}{σ : Sub Δ (Γ ▹t)} → mSub (πₜ¹* σ) ≡ FFOL.πₜ¹ M (subst (FFOL.Sub M (mCon Δ)) e▹ₜ (mSub σ))
|
||||
eπₜ¹ = {!!}
|
||||
eπₜ² : {Γ Δ : Con}{σ : Sub Δ (Γ ▹t)} → mTm (πₜ²* σ) ≡ FFOL.πₜ² M (subst (FFOL.Sub M (mCon Δ)) e▹ₜ (mSub σ))
|
||||
eπₜ² = {!!}
|
||||
e,ₜ : {Γ Δ : Con}{σ : Sub Δ Γ}{t : Tm (Con.t Δ)} → mSub (σ ,ₜ* t) ≡ subst (FFOL.Sub M (mCon Δ)) (≡sym e▹ₜ) (FFOL._,ₜ_ M (mSub σ) (mTm t))
|
||||
e,ₜ = {!!}
|
||||
-- Proofs are in prop, so no equation needed
|
||||
--[]p : {Γ Δ : Con}{A : For Γ}{pf : FFOL._⊢_ S Γ A}{σ : FFOL.Sub S Δ Γ} → m⊢ (FFOL._[_]p S pf σ) ≡ FFOL._[_]p M (m⊢ pf) (mSub σ)
|
||||
e▹ₚ = {!!}
|
||||
eπₚ¹ : {Γ Δ : Con}{A : For (Con.t Γ)}{σ : Sub Δ (Γ ▹p A)} → mSub (πₚ¹* σ) ≡ FFOL.πₚ¹ M (subst (FFOL.Sub M (mCon Δ)) e▹ₚ (mSub σ))
|
||||
eπₚ¹ = {!!}
|
||||
--πₚ² : {Γ Δ : Con}{A : For Γ}{σ : Sub Δ (Γ ▹p A)} → m⊢ (πₚ²* σ) ≡ FFOL.πₚ¹ M (subst (FFOL.Sub M (mCon Δ)) e▹ₚ (mSub σ))
|
||||
e,ₚ : {Γ Δ : Con}{A : For (Con.t Γ)}{σ : Sub Δ Γ}{pf : Pf (Con.t Δ) (Con.p Δ) (A [ Sub.t σ ]f)}
|
||||
→ mSub (σ ,ₚ* pf) ≡ subst (FFOL.Sub M (mCon Δ)) (≡sym e▹ₚ) (FFOL._,ₚ_ M (mSub σ) (substP (FFOL._⊢_ M (mCon Δ)) e[]f (m⊢ pf)))
|
||||
e,ₚ = {!!}
|
||||
eR : {Γ : Con}{t u : Tm (Con.t Γ)} → mFor (R t u) ≡ FFOL.R M (mTm t) (mTm u)
|
||||
eR = {!!}
|
||||
e⇒ : {Γ : Con}{A B : For (Con.t Γ)} → mFor (A ⇒ B) ≡ FFOL._⇒_ M (mFor A) (mFor B)
|
||||
e⇒ = {!!}
|
||||
e∀∀ : {Γ : Con}{A : For ((Con.t Γ) ▹t⁰)} → mFor (∀∀ A) ≡ FFOL.∀∀ M (subst (FFOL.For M) e▹ₜ (mFor A))
|
||||
e∀∀ = {!!}
|
||||
-}
|
||||
m : Mapping ffol M
|
||||
m = record { mCon = mCon ; mSub = mSub ; mTm = λ {Γ} t → mTm {Γ} t ; mFor = λ {Γ} A → mFor {Γ} A ; m⊢ = m⊢ }
|
||||
|
||||
--mor : (M : FFOL) → Morphism ffol M
|
||||
--mor M = record {InitialMorphism M}
|
||||
|
||||
\end{code}
|
||||
765
FFOLInitial2.lagda
Normal file
765
FFOLInitial2.lagda
Normal file
@ -0,0 +1,765 @@
|
||||
git s\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module FFOLInitial2 where
|
||||
|
||||
open import FFOL
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
|
||||
data Con : Set₁
|
||||
data TmVar : Con → Set₁
|
||||
data Tm : Con → Set₁
|
||||
data For : Con → Set₁
|
||||
data Con where
|
||||
◇ : Con
|
||||
_▹ₜ : Con → Con
|
||||
_▹ₚ_ : (Γ : Con) → For Γ → Con
|
||||
|
||||
variable
|
||||
Γ Δ Ξ : Con
|
||||
|
||||
-- A term variable is a de-bruijn variable, TmVar n ≈ ⟦0,n-1⟧
|
||||
data TmVar where
|
||||
tvzero : TmVar (Γ ▹ₜ)
|
||||
tvnext : TmVar Γ → TmVar (Γ ▹ₜ)
|
||||
|
||||
-- For now, we only have term variables (no function symbol)
|
||||
data Tm where
|
||||
var : TmVar Γ → Tm Γ
|
||||
|
||||
-- Now we can define formulæ
|
||||
data For where
|
||||
R : Tm Γ → Tm Γ → For Γ
|
||||
_⇒_ : For Γ → For Γ → For Γ
|
||||
∀∀ : For (Γ ▹ₜ) → For Γ
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
data Sub : Con → Con → Set₁
|
||||
data Ren : Con → Con → Set₁
|
||||
id : Sub Γ Γ
|
||||
idᵣ : Ren Γ Γ
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
_∘ᵣ_ : {Γ Δ Ξ : Con} → Ren Δ Ξ → Ren Γ Δ → Ren Γ Ξ
|
||||
_[_]t : Tm Γ → Sub Δ Γ → Tm Δ
|
||||
_[_]f : For Γ → Sub Δ Γ → For Δ
|
||||
_[_]tvᵣ : TmVar Γ → Ren Δ Γ → TmVar Δ
|
||||
_[_]tᵣ : Tm Γ → Ren Δ Γ → Tm Δ
|
||||
_[_]fᵣ : For Γ → Ren Δ Γ → For Δ
|
||||
[]f-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ}{β : Sub Δ Γ}{A : For Γ} → A [ β ∘ α ]f ≡ (A [ β ]f) [ α ]f
|
||||
[]t-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ}{β : Sub Δ Γ}{t : Tm Γ} → t [ β ∘ α ]t ≡ (t [ β ]t) [ α ]t
|
||||
[]fᵣ-∘ᵣ : {Γ Δ Ξ : Con} → {α : Ren Ξ Δ}{β : Ren Δ Γ}{A : For Γ} → A [ β ∘ᵣ α ]fᵣ ≡ (A [ β ]fᵣ) [ α ]fᵣ
|
||||
[]tᵣ-∘ᵣ : {Γ Δ Ξ : Con} → {α : Ren Ξ Δ}{β : Ren Δ Γ}{t : Tm Γ} → t [ β ∘ᵣ α ]tᵣ ≡ (t [ β ]tᵣ) [ α ]tᵣ
|
||||
data PfVar : (Γ : Con) → For Γ → Prop₁
|
||||
data Pf : (Γ : Con) → For Γ → Prop₁
|
||||
πₜ¹ : Sub Δ (Γ ▹ₜ) → Sub Δ Γ
|
||||
πₜ² : Sub Δ (Γ ▹ₜ) → Tm Δ
|
||||
πₚ¹ : {Γ Δ : Con} {A : For Γ} → Sub Δ (Γ ▹ₚ A) → Sub Δ Γ
|
||||
πₚ² : {Γ Δ : Con} {A : For Γ} → (σ : Sub Δ (Γ ▹ₚ A)) → Pf Δ (A [ πₚ¹ σ ]f)
|
||||
_[_]p : {Γ Δ : Con} → {A : For Γ} → Pf Γ A → (σ : Sub Δ Γ) → Pf Δ (A [ σ ]f)
|
||||
_[_]pvᵣ : {Γ Δ : Con} → {A : For Γ} → PfVar Γ A → (σ : Ren Δ Γ) → PfVar Δ (A [ σ ]fᵣ)
|
||||
|
||||
data Sub where
|
||||
ε : Sub Γ ◇
|
||||
_,ₜ_ : Sub Δ Γ → Tm Δ → Sub Δ (Γ ▹ₜ)
|
||||
_,ₚ_ : {A : For Γ} → (σ : Sub Δ Γ) → Pf Δ (A [ σ ]f) → Sub Δ (Γ ▹ₚ A)
|
||||
|
||||
πₜ¹ (σ ,ₜ t) = σ
|
||||
πₜ² (σ ,ₜ t) = t
|
||||
πₚ¹ (σ ,ₚ pf) = σ
|
||||
πₚ² (σ ,ₚ pf) = pf
|
||||
|
||||
|
||||
data Ren where
|
||||
εᵣ : Ren Γ ◇
|
||||
_,ₜᵣ_ : Ren Δ Γ → TmVar Δ → Ren Δ (Γ ▹ₜ)
|
||||
_,ₚᵣ_ : {A : For Γ} → (σ : Ren Δ Γ) → PfVar Δ (A [ σ ]fᵣ) → Ren Δ (Γ ▹ₚ A)
|
||||
|
||||
πₜ¹ᵣ : Ren Δ (Γ ▹ₜ) → Ren Δ Γ
|
||||
πₜ²ᵣ : Ren Δ (Γ ▹ₜ) → TmVar Δ
|
||||
πₚ¹ᵣ : {Γ Δ : Con} {A : For Γ} → Ren Δ (Γ ▹ₚ A) → Ren Δ Γ
|
||||
πₚ²ᵣ : {Γ Δ : Con} {A : For Γ} → (σ : Ren Δ (Γ ▹ₚ A)) → PfVar Δ (A [ πₚ¹ᵣ σ ]fᵣ)
|
||||
πₜ¹ᵣ (σ ,ₜᵣ t) = σ
|
||||
πₜ²ᵣ (σ ,ₜᵣ t) = t
|
||||
πₚ¹ᵣ (σ ,ₚᵣ pf) = σ
|
||||
πₚ²ᵣ (σ ,ₚᵣ pf) = pf
|
||||
|
||||
liftᵣₜ : Ren Δ Γ → Ren (Δ ▹ₜ) (Γ ▹ₜ)
|
||||
liftᵣₜ εᵣ = εᵣ ,ₜᵣ tvzero
|
||||
liftᵣₜ (σ ,ₜᵣ t) = (liftᵣₜ σ) ,ₜᵣ tvzero
|
||||
liftᵣₜ (σ ,ₚᵣ p) = {!!}
|
||||
idᵣ {◇} = εᵣ
|
||||
idᵣ {Γ ▹ₜ} = liftᵣₜ (idᵣ {Γ})
|
||||
idᵣ {Γ ▹ₚ A} = {!!}
|
||||
|
||||
εᵣ ∘ᵣ β = εᵣ
|
||||
(α ,ₜᵣ t) ∘ᵣ β = (α ∘ᵣ β) ,ₜᵣ (t [ β ]tvᵣ)
|
||||
(α ,ₚᵣ pf) ∘ᵣ β = (α ∘ᵣ β) ,ₚᵣ substP (PfVar _) (≡sym []fᵣ-∘ᵣ) (pf [ β ]pvᵣ)
|
||||
|
||||
tvzero [ _ ,ₜᵣ tv ]tvᵣ = tv
|
||||
tvnext tv [ σ ,ₜᵣ _ ]tvᵣ = tv [ σ ]tvᵣ
|
||||
var tv [ σ ]tᵣ = var (tv [ σ ]tvᵣ)
|
||||
(R t u) [ σ ]fᵣ = R (t [ σ ]tᵣ) (u [ σ ]tᵣ)
|
||||
(A ⇒ B) [ σ ]fᵣ = (A [ σ ]fᵣ) ⇒ (B [ σ ]fᵣ)
|
||||
(∀∀ A) [ σ ]fᵣ = ∀∀ (A [ (σ ∘ᵣ πₜ¹ᵣ idᵣ) ,ₜᵣ (πₜ²ᵣ idᵣ) ]fᵣ)
|
||||
|
||||
|
||||
{-
|
||||
-- We now show how we can extend renamings
|
||||
rightRen :{A : For Δₜ} → Ren Γₚ Δₚ → Ren Γₚ (Δₚ ▹p⁰ A)
|
||||
rightRen zeroRen = zeroRen
|
||||
rightRen (leftRen x h) = leftRen (pvnext x) (rightRen h)
|
||||
bothRen : {A : For Γₜ} → Ren Γₚ Δₚ → Ren (Γₚ ▹p⁰ A) (Δₚ ▹p⁰ A)
|
||||
bothRen zeroRen = leftRen pvzero zeroRen
|
||||
bothRen (leftRen x h) = leftRen pvzero (leftRen (pvnext x) (rightRen h))
|
||||
reflRen : Ren Γₚ Γₚ
|
||||
reflRen {Γₚ = ◇p} = zeroRen
|
||||
reflRen {Γₚ = Γₚ ▹p⁰ x} = bothRen reflRen
|
||||
-}
|
||||
|
||||
id = {!!}
|
||||
ε ∘ β = ε
|
||||
(α ,ₜ t) ∘ β = (α ∘ β) ,ₜ (t [ β ]t)
|
||||
(α ,ₚ pf) ∘ β = (α ∘ β) ,ₚ substP (Pf _) (≡sym []f-∘) (pf [ β ]p)
|
||||
|
||||
var tvzero [ σ ,ₜ t ]t = t
|
||||
var (tvnext tv) [ σ ,ₜ t ]t = var tv [ σ ]t
|
||||
(R t u) [ σ ]f = R (t [ σ ]t) (u [ σ ]t)
|
||||
(A ⇒ B) [ σ ]f = (A [ σ ]f) ⇒ (B [ σ ]f)
|
||||
(∀∀ A) [ σ ]f = ∀∀ (A [ (σ ∘ πₜ¹ id) ,ₜ πₜ² id ]f)
|
||||
|
||||
[]t-∘ {β = β ,ₜ t} {t = var tvzero} = {!!}
|
||||
[]t-∘ {t = var (tvnext tv)} = {!!}
|
||||
[]f-∘ {A = R t u} = {!cong₂ R!}
|
||||
[]f-∘ {A = A ⇒ B} = {!!}
|
||||
[]f-∘ {A = ∀∀ A} = {!!}
|
||||
|
||||
|
||||
|
||||
data PfVar where
|
||||
pvzero : {A : For Γ} → PfVar (Γ ▹ₚ A) (A [ πₚ¹ id ]f)
|
||||
pvnext : {A B : For Γ} → PfVar Γ A → PfVar (Γ ▹ₚ B) (A [ πₚ¹ id ]f)
|
||||
data Pf where
|
||||
var : {A : For Γ} → PfVar Γ A → Pf Γ A
|
||||
app : {A B : For Γ} → Pf Γ (A ⇒ B) → Pf Γ A → Pf Γ B
|
||||
lam : {A B : For Γ} → Pf (Γ ▹ₚ A) (B [ πₚ¹ id ]f) → Pf Γ (A ⇒ B)
|
||||
p∀∀e : {A : For (Γ ▹ₜ)} → {t : Tm Γ} → Pf Γ (∀∀ A) → Pf Γ (A [ id ,ₜ t ]f)
|
||||
p∀∀i : {A : For (Γ ▹ₜ)} → Pf (Γ ▹ₜ) A → Pf Γ (∀∀ A)
|
||||
|
||||
var pvzero [ σ ,ₚ pf ]p = {!pf!}
|
||||
var (pvnext pv) [ σ ]p = {!!}
|
||||
app pf pf' [ σ ]p = {!!}
|
||||
lam pf [ σ ]p = {!!}
|
||||
p∀∀e pf [ σ ]p = {!!}
|
||||
p∀∀i pf [ σ ]p = {!!}
|
||||
|
||||
{-
|
||||
{-- TERM CONTEXTS - TERMS - FORMULAE - TERM SUBSTITUTIONS --}
|
||||
|
||||
-- Term contexts are isomorphic to Nat
|
||||
data Cont : Set₁ where
|
||||
◇t : Cont
|
||||
_▹t⁰ : Cont → Cont
|
||||
|
||||
variable
|
||||
Γₜ Δₜ Ξₜ : Cont
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- Then we define term substitutions
|
||||
|
||||
-- We write down the access functions from the algebra, in restricted versions
|
||||
-- And their equalities (the fact that there are reciprocical)
|
||||
πₜ²∘,ₜ : {σₜ : Subt Δₜ Γₜ} → {t : Tm Δₜ} → πₜ² (σₜ ,ₜ t) ≡ t
|
||||
πₜ²∘,ₜ = refl
|
||||
πₜ¹∘,ₜ : {σₜ : Subt Δₜ Γₜ} → {t : Tm Δₜ} → πₜ¹ (σₜ ,ₜ t) ≡ σₜ
|
||||
πₜ¹∘,ₜ = refl
|
||||
,ₜ∘πₜ : {σₜ : Subt Δₜ (Γₜ ▹t⁰)} → (πₜ¹ σₜ) ,ₜ (πₜ² σₜ) ≡ σₜ
|
||||
,ₜ∘πₜ {σₜ = σₜ ,ₜ t} = refl
|
||||
|
||||
|
||||
-- We now define the action of term substitutions on terms
|
||||
|
||||
-- We define weakenings of the term-context for terms
|
||||
-- «A term of n variables can be seen as a term of n+1 variables»
|
||||
wkₜt : Tm Γₜ → Tm (Γₜ ▹t⁰)
|
||||
wkₜt (var tv) = var (tvnext tv)
|
||||
|
||||
-- From a substition into n variables, we get a substitution into n+1 variables which don't use the last one
|
||||
wkₜσₜ : Subt Δₜ Γₜ → Subt (Δₜ ▹t⁰) Γₜ
|
||||
wkₜσₜ εₜ = εₜ
|
||||
wkₜσₜ (σ ,ₜ t) = (wkₜσₜ σ) ,ₜ (wkₜt t)
|
||||
|
||||
-- From a substitution into n variables, we construct a substitution from n+1 variables to n+1 variables which maps it to itself
|
||||
-- i.e. 0 -> 0 and for all i ->(old) σ(i) we get i+1 -> σ(i)+1
|
||||
lfₜσₜ : Subt Δₜ Γₜ → Subt (Δₜ ▹t⁰) (Γₜ ▹t⁰)
|
||||
lfₜσₜ σ = (wkₜσₜ σ) ,ₜ (var tvzero)
|
||||
|
||||
-- We show how wkₜt and interacts with [_]t
|
||||
wkₜ[]t : {α : Subt Δₜ Γₜ} → {t : Tm Γₜ} → wkₜt (t [ α ]t) ≡ (wkₜt t [ lfₜσₜ α ]t)
|
||||
wkₜ[]t {α = α ,ₜ t} {var tvzero} = refl
|
||||
wkₜ[]t {α = α ,ₜ t} {var (tvnext tv)} = wkₜ[]t {t = var tv}
|
||||
|
||||
-- We can now subst on formulæ
|
||||
|
||||
|
||||
|
||||
|
||||
-- We now can define identity and composition of term substitutions
|
||||
idₜ : Subt Γₜ Γₜ
|
||||
idₜ {◇t} = εₜ
|
||||
idₜ {Γₜ ▹t⁰} = lfₜσₜ (idₜ {Γₜ})
|
||||
_∘ₜ_ : Subt Δₜ Γₜ → Subt Ξₜ Δₜ → Subt Ξₜ Γₜ
|
||||
εₜ ∘ₜ β = εₜ
|
||||
(α ,ₜ x) ∘ₜ β = (α ∘ₜ β) ,ₜ (x [ β ]t)
|
||||
|
||||
-- We now have to show all their equalities (idₜ and ∘ₜ respect []t, []f, wkₜ, lfₜ, categorical rules
|
||||
|
||||
-- Substitution for terms
|
||||
[]t-id : {t : Tm Γₜ} → t [ idₜ {Γₜ} ]t ≡ t
|
||||
[]t-id {Γₜ ▹t⁰} {var tvzero} = refl
|
||||
[]t-id {Γₜ ▹t⁰} {var (tvnext tv)} = substP (λ t → t ≡ var (tvnext tv)) (wkₜ[]t {t = var tv}) (substP (λ t → wkₜt t ≡ var (tvnext tv)) (≡sym ([]t-id {t = var tv})) refl)
|
||||
[]t-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → {t : Tm Γₜ} → t [ β ∘ₜ α ]t ≡ (t [ β ]t) [ α ]t
|
||||
[]t-∘ {α = α} {β = β ,ₜ t} {t = var tvzero} = refl
|
||||
[]t-∘ {α = α} {β = β ,ₜ t} {t = var (tvnext tv)} = []t-∘ {t = var tv}
|
||||
|
||||
-- Weakenings and liftings of substitutions
|
||||
wkₜσₜ-∘ₜl : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → wkₜσₜ (β ∘ₜ α) ≡ (wkₜσₜ β ∘ₜ lfₜσₜ α)
|
||||
wkₜσₜ-∘ₜl {β = εₜ} = refl
|
||||
wkₜσₜ-∘ₜl {β = β ,ₜ t} = cong₂ _,ₜ_ wkₜσₜ-∘ₜl (wkₜ[]t {t = t})
|
||||
wkₜσₜ-∘ₜr : {α : Subt Γₜ Δₜ} → {β : Subt Ξₜ Γₜ} → α ∘ₜ (wkₜσₜ β) ≡ wkₜσₜ (α ∘ₜ β)
|
||||
wkₜσₜ-∘ₜr {α = εₜ} = refl
|
||||
wkₜσₜ-∘ₜr {α = α ,ₜ var tv} = cong₂ _,ₜ_ (wkₜσₜ-∘ₜr {α = α}) (≡sym (wkₜ[]t {t = var tv}))
|
||||
lfₜσₜ-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → lfₜσₜ (β ∘ₜ α) ≡ (lfₜσₜ β) ∘ₜ (lfₜσₜ α)
|
||||
lfₜσₜ-∘ {α = α} {β = εₜ} = refl
|
||||
lfₜσₜ-∘ {α = α} {β = β ,ₜ t} = cong₂ _,ₜ_ (cong₂ _,ₜ_ wkₜσₜ-∘ₜl (wkₜ[]t {t = t})) refl
|
||||
|
||||
-- Cancelling a weakening with a ,ₜ
|
||||
wkₜ[,]t : {t : Tm Γₜ}{u : Tm Δₜ}{β : Subt Δₜ Γₜ} → (wkₜt t) [ β ,ₜ u ]t ≡ t [ β ]t
|
||||
wkₜ[,]t {t = var tvzero} = refl
|
||||
wkₜ[,]t {t = var (tvnext tv)} = refl
|
||||
wkₜ∘ₜ,ₜ : {α : Subt Γₜ Δₜ}{β : Subt Ξₜ Γₜ}{t : Tm Ξₜ} → (wkₜσₜ α) ∘ₜ (β ,ₜ t) ≡ (α ∘ₜ β)
|
||||
wkₜ∘ₜ,ₜ {α = εₜ} = refl
|
||||
wkₜ∘ₜ,ₜ {α = α ,ₜ t} {β = β} = cong₂ _,ₜ_ (wkₜ∘ₜ,ₜ {α = α}) (wkₜ[,]t {t = t} {β = β})
|
||||
|
||||
-- Categorical rules are respected by idₜ and ∘ₜ
|
||||
idlₜ : {α : Subt Δₜ Γₜ} → idₜ ∘ₜ α ≡ α
|
||||
idlₜ {α = εₜ} = refl
|
||||
idlₜ {α = α ,ₜ x} = cong₂ _,ₜ_ (≡tran wkₜ∘ₜ,ₜ idlₜ) refl
|
||||
idrₜ : {α : Subt Δₜ Γₜ} → α ∘ₜ idₜ ≡ α
|
||||
idrₜ {α = εₜ} = refl
|
||||
idrₜ {α = α ,ₜ x} = cong₂ _,ₜ_ idrₜ []t-id
|
||||
∘ₜ-ass : {Γₜ Δₜ Ξₜ Ψₜ : Cont}{α : Subt Γₜ Δₜ}{β : Subt Δₜ Ξₜ}{γ : Subt Ξₜ Ψₜ} → (γ ∘ₜ β) ∘ₜ α ≡ γ ∘ₜ (β ∘ₜ α)
|
||||
∘ₜ-ass {α = α} {β} {εₜ} = refl
|
||||
∘ₜ-ass {α = α} {β} {γ ,ₜ x} = cong₂ _,ₜ_ ∘ₜ-ass (≡sym ([]t-∘ {t = x}))
|
||||
|
||||
-- Unicity of the terminal morphism
|
||||
εₜ-u : {σₜ : Subt Γₜ ◇t} → σₜ ≡ εₜ
|
||||
εₜ-u {σₜ = εₜ} = refl
|
||||
|
||||
-- Substitution for formulæ
|
||||
[]f-id : {F : For Γₜ} → F [ idₜ {Γₜ} ]f ≡ F
|
||||
[]f-id {F = R t u} = cong₂ R []t-id []t-id
|
||||
[]f-id {F = F ⇒ G} = cong₂ _⇒_ []f-id []f-id
|
||||
[]f-id {F = ∀∀ F} = cong ∀∀ []f-id
|
||||
[]f-∘ : {α : Subt Ξₜ Δₜ} → {β : Subt Δₜ Γₜ} → {F : For Γₜ} → F [ β ∘ₜ α ]f ≡ (F [ β ]f) [ α ]f
|
||||
[]f-∘ {α = α} {β = β} {F = R t u} = cong₂ R ([]t-∘ {α = α} {β = β} {t = t}) ([]t-∘ {α = α} {β = β} {t = u})
|
||||
[]f-∘ {F = F ⇒ G} = cong₂ _⇒_ []f-∘ []f-∘
|
||||
[]f-∘ {F = ∀∀ F} = cong ∀∀ (≡tran (cong (λ σ → F [ σ ]f) lfₜσₜ-∘) []f-∘)
|
||||
|
||||
-- Substitution for formulæ constructors
|
||||
-- we omit []f-R and []f-⇒ as they are directly refl
|
||||
[]f-∀∀ : {A : For (Γₜ ▹t⁰)} → {σₜ : Subt Δₜ Γₜ} → (∀∀ A) [ σₜ ]f ≡ (∀∀ (A [ (σₜ ∘ₜ πₜ¹ idₜ) ,ₜ πₜ² idₜ ]f))
|
||||
[]f-∀∀ {A = A} = cong ∀∀ (cong (_[_]f A) (cong₂ _,ₜ_ (≡tran (cong wkₜσₜ (≡sym idrₜ)) (≡sym wkₜσₜ-∘ₜr)) refl))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- We can now define proof contexts, which are indexed by a term context
|
||||
-- i.e. we know which terms a proof context can use
|
||||
data Conp : Cont → Set₁ where
|
||||
◇p : Conp Γₜ
|
||||
_▹p⁰_ : Conp Γₜ → For Γₜ → Conp Γₜ
|
||||
|
||||
variable
|
||||
Γₚ Γₚ' : Conp Γₜ
|
||||
Δₚ Δₚ' : Conp Δₜ
|
||||
Ξₚ Ξₚ' : Conp Ξₜ
|
||||
|
||||
-- The actions of Subt's is extended to contexts
|
||||
_[_]c : Conp Γₜ → Subt Δₜ Γₜ → Conp Δₜ
|
||||
◇p [ σₜ ]c = ◇p
|
||||
(Γₚ ▹p⁰ A) [ σₜ ]c = (Γₚ [ σₜ ]c) ▹p⁰ (A [ σₜ ]f)
|
||||
-- This Conp is indeed a functor
|
||||
[]c-id : Γₚ [ idₜ ]c ≡ Γₚ
|
||||
[]c-id {Γₚ = ◇p} = refl
|
||||
[]c-id {Γₚ = Γₚ ▹p⁰ x} = cong₂ _▹p⁰_ []c-id []f-id
|
||||
[]c-∘ : {α : Subt Δₜ Ξₜ} {β : Subt Γₜ Δₜ} {Ξₚ : Conp Ξₜ} → Ξₚ [ α ∘ₜ β ]c ≡ (Ξₚ [ α ]c) [ β ]c
|
||||
[]c-∘ {α = α} {β = β} {◇p} = refl
|
||||
[]c-∘ {α = α} {β = β} {Ξₚ ▹p⁰ A} = cong₂ _▹p⁰_ []c-∘ []f-∘
|
||||
|
||||
|
||||
-- We can also add a term that will not be used in the formulæ already present
|
||||
-- (that's why we use wkₜσₜ)
|
||||
_▹tp : Conp Γₜ → Conp (Γₜ ▹t⁰)
|
||||
Γ ▹tp = Γ [ wkₜσₜ idₜ ]c
|
||||
-- We show how it interacts with ,ₜ and lfₜσₜ
|
||||
▹tp,ₜ : {σₜ : Subt Γₜ Δₜ}{t : Tm Γₜ} → (Γₚ ▹tp) [ σₜ ,ₜ t ]c ≡ Γₚ [ σₜ ]c
|
||||
▹tp,ₜ {Γₚ = Γₚ} = ≡tran (≡sym []c-∘) (cong (λ ξ → Γₚ [ ξ ]c) (≡tran wkₜ∘ₜ,ₜ idlₜ))
|
||||
▹tp-lfₜ : {σ : Subt Δₜ Γₜ} → ((Δₚ ▹tp) [ lfₜσₜ σ ]c) ≡ ((Δₚ [ σ ]c) ▹tp)
|
||||
▹tp-lfₜ {Δₚ = Δₚ} = ≡tran² (≡sym []c-∘) (cong (λ ξ → Δₚ [ ξ ]c) (≡tran² (≡sym wkₜσₜ-∘ₜl) (cong wkₜσₜ (≡tran idlₜ (≡sym idrₜ))) (≡sym wkₜσₜ-∘ₜr))) []c-∘
|
||||
|
||||
|
||||
|
||||
-- With those contexts, we have everything to define proofs
|
||||
|
||||
|
||||
-- The action on Cont's morphisms of Pf functor
|
||||
_[_]pvₜ : {A : For Δₜ}→ PfVar Δₜ Δₚ A → (σ : Subt Γₜ Δₜ)→ PfVar Γₜ (Δₚ [ σ ]c) (A [ σ ]f)
|
||||
pvzero [ σ ]pvₜ = pvzero
|
||||
pvnext pv [ σ ]pvₜ = pvnext (pv [ σ ]pvₜ)
|
||||
_[_]pₜ : {A : For Δₜ} → Pf Δₜ Δₚ A → (σ : Subt Γₜ Δₜ) → Pf Γₜ (Δₚ [ σ ]c) (A [ σ ]f)
|
||||
var pv [ σ ]pₜ = var (pv [ σ ]pvₜ)
|
||||
app pf pf' [ σ ]pₜ = app (pf [ σ ]pₜ) (pf' [ σ ]pₜ)
|
||||
lam pf [ σ ]pₜ = lam (pf [ σ ]pₜ)
|
||||
_[_]pₜ {Δₚ = Δₚ} {Γₜ = Γₜ} (p∀∀e {A = A} {t = t} pf) σ =
|
||||
substP (λ F → Pf Γₜ (Δₚ [ σ ]c) F) (≡tran² (≡sym []f-∘) (cong (λ σ → A [ σ ]f)
|
||||
(cong₂ _,ₜ_ (≡tran² wkₜ∘ₜ,ₜ idrₜ (≡sym idlₜ)) refl)) ([]f-∘))
|
||||
(p∀∀e {t = t [ σ ]t} (pf [ σ ]pₜ))
|
||||
_[_]pₜ {Γₜ = Γₜ} (p∀∀i pf) σ
|
||||
= p∀∀i (substP (λ Ξₚ → Pf (Γₜ ▹t⁰) (Ξₚ) _) ▹tp-lfₜ (pf [ lfₜσₜ σ ]pₜ))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- We now can create Renamings, a subcategory from (Conp,Subp) that
|
||||
-- A renaming from a context Γₚ to a context Δₚ means when they are seen
|
||||
-- as lists, that every element of Γₚ is an element of Δₚ
|
||||
-- In other words, we can prove Γₚ from Δₚ using only proof variables (var)
|
||||
|
||||
-- We can extend renamings with term variables
|
||||
PfVar▹tp : {A : For Δₜ} → PfVar Δₜ Δₚ A → PfVar (Δₜ ▹t⁰) (Δₚ ▹tp) (A [ wkₜσₜ idₜ ]f)
|
||||
PfVar▹tp pvzero = pvzero
|
||||
PfVar▹tp (pvnext x) = pvnext (PfVar▹tp x)
|
||||
Ren▹tp : Ren Γₚ Δₚ → Ren (Γₚ ▹tp) (Δₚ ▹tp)
|
||||
Ren▹tp zeroRen = zeroRen
|
||||
Ren▹tp (leftRen x s) = leftRen (PfVar▹tp x) (Ren▹tp s)
|
||||
|
||||
-- Renamings can be used to (strongly) weaken proofs
|
||||
wkᵣpv : {A : For Δₜ} → Ren Δₚ' Δₚ → PfVar Δₜ Δₚ' A → PfVar Δₜ Δₚ A
|
||||
wkᵣpv (leftRen x x₁) pvzero = x
|
||||
wkᵣpv (leftRen x x₁) (pvnext s) = wkᵣpv x₁ s
|
||||
wkᵣp : {A : For Δₜ} → Ren Δₚ Δₚ' → Pf Δₜ Δₚ A → Pf Δₜ Δₚ' A
|
||||
wkᵣp s (var pv) = var (wkᵣpv s pv)
|
||||
wkᵣp s (app pf pf₁) = app (wkᵣp s pf) (wkᵣp s pf₁)
|
||||
wkᵣp s (lam {A = A} pf) = lam (wkᵣp (bothRen s) pf)
|
||||
wkᵣp s (p∀∀e pf) = p∀∀e (wkᵣp s pf)
|
||||
wkᵣp s (p∀∀i pf) = p∀∀i (wkᵣp (Ren▹tp s) pf)
|
||||
|
||||
|
||||
-- But we need something stronger than just renamings
|
||||
-- introducing: Proof substitutions
|
||||
-- They are basicly a list of proofs for the formulæ contained in
|
||||
-- the goal context.
|
||||
-- It is not defined between all contexts, only those with the same term context
|
||||
data Subp : {Δₜ : Cont} → Conp Δₜ → Conp Δₜ → Prop₁ where
|
||||
εₚ : Subp Δₚ ◇p
|
||||
|
||||
|
||||
-- We write down the access functions from the algebra, in restricted versions
|
||||
|
||||
-- The action of Cont's morphisms on Subp
|
||||
_[_]σₚ : Subp {Δₜ} Δₚ Δₚ' → (σ : Subt Γₜ Δₜ) → Subp {Γₜ} (Δₚ [ σ ]c) (Δₚ' [ σ ]c)
|
||||
εₚ [ σₜ ]σₚ = εₚ
|
||||
(σₚ ,ₚ pf) [ σₜ ]σₚ = (σₚ [ σₜ ]σₚ) ,ₚ (pf [ σₜ ]pₜ)
|
||||
|
||||
-- They are indeed stronger than renamings
|
||||
Ren→Sub : Ren Δₚ Δₚ' → Subp {Δₜ} Δₚ' Δₚ
|
||||
Ren→Sub zeroRen = εₚ
|
||||
Ren→Sub (leftRen x s) = Ren→Sub s ,ₚ var x
|
||||
|
||||
|
||||
-- From a substition into n variables, we get a substitution into n+1 variables which don't use the last one
|
||||
wkₚσₚ : {Δₜ : Cont} {Δₚ Γₚ : Conp Δₜ}{A : For Δₜ} → Subp {Δₜ} Δₚ Γₚ → Subp {Δₜ} (Δₚ ▹p⁰ A) Γₚ
|
||||
wkₚσₚ εₚ = εₚ
|
||||
wkₚσₚ (σₚ ,ₚ pf) = (wkₚσₚ σₚ) ,ₚ wkᵣp (rightRen reflRen) pf
|
||||
|
||||
-- From a substitution into n variables, we construct a substitution from n+1 variables to n+1 variables which maps it to itself
|
||||
-- i.e. 0 -> 0 and for all i ->(old) σ(i) we get i+1 -> σ(i)+1
|
||||
lfₚσₚ : {Δₜ : Cont}{Δₚ Γₚ : Conp Δₜ}{A : For Δₜ} → Subp {Δₜ} Δₚ Γₚ → Subp {Δₜ} (Δₚ ▹p⁰ A) (Γₚ ▹p⁰ A)
|
||||
lfₚσₚ σ = (wkₚσₚ σ) ,ₚ (var pvzero)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
wkₜσₚ : Subp {Δₜ} Δₚ' Δₚ → Subp {Δₜ ▹t⁰} (Δₚ' ▹tp) (Δₚ ▹tp)
|
||||
wkₜσₚ εₚ = εₚ
|
||||
wkₜσₚ {Δₜ = Δₜ} (_,ₚ_ {A = A} σₚ pf) = (wkₜσₚ σₚ) ,ₚ substP (λ Ξₚ → Pf (Δₜ ▹t⁰) Ξₚ (A [ wkₜσₜ idₜ ]f)) refl (_[_]pₜ {Γₜ = Δₜ ▹t⁰} pf (wkₜσₜ idₜ))
|
||||
|
||||
_[_]p : {A : For Δₜ} → Pf Δₜ Δₚ A → (σ : Subp {Δₜ} Δₚ' Δₚ) → Pf Δₜ Δₚ' A
|
||||
var pvzero [ σ ,ₚ pf ]p = pf
|
||||
var (pvnext pv) [ σ ,ₚ pf ]p = var pv [ σ ]p
|
||||
app pf pf₁ [ σ ]p = app (pf [ σ ]p) (pf₁ [ σ ]p)
|
||||
lam pf [ σ ]p = lam (pf [ wkₚσₚ σ ,ₚ var pvzero ]p)
|
||||
p∀∀e pf [ σ ]p = p∀∀e (pf [ σ ]p)
|
||||
p∀∀i pf [ σ ]p = p∀∀i (pf [ wkₜσₚ σ ]p)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- We can now define identity and composition on proof substitutions
|
||||
idₚ : Subp {Δₜ} Δₚ Δₚ
|
||||
idₚ {Δₚ = ◇p} = εₚ
|
||||
idₚ {Δₚ = Δₚ ▹p⁰ x} = lfₚσₚ (idₚ {Δₚ = Δₚ})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- We can now merge the two notions of contexts, substitutions, and everything
|
||||
record Con : Set₁ where
|
||||
constructor con
|
||||
field
|
||||
t : Cont
|
||||
p : Conp t
|
||||
|
||||
variable
|
||||
Γ Δ Ξ : Con
|
||||
|
||||
record Sub (Γ : Con) (Δ : Con) : Set₁ where
|
||||
constructor sub
|
||||
field
|
||||
t : Subt (Con.t Γ) (Con.t Δ)
|
||||
p : Subp {Con.t Γ} (Con.p Γ) ((Con.p Δ) [ t ]c)
|
||||
|
||||
-- We need this to apply term-substitution theorems to global substitutions
|
||||
sub= : {Γ Δ : Con}{σₜ σₜ' : Subt (Con.t Γ) (Con.t Δ)} →
|
||||
σₜ ≡ σₜ' →
|
||||
{σₚ : Subp {Con.t Γ} (Con.p Γ) ((Con.p Δ) [ σₜ ]c)}
|
||||
{σₚ' : Subp {Con.t Γ} (Con.p Γ) ((Con.p Δ) [ σₜ' ]c)} →
|
||||
sub σₜ σₚ ≡ sub σₜ' σₚ'
|
||||
sub= refl = refl
|
||||
|
||||
-- (Con,Sub) is a category with an initial object
|
||||
id : Sub Γ Γ
|
||||
id {Γ} = sub idₜ (substP (Subp _) (≡sym []c-id) idₚ)
|
||||
_∘_ : Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
sub αₜ αₚ ∘ sub βₜ βₚ = sub (αₜ ∘ₜ βₜ) (substP (Subp _) (≡sym []c-∘) (αₚ [ βₜ ]σₚ) ∘ₚ βₚ)
|
||||
|
||||
|
||||
-- We have our two context extension operators
|
||||
_▹t : Con → Con
|
||||
Γ ▹t = con ((Con.t Γ) ▹t⁰) (Con.p Γ ▹tp)
|
||||
_▹p_ : (Γ : Con) → For (Con.t Γ) → Con
|
||||
Γ ▹p A = con (Con.t Γ) (Con.p Γ ▹p⁰ A)
|
||||
|
||||
-- We define the access function from the algebra, but defined for fully-featured substitutions
|
||||
-- For term substitutions
|
||||
πₜ¹* : {Γ Δ : Con} → Sub Δ (Γ ▹t) → Sub Δ Γ
|
||||
πₜ¹* (sub (σₜ ,ₜ t) σₚ) = sub σₜ (substP (Subp _) ▹tp,ₜ σₚ)
|
||||
πₜ²* : {Γ Δ : Con} → Sub Δ (Γ ▹t) → Tm (Con.t Δ)
|
||||
πₜ²* (sub (σₜ ,ₜ t) σₚ) = t
|
||||
_,ₜ*_ : {Γ Δ : Con} → Sub Δ Γ → Tm (Con.t Δ) → Sub Δ (Γ ▹t)
|
||||
(sub σₜ σₚ) ,ₜ* t = sub (σₜ ,ₜ t) (substP (Subp _) (≡sym ▹tp,ₜ) σₚ)
|
||||
-- And the equations
|
||||
πₜ²∘,ₜ* : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm (Con.t Δ)} → πₜ²* (σ ,ₜ* t) ≡ t
|
||||
πₜ²∘,ₜ* = refl
|
||||
πₜ¹∘,ₜ* : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t : Tm (Con.t Δ)} → πₜ¹* (σ ,ₜ* t) ≡ σ
|
||||
πₜ¹∘,ₜ* {Γ}{Δ}{σ}{t} = sub= refl
|
||||
,ₜ∘πₜ* : {Γ Δ : Con} → {σ : Sub Δ (Γ ▹t)} → (πₜ¹* σ) ,ₜ* (πₜ²* σ) ≡ σ
|
||||
,ₜ∘πₜ* {Γ} {Δ} {sub (σₜ ,ₜ t) σₚ} = sub= refl
|
||||
,ₜ∘* : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{t : Tm (Con.t Γ)} → (σ ,ₜ* t) ∘ δ ≡ (σ ∘ δ) ,ₜ* (t [ Sub.t δ ]t)
|
||||
,ₜ∘* {Γ} {Δ} {Ξ} {sub σₜ σₚ} {sub δₜ δₚ} {t} = sub= refl
|
||||
|
||||
|
||||
-- And for proof substitutions
|
||||
πₚ¹* : {Γ Δ : Con} {A : For (Con.t Γ)} → Sub Δ (Γ ▹p A) → Sub Δ Γ
|
||||
πₚ¹* (sub σₜ σaₚ) = sub σₜ (πₚ¹ σaₚ)
|
||||
πₚ²* : {Γ Δ : Con} {F : For (Con.t Γ)} (σ : Sub Δ (Γ ▹p F)) → Pf (Con.t Δ) (Con.p Δ) (F [ Sub.t (πₚ¹* σ) ]f)
|
||||
πₚ²* (sub σₜ (σₚ ,ₚ pf)) = pf
|
||||
_,ₚ*_ : {Γ Δ : Con} {F : For (Con.t Γ)} (σ : Sub Δ Γ) → Pf (Con.t Δ) (Con.p Δ) (F [ Sub.t σ ]f) → Sub Δ (Γ ▹p F)
|
||||
sub σₜ σₚ ,ₚ* pf = sub σₜ (σₚ ,ₚ pf)
|
||||
-- And the equations
|
||||
,ₚ∘πₚ : {Γ Δ : Con} → {F : For (Con.t Γ)} → {σ : Sub Δ (Γ ▹p F)} → (πₚ¹* σ) ,ₚ* (πₚ²* σ) ≡ σ
|
||||
,ₚ∘πₚ {σ = sub σₜ (σₚ ,ₚ p)} = refl
|
||||
,ₚ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{F : For (Con.t Ξ)}{prf : Pf (Con.t Γ) (Con.p Γ) (F [ Sub.t σ ]f)}
|
||||
→ (σ ,ₚ* prf) ∘ δ ≡ (σ ∘ δ) ,ₚ* (substP (λ F → Pf (Con.t Δ) (Con.p Δ) F) (≡sym []f-∘) ((prf [ Sub.t δ ]pₜ) [ Sub.p δ ]p))
|
||||
,ₚ∘ {Γ}{Δ}{Ξ}{σ = sub σₜ σₚ} {sub δₜ δₚ} {F = A} {prf} = sub= refl
|
||||
|
||||
-- and FINALLY, we compile everything into an implementation of the FFOL record
|
||||
|
||||
ffol : FFOL {lsuc lzero} {lsuc lzero} {lsuc lzero} {lsuc lzero}
|
||||
ffol = record
|
||||
{ Con = Con
|
||||
; Sub = Sub
|
||||
; _∘_ = _∘_
|
||||
; ∘-ass = sub= ∘ₜ-ass
|
||||
; id = id
|
||||
; idl = sub= idlₜ
|
||||
; idr = sub= idrₜ
|
||||
; ◇ = con ◇t ◇p
|
||||
; ε = sub εₜ εₚ
|
||||
; ε-u = sub= εₜ-u
|
||||
; Tm = λ Γ → Tm (Con.t Γ)
|
||||
; _[_]t = λ t σ → t [ Sub.t σ ]t
|
||||
; []t-id = []t-id
|
||||
; []t-∘ = λ {Γ}{Δ}{Ξ}{α}{β}{t} → []t-∘ {α = Sub.t α} {β = Sub.t β} {t = t}
|
||||
; _▹ₜ = _▹t
|
||||
; πₜ¹ = πₜ¹*
|
||||
; πₜ² = πₜ²*
|
||||
; _,ₜ_ = _,ₜ*_
|
||||
; πₜ²∘,ₜ = refl
|
||||
; πₜ¹∘,ₜ = λ {Γ}{Δ}{σ}{t} → πₜ¹∘,ₜ* {Γ}{Δ}{σ}{t}
|
||||
; ,ₜ∘πₜ = ,ₜ∘πₜ*
|
||||
; ,ₜ∘ = λ {Γ}{Δ}{Ξ}{σ}{δ}{t} → ,ₜ∘* {Γ}{Δ}{Ξ}{σ}{δ}{t}
|
||||
; For = λ Γ → For (Con.t Γ)
|
||||
; _[_]f = λ A σ → A [ Sub.t σ ]f
|
||||
; []f-id = []f-id
|
||||
; []f-∘ = []f-∘
|
||||
; R = R
|
||||
; R[] = refl
|
||||
; _⊢_ = λ Γ A → Pf (Con.t Γ) (Con.p Γ) A
|
||||
; _[_]p = λ pf σ → (pf [ Sub.t σ ]pₜ) [ Sub.p σ ]p
|
||||
; _▹ₚ_ = _▹p_
|
||||
; πₚ¹ = πₚ¹*
|
||||
; πₚ² = πₚ²*
|
||||
; _,ₚ_ = _,ₚ*_
|
||||
; ,ₚ∘πₚ = ,ₚ∘πₚ
|
||||
; πₚ¹∘,ₚ = refl
|
||||
; ,ₚ∘ = λ {Γ}{Δ}{Ξ}{σ}{δ}{F}{prf} → ,ₚ∘ {Γ}{Δ}{Ξ}{σ}{δ}{F}{prf}
|
||||
; _⇒_ = _⇒_
|
||||
; []f-⇒ = refl
|
||||
; ∀∀ = ∀∀
|
||||
; []f-∀∀ = []f-∀∀
|
||||
; lam = λ {Γ}{F}{G} pf → substP (λ H → Pf (Con.t Γ) (Con.p Γ) (F ⇒ H)) []f-id (lam pf)
|
||||
; app = app
|
||||
; ∀i = p∀∀i
|
||||
; ∀e = λ {Γ} {F} pf {t} → p∀∀e pf
|
||||
}
|
||||
|
||||
|
||||
-- We define normal and neutral forms
|
||||
data Ne : (Γₜ : Cont) → (Γₚ : Conp Γₜ) → For Γₜ → Prop₁
|
||||
data Nf : (Γₜ : Cont) → (Γₚ : Conp Γₜ) → For Γₜ → Prop₁
|
||||
data Ne where
|
||||
var : {A : For Γₜ} → PfVar Γₜ Γₚ A → Ne Γₜ Γₚ A
|
||||
app : {A B : For Γₜ} → Ne Γₜ Γₚ (A ⇒ B) → Nf Γₜ Γₚ A → Ne Γₜ Γₚ B
|
||||
p∀∀e : {A : For (Γₜ ▹t⁰)} → {t : Tm Γₜ} → Ne Γₜ Γₚ (∀∀ A) → Ne Γₜ Γₚ (A [ idₜ ,ₜ t ]f)
|
||||
data Nf where
|
||||
R : {t u : Tm Γₜ} → Ne Γₜ Γₚ (R t u) → Nf Γₜ Γₚ (R t u)
|
||||
lam : {A B : For Γₜ} → Nf Γₜ (Γₚ ▹p⁰ A) B → Nf Γₜ Γₚ (A ⇒ B)
|
||||
p∀∀i : {A : For (Γₜ ▹t⁰)} → Nf (Γₜ ▹t⁰) (Γₚ ▹tp) A → Nf Γₜ Γₚ (∀∀ A)
|
||||
|
||||
|
||||
Pf* : (Γₜ : Cont) → Conp Γₜ → Conp Γₜ → Prop₁
|
||||
Pf* Γₜ Γₚ ◇p = ⊤
|
||||
Pf* Γₜ Γₚ (Γₚ' ▹p⁰ A) = (Pf* Γₜ Γₚ Γₚ') ∧ (Pf Γₜ Γₚ A)
|
||||
|
||||
Sub→Pf* : {Γₜ : Cont} {Γₚ Γₚ' : Conp Γₜ} → Subp {Γₜ} Γₚ Γₚ' → Pf* Γₜ Γₚ Γₚ'
|
||||
Sub→Pf* εₚ = tt
|
||||
Sub→Pf* (σₚ ,ₚ pf) = ⟨ (Sub→Pf* σₚ) , pf ⟩
|
||||
Pf*-id : {Γₜ : Cont} {Γₚ : Conp Γₜ} → Pf* Γₜ Γₚ Γₚ
|
||||
Pf*-id = Sub→Pf* idₚ
|
||||
|
||||
Pf*▹p : {Γₜ : Cont}{Γₚ Γₚ' : Conp Γₜ}{A : For Γₜ} → Pf* Γₜ Γₚ Γₚ' → Pf* Γₜ (Γₚ ▹p⁰ A) Γₚ'
|
||||
Pf*▹p {Γₚ' = ◇p} s = tt
|
||||
Pf*▹p {Γₚ' = Γₚ' ▹p⁰ x} s = ⟨ (Pf*▹p (proj₁ s)) , (wkᵣp (rightRen reflRen) (proj₂ s)) ⟩
|
||||
Pf*▹tp : {Γₜ : Cont}{Γₚ Γₚ' : Conp Γₜ} → Pf* Γₜ Γₚ Γₚ' → Pf* (Γₜ ▹t⁰) (Γₚ ▹tp) (Γₚ' ▹tp)
|
||||
Pf*▹tp {Γₚ' = ◇p} s = tt
|
||||
Pf*▹tp {Γₚ' = Γₚ' ▹p⁰ A} s = ⟨ Pf*▹tp (proj₁ s) , (proj₂ s) [ wkₜσₜ idₜ ]pₜ ⟩
|
||||
|
||||
Pf*Pf : {Γₜ : Cont} {Γₚ Γₚ' : Conp Γₜ} {A : For Γₜ} → Pf* Γₜ Γₚ Γₚ' → Pf Γₜ Γₚ' A → Pf Γₜ Γₚ A
|
||||
Pf*Pf s (var pvzero) = proj₂ s
|
||||
Pf*Pf s (var (pvnext pv)) = Pf*Pf (proj₁ s) (var pv)
|
||||
Pf*Pf s (app p p') = app (Pf*Pf s p) (Pf*Pf s p')
|
||||
Pf*Pf s (lam p) = lam (Pf*Pf (⟨ (Pf*▹p s) , (var pvzero) ⟩) p)
|
||||
Pf*Pf s (p∀∀e p) = p∀∀e (Pf*Pf s p)
|
||||
Pf*Pf s (p∀∀i p) = p∀∀i (Pf*Pf (Pf*▹tp s) p)
|
||||
|
||||
Pf*-∘ : {Γₜ : Cont} {Γₚ Δₚ Ξₚ : Conp Γₜ} → Pf* Γₜ Δₚ Ξₚ → Pf* Γₜ Γₚ Δₚ → Pf* Γₜ Γₚ Ξₚ
|
||||
Pf*-∘ {Ξₚ = ◇p} α β = tt
|
||||
Pf*-∘ {Ξₚ = Ξₚ ▹p⁰ A} α β = ⟨ Pf*-∘ (proj₁ α) β , Pf*Pf β (proj₂ α) ⟩
|
||||
-}
|
||||
|
||||
{-
|
||||
module InitialMorphism (M : FFOL {lsuc lzero} {lsuc lzero} {lsuc lzero} {lsuc lzero} {lsuc lzero}) where
|
||||
{-# TERMINATING #-}
|
||||
|
||||
mCont : Cont → (FFOL.Con M)
|
||||
mCont ◇t = FFOL.◇ M
|
||||
mCont (Γₜ ▹t⁰) = FFOL._▹ₜ M (mCont Γₜ)
|
||||
mTmT : {Γₜ : Cont} → Tm Γₜ → (FFOL.Tm M (mCont Γₜ))
|
||||
-- Zero is (πₜ² id)
|
||||
mTmT {Γₜ ▹t⁰} (var tvzero) = FFOL.πₜ² M (FFOL.id M)
|
||||
-- N+1 is wk[tm N]
|
||||
mTmT {Γₜ ▹t⁰} (var (tvnext tv)) = (FFOL._[_]t M (mTmT (var tv)) (FFOL.πₜ¹ M (FFOL.id M)))
|
||||
|
||||
mForT : {Γₜ : Cont} → (For Γₜ) → (FFOL.For M (mCont Γₜ))
|
||||
mForT (R t u) = FFOL.R M (mTmT t) (mTmT u)
|
||||
mForT (A ⇒ B) = FFOL._⇒_ M (mForT A) (mForT B)
|
||||
mForT {Γ} (∀∀ A) = FFOL.∀∀ M (mForT A)
|
||||
|
||||
mSubt : {Δₜ : Cont}{Γₜ : Cont} → Subt Δₜ Γₜ → (FFOL.Sub M (mCont Δₜ) (mCont Γₜ))
|
||||
mSubt εₜ = FFOL.ε M
|
||||
mSubt (σₜ ,ₜ t) = FFOL._,ₜ_ M (mSubt σₜ) (mTmT t)
|
||||
|
||||
|
||||
|
||||
|
||||
mConp : {Γₜ : Cont} → Conp Γₜ → (FFOL.Con M)
|
||||
mForP : {Γₜ : Cont} {Γₚ : Conp Γₜ} → (For Γₜ) → (FFOL.For M (mConp Γₚ))
|
||||
mConp {Γₜ} ◇p = mCont Γₜ
|
||||
mConp {Γₜ} (Γₚ ▹p⁰ A) = FFOL._▹ₚ_ M (mConp Γₚ) (mForP {Γₚ = Γₚ} A)
|
||||
mForP {Γₜ} {Γₚ = ◇p} A = mForT {Γₜ} A
|
||||
mForP {Γₚ = Γₚ ▹p⁰ B} A = FFOL._[_]f M (mForP {Γₚ = Γₚ} A) (FFOL.πₚ¹ M (FFOL.id M))
|
||||
|
||||
mTmP : {Γₜ : Cont}{Γₚ : Conp Γₜ} → Tm Γₜ → (FFOL.Tm M (mConp Γₚ))
|
||||
mTmP {Γₜ}{Γₚ = ◇p} t = mTmT {Γₜ} t
|
||||
mTmP {Γₚ = Γₚ ▹p⁰ x} t = FFOL._[_]t M (mTmP {Γₚ = Γₚ} t) (FFOL.πₚ¹ M (FFOL.id M))
|
||||
|
||||
mCon : Con → (FFOL.Con M)
|
||||
mCon Γ = mConp {Con.t Γ} (Con.p Γ)
|
||||
|
||||
mFor : {Γ : Con} → (For (Con.t Γ)) → (FFOL.For M (mCon Γ))
|
||||
mFor {Γ} A = mForP {Con.t Γ} {Con.p Γ} A
|
||||
|
||||
mTm : {Γ : Con} → Tm (Con.t Γ) → (FFOL.Tm M (mCon Γ))
|
||||
mTm {Γ} t = mTmP {Con.t Γ} {Con.p Γ} t
|
||||
|
||||
e▹ₜT : {Γₜ : Cont} → mCont (Γₜ ▹t⁰) ≡ FFOL._▹ₜ M (mCont Γₜ)
|
||||
e▹ₜT = refl
|
||||
e▹ₜP : {Γₜ : Cont}{Γₚ : Conp Γₜ} → mConp {Γₜ ▹t⁰} (Γₚ [ wkₜσₜ idₜ ]c) ≡ FFOL._▹ₜ M (mConp Γₚ)
|
||||
e▹ₜP {Γₜ = Γₜ} {Γₚ = ◇p} = e▹ₜT {Γₜ = Γₜ}
|
||||
e▹ₜP {Γₚ = Γₚ ▹p⁰ A} = {!!}
|
||||
e▹ₜ : {Γ : Con} → mCon (con (Con.t Γ ▹t⁰) (Con.p Γ [ wkₜσₜ idₜ ]c)) ≡ FFOL._▹ₜ M (mCon Γ)
|
||||
e▹ₜ {Γ} = e▹ₜP {Γₜ = Con.t Γ} {Γₚ = Con.p Γ}
|
||||
|
||||
mForT⇒ : {Γₜ : Cont}{A B : For Γₜ} → mForT {Γₜ} (A ⇒ B) ≡ FFOL._⇒_ M (mForT {Γₜ} A) (mForT {Γₜ} B)
|
||||
mForT⇒ = refl
|
||||
mForP⇒ : {Γₜ : Cont}{Γₚ : Conp Γₜ}{A B : For Γₜ} → mForP {Γₜ} {Γₚ} (A ⇒ B) ≡ FFOL._⇒_ M (mForP {Γₜ} {Γₚ} A) (mForP {Γₜ} {Γₚ} B)
|
||||
mForP⇒ {Γₜ} {Γₚ = ◇p}{A}{B} = mForT⇒ {Γₜ}{A}{B}
|
||||
mForP⇒ {Γₚ = Γₚ ▹p⁰ C}{A}{B} = ≡tran (cong (λ X → (M FFOL.[ X ]f) _) (mForP⇒ {Γₚ = Γₚ})) (FFOL.[]f-⇒ M {F = mForP {Γₚ = Γₚ} A} {G = mForP {Γₚ = Γₚ} B} {σ = (FFOL.πₚ¹ M (FFOL.id M))})
|
||||
mFor⇒ : {Γ : Con}{A B : For (Con.t Γ)} → mFor {Γ} (A ⇒ B) ≡ FFOL._⇒_ M (mFor {Γ} A) (mFor {Γ} B)
|
||||
mFor⇒ {Γ} = mForP⇒ {Con.t Γ} {Con.p Γ}
|
||||
|
||||
mForT∀∀ : {Γₜ : Cont}{A : For (Γₜ ▹t⁰)} → mForT {Γₜ} (∀∀ A) ≡ FFOL.∀∀ M (mForT {Γₜ ▹t⁰} A)
|
||||
mForT∀∀ = refl
|
||||
mForP∀∀ : {Γₜ : Cont}{Γₚ : Conp Γₜ}{A : For (Γₜ ▹t⁰)} → mForP {Γₜ} {Γₚ} (∀∀ A) ≡ FFOL.∀∀ M (subst (FFOL.For M) (e▹ₜP {Γₜ} {Γₚ}) (mForP {Γₜ ▹t⁰} {Γₚ ▹tp} A))
|
||||
-- mFor∀∀ : {Γ : Con}{A : For ((Con.t Γ) ▹t⁰)} → mFor {Γ} (∀∀ A) ≡ FFOL.∀∀ M (mFor {Γ ▹t} A)
|
||||
|
||||
--mForL : {Γ : Con}{A : For (Con.t Γ ▹t⁰)}{t : Tm (Con.t Γ)} → FFOL._[_]f M (mFor {Γ = {!Γ ▹t!}} A) (FFOL._,ₜ_ M (FFOL.id M) (mTm {Γ = Γ} t)) ≡ mFor {Γ = Γ} (A [ idₜ ,ₜ t ]f)
|
||||
|
||||
m⊢ : {Γ : Con} {A : For (Con.t Γ)} → Pf (Con.t Γ) (Con.p Γ) A → FFOL._⊢_ M (mCon Γ) (mFor {Γ = Γ} A)
|
||||
m⊢ (var pvzero) = FFOL.πₚ² M (FFOL.id M)
|
||||
m⊢ (var (pvnext pv)) = FFOL._[_]p M (m⊢ (var pv)) (FFOL.πₚ¹ M (FFOL.id M))
|
||||
m⊢ {Γ} {B} (app {A = A} pf pf') = FFOL.app M (substP (FFOL._⊢_ M _) (mFor⇒ {Γ}{A}{B}) (m⊢ pf)) (m⊢ pf')
|
||||
m⊢ {Γ} {A ⇒ B} (lam pf) = substP (FFOL._⊢_ M _) (≡sym (mFor⇒ {Γ}{A}{B})) (FFOL.lam M (m⊢ pf))
|
||||
m⊢ {Γ} (p∀∀e {A = A} {t = t} pf) = substP (FFOL._⊢_ M _) {!!} (FFOL.∀e M {F = mFor {{!!}} A} (substP (FFOL._⊢_ M _) {!!} (m⊢ pf)) {t = mTm {Γ} t})
|
||||
m⊢ {Γ} (p∀∀i {A = A} pf) = substP (FFOL._⊢_ M _) (≡sym mForP∀∀) (FFOL.∀i M (substP (λ Ξ → FFOL._⊢_ M Ξ (mFor A)) e▹ₜ (m⊢ pf)))
|
||||
|
||||
|
||||
mSubp : {Γₜ : Cont}{Δₚ Γₚ : Conp Γₜ} → Subp {Γₜ} Δₚ Γₚ → (FFOL.Sub M (mConp Δₚ) (mConp Γₚ))
|
||||
mSubp {Γₜ} {Γₚ = ◇p} σₚ = {!FFOL.ε M!}
|
||||
mSubp {Γₚ = Γₚ ▹p⁰ A} σₚ = FFOL._,ₚ_ M (mSubp (πₚ¹ σₚ)) {!m⊢ (πₚ² σₚ)!}
|
||||
|
||||
|
||||
mSub : {Δ : Con}{Γ : Con} → Sub Δ Γ → (FFOL.Sub M (mCon Δ) (mCon Γ))
|
||||
mSub {Δ}{Γ} σ = FFOL._∘_ M (subst (FFOL.Sub M (mCont (Con.t Δ))) {!!} (mSubt (Sub.t σ))) ({!mSubp (Sub.p σ)!})
|
||||
|
||||
|
||||
e▹ₚ : {Γ : Con}{A : For (Con.t Γ)} → mCon (Γ ▹p A) ≡ FFOL._▹ₚ_ M (mCon Γ) (mFor {Γ} A)
|
||||
e[]f : {Γ Δ : Con}{A : For (Con.t Γ)}{σ : Sub Δ Γ} → mFor {Δ} (A [ Sub.t σ ]f) ≡ FFOL._[_]f M (mFor {Γ} A) (mSub σ)
|
||||
|
||||
|
||||
{-
|
||||
e▹ₜ {con Γₜ ◇p} = refl
|
||||
e▹ₜ {con Γₜ (Γₚ ▹p⁰ A)} = ≡tran²
|
||||
(cong₂' (FFOL._▹ₚ_ M) (e▹ₜ {con Γₜ Γₚ}) (cong (subst (FFOL.For M) (e▹ₜ {Γ = con Γₜ Γₚ})) (e[]f {A = A}{σ = πₜ¹* id})))
|
||||
(substP (λ X → (M FFOL.▹ₚ (M FFOL.▹ₜ) (mCon (con Γₜ Γₚ))) X ≡ (M FFOL.▹ₜ) ((M FFOL.▹ₚ mCon (con Γₜ Γₚ)) (mFor A)))
|
||||
(≡tran
|
||||
(coeshift {!!})
|
||||
(cong (λ X → subst (FFOL.For M) _ (FFOL._[_]f M (mFor A) (mSub (sub (wkₜσₜ idₜ) X)))) (≡sym (coecoe-coe {eq1 = {!!}} {x = idₚ {Δₚ = Γₚ}}))))
|
||||
{!!})
|
||||
(cong (M FFOL.▹ₜ) (≡sym (e▹ₚ {con Γₜ Γₚ})))
|
||||
-- substP (λ X → FFOL._▹ₚ_ M X (mFor {Γ = ?} (A [ wkₜσₜ idₜ ]f)) ≡ (FFOL._▹ₜ M (mCon (con Γₜ (Γₚ ▹p⁰ A))))) (≡sym (e▹ₜ {Γ = con Γₜ Γₚ})) ?
|
||||
-}
|
||||
|
||||
|
||||
e[]f = {!!}
|
||||
e▹ₚ = {!!}
|
||||
|
||||
|
||||
{-
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
e∘ : {Γ Δ Ξ : Con}{δ : Sub Δ Ξ}{σ : Sub Γ Δ} → mSub (δ ∘ σ) ≡ FFOL._∘_ M (mSub δ) (mSub σ)
|
||||
e∘ = {!!}
|
||||
eid : {Γ : Con} → mSub (id {Γ}) ≡ FFOL.id M {mCon Γ}
|
||||
eid = {!!}
|
||||
e◇ : mCon ◇ ≡ FFOL.◇ M
|
||||
e◇ = {!!}
|
||||
eε : {Γ : Con} → mSub (sub (εₜ {Con.t Γ}) (εₚ {Con.t Γ} {Con.p Γ})) ≡ subst (FFOL.Sub M (mCon Γ)) (≡sym e◇) (FFOL.ε M {mCon Γ})
|
||||
eε = {!!}
|
||||
e[]t : {Γ Δ : Con}{t : Tm (Con.t Γ)}{σ : Sub Δ Γ} → mTm (t [ Sub.t σ ]t) ≡ FFOL._[_]t M (mTm t) (mSub σ)
|
||||
e[]t = {!!}
|
||||
eπₜ¹ : {Γ Δ : Con}{σ : Sub Δ (Γ ▹t)} → mSub (πₜ¹* σ) ≡ FFOL.πₜ¹ M (subst (FFOL.Sub M (mCon Δ)) e▹ₜ (mSub σ))
|
||||
eπₜ¹ = {!!}
|
||||
eπₜ² : {Γ Δ : Con}{σ : Sub Δ (Γ ▹t)} → mTm (πₜ²* σ) ≡ FFOL.πₜ² M (subst (FFOL.Sub M (mCon Δ)) e▹ₜ (mSub σ))
|
||||
eπₜ² = {!!}
|
||||
e,ₜ : {Γ Δ : Con}{σ : Sub Δ Γ}{t : Tm (Con.t Δ)} → mSub (σ ,ₜ* t) ≡ subst (FFOL.Sub M (mCon Δ)) (≡sym e▹ₜ) (FFOL._,ₜ_ M (mSub σ) (mTm t))
|
||||
e,ₜ = {!!}
|
||||
-- Proofs are in prop, so no equation needed
|
||||
--[]p : {Γ Δ : Con}{A : For Γ}{pf : FFOL._⊢_ S Γ A}{σ : FFOL.Sub S Δ Γ} → m⊢ (FFOL._[_]p S pf σ) ≡ FFOL._[_]p M (m⊢ pf) (mSub σ)
|
||||
e▹ₚ = {!!}
|
||||
eπₚ¹ : {Γ Δ : Con}{A : For (Con.t Γ)}{σ : Sub Δ (Γ ▹p A)} → mSub (πₚ¹* σ) ≡ FFOL.πₚ¹ M (subst (FFOL.Sub M (mCon Δ)) e▹ₚ (mSub σ))
|
||||
eπₚ¹ = {!!}
|
||||
--πₚ² : {Γ Δ : Con}{A : For Γ}{σ : Sub Δ (Γ ▹p A)} → m⊢ (πₚ²* σ) ≡ FFOL.πₚ¹ M (subst (FFOL.Sub M (mCon Δ)) e▹ₚ (mSub σ))
|
||||
e,ₚ : {Γ Δ : Con}{A : For (Con.t Γ)}{σ : Sub Δ Γ}{pf : Pf (Con.t Δ) (Con.p Δ) (A [ Sub.t σ ]f)}
|
||||
→ mSub (σ ,ₚ* pf) ≡ subst (FFOL.Sub M (mCon Δ)) (≡sym e▹ₚ) (FFOL._,ₚ_ M (mSub σ) (substP (FFOL._⊢_ M (mCon Δ)) e[]f (m⊢ pf)))
|
||||
e,ₚ = {!!}
|
||||
eR : {Γ : Con}{t u : Tm (Con.t Γ)} → mFor (R t u) ≡ FFOL.R M (mTm t) (mTm u)
|
||||
eR = {!!}
|
||||
e⇒ : {Γ : Con}{A B : For (Con.t Γ)} → mFor (A ⇒ B) ≡ FFOL._⇒_ M (mFor A) (mFor B)
|
||||
e⇒ = {!!}
|
||||
e∀∀ : {Γ : Con}{A : For ((Con.t Γ) ▹t⁰)} → mFor (∀∀ A) ≡ FFOL.∀∀ M (subst (FFOL.For M) e▹ₜ (mFor A))
|
||||
e∀∀ = {!!}
|
||||
-}
|
||||
m : Mapping ffol M
|
||||
m = record { mCon = mCon ; mSub = mSub ; mTm = λ {Γ} t → mTm {Γ} t ; mFor = λ {Γ} A → mFor {Γ} A ; m⊢ = m⊢ }
|
||||
|
||||
--mor : (M : FFOL) → Morphism ffol M
|
||||
--mor M = record {InitialMorphism M}
|
||||
|
||||
-}
|
||||
|
||||
\end{code}
|
||||
@ -1,15 +1,14 @@
|
||||
{-# OPTIONS --prop #-}
|
||||
|
||||
open import Agda.Builtin.Nat
|
||||
|
||||
module InfinitaryFirstOrderLogic (Term : Set) (R : Nat → Set) where
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module IFOL (Term : Set) (R : Nat → Set) where
|
||||
|
||||
open import ListUtil
|
||||
|
||||
data Args : Nat → Set where
|
||||
zero : Args 0
|
||||
next : {n : Nat} → Args n → Term → Args (suc n)
|
||||
next : {n : Nat} → Args n → Term → Args (succ n)
|
||||
|
||||
data Form : Set where
|
||||
Rel : {n : Nat} → R n → (Args n) → Form
|
||||
120
IFOL2.lagda
Normal file
120
IFOL2.lagda
Normal file
@ -0,0 +1,120 @@
|
||||
\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module IFOL2 where
|
||||
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
|
||||
variable
|
||||
ℓ¹ ℓ² ℓ³ ℓ⁴ : Level
|
||||
ℓ¹' ℓ²' ℓ³' ℓ⁴' : Level
|
||||
|
||||
record IFOL (TM : Set) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴)) where
|
||||
infixr 10 _∘_
|
||||
field
|
||||
|
||||
-- We first make the base category with its terminal object
|
||||
Con : Set ℓ¹
|
||||
Sub : Con → Con → Prop ℓ² -- It makes a category
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
id : {Γ : Con} → Sub Γ Γ
|
||||
◇ : Con -- The terminal object of the category
|
||||
ε : {Γ : Con} → Sub Γ ◇ -- The morphism from any object to the terminal
|
||||
|
||||
-- Functor Con → Set called For
|
||||
For : Con → Set ℓ³
|
||||
_[_]f : {Γ Δ : Con} → For Γ → Sub Δ Γ → For Δ -- Action on morphisms
|
||||
[]f-id : {Γ : Con} → {F : For Γ} → F [ id {Γ} ]f ≡ F
|
||||
[]f-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ}
|
||||
→ F [ β ∘ α ]f ≡ (F [ β ]f) [ α ]f
|
||||
|
||||
-- Functor Con × For → Prop called Pf or ⊢
|
||||
Pf : (Γ : Con) → For Γ → Prop ℓ⁴
|
||||
-- Action on morphisms
|
||||
_[_]p : {Γ Δ : Con} → {F : For Γ} → Pf Γ F → (σ : Sub Δ Γ) → Pf Δ (F [ σ ]f)
|
||||
-- Equalities below are useless because Γ ⊢ F is in prop
|
||||
-- []p-id : {Γ : Con} → {F : For Γ} → {prf : Γ ⊢ F}
|
||||
-- → prf [ id {Γ} ]p ≡ prf
|
||||
-- []p-∘ : {Γ Δ Ξ : Con}{α : Sub Ξ Δ}{β : Sub Δ Γ}{F : For Γ}{prf : Γ ⊢ F}
|
||||
-- → prf [ α ∘ β ]p ≡ (prf [ β ]p) [ α ]p
|
||||
|
||||
-- → Prop⁺
|
||||
_▹ₚ_ : (Γ : Con) → For Γ → Con
|
||||
πₚ¹ : {Γ Δ : Con}{F : For Γ} → Sub Δ (Γ ▹ₚ F) → Sub Δ Γ
|
||||
πₚ² : {Γ Δ : Con}{F : For Γ} → (σ : Sub Δ (Γ ▹ₚ F)) → Pf Δ (F [ πₚ¹ σ ]f)
|
||||
_,ₚ_ : {Γ Δ : Con}{F : For Γ} → (σ : Sub Δ Γ) → Pf Δ (F [ σ ]f) → Sub Δ (Γ ▹ₚ F)
|
||||
-- All equalities are useless because Sub and Pf are in prop
|
||||
|
||||
|
||||
{-- FORMULAE CONSTRUCTORS --}
|
||||
-- Formulas with relation on terms
|
||||
R : {Γ : Con} → (t u : TM) → For Γ
|
||||
R[] : {Γ Δ : Con} → {σ : Sub Δ Γ} → {t u : TM}
|
||||
→ (R t u) [ σ ]f ≡ R t u
|
||||
|
||||
-- Implication
|
||||
_⇒_ : {Γ : Con} → For Γ → For Γ → For Γ
|
||||
[]f-⇒ : {Γ Δ : Con} → {F G : For Γ} → {σ : Sub Δ Γ}
|
||||
→ (F ⇒ G) [ σ ]f ≡ (F [ σ ]f) ⇒ (G [ σ ]f)
|
||||
|
||||
--# Forall
|
||||
∀∀ : {Γ : Con} → (TM → For Γ) → For Γ
|
||||
[]f-∀∀ : {Γ Δ : Con} → {F : TM → For Γ} → {σ : Sub Δ Γ}
|
||||
→ (∀∀ F) [ σ ]f ≡ (∀∀ (λ t → (F t) [ σ ]f))
|
||||
|
||||
--#
|
||||
{-- PROOFS CONSTRUCTORS --}
|
||||
-- Again, we don't have to write the _[_]p equalities as Proofs are in Prop
|
||||
|
||||
-- Lam & App
|
||||
lam : {Γ : Con}{F G : For Γ} → Pf (Γ ▹ₚ F) (G [ πₚ¹ id ]f) → Pf Γ (F ⇒ G)
|
||||
app : {Γ : Con}{F G : For Γ} → Pf Γ (F ⇒ G) → Pf Γ F → Pf Γ G
|
||||
|
||||
--# ∀i and ∀e
|
||||
∀i : {Γ : Con}{A : TM → For Γ} → ((t : TM) → Pf Γ (A t)) → Pf Γ (∀∀ A)
|
||||
∀e : {Γ : Con}{A : TM → For Γ} → Pf Γ (∀∀ A) → (t : TM) → Pf Γ (A t)
|
||||
--#
|
||||
|
||||
record Mapping (TM : Set) (S : IFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} TM) (D : IFOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'} TM) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ¹' ⊔ ℓ²' ⊔ ℓ³' ⊔ ℓ⁴')) where
|
||||
field
|
||||
|
||||
-- We first make the base category with its final object
|
||||
mCon : (IFOL.Con S) → (IFOL.Con D)
|
||||
mSub : {Δ : (IFOL.Con S)}{Γ : (IFOL.Con S)} → (IFOL.Sub S Δ Γ) → (IFOL.Sub D (mCon Δ) (mCon Γ))
|
||||
mFor : {Γ : (IFOL.Con S)} → (IFOL.For S Γ) → (IFOL.For D (mCon Γ))
|
||||
mPf : {Γ : (IFOL.Con S)} {A : IFOL.For S Γ} → IFOL.Pf S Γ A → IFOL.Pf D (mCon Γ) (mFor A)
|
||||
|
||||
|
||||
record Morphism (TM : Set)(S : IFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} TM) (D : IFOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'} TM) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ¹' ⊔ ℓ²' ⊔ ℓ³' ⊔ ℓ⁴')) where
|
||||
field m : Mapping TM S D
|
||||
mCon = Mapping.mCon m
|
||||
mSub = Mapping.mSub m
|
||||
mFor = Mapping.mFor m
|
||||
mPf = Mapping.mPf m
|
||||
field
|
||||
e◇ : mCon (IFOL.◇ S) ≡ IFOL.◇ D
|
||||
e[]f : {Γ Δ : IFOL.Con S}{A : IFOL.For S Γ}{σ : IFOL.Sub S Δ Γ} → mFor (IFOL._[_]f S A σ) ≡ IFOL._[_]f D (mFor A) (mSub σ)
|
||||
-- Proofs are in prop, so some equations are not needed
|
||||
--[]p : {Γ Δ : IFOL.Con S}{A : IFOL.For S Γ}{pf : IFOL._⊢_ S Γ A}{σ : IFOL.Sub S Δ Γ} → mPf (IFOL._[_]p S pf σ) ≡ IFOL._[_]p D (mPf pf) (mSub σ)
|
||||
e▹ₚ : {Γ : IFOL.Con S}{A : IFOL.For S Γ} → mCon (IFOL._▹ₚ_ S Γ A) ≡ IFOL._▹ₚ_ D (mCon Γ) (mFor A)
|
||||
--πₚ² : {Γ Δ : IFOL.Con S}{A : IFOL.For S Γ}{σ : IFOL.Sub S Δ (IFOL._▹ₚ_ S Γ A)} → mPf (IFOL.πₚ² S σ) ≡ IFOL.πₚ¹ D (subst (IFOL.Sub D (mCon Δ)) ▹ₚ (mSub σ))
|
||||
eR : {Γ : IFOL.Con S}{t u : TM} → mFor {Γ} (IFOL.R S t u) ≡ IFOL.R D t u
|
||||
e⇒ : {Γ : IFOL.Con S}{A B : IFOL.For S Γ} → mFor (IFOL._⇒_ S A B) ≡ IFOL._⇒_ D (mFor A) (mFor B)
|
||||
e∀∀ : {Γ : IFOL.Con S}{A : TM → IFOL.For S Γ} → mFor (IFOL.∀∀ S A) ≡ IFOL.∀∀ D (λ t → (mFor (A t)))
|
||||
-- No equation needed for lam, app, ∀i, ∀e as their output are in prop
|
||||
|
||||
record TrNat {TM : Set}{S : IFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} TM} {D : IFOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'} TM} (a : Mapping TM S D) (b : Mapping TM S D) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ¹' ⊔ ℓ²' ⊔ ℓ³' ⊔ ℓ⁴')) where
|
||||
field
|
||||
f : (Γ : IFOL.Con S) → IFOL.Sub D (Mapping.mCon a Γ) (Mapping.mCon b Γ)
|
||||
-- Unneeded because Sub are in prop
|
||||
--eq : (Γ Δ : IFOL.Con S)(σ : IFOL.Sub S Γ Δ) → (IFOL._∘_ D (f Δ) (Mapping.mSub a σ)) ≡ (IFOL._∘_ D (Mapping.mSub b σ) (f Γ))
|
||||
|
||||
_∘TrNat_ : {TM : Set}{S : IFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} TM}{D : IFOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'} TM}{a b c : Mapping TM S D} → TrNat a b → TrNat b c → TrNat a c
|
||||
_∘TrNat_ {D = D} α β = record { f = λ Γ → IFOL._∘_ D (TrNat.f β Γ) (TrNat.f α Γ) }
|
||||
|
||||
idTrNat : {TM : Set}{S : IFOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴} TM}{D : IFOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'} TM}{a : Mapping TM S D} → TrNat a a
|
||||
idTrNat {D = D} = record { f = λ Γ → IFOL.id D }
|
||||
\end{code}
|
||||
174
IFOLCompleteness.lagda
Normal file
174
IFOLCompleteness.lagda
Normal file
@ -0,0 +1,174 @@
|
||||
\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module IFOLCompleteness (TM : Set) where
|
||||
|
||||
open import Agda.Primitive
|
||||
open import IFOL2
|
||||
open import ListUtil
|
||||
|
||||
record Kripke : Set (lsuc (ℓ¹)) where
|
||||
field
|
||||
World : Set ℓ¹
|
||||
_-w->_ : World → World → Prop ℓ¹ -- arrows
|
||||
-w->id : {w : World} → w -w-> w -- id arrow
|
||||
_∘-w->_ : {w w' w'' : World} → w -w-> w' → w' -w-> w'' → w -w-> w'' -- arrow composition
|
||||
|
||||
REL : World → TM → TM → Prop ℓ¹
|
||||
REL≤ : {t u : TM} {w w' : World} → w -w-> w' → REL w t u → REL w' t u
|
||||
|
||||
infixr 10 _∘_
|
||||
|
||||
Con : Set (lsuc ℓ¹)
|
||||
Con = (World → Prop ℓ¹) ×'' (λ Γ → {w w' : World} → (w -w-> w')→ Γ w → Γ w')
|
||||
Sub : Con → Con → Prop ℓ¹
|
||||
Sub Δ Γ = (w : World) → (proj×''₁ Δ) w → (proj×''₁ Γ) w
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
α ∘ β = λ w γ → α w (β w γ)
|
||||
id : {Γ : Con} → Sub Γ Γ
|
||||
id = λ w γ → γ
|
||||
◇ : Con -- The initial object of the category
|
||||
◇ = (λ w → ⊤) ,×'' (λ _ _ → tt)
|
||||
ε : {Γ : Con} → Sub Γ ◇ -- The morphism from the initial to any object
|
||||
ε w Γ = tt
|
||||
|
||||
-- Functor Con → Set called For
|
||||
For : Set (lsuc ℓ¹)
|
||||
For = (World → Prop ℓ¹) ×'' (λ F → {w w' : World} → (w -w-> w')→ F w → F w')
|
||||
|
||||
-- Proofs
|
||||
Pf : (Γ : Con) → For → Prop ℓ¹
|
||||
Pf Γ F = ∀ w (γ : (proj×''₁ Γ) w) → (proj×''₁ F) w
|
||||
_[_]p : {Γ Δ : Con} → {F : For} → Pf Γ F → (σ : Sub Δ Γ) → Pf Δ F -- The functor's action on morphisms
|
||||
prf [ σ ]p = λ w → λ γ → prf w (σ w γ)
|
||||
-- Equalities below are useless because Γ ⊢ F is in prop
|
||||
-- []p-id : {Γ : Con} → {F : For Γ} → {prf : Γ ⊢ F} → prf [ id {Γ} ]p ≡ prf
|
||||
-- []p-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ} → {prf : Γ ⊢ F} → prf [ α ∘ β ]p ≡ (prf [ β ]p) [ α ]p
|
||||
|
||||
|
||||
-- → Prop⁺
|
||||
_▹ₚ_ : (Γ : Con) → For → Con
|
||||
Γ ▹ₚ F = (λ w → (proj×''₁ Γ) w ∧ (proj×''₁ F) w) ,×'' λ s γ → ⟨ proj×''₂ Γ s (proj₁ γ) , proj×''₂ F s (proj₂ γ) ⟩
|
||||
|
||||
πₚ¹ : {Γ Δ : Con} → {F : For} → Sub Δ (Γ ▹ₚ F) → Sub Δ Γ
|
||||
πₚ¹ σ w δ = proj₁ (σ w δ)
|
||||
πₚ² : {Γ Δ : Con} → {F : For} → (σ : Sub Δ (Γ ▹ₚ F)) → Pf Δ F
|
||||
πₚ² σ w δ = proj₂ (σ w δ)
|
||||
_,ₚ_ : {Γ Δ : Con} → {F : For} → (σ : Sub Δ Γ) → Pf Δ F → Sub Δ (Γ ▹ₚ F)
|
||||
(σ ,ₚ pf) w δ = ⟨ (σ w δ) , pf w δ ⟩
|
||||
|
||||
|
||||
-- Base relation formula
|
||||
R : TM → TM → For
|
||||
R t u = (λ w → REL w t u) ,×'' REL≤
|
||||
|
||||
-- Implication
|
||||
_⇒_ : For → For → For
|
||||
(F ⇒ G) = (λ w → {w' : World} → (s : w -w-> w') → ((proj×''₁ F) w') → ((proj×''₁ G) w')) ,×'' λ s f s' f' → f (s ∘-w-> s') f'
|
||||
|
||||
-- Forall
|
||||
∀∀ : (TM → For) → For
|
||||
(∀∀ F) = (λ w → {t : TM} → proj×''₁ (F t) w) ,×'' λ s h {t} → proj×''₂ (F t) s (h {t})
|
||||
|
||||
-- Lam & App
|
||||
lam : {Γ : Con} → {F : For} → {G : For} → Pf (Γ ▹ₚ F) G → Pf Γ (F ⇒ G)
|
||||
lam {Γ} pf w γ {w'} s x = pf w' ⟨ proj×''₂ Γ s γ , x ⟩
|
||||
--lam prf = λ w γ w' s h → prf w (γ , h)
|
||||
app : {Γ : Con} → {F G : For} → Pf Γ (F ⇒ G) → Pf Γ F → Pf Γ G
|
||||
app pf pf' w γ = pf w γ -w->id (pf' w γ)
|
||||
|
||||
-- ∀i and ∀e
|
||||
∀i : {Γ : Con} {A : TM → For} → ((t : TM) → Pf Γ (A t)) → Pf Γ (∀∀ A)
|
||||
∀i pf w γ {t} = pf t w γ
|
||||
∀e : {Γ : Con} {A : TM → For} → Pf Γ (∀∀ A) → (t : TM) → Pf Γ (A t)
|
||||
∀e pf t w γ = pf w γ
|
||||
-- Again, we don't write the _[_]p equalities as everything is in Prop
|
||||
|
||||
ifol : IFOL TM
|
||||
ifol = record
|
||||
{ Con = Con
|
||||
; Sub = Sub
|
||||
; _∘_ = λ {Γ}{Δ}{Ξ} σ δ → _∘_ {Γ}{Δ}{Ξ} σ δ
|
||||
; id = λ {Γ} → id {Γ}
|
||||
; ◇ = ◇
|
||||
; ε = λ {Γ} → ε {Γ}
|
||||
; For = λ Γ → For
|
||||
; _[_]f = λ A σ → A
|
||||
; []f-id = refl
|
||||
; []f-∘ = refl
|
||||
; Pf = Pf
|
||||
; _[_]p = λ {Γ}{Δ}{F} pf σ → _[_]p {Γ}{Δ}{F} pf σ
|
||||
; _▹ₚ_ = _▹ₚ_
|
||||
; πₚ¹ = λ {Γ}{Δ}{F}σ → πₚ¹ {Γ}{Δ}{F} σ
|
||||
; πₚ² = λ {Γ}{Δ}{F}σ → πₚ² {Γ}{Δ}{F} σ
|
||||
; _,ₚ_ = λ {Γ}{Δ}{F} σ pf → _,ₚ_ {Γ}{Δ}{F}σ pf
|
||||
; R = R
|
||||
; R[] = refl
|
||||
; _⇒_ = _⇒_
|
||||
; []f-⇒ = refl
|
||||
; ∀∀ = ∀∀
|
||||
; []f-∀∀ = refl
|
||||
; lam = λ {Γ}{F}{G} pf → lam {Γ}{F}{G} pf
|
||||
; app = λ {Γ}{F}{G} pf pf' → app {Γ}{F}{G} pf pf'
|
||||
; ∀i = λ {Γ}{A} F → ∀i {Γ}{A} F
|
||||
; ∀e = λ {Γ}{A} F t → ∀e {Γ}{A} F t
|
||||
}
|
||||
module U where
|
||||
|
||||
import IFOLInitial TM as I
|
||||
|
||||
U : Kripke
|
||||
U = record
|
||||
{ World = I.Con
|
||||
; _-w->_ = λ Γ Δ → I.Sub Δ Γ
|
||||
; -w->id = I.id
|
||||
; _∘-w->_ = λ σ σ' → σ I.∘ σ'
|
||||
; REL = λ Γ t u → I.Pf Γ (I.R t u)
|
||||
; REL≤ = λ σ pf → pf I.[ σ ]p
|
||||
}
|
||||
|
||||
open Kripke U
|
||||
|
||||
y : Mapping TM I.ifol ifol
|
||||
y = record
|
||||
{ mCon = λ Γ → (λ Δ → I.Sub Δ Γ) ,×'' λ σ δ → δ I.∘ σ
|
||||
; mSub = λ σ Ξ δ → σ I.∘ δ
|
||||
; mFor = λ A → (λ Ξ → I.Pf Ξ A) ,×'' λ σ pf → pf I.[ σ ]p
|
||||
; mPf = λ pf Ξ σ → pf I.[ σ ]p
|
||||
}
|
||||
m : Morphism TM I.ifol ifol
|
||||
m = I.InitialMorphism.mor ifol
|
||||
|
||||
q : (Γ : I.Con) → Sub (Morphism.mCon m Γ) (Mapping.mCon y Γ)
|
||||
u : (Γ : I.Con) → Sub (Mapping.mCon y Γ) (Morphism.mCon m Γ)
|
||||
|
||||
⟦_⟧c = Morphism.mCon m
|
||||
⟦_,_⟧f = λ A Γ → Morphism.mFor m {Γ} A
|
||||
|
||||
q⁰ : {F : I.For} → {Γ Γ₀ : I.Con} → proj×''₁ ⟦ F , Γ₀ ⟧f Γ → I.Pf Γ F
|
||||
u⁰ : {F : I.For} → {Γ Γ₀ : I.Con} → I.Pf Γ F → proj×''₁ ⟦ F , Γ₀ ⟧f Γ
|
||||
|
||||
q⁰ {I.R t v} {Γ} h = h
|
||||
q⁰ {I.∀∀ A} {Γ} h = I.∀i (λ t → q⁰ {A t} h)
|
||||
q⁰ {A I.⇒ B} {Γ} h = I.lam (q⁰ {B} (h (I.πₚ¹ I.id) (u⁰ {A} (I.var I.pvzero))))
|
||||
u⁰ {I.R t v} {Γ} pf = pf
|
||||
u⁰ {I.∀∀ A} {Γ} pf {t} = u⁰ {A t} (I.∀e pf t)
|
||||
u⁰ {A I.⇒ B} {Γ} pf iq hF = u⁰ {B} (I.app (pf I.[ iq ]p) (q⁰ hF) )
|
||||
|
||||
|
||||
q I.◇ w γ = I.ε
|
||||
q (Γ I.▹ₚ A) w γ = (q Γ w (proj₁ γ) I.,ₚ q⁰ (proj₂ γ))
|
||||
u I.◇ w σ = tt
|
||||
u (Γ I.▹ₚ A) w σ = ⟨ (u Γ w (I.πₚ¹ σ)) , u⁰ (I.πₚ² σ) ⟩
|
||||
|
||||
ηq : TrNat (Morphism.m m) y
|
||||
ηq = record { f = q }
|
||||
ηu : TrNat y (Morphism.m m)
|
||||
ηu = record { f = u }
|
||||
|
||||
eq : ηu ∘TrNat ηq ≡ idTrNat
|
||||
eq = refl
|
||||
|
||||
\end{code}
|
||||
200
IFOLInitial.lagda
Normal file
200
IFOLInitial.lagda
Normal file
@ -0,0 +1,200 @@
|
||||
\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module IFOLInitial (TM : Set) where
|
||||
|
||||
open import IFOL2
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
|
||||
--#
|
||||
data For : Set where
|
||||
R : TM → TM → For
|
||||
_⇒_ : For → For → For
|
||||
∀∀ : (TM → For) → For
|
||||
--#
|
||||
|
||||
data Con : Set where
|
||||
◇ : Con
|
||||
_▹ₚ_ : Con → For → Con
|
||||
|
||||
variable
|
||||
Γ Δ Ξ : Con
|
||||
A B : For
|
||||
|
||||
data PfVar : Con → For → Prop where
|
||||
pvzero : PfVar (Γ ▹ₚ A) A
|
||||
pvnext : PfVar Γ A → PfVar (Γ ▹ₚ B) A
|
||||
--#
|
||||
data Pf : Con → For → Prop where
|
||||
var : PfVar Γ A → Pf Γ A
|
||||
lam : Pf (Γ ▹ₚ A) B → Pf Γ (A ⇒ B)
|
||||
app : Pf Γ (A ⇒ B) → Pf Γ A → Pf Γ B
|
||||
∀i : {A : TM → For} → ((t : TM) → Pf Γ (A t)) → Pf Γ (∀∀ A)
|
||||
∀e : {A : TM → For} → Pf Γ (∀∀ A) → (t : TM) → Pf Γ (A t)
|
||||
--#
|
||||
|
||||
|
||||
data Ren : Con → Con → Prop where
|
||||
ε : Ren Γ ◇
|
||||
_,ₚR_ : Ren Δ Γ → PfVar Δ A → Ren Δ (Γ ▹ₚ A)
|
||||
|
||||
rightR : Ren Δ Γ → Ren (Δ ▹ₚ A) Γ
|
||||
rightR ε = ε
|
||||
rightR (σ ,ₚR pv) = (rightR σ) ,ₚR (pvnext pv)
|
||||
|
||||
idR : Ren Γ Γ
|
||||
idR {◇} = ε
|
||||
idR {Γ ▹ₚ A} = (rightR (idR {Γ})) ,ₚR pvzero
|
||||
|
||||
data Sub : Con → Con → Prop where
|
||||
ε : Sub Γ ◇
|
||||
_,ₚ_ : Sub Δ Γ → Pf Δ A → Sub Δ (Γ ▹ₚ A)
|
||||
|
||||
πₚ¹ : Sub Δ (Γ ▹ₚ A) → Sub Δ Γ
|
||||
πₚ² : Sub Δ (Γ ▹ₚ A) → Pf Δ A
|
||||
πₚ¹ (σ ,ₚ pf) = σ
|
||||
πₚ² (σ ,ₚ pf) = pf
|
||||
|
||||
SubR : Ren Γ Δ → Sub Γ Δ
|
||||
SubR ε = ε
|
||||
SubR (σ ,ₚR pv) = SubR σ ,ₚ var pv
|
||||
|
||||
id : Sub Γ Γ
|
||||
id = SubR idR
|
||||
|
||||
_[_]pvr : PfVar Γ A → Ren Δ Γ → PfVar Δ A
|
||||
pvzero [ _ ,ₚR pv ]pvr = pv
|
||||
pvnext pv [ σ ,ₚR _ ]pvr = pv [ σ ]pvr
|
||||
_[_]pr : Pf Γ A → Ren Δ Γ → Pf Δ A
|
||||
var pv [ σ ]pr = var (pv [ σ ]pvr)
|
||||
lam pf [ σ ]pr = lam (pf [ (rightR σ) ,ₚR pvzero ]pr)
|
||||
app pf pf' [ σ ]pr = app (pf [ σ ]pr) (pf' [ σ ]pr)
|
||||
∀i fpf [ σ ]pr = ∀i (λ t → (fpf t) [ σ ]pr)
|
||||
∀e pf t [ σ ]pr = ∀e (pf [ σ ]pr) t
|
||||
|
||||
wkSub : Sub Δ Γ → Sub (Δ ▹ₚ A) Γ
|
||||
wkSub ε = ε
|
||||
wkSub (σ ,ₚ pf) = (wkSub σ) ,ₚ (pf [ rightR idR ]pr)
|
||||
|
||||
_[_]p : Pf Γ A → Sub Δ Γ → Pf Δ A
|
||||
var pvzero [ _ ,ₚ pf ]p = pf
|
||||
var (pvnext pv) [ σ ,ₚ _ ]p = var pv [ σ ]p
|
||||
lam pf [ σ ]p = lam (pf [ wkSub σ ,ₚ var pvzero ]p)
|
||||
app pf pf' [ σ ]p = app (pf [ σ ]p) (pf' [ σ ]p)
|
||||
∀i fpf [ σ ]p = ∀i (λ t → (fpf t) [ σ ]p)
|
||||
∀e pf t [ σ ]p = ∀e (pf [ σ ]p) t
|
||||
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
ε ∘ β = ε
|
||||
(α ,ₚ pf) ∘ β = (α ∘ β) ,ₚ (pf [ β ]p)
|
||||
|
||||
|
||||
ifol : IFOL TM
|
||||
ifol = record
|
||||
{ Con = Con
|
||||
; Sub = Sub
|
||||
; _∘_ = _∘_
|
||||
; id = id
|
||||
; ◇ = ◇
|
||||
; ε = ε
|
||||
; For = λ Γ → For
|
||||
; _[_]f = λ A σ → A
|
||||
; []f-id = refl
|
||||
; []f-∘ = refl
|
||||
; Pf = Pf
|
||||
; _[_]p = _[_]p
|
||||
; _▹ₚ_ = _▹ₚ_
|
||||
; πₚ¹ = πₚ¹
|
||||
; πₚ² = πₚ²
|
||||
; _,ₚ_ = _,ₚ_
|
||||
; R = R
|
||||
; _⇒_ = _⇒_
|
||||
; ∀∀ = ∀∀
|
||||
; R[] = refl
|
||||
; []f-⇒ = refl
|
||||
; []f-∀∀ = refl
|
||||
; lam = lam
|
||||
; app = app
|
||||
; ∀i = ∀i
|
||||
; ∀e = ∀e
|
||||
}
|
||||
|
||||
module InitialMorphism (M : IFOL {ℓ¹}{ℓ²}{ℓ³}{ℓ⁴} TM) where
|
||||
|
||||
mCon : Con → (IFOL.Con M)
|
||||
mFor : {Γ : Con} → For → (IFOL.For M (mCon Γ))
|
||||
|
||||
mCon ◇ = IFOL.◇ M
|
||||
mCon (Γ ▹ₚ A) = IFOL._▹ₚ_ M (mCon Γ) (mFor {Γ} A)
|
||||
mFor {Γ} (R t u) = IFOL.R M t u
|
||||
mFor {Γ} (A ⇒ B) = IFOL._⇒_ M (mFor {Γ} A) (mFor {Γ} B)
|
||||
mFor {Γ} (∀∀ A) = IFOL.∀∀ M (λ t → mFor {Γ} (A t))
|
||||
|
||||
|
||||
mSub : {Δ : Con}{Γ : Con} → Sub Δ Γ → (IFOL.Sub M (mCon Δ) (mCon Γ))
|
||||
mPf : {Γ : Con} {A : For} → Pf Γ A → IFOL.Pf M (mCon Γ) (mFor {Γ} A)
|
||||
|
||||
e[]f⁰ : {Γ : Con}{A B : For} → mFor {Γ ▹ₚ B} A ≡ IFOL._[_]f M (mFor {Γ} A) (IFOL.πₚ¹ M (IFOL.id M))
|
||||
e[]f⁰ {A = R t u} = ≡sym (IFOL.R[] M)
|
||||
e[]f⁰ {A = A ⇒ B} = ≡sym (≡tran ( IFOL.[]f-⇒ M) (cong₂ (IFOL._⇒_ M) (≡sym (e[]f⁰ {A = A})) (≡sym (e[]f⁰ {A = B}))))
|
||||
e[]f⁰ {Γ}{A = ∀∀ A} = ≡sym (≡tran (IFOL.[]f-∀∀ M {F = λ t → mFor {Γ} (A t)}) (cong (IFOL.∀∀ M) (≡fun (λ t → ≡sym (e[]f⁰ {Γ} {A = A t})))))
|
||||
|
||||
e[]f : {Γ Δ : Con}{A : For}{σ : Sub Δ Γ} → mFor {Δ} A ≡ IFOL._[_]f M (mFor {Γ} A) (mSub σ)
|
||||
e[]f {A = R t u} {σ} = ≡sym (IFOL.R[] M)
|
||||
e[]f {A = A ⇒ B} {σ} = ≡sym (≡tran ( IFOL.[]f-⇒ M) (cong₂ (IFOL._⇒_ M) (≡sym (e[]f {A = A} {σ})) (≡sym (e[]f {A = B} {σ}))))
|
||||
e[]f {Γ}{A = ∀∀ A} {σ} = ≡sym (≡tran (IFOL.[]f-∀∀ M {F = λ t → mFor {Γ} (A t)}) (cong (IFOL.∀∀ M) (≡fun (λ t → ≡sym (e[]f {Γ} {A = A t} {σ})))))
|
||||
|
||||
mPf {A = A} (var (pvzero {Γ})) = substP (IFOL.Pf M _) (≡sym (e[]f⁰ {Γ} {A} {A})) (IFOL.πₚ² M (IFOL.id M))
|
||||
mPf {A = A} (var (pvnext {Γ} {B = B} pv)) = substP (IFOL.Pf M _) (≡sym (e[]f⁰ {Γ} {A} {B})) (IFOL._[_]p M (mPf (var pv)) (IFOL.πₚ¹ M (IFOL.id M)))
|
||||
mPf {Γ} (lam {A = A} {B} pf) = IFOL.lam M (substP (IFOL.Pf M _) (e[]f⁰ {Γ} {B} {A}) (mPf pf))
|
||||
mPf (app pf pf') = IFOL.app M (mPf pf) (mPf pf')
|
||||
mPf (∀i pf) = IFOL.∀i M (λ t → mPf (pf t))
|
||||
mPf (∀e pf t) = IFOL.∀e M (mPf pf) t
|
||||
|
||||
mSub ε = IFOL.ε M
|
||||
mSub (_,ₚ_ {Δ} {Γ = Γ} {A} σ pf) = IFOL._,ₚ_ M (mSub σ) (substP (IFOL.Pf M _) (e[]f {Γ} {Δ} {A} {σ}) (mPf pf))
|
||||
|
||||
mor : Morphism TM ifol M
|
||||
mor = record {
|
||||
m = record {
|
||||
mCon = mCon
|
||||
; mSub = mSub
|
||||
; mFor = λ {Γ} A → mFor {Γ} A
|
||||
; mPf = mPf
|
||||
}
|
||||
; e◇ = refl
|
||||
; e▹ₚ = refl
|
||||
; e[]f = λ {Γ}{Δ}{A}{σ} → e[]f {Γ}{Δ}{A}{σ}
|
||||
; eR = refl
|
||||
; e∀∀ = refl
|
||||
; e⇒ = refl
|
||||
}
|
||||
|
||||
module InitialMorphismUniqueness {M : IFOL {lzero} {lzero} {lzero} {lzero} TM} {m : Morphism TM ifol M} where
|
||||
|
||||
open InitialMorphism M
|
||||
mCon≡ : {Γ : Con} → mCon Γ ≡ (Morphism.mCon m Γ)
|
||||
mFor≡ : {Γ : Con} {A : For} → mFor {Γ} A ≡ subst (IFOL.For M) (≡sym mCon≡) (Morphism.mFor m {Γ} A)
|
||||
|
||||
mCon≡ {◇} = ≡sym (Morphism.e◇ m)
|
||||
mCon≡ {Γ ▹ₚ A} = ≡sym (≡tran (Morphism.e▹ₚ m) (cong₂' (IFOL._▹ₚ_ M) (≡sym mCon≡) (≡sym mFor≡)))
|
||||
mFor≡ {Γ} {A ⇒ B} = ≡sym (≡tran²
|
||||
(cong (subst (IFOL.For M) (≡sym mCon≡)) (Morphism.e⇒ m))
|
||||
(substppoly {eq = ≡sym (mCon≡ {Γ})} {f = λ {ξ} X Y → IFOL._⇒_ M {ξ} X Y})
|
||||
(cong₂ (IFOL._⇒_ M) (≡sym (mFor≡ {Γ} {A})) (≡sym (mFor≡ {Γ} {B}))))
|
||||
mFor≡ {Γ} {R t u} = ≡sym (≡tran (cong (subst (IFOL.For M) (≡sym mCon≡)) (Morphism.eR m)) (substpoly {f = λ {ξ} → IFOL.R M {ξ} t u} {eq = ≡sym mCon≡}))
|
||||
mFor≡ {Γ} {∀∀ A} = ≡sym (≡tran³
|
||||
(cong (subst (IFOL.For M) (≡sym mCon≡)) (Morphism.e∀∀ m))
|
||||
(substfpoly {eq = ≡sym mCon≡}{f = λ {ξ} X → IFOL.∀∀ M {ξ} X}{x = λ t → Mapping.mFor (Morphism.m m) {Γ} (A t)})
|
||||
(cong (IFOL.∀∀ M) (≡sym coefun'))
|
||||
(cong (IFOL.∀∀ M) (≡fun λ t → ≡sym (mFor≡ {Γ} {A t}))))
|
||||
|
||||
|
||||
-- Those two lines are not needed as those sorts are in Prop
|
||||
--mSub≡ : {Δ : Con}{Γ : Con}{σ : Sub Δ Γ} → mSub {Δ} {Γ} σ ≡ Morphism.mSub m {Δ} {Γ} σ
|
||||
--mPf≡ : {Γ : Con} {A : For}{p : Pf Γ A} → mPf {Γ} {A} p ≡ Morphism.mPf m {Γ} {A} p
|
||||
|
||||
\end{code}
|
||||
@ -1,12 +1,11 @@
|
||||
{-# OPTIONS --prop #-}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import Agda.Builtin.Nat
|
||||
open import PropUtil
|
||||
|
||||
module InfinitaryFirstOrderKripke (Term : Set) (R : Nat → Set) where
|
||||
module IFOLKripke (Term : Set) (R : Nat → Set) where
|
||||
|
||||
open import ListUtil
|
||||
open import PropUtil
|
||||
open import InfinitaryFirstOrderLogic Term R
|
||||
open import IFOL Term R
|
||||
|
||||
private
|
||||
variable
|
||||
@ -1,14 +1,13 @@
|
||||
{-# OPTIONS --prop #-}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import Agda.Builtin.Nat hiding (zero)
|
||||
open import PropUtil hiding (zero)
|
||||
|
||||
module InfinitaryFirstOrderKripkeGeneral (Term : Set) (R : Nat → Set) where
|
||||
module IFOLNormalization (Term : Set) (R : Nat → Set) where
|
||||
|
||||
open import ListUtil
|
||||
open import PropUtil
|
||||
open import InfinitaryFirstOrderLogic Term R using (Form; Args; Rel; _⇒_; _∧∧_; ⊤⊤; ∀∀; Con)
|
||||
open import ListUtil hiding (zero)
|
||||
open import IFOL Term R using (Form; Args; Rel; _⇒_; _∧∧_; ⊤⊤; ∀∀; Con)
|
||||
|
||||
open import InfinitaryFirstOrderKripke Term R using (Kripke)
|
||||
open import IFOLKripke Term R using (Kripke)
|
||||
|
||||
record Preorder (T : Set₀) : Set₁ where
|
||||
constructor order
|
||||
@ -78,7 +77,7 @@ module InfinitaryFirstOrderKripkeGeneral (Term : Set) (R : Nat → Set) where
|
||||
module NormalizationTests where
|
||||
|
||||
{- Now using our records -}
|
||||
open import InfinitaryFirstOrderLogic Term R hiding (Form; _⇒_; Con)
|
||||
open import IFOL Term R hiding (Form; _⇒_; Con)
|
||||
|
||||
|
||||
ClassicNN : NormalAndNeutral
|
||||
40
Makefile
Normal file
40
Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
define extract
|
||||
cat $(1) | grep -A5000 -m1 $(3) | grep -B5000 -m1 $(4) | head -n -1 | sed 's/\\>\[6\]/\\>\[0\]/g' > $(2)
|
||||
endef
|
||||
|
||||
define split
|
||||
last=-1;i=1;for cur in $$(grep -n -e "--\\\\#" $(1) | cut -d':' -f1); do if [ ! "-1" -eq $$last ]; then dif=$$((cur-last-1));cat $(1) | head -n $$((cur-2)) | tail -n $$((dif)) | awk -f stripAgda.awk > $(2)$$i$(3); i=$$((i+1)); fi; last=$$cur; done
|
||||
endef
|
||||
|
||||
all: report/build/M1Report.pdf
|
||||
|
||||
latex/%.tex: %.lagda
|
||||
agda --latex --allow-unsolved-metas $<
|
||||
cp latex/agda.sty report/agda.sty
|
||||
html/%.html: %.lagda
|
||||
agda --html --allow-unsolved-metas $<
|
||||
html/%.html: %.agda
|
||||
agda --html --allow-unsolved-metas $<
|
||||
|
||||
report/build/M1Report.pdf: agda-tex agda-html report/M1Report.tex report/header.tex report/Bilibibio.bib
|
||||
cd report/; latexmk -pdf -xelatex -silent -shell-escape -outdir=build/ -synctex=1 "M1Report"
|
||||
|
||||
agda-tex: latex/ZOL2.tex latex/ZOLInitial.tex latex/ZOLCompleteness.tex latex/IFOL2.tex latex/IFOLInitial.tex latex/IFOLInitial.tex latex/FFOL.tex latex/FFOLInitial.tex
|
||||
mkdir -p report/agda
|
||||
$(call split,"latex/ZOL2.tex","report/agda/ZOL-",".tex")
|
||||
$(call split,"latex/ZOLInitial.tex","report/agda/ZOL-I-",".tex")
|
||||
$(call split,"latex/ZOLCompleteness.tex","report/agda/ZOL-U-",".tex")
|
||||
$(call split,"latex/IFOL2.tex","report/agda/IFOL-",".tex")
|
||||
$(call split,"latex/IFOLInitial.tex","report/agda/IFOL-I-",".tex")
|
||||
$(call split,"latex/IFOLCompleteness.tex","report/agda/IFOL-C-",".tex")
|
||||
$(call split,"latex/FFOL.tex","report/agda/FFOL-",".tex")
|
||||
$(call split,"latex/FFOLInitial.tex","report/agda/FFOL-I-",".tex")
|
||||
|
||||
agda-html: report/CodeIndex.html html/PropUtil.html html/ListUtil.html html/ZOL2.html html/ZOLInitial.html html/ZOLCompleteness.html html/IFOL2.html html/IFOLInitial.html html/IFOLCompleteness.html html/FFOL.html html/FFOLInitial.html
|
||||
mkdir -p html/
|
||||
cp report/CodeIndex.html html/
|
||||
cd html; ebook-convert CodeIndex.html Code.pdf --base-font-size=8 --margin-bottom=3 --margin-top=3 --paper-size=a4 --language=en --authors="Samy Avrillon" --toc-filter=".*"
|
||||
|
||||
.PHONY: clean agda-tex agda-tex-FFOL agda-tex-ZOL agda-tex-FIni
|
||||
clean:
|
||||
rm -fr *.agdai report/agda latex report/build html html2
|
||||
@ -13,7 +13,7 @@ module PropUtil where
|
||||
-- ⊥ is a data with no constructor
|
||||
-- ⊤ is a record with one always-available constructor
|
||||
data ⊥ : Prop where
|
||||
record ⊤ : Prop where
|
||||
record ⊤ : Prop ℓ where
|
||||
constructor tt
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ module PropUtil where
|
||||
inj₁ : {P Q : Prop} → P → P ∨ Q
|
||||
inj₂ : {P Q : Prop} → Q → P ∨ Q
|
||||
|
||||
record _∧_ (P Q : Prop) : Prop where
|
||||
record _∧_ (P Q : Prop ℓ) : Prop ℓ where
|
||||
constructor ⟨_,_⟩
|
||||
field
|
||||
p : P
|
||||
@ -31,9 +31,9 @@ module PropUtil where
|
||||
infixr 11 _∨_
|
||||
|
||||
-- ∧ elimination
|
||||
proj₁ : {P Q : Prop} → P ∧ Q → P
|
||||
proj₁ : {P Q : Prop ℓ} → P ∧ Q → P
|
||||
proj₁ pq = _∧_.p pq
|
||||
proj₂ : {P Q : Prop} → P ∧ Q → Q
|
||||
proj₂ : {P Q : Prop ℓ} → P ∧ Q → Q
|
||||
proj₂ pq = _∧_.q pq
|
||||
|
||||
-- ∨ elimination
|
||||
@ -158,31 +158,25 @@ module PropUtil where
|
||||
congsubst : {ℓ ℓ' : Level}{A : Set ℓ}{P : A → Set ℓ'}{a a' : A}{e : a ≡ a}{p : P a}{p' : P a} → p ≡ p' → subst P e p ≡ subst P e p'
|
||||
congsubst {P = P} {e = refl} h = cong (subst P refl) h
|
||||
|
||||
substpoly : {ℓ ℓ' : Level}{A : Set ℓ}{P : A → Set ℓ'}{f : {ξ : A} → P ξ}
|
||||
{α β : A}{eq : α ≡ β}
|
||||
→ subst P eq (f {α}) ≡ f {β}
|
||||
substpoly {eq = refl} = coerefl
|
||||
|
||||
substfpoly : {ℓ ℓ' : Level}{A : Set ℓ}{P R : A → Set ℓ'}{α β : A}
|
||||
{eq : α ≡ β} {f : {ξ : A} → R ξ → P ξ} {x : R α}
|
||||
→ coe (cong P eq) (f {α} x) ≡ f (coe (cong R eq) x)
|
||||
substfpoly {eq = refl} {f} = ≡tran coerefl (cong f (≡sym coerefl))
|
||||
|
||||
substppoly : {ℓ ℓ' ℓ'' ℓ''' : Level}{A : Set ℓ}{P : A → Set ℓ'}{R : A → Set ℓ''}{Q : A → Set ℓ'''}{α β : A}
|
||||
{eq : α ≡ β}{f : {ξ : A} → R ξ → Q ξ → P ξ} {x : R α} {y : Q α}
|
||||
→ coe (cong P eq) (f {α} x y) ≡ f {β} (coe (cong R eq) x) (coe (cong Q eq) y)
|
||||
substppoly {eq = refl} {f}{x}{y} = ≡tran coerefl (cong₂ f (≡sym coerefl) (≡sym coerefl))
|
||||
substfpoly' : {ℓ ℓ' ℓ'' : Level}{A B : Set ℓ}{P R : A → Set ℓ'}{Q : B → Prop ℓ''}{α β : A}{γ δ : B}
|
||||
{eq : α ≡ β}{eq' : γ ≡ δ} {f : {ξ : A}{ι : B} → R ξ → Q ι → P ξ} {x : R α} {y : Q γ}
|
||||
→ coe (cong P eq) (f {α} {γ} x y) ≡ f {β} {δ} (coe (cong R eq) x) (substP Q eq' y)
|
||||
substfpoly' {eq = refl} {refl} {f}{x}{y} = ≡tran² coerefl (cong (λ x → f x y) (≡sym coerefl)) refl
|
||||
|
||||
substfpoly⁴ : {ℓ ℓ' ℓ'' : Level}{A : Set ℓ}{P R : A → Set ℓ'}{Q : A → Prop ℓ''}{α β : A}
|
||||
{eq : α ≡ β} {f : {ξ : A} → R ξ → Q ξ → P ξ} {x : R α} {y : Q α}
|
||||
→ coe (cong P eq) (f {α} x y) ≡ f {β} (coe (cong R eq) x) (substP Q eq y)
|
||||
substfpoly⁴ {eq = refl} {f}{x}{y} = ≡tran² coerefl (cong (λ x → f x y) (≡sym coerefl)) refl
|
||||
substfpoly³ : {ℓ ℓ' ℓ'' ℓ''' : Level}{A B C : Set ℓ}{R : A → Set ℓ'}{Q : B → Prop ℓ''}{P : C → Set ℓ'''}{α β : A}{γ δ : B}{ε φ : C}
|
||||
{eq : α ≡ β}{eq' : γ ≡ δ}{eq'' : ε ≡ φ} {f : {ξ : A}{ι : B}{τ : C} → R ξ → Q ι → P τ} {x : R α} {y : Q γ}
|
||||
→ coe (cong P eq'') (f {α} {γ} {ε} x y) ≡ f {β} {δ} {φ} (coe (cong R eq) x) (substP Q eq' y)
|
||||
substfpoly³ {eq = refl} {refl} {refl} {f}{x}{y} = ≡tran² coerefl (cong (λ x → f x y) (≡sym coerefl)) refl
|
||||
substfpoly'' : {ℓ ℓ' ℓ'' : Level}{A C : Set ℓ}{P : A → C → Set ℓ'}{R : A → Set ℓ'}{Q : A → C → Prop ℓ''}{α β : A}{ε φ : C}
|
||||
{eq : α ≡ β}{eq'' : ε ≡ φ} {f : {ξ : A}{κ : C} → R ξ → Q ξ κ → P ξ κ} {x : R α} {y : Q α ε}
|
||||
→ coe (cong₂ P eq eq'') (f {α} {ε} x y) ≡ f {β} {φ} (coe (cong R eq) x) (substP (λ X → Q X φ) eq (substP (Q α) eq'' y))
|
||||
substfpoly'' {eq = refl} {refl} {f}{x}{y} = ≡tran² coerefl (cong (λ x → f x y) (≡sym coerefl)) refl
|
||||
|
||||
substfgpoly : {ℓ ℓ' : Level}{A B : Set ℓ} {P Q : A → Set ℓ'} {R : B → Set ℓ'} {F : B → A} {α β : A} {ε φ : B}
|
||||
{eq₁ : α ≡ β} {eq₂ : F ε ≡ α} {eq₃ : F φ ≡ β} {eq₄ : ε ≡ φ}
|
||||
{g : {a : A} → Q a → P a} {f : {b : B} → R b → Q (F b)} {x : R ε}
|
||||
@ -217,17 +211,14 @@ module PropUtil where
|
||||
{b₁ b₂ : B} {α γ : A b₁} {δ φ : A b₂}
|
||||
{eq0 : b₁ ≡ b₂}{eqa : subst A eq0 α ≡ δ}{eqb : subst A eq0 γ ≡ φ} → {a : R b₂ δ φ}{a' : R b₁ α γ} → coe (coep∘-helper {eq0 = eq0} {eqa = eqa} {eqb = eqb}) a ≡ a
|
||||
coep∘-helper-coe {eq0 = refl}{refl}{refl} = coerefl
|
||||
{-coep∘' : {ℓ ℓ' ℓ'' : Level}{B : Set ℓ}{A : B → Set ℓ''} {R : (b : B) → A b → A b → Set ℓ'}
|
||||
{b₁ b₂ : B} {α β γ : A b₁} {δ ε φ : A b₂}
|
||||
{p : {b : B}{x y z : A b} → R b x y → R b z x → R b z y}{x : R b₁ β γ}{y : R b₁ α β}
|
||||
{eq0 : b₁ ≡ b₂}{eq1 : subst A eq0 α ≡ δ} {eq2 : subst A eq0 β ≡ ε} {eq3 : subst A eq0 γ ≡ φ}
|
||||
{eq4 : R b₂ δ φ ≡ R b₁ α γ}{eq5 : R b₂ ε φ ≡ R b₁ β γ}{eq6 : R b₂ δ ε ≡ R b₁ α β}
|
||||
→ coe eq4
|
||||
(p {b₂} {ε} {φ} {δ} (coe (≡sym (eq5)) x) (coe (≡sym (
|
||||
eq6
|
||||
)) y)) ≡ p {b₁} {β} {γ} {α} x y
|
||||
--coep∘' {p = p} {x} {y} {eq0 = refl} {refl} {refl} {refl} {eq4} = {!!}
|
||||
-}
|
||||
|
||||
|
||||
coefun : {ℓ : Level}{A B C : Set ℓ}{f : B → C}{eq : A ≡ B}
|
||||
→ f ≡ coe (cong (λ X → X → C) eq) (λ (x : A) → f (coe eq x))
|
||||
coefun {f = f} {eq = refl} = ≡tran (≡fun (λ x → cong f (≡sym (coerefl {eq = refl})))) (≡sym (coerefl {eq = refl}))
|
||||
coefun' : {ℓ : Level}{A B C : Set ℓ}{f : A → B}{eq : B ≡ C}
|
||||
→ (λ (x : A) → coe eq (f x)) ≡ coe (cong (λ X → A → X) eq) (λ (x : A) → f x)
|
||||
coefun' {f = f} {eq = refl} = ≡tran (≡fun (λ x → coerefl)) (≡sym coerefl)
|
||||
|
||||
|
||||
|
||||
@ -253,6 +244,12 @@ module PropUtil where
|
||||
a : A
|
||||
b : B
|
||||
|
||||
record _×p_ (A : Prop ℓ) (B : A → Prop ℓ') : Prop (ℓ ⊔ ℓ') where
|
||||
constructor _,×p_
|
||||
field
|
||||
a : A
|
||||
b : B a
|
||||
|
||||
record _×''_ (A : Set ℓ) (B : A → Prop ℓ') : Set (ℓ ⊔ ℓ') where
|
||||
constructor _,×''_
|
||||
field
|
||||
@ -276,6 +273,11 @@ module PropUtil where
|
||||
proj×'₂ : {ℓ ℓ' : Level}{A : Set ℓ}{B : Prop ℓ'} → (A ×' B) → B
|
||||
proj×'₂ p = _×'_.b p
|
||||
|
||||
proj×p₁ : {ℓ ℓ' : Level}{A : Prop ℓ}{B : A → Prop ℓ'} → (A ×p B) → A
|
||||
proj×p₁ p = _×p_.a p
|
||||
proj×p₂ : {ℓ ℓ' : Level}{A : Prop ℓ}{B : A → Prop ℓ'} → (p : A ×p B) → B (proj×p₁ p)
|
||||
proj×p₂ p = _×p_.b p
|
||||
|
||||
proj×''₁ : {ℓ ℓ' : Level}{A : Set ℓ}{B : A → Prop ℓ'} → (A ×'' B) → A
|
||||
proj×''₁ p = _×''_.a p
|
||||
proj×''₂ : {ℓ ℓ' : Level}{A : Set ℓ}{B : A → Prop ℓ'} → (p : A ×'' B) → B (proj×''₁ p)
|
||||
|
||||
50
Readme.agda
50
Readme.agda
@ -1,31 +1,31 @@
|
||||
{-# OPTIONS --prop #-}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
module Readme where
|
||||
|
||||
-- We will use String as propositional variables
|
||||
open import Agda.Builtin.String using (String)
|
||||
open import ListUtil
|
||||
postulate String : Set
|
||||
{-# BUILTIN STRING String #-}
|
||||
|
||||
open import PropUtil
|
||||
open import ListUtil
|
||||
|
||||
-- We can use the basic propositional logic
|
||||
open import PropositionalLogic String
|
||||
open import ZOL String
|
||||
|
||||
-- Here is an example of a propositional formula and its proof
|
||||
-- The formula is (Q → R) → (P → Q) → P → R
|
||||
d-C : [] ⊢ ((Var "Q") ⇒ (Var "R")) ⇒ ((Var "P") ⇒ (Var "Q")) ⇒ (Var "P") ⇒ (Var "R")
|
||||
d-C = lam (lam (lam (app (zero $ next∈ $ next∈ zero∈) (app (zero $ next∈ zero∈) (zero zero∈)))))
|
||||
zol-ex : [] ⊢ ((Var "Q") ⇒ (Var "R")) ⇒ ((Var "P") ⇒ (Var "Q")) ⇒ (Var "P") ⇒ (Var "R")
|
||||
zol-ex = lam (lam (lam (app (zero $ next∈ $ next∈ zero∈) (app (zero $ next∈ zero∈) (zero zero∈)))))
|
||||
|
||||
-- We can with the basic interpretation ⟦_⟧ prove that some formulæ are not provable
|
||||
-- For example, we can disprove (P → Q) → P 's provability as we can construct an
|
||||
-- environnement where the statement doesn't hold
|
||||
|
||||
ρ₀ : Env
|
||||
ρ₀ "P" = ⊥
|
||||
ρ₀ "Q" = ⊤
|
||||
ρ₀ _ = ⊥
|
||||
|
||||
cex-d : ([] ⊢ (((Var "P") ⇒ (Var "Q")) ⇒ (Var "P"))) → ⊥
|
||||
cex-d h = ⟦ h ⟧ᵈ {ρ₀} tt λ x → tt
|
||||
zol-cex : ([] ⊢ (((Var "P") ⇒ (Var "Q")) ⇒ (Var "P"))) → ⊥
|
||||
zol-cex h = ⟦ h ⟧ᵈ {ρ₀} tt λ x → tt
|
||||
|
||||
-- But this is not enough to show the non-provability of every non-provable statement.
|
||||
-- Let's take as an example Pierce formula : ((P → Q) → P) → P
|
||||
@ -52,7 +52,7 @@ TND→P tnd {P} {Q} pqp = dis (tnd {P}) (λ p → p) (λ np → pqp (λ p → ca
|
||||
-- that the Pierce formula cannot be proven
|
||||
|
||||
-- We import the general definition of Kripke models
|
||||
open import PropositionalKripke String
|
||||
open import ZOLKripke String
|
||||
|
||||
-- We will now create a specific Kripke model in which Pierce formula doesn't hold
|
||||
|
||||
@ -116,9 +116,9 @@ module PierceDisproof where
|
||||
PierceNotProvable h = Pierce⊥w₁ (⟦ h ⟧ {w₁} tt)
|
||||
|
||||
|
||||
module GeneralizationInPropositionalLogic where
|
||||
module GeneralizationInZOL where
|
||||
|
||||
-- With Kripke models, we can even prove completeness
|
||||
-- With Kripke models, we can even prove completeness of ZOL
|
||||
-- Using the Universal Kripke Model
|
||||
|
||||
-- With a slightly different universal model (using normal and neutral forms),
|
||||
@ -130,7 +130,7 @@ module GeneralizationInPropositionalLogic where
|
||||
|
||||
-- As all those proofs are really similar, we created a NormalizationFrame structure
|
||||
-- that computes most of the proofs with only a few lemmas
|
||||
open import PropositionalKripkeGeneral String
|
||||
open import ZOLNormalization String
|
||||
|
||||
-- We now have access to quote and unquote functions with this
|
||||
u1 = NormalizationFrame.u NormalizationTests.Frame⊢
|
||||
@ -146,13 +146,13 @@ module GeneralizationInPropositionalLogic where
|
||||
u6 = NormalizationFrame.u NormalizationTests.Frame⊆
|
||||
q6 = NormalizationFrame.q NormalizationTests.Frame⊆
|
||||
|
||||
module GeneralizationInInfinitaryFirstOrderLogic where
|
||||
module GeneralizationInIFOL where
|
||||
|
||||
-- We also did implement infinitary first order logic
|
||||
-- (i.e. ∀ is like an infinitary ∧)
|
||||
-- The proofs works the same with only little modifications
|
||||
|
||||
open import InfinitaryFirstOrderKripkeGeneral String (λ n → String)
|
||||
open import IFOLNormalization String (λ n → String)
|
||||
|
||||
u1 = NormalizationFrame.u NormalizationTests.Frame⊢
|
||||
q1 = NormalizationFrame.q NormalizationTests.Frame⊢
|
||||
@ -168,4 +168,22 @@ module GeneralizationInInfinitaryFirstOrderLogic where
|
||||
q6 = NormalizationFrame.q NormalizationTests.Frame⊆
|
||||
|
||||
|
||||
module NormalizationInFFOL where
|
||||
|
||||
-- We also did an implementation of the negative fragment
|
||||
-- of finitary first order logic (∀ is defined with context extension)
|
||||
|
||||
-- The algebra has been written in this file
|
||||
-- There is also the class of Tarski models, written as an example
|
||||
open import FFOL
|
||||
|
||||
-- We have also written the syntax (initial model)
|
||||
-- (a lot of transport hell, but i did it !)
|
||||
open import FFOLInitial
|
||||
|
||||
-- And now, we can finally write the class of Family and Presheaf models
|
||||
-- and we can make the proof of completeness of the latter.
|
||||
open import FFOLCompleteness
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{-# OPTIONS --prop #-}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
module PropositionalLogic (PV : Set) where
|
||||
module ZOL (PV : Set) where
|
||||
|
||||
open import PropUtil
|
||||
open import ListUtil
|
||||
130
ZOL2.lagda
Normal file
130
ZOL2.lagda
Normal file
@ -0,0 +1,130 @@
|
||||
\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module ZOL2 where
|
||||
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
|
||||
variable
|
||||
ℓ¹ ℓ² ℓ³ ℓ⁴ : Level
|
||||
ℓ¹' ℓ²' ℓ³' ℓ⁴' : Level
|
||||
|
||||
record ZOL : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴)) where
|
||||
infixr 10 _∘_
|
||||
field
|
||||
|
||||
--# We first make the base category with its terminal object
|
||||
Con : Set ℓ¹
|
||||
Sub : Con → Con → Prop ℓ² -- It makes a posetal category
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
id : {Γ : Con} → Sub Γ Γ
|
||||
◇ : Con -- The terminal object of the category
|
||||
ε : {Γ : Con} → Sub Γ ◇ -- The morphism from any object to the terminal
|
||||
|
||||
--# Categorical equations don't need to be stated as the category is *posetal*
|
||||
--∘-ass : {Γ Δ Ξ Ψ : Con}{α : Sub Γ Δ}{β : Sub Δ Ξ}{γ : Sub Ξ Ψ}
|
||||
--idl : {Γ Δ : Con} {σ : Sub Γ Δ} → (id {Δ}) ∘ σ ≡ σ
|
||||
--idr : {Γ Δ : Con} {σ : Sub Γ Δ} → σ ∘ (id {Γ}) ≡ σ
|
||||
-- → (γ ∘ β) ∘ α ≡ γ ∘ (β ∘ α)
|
||||
--ε-u : {Γ : Con} → {σ : Sub Γ ◇} → σ ≡ ε {Γ}
|
||||
|
||||
--# Functor Con → Set called For
|
||||
For : Con → Set ℓ³
|
||||
_[_]f : {Γ Δ : Con} → For Γ → Sub Δ Γ → For Δ -- Action on morphisms
|
||||
[]f-id : {Γ : Con} → {F : For Γ} → F [ id {Γ} ]f ≡ F
|
||||
[]f-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ}
|
||||
→ F [ β ∘ α ]f ≡ (F [ β ]f) [ α ]f
|
||||
|
||||
--# Functor Con × For → Prop called Pf or ⊢
|
||||
Pf : (Γ : Con) → For Γ → Prop ℓ⁴
|
||||
-- Action on morphisms
|
||||
_[_]p : {Γ Δ : Con} → {F : For Γ} → Pf Γ F → (σ : Sub Δ Γ) → Pf Δ (F [ σ ]f)
|
||||
--# Equalities below are useless because Pf Γ F is in prop
|
||||
-- []p-id : {Γ : Con} → {F : For Γ} → {prf : Pf Γ F}
|
||||
-- → prf [ id {Γ} ]p ≡ prf
|
||||
-- []p-∘ : {Γ Δ Ξ : Con}{α : Sub Ξ Δ}{β : Sub Δ Γ}{F : For Γ}{prf : Pf Γ F}
|
||||
-- → prf [ α ∘ β ]p ≡ (prf [ β ]p) [ α ]p
|
||||
|
||||
--# → Prop⁺
|
||||
_▹ₚ_ : (Γ : Con) → For Γ → Con
|
||||
πₚ¹ : {Γ Δ : Con}{F : For Γ} → Sub Δ (Γ ▹ₚ F) → Sub Δ Γ
|
||||
πₚ² : {Γ Δ : Con}{F : For Γ} → (σ : Sub Δ (Γ ▹ₚ F)) → Pf Δ (F [ πₚ¹ σ ]f)
|
||||
_,ₚ_ : {Γ Δ : Con}{F : For Γ} → (σ : Sub Δ Γ) → Pf Δ (F [ σ ]f) → Sub Δ (Γ ▹ₚ F)
|
||||
--# Equality below are useless because Pf and Sub are in Prop
|
||||
--,ₚ∘πₚ : {Γ Δ : Con}{F : For Γ}{σ : Sub Δ (Γ ▹ₚ F)} → (πₚ¹ σ) ,ₚ (πₚ² σ) ≡ σ
|
||||
--πₚ¹∘,ₚ : {Γ Δ : Con}{σ : Sub Δ Γ}{F : For Γ}{prf : Pf Δ (F [ σ ]f)}
|
||||
-- → πₚ¹ (σ ,ₚ prf) ≡ σ
|
||||
-- πₚ²∘,ₚ : {Γ Δ : Con}{σ : Sub Δ Γ}{F : For Γ}{prf : Pf Δ (F [ σ ]f)}
|
||||
-- → πₚ² (σ ,ₚ prf) ≡ prf
|
||||
--,ₚ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{F : For Ξ}{prf : Pf Γ (F [ σ ]f)}
|
||||
-- → (σ ,ₚ prf) ∘ δ ≡ (σ ∘ δ) ,ₚ (substP (Pf Δ) (≡sym []f-∘) (prf [ δ ]p))
|
||||
|
||||
--#
|
||||
{-- FORMULAE CONSTRUCTORS --}
|
||||
|
||||
--# i formula
|
||||
ι : {Γ : Con} → For Γ
|
||||
[]f-ι : {Γ Δ : Con} {σ : Sub Δ Γ}→ ι [ σ ]f ≡ ι
|
||||
|
||||
--# Implication
|
||||
_⇒_ : {Γ : Con} → For Γ → For Γ → For Γ
|
||||
[]f-⇒ : {Γ Δ : Con} → {F G : For Γ} → {σ : Sub Δ Γ}
|
||||
→ (F ⇒ G) [ σ ]f ≡ (F [ σ ]f) ⇒ (G [ σ ]f)
|
||||
|
||||
--#
|
||||
{-- PROOFS CONSTRUCTORS --}
|
||||
-- Again, we don't have to write the _[_]p equalities as Proofs are in Prop
|
||||
|
||||
--# Lam & App
|
||||
lam : {Γ : Con}{F G : For Γ} → Pf (Γ ▹ₚ F) (G [ πₚ¹ id ]f) → Pf Γ (F ⇒ G)
|
||||
app : {Γ : Con}{F G : For Γ} → Pf Γ (F ⇒ G) → Pf Γ F → Pf Γ G
|
||||
|
||||
--#
|
||||
|
||||
record Mapping (S : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}) (D : ZOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'}) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ¹' ⊔ ℓ²' ⊔ ℓ³' ⊔ ℓ⁴')) where
|
||||
field
|
||||
|
||||
--#
|
||||
mCon : (ZOL.Con S) → (ZOL.Con D)
|
||||
mSub : {Δ : (ZOL.Con S)}{Γ : (ZOL.Con S)} →
|
||||
(ZOL.Sub S Δ Γ) → (ZOL.Sub D (mCon Δ) (mCon Γ))
|
||||
mFor : {Γ : (ZOL.Con S)} → (ZOL.For S Γ) → (ZOL.For D (mCon Γ))
|
||||
mPf : {Γ : (ZOL.Con S)} {A : ZOL.For S Γ}
|
||||
→ ZOL.Pf S Γ A → ZOL.Pf D (mCon Γ) (mFor A)
|
||||
--#
|
||||
|
||||
record Morphism (S : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}) (D : ZOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'}) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ¹' ⊔ ℓ²' ⊔ ℓ³' ⊔ ℓ⁴')) where
|
||||
field m : Mapping S D
|
||||
mCon = Mapping.mCon m
|
||||
mSub = Mapping.mSub m
|
||||
mFor = Mapping.mFor m
|
||||
mPf = Mapping.mPf m
|
||||
field
|
||||
--#
|
||||
e◇ : mCon (ZOL.◇ S) ≡ ZOL.◇ D
|
||||
e[]f : {Γ Δ : ZOL.Con S}{A : ZOL.For S Γ}{σ : ZOL.Sub S Δ Γ} →
|
||||
mFor (ZOL._[_]f S A σ) ≡ ZOL._[_]f D (mFor A) (mSub σ)
|
||||
e▹ₚ : {Γ : ZOL.Con S}{A : ZOL.For S Γ} →
|
||||
mCon (ZOL._▹ₚ_ S Γ A) ≡ ZOL._▹ₚ_ D (mCon Γ) (mFor A)
|
||||
eι : {Γ : ZOL.Con S} → mFor (ZOL.ι S {Γ}) ≡ ZOL.ι D {mCon Γ}
|
||||
e⇒ : {Γ : ZOL.Con S}{A B : ZOL.For S Γ} →
|
||||
mFor (ZOL._⇒_ S A B) ≡ ZOL._⇒_ D (mFor A) (mFor B)
|
||||
-- No equation needed for lam, app, ∀i, ∀e as their output are in prop
|
||||
--#
|
||||
|
||||
record TrNat {S : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}} {D : ZOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'}} (a : Mapping S D) (b : Mapping S D) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ¹' ⊔ ℓ²' ⊔ ℓ³' ⊔ ℓ⁴')) where
|
||||
field
|
||||
f : (Γ : ZOL.Con S) → ZOL.Sub D (Mapping.mCon a Γ) (Mapping.mCon b Γ)
|
||||
-- Unneeded because Sub are in prop
|
||||
--eq : (Γ Δ : ZOL.Con S)(σ : ZOL.Sub S Γ Δ) → (ZOL._∘_ D (f Δ) (Mapping.mSub a σ)) ≡ (ZOL._∘_ D (Mapping.mSub b σ) (f Γ))
|
||||
|
||||
_∘TrNat_ : {S : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}}{D : ZOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'}}{a b c : Mapping S D} → TrNat a b → TrNat b c → TrNat a c
|
||||
_∘TrNat_ {D = D} α β = record { f = λ Γ → ZOL._∘_ D (TrNat.f β Γ) (TrNat.f α Γ) }
|
||||
|
||||
idTrNat : {S : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}}{D : ZOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'}}{a : Mapping S D} → TrNat a a
|
||||
idTrNat {D = D} = record { f = λ Γ → ZOL.id D }
|
||||
|
||||
\end{code}
|
||||
162
ZOLCompleteness.lagda
Normal file
162
ZOLCompleteness.lagda
Normal file
@ -0,0 +1,162 @@
|
||||
\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module ZOLCompleteness where
|
||||
|
||||
open import Agda.Primitive
|
||||
open import ZOL2
|
||||
open import ListUtil
|
||||
|
||||
record Kripke : Set (lsuc (ℓ¹)) where
|
||||
field
|
||||
World : Set ℓ¹
|
||||
_-w->_ : World → World → Prop ℓ¹ -- arrows
|
||||
-w->id : {w : World} → w -w-> w -- id arrow
|
||||
_∘-w->_ : {w w' w'' : World} → w -w-> w' → w' -w-> w'' → w -w-> w'' -- arrow composition
|
||||
|
||||
Ι : World → Prop ℓ¹
|
||||
Ι≤ : {w w' : World} → w -w-> w' → Ι w → Ι w'
|
||||
|
||||
infixr 10 _∘_
|
||||
|
||||
Con : Set (lsuc ℓ¹)
|
||||
Con = (World → Prop ℓ¹) ×'' (λ Γ → {w w' : World} → (w -w-> w')→ Γ w → Γ w')
|
||||
Sub : Con → Con → Prop ℓ¹
|
||||
Sub Δ Γ = (w : World) → (proj×''₁ Δ) w → (proj×''₁ Γ) w
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
α ∘ β = λ w γ → α w (β w γ)
|
||||
id : {Γ : Con} → Sub Γ Γ
|
||||
id = λ w γ → γ
|
||||
◇ : Con -- The initial object of the category
|
||||
◇ = (λ w → ⊤) ,×'' (λ _ _ → tt)
|
||||
ε : {Γ : Con} → Sub Γ ◇ -- The morphism from the initial to any object
|
||||
ε w Γ = tt
|
||||
|
||||
-- Functor Con → Set called For
|
||||
For : Set (lsuc ℓ¹)
|
||||
For = (World → Prop ℓ¹) ×'' (λ F → {w w' : World} → (w -w-> w')→ F w → F w')
|
||||
|
||||
-- Proofs
|
||||
Pf : (Γ : Con) → For → Prop ℓ¹
|
||||
Pf Γ F = ∀ w (γ : (proj×''₁ Γ) w) → (proj×''₁ F) w
|
||||
_[_]p : {Γ Δ : Con} → {F : For} → Pf Γ F → (σ : Sub Δ Γ) → Pf Δ F -- The functor's action on morphisms
|
||||
prf [ σ ]p = λ w → λ γ → prf w (σ w γ)
|
||||
-- Equalities below are useless because Γ ⊢ F is in prop
|
||||
-- []p-id : {Γ : Con} → {F : For Γ} → {prf : Γ ⊢ F} → prf [ id {Γ} ]p ≡ prf
|
||||
-- []p-∘ : {Γ Δ Ξ : Con} → {α : Sub Ξ Δ} → {β : Sub Δ Γ} → {F : For Γ} → {prf : Γ ⊢ F} → prf [ α ∘ β ]p ≡ (prf [ β ]p) [ α ]p
|
||||
|
||||
|
||||
-- → Prop⁺
|
||||
_▹ₚ_ : (Γ : Con) → For → Con
|
||||
Γ ▹ₚ F = (λ w → (proj×''₁ Γ) w ∧ (proj×''₁ F) w) ,×'' λ s γ → ⟨ proj×''₂ Γ s (proj₁ γ) , proj×''₂ F s (proj₂ γ) ⟩
|
||||
|
||||
πₚ¹ : {Γ Δ : Con} → {F : For} → Sub Δ (Γ ▹ₚ F) → Sub Δ Γ
|
||||
πₚ¹ σ w δ = proj₁ (σ w δ)
|
||||
πₚ² : {Γ Δ : Con} → {F : For} → (σ : Sub Δ (Γ ▹ₚ F)) → Pf Δ F
|
||||
πₚ² σ w δ = proj₂ (σ w δ)
|
||||
_,ₚ_ : {Γ Δ : Con} → {F : For} → (σ : Sub Δ Γ) → Pf Δ F → Sub Δ (Γ ▹ₚ F)
|
||||
(σ ,ₚ pf) w δ = ⟨ (σ w δ) , pf w δ ⟩
|
||||
|
||||
|
||||
-- Base formula
|
||||
ι : For
|
||||
ι = (λ w → Ι w) ,×'' λ s f → Ι≤ s f
|
||||
|
||||
-- Implication
|
||||
_⇒_ : For → For → For
|
||||
(F ⇒ G) = (λ w → {w' : World} → (s : w -w-> w') → ((proj×''₁ F) w') → ((proj×''₁ G) w')) ,×'' λ s f s' f' → f (s ∘-w-> s') f'
|
||||
|
||||
-- Lam & App
|
||||
lam : {Γ : Con} → {F : For} → {G : For} → Pf (Γ ▹ₚ F) G → Pf Γ (F ⇒ G)
|
||||
lam {Γ} pf w γ {w'} s x = pf w' ⟨ proj×''₂ Γ s γ , x ⟩
|
||||
--lam prf = λ w γ w' s h → prf w (γ , h)
|
||||
app : {Γ : Con} → {F G : For} → Pf Γ (F ⇒ G) → Pf Γ F → Pf Γ G
|
||||
app pf pf' w γ = pf w γ -w->id (pf' w γ)
|
||||
-- Again, we don't write the _[_]p equalities as everything is in Prop
|
||||
|
||||
zol : ZOL
|
||||
zol = record
|
||||
{ Con = Con
|
||||
; Sub = Sub
|
||||
; _∘_ = λ {Γ}{Δ}{Ξ} σ δ → _∘_ {Γ}{Δ}{Ξ} σ δ
|
||||
; id = λ {Γ} → id {Γ}
|
||||
; ◇ = ◇
|
||||
; ε = λ {Γ} → ε {Γ}
|
||||
; For = λ Γ → For
|
||||
; _[_]f = λ A σ → A
|
||||
; []f-id = refl
|
||||
; []f-∘ = refl
|
||||
; Pf = Pf
|
||||
; _[_]p = λ {Γ}{Δ}{F} pf σ → _[_]p {Γ}{Δ}{F} pf σ
|
||||
; _▹ₚ_ = _▹ₚ_
|
||||
; πₚ¹ = λ {Γ}{Δ}{F}σ → πₚ¹ {Γ}{Δ}{F} σ
|
||||
; πₚ² = λ {Γ}{Δ}{F}σ → πₚ² {Γ}{Δ}{F} σ
|
||||
; _,ₚ_ = λ {Γ}{Δ}{F} σ pf → _,ₚ_ {Γ}{Δ}{F}σ pf
|
||||
; ι = ι
|
||||
; []f-ι = refl
|
||||
; _⇒_ = _⇒_
|
||||
; []f-⇒ = refl
|
||||
; lam = λ {Γ}{F}{G} pf → lam {Γ}{F}{G} pf
|
||||
; app = λ {Γ}{F}{G} pf pf' → app {Γ}{F}{G} pf pf'
|
||||
}
|
||||
|
||||
module U where
|
||||
|
||||
import ZOLInitial as I
|
||||
|
||||
U : Kripke
|
||||
U = record
|
||||
{ World = I.Con
|
||||
; _-w->_ = λ Γ Δ → I.Sub Δ Γ
|
||||
; -w->id = I.id
|
||||
; _∘-w->_ = λ σ σ' → σ I.∘ σ'
|
||||
; Ι = λ Γ → I.Pf Γ I.ι
|
||||
; Ι≤ = λ s pf → pf I.[ s ]p
|
||||
}
|
||||
|
||||
open Kripke U
|
||||
|
||||
y : Mapping I.zol zol
|
||||
y = record
|
||||
{ mCon = λ Γ → (λ Δ → I.Sub Δ Γ) ,×'' λ σ δ → δ I.∘ σ
|
||||
; mSub = λ σ Ξ δ → σ I.∘ δ
|
||||
; mFor = λ A → (λ Ξ → I.Pf Ξ A) ,×'' λ σ pf → pf I.[ σ ]p
|
||||
; mPf = λ pf Ξ σ → pf I.[ σ ]p
|
||||
}
|
||||
m : Morphism I.zol zol
|
||||
m = I.InitialMorphism.mor zol
|
||||
|
||||
q : (Γ : I.Con) → Sub (Morphism.mCon m Γ) (Mapping.mCon y Γ)
|
||||
u : (Γ : I.Con) → Sub (Mapping.mCon y Γ) (Morphism.mCon m Γ)
|
||||
|
||||
⟦_⟧c = Morphism.mCon m
|
||||
⟦_,_⟧f = λ A Γ → Morphism.mFor m {Γ} A
|
||||
|
||||
q⁰ : {F : I.For} → {Γ Γ₀ : I.Con} → proj×''₁ ⟦ F , Γ₀ ⟧f Γ → I.Pf Γ F
|
||||
u⁰ : {F : I.For} → {Γ Γ₀ : I.Con} → I.Pf Γ F → proj×''₁ ⟦ F , Γ₀ ⟧f Γ
|
||||
|
||||
q⁰ {I.ι} {Γ} h = h
|
||||
q⁰ {A I.⇒ B} {Γ} h = I.lam (q⁰ {B} (h (I.πₚ¹ I.id) (u⁰ {A} (I.var I.pvzero))))
|
||||
u⁰ {I.ι} {Γ} pf = pf
|
||||
u⁰ {A I.⇒ B} {Γ} pf iq hF = u⁰ {B} (I.app (pf I.[ iq ]p) (q⁰ hF) )
|
||||
|
||||
|
||||
q I.◇ w γ = I.ε
|
||||
q (Γ I.▹ₚ A) w γ = (q Γ w (proj₁ γ) I.,ₚ q⁰ (proj₂ γ))
|
||||
u I.◇ w σ = tt
|
||||
u (Γ I.▹ₚ A) w σ = ⟨ (u Γ w (I.πₚ¹ σ)) , u⁰ (I.πₚ² σ) ⟩
|
||||
|
||||
ηq : TrNat (Morphism.m m) y
|
||||
ηq = record { f = q }
|
||||
ηu : TrNat y (Morphism.m m)
|
||||
ηu = record { f = u }
|
||||
|
||||
eq : ηu ∘TrNat ηq ≡ idTrNat
|
||||
eq = refl
|
||||
|
||||
realCompleteness : {Γ Δ : I.Con} → ({Ξ : I.Con} → (proj×''₁ ⟦ Γ ⟧c) Ξ → (proj×''₁ ⟦ Δ ⟧c) Ξ ) → I.Sub Γ Δ
|
||||
realCompleteness {Γ} {Δ} f = q Δ Γ (f {Γ} (u Γ Γ I.id))
|
||||
|
||||
\end{code}
|
||||
193
ZOLInitial.lagda
Normal file
193
ZOLInitial.lagda
Normal file
@ -0,0 +1,193 @@
|
||||
\begin{code}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
open import PropUtil
|
||||
|
||||
module ZOLInitial where
|
||||
|
||||
open import ZOL2
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
|
||||
--#
|
||||
data For : Set where
|
||||
ι : For
|
||||
_⇒_ : For → For → For
|
||||
|
||||
data Con : Set where
|
||||
◇ : Con
|
||||
_▹ₚ_ : Con → For → Con
|
||||
|
||||
--#
|
||||
variable
|
||||
Γ Δ Ξ : Con
|
||||
A B : For
|
||||
|
||||
--#
|
||||
data PfVar : Con → For → Prop where
|
||||
pvzero : PfVar (Γ ▹ₚ A) A
|
||||
pvnext : PfVar Γ A → PfVar (Γ ▹ₚ B) A
|
||||
data Pf : Con → For → Prop where
|
||||
var : PfVar Γ A → Pf Γ A
|
||||
lam : Pf (Γ ▹ₚ A) B → Pf Γ (A ⇒ B)
|
||||
app : Pf Γ (A ⇒ B) → Pf Γ A → Pf Γ B
|
||||
|
||||
--#
|
||||
data Ren : Con → Con → Prop where
|
||||
ε : Ren Γ ◇
|
||||
_,ₚR_ : Ren Δ Γ → PfVar Δ A → Ren Δ (Γ ▹ₚ A)
|
||||
|
||||
--#
|
||||
rightR : Ren Δ Γ → Ren (Δ ▹ₚ A) Γ
|
||||
rightR ε = ε
|
||||
rightR (σ ,ₚR pv) = (rightR σ) ,ₚR (pvnext pv)
|
||||
|
||||
idR : Ren Γ Γ
|
||||
idR {◇} = ε
|
||||
idR {Γ ▹ₚ A} = (rightR (idR {Γ})) ,ₚR pvzero
|
||||
|
||||
--#
|
||||
data Sub : Con → Con → Prop where
|
||||
ε : Sub Γ ◇
|
||||
_,ₚ_ : Sub Δ Γ → Pf Δ A → Sub Δ (Γ ▹ₚ A)
|
||||
|
||||
--#
|
||||
πₚ¹ : Sub Δ (Γ ▹ₚ A) → Sub Δ Γ
|
||||
πₚ² : Sub Δ (Γ ▹ₚ A) → Pf Δ A
|
||||
πₚ¹ (σ ,ₚ pf) = σ
|
||||
πₚ² (σ ,ₚ pf) = pf
|
||||
|
||||
--#
|
||||
SubR : Ren Γ Δ → Sub Γ Δ
|
||||
SubR ε = ε
|
||||
SubR (σ ,ₚR pv) = SubR σ ,ₚ var pv
|
||||
|
||||
id : Sub Γ Γ
|
||||
id = SubR idR
|
||||
|
||||
--#
|
||||
_[_]pvr : PfVar Γ A → Ren Δ Γ → PfVar Δ A
|
||||
pvzero [ _ ,ₚR pv ]pvr = pv
|
||||
pvnext pv [ σ ,ₚR _ ]pvr = pv [ σ ]pvr
|
||||
_[_]pr : Pf Γ A → Ren Δ Γ → Pf Δ A
|
||||
var pv [ σ ]pr = var (pv [ σ ]pvr)
|
||||
lam pf [ σ ]pr = lam (pf [ (rightR σ) ,ₚR pvzero ]pr)
|
||||
app pf pf' [ σ ]pr = app (pf [ σ ]pr) (pf' [ σ ]pr)
|
||||
|
||||
wkSub : Sub Δ Γ → Sub (Δ ▹ₚ A) Γ
|
||||
wkSub ε = ε
|
||||
wkSub (σ ,ₚ pf) = (wkSub σ) ,ₚ (pf [ rightR idR ]pr)
|
||||
|
||||
--#
|
||||
_[_]p : Pf Γ A → Sub Δ Γ → Pf Δ A
|
||||
var pvzero [ _ ,ₚ pf ]p = pf
|
||||
var (pvnext pv) [ σ ,ₚ _ ]p = var pv [ σ ]p
|
||||
lam pf [ σ ]p = lam (pf [ wkSub σ ,ₚ var pvzero ]p)
|
||||
app pf pf' [ σ ]p = app (pf [ σ ]p) (pf' [ σ ]p)
|
||||
|
||||
--#
|
||||
_∘_ : {Γ Δ Ξ : Con} → Sub Δ Ξ → Sub Γ Δ → Sub Γ Ξ
|
||||
ε ∘ β = ε
|
||||
(α ,ₚ pf) ∘ β = (α ∘ β) ,ₚ (pf [ β ]p)
|
||||
|
||||
--#
|
||||
|
||||
|
||||
|
||||
zol : ZOL
|
||||
zol = record
|
||||
{ Con = Con
|
||||
; Sub = Sub
|
||||
; _∘_ = _∘_
|
||||
; id = id
|
||||
; ◇ = ◇
|
||||
; ε = ε
|
||||
; For = λ Γ → For
|
||||
; _[_]f = λ A σ → A
|
||||
; []f-id = refl
|
||||
; []f-∘ = refl
|
||||
; Pf = Pf
|
||||
; _[_]p = _[_]p
|
||||
; _▹ₚ_ = _▹ₚ_
|
||||
; πₚ¹ = πₚ¹
|
||||
; πₚ² = πₚ²
|
||||
; _,ₚ_ = _,ₚ_
|
||||
; ι = ι
|
||||
; []f-ι = refl
|
||||
; _⇒_ = _⇒_
|
||||
; []f-⇒ = refl
|
||||
; lam = lam
|
||||
; app = app
|
||||
}
|
||||
|
||||
module InitialMorphism (M : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}) where
|
||||
|
||||
--#
|
||||
mCon : Con → (ZOL.Con M)
|
||||
mFor : {Γ : Con} → For → (ZOL.For M (mCon Γ))
|
||||
|
||||
mCon ◇ = ZOL.◇ M
|
||||
mCon (Γ ▹ₚ A) = ZOL._▹ₚ_ M (mCon Γ) (mFor {Γ} A)
|
||||
mFor {Γ} ι = ZOL.ι M
|
||||
mFor {Γ} (A ⇒ B) = ZOL._⇒_ M (mFor {Γ} A) (mFor {Γ} B)
|
||||
|
||||
--#
|
||||
|
||||
mSub : {Δ : Con}{Γ : Con} → Sub Δ Γ → (ZOL.Sub M (mCon Δ) (mCon Γ))
|
||||
mPf : {Γ : Con} {A : For} → Pf Γ A → ZOL.Pf M (mCon Γ) (mFor {Γ} A)
|
||||
|
||||
e[]f⁰ : {Γ : Con}{A B : For} → mFor {Γ ▹ₚ B} A ≡ ZOL._[_]f M (mFor {Γ} A) (ZOL.πₚ¹ M (ZOL.id M))
|
||||
e[]f⁰ {A = ι} = ≡sym (ZOL.[]f-ι M)
|
||||
e[]f⁰ {A = A ⇒ B} = ≡sym (≡tran (ZOL.[]f-⇒ M) (cong₂ (ZOL._⇒_ M) (≡sym (e[]f⁰ {A = A})) (≡sym (e[]f⁰ {A = B}))))
|
||||
|
||||
e[]f : {Γ Δ : Con}{A : For}{σ : Sub Δ Γ} → mFor {Δ} A ≡ ZOL._[_]f M (mFor {Γ} A) (mSub σ)
|
||||
e[]f {A = ι} = ≡sym (ZOL.[]f-ι M)
|
||||
e[]f {Γ} {Δ} {A = A ⇒ B} {σ} = ≡sym (≡tran (ZOL.[]f-⇒ M) (cong₂ (ZOL._⇒_ M) (≡sym (e[]f {A = A}{σ})) (≡sym (e[]f {A = B}{σ}))))
|
||||
|
||||
|
||||
|
||||
mPf {A = A} (var (pvzero {Γ})) = substP (ZOL.Pf M _) (≡sym (e[]f⁰ {Γ} {A} {A})) (ZOL.πₚ² M (ZOL.id M))
|
||||
mPf {A = A} (var (pvnext {Γ} {B = B} pv)) = substP (ZOL.Pf M _) (≡sym (e[]f⁰ {Γ} {A} {B})) (ZOL._[_]p M (mPf (var pv)) (ZOL.πₚ¹ M (ZOL.id M)))
|
||||
mPf {Γ} (lam {A = A} {B} pf) = ZOL.lam M (substP (ZOL.Pf M _) (e[]f⁰ {Γ} {B} {A}) (mPf pf))
|
||||
mPf (app pf pf') = ZOL.app M (mPf pf) (mPf pf')
|
||||
|
||||
mSub ε = ZOL.ε M
|
||||
mSub (_,ₚ_ {Δ} {Γ = Γ} {A} σ pf) = ZOL._,ₚ_ M (mSub σ) (substP (ZOL.Pf M _) (e[]f {Γ} {Δ} {A} {σ}) (mPf pf))
|
||||
|
||||
mor : Morphism zol M
|
||||
mor = record {
|
||||
m = record {
|
||||
mCon = mCon
|
||||
; mSub = mSub
|
||||
; mFor = λ {Γ} A → mFor {Γ} A
|
||||
; mPf = mPf
|
||||
}
|
||||
; e◇ = refl
|
||||
; e[]f = λ {Γ}{Δ}{A}{σ} → e[]f {A = A} {σ}
|
||||
; e▹ₚ = refl
|
||||
; eι = refl
|
||||
; e⇒ = refl
|
||||
}
|
||||
|
||||
module InitialMorphismUniqueness {M : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}} {m : Morphism zol M} where
|
||||
|
||||
open InitialMorphism M
|
||||
mCon≡ : {Γ : Con} → mCon Γ ≡ (Morphism.mCon m Γ)
|
||||
mFor≡ : {Γ : Con} {A : For} → mFor {Γ} A ≡ subst (ZOL.For M) (≡sym mCon≡) (Morphism.mFor m {Γ} A)
|
||||
|
||||
mCon≡ {◇} = ≡sym (Morphism.e◇ m)
|
||||
mCon≡ {Γ ▹ₚ A} = ≡sym (≡tran (Morphism.e▹ₚ m) (cong₂' (ZOL._▹ₚ_ M) (≡sym mCon≡) (≡sym mFor≡)))
|
||||
mFor≡ {Γ} {ι} = ≡sym (≡tran
|
||||
(cong (subst (ZOL.For M) (≡sym mCon≡)) (Morphism.eι m))
|
||||
(substpoly {f = λ {Ξ} → ZOL.ι M {Ξ}} {eq = ≡sym mCon≡})
|
||||
)
|
||||
mFor≡ {Γ} {A ⇒ B} = ≡sym (≡tran²
|
||||
(cong (subst (ZOL.For M) (≡sym mCon≡)) (Morphism.e⇒ m))
|
||||
(substppoly {eq = ≡sym (mCon≡ {Γ})} {f = λ {ξ} X Y → ZOL._⇒_ M {ξ} X Y})
|
||||
(cong₂ (ZOL._⇒_ M) (≡sym (mFor≡ {Γ} {A})) (≡sym (mFor≡ {Γ} {B}))))
|
||||
|
||||
-- Those two lines are not needed as those sorts are in Prop
|
||||
--mSub≡ : {Δ : Con}{Γ : Con}{σ : Sub Δ Γ} → mSub {Δ} {Γ} σ ≡ Morphism.mSub m {Δ} {Γ} σ
|
||||
--mPf≡ : {Γ : Con} {A : For}{p : Pf Γ A} → mPf {Γ} {A} p ≡ Morphism.mPf m {Γ} {A} p
|
||||
|
||||
\end{code}
|
||||
@ -1,10 +1,10 @@
|
||||
{-# OPTIONS --prop #-}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
module PropositionalKripke (PV : Set) where
|
||||
module ZOLKripke (PV : Set) where
|
||||
|
||||
open import ListUtil
|
||||
open import PropUtil
|
||||
open import PropositionalLogic PV
|
||||
open import ZOL PV
|
||||
|
||||
private
|
||||
variable
|
||||
@ -1,12 +1,12 @@
|
||||
{-# OPTIONS --prop #-}
|
||||
{-# OPTIONS --prop --rewriting #-}
|
||||
|
||||
module PropositionalKripkeGeneral (PV : Set) where
|
||||
module ZOLNormalization (PV : Set) where
|
||||
|
||||
open import ListUtil
|
||||
open import PropUtil
|
||||
open import PropositionalLogic PV using (Form; Var; _⇒_; _∧∧_; ⊤⊤; Con)
|
||||
open import ListUtil hiding (zero)
|
||||
open import PropUtil hiding (zero)
|
||||
open import ZOL PV using (Form; Var; _⇒_; _∧∧_; ⊤⊤; Con)
|
||||
|
||||
open import PropositionalKripke PV using (Kripke)
|
||||
open import ZOLKripke PV using (Kripke)
|
||||
|
||||
record Preorder (T : Set₀) : Set₁ where
|
||||
constructor order
|
||||
@ -61,12 +61,13 @@ module PropositionalKripkeGeneral (PV : Set) where
|
||||
u : {F : Form} → {Γ : Con} → Γ ⊢⁰ F → Γ ⊩ᶠ F
|
||||
|
||||
u {Var x} h = h
|
||||
u {F ⇒ F₁} h {Γ'} iq hF = u {F₁} (app {Γ'} {F} {F₁} (⊢tran iq h) (q hF))
|
||||
u {F ⇒ F₁} h {Γ'} iq hF = {!retro (Preorder.refl≤ o)!}
|
||||
--u {F ⇒ F₁} h {Γ'} iq hF = u {F₁} (app {Γ'} {F} {F₁} (⊢tran iq h) (q hF))
|
||||
u {F ∧∧ G} h = ⟨ (u {F} (ande₁ h)) , (u {G} (ande₂ h)) ⟩
|
||||
u {⊤⊤} h = tt
|
||||
|
||||
q {Var x} h = neu⁰ h
|
||||
q {F ⇒ F₁} {Γ} h = lam (q (h (retro (Preorder.refl≤ o)) (u {F} {F ∷ Γ} zero)))
|
||||
q {F ⇒ F₁} {Γ} h = lam (q {F₁} (h (retro (Preorder.refl≤ o)) (u {F} {F ∷ Γ} zero)))
|
||||
q {F ∧∧ G} ⟨ hF , hG ⟩ = andi (q {F} hF) (q {G} hG)
|
||||
q {⊤⊤} h = true
|
||||
|
||||
@ -75,7 +76,7 @@ module PropositionalKripkeGeneral (PV : Set) where
|
||||
module NormalizationTests where
|
||||
|
||||
{- Now using our records -}
|
||||
open import PropositionalLogic PV hiding (Form; Var; _⇒_; Con)
|
||||
open import ZOL PV hiding (Form; Var; _⇒_; Con)
|
||||
|
||||
|
||||
ClassicNN : NormalAndNeutral
|
||||
89
report/Bilibibio.bib
Normal file
89
report/Bilibibio.bib
Normal file
@ -0,0 +1,89 @@
|
||||
@article{NBE2016,
|
||||
title={Normalisation by Evaluation for Dependent Types},
|
||||
author={Thorsten Altenkirch and Ambrus Kaposi},
|
||||
booktitle={International Conference on Formal Structures for Computation and Deduction},
|
||||
year={2016}
|
||||
}
|
||||
@phdthesis{AltenkirschThesis1993,
|
||||
title={Constructions, inductive types and strong normalization},
|
||||
author={Thorsten Altenkirch},
|
||||
booktitle={CST},
|
||||
year={1993}
|
||||
}
|
||||
@unpublished{TaoOfTypes,
|
||||
title={The Tao of Types},
|
||||
author={Thorsten Altenkirsch}
|
||||
}
|
||||
@inproceedings{folSogatKaposi2023,
|
||||
title={Why is equality interesting?},
|
||||
author={Ambrus Kaposi},
|
||||
url={https://akaposi.github.io/pres_wld.pdf}}
|
||||
|
||||
@phdthesis{UemuraThesis2021,
|
||||
title = {Abstract and concrete type theories},
|
||||
isbn = {9789464213768},
|
||||
url = {https://dare.uva.nl/search?identifier=41ff0b60-64d4-4003-8182-c244a9afab3b},
|
||||
language = {en},
|
||||
urldate = {2023-08-04},
|
||||
publisher = {AmsterdamInstitute for Logic, Language and Computation},
|
||||
author = {Uemura, T.},
|
||||
year = {2021},
|
||||
}
|
||||
|
||||
@article{logicalFramework1993,
|
||||
author = {Harper, Robert and Honsell, Furio and Plotkin, Gordon},
|
||||
title = {A Framework for Defining Logics},
|
||||
year = {1993},
|
||||
issue_date = {Jan. 1993},
|
||||
publisher = {Association for Computing Machinery},
|
||||
address = {New York, NY, USA},
|
||||
volume = {40},
|
||||
number = {1},
|
||||
issn = {0004-5411},
|
||||
url = {https://doi.org/10.1145/138027.138060},
|
||||
doi = {10.1145/138027.138060},
|
||||
abstract = {The Edinburgh Logical Framework (LF) provides a means to define (or present) logics. It is based on a general treatment of syntax, rules, and proofs by means of a typed λ-calculus with dependent types. Syntax is treated in a style similar to, but more general than, Martin-Lo¨f's system of arities. The treatment of rules and proofs focuses on his notion of a judgment. Logics are represented in LF via a new principle, the judgments as types principle, whereby each judgment is identified with the type of its proofs. This allows for a smooth treatment of discharge and variable occurence conditions and leads to a uniform treatment of rules and proofs whereby rules are viewed as proofs of higher-order judgments and proof checking is reduced to type checking. The practical benefit of our treatment of formal systems is that logic-independent tools, such as proof editors and proof checkers, can be constructed.},
|
||||
journal = {J. ACM},
|
||||
month = {jan},
|
||||
pages = {143–184},
|
||||
numpages = {42},
|
||||
keywords = {formal systems, interactive theorem proving, proof checking, typed lambda calculus}
|
||||
}
|
||||
|
||||
@article{hoffmann1999,
|
||||
author = {Hofmann, Martin},
|
||||
title = {Semantical Analysis of Higher-Order Abstract Syntax},
|
||||
year = {1999},
|
||||
isbn = {0769501583},
|
||||
publisher = {IEEE Computer Society},
|
||||
address = {USA},
|
||||
abstract = {A functor category semantics for higher-order abstract syntax is proposed with the following aims: relating higher-order and first order syntax, justifying induction principles, suggesting new logical principles to reason about higher-order syntax},
|
||||
booktitle = {Proceedings of the 14th Annual IEEE Symposium on Logic in Computer Science},
|
||||
pages = {204},
|
||||
series = {LICS '99}
|
||||
}
|
||||
|
||||
@article{fioreMahmoud2013secondorder,
|
||||
title={Second-Order Algebraic Theories},
|
||||
author={Marcelo Fiore and Ola Mahmoud},
|
||||
year={2013},
|
||||
eprint={1308.5409},
|
||||
archivePrefix={arXiv},
|
||||
primaryClass={cs.LO}
|
||||
}
|
||||
@article{RedFreeNorm1995,
|
||||
doi = {10.1007/3-540-60164-3_27},
|
||||
url = {https://doi.org/10.1007\3-540-60164-3_27},
|
||||
year = 1995,
|
||||
publisher = {Springer Berlin Heidelberg},
|
||||
pages = {182--199},
|
||||
author = {Thorsten Altenkirch and Martin Hofmann and Thomas Streicher},
|
||||
title = {Categorical reconstruction of a reduction free normalization proof},
|
||||
booktitle = {Category Theory and Computer Science}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
21
report/CodeIndex.html
Normal file
21
report/CodeIndex.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ZOL2</title>
|
||||
<link rel="stylesheet" href="Agda.css">
|
||||
</head>
|
||||
<body style="font-size: 20pt;">
|
||||
<ol>
|
||||
<li><a href="./PropUtil.html">PropUtil</a></li>
|
||||
<li><a href="./ListUtil.html">ListUtil</a></li>
|
||||
<li><a href="./ZOL2.html">ZOL</a></li>
|
||||
<li><a href="./ZOLInitial.html">ZOLInitial</a></li>
|
||||
<li><a href="./ZOLCompleteness.html">ZOLCompleteness</a></li>
|
||||
<li><a href="./IFOL2.html">IFOL</a></li>
|
||||
<li><a href="./IFOLInitial.html">IFOLInitial</a></li>
|
||||
<li><a href="./IFOLCompleteness.html">IFOLCompleteness</a></li>
|
||||
<li><a href="./FFOL.html">FFOL</a></li>
|
||||
<li><a href="./FFOLInitial.html">FFOLInitial</a></li>
|
||||
</ol>
|
||||
</body>
|
||||
600
report/M1Report.tex
Normal file
600
report/M1Report.tex
Normal file
@ -0,0 +1,600 @@
|
||||
% !TeX spellcheck = en_US
|
||||
\documentclass[10pt,a4paper]{article}
|
||||
|
||||
\include{./header.tex}
|
||||
|
||||
\title{Logic as a Second-Order Generalized Algebraic Theory
|
||||
\\[1ex] \large Notes on my 3-month internship at the Faculty of Informatics of ELTE (Budapest, Hungary)}
|
||||
\hypersetup{pdftitle={Completeness Proof for different kinds of logical frameworks}}
|
||||
\author{Samy Avrillon, supervised by
|
||||
\\[1ex] Ambrus Kaposi (ELTE, Budapest, Hungary)
|
||||
\\[1ex] and Thorsten Altenkirsch (University of Notthingam, United Kingdom)}
|
||||
|
||||
\begin{document}
|
||||
\doparttoc
|
||||
\maketitle
|
||||
|
||||
\hsep
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\newpage
|
||||
|
||||
|
||||
\section{Introduction}
|
||||
|
||||
In the first place, I was supposed to do this internship in Nottingham (UK) with Thorsten Altenkirsh. But, because of administrative issues, I was not able to go there, and Thorsten Altenkirsh contacted Ambrus Kaposi in Budapest, whose university agreed to accept me. Therefore, I went to Budapest and I did the internship under the physical supervision of Ambrus Kaposi, and the remote supervision of Thorsten Altenkirsch.
|
||||
|
||||
\subsection{Introduction to the problem}
|
||||
What we call a \enquote{logic} or \enquote{logical framework} is a set of definitions containing formulas and a notion of provability of those formulæ, plus a set of operators/equalities to construct or reduce these proofs \cite{logicalFramework1993}. I have studied the most common logical frameworks, that is, Propositional Logic, First-Order Logic with an infinitary operator, and Predicate Logic. For each of those logics, one can define a notion of \emph{model}. A model of a certain kind of logic is something that implements all of the logic's definitions, operators, and equalities. From all of those models, one can extract the \emph{initial model}, also called \emph{syntax}. It is the smallest of all models, which means that for any model of that logic, we have a morphism from the syntax to this model.
|
||||
|
||||
Then, our goal is for each logic to prove the completeness of a specific class of models. Completeness can be stated as such: \enquote{For any formula, if it is provable in all models of the specified class, then it has a proof in the syntax}.
|
||||
|
||||
\subsection{Motivation}
|
||||
Ambrus is currently studying Second-Order Generalized Algebraic Theories (or SOGAT) and he is trying to state a better definition than that first defined in Taichi Uemura's thesis \cite{UemuraThesis2021}. He also wants to write a paper with examples to show why they are useful, and adding some examples for different frameworks of logic can help with that. Having a completeness proof in this (categorical) higher order setting \cite{hoffmann1999} can help.
|
||||
|
||||
\subsection{Structure of this report}
|
||||
|
||||
In this report, we will gradually increase the complexity of the logic we are studying. We will first study the most simple Propositional logic, which will serve as an explanation of the different concepts used in the report, and then we will study Predicate Logic, first in a layout using a trick to avoid most of the difficulties, and then in a more satisfying layout but which is harder to make.
|
||||
|
||||
For each logic, we will first give the SOGAT definition of the logic. We will then transform it into a GAT (i.e. something that can be understood by Agda). Then we will construct the syntax of the logic. Finally, we will construct the completeness proof for the studied logic.
|
||||
|
||||
Unfortunately, the proof of the initiality of Predicate Logic's syntax, as well as its completeness proof, are not given in this report as I did not have the time to make them at the end of the internship.
|
||||
|
||||
\section{Propositional Logic}
|
||||
\subsection{Propositional Logic as a SOGAT}
|
||||
|
||||
The first and most simple logical framework we can work with is that of Propositional Logic (referred to as Zero Order Logic or ZOL in the code). We also work in the most simple framework in which we only have one axiom rule for creating formulæ: the \iotAgda{} rule. Propositional Logic is usually done with a fixed set of propositional variables instead of only one that is fixed, but adding them does not make the construction more interesting, only more complicated.
|
||||
|
||||
To state all the definitions, functions, and more importantly, all the equalities that a model of Propositional Logic has to verify, we will write down Propositional Logic as a SOGAT. It goes as described in \autoref{fig:zol-sogat}.
|
||||
|
||||
\begin{figure}
|
||||
\begin{tcolorbox}
|
||||
\begin{center}
|
||||
\begin{tabular}{lcl}
|
||||
\For & : & \Set \\
|
||||
--- \impliesAgda --- & : & \For \agdato \For \agdato \For\\
|
||||
\iotAgda & : & \For \\
|
||||
&&\\
|
||||
\Pf & : & \For \agdato \Prop⁺ \\
|
||||
\lam & : & (\Pf{} A \agdato⁺ \Pf{} B) \agdato \Pf{} (A \impliesAgda B)\\
|
||||
\app & : & \Pf{} (A \impliesAgda B) \agdato (\Pf{} A \agdato \Pf{} B)
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
\end{tcolorbox}
|
||||
\caption{ZOL Sogat Presentation}
|
||||
\label{fig:zol-sogat}
|
||||
\end{figure}
|
||||
|
||||
We can see that in this Sogat, we have two sorts (\For{} and \Pf{}), each of them having two constructors. Although SOGATs can have equations in them, every SOGAT in this report will not have any.
|
||||
|
||||
A keen eye may have seen that there should be a problem with the \lam{} constructor. Its type is indeed not strictly positive (i.e. the type \Pf{} appears to the left of an arrow in the arguments of the constructor). That's why we use a ${}^+$ on the arrow, and we use the same ${}^+$ on the sort of \Pf{}. This kind of arrow means that \Pf{} should be \emph{locally representable}. It means that we have to use \emph{proof variables} to implement this SOGAT.
|
||||
|
||||
\subsection{From a SOGAT to GAT}
|
||||
|
||||
|
||||
Unfortunately, Agda cannot understand SOGATs directly (yet). So we have to convert this SOGAT into a (First Order) Generalized Algebraic Theory (or GAT). I will describe the process in this section, each line of the SOGAT giving birth to a set of sorts, constructors, and equations in the GAT.
|
||||
|
||||
The first thing we need to define any SOGAT-derived GAT is a base category with a terminal object. We will call \emph{contexts} the objects of this category and \emph{substitutions} the morphisms of the category.
|
||||
|
||||
You can see that the equations for the category ($\circ$-associativity, identity to the right and the left) have not been written down. This is because substitutions are defined as \Prop{} objects and not \Set{} objects. The difference between those two kinds of objects is that the former are said to be \emph{proof-irrelevant}. You can understand it as \enquote{there is at most one object into a type that is in \Prop}. Therefore, the equalities described above are trivially true, because any substitution from $\Gamma$ to $\Delta$ is equal to any other substitution from $\Gamma$ to $\Delta$. This trick of using \Prop{} instead of \Set{} will be used throughout the report, and it will allow us to write down (and prove) a lot fewer equations.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-1.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
Once we have our base category, we can start to describe the sorts that we have in our SOGAT. Every sort from the SOGAT will be translated into a functor from our base category to \Set{} (or \Prop{}, depending on the case). Therefore, we have to define an action on objects, an action on morphisms (that we will always write contra-variant, and we will use the $\_[\_]$ notation), and some equalities that we will call \emph{functorality} or \enquote{\textit{Type} respects substitution}
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-3.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-4.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
Now, we will translate the ${}^+$ in the type of proofs. As we said before, this translates into the fact that we have \emph{proof variables}. This means that we should be able to move from one context to another context in which we added one proof variable. We call this \emph{context extension}. For proof-variables, this context extension takes one parameter, as each proof-variables is of one specific \enquote{type} (which is the formula that they prove).
|
||||
|
||||
With those context extensions, we also have to add a way to extend substitutions (which are the morphisms from the base category). We do that by adding a \emph{comma} operator that takes a substitution and a proof and which extends the goal of the substitution. (If we see a proof context as a list of formulæ and a proof substitution as a list of proofs, the action of the comma operator is simply to add one proof to the list). We also need to be able to extract the proof and the base substitution from a substitution into an extended context (called \emph{weakening} operation). Therefore, we add two $\pi$ projections that extract the data from the substitution. We also need some equalities, that are saying that $(\AgdaField{$\pi_p¹$} , \AgdaField{$\pi_p²$})$, and $\AgdaField{$,_p$}$ are reciprocal, plus one equality saying that the comma operator also transposes the substitution. But as both \AgdaField{Pf} and \AgdaField{Sub} are in \Prop{}, those equations are unneeded.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-6.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
The last step is to add the constructors of our objects into the algebra. We write them directly as they were presented in the SOGAT, except for the new \AgdaField{Con} parameter that we need to add to everything. We also need to add one equation for each constructor saying that the constructors do respect substitutions. And we don't add any for \AgdaField{Pf} constructors as they are unneeded as \AgdaField{Pf} are in \AgdaPrimitive{Prop}.
|
||||
|
||||
The only one we cannot translate directly is the $\rightarrow^+$ from the \lam{} constructor from the SOGAT. To translate this \emph{locally representable application}, we transform the parameter of the arrow into a context extension of the appropriate type. Therefore, a function $\Pf\; A \rightarrow^+ \Pf\; B$ becomes a proof $\Pf\; (\Gamma \:\AgdaField{$\triangleright_p$}\, A)\; B$ (except that we have to transform B that is a $\For\;\Gamma$ into a $\For\;(\Gamma \:\AgdaField{$\triangleright_p$}\, A)$, using the \emph{weakening} substitution $\AgdaField{$\pi_p¹$}\;\AgdaField{id}\;:\;\AgdaField{Sub}\;\Gamma\;(\Gamma \:\AgdaField{$\triangleright_p$}\, X)$ for any Γ-formula $X$)
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-9.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-10.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-12.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
We now have completed our definition of a model for Propositional Logic, in the SOGAT setting. In the meantime, we will define (categorical) morphisms between models. They are composed of mappings for every sort of the GAT, plus equations for the categorical objects (terminal object, identity, and composition), for the action of the functors on morphisms ($[]f$ and $[]p$), and finally equations to say that the constructors are also transported by the morphism. A lot of those equations are not written because \AgdaField{Pf} and \AgdaField{Sub} are in \Prop{}.
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-14.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-16.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
\subsection{Finding a strict syntax}
|
||||
|
||||
What will be the use of these morphisms? One thing we want to do is to find the \emph{initial} model, or \emph{syntax} for this class of models. It means that we want to find a model from which, for any model $M$, there exists one and only one morphism from this model to $M$. We can also call the syntax the \emph{minimal model}, as it is the model that contains just the objects something needs to be a model of Propositional Logic.
|
||||
|
||||
Mathematically, this model is really easy to find. We only have to take all the sorts defined in the GAT and apply a quotient by every equation of the GAT. But this is not very interesting, as the defined model would not be \emph{strict}, i.e. all equations will not be definitional. Having only strict definitions for objects allows us to study completeness while removing a lot of transport issues that make the transport hell far bigger in the completeness proof. Transport hell will be explained in \autoref{sec:transport-hell}.
|
||||
|
||||
So we have three things to do :
|
||||
\begin{enumerate}
|
||||
\setlength{\itemsep}{-1ex}
|
||||
\item Create a model $I$ for Propositional Logic that we think is minimal
|
||||
\item For any other model $M$, create a morphism $m_I : I \to M$
|
||||
\item Show that any morphism $I \to M$ is equal to $m_I$
|
||||
\end{enumerate}
|
||||
|
||||
Let's get started. This framework of Propositional logic has one property that we can make use of to make the construction of the syntax much simpler. (Actually, we don't know if we could have made the syntax with this method if we haven't had this property. We will try to investigate it further in the future). This property is that formulæ do not depend on contexts. One can understand it as \enquote{a formula is the same regardless of the proof variables associated with it, as it doesn't use any of them}. Without this property, we would have to define mutually every sort of our theory, which would be extremely complicated.
|
||||
|
||||
The first step is to define our sorts, no difficulty, we only make one datatype constructor for each constructor in the SOGAT (or in the GAT). For contexts, the only two constructors are as the terminal object of the base category, or as a context extension of another context. That's where we use the fact that formulæ don't depend on contexts: it allows us to define \AgdaDatatype{For} and \AgdaDatatype{Con} separately, but also to define \AgdaDatatype{Pf} and \AgdaDatatype{Sub} separately (the \AgdaField{lam} constructor should refer to \AgdaFunction{\_[\_]f}, but formulæ substitution is identity when formulæ do not depend on contexts). There is also another special constructor for proofs, which is that of proof variables, and which corresponds to the \enquote{constructor} which is \AgdaField{$\pi_p^2$}
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-I-1.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-I-3.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
The next step is to define substitutions. But we will first define a weaker property than substitution called \enquote{renamings}. The two definitions are put one next to the other, and we can see that when \AgdaDatatype{Sub} are lists of complete proofs, \AgdaDatatype{Ren} are only lists of proof variables (i.e. direct proofs assumed from the contexts). This weaker form of substitution is needed to define the identity substitution, as we cannot directly define it recursively for fully-featured substitutions.
|
||||
|
||||
The projections are simply a pattern-matching against the datatype.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-I-4.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-I-6.tex}
|
||||
\vspace{0ex}
|
||||
\agda{agda/ZOL-I-7.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
Because we need to refer to \AgdaField{id}, and more precisely to \AgdaField{$\pi_p^1$} \AgdaField{id} in the notion of proof substitution, we first define proof \emph{renamings} so we can define \AgdaFunction{wkSub} (which is the same as \AgdaField{$\pi_p^1$} \AgdaField{id}) and only after that, we define fully featured substitution.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-I-9.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-I-10.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
The last step is then to define substitution composition, which is done by applying the second part of the substitution to every element of the first part.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-I-11.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
And we now have a working model for Propositional Logic. We can implement our previously defined record and all the equations can be directly understood by Agda (\AgdaInductiveConstructor{refl} is enough proof).
|
||||
|
||||
I won't dive into the construction of the initial morphism and the proof that it is unique, since it is a bit ugly because of some \emph{transport hell} (see \autoref{sec:transport-hell} for an explanation of the issue).
|
||||
|
||||
Still, below is the construction of the \AgdaField{Con} and \AgdaField{For} mappings, as they show the basic idea of the construction. The idea is simple, we pattern-match against the datatype definition of our sort in our syntax, and for each constructor, we call the corresponding one in the algebra.
|
||||
|
||||
And the uniqueness proof is pretty simple again because you only need to prove that the \AgdaDatatype{Con} and \AgdaDatatype{For} mappings are unique, because the other ones are in \AgdaPrimitive{Prop}, so they are automatically unique. And to prove the unicity, you split again on the sort's datatype, and for each constructor, you use the fact that a morphism preserves constructors, and you have a nice proof by recursion (except it's ugly because of transport hell).
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-I-13.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
\subsection{Stating and Proving Completeness}
|
||||
|
||||
Now that we have our syntax, we can try to state and prove completeness in our specific categorical framework.
|
||||
|
||||
The general idea of completeness proofs is to take a class of models (here we will take Kripke Models) and to state that for any formlæ that has a proof in every Kripke model, then it has a proof in the syntax. The other direction is called \emph{soundness}, but we already have proven that when we created our initial morphism. This morphism can indeed turn proofs in the syntax into proofs in any model.
|
||||
|
||||
This completeness proof is often done by taking some specific model of the class that is said to be \emph{universal}, and by showing that you can go between proofs in the universal model and proofs from the syntax freely. We often try to distinguish two reciprocal functions: \AgdaOperator{quote} that turns a proof from the syntax into a proof in the Kripke model, and an \AgdaOperator{unquote} function that does the converse.
|
||||
|
||||
To state this in our categorical layout, we will use a different mapping going from the initial model to our Kripke model which is called the \emph{Yoneda mapping}. The Yoneda mapping is simply defined with the following equation:
|
||||
|
||||
\[ y(\Gamma) = \operatorname{Hom}_\mathcal{U}(-,\Gamma) = \AgdaDatatype{Sub}_\mathcal{U} \; - \; \Gamma\]
|
||||
|
||||
This works because, in the universal model, a context is a map from contexts of the syntax to \AgdaPrimitive{Prop} (because the category is posetal).
|
||||
|
||||
\begin{center}
|
||||
\begin{tikzpicture}[thick, scale=3]
|
||||
\node at (-1,0) (nI) {$\mathcal{I}$};
|
||||
\node at (1,0) (nU) {$\mathcal{U}$};
|
||||
|
||||
\draw[->] (nI) to[bend left] node[midway,above,inner sep=1ex] {$\llbracket\_\rrbracket$} (nU);
|
||||
\draw[->] (nI) to[bend right] node[midway,below,inner sep=1ex] {$y$} (nU);
|
||||
|
||||
\node at (-.15,+.25) (I0) {};
|
||||
\node at (-.15,-.25) (Y0) {};
|
||||
\draw[->,double distance=.4ex] (I0) to node[midway,left,inner sep=1ex] {$q$} (Y0);
|
||||
\node at (+.15,+.25) (I1) {};
|
||||
\node at (+.15,-.25) (Y1) {};
|
||||
\draw[->,double distance=.4ex] (Y1) to node[midway,right,inner sep=1ex] {$u$} (I1);
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
With this Yoneda Mapping, we want to construct two natural transformations $u$ and $q$ so that $u \circ q = id$. These two natural transformations witness a generalized version of completeness as we can prove the \enquote{real} completeness with the following construction.
|
||||
|
||||
\begin{center}
|
||||
\begin{code}
|
||||
\>[4]\AgdaFunction{completeness}\AgdaSpace{}%
|
||||
\AgdaSymbol{:}\AgdaSpace{}%
|
||||
\AgdaSymbol{\{}\AgdaBound{Γ}\AgdaSpace{}%
|
||||
\AgdaBound{Δ}\AgdaSpace{}%
|
||||
\AgdaSymbol{:}\AgdaSpace{}%
|
||||
\AgdaDatatype{I.Con}\AgdaSymbol{\}}\AgdaSpace{}%
|
||||
\AgdaSymbol{→}\AgdaSpace{}%
|
||||
\AgdaSymbol{(\{}\AgdaBound{Ξ}\AgdaSpace{}%
|
||||
\AgdaSymbol{:}\AgdaSpace{}%
|
||||
\AgdaDatatype{I.Con}\AgdaSymbol{\}}\AgdaSpace{}%
|
||||
\AgdaSymbol{→}\AgdaSpace{}%
|
||||
\AgdaOperator{\AgdaFunction{⟦}}\AgdaSpace{}%
|
||||
\AgdaBound{Γ}\AgdaSpace{}%
|
||||
\AgdaOperator{\AgdaFunction{⟧c}}\AgdaSpace{}%
|
||||
\AgdaBound{Ξ}\AgdaSpace{}%
|
||||
\AgdaSymbol{→}\AgdaSpace{}%
|
||||
\AgdaOperator{\AgdaFunction{⟦}}\AgdaSpace{}%
|
||||
\AgdaBound{Δ}\AgdaSpace{}%
|
||||
\AgdaOperator{\AgdaFunction{⟧c}}\AgdaSpace{}%
|
||||
\AgdaBound{Ξ}\AgdaSpace{}%
|
||||
\AgdaSymbol{)}%
|
||||
\>[99]\AgdaSymbol{→}\AgdaSpace{}%
|
||||
\AgdaDatatype{I.Sub}\AgdaSpace{}%
|
||||
\AgdaBound{Γ}\AgdaSpace{}%
|
||||
\AgdaBound{Δ}\<%
|
||||
\\
|
||||
%
|
||||
\>[4]\AgdaFunction{completeness}\AgdaSpace{}%
|
||||
\AgdaSymbol{\{}\AgdaBound{Γ}\AgdaSymbol{\}}\AgdaSpace{}%
|
||||
\AgdaSymbol{\{}\AgdaBound{Δ}\AgdaSymbol{\}}\AgdaSpace{}%
|
||||
\AgdaBound{f}\AgdaSpace{}%
|
||||
\AgdaSymbol{=}\AgdaSpace{}%
|
||||
\AgdaFunction{q}\AgdaSpace{}%
|
||||
\AgdaBound{Δ}\AgdaSpace{}%
|
||||
\AgdaBound{Γ}\AgdaSpace{}%
|
||||
\AgdaSymbol{(}\AgdaBound{f}\AgdaSpace{}%
|
||||
\AgdaSymbol{\{}\AgdaBound{Γ}\AgdaSymbol{\}}\AgdaSpace{}%
|
||||
\AgdaSymbol{(}\AgdaFunction{u}\AgdaSpace{}%
|
||||
\AgdaBound{Γ}\AgdaSpace{}%
|
||||
\AgdaBound{Γ}\AgdaSpace{}%
|
||||
\AgdaFunction{I.id}\AgdaSymbol{))}\<%
|
||||
\end{code}
|
||||
\end{center}
|
||||
|
||||
This construction means \enquote{for any list of formulæ $\Delta$ which are proven in the universal model in the context $\Gamma$ (the data of these proofs is $f$), we have a list of proofs \emph{in the syntax} of the formulæ of $\Delta$ in the context $\Gamma$}. This is exactly completeness!
|
||||
|
||||
You can notice that we have only worked with negative fragments of logic (i.e. without disjunction) because then, Kripke models would not have been sufficient to make the completeness proof. This is another way to extend the work done during this internship.
|
||||
|
||||
During the internship, i also studied different forms of normalization proofs (i.e. saying that if we have a proof of $A$ in $\Gamma$ then we have a \emph{normal} proof of $A$ in $\Gamma$) using different wide subcategories of $\bCon$. One of those normalizations was exactly completeness. We will try to study a formalization for other logical frameworks of this \enquote{generalized normalization proof} \cite{RedFreeNorm1995}.
|
||||
|
||||
\section{First-order logic (or Predicate Logic)}
|
||||
|
||||
In this part, we will try to implement the same as we did for Propositional Logic, but this time for Predicate Logic. We again work in a simpler layout where we don't have function symbols and only have one binary relation \AgdaField{R}. And again, adding other relations and function symbols does not add a lot of new interesting content, but makes everything less readable and more complex to use.
|
||||
|
||||
\subsection{Infinitary First-Order Logic}
|
||||
|
||||
A naive version of first-order logic can be done by implementing $\forall$ as an infinitary \enquote{and} operator. I have implemented this solution, and we can look at what it added to the code.
|
||||
|
||||
The trick is to use an external set of terms, that is a parameter of the algebra (and therefore of all the models). This external set is called $\operatorname{TM}$.
|
||||
|
||||
The SOGAT for this new logic is given in \autoref{fig:ifol-sogat}. We can see that we added one constructor for formulæ: $\forall$ that takes as input a function from our external $\operatorname{TM}$ to formulæ and makes this function into a formula. We also add the introduction and elimination rule for $\forall$. We don't need to put a plus on this arrow as the set on which the recurring is external, so we don't have any strict positivity problem.
|
||||
|
||||
\begin{figure}
|
||||
\begin{tcolorbox}
|
||||
\begin{center}
|
||||
\begin{tabular}{lcl}
|
||||
\For & : & \Set \\
|
||||
--- \impliesAgda --- & : & \For \agdato \For \agdato \For \\
|
||||
\R & : & TM \agdato TM \agdato \For \\
|
||||
\forallAgda & : & (TM \agdato \For) \agdato \For \\
|
||||
&&\\
|
||||
\Pf & : & \For \agdato \Prop⁺ \\
|
||||
\lam & : & (\Pf{} A \agdato⁺ \Pf{} B) \agdato \Pf{} (A \impliesAgda B) \\
|
||||
\app & : & \Pf{} (A \impliesAgda B) \agdato (\Pf{} A \agdato \Pf{} B) \\
|
||||
\foralli & : & (t : TM \agdato \Pf{} A t) \agdato \Pf{} (\forallAgda A)\\
|
||||
\foralle & : & \Pf{} (\forallAgda A) \agdato (t : TM) \agdato \Pf{} (A\;t)\\
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
\end{tcolorbox}
|
||||
\caption{IFOL Sogat Presentation}
|
||||
\label{fig:ifol-sogat}
|
||||
\end{figure}
|
||||
|
||||
Therefore, the GAT we deduce from this is not a lot more complex, we simply have to add the operators as they were described in the SOGAT together with their functorality equalities for the types that are not in \AgdaPrimitive{Prop}.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/IFOL-1.tex}
|
||||
\agdasep
|
||||
\agda{agda/IFOL-3.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
The same goes to add the constructors from the syntax, this is pretty straightforward. We add a simple constructor taking a function from $\operatorname{TM}$ to \AgdaDatatype{For}, and two proofs constructors which don't break strict positivity as \AgdaInductiveConstructor{$\forall i$} takes as input a \enquote{list of proofs indexed by TM}.
|
||||
|
||||
We also need to add cases for proof substitutions but they are trivial cases. The same goes for the initial morphism and the proof of initiality, feel free to look at the code if you want to check it.
|
||||
|
||||
%TODO add ref to code on internet and in appendix
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/IFOL-I-1.tex}
|
||||
\agdasep
|
||||
\agda{agda/IFOL-I-3.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
And Completeness proof is not harder, we just have to add the Kripke interpretation of this external forall, which is very natural, and we also need to add a case for \AgdaInductiveConstructor{$\forall$} to the definition of $u$ and $q$.
|
||||
|
||||
We now have something that mimics first-order logic, but because the set of terms is external, the non-formulæ variables (the term variables) do not exist in our language. This logic is then not exactly first-order, and a more correct name might have been \enquote{Zero Order Logic with one Infinitary Operator}. Still, this construction is much simpler than the real Predicate Logic that is presented in the next section.
|
||||
|
||||
\subsection{(Finitary) Predicate Logic as a SOGAT}
|
||||
|
||||
\subsubsection{Making the SOGAT}
|
||||
|
||||
The first step is again to create the SOGAT of Predicate Logic. The SOGAT is given in \autoref{fig:ffol-sogat}. We can see that \emph{terms} are now part of the theory, and we see that they have to be locally representable (into $\AgdaPrimitive{Set}^+$). This is because the proof constructor \AgdaInductiveConstructor{$\forall i$} now has a strictly positive arrow because terms are not external anymore.
|
||||
|
||||
Except for this difference, the two SOGAT for infinitary and finitary first-order logic looks very similar, and this is a great example to show that SOGATs are a good way of describing models.
|
||||
|
||||
\begin{figure}
|
||||
\begin{tcolorbox}
|
||||
\begin{center}
|
||||
\begin{tabular}{lcl}
|
||||
\Tm & : & \Set⁺ \\
|
||||
&&\\
|
||||
\For & : & \Set \\
|
||||
--- \impliesAgda --- & : & \For \agdato \For \agdato \For \\
|
||||
\R & : & \Tm \agdato \Tm \agdato \For \\
|
||||
\forallAgda & : & (\Tm \agdato \For) \agdato \For \\
|
||||
&&\\
|
||||
\Pf & : & \For \agdato \Prop⁺ \\
|
||||
\lam & : & (\Pf{} A \agdato⁺ \Pf{} B) \agdato \Pf{} (A \impliesAgda B) \\
|
||||
\app & : & \Pf{} (A \impliesAgda B) \agdato (\Pf{} A \agdato \Pf{} B) \\
|
||||
\foralli & : & (t : \Tm \agdato⁺ \Pf{} A t) \agdato \Pf{} (\forallAgda A)\\
|
||||
\foralle & : & \Pf{} (\forallAgda A) \agdato (t : \Tm) \agdato \Pf{} (A\;t)\\
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
\end{tcolorbox}
|
||||
\caption{FFOL Sogat Presentation}
|
||||
\label{fig:ffol-sogat}
|
||||
\end{figure}
|
||||
|
||||
\subsubsection{Making a GAT out of it}
|
||||
|
||||
So now that we want to encode a GAT from this SOGAT, we can follow the same process as we followed before. One difference is that \AgdaField{Sub} now have to be in \AgdaPrimitive{Set}, and so we have a lot more equations that were trivial before. For example, the base category now has to make explicit all the categorical equations.
|
||||
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-1.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
We also have to add a term extension operator as we did for formula extension. One difference is that this new kind of extension has no parameters. However, it makes it so \AgdaField{Sub} have to be in \AgdaPrimitive{Set}, and so we have to add a lot of equations about the two-term extensions.
|
||||
|
||||
Please ignore the \AgdaFunction{substP} for now, this notion will be explained in \autoref{sec:transport-hell}, you can just consider that this function returns its third argument unchanged and ignores the two firsts.
|
||||
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-3.tex}
|
||||
\end{tcolorbox}
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-7.tex}
|
||||
\agda{agda/FFOL-8.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
We also have to add a \Tm{} functor, that will have no other constructor than that of \AgdaField{$\pi_t^2$}. We don't need to change the other constructors except for \AgdaField{$\forall i$} in which the strictly positive application becomes a proof from a term-extended context, and for \AgdaField{$\forall e$} in which we have to \enquote{compute} what it means to apply a formula at some specific term.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-2.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-14.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
We now have a complete GAT for Predicate logic, and we already see that we have a lot more equations to prove.
|
||||
|
||||
\subsection{Finding a Syntax for First-Order Logic}
|
||||
|
||||
Even though the new SOGAT does not seem a lot more complex than the one for IFOL, there are three reasons why making the Syntax will be much harder.
|
||||
|
||||
\begin{enumerate}
|
||||
\item We cannot make Sub to be in \AgdaPrimitive{Prop} anymore, because we have term extensions, and terms are in \AgdaPrimitive{Set}, and therefore we have a lot more equations.
|
||||
\item We now have two parallel ways of extending contexts and that squares the difficulty
|
||||
\item Formulæ now have to depend on contexts too (because they can contain terms)
|
||||
\end{enumerate}
|
||||
|
||||
However, we can still do something that simplifies greatly the making of the syntax. We can split the $\bCon$ category in two. The first part will be related to term extensions and the second part will be related to proof extensions.
|
||||
|
||||
The difficulty is that those two parts are not independent. Indeed, a proof-extension-related context (or \emph{proof context}) will depend on formulæ, which will themselves depend on term-extension-related contexts (or \emph{term contexts}).
|
||||
|
||||
So, let's first define the term contexts, which simply describes how many terms they are in the context (therefore, they are isomorphic to Nat).
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-1.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
Then, we can define already define terms (which can only be term variables, because \AgdaField{$\pi_t^2$} is the only constructor in our simplified version), and formulæ. Both types are indexed only by a \textbf{term} context, and we will need later to make them $\bCon \rightarrow \bSet$ rather than $\textbf{Cont} \rightarrow \bSet$. This follows the same reasoning we did when we said that Formulæ didn't have to depend on Contexts. Formulæ (and terms) never need to access proof variables, and that is the reason why we can do the separation.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-3.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-4.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
We now can define \textbf{term} substitutions. The algebra gives us two ways of constructing them: with \AgdaField{$,_t$} and as a morphism from the initial object, like in Propositional Logic. That's how we make our constructors. The two projections $\pi_t^1$ and $\pi_t^2$ are then simply obtained by eliminating the \AgdaInductiveConstructor{$,_t$} constructor and getting the first or second term. The equalities between $\pi_t¹$, $\pi_t²$ and $,_t$ can be proven easily in that layout.
|
||||
|
||||
We also have to define the action of term substitutions on terms and formulæ. The definitions are natural, as we just go down the formulæ to get to the term variables and transform them into the terms specified in the substitution.
|
||||
|
||||
We also define the categorical constructors for the $\textbf{Cont}$ category, that are, the \AgdaFunction{id${}_t$} and \AgdaFunction{$\circ_t$} operators, and we have to show their three categorical laws. Please note that these are not the equalities we will use in the final algebra, because they are only related to \AgdaDatatype{Subt} and not to the more general \AgdaField{Sub} (but we will surely use them later).
|
||||
|
||||
We also show the functorality of \agdaSubst[t] and \agdaSubst{f}. One can notice we use some helper functions that are called \AgdaFunction{wk${}_t$} and \AgdaFunction{lf${}_t$}. Those stand for weakening and lifting. I don't show their definitions here, because they are only helper functions, but \AgdaFunction{wk${}_t$} means that from something going from a context $\Gamma$, we create something going from the context $\Gamma$ \AgdaInductiveConstructor{$\triangleright_t$} that does not use the added variable. \AgdaFunction{lf${}_t$} means that we add one variable to the source, we add one variable to the goal, and this variable is mapped to itself.
|
||||
|
||||
We do not need renamings this time to define them because we do not have any term constructor aside from term variables.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-5.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-7.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-9.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-10.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
We can now start creating the other category related to proof variables. For that, we can define the base set of the category as we did with term contexts. But this time, our extension constructor has another parameter: The formula the added proof proves. Therefore, we have a dependency of \AgdaDatatype{Conp} on \AgdaDatatype{Cont}, because formulæ are defined in \AgdaDatatype{Cont}.
|
||||
|
||||
This new $\textbf{Conp}$ category is indeed a functor from $\textbf{Cont}$ to $\bSet$. So we have to define its action on $\textbf{Cont}$'s morphisms. And we also have to prove that this action respects the functorality of $\textbf{Conp}$.
|
||||
|
||||
We will finally create another operator on $\textbf{Conp}$: \AgdaFunction{$\triangleright$tp}. This operator does a term extension of a proof context, which doesn't add any information to the proofs, it only adds one unused variable to them (we substitute all the proofs with \AgdaFunction{wk${}_t$} \AgdaFunction{id${}_t$}). It can be understood as the action of the general \AgdaField{$\triangleright_t$} functor on $\textbf{Conp}$.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-12.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-14.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-16.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
We now have everything we need to define proofs, and we simply implement all the constructors from the GAT. You can notice that we have separated term and proof contexts in the definitions, but it is only for the sake of readability because operations on proofs will often modify the proof context without changing the term context.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-18.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
We also define the action of term substitutions on proofs (because \AgdaDatatype{Pf} is a functor that is indexed by $\textbf{Cont}$). Terms substitutions do nothing to the proofs, they only affect formulæ and terms, which you cannot find inside a proof. So it is only changing the type of a proof from \Pf{}~$\Delta_t$~$\Delta_p$~$A$ to \Pf{}~$\Gamma_t$~$\Delta_p[\sigma_t]$~$A[\sigma_t]$.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-19.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
Again, before we can define proof substitutions, we need to define \emph{renamings} as we did for Propositional Logic. They allow us to define proof-weakening and the identity substitution. Those two functions are needed to define fully-featured substitutions. But please note that those proof substitutions are defined with a fixed term context. So they are weaker than the final substitutions we will have to define for our algebra, which have to be able to be morphisms between contexts that differ on term-contexts and proof context at the same time. But this is not an issue and we can define all substitutions using only those restricted proof-substitutions.
|
||||
|
||||
Again, these substitutions are a functor over the category $\textbf{Cont}$, so we have to construct the action on morphisms, which is simply applying the transformations to all the proofs contained in the substitution.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-20.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-22.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-24.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
With this new kind of substitution, we can substitute on proofs (that's what they're for). In other words, we have to describe the action of the \Pf{} functor on the morphisms of the category $\textbf{Conp}$.
|
||||
|
||||
Proof substitution of proofs is simple to define, as we only get down the proof until we find a proof variable, in which case we replace it with the proof in the substitution, as we did for term-substitutions and formulæ.
|
||||
|
||||
Again, we have defined \AgdaFunction{wk${}_p$} and \AgdaFunction{lf${}_p$}. The former will add an unused proof variable (an assumption) to a substitution, and the latter adds a formula to the goal which is proven using an assumption.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-26.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
This definition of proof substitutions allows us to define the categorical operators for proof substitutions.
|
||||
|
||||
Of course, we have to show that the categorical laws apply to them, that \agdaSubst{$\sigma_p$} respects them, as we did for the \AgdaInductiveConstructor{Subt}'s laws.
|
||||
|
||||
The proofs of these laws contain a lot of transports which make them not very readable. This transport issue is explained in \autoref{sec:transport-hell}.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/FFOL-I-27.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
The last step is to merge our two kinds of contexts and substitutions to match the algebra.
|
||||
|
||||
For contexts, we simply have a record type containing both a \AgdaDatatype{Cont} and a \AgdaDatatype{Conp} that depends on it. But for substitutions, we defined \AgdaDatatype{Subp} to only describe substitutions between \AgdaDatatype{Conp}{\footnotesize s} with \emph{the same \AgdaDatatype{Cont}}. Our solution is to understand global substitutions as a sequence of two substitutions, first on terms, and then on proofs. That's why in the definition below, the \enquote{proof} part of the substitution can only be applied to proofs on $\Delta_p [t]$, i.e. proofs that have already been term-substituted by the \enquote{term} part of the substitution. The definition of the global proof substitution matching the shape given to the algebra is given after, and you can see that substitutions work exactly as described, first, the proof and everything inside is substituted using the \enquote{term} part of the substitution, and only after that the \enquote{proof} part of the substitution is applied.
|
||||
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-I-28.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-30.tex}
|
||||
|
||||
\agdasep
|
||||
|
||||
\begin{code}
|
||||
\>[4]\AgdaOperator{\AgdaField{pf\AgdaSpace{}[\AgdaSpace{}\textsigma\AgdaSpace{}]p}}\AgdaSpace{}%
|
||||
\AgdaSymbol{=}\AgdaSpace{}%
|
||||
\AgdaSymbol{(}pf\AgdaSpace{}%
|
||||
\AgdaOperator{\AgdaFunction{[}}\AgdaSpace{}%
|
||||
\AgdaField{Sub.t}\AgdaSpace{}%
|
||||
\textsigma\AgdaSpace{}%
|
||||
\AgdaOperator{\AgdaFunction{]pₜ}}\AgdaSymbol{)}\AgdaSpace{}%
|
||||
\AgdaOperator{\AgdaFunction{[}}\AgdaSpace{}%
|
||||
\AgdaField{Sub.p}\AgdaSpace{}%
|
||||
\textsigma\AgdaSpace{}%
|
||||
\AgdaOperator{\AgdaFunction{]p}}\<%
|
||||
\end{code}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
And we can finally define our categorical operators for the merged version. They are only a concatenation of the previously defined operators, so no hard logic here. Those constructions are followed by the equations needed for the algebra.
|
||||
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-I-32.tex}
|
||||
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-33.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
And we now have a working syntax for Predicate Logic. Unfortunately, I did not yet prove that it was indeed an initial model, because for the proof i need to work with a lot of transport hell, which is not technically hard to solve but takes a lot of time.
|
||||
|
||||
\subsection{Transport Hell}
|
||||
|
||||
\label{sec:transport-hell}
|
||||
|
||||
For you to understand the code, we will now explain what are transports. I'll do this with the example of the definition of \AgdaFunction{id} in the Finitary First Order Logic syntax.
|
||||
|
||||
To construct it, we use \AgdaFunction{idₜ} and \AgdaFunction{id${}ₚ$}, merged with the constructor \AgdaInductiveConstructor{sub}. Here are the types of the different elements in an array.
|
||||
|
||||
\begin{center}
|
||||
\renewcommand{\arraystretch}{1.2}
|
||||
\begin{tabular}{l|l}
|
||||
\AgdaFunction{id} & \AgdaRecord{Sub} (\AgdaInductiveConstructor{con} Γₜ Γₚ) (\AgdaInductiveConstructor{con} Γₜ Γₚ) \\\hline
|
||||
\AgdaFunction{idₜ} & \AgdaDatatype{Subt} Γₜ Γₜ \\
|
||||
\AgdaFunction{idₚ} & \AgdaDatatype{Subp} Γₚ Γₚ \\\hline
|
||||
\AgdaInductiveConstructor{sub} & (σ : \AgdaDatatype{Subt} Γₜ Δₜ) \\
|
||||
& \AgdaSymbol{$\rightarrow$} \AgdaDatatype{Subp} Γₚ (Δₚ[σ]c) \\
|
||||
& \AgdaSymbol{$\rightarrow$} \AgdaRecord{Sub} (\AgdaInductiveConstructor{con} Γₜ Γₚ) (\AgdaInductiveConstructor{con} Δₜ Δₚ) \\
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
|
||||
But if we try to construct \AgdaFunction{id}, then we will eventually end up with the following goal:
|
||||
|
||||
\begin{center}
|
||||
\AgdaFunction{id} = \AgdaInductiveConstructor{sub} \AgdaFunction{idₜ} \textbf{?} \quad\textit{with}\qquad \textbf{?} : \AgdaDatatype{Subp} Γₚ (Γₚ[\AgdaFunction{idₜ}]c)
|
||||
\end{center}
|
||||
|
||||
But then Agda will complain if we give it as a goal the expression \enquote{\AgdaFunction{idₚ}}. Indeed, it is not trivial for them that \AgdaDatatype{Subp} Γₚ (Γₚ[\AgdaFunction{idₜ}]c) is the same as \AgdaDatatype{Subp} Γₚ Γₚ. Even if we can easily prove the equality between those two elements of \AgdaPrimitive{Prop} (the proof of the equality is derived from the fact that Conp is a functor from $\textbf{Cont}$ to $\bSet$, and therefore it has to respect the identity of $\textbf{Conp}$).
|
||||
|
||||
That's where transport comes in. The function name is \enquote{subst} but we call it \emph{transport} to avoid confusion with \AgdaDatatype{Sub}. Its definition is as follows:
|
||||
|
||||
\begin{center}
|
||||
\AgdaFunction{subst} : \{A : \AgdaPrimitive{Set}\}(P : A → \AgdaPrimitive{Prop})\{a a' : A\} → a ≡ a' → P a → P a'
|
||||
\end{center}
|
||||
|
||||
This is exactly the thing that will solve our problem. With the equality between the two elements of \AgdaPrimitive{Prop}, we can now convert \AgdaFunction{idₚ} to something that will correctly match the goal required by Agda.
|
||||
|
||||
This section is called \enquote{Transport Hell} because those transports between equal sets can get annoying. In a former version of the syntax, the \AgdaDatatype{Subp} were \AgdaPrimitive{Set}s instead of \AgdaPrimitive{Prop}s. And that created a lot of equalities related to polymorphic functions (quite all \AgdaDatatype{Subp}'s related functions were then polymorphic, as they would depend on proof contexts). And to solve those equalities, you have to extract what are precisely the polymorphic functions you are working with. You can see those proofs on \href{https://github.com/MysaaJava/m1-internship/commit/2728c60633a80631ed7b61bbfae5c81a1e0e193a#diff-99bc55bebd36ad0afbae3c6448793992086091c5b6b25973f73dd779690d7dd2}{former versions of the syntax}, they are long and not very interesting (as it is mainly trying to tweak our equation so that Agda understands that two types are equal).
|
||||
|
||||
\section{Summary}
|
||||
|
||||
During this internship, I created a set of Agda definitions for different frameworks of logic. Even though this has already been done by other people, my definitions are directly derived from the SOGAT definitions. It makes the files and this report a good example of how to use SOGAT, and how to convert them into GAT.
|
||||
|
||||
We also created a proof of completeness in this layout, which shows the usefulness of the theory. I did not make the completeness proof of predicate logic, but it is the next thing that will be added to the project.
|
||||
|
||||
This project is also a great entry point to study the different ways a SOGAT can be turned into a GAT. We need further work to understand the specificities of the SOGATs used in this report that allowed us to turn them directly into strict syntaxes (it is not the case for any SOGAT, especially for those with equations). Making a formalization of this transformation for a specific class of SOGAT would be a great step forward.
|
||||
|
||||
|
||||
|
||||
\section{Bibliography}
|
||||
\begingroup
|
||||
\renewcommand{\section}[2]{}%
|
||||
\printbibliography
|
||||
\endgroup
|
||||
|
||||
\newpage
|
||||
\addappheadtotoc
|
||||
\appendix
|
||||
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
|
||||
\appendixpage
|
||||
|
||||
\section{Agda Code}
|
||||
The Agda code has been written to A4 paper and is given in the next pages
|
||||
|
||||
\end{document}
|
||||
169
report/header.tex
Normal file
169
report/header.tex
Normal file
@ -0,0 +1,169 @@
|
||||
% Loading packages
|
||||
\usepackage{autofe}
|
||||
\usepackage{hyperref}
|
||||
\hypersetup{
|
||||
colorlinks=true,
|
||||
linkcolor=blue,
|
||||
filecolor=magenta,
|
||||
urlcolor=cyan
|
||||
}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{bbm}
|
||||
\usepackage{stmaryrd}
|
||||
\usepackage[main=english]{babel}
|
||||
\usepackage{csquotes}
|
||||
\usepackage{listings}
|
||||
\usepackage{lstautogobble}
|
||||
\usepackage{svg}
|
||||
\usepackage{tikz}
|
||||
\usepackage{multirow}
|
||||
\usepackage{multicol}
|
||||
\usepackage{tcolorbox}
|
||||
\usepackage{mdframed}
|
||||
\usepackage{proof}
|
||||
\usepackage{biblatex}
|
||||
\usepackage{xparse}
|
||||
\usepackage{cprotect}
|
||||
\usepackage{titlesec}
|
||||
\usepackage{xpatch}
|
||||
\usepackage{enumitem}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{mathtools}
|
||||
\usepackage[page,header]{appendix}
|
||||
\usepackage{minitoc}
|
||||
\usepackage{mathtools}
|
||||
\usepackage{textgreek}
|
||||
\usepackage{pdfpages}
|
||||
|
||||
\usepackage[textheight=0.75\paperheight]{geometry}
|
||||
|
||||
\usepackage{csquotes}
|
||||
\usepackage[lighttt]{lmodern}
|
||||
\usetikzlibrary{shapes.geometric,positioning}
|
||||
|
||||
% Macros caractères globales
|
||||
\newcommand{\pgrph}{\P}
|
||||
\newcommand{\hsep}{\vspace{.2cm}\centerline{\rule{0.8\linewidth}{.05pt}}\vspace{.4cm}}
|
||||
\renewcommand{\P}{\mathbb{P}}
|
||||
\newcommand{\E}{\mathbb{E}}
|
||||
\newcommand{\1}{\scalebox{1.2}{$\mathbbm{1}$}}
|
||||
\newcommand{\floor}[1]{\left\lfloor#1\right\rfloor}
|
||||
\newcommand{\littleO}{o}
|
||||
\newcommand{\bigO}{\mathcal{O}}
|
||||
\newcommand{\longdash}{\:\textrm{---}\:}
|
||||
\newcommand\hole{\left[\raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}\right]}
|
||||
\newcommand\bracket[1]{\!\left[#1\right]}
|
||||
\newcommand{\ssi}{\quad\text{\underline{ssi}}\quad}
|
||||
\newcommand\eng[1]{\textit{\foreignlanguage{english}{#1}}}
|
||||
\newcommand\spacebar{\;|\;}
|
||||
\def\nDownarrow{\not\mspace{1mu}\Downarrow}
|
||||
\let\pprec\preccurlyeq
|
||||
|
||||
|
||||
% Création des environnement globaux
|
||||
\newtheorem{theorem}{Théorème}
|
||||
\newtheorem{definition}{Definition}
|
||||
\newtheorem{property}{Propriété}
|
||||
|
||||
\newcounter{rule}
|
||||
\addto\extrasfrench{%
|
||||
\renewcommand{\figureautorefname}{\textsc{Figure}}
|
||||
\renewcommand{\sectionautorefname}{Section}
|
||||
\renewcommand{\subsectionautorefname}{Sous-section}
|
||||
\renewcommand{\appendixautorefname}{Annexe}
|
||||
\renewcommand{\theoremautorefname}{Théorème}
|
||||
\providecommand\propertyautorefname{Propriété}
|
||||
\providecommand\ruleautorefname{règle}
|
||||
}
|
||||
|
||||
% Commandes logiques globales
|
||||
\newcommand{\ifnullthenelse}[3]{
|
||||
\ifnum\value{#1}=0
|
||||
#2
|
||||
\else
|
||||
#3
|
||||
\fi
|
||||
}
|
||||
|
||||
%%% Commande \newtag permettant de changer le label d'une equation
|
||||
\makeatletter
|
||||
\newcommand\newtag[2]{#1\def\@currentlabel{#1}\label{#2}}
|
||||
\makeatother
|
||||
|
||||
|
||||
% Macros caractères spécifiques au document
|
||||
\newcommand\Tm{\AgdaDatatype{Tm}}
|
||||
\newcommand\Set{\AgdaPrimitive{Set}}
|
||||
\newcommand\For{\AgdaDatatype{For}}
|
||||
\newcommand\Prop{\AgdaPrimitive{Prop}}
|
||||
\newcommand\R{\AgdaInductiveConstructor{R}}
|
||||
\newcommand\lam{\AgdaInductiveConstructor{lam}}
|
||||
\newcommand\app{\AgdaInductiveConstructor{app}}
|
||||
\newcommand\foralli{\AgdaInductiveConstructor{\ensuremath{\forall i}}}
|
||||
\newcommand\foralle{\AgdaInductiveConstructor{\ensuremath{\forall e}}}
|
||||
\newcommand\impliesAgda{\:\AgdaInductiveConstructor{\ensuremath{\implies}}\,}
|
||||
\newcommand\iotAgda{\AgdaInductiveConstructor{\ensuremath{\iota}}}
|
||||
\newcommand\forallAgda{\AgdaInductiveConstructor{\ensuremath{\forall}}}
|
||||
\newcommand\agdato{\;\AgdaSymbol{→}\;}
|
||||
\newcommand\Pf{\AgdaDatatype{Pf}}
|
||||
\newcommand\bCon{\textbf{Con}}
|
||||
\newcommand\bSet{\textbf{Set}}
|
||||
\newcommand\bProp{\textbf{Prop}}
|
||||
\newcommand\agdaSubst[1][]{\AgdaOperator{\AgdaFunction{\AgdaUnderscore{}[\AgdaUnderscore{}]#1}}}
|
||||
|
||||
% Agda Config
|
||||
\usepackage{agda}
|
||||
\let\AgdaPrimitiveZ\AgdaPrimitive
|
||||
\renewcommand\AgdaPrimitive[1]{\AgdaPrimitiveZ{\textbf{#1}}}
|
||||
|
||||
\AgdaNoSpaceAroundCode{}
|
||||
\def\agdasep{\begin{center}\vspace{-2.5ex}\rule{0.9\linewidth}{0.4pt}\vspace{-1ex}\end{center}}
|
||||
\usepackage{newunicodechar}
|
||||
\newunicodechar{∘}{\ensuremath{\mathnormal{\circ}}}
|
||||
\newunicodechar{≡}{\ensuremath{\mathnormal{\equiv}}}
|
||||
\newunicodechar{◇}{\ensuremath{\mathnormal{\diamond}}}
|
||||
\newunicodechar{Γ}{\textGamma}
|
||||
\newunicodechar{Δ}{\textDelta}
|
||||
\newunicodechar{Ξ}{\textXi}
|
||||
\newunicodechar{α}{\textalpha}
|
||||
\newunicodechar{β}{\textbeta}
|
||||
\newunicodechar{γ}{\textgamma}
|
||||
\newunicodechar{δ}{\textdelta}
|
||||
\newunicodechar{ε}{\textvarepsilon}
|
||||
\newunicodechar{σ}{\textsigma}
|
||||
\newunicodechar{ι}{\textiota}
|
||||
\newunicodechar{π}{\textpi}
|
||||
\newunicodechar{λ}{\textlambda}
|
||||
\newunicodechar{ℓ}{\ensuremath{\ell}}
|
||||
\newunicodechar{▹}{\ensuremath{\mathnormal{\triangleright}}}
|
||||
\newunicodechar{⊢}{\ensuremath{\mathnormal{\vdash}}}
|
||||
\newunicodechar{⇒}{\ensuremath{\mathnormal{\Rightarrow}}}
|
||||
\newunicodechar{∀}{\ensuremath{\mathnormal{\forall}}}
|
||||
\newunicodechar{≈}{\ensuremath{\mathnormal{\approx}}}
|
||||
\newunicodechar{⁺}{\ensuremath{{}^+}}
|
||||
\newunicodechar{¹}{\ensuremath{{}^1}}
|
||||
\newunicodechar{²}{\ensuremath{{}^2}}
|
||||
\newunicodechar{ₜ}{\ensuremath{{}_\text{t}}}
|
||||
\newunicodechar{ₚ}{\ensuremath{{}_\text{p}}}
|
||||
\newunicodechar{⁰}{\ensuremath{{}^0}}
|
||||
|
||||
|
||||
\newcommand\agda[1]{
|
||||
\small
|
||||
\begin{code}
|
||||
\input{#1}
|
||||
\end{code}
|
||||
}
|
||||
% Création des environnements spécifiques au document
|
||||
|
||||
|
||||
%%% Subparaghaphs box
|
||||
\newtcbox{\subparaghaphbox}{nobeforeafter,tcbox raise base, arc=9pt, outer arc=9pt, boxsep=2pt,left=2pt,right=2pt,top=2pt,bottom=2pt,boxrule=1pt,colback=white!85!orange}
|
||||
\newcommand{\subparaghaphboxedcontent}[1]{\subparaghaphbox{#1}\newline}
|
||||
%\titleclass{\mathcases}{straight}[\subparagraph]
|
||||
\titleformat{\subparagraph}[runin]{\normalfont\normalsize\bfseries}{}{0em}{\subparaghaphboxedcontent}
|
||||
\titlespacing*{\subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0.5em}
|
||||
|
||||
|
||||
\addbibresource{Bilibibio.bib}
|
||||
33
stripAgda.awk
Normal file
33
stripAgda.awk
Normal file
@ -0,0 +1,33 @@
|
||||
BEGIN {
|
||||
b=1
|
||||
}
|
||||
/\\>\[2\]\\AgdaComment{--\\#}\\<%/ {
|
||||
b=2
|
||||
}
|
||||
/^\\\\\[\\AgdaEmptyExtraSkip\]%$/ {
|
||||
agg=agg""((agg=="")?"":"\n")""$0
|
||||
b=0
|
||||
}
|
||||
/^%$/ {
|
||||
agg=agg""((agg=="")?"":"\n")""$0
|
||||
b=0
|
||||
}
|
||||
/^\\\\$/ {
|
||||
agg=agg""((agg=="")?"":"\n")""((b==2)?"":$0)
|
||||
b=0
|
||||
}
|
||||
/^\\>\[0\]\\<%$/ {
|
||||
agg=agg""((agg=="")?"":"\n")""$0
|
||||
b=0
|
||||
}
|
||||
// {
|
||||
if (b==1){
|
||||
if(agg!=""){
|
||||
print agg
|
||||
}
|
||||
agg=""
|
||||
print $0
|
||||
}else if (b==0){
|
||||
b=1
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user