Second-order logic with a transitive closure
Lax134656.SecondOrderTransitiveClosure · concepts/Lax134656/SecondOrderTransitiveClosure.lean · lax-134656
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A second-order transitive-closure specification over a vocabulary consists of a block of relation variables and three first-order sentences over : a transition sentence over two copies of the block, and a source and a target sentence over one copy. On a linearly ordered -structure it defines a directed graph whose nodes, the states, are the assignments of relations to the block, with an edge from one state to another when the transition sentence holds with the first copy of the block read as the current state and the second as the next. The specification accepts the structure when some state satisfying the target sentence is reachable, by a possibly empty path, from some state satisfying the source sentence.
A decision problem over is SO(TC) definable when some specification accepts, for every nonempty finite -structure and every linear order on , exactly when is a yes-instance of . A state holds polynomially many bits and a path may be exponentially long: this is the logic SO(TC), which captures polynomial space on ordered structures, in the normal form of a single application of the operator.
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 | import Lax904597.SecondOrder |
| 7 | import Lax535992.InflationaryFixedPoint |
| 8 | |
| 9 | /-! |
| 10 | --- |
| 11 | title: Second-order logic with a transitive closure |
| 12 | type: definition |
| 13 | --- |
| 14 | A second-order transitive-closure specification over a vocabulary |
| 15 | consists of a block of relation variables and three first-order sentences |
| 16 | over : a transition sentence over two copies of the |
| 17 | block, and a source and a target sentence over one copy. On a linearly |
| 18 | ordered -structure it defines a directed graph whose nodes, the states, |
| 19 | are the assignments of relations to the block, with an edge from one state |
| 20 | to another when the transition sentence holds with the first copy of the |
| 21 | block read as the current state and the second as the next. The |
| 22 | specification accepts the structure when some state satisfying the target |
| 23 | sentence is reachable, by a possibly empty path, from some state satisfying |
| 24 | the source sentence. |
| 25 | |
| 26 | A decision problem over is SO(TC) definable when some specification |
| 27 | accepts, for every nonempty finite -structure and every linear order |
| 28 | on , exactly when is a yes-instance of . A state holds |
| 29 | polynomially many bits and a path may be exponentially long: this is the |
| 30 | logic SO(TC), which captures polynomial space on ordered structures, in the |
| 31 | normal form of a single application of the operator. |
| 32 | -/ |
| 33 | |
| 34 | namespace Lax134656.SecondOrderTransitiveClosure |
| 35 | |
| 36 | open Lax904597.Problems Lax904597.SecondOrder Lax535992.InflationaryFixedPoint |
| 37 | |
| 38 | open FirstOrder |
| 39 | |
| 40 | open Language Structure |
| 41 | |
| 42 | /-- The structure over `L` expanded by *two* copies of a block's vocabulary – |
| 43 | the current state and the next one – interpreted by two assignments. -/ |
| 44 | @[reducible] |
| 45 | def SOBlock.structure₂ {L : Language.{0, 0}} (B : SOBlock) {A : Type} [inst : L.Structure A] |
| 46 | (ρ σ : B.Assignment A) : ((L.sum B.lang).sum B.lang).Structure A := |
| 47 | @sumStructure (L.sum B.lang) B.lang A (SOBlock.structure₁ B ρ) (B.structure σ) |
| 48 | |
| 49 | /-- A single-`TC` definition over a second-order block: the states of the walk |
| 50 | are the assignments of the block `B`, and the transition, source and target |
| 51 | conditions are first-order sentences over the base vocabulary expanded by the |
| 52 | order and by copies of the block. The transition sentence sees two copies – |
| 53 | the current state and the next one. |
| 54 | |
| 55 | The order is visible to all three sentences; the problem itself does not see |
| 56 | it. -/ |
| 57 | structure SOTCSpec (L : Language.{0, 0}) : Type 1 where |
| 58 | /-- The block whose assignments are the states of the walk. -/ |
| 59 | B : SOBlock |
| 60 | /-- The transition sentence, over two copies of the block: the current state |
| 61 | reads the first copy, the next state the second. -/ |
| 62 | step : (((L.sum Language.order).sum B.lang).sum B.lang).Sentence |
| 63 | /-- The sentence defining the admissible starting states. -/ |
| 64 | src : ((L.sum Language.order).sum B.lang).Sentence |
| 65 | /-- The sentence defining the accepting states. -/ |
| 66 | tgt : ((L.sum Language.order).sum B.lang).Sentence |
| 67 | |
| 68 | namespace SOTCSpec |
| 69 | |
| 70 | section Semantics |
| 71 | |
| 72 | variable {L : Language.{0, 0}} (spec : SOTCSpec L) {A : Type} [L.Structure A] [LinearOrder A] |
| 73 | |
| 74 | variable (A) in |
| 75 | /-- A state of the walk: an assignment of the block. -/ |
| 76 | abbrev State : Type := spec.B.Assignment A |
| 77 | |
| 78 | /-- One step of the walk: the transition sentence, read with the current state |
| 79 | in the first copy of the block and the next state in the second. -/ |
| 80 | def Step (ρ σ : spec.State A) : Prop := |
| 81 | @Sentence.Realize _ A (SOBlock.structure₂ (L := L.sum Language.order) spec.B ρ σ) spec.step |
| 82 | |
| 83 | /-- Reachability in the walk: the reflexive-transitive closure of |
| 84 | `SOTCSpec.Step`. -/ |
| 85 | abbrev Reach : spec.State A → spec.State A → Prop := |
| 86 | Relation.ReflTransGen spec.Step |
| 87 | |
| 88 | /-- A state is a starting state when it satisfies the source sentence. -/ |
| 89 | def IsSrc (ρ : spec.State A) : Prop := |
| 90 | @Sentence.Realize _ A (SOBlock.structure₁ (L := L.sum Language.order) spec.B ρ) spec.src |
| 91 | |
| 92 | /-- A state is accepting when it satisfies the target sentence. -/ |
| 93 | def IsTgt (ρ : spec.State A) : Prop := |
| 94 | @Sentence.Realize _ A (SOBlock.structure₁ (L := L.sum Language.order) spec.B ρ) spec.tgt |
| 95 | |
| 96 | variable (A) in |
| 97 | /-- The structure is accepted: some accepting state is reachable from some |
| 98 | starting state. -/ |
| 99 | def Accepts : Prop := |
| 100 | ∃ ρ σ : spec.State A, spec.IsSrc ρ ∧ spec.IsTgt σ ∧ spec.Reach ρ σ |
| 101 | |
| 102 | end Semantics |
| 103 | |
| 104 | end SOTCSpec |
| 105 | |
| 106 | /-- A decision problem is *SO(TC) definable* if, on nonempty finite *ordered* |
| 107 | structures, it is defined by a single transitive closure over the assignments |
| 108 | of a second-order quantifier block: there is an `SOTCSpec` whose accepting |
| 109 | states are reachable from its starting states exactly on the yes-instances. |
| 110 | The equivalence is required for *every* linear order on the universe: the |
| 111 | problem itself does not see the order, while the three sentences may. -/ |
| 112 | def SOTCDefinable {L : Language.{0, 0}} [L.IsRelational] (P : DecisionProblem L) : Prop := |
| 113 | ∃ spec : SOTCSpec L, |
| 114 | ∀ (A : Type) [L.Structure A] [LinearOrder A] [Finite A] [Nonempty A], |
| 115 | P A ↔ spec.Accepts A |
| 116 | |
| 117 | end Lax134656.SecondOrderTransitiveClosure |
| 118 |
Builds on
Used by
Lax134656.AbiteboulVianuLax134656.AbiteboulVianuOrderedLax134656.ClassPSPACELax134656.HierarchyInPSPACELax134656.InflationaryInPartialLax134656.OrderFreeTransitiveClosureLax134656.PartialFixedPointCaptureLax134656.PartialFixedPointClosureLax134656.PSPACEClosureLax134656.PSPACEEqCoPSPACELax134656.QsatInvarianceLax134656.QsatPSPACECompleteLax134656.SpaceBoundedMachineInvarianceLax134656.SpaceMachinesPSPACECompleteLax134656.SuccinctReachInvarianceLax134656.SuccinctReachPSPACECompleteLax134656.TransitiveClosureWithoutOrder
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments