Advance on the report
This commit is contained in:
parent
841f6e96f1
commit
360dd1823c
@ -78,6 +78,7 @@ module FFOL where
|
||||
-- → πₚ² (σ ,ₚ prf) ≡ prf
|
||||
,ₚ∘ : {Γ Δ Ξ : Con}{σ : Sub Γ Ξ}{δ : Sub Δ Γ}{F : For Ξ}{prf : Γ ⊢ (F [ σ ]f)}
|
||||
→ (σ ,ₚ prf) ∘ δ ≡ (σ ∘ δ) ,ₚ (substP (λ F → Δ ⊢ F) (≡sym []f-∘) (prf [ δ ]p))
|
||||
--#
|
||||
|
||||
|
||||
{-- FORMULAE CONSTRUCTORS --}
|
||||
|
||||
@ -62,11 +62,12 @@ module IFOL2 where
|
||||
[]f-⇒ : {Γ Δ : Con} → {F G : For Γ} → {σ : Sub Δ Γ}
|
||||
→ (F ⇒ G) [ σ ]f ≡ (F [ σ ]f) ⇒ (G [ σ ]f)
|
||||
|
||||
-- Forall
|
||||
--# 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
|
||||
|
||||
@ -74,9 +75,10 @@ module IFOL2 where
|
||||
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 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
|
||||
|
||||
@ -9,10 +9,12 @@ module IFOLInitial (TM : Set) where
|
||||
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
|
||||
@ -25,12 +27,14 @@ module IFOLInitial (TM : Set) where
|
||||
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
|
||||
|
||||
20
Makefile
20
Makefile
@ -8,25 +8,23 @@ endef
|
||||
|
||||
all: report/build/M1Report.pdf
|
||||
|
||||
latex/FFOL.tex: FFOL.lagda
|
||||
agda --latex $<
|
||||
cp latex/agda.sty report/agda.sty
|
||||
latex/ZOL.tex: ZOL2.lagda
|
||||
agda --latex $<
|
||||
cp latex/agda.sty report/agda.sty
|
||||
mv latex/ZOL2.tex latex/ZOL.tex
|
||||
latex/FFOLInitial.tex: FFOLInitial.lagda
|
||||
latex/%.tex: %.lagda
|
||||
agda --latex --allow-unsolved-metas $<
|
||||
cp latex/agda.sty report/agda.sty
|
||||
|
||||
report/build/M1Report.pdf: agda-tex-FFOL agda-tex-FIni agda-tex-ZOL
|
||||
$(cd report/; latexmk -pdf -xelatex -silent -shell-escape -outdir=build/ -synctex=1 "M1Report")
|
||||
|
||||
agda-tex: latex/ZOL.tex latex/FFOLInitial.tex latex/FFOL.tex
|
||||
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/ZOL.tex","report/agda/ZOL-",".tex")
|
||||
$(call split,"latex/FFOLInitial.tex","report/agda/FFOL-I-",".tex")
|
||||
$(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")
|
||||
|
||||
.PHONY: clean agda-tex agda-tex-FFOL agda-tex-ZOL agda-tex-FIni
|
||||
clean:
|
||||
|
||||
27
ZOL2.lagda
27
ZOL2.lagda
@ -53,7 +53,7 @@ module ZOL2 where
|
||||
πₚ¹ : {Γ Δ : 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
|
||||
--# 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) ≡ σ
|
||||
@ -62,7 +62,9 @@ module ZOL2 where
|
||||
--,ₚ∘ : {Γ Δ Ξ : 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 ≡ ι
|
||||
@ -85,26 +87,33 @@ module ZOL2 where
|
||||
record Mapping (S : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}) (D : ZOL {ℓ¹'} {ℓ²'} {ℓ³'} {ℓ⁴'}) : Set (lsuc (ℓ¹ ⊔ ℓ² ⊔ ℓ³ ⊔ ℓ⁴ ⊔ ℓ¹' ⊔ ℓ²' ⊔ ℓ³' ⊔ ℓ⁴')) where
|
||||
field
|
||||
|
||||
-- We first make the base category with its final object
|
||||
--#
|
||||
mCon : (ZOL.Con S) → (ZOL.Con D)
|
||||
mSub : {Δ : (ZOL.Con S)}{Γ : (ZOL.Con S)} → (ZOL.Sub S Δ Γ) → (ZOL.Sub D (mCon Δ) (mCon Γ))
|
||||
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)
|
||||
|
||||
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
|
||||
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[]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)
|
||||
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
|
||||
|
||||
@ -9,6 +9,7 @@ module ZOLInitial where
|
||||
open import Agda.Primitive
|
||||
open import ListUtil
|
||||
|
||||
--#
|
||||
data For : Set where
|
||||
ι : For
|
||||
_⇒_ : For → For → For
|
||||
@ -17,10 +18,12 @@ module ZOLInitial 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
|
||||
@ -29,10 +32,12 @@ module ZOLInitial where
|
||||
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)
|
||||
@ -41,15 +46,18 @@ module ZOLInitial where
|
||||
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
|
||||
@ -57,6 +65,7 @@ module ZOLInitial where
|
||||
id : Sub Γ Γ
|
||||
id = SubR idR
|
||||
|
||||
--#
|
||||
_[_]pvr : PfVar Γ A → Ren Δ Γ → PfVar Δ A
|
||||
pvzero [ _ ,ₚR pv ]pvr = pv
|
||||
pvnext pv [ σ ,ₚR _ ]pvr = pv [ σ ]pvr
|
||||
@ -69,17 +78,19 @@ module ZOLInitial where
|
||||
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)
|
||||
|
||||
|
||||
--#
|
||||
|
||||
|
||||
|
||||
@ -111,6 +122,7 @@ module ZOLInitial where
|
||||
|
||||
module InitialMorphism (M : ZOL {ℓ¹} {ℓ²} {ℓ³} {ℓ⁴}) where
|
||||
|
||||
--#
|
||||
mCon : Con → (ZOL.Con M)
|
||||
mFor : {Γ : Con} → For → (ZOL.For M (mCon Γ))
|
||||
|
||||
@ -119,6 +131,7 @@ module ZOLInitial where
|
||||
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)
|
||||
|
||||
@ -34,12 +34,12 @@
|
||||
\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.
|
||||
\subsection{Structure of this report}
|
||||
\section{A first account of Completeness and Normalization}
|
||||
\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 (refered as Zero Order Logic or ZOL in the code). We also have only one axiom rule for creating formulæ: the $\iota$ 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.
|
||||
The first and most simple logical framework we can work with is that of Propositional Logic (refered 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 $\iota$ 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.
|
||||
|
||||
In order to state all the definition, 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}.
|
||||
In order 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}
|
||||
@ -59,173 +59,307 @@
|
||||
\label{fig:zol-sogat}
|
||||
\end{figure}
|
||||
|
||||
We can see that in this Sogat, we have two sorts (\For and \Pf), each of which have two constructors. Althrough Sogat can have equations in them, i won't use any in that report.
|
||||
We can see that in this Sogat, we have two sorts ($\For$ and $\Pf$), each of which have two constructors. Although SOGATs can have equations in them, i won't use any in that report.
|
||||
|
||||
A keen eye may have seen that there is 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. These arrow means that \Pf should be \emph{locally representable}. It basically means that we have to use \emph{proof variables} to implement this Sogat.
|
||||
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. These arrow means that \Pf should be \emph{locally representable}. It basically means that we have to use \emph{proof variables} to implement this SOGAT.
|
||||
|
||||
\subsection{From SOGAT to GAT}
|
||||
\subsection{From a SOGAT to GAT}
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-4.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
Unfortunately, Agda cannot understand SOGATs directly (yet). So we have to convert this SOGAT into a 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.
|
||||
|
||||
\subsection{Normalization for Infinitary First Order Logic}
|
||||
\begin{figure}
|
||||
You can see that the equations for the category ($\circ$-associativity, identity to the right and to the left) have not been written down. This is because substitutions are defined as \AgdaPrimitive{Prop}s and not \AgdaPrimitive{Set}s. 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 equality 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 \AgdaPrimitive{Prop} instead of \AgdaPrimitive{Set} will be used through the report, and it will allow us to write down (and prove) a lot less equations.
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-1.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
Once we have our base category, we can start to describe the sorts ze have in our SOGAT. Every sort from the SOGAT will be translated into a functor from our base category to \AgdaPrimitive{Set} or \AgdaPrimitive{Prop}. Therefore, we have to define an action on objects, an action on morphisms (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 i said before, this translates into the fact that we have \emph{proof variables}. Therefore, we should be able to move from a context to another context in which we added a variable. We call that \emph{context extension}. For proof-variables, this context extension takes a parameter, as the proof-variables have a \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, then we are only adding 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 $(\pi_p¹ , \pi_p²)$ and $,_p$ are reciprocal, plus one equality saying that thet 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-5.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 respects 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 $\AgdaField{lam}$ constructor from the SOGAT. Well, to translate this \emph{locally representable application}, we only transform the parameter of the arrow into a context extension of the appropriate type. Therefore, a function $\Pf A \rightarrow^+ \Pf B$ only becames a proof $\Pf (\Gamma \triangleright_p A)\; B$ (except that we have to transform B that is a $\For\;\Gamma$ into a $\For\;(\Gamma \triangleright_p A)$, and for that, we use the \emph{weakening} substitution $\text{\AgdaField{$\pi_p^1$}}\;\text{\AgdaField{id}}\;:\;\AgdaField{Sub}\;\Gamma\;(\Gamma \triangleright_p X)$ for any Γ-formula $X$
|
||||
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-8.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-9.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-11.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
We now have completed our definition of a model for Propositional Logic, in the SOGAT setting. We can also 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. A lot of those equation are not written because \AgdaField{Pf} and \AgdaField{Sub} are in \AgdaPrimitive{Prop}.
|
||||
\begin{tcolorbox}
|
||||
\agda{agda/ZOL-13.tex}
|
||||
\agdasep
|
||||
\agda{agda/ZOL-15.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} syntax for this class of models. It means, 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 on every equations of the GAT. But this is not really interesting, as the defined model would not be \emph{strict}, meaning that all of the equations are definitional. Having only strict definition for objects allows us to study completeness in a much better framework, as we can, for example, do an induction on the types as they are defined in the syntax.
|
||||
|
||||
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 more 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 Formula doesn't depend on contexts. One can understand it as \enquote{a formula is the same whichever are 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 awfully complicated.
|
||||
|
||||
Contexts also only have two constructors in the GAT, the terminal object of the category or created from a proof context extension.
|
||||
|
||||
Our 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 \AgdaOperator{Sub} separately (as in the algebra, the \AgdaField{lam} constructor refers to \AgdaOperator{\_[\_]f}, which is removed when formulæ doesn't 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 definition are put one next to the other, and we can see that when \AgdaDatatype{Sub} are a list of complete proofs, \AgdaDatatype{Ren} are only a list of Proof variables (or direct proof 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}
|
||||
\agda{agda/ZOL-I-7.tex}
|
||||
\end{tcolorbox}
|
||||
|
||||
Because we need to refer to \AgdaField{id}, and more precisely to \AgdaField{$\pi_p^1 id$} in the notion of proof substitution, we first define proof \emph{renamings} so we can define \AgdaOperator{wkSub} (which is the same as \AgdaField{$\pi_p^1 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 only 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 equation can be directly understood by Agda (\AgdaInductiveConstructor{refl} is enough proof)
|
||||
|
||||
I won't dive into the contsruction of the initial morphism and the proof that it is unique, because it is a bit ugly because of some \emph{transport hell} (see \autoref{sec:transport-hell} for an explanation of the issue).
|
||||
|
||||
Still, i give you the construction of the Con and For mappings, as they show the basic idea of these construction. The idea is simple, you pattern-match against the datatype definition of your Sort in your syntax, and for each constructor, you 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 model (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.
|
||||
|
||||
In order to state this into our categorical layout, we will use an other mapping going from the initial model to our Kripke model that is called the \emph{Yoneda mapping}. TODO explain what is the yoneda mapping, and why it does a completeness proof.
|
||||
|
||||
\begin{center}
|
||||
\begin{tikzpicture}[thick, scale=5]
|
||||
\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] {$u$} (Y0);
|
||||
\node at (+.15,+.25) (I1) {};
|
||||
\node at (+.15,-.25) (Y1) {};
|
||||
\draw[->,double distance=.4ex] (Y1) to node[midway,right,inner sep=1ex] {$q$} (I1);
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
\section{First order logic (or Predicate Logic)}
|
||||
|
||||
In this part, we will try to implemeent 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 relation and function symbols don't add a lot of new interesting content, but makes everything less readable and more complex to use.
|
||||
|
||||
\subsection{Infinitary First Order Logic}
|
||||
|
||||
A really naive version of first order logic can be done by implementing $\forall$ as a 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 make this 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{array}{lcl}
|
||||
\For & : & \Set \\
|
||||
- \implies - & : & \For \rightarrow \For \rightarrow \For\\
|
||||
\forall & : & (\operatorname{TM} \rightarrow \For) \rightarrow \For \\
|
||||
\R & : & \operatorname{TM} \rightarrow \operatorname{TM} \rightarrow \For\\
|
||||
\\
|
||||
\Pf & : & \For \rightarrow \Prop^+ \\
|
||||
\lam & : & (\Pf A \rightarrow^+ \Pf B) \rightarrow \Pf (A \implies B)\\
|
||||
\app & : & \Pf (A \implies B) \rightarrow (\Pf A \rightarrow \Pf B)\\
|
||||
\foralli & : & (t : \operatorname{TM} \rightarrow \Pf A\;t) \rightarrow \Pf (\forall A)\\
|
||||
\foralle & : & \Pf (\forall A) \rightarrow (t : \operatorname{TM}) \rightarrow \Pf (A\;t)\\
|
||||
\end{array}
|
||||
\]
|
||||
\end{tcolorbox}
|
||||
\caption{IFOL Sogat Presentation}
|
||||
\label{fig:ifol-sogat}
|
||||
\end{figure}
|
||||
|
||||
Therefore, the GAT we deduce from this is not really harder, we only add the operators as we described them in the SOGAT, while still adding the 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 $\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 really 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.
|
||||
|
||||
\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 Kripke interpretation of this external forall, which is very natural, and we also need to add the following lines to our $u$ and $q$ definition so we get all cases done.
|
||||
|
||||
\begin{tcolorbox}
|
||||
TODO add the lines described above, need to refer to what has been said (and shown) for ZOL completeness
|
||||
%\agda{TODO}
|
||||
\end{tcolorbox}
|
||||
|
||||
\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 \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 $\forall i$ now has a strictly positive arrow, because Term are not extrenal anymore.
|
||||
|
||||
\begin{figure}
|
||||
\begin{tcolorbox}
|
||||
\[
|
||||
\begin{array}{lcl}
|
||||
\Tm & : & \Set^+ \\
|
||||
\\
|
||||
\For & : & \Set \\
|
||||
- \implies - & : & \For \rightarrow \For \rightarrow \For\\
|
||||
\forall & : & (\operatorname{TM} \rightarrow \For) \rightarrow \For \\
|
||||
\R & : & \operatorname{TM} \rightarrow \operatorname{TM} \rightarrow \For\\
|
||||
\forall & : & (\Tm \rightarrow \For) \rightarrow \For \\
|
||||
\R & : & \Tm \rightarrow \Tm \rightarrow \For\\
|
||||
\\
|
||||
\Pf & : & \For \rightarrow \Prop^+ \\
|
||||
\lam & : & (\Pf A \rightarrow^+ \Pf B) \rightarrow \Pf (A \implies B)\\
|
||||
\app & : & \Pf (A \implies B) \rightarrow (\Pf A \rightarrow \Pf B)\\
|
||||
\foralli & : & (t : \operatorname{TM} \rightarrow \Pf A\;t) \rightarrow \Pf (\forall A)\\
|
||||
\foralle & : & \Pf (\forall A) \rightarrow (t : \operatorname{TM}) \rightarrow \Pf (A\;t)\\
|
||||
\foralli & : & (t : \Tm \rightarrow^+ \Pf A\;t) \rightarrow \Pf (\forall A)\\
|
||||
\foralle & : & \Pf (\forall A) \rightarrow (t : \Tm) \rightarrow \Pf (A\;t)\\
|
||||
\end{array}
|
||||
\]
|
||||
\end{tcolorbox}
|
||||
\caption{ZOL Sogat Presentation}
|
||||
\label{fig:ifol-sogat}
|
||||
\end{figure}
|
||||
\subsection{Merging the two proofs}
|
||||
\section{Predicate Logic}
|
||||
\subsection{SOGAT Presentation of Predicate Logic}
|
||||
\caption{FFOL Sogat Presentation}
|
||||
\label{fig:ffol-sogat}
|
||||
\end{figure}
|
||||
|
||||
In order to find all the definitions, functions and more importantly, all the equations that a model of Predicate Logic has to verify, Ambrus gave me a Second Order Generalized Algebraic Theory (SOGAT) of the models. It goes as described in \autoref{fig:ffol-sogat}.
|
||||
\subsubsection{Making a GAT out of it}
|
||||
|
||||
Why is this definition \enquote{Second Order} ? That's because some definitions are not strictly positive. These are the definitions of $\lam$ and $\foralli$. This SOGAT definition makes sense because of the ${}^+$ in $\Tm$ and $\Pf$ definitions, that indicates that those two objects should be \emph{locally representable}. It means that one can use \emph{term variables} and \emph{proof variables}.
|
||||
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 the categorical equations.
|
||||
|
||||
We can notice that there is no equations in this SOGAT.
|
||||
|
||||
\begin{figure}
|
||||
\begin{tcolorbox}
|
||||
\[
|
||||
\begin{array}{lcl}
|
||||
\Tm & : & \Set^+ \\
|
||||
\\
|
||||
\For & : & \Set \\
|
||||
- \implies - & : & \For \rightarrow \For \rightarrow \For\\
|
||||
\forall & : & (\Tm \rightarrow \For) \rightarrow \For \\
|
||||
\R & : & \Tm \rightarrow \Tm \rightarrow \For\\
|
||||
\\
|
||||
\Pf & : & \For \rightarrow \Prop^+ \\
|
||||
\lam & : & (\Pf A \rightarrow^+ \Pf B) \rightarrow \Pf (A \implies B)\\
|
||||
\app & : & \Pf (A \implies B) \rightarrow (\Pf A \rightarrow \Pf B)\\
|
||||
\foralli & : & (t : \Tm \rightarrow^+ A\;t) \rightarrow \Pf (\forall A)\\
|
||||
\foralle & : & \Pf (\forall A) \rightarrow (t : \Tm) \rightarrow \Pf (A\;t)\\
|
||||
\end{array}
|
||||
\]
|
||||
\end{tcolorbox}
|
||||
\caption{FFOL Sogat Presentation}
|
||||
\label{fig:ffol-sogat}
|
||||
\end{figure}
|
||||
|
||||
\subsection{Turning a SOGAT Presentation into a GAT}
|
||||
|
||||
But now, we want to encode in Agda a Sogat Algebra, which we can't do (for now), as Agda can only understand simple Generalized Algebraic Theories (or GAT).
|
||||
|
||||
In order to break this apparent strict positivity, we will translate every object of the SOGAT into a functor from a context category called $\bCon$. This context category shall have an initial object and two endo-mappings called \emph{context extensions}. They can be understood as adding to a context a proof variable or a term variable. We will also call \emph{substitutions} morphisms from the $\bCon$ category, and for a morphism $\sigma$ and a functor $F$, we will denote $\_\left[\sigma\right]$ the action of the functor on the morphism $\sigma$.
|
||||
|
||||
We will first define this category, its initial object, and every rule that these components should obey.
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-1.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
We can now define terms, formulæ and proofs, which are functors from $\bCon$ to $\bSet$ (and proofs are a more complex functor from $\bCon$ to XXXXX). For each of them, we define the action of the functors on morphisms, and we also write the equalities that describe the functionality.
|
||||
We also have to add a term extension operator like we did for formula extension. One difference is that this new kind of extension has no parameter. However, it makes it so \AgdaField{Sub} have to be in \AgdaPrimitive{Set}, and so we have to add a lot of equation concerning the two term extensions.
|
||||
|
||||
\def\agdasep{\begin{center}\vspace{-2.5ex}\rule{0.9\linewidth}{0.4pt}\vspace{-1ex}\end{center}}
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-2.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-4.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-5.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
Then we define our context extensions. We also have constructors for substitutions to extended contexts. This constructor should work as a product, which means that we have two \enquote{projections} that can revert the mapping. The constructor should finally be consistent with $\circ$.
|
||||
|
||||
Please ignore the \verb*|substP| for now, this notion will be explained in \autoref{sec:transport-hell}.
|
||||
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 ignore the two firsts.
|
||||
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-3.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agdasep
|
||||
\agda{agda/FFOL-7.tex}
|
||||
\agda{agda/FFOL-8.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
Finally, with those context extensions, we can define our operators on functions and proofs. Those operators have to commute with the images of substitutions (the equations are unneeded for proof operators, as they are in prop).
|
||||
|
||||
We can take a closer look at where our apparently strictly positive application should be ($\lam$ and $\foralli$). We can see that instead of an application, we only have a formula (or a proof) that goes from an extended context to a base contexts. This \enquote{removal} of the term variable stands for the strictly positive function that would have taken a term/proof as a parameter.
|
||||
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 $\forall i$ in which the strictly positive application become a proof from a term-extended context, and for $\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-9.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-10.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-11.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-13.tex}
|
||||
\agda{agda/FFOL-2.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-14.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
We now have a generalized algebraic theory that describes all the models of Predicate logic. A model is indeed an implementation of the agda record described above.
|
||||
We now have a complete GAT for Predicate logic, and we already see that we have a lot more equations to prove.
|
||||
|
||||
\section{Implementing the Syntax}
|
||||
\subsection{Finding a Syntax for First Order Logic}
|
||||
|
||||
We will now try de define a strict syntax for that model. This means that we want to define \enquote{physically} a model that will be as tiny as possible.
|
||||
Even though this new SOGAT don't seem a lot more complex than the one for IFOL, there is three reasons why making the Syntax will be much harder.
|
||||
|
||||
\subsection{Separated Contexts}
|
||||
\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 have anothe parrallel way of extending contexts which squares the difficulty
|
||||
\item Formulæ now have to depend on contexts too.
|
||||
\end{enumerate}
|
||||
|
||||
A first intuition to help us construct this syntax is that we can split the $\bCon$ category in two. A first part will be related to term-extensions and the second part will be related to proof-extensions.
|
||||
However, we can still do something that simplifies greatly the making of the syntax. We can split the $\bCon$ category in two. A first part will be related to term-extensions and the second part will be related to proof-extensions.
|
||||
|
||||
One difficulty is that those two parts are not intependent. Indeed, a proof-extension related context (or \emph{proof context}) will depend on formulæ, that will depend on term-extension related contexts (or \emph{term contexts}).
|
||||
The difficulty is that those two parts are not independent. Indeed, a proof-extension related context (or \emph{proof context}) will depend on formulæ, that 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, it is isomorphic to Nat).
|
||||
|
||||
So, we first define the term contexts, which simply describes how many terms they are in the context (therefore, it is isomorphic to Nat).
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-I-1.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
Then, we can define terms (which can only be term variables in our simplified version), and formulæ (with only one binary relation). They are both indexed only on a term context, and we will need make them $\bCon \rightarrow \bSet$ rather than $\textbf{Cont} \rightarrow \bSet$. But this will be only a trivial extraction of the $\textbf{Cont}$ inside the $\bCon$, as we can notice that the terms and formulæ defined by a context doesn't depend on the proof variables available. We simply give the constructors described in the algebra.
|
||||
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æ 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 term substitutions. The algebra gives us two ways of constructing them: with $,_t$ and as a morphism from the initial object. That's how we make our constructor The two projections $\pi_t^1$ and $\pi_t^2$ are then simply obtained by destroying the $,_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 now can define \textbf{term} substitutions. The algebra gives us two ways of constructing them: with $,_t$ and as a morphism from the initial object, like we did for Propositional Logic. That's how we make our constructor The two projections $\pi_t^1$ and $\pi_t^2$ are then simply obtained by destroying the $,_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 really 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 is, the $id_t$ and $\circ_t$ operators, and we obviously have to show their three categorical laws.
|
||||
We also define the categorical constructors for the $\textbf{Cont}$ category, that is, the $id_t$ and $\circ_t$ operators, and we obviously 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} (but we will surely use them later).
|
||||
|
||||
We finally have to show the functorality of $\_\left[\_\right]\!t$ and $\_\left[\_\right]\!f$ i.e. that they do nothing on identity and that applying two substitutions one after the other is like applying their composition.
|
||||
We also show the functorality of $\_\left[\_\right]\!t$ and $\_\left[\_\right]\!f$. You can see we use some helper functions that are called $\operatorname{wk}_t$ and $\operatorname{lf}_t$. Those stands for weakening and lifting. I don't show their definitions here, because they are only helper functions, but $\operatorname{wk}_t$ means that from something going from a context $\Gamma$, we create something going from the context $\Gamma \triangleright_t$ that does not uses the added variable. $\operatorname{lf}_t$ means that we add one variable in the source, one variable in the goal, and that this variable is mapped to itself.
|
||||
|
||||
You can see we use some helper functions that are called $\operatorname{wk}_t$ and $\operatorname{lf}_t$. Those stands for weakening and lifting. I don't show their definitions here, because they are only helper functions, but $\operatorname{wk}_t$ means that from something going from a context $\Gamma$, we create something going from the context $\Gamma \triangleright_t$ that does not uses the added variable. $\operatorname{lf}_t$ means that we add one variable in the source, one variable in the goal, and that this variable is mapped to itself.
|
||||
I did not need renamings this time to define them because i don't have any term constructor aside from term variables.
|
||||
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-I-5.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-7.tex}
|
||||
@ -233,88 +367,69 @@
|
||||
\agda{agda/FFOL-I-9.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-10.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
We can now start creating the other category. For that, we can define the base set of the category like 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 $\operatorname{Conp}$ on $\operatorname{Cont}$, because formula is defined in conp.
|
||||
We can now start creating the other category. For that, we can define the base set of the category like 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 $\operatorname{Conp}$ on $\operatorname{Cont}$, because formulæ are defined in \AgdaDatatype{Cont}.
|
||||
|
||||
This new $\textbf{Conp}$ category is in fact a functor from $\textbf{Cont}$ to $\bSet$. So we have to define its action on $\textbf{Cont}$'s morphisms. And we also have to proove that this action respects the functorality of $\operatorname{Conp}$.
|
||||
|
||||
We will finally create another operator on $\textbf{Conp}$: $\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 $\operatorname{wk}_t \operatorname{id}_t$). It can be understood as the action of the general $\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. As we are in the syntax, the only constructors for proofs will be those defined in the algebra, plus proof variables. These definitions are pretty straightforward as they are directly induced from the algebra. 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.
|
||||
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 Pf is a functor that is indexed by $\textbf{Cont}$). Terms substitutions does 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 Δ_t\;Δ_p\;A$ to $\Pf Γ_t\;Δ_p[σ]\; A[σ]$.
|
||||
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-I-18.tex}
|
||||
\agdasep
|
||||
\agda{agda/FFOL-I-19.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
Before we can define proof substitutions, we need to define a weaker version of them, that are called \emph{renamings}. A renaming from a proof context $Γ_p$ to a proof context $Δ_p$ that have the same term-context, is a way of re-ordering, duplicating or deleting the proofs contained inside of $Δ_p$. If we were to understand proof contexts as list of formulæ, then a renaming from $Γ_p$ to $Δ_p$ would be a witness that each formula in $Δ_p$ is contained at least one time in $Γ_p$. That's why we use $\operatorname{PfVar}$, as $\operatorname{PfVar} Γ_t Γ_p A$ is a witness that proof-context $Γ_p$ contains the formula $A$.
|
||||
|
||||
For these renamings, we make some constructors, for example the identity renaming, or the weakening of a renaming. We will finally make a operator that weakens a proof in $Γ_p$ with a renaming from $Γ_p$ to $Δ_p$ into a proof in $Δ_p$.
|
||||
|
||||
\begin{tcolorbox}
|
||||
|
||||
\agda{agda/FFOL-I-20.tex}
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
Now, we are defining a complete proof substitution, that can also be understood as a list a proofs of the formulæ described in the goal proof-context.
|
||||
|
||||
We can notice that those proof substitutions works with a fixed term-context. So they are weaker than the final substitutions we well have to define for our algebra, that have to be able to be morphisms between contexts that can 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, before we can define proof substitutions, we need to define \emph{renamings} like we did for Propositional Logic. They allow us to define proof-weakening and the identity substitution. With them, we can define the complete proof substitutions like we did for Propositional Logic. But please note that those proof substitutions are defined with a fixed term-context. So they are weaker than the final substitutions we well have to define for our algebra, that have to be able to be morphisms between contexts that can 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, like we did for term-substitutions and formulæ.
|
||||
|
||||
Again, we have defined $\operatorname{wk}_p$ and $\operatorname{lf}_p$. The former will add an unused proof variable (an assumption) in a substitution, and the latter adds a formula in the goal which is proven using an assumption.
|
||||
Again, we have defined \AgdaFunction{wk${}_p$} and \AgdaFunction{lf${}_p$}. The former will add an unused proof variable (an assumption) in a substitution, and the latter adds a formula in 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 $\_[\_]\sigma_p$ respects them, as we did for the Subt's laws.
|
||||
|
||||
The proofs of these laws contains a lot of transports, which will be described more precisely in \autoref{sec:transport-hell}.
|
||||
The proofs of these laws contains a lot of transports which make them not very readable, but this problem will be described more precisly 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 in order to match the algebra.
|
||||
|
||||
For contexts, we simply have a record type. But for substitutions, we defined Subp to only describe substitutions between Conp{\footnotesize s} with \emph{the same Conp}. Our solution is to understand global substitutions as a sequence of substitutions, first on terms, and then on proofs. That's why the \enquote{proof} part of the substitution can only be applyed to proofs on $\Delta_p [t]p$, i.e. proofs that have already been term-substituted by the \enquote{term} part of the substitution. The definition of the algebra's substitution is given after, and you can see that substitutions works 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.
|
||||
For contexts, we simply have a record type. But for substitutions, we defined Subp to only describe substitutions between Conp{\footnotesize s} with \emph{the same Conp}. Our solution is to understand global substitutions as a sequence of two substitutions, first on terms, and then on proofs. That's why the \enquote{proof} part of the substitution can only be applyed to proofs on $\Delta_p [t]p$, i.e. proofs that have already been term-substituted by the \enquote{term} part of the substitution. The definition of the algebra's substitution is given after, and you can see that substitutions works 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}
|
||||
|
||||
@ -355,12 +470,15 @@
|
||||
|
||||
\end{tcolorbox}
|
||||
|
||||
And we now have a working syntax for Predicate Logic. Unfortunately, i did not prove yet that it was really an initial model, because for the proof i need to work with a lot of transport hell, which are not really hard to solve, but takes a lot of time.
|
||||
|
||||
\subsection{Transport Hell}
|
||||
|
||||
\label{sec:transport-hell}
|
||||
|
||||
In order for you to understand the code, i have to explain what are transport. I'll do this with the example of the definition of \AgdaFunction{id}.
|
||||
To construct it, we will use \AgdaFunction{idₜ} and \AgdaFunction{id${}ₚ$}, merged together with the constructor \AgdaInductiveConstructor{sub}. Here are the types of the different elements in an array.
|
||||
In order for you to understand the code, i have to 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 together with the constructor \AgdaInductiveConstructor{sub}. Here are the types of the different elements in an array.
|
||||
|
||||
\begin{center}
|
||||
\renewcommand{\arraystretch}{1.2}
|
||||
|
||||
@ -109,6 +109,7 @@
|
||||
% Agda Config
|
||||
\usepackage{agda}
|
||||
\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}}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user