The Tseitin encoding of a first-order kernel: semantic layer #
Machinery for the hardness half of the Cook–Levin theorem
(Cook 1971; Levin 1973;
DescriptiveComplexity.sat_hard_of_sigmaSODefinable, in
DescriptiveComplexity.Problems.Sat.Hardness): the generic, machine-free reduction of
any existential-second-order definable problem to SAT (via a Tseitin
(Tseitin 1968) encoding), in the style of Dahlhaus
(Dahlhaus 1983). Given the first-order kernel φ
(a sentence over the input
vocabulary expanded by one second-order block), the produced CNF instance has
- one propositional variable per relation variable
iof the block and tupleā(“ā ∈ Rᵢ”), and one per subformula positionpofφand context tuplew(“the subformula atpholds underw”); - Tseitin-style clauses per subformula position, forcing the position variables to compute the truth value of their subformulas bottom-up.
This file contains the semantic part of the construction, independent of the FO formulas defining the CNF instance inside the input structure:
DescriptiveComplexity.Tseitin.NodeAt f m: the type of subformula positions offwith context lengthm(the root is uniformly reachable viaDescriptiveComplexity.Tseitin.rootAt);DescriptiveComplexity.Tseitin.Gates: a valuation of the position variables computes truth values correctly at every position (“all Tseitin gates hold”);DescriptiveComplexity.Tseitin.canonVal, the canonical valuation by actual truth values, which satisfies all gates (DescriptiveComplexity.Tseitin.gates_canonVal), and the converse reading (DescriptiveComplexity.Tseitin.gates_realize): any valuation satisfying the gates assigns the root its actual truth value;DescriptiveComplexity.Tseitin.IsClauseSem/DescriptiveComplexity.Tseitin.LitSem: the clauses of the encoding and their literals, as semantic predicates on tuples of a fixed lengthDpadded with minimal elements (junk tuples are excluded by canonicity conditions);- the main equivalence
DescriptiveComplexity.Tseitin.satCond_iff_gates: a valuation satisfies every clause iff the induced (padding-invariant) valuation satisfies every gate.
The corresponding first-order formulas and their realization lemmas are in
DescriptiveComplexity.Problems.Sat.TseitinFormulas.
Subformula positions #
The type of subformula positions (“nodes”) of f with context length
m: positions at which the subformula has m free de Bruijn variables. The
family is indexed by the context length so that all node-dependent data
(valuations, clauses) can be typed uniformly, without a dependent context
function.
Equations
- DescriptiveComplexity.Tseitin.NodeAt FirstOrder.Language.BoundedFormula.falsum x✝ = PLift (x✝¹ = x✝)
- DescriptiveComplexity.Tseitin.NodeAt (FirstOrder.Language.BoundedFormula.equal t₁ t₂) x✝ = PLift (x✝¹ = x✝)
- DescriptiveComplexity.Tseitin.NodeAt (FirstOrder.Language.BoundedFormula.rel R ts) x✝ = PLift (x✝¹ = x✝)
- DescriptiveComplexity.Tseitin.NodeAt (f₁.imp f₂) x✝ = (PLift (x✝¹ = x✝) ⊕ DescriptiveComplexity.Tseitin.NodeAt f₁ x✝ ⊕ DescriptiveComplexity.Tseitin.NodeAt f₂ x✝)
- DescriptiveComplexity.Tseitin.NodeAt f.all x✝ = (PLift (x✝¹ = x✝) ⊕ DescriptiveComplexity.Tseitin.NodeAt f x✝)
Instances For
Dependency graph
The root position of a formula.
Equations
- DescriptiveComplexity.Tseitin.rootAt FirstOrder.Language.BoundedFormula.falsum = { down := ⋯ }
- DescriptiveComplexity.Tseitin.rootAt (FirstOrder.Language.BoundedFormula.equal t₁ t₂) = { down := ⋯ }
- DescriptiveComplexity.Tseitin.rootAt (FirstOrder.Language.BoundedFormula.rel R ts) = { down := ⋯ }
- DescriptiveComplexity.Tseitin.rootAt (f₁.imp f₂) = Sum.inl { down := ⋯ }
- DescriptiveComplexity.Tseitin.rootAt f.all = Sum.inl { down := ⋯ }
Instances For
Dependency graph
Whether a position is the root, as a Boolean (usable inside formula definitions, where positions of a variable formula cannot be pattern-matched).
Equations
- DescriptiveComplexity.Tseitin.isRootB FirstOrder.Language.BoundedFormula.falsum x✝ = true
- DescriptiveComplexity.Tseitin.isRootB (FirstOrder.Language.BoundedFormula.equal t₁ t₂) x✝ = true
- DescriptiveComplexity.Tseitin.isRootB (FirstOrder.Language.BoundedFormula.rel R ts) x✝ = true
- DescriptiveComplexity.Tseitin.isRootB (f₁.imp f₂) x✝ = Sum.isLeft x✝
- DescriptiveComplexity.Tseitin.isRootB f.all x✝ = Sum.isLeft x✝
Instances For
Dependency graph
A position is the root iff isRootB says so; in that case its context
length is the formula's own index. Stated as an equality of dependent
pairs.
Dependency graph
Equality of dependent pairs through a fiberwise injective map.
Dependency graph
The largest context length occurring in a formula.
Equations
- DescriptiveComplexity.Tseitin.maxCtx FirstOrder.Language.BoundedFormula.falsum = x✝
- DescriptiveComplexity.Tseitin.maxCtx (FirstOrder.Language.BoundedFormula.equal t₁ t₂) = x✝
- DescriptiveComplexity.Tseitin.maxCtx (FirstOrder.Language.BoundedFormula.rel R ts) = x✝
- DescriptiveComplexity.Tseitin.maxCtx (f₁.imp f₂) = max (DescriptiveComplexity.Tseitin.maxCtx f₁) (DescriptiveComplexity.Tseitin.maxCtx f₂)
- DescriptiveComplexity.Tseitin.maxCtx f.all = DescriptiveComplexity.Tseitin.maxCtx f
Instances For
Dependency graph
A formula's own index is a context length, hence bounded by maxCtx.
Dependency graph
Context lengths of actual positions are bounded by maxCtx.
Dependency graph
There are finitely many positions in a formula.
Dependency graph
Terms of the expanded language #
A term of the language expanded by a (relational) block is a term of the base language.
Equations
- DescriptiveComplexity.Tseitin.termToL (FirstOrder.Language.var a) = FirstOrder.Language.var a
- DescriptiveComplexity.Tseitin.termToL (FirstOrder.Language.func (Sum.inl f_2) ts) = FirstOrder.Language.func f_2 fun (i : Fin l) => DescriptiveComplexity.Tseitin.termToL (ts i)
- DescriptiveComplexity.Tseitin.termToL (FirstOrder.Language.func (Sum.inr f_2) ts) = isEmptyElim f_2
Instances For
Dependency graph
Reembedding termToL into the expanded language gives the term back.
Dependency graph
Realization of termToL in the base structure agrees with realization of
the term in any expansion.
Dependency graph
Gates: correctness of a valuation of the position variables #
The expansion of an L-structure by a block assignment.
Equations
Instances For
Dependency graph
Realization of a kernel formula in the expansion of an L-structure by a
block assignment.
Equations
- DescriptiveComplexity.Tseitin.RealizeWith μ f w = f.Realize (fun (a : Empty) => isEmptyElim a) w
Instances For
Dependency graph
The truth value of an equality atom of the kernel under a context tuple.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The truth value of an input-relation atom of the kernel under a context tuple.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The truth value of a block-variable atom of the kernel under an assignment and a context tuple.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The truth value of an arbitrary atom of the kernel.
Equations
- DescriptiveComplexity.Tseitin.atomHolds μ (Sum.inl r) ts w = DescriptiveComplexity.Tseitin.relGuard r ts w
- DescriptiveComplexity.Tseitin.atomHolds μ (Sum.inr r) ts w = DescriptiveComplexity.Tseitin.blockAtom μ r ts w
Instances For
Dependency graph
A valuation of the position variables of a formula: a truth value for every position and context tuple.
Equations
- DescriptiveComplexity.Tseitin.NodeVal A f = ((m : ℕ) → DescriptiveComplexity.Tseitin.NodeAt f m → (Fin m → A) → Prop)
Instances For
Dependency graph
All Tseitin gates of a formula hold under a valuation of its position
variables: at every position, the valuation relates to the valuations at the
children (or to the atom's truth value) as dictated by the connective. A
valuation satisfying all gates computes actual truth values
(DescriptiveComplexity.Tseitin.gates_realize).
Equations
- One or more equations did not get rendered due to their size.
- DescriptiveComplexity.Tseitin.Gates μ FirstOrder.Language.BoundedFormula.falsum ν = ∀ (w : Fin x✝ → A), ¬ν x✝ { down := ⋯ } w
- DescriptiveComplexity.Tseitin.Gates μ (FirstOrder.Language.BoundedFormula.equal t₁ t₂) ν = ∀ (w : Fin x✝ → A), ν x✝ { down := ⋯ } w ↔ DescriptiveComplexity.Tseitin.eqGuard t₁ t₂ w
- DescriptiveComplexity.Tseitin.Gates μ (FirstOrder.Language.BoundedFormula.rel R ts) ν = ∀ (w : Fin x✝ → A), ν x✝ { down := ⋯ } w ↔ DescriptiveComplexity.Tseitin.atomHolds μ R ts w
Instances For
Dependency graph
The canonical valuation: each position variable receives the truth value of its subformula.
Equations
- One or more equations did not get rendered due to their size.
- DescriptiveComplexity.Tseitin.canonVal μ FirstOrder.Language.BoundedFormula.falsum x✝² x✝ x✝¹ = False
- DescriptiveComplexity.Tseitin.canonVal μ (f₁.imp f₂) x✝¹ (Sum.inl h) x✝ = DescriptiveComplexity.Tseitin.RealizeWith μ (f₁.imp f₂) (x✝ ∘ Fin.cast ⋯)
- DescriptiveComplexity.Tseitin.canonVal μ (f₁.imp f₂) x✝¹ (Sum.inr (Sum.inl q)) x✝ = DescriptiveComplexity.Tseitin.canonVal μ f₁ x✝¹ q x✝
- DescriptiveComplexity.Tseitin.canonVal μ (f₁.imp f₂) x✝¹ (Sum.inr (Sum.inr q)) x✝ = DescriptiveComplexity.Tseitin.canonVal μ f₂ x✝¹ q x✝
- DescriptiveComplexity.Tseitin.canonVal μ f.all x✝¹ (Sum.inl h) x✝ = DescriptiveComplexity.Tseitin.RealizeWith μ f.all (x✝ ∘ Fin.cast ⋯)
- DescriptiveComplexity.Tseitin.canonVal μ f.all x✝¹ (Sum.inr q) x✝ = DescriptiveComplexity.Tseitin.canonVal μ f x✝¹ q x✝
Instances For
Dependency graph
The canonical valuation at the root is the truth value of the whole formula.
Dependency graph
Unfolding RealizeWith #
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Gates compute truth values #
Any valuation satisfying all gates assigns to the root the truth value of the formula.
Dependency graph
The canonical valuation satisfies all gates.
Dependency graph
The clauses of the encoding and their literals #
The literal tuple of a block-variable atom: canonical, with the atom's term values as prefix.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The clauses of the Tseitin encoding, as a predicate on positions, clause
kinds (Fin 3) and canonical D-tuples:
falsumnode at contextw: kind 0, the unit clause¬v(p, w);equal/input-relation node: kind 0, the unit clausev(p, w), present when the atom holds underw; kind 1, the unit clause¬v(p, w), present otherwise;- block-variable node: kind 0,
¬v(p, w) ∨ R(ā); kind 1,v(p, w) ∨ ¬R(ā); impnode with childrena,b: kind 0,¬v(p, w) ∨ ¬a(w) ∨ b(w); kind 1,v(p, w) ∨ a(w); kind 2,v(p, w) ∨ ¬b(w);allnode with childc: kind 0 (indexed by extended tuplesw ⌢ a),¬v(p, w) ∨ c(w ⌢ a); kind 1, the wide clausev(p, w) ∨ ⋁_a ¬c(w ⌢ a).
Equations
- One or more equations did not get rendered due to their size.
- DescriptiveComplexity.Tseitin.IsClauseSem FirstOrder.Language.BoundedFormula.falsum x_7 x_4 x_2 x_3 = (x_2 = 0 ∧ DescriptiveComplexity.Canon x x_3)
- DescriptiveComplexity.Tseitin.IsClauseSem (FirstOrder.Language.BoundedFormula.rel (Sum.inr val) ts) h_2 x_8 x_2 x_3 = (DescriptiveComplexity.Canon x x_3 ∧ (x_2 = 0 ∨ x_2 = 1))
- DescriptiveComplexity.Tseitin.IsClauseSem (f₁.imp f₂) h (Sum.inl h_1) x_2 x_3 = DescriptiveComplexity.Canon x x_3
- DescriptiveComplexity.Tseitin.IsClauseSem (f₁.imp f₂) h (Sum.inr (Sum.inl q)) x_2 x_3 = DescriptiveComplexity.Tseitin.IsClauseSem f₁ ⋯ q x_2 x_3
- DescriptiveComplexity.Tseitin.IsClauseSem (f₁.imp f₂) h (Sum.inr (Sum.inr q)) x_2 x_3 = DescriptiveComplexity.Tseitin.IsClauseSem f₂ ⋯ q x_2 x_3
- DescriptiveComplexity.Tseitin.IsClauseSem f.all h (Sum.inl h_1) x_2 x_3 = (x_2 = 0 ∧ DescriptiveComplexity.Canon (x + 1) x_3 ∨ x_2 = 1 ∧ DescriptiveComplexity.Canon x x_3)
- DescriptiveComplexity.Tseitin.IsClauseSem f.all h (Sum.inr q) x_2 x_3 = DescriptiveComplexity.Tseitin.IsClauseSem f h q x_2 x_3
Instances For
Dependency graph
The literals of the clauses of the Tseitin encoding: LitSem s f h p k u v x
states that the propositional variable indexed by v (a block variable index
or a position) at tuple x occurs with sign s in the clause (p, k, u).
The clause-existence guards of DescriptiveComplexity.Tseitin.IsClauseSem are not
repeated here.
Equations
- One or more equations did not get rendered due to their size.
- DescriptiveComplexity.Tseitin.LitSem s FirstOrder.Language.BoundedFormula.falsum x_9 x_5 x_2 x_3 v x_4 = (s = false ∧ x_2 = 0 ∧ v = Sum.inr ⟨x, { down := ⋯ }⟩ ∧ x_4 = x_3)
- DescriptiveComplexity.Tseitin.LitSem s (f₁.imp f₂) h (Sum.inr (Sum.inl q)) x_2 x_3 (Sum.inl i) x_4 = DescriptiveComplexity.Tseitin.LitSem s f₁ ⋯ q x_2 x_3 (Sum.inl i) x_4
- DescriptiveComplexity.Tseitin.LitSem s (f₁.imp f₂) h (Sum.inr (Sum.inl q)) x_2 x_3 v x_4 = False
- DescriptiveComplexity.Tseitin.LitSem s (f₁.imp f₂) h (Sum.inr (Sum.inr q)) x_2 x_3 (Sum.inl i) x_4 = DescriptiveComplexity.Tseitin.LitSem s f₂ ⋯ q x_2 x_3 (Sum.inl i) x_4
- DescriptiveComplexity.Tseitin.LitSem s (f₁.imp f₂) h (Sum.inr (Sum.inr q)) x_2 x_3 v x_4 = False
- DescriptiveComplexity.Tseitin.LitSem s f.all h (Sum.inr q) x_2 x_3 (Sum.inl i) x_4 = DescriptiveComplexity.Tseitin.LitSem s f h q x_2 x_3 (Sum.inl i) x_4
- DescriptiveComplexity.Tseitin.LitSem s f.all h (Sum.inr q) x_2 x_3 (Sum.inr ⟨m', Sum.inr q'⟩) x_4 = DescriptiveComplexity.Tseitin.LitSem s f h q x_2 x_3 (Sum.inr ⟨m', q'⟩) x_4
- DescriptiveComplexity.Tseitin.LitSem s f.all h (Sum.inr q) x_2 x_3 v x_4 = False
Instances For
Dependency graph
Clause satisfaction is gate satisfaction #
Every clause of the encoding contains a literal made true by the
valuation tv of the propositional variables.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The block assignment read off a valuation of the propositional variables, on padded tuples.
Equations
- DescriptiveComplexity.Tseitin.padAssign a₀ tv i a = tv (Sum.inl i) (DescriptiveComplexity.pad a₀ a)
Instances For
Dependency graph
The position valuation read off a valuation of the propositional variables, on padded tuples.
Equations
- DescriptiveComplexity.Tseitin.padVal a₀ tv m q w = tv (Sum.inr ⟨m, q⟩) (DescriptiveComplexity.pad a₀ w)
Instances For
Dependency graph
Clause satisfaction is gate satisfaction: a valuation of the propositional variables makes every clause of the Tseitin encoding true iff the valuation it induces on positions (through canonical padding) satisfies every gate, with the block variables read off the atom variables.