First-order logic with a transitive closure
Lax485149.TransitiveClosure · concepts/Lax485149/TransitiveClosure.lean · lax-485149
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A transitive-closure specification over a vocabulary consists of a finite set of modes, an arity , and first-order formulas over : a transition formula for each pair of modes and, for each mode , a source formula and a target formula , with and tuples of variables. On a linearly ordered -structure it defines a directed graph whose nodes are the pairs of a mode and a -tuple of elements, with an edge from to when . The specification accepts when some node satisfying its target formula is reachable, by a possibly empty path, from some node satisfying its source formula.
A decision problem over is FO(TC) definable when some specification accepts, for every nonempty finite -structure and every linear order on , exactly when is a yes-instance of . This is the normal form of first-order logic with a transitive closure operator on ordered structures, a single positive application of the operator; the modes play the role of a bounded amount of extra state, which tuples of elements cannot carry on small universes.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.ModelTheory.Order |
| 2 | import Mathlib.ModelTheory.Semantics |
| 3 | import Mathlib.Logic.Relation |
| 4 | import Lax904597.Problems |
| 5 | import Lax904597.Interpretations |
| 6 | |
| 7 | /-! |
| 8 | --- |
| 9 | title: First-order logic with a transitive closure |
| 10 | type: definition |
| 11 | --- |
| 12 | A transitive-closure specification over a vocabulary consists of a finite |
| 13 | set of modes, an arity , and first-order formulas over : |
| 14 | a transition formula for each pair of modes |
| 15 | and, for each mode , a source formula and a target |
| 16 | formula , with and tuples of |
| 17 | variables. On a linearly ordered -structure it defines a directed |
| 18 | graph whose nodes are the pairs of a mode and a -tuple of |
| 19 | elements, with an edge from to when |
| 20 | . The specification accepts |
| 21 | when some node satisfying its target formula is reachable, by a possibly |
| 22 | empty path, from some node satisfying its source formula. |
| 23 | |
| 24 | A decision problem over is FO(TC) definable when some specification |
| 25 | accepts, for every nonempty finite -structure and every linear order |
| 26 | on , exactly when is a yes-instance of . This is the normal form |
| 27 | of first-order logic with a transitive closure operator on ordered |
| 28 | structures, a single positive application of the operator; the modes play |
| 29 | the role of a bounded amount of extra state, which tuples of elements cannot |
| 30 | carry on small universes. |
| 31 | -/ |
| 32 | |
| 33 | namespace Lax485149.TransitiveClosure |
| 34 | |
| 35 | open Lax904597.Problems |
| 36 | |
| 37 | open FirstOrder |
| 38 | |
| 39 | open Language |
| 40 | |
| 41 | /-- A single-`TC` definition: the transition formula of a graph on `k`-tuples, |
| 42 | together with formulas for the admissible start and end tuples. All three are |
| 43 | first-order over the ordered expansion of the vocabulary, so that they may |
| 44 | mention the linear order, as the ordered setting of the capture theorem |
| 45 | allows. -/ |
| 46 | structure TCSpec (L : Language.{0, 0}) where |
| 47 | /-- The *modes*: a finite amount of state the walk carries besides its tuple |
| 48 | of elements. Tuples of elements cannot hold finite data of their own – a |
| 49 | one-element universe has only one tuple – so, exactly as tags replace the |
| 50 | order-encoded sorts of a textbook interpretation in `FOInterpretation`, a |
| 51 | mode carries what the tuple cannot. -/ |
| 52 | Mode : Type |
| 53 | /-- Modes are finite. -/ |
| 54 | [modeFinite : Finite Mode] |
| 55 | /-- The arity: the walk runs on `k`-tuples of elements. -/ |
| 56 | k : ℕ |
| 57 | /-- The transition formula, one per pair of modes, with two `k`-tuples of |
| 58 | free variables: the current tuple on the left, the next one on the right. -/ |
| 59 | step : Mode → Mode → (L.sum Language.order).Formula (Fin k ⊕ Fin k) |
| 60 | /-- The formula defining the admissible starting tuples, per mode. -/ |
| 61 | src : Mode → (L.sum Language.order).Formula (Fin k) |
| 62 | /-- The formula defining the accepting tuples, per mode. -/ |
| 63 | tgt : Mode → (L.sum Language.order).Formula (Fin k) |
| 64 | |
| 65 | attribute [instance] TCSpec.modeFinite |
| 66 | |
| 67 | namespace TCSpec |
| 68 | |
| 69 | section Semantics |
| 70 | |
| 71 | variable {L : Language.{0, 0}} (spec : TCSpec L) {A : Type} [L.Structure A] [LinearOrder A] |
| 72 | |
| 73 | variable (A) in |
| 74 | /-- A node of the walk: a mode together with a `k`-tuple of elements. -/ |
| 75 | abbrev Node : Type := spec.Mode × (Fin spec.k → A) |
| 76 | |
| 77 | /-- One step of the walk: the transition formula of the two modes, read with |
| 78 | the current tuple on the left and the next one on the right. -/ |
| 79 | def Step (a b : spec.Node A) : Prop := |
| 80 | (spec.step a.1 b.1).Realize (Sum.elim a.2 b.2) |
| 81 | |
| 82 | /-- Reachability in the walk: the reflexive-transitive closure of |
| 83 | `TCSpec.Step`. -/ |
| 84 | abbrev Reach : spec.Node A → spec.Node A → Prop := |
| 85 | Relation.ReflTransGen spec.Step |
| 86 | |
| 87 | /-- A node is a starting node when its tuple satisfies the source formula of |
| 88 | its mode. -/ |
| 89 | def IsSrc (a : spec.Node A) : Prop := (spec.src a.1).Realize a.2 |
| 90 | |
| 91 | /-- A node is accepting when its tuple satisfies the target formula of its |
| 92 | mode. -/ |
| 93 | def IsTgt (a : spec.Node A) : Prop := (spec.tgt a.1).Realize a.2 |
| 94 | |
| 95 | variable (A) in |
| 96 | /-- The structure is accepted: some accepting node is reachable from some |
| 97 | starting node. -/ |
| 98 | def Accepts : Prop := |
| 99 | ∃ u v : spec.Node A, spec.IsSrc u ∧ spec.IsTgt v ∧ spec.Reach u v |
| 100 | |
| 101 | end Semantics |
| 102 | |
| 103 | end TCSpec |
| 104 | |
| 105 | /-- A decision problem is *FO(TC) definable* if, on nonempty finite *ordered* |
| 106 | structures, it is defined by a single transitive closure: there is a `TCSpec` |
| 107 | whose accepting tuples are reachable from its starting tuples exactly on the |
| 108 | yes-instances. |
| 109 | |
| 110 | The equivalence is required for *every* linear order on the universe, so this |
| 111 | is order-invariant FO(TC) definability: the problem itself does not see the |
| 112 | order, while the transition and endpoint formulas may. -/ |
| 113 | def TCDefinable {L : Language.{0, 0}} [L.IsRelational] (P : DecisionProblem L) : Prop := |
| 114 | ∃ spec : TCSpec L, |
| 115 | ∀ (A : Type) [L.Structure A] [LinearOrder A] [Finite A] [Nonempty A], |
| 116 | P A ↔ spec.Accepts A |
| 117 | |
| 118 | end Lax485149.TransitiveClosure |
| 119 |
Used by
Lax485149.ClassLLax485149.DeterministicReachabilityInvarianceLax485149.DeterministicTransitiveClosureLax485149.FirstOrderInTransitiveClosureLax485149.ImmermanSzelepcsenyiLax485149.KromAndTransitiveClosureLax485149.LByAutomataLax485149.LClosureLax485149.LEqCoLLax485149.LSubsetNLLax485149.NLByAutomataLax485149.NLClosureLax485149.NLEqCoNLLax485149.NLIsTransitiveClosureLax485149.NLSubsetNPLax485149.ReachabilityInvarianceLax485149.ReachdLCompleteLax485149.ReachNLCompleteLax485149.TransitiveClosureClosureLax485149.TwoSatInvarianceLax485149.TwoSatNLCompleteLax485149.UnreachdLCompleteLax485149.UnreachNLComplete
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments