Documentation

CslibFrontier.Logics.SecondOrder.Horn

Existential second-order Horn logic #

An SO∃-Horn sentence ∃ R₁ … Rₖ, ⋀ᵢ ∀ x̄ᵢ, Cᵢ existentially quantifies finitely many relation variables over a conjunction of universally closed clauses. Each clause has the form guard ∧ Rⱼ₁(ȳ₁) ∧ … ∧ Rⱼₘ(ȳₘ) → head. Here guard is a formula of the base vocabulary, the body atoms apply relation variables to clause variables, and head is either one such atom (a definite clause) or ⊥ (a goal clause). The Horn restriction applies only to the quantified relation variables: base-vocabulary symbols occur in the guard with either sign. Grädel's textbook definition allows arbitrary first-order guards. His original paper allows only input literals in clause bodies, and the two variants are equivalent on ordered structures with successor and endpoint constants [Gradel2007, Exercise 3.2.20]. Sentence.IsQF is the quantifier-free restriction: a quantifier-free guard in disjunctive normal form splits a clause into finitely many clauses whose guards are conjunctions of literals.

The least relations closed under the definite clauses form a sentence's least model. A sentence holds exactly when its least model satisfies its goal clauses. Truth therefore comes from one canonical least fixed point, with no search over relations. toESO maps the syntax into ordinary existential second-order logic and preserves truth.

Main definitions #

Main results #

References #

Atoms and clauses #

structure Cslib.Logic.ESO.Horn.Atom {V : Type} (arity : V → ℕ) (β : Type) :

A relation-variable atom R(y₁, …, yₖ) whose arguments are variables from β.

  • rel : V

    The relation variable.

  • args : Fin (arity self.rel) → β

    The argument variables.

def Cslib.Logic.ESO.Horn.Atom.Holds {V : Type} {arity : V → ℕ} {M : Type w} {β : Type} (a : Atom arity β) (R : (i : V) → Set (Fin (arity i) → M)) (v : β → M) :

An atom holds under relations R and a variable assignment v.

theorem Cslib.Logic.ESO.Horn.Atom.Holds.mono {V : Type} {arity : V → ℕ} {M : Type w} {β : Type} {a : Atom arity β} {R S : (i : V) → Set (Fin (arity i) → M)} (hRS : R ≤ S) {v : β → M} (h : a.Holds R v) :
a.Holds S v

Atoms are monotone in the interpretation of the relation variables.

structure Cslib.Logic.ESO.Horn.Clause (L : FirstOrder.Language) {V : Type} (arity : V → ℕ) :
Type (max u v)

A guarded Horn clause ∀ x̄, guard ∧ body → head. Its variables are Fin width. The guard is a base-vocabulary formula; the head is one atom (a definite clause) or ⊥ (a goal clause).

def Cslib.Logic.ESO.Horn.Clause.Holds {V : Type} {arity : V → ℕ} {M : Type w} {L : FirstOrder.Language} [L.Structure M] (C : Clause L arity) (R : (i : V) → Set (Fin (arity i) → M)) :

A clause holds under relations R when every assignment satisfying its guard and body satisfies its head; a goal clause forbids such assignments.

def Cslib.Logic.ESO.Horn.Clause.mapGuard {V : Type} {arity : V → ℕ} {L L' : FirstOrder.Language} (f : {α : Type} → L.Formula α → L'.Formula α) (C : Clause L arity) :
Clause L' arity

Replace the guard of a clause by its image under a formula translation.

theorem Cslib.Logic.ESO.Horn.Clause.holds_mapGuard {V : Type} {arity : V → ℕ} {M : Type w} {L L' : FirstOrder.Language} [L.Structure M] [L'.Structure M] (f : {α : Type} → L.Formula α → L'.Formula α) (hf : ∀ {α : Type} (φ : L.Formula α) (v : α → M), (f φ).Realize v ↔ φ.Realize v) (C : Clause L arity) (R : (i : V) → Set (Fin (arity i) → M)) :
(mapGuard (fun {α : Type} => f) C).Holds R ↔ C.Holds R

A truth-preserving guard translation preserves clause truth.

Sentences #

structure Cslib.Logic.ESO.Horn.Sentence (L : FirstOrder.Language) :
Type (max (max 1 u) v)

An existential second-order Horn sentence: finitely many relation variables and a finite conjunction of guarded Horn clauses over them.

An SO∃-Horn sentence holds in M when some relations satisfy all of its clauses.

Grädel's restriction: every guard is quantifier-free.

def Cslib.Logic.ESO.Horn.Sentence.mapGuards {L L' : FirstOrder.Language} (f : {α : Type} → L.Formula α → L'.Formula α) (Φ : Sentence L) :

Translate every guard, keeping the relation variables and the Horn structure.

theorem Cslib.Logic.ESO.Horn.Sentence.realize_mapGuards {M : Type w} {L L' : FirstOrder.Language} [L.Structure M] [L'.Structure M] (f : {α : Type} → L.Formula α → L'.Formula α) (hf : ∀ {α : Type} (φ : L.Formula α) (v : α → M), (f φ).Realize v ↔ φ.Realize v) (Φ : Sentence L) :
(mapGuards (fun {α : Type} => f) Φ).Realize M ↔ Φ.Realize M

A truth-preserving guard translation preserves sentence truth.

def Cslib.Logic.ESO.Horn.Sentence.consequence {L : FirstOrder.Language} (Φ : Sentence L) (M : Type w) [L.Structure M] :
((i : Φ.Var) → Set (Fin (Φ.arity i) → M)) →o (i : Φ.Var) → Set (Fin (Φ.arity i) → M)

The immediate-consequence operator of the definite clauses: one round of rule application. A tuple is produced for a relation variable when some definite clause has it as an instance of its head and its guard and body hold under R.

def Cslib.Logic.ESO.Horn.Sentence.leastModel {L : FirstOrder.Language} (Φ : Sentence L) (M : Type w) [L.Structure M] (i : Φ.Var) :
Set (Fin (Φ.arity i) → M)

The least relations closed under the definite clauses: the least fixed point of the immediate-consequence operator.

def Cslib.Logic.ESO.Horn.Sentence.Closed {M : Type w} {L : FirstOrder.Language} [L.Structure M] (Φ : Sentence L) (R : (i : Φ.Var) → Set (Fin (Φ.arity i) → M)) :

Relations closed under every definite clause.

def Cslib.Logic.ESO.Horn.Sentence.Consistent {M : Type w} {L : FirstOrder.Language} [L.Structure M] (Φ : Sentence L) (R : (i : Φ.Var) → Set (Fin (Φ.arity i) → M)) :

Relations satisfying every goal clause.

theorem Cslib.Logic.ESO.Horn.Sentence.realize_iff {M : Type w} {L : FirstOrder.Language} [L.Structure M] (Φ : Sentence L) :
Φ.Realize M ↔ ∃ (R : (i : Φ.Var) → Set (Fin (Φ.arity i) → M)), Φ.Closed R ∧ Φ.Consistent R

Truth splits into closure under the definite clauses and consistency with the goal clauses.

theorem Cslib.Logic.ESO.Horn.Sentence.closed_iff_consequence_le {M : Type w} {L : FirstOrder.Language} [L.Structure M] (Φ : Sentence L) {R : (i : Φ.Var) → Set (Fin (Φ.arity i) → M)} :
Φ.Closed R ↔ (Φ.consequence M) R ≤ R

Closure under the definite clauses is pre-fixedness for the immediate-consequence operator.

theorem Cslib.Logic.ESO.Horn.Sentence.leastModel_le {M : Type w} {L : FirstOrder.Language} [L.Structure M] (Φ : Sentence L) {R : (i : Φ.Var) → Set (Fin (Φ.arity i) → M)} (hR : Φ.Closed R) :

The least model is below every closed family of relations.

The least model is closed under the definite clauses.

Least-model semantics. An SO∃-Horn sentence holds exactly when the least relations closed under its definite clauses satisfy its goal clauses. Truth is therefore decided by one least fixed point, with no search over relations.

The embedding into existential second-order logic #

def Cslib.Logic.ESO.Horn.Atom.formula {V : Type} {arity : V → ℕ} {L : FirstOrder.Language} {β : Type} (a : Atom arity β) :
(L.sum (varLanguage arity)).Formula β

An atom as an atomic formula of the base vocabulary extended by the relation variables.

noncomputable def Cslib.Logic.ESO.Horn.Clause.formula {V : Type} {arity : V → ℕ} {L : FirstOrder.Language} (C : Clause L arity) :

A clause as its universal closure ∀ x̄, guard ∧ body → head.

The existential second-order sentence with the same relation variables, whose matrix is the conjunction of the clause formulas.

theorem Cslib.Logic.ESO.Horn.Atom.realize_formula {V : Type} {arity : V → ℕ} {M : Type w} {L : FirstOrder.Language} [L.Structure M] {β : Type} (a : Atom arity β) (R : (i : V) → Set (Fin (arity i) → M)) (v : β → M) :

The atomic formula of an atom holds exactly when the atom does.

theorem Cslib.Logic.ESO.Horn.Clause.realize_formula {V : Type} {arity : V → ℕ} {M : Type w} {L : FirstOrder.Language} [L.Structure M] (C : Clause L arity) (R : (i : V) → Set (Fin (arity i) → M)) :

The universal closure of a clause holds exactly when the clause does.

SO∃-Horn is a fragment of SO∃. The existential second-order sentence Φ.toESO holds exactly when Φ does.