Syntax of first-order logic #
This file defines the syntax of first-order logic.
Definitions #
Languagedefines first-order languages.L.Term nandL.Formula nare terms and formulas for a first-order languageL, with variables as well-scoped de Bruijn indexes inFin n.L.Subst n m, defined asFin n → L.Term m, is the parallel de Bruijn substitutions that substitutesnvariables into terms inL.Term m.Term.substandFormula.substare substitutions of terms and formulas.- Operations over
L.Subst, including identical substitutionidₛ, composition∘ₛ, variable shiftingSubst.shift, substitution lifting⇑ₛ(the "up" operation in Autosubst paper), single variable substitution↦ₛ, etc.
Equational theory #
We formalize the equational theory of de Bruijn substitutions, extending the Autosubst paper with well-scoped syntax and a much richer set of operations.
We tag the rewriting rules in Autosubst paper with the simp set syntax_simp. Tactic syntax_simp
uses these rules to rewrite FOL syntaxes to their normal forms, e.g.
example {L : Language} {n m : ℕ} {t : L.Term (n + 1)} {t' : L.Term n} {σ : L.Subst n m} :
t[↦ₛ t']ₜ[σ]ₜ = t[⇑ₛσ]ₜ[↦ₛ t'[σ]ₜ]ₜ := by
syntax_simp
This is not a complete decision procedure like the Autosubst paper does, though it already solves a lot of equalities.
Design note #
- Syntax representations. Our definition is a nameless representation with de Bruijn index, in favor of its simplicity with well-defined capture-avoiding substitution. We don't want our syntactic definition rely on meta-level constructions (e.g. HOAS). In comparison, Mathlib's model theory folder uses a locally nameless representation.
- Well-scoped syntax. We start from a non-well-scoped design, where
L.Formulatakes any index inℕas its variable. Switching to well-scoped design gives some advantages:- it makes definitions simpler in many cases, e.g.
Language.Orderrequires twoFormula 2s for less-equal⪯and less-than≺. In non-well-scoped design, one would require a formula with a proof that only0and1are used. - it's easier to prove computability results, since substitutions as
ℕ → L.Termare not encodable, butFin n → L.Term mare. - The proof system can admit empty structure (see
Proof.leanfor more details).
- it makes definitions simpler in many cases, e.g.
- Equality. Equality can be defined as a primitive notion (which is what we are doing) or an
optional binary relation. The advantage to define it as a primitive notion is that we can enforce
equalities to be interpreted as true equality, and we can ship
prwtactic on equalities along with iffs.
References #
- Autosubst: Reasoning with de Bruijn Terms and Parallel Substitution. Steven Schäfer, Tobias Tebbi, Gert Smolka. https://www.ps.uni-saarland.de/Publications/documents/SchaeferEtAl_2015_Autosubst_-Reasoning.pdf
- Completeness and Decidability of de Bruijn Substitution Algebra in Coq. Steven Schäfer, Gert Smolka, Tobias Tebbi. https://www.ps.uni-saarland.de/Publications/documents/SchaeferEtAl_2015_Completeness.pdf
- 1001 Representations of Syntax with Binding. Jesper Cockx. https://jesper.sikanda.be/posts/1001-syntax-representations.html
A variable indexed by Fin n.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A function symbol applied by a vector of terms.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
Substitution of a term.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Identical substitution.
Equations
- idₛ = FirstOrder.Language.Subst.of fun (i : Fin n) => #i
Instances For
Identical substitution.
Equations
- FirstOrder.Language.termIdₛ = Lean.ParserDescr.node `FirstOrder.Language.termIdₛ 1024 (Lean.ParserDescr.symbol "idₛ")
Instances For
Composition of substitutions. Note: the direction is opposite to Function.comp.
Instances For
Composition of substitutions. Note: the direction is opposite to Function.comp.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Subst.shift k shifts variables from 0..n-1 to k..n-1+k.
Equations
- FirstOrder.Language.Subst.shift k = FirstOrder.Language.Subst.of fun (x : Fin n) => #(x.addNat k)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
↑ₜt is the abbreviation of t[Subst.shift 1]ₜ.
Equations
- FirstOrder.Language.«term↑ₜ_» = Lean.ParserDescr.node `FirstOrder.Language.«term↑ₜ_» 1024 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "↑ₜ") (Lean.ParserDescr.cat `term 1024))
Instances For
↑ₜ^[k] t is the abbreviation of t[Subst.shift k]ₜ.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Subst.embed k keeps variables from 0..k-1 unchanged, but embeds them into L.Term (n + k).
Equations
- FirstOrder.Language.Subst.embed k = FirstOrder.Language.Subst.of fun (i : Fin k) => #(i.castAdd' n)
Instances For
↦ₛ t substitutes variable 0 to t and shifts remained variables i + 1 back to i. It is
an abbreviation of t ∷ᵥ id.
Equations
- FirstOrder.Language.«term↦ₛ_» = Lean.ParserDescr.node `FirstOrder.Language.«term↦ₛ_» 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "↦ₛ ") (Lean.ParserDescr.cat `term 1022))
Instances For
≔ₛ t is similar to ↦ₛ t, but only substitutes variable 0 and does not shift others. It is
an abbreviation of t ∷ᵥ Subst.shift 1.
Equations
- ≔ₛ t = t ∷ᵥ FirstOrder.Language.Subst.shift 1
Instances For
≔ₛ t is similar to ↦ₛ t, but only substitutes variable 0 and does not shift others. It is
an abbreviation of t ∷ᵥ Subst.shift 1.
Equations
- FirstOrder.Language.«term≔ₛ_» = Lean.ParserDescr.node `FirstOrder.Language.«term≔ₛ_» 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "≔ₛ ") (Lean.ParserDescr.cat `term 1022))
Instances For
⇑ₛ^[k] σ keeps variables 0..k-1 unchanged and performs substitutions on remained variables
as if 0..k-1 are all eliminated.
Equations
Instances For
⇑ₛ^[k] σ keeps variables 0..k-1 unchanged and performs substitutions on remained variables
as if 0..k-1 are all eliminated.
Equations
- One or more equations did not get rendered due to their size.
Instances For
⇑ₛσ is an abbreviation of ⇑ₛ^[1] σ.
Equations
- FirstOrder.Language.«term⇑ₛ_» = Lean.ParserDescr.node `FirstOrder.Language.«term⇑ₛ_» 1024 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "⇑ₛ") (Lean.ParserDescr.cat `term 1024))
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
L.Formula n is the type of formulas with free variables indexed by Fin n.
- rel
{L : Language}
{n m : ℕ}
: L.Rel m → (Fin m → L.Term n) → L.Formula n
A relation symbol applied by a vector of terms.
- eq
{L : Language}
{n : ℕ}
: L.Term n → L.Term n → L.Formula n
Equality between two terms.
- false {L : Language} {n : ℕ} : L.Formula n
- imp {L : Language} {n : ℕ} : L.Formula n → L.Formula n → L.Formula n
- all
{L : Language}
{n : ℕ}
: L.Formula (n + 1) → L.Formula n
Universal quantification of a formula.
Instances For
A relation symbol applied by a vector of terms.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equality between two terms.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Universal quantification of a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Existential quantification of a formula. It is defined as ~ ∀' (~ p).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Conjunction of a vector of formulas.
Equations
Instances For
Conjunction of a vector of formulas.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pretty printer defined by notation3 command.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Disjunction of a vector of formulas.
Equations
Instances For
Pretty printer defined by notation3 command.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Disjunction of a vector of formulas.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Universal quantification of a block of k variables.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Existential quantification of a block of k variables.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Substitution of a formula.
Equations
Instances For
Substitution of a formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
↑ₚp is the abbreviation of p[Subst.shift 1]ₚ.
Equations
- One or more equations did not get rendered due to their size.
Instances For
↑ₚ^[k] p is the abbreviation of p[Subst.shift k]ₚ.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- FirstOrder.Language.«term∀*_» = Lean.ParserDescr.node `FirstOrder.Language.«term∀*_» 100 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "∀* ") (Lean.ParserDescr.cat `term 100))
Instances For
append Γ p is the same as insert p Γ, but with a nicer notation Γ,' p so that when writing
proofs, Γ,' p₁,' ⋯,' pₙ looks like a list of local hypotheses.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- FirstOrder.Language.«term↑ᴳ_» = Lean.ParserDescr.node `FirstOrder.Language.«term↑ᴳ_» 1024 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "↑ᴳ") (Lean.ParserDescr.cat `term 1024))
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
- reprFunc {m : ℕ} : L.Func m → ℕ → (Fin m → ℕ → Std.Format) → Std.Format
- reprRel {m : ℕ} : L.Rel m → ℕ → (Fin m → ℕ → Std.Format) → Std.Format
Instances
Equations
- FirstOrder.Language.instReprTerm = { reprPrec := FirstOrder.Language.reprTerm✝ }