Reductions in first-order logic with a deterministic transitive closure
Lax945089.TransitiveClosureReductions · concepts/Lax945089/TransitiveClosureReductions.lean · lax-945089
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A parameterized walk over a vocabulary is a finite set of modes, an arity , a number of parameters, and a step formula for each pair of modes, in two -tuples of variables and the parameters; at a valuation of the parameters it defines a graph on the pairs of a mode and a -tuple, and its reachability relation. Its determinization keeps only the steps that are alone in leaving their node. A finite family of walks gives one relation variable per walk and pair of modes, holding the reachability relation between two nodes of these modes at given parameters.
An FO(DTC) reduction from a problem to a problem consists of a finite family of walks over the ordered expansion of the vocabulary of and a relativized first-order interpretation whose formulas may use, beside the vocabulary and the order, the reachability relations of the determinized walks. For every nonempty finite structure and every linear order on it, the interpreted structure must be nonempty and be a yes-instance of exactly when the structure is a yes-instance of . This is Immerman's logical form of a deterministic logarithmic-space reduction.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.ModelTheory.Order |
| 2 | import Mathlib.ModelTheory.Semantics |
| 3 | import Mathlib.Logic.Relation |
| 4 | import Mathlib.Data.Finite.Sigma |
| 5 | import Mathlib.Data.Finite.Prod |
| 6 | import Lax904597.Problems |
| 7 | import Lax904597.Interpretations |
| 8 | import Lax904597.Relativized |
| 9 | import Lax904597.SecondOrder |
| 10 | import Lax535992.InflationaryFixedPoint |
| 11 | |
| 12 | /-! |
| 13 | --- |
| 14 | title: Reductions in first-order logic with a deterministic transitive closure |
| 15 | type: definition |
| 16 | --- |
| 17 | A parameterized walk over a vocabulary is a finite set of modes, an arity |
| 18 | , a number of parameters, and a step formula for each pair of modes, in |
| 19 | two -tuples of variables and the parameters; at a valuation of the |
| 20 | parameters it defines a graph on the pairs of a mode and a -tuple, and |
| 21 | its reachability relation. Its determinization keeps only the steps that |
| 22 | are alone in leaving their node. A finite family of walks gives one |
| 23 | relation variable per walk and pair of modes, holding the reachability |
| 24 | relation between two nodes of these modes at given parameters. |
| 25 | |
| 26 | An FO(DTC) reduction from a problem to a problem consists of a |
| 27 | finite family of walks over the ordered expansion of the vocabulary of |
| 28 | and a relativized first-order interpretation whose formulas may use, beside |
| 29 | the vocabulary and the order, the reachability relations of the |
| 30 | determinized walks. For every nonempty finite structure and every linear |
| 31 | order on it, the interpreted structure must be nonempty and be a |
| 32 | yes-instance of exactly when the structure is a yes-instance of . |
| 33 | This is Immerman's logical form of a deterministic logarithmic-space |
| 34 | reduction. |
| 35 | -/ |
| 36 | |
| 37 | namespace Lax945089.TransitiveClosureReductions |
| 38 | |
| 39 | open Lax904597.Problems Lax904597.Relativized Lax904597.SecondOrder |
| 40 | open Lax535992.InflationaryFixedPoint |
| 41 | |
| 42 | open FirstOrder |
| 43 | |
| 44 | open Language Structure |
| 45 | |
| 46 | /-- A **parameterized transitive-closure specification**: a walk on `k`-tuples |
| 47 | carrying a finite mode, whose step formula may mention `par` parameters beside |
| 48 | the current and the next tuple. It has no source and target formulas: what it |
| 49 | defines is the reachability *relation*. -/ |
| 50 | structure ParamTCSpec (L : Language.{0, 0}) : Type 1 where |
| 51 | /-- The modes: the finite control the walk carries beside its tuple. -/ |
| 52 | Mode : Type |
| 53 | /-- Modes are finite. -/ |
| 54 | [modeFinite : Finite Mode] |
| 55 | /-- The walk runs on `k`-tuples of elements. -/ |
| 56 | k : ℕ |
| 57 | /-- The number of parameters the step formula may mention. -/ |
| 58 | par : ℕ |
| 59 | /-- The step formula, one per pair of modes: the current tuple, the next |
| 60 | tuple, then the parameters. -/ |
| 61 | step : Mode → Mode → L.Formula ((Fin k ⊕ Fin k) ⊕ Fin par) |
| 62 | |
| 63 | namespace ParamTCSpec |
| 64 | |
| 65 | variable {L : Language.{0, 0}} (s : ParamTCSpec L) {A : Type} [L.Structure A] |
| 66 | |
| 67 | attribute [instance] modeFinite |
| 68 | |
| 69 | variable (A) in |
| 70 | /-- A node of the walk: a mode together with a `k`-tuple. -/ |
| 71 | abbrev Node : Type := s.Mode × (Fin s.k → A) |
| 72 | |
| 73 | /-- One step of the walk, at a valuation of the parameters. -/ |
| 74 | def StepAt (z : Fin s.par → A) (a b : s.Node A) : Prop := |
| 75 | (s.step a.1 b.1).Realize (Sum.elim (Sum.elim a.2 b.2) z) |
| 76 | |
| 77 | /-- Reachability in the walk, at a valuation of the parameters. -/ |
| 78 | abbrev ReachAt (z : Fin s.par → A) : s.Node A → s.Node A → Prop := |
| 79 | Relation.ReflTransGen (s.StepAt z) |
| 80 | |
| 81 | /-- The position of the `i`-th coordinate of the *first* tuple. -/ |
| 82 | def leftIx (i : Fin s.k) : Fin (s.k + s.k + s.par) := ⟨i, by have := i.isLt; omega⟩ |
| 83 | |
| 84 | /-- The position of the `i`-th coordinate of the *second* tuple. -/ |
| 85 | def rightIx (i : Fin s.k) : Fin (s.k + s.k + s.par) := ⟨s.k + i, by have := i.isLt; omega⟩ |
| 86 | |
| 87 | /-- The position of the `j`-th parameter. -/ |
| 88 | def parIx (j : Fin s.par) : Fin (s.k + s.k + s.par) := ⟨s.k + s.k + j, by have := j.isLt; omega⟩ |
| 89 | |
| 90 | end ParamTCSpec |
| 91 | |
| 92 | /-- A finite family of parameterized walks. Its relation variables – one per |
| 93 | walk and ordered pair of that walk's modes – are what an FO(TC) reduction's |
| 94 | formulas may read. -/ |
| 95 | structure TCFamily (L : Language.{0, 0}) : Type 1 where |
| 96 | /-- The index type of the family. -/ |
| 97 | Ix : Type |
| 98 | /-- The family is finite. -/ |
| 99 | [ixFinite : Finite Ix] |
| 100 | /-- The walk of each index. -/ |
| 101 | spec : Ix → ParamTCSpec L |
| 102 | |
| 103 | namespace TCFamily |
| 104 | |
| 105 | variable {L : Language.{0, 0}} (F : TCFamily L) |
| 106 | |
| 107 | attribute [instance] ixFinite |
| 108 | |
| 109 | /-- The block of relation variables of a family: one variable per walk and |
| 110 | ordered pair of modes, of arity “two tuples and the parameters”. -/ |
| 111 | def block : SOBlock where |
| 112 | ι := Σ i : F.Ix, (F.spec i).Mode × (F.spec i).Mode |
| 113 | arity := fun q => (F.spec q.1).k + (F.spec q.1).k + (F.spec q.1).par |
| 114 | |
| 115 | variable {F} {A : Type} [L.Structure A] |
| 116 | |
| 117 | /-- The assignment the block *has*, as opposed to one a second-order |
| 118 | quantifier would guess: each variable holds the reachability relation of its |
| 119 | walk, at the parameters read off the tuple. -/ |
| 120 | def reachAssign (F : TCFamily L) (A : Type) [L.Structure A] : F.block.Assignment A := |
| 121 | fun q w => |
| 122 | (F.spec q.1).ReachAt (fun j => w ((F.spec q.1).parIx j)) |
| 123 | (q.2.1, fun i => w ((F.spec q.1).leftIx i)) |
| 124 | (q.2.2, fun i => w ((F.spec q.1).rightIx i)) |
| 125 | |
| 126 | end TCFamily |
| 127 | |
| 128 | open FirstOrder |
| 129 | |
| 130 | open Language Structure |
| 131 | |
| 132 | /-- An **FO(TC) interpretation**: a relativized first-order interpretation |
| 133 | whose formulas may read the reachability relations of a finite family of |
| 134 | first-order walks over the base structure. |
| 135 | |
| 136 | Over an ordered base (`L := L₀.sum Language.order`) this is Immerman's FO(TC) |
| 137 | reduction, the logical form of a logarithmic-space reduction. -/ |
| 138 | structure TCInterpretation (L L' : Language.{0, 0}) (Tag : Type) (dim : ℕ) : Type 1 where |
| 139 | /-- The walks whose reachability relations the formulas may read. -/ |
| 140 | fam : TCFamily L |
| 141 | /-- The interpretation, over the base vocabulary expanded by the walks' |
| 142 | relation variables. -/ |
| 143 | toRel : RelFOInterpretation (L.sum fam.block.lang) L' Tag dim |
| 144 | |
| 145 | namespace TCInterpretation |
| 146 | |
| 147 | variable {L L' : Language.{0, 0}} {Tag : Type} {dim : ℕ} |
| 148 | |
| 149 | variable (I : TCInterpretation L L' Tag dim) (A : Type) [L.Structure A] |
| 150 | |
| 151 | /-- The base structure expanded by the reachability relations of the walks – |
| 152 | the structure the interpretation is read over. -/ |
| 153 | @[reducible] |
| 154 | def expStructure : (L.sum I.fam.block.lang).Structure A := |
| 155 | SOBlock.structure₁ (L := L) I.fam.block (I.fam.reachAssign A) |
| 156 | |
| 157 | /-- The universe of the interpreted structure. -/ |
| 158 | def Map : Type := |
| 159 | letI := I.expStructure A |
| 160 | I.toRel.MapRel A |
| 161 | |
| 162 | /-- The `L'`-structure interpreted in `A`. -/ |
| 163 | instance mapStructure [L'.IsRelational] : L'.Structure (I.Map A) := |
| 164 | letI := I.expStructure A |
| 165 | RelFOInterpretation.mapRelStructure I.toRel A |
| 166 | |
| 167 | end TCInterpretation |
| 168 | |
| 169 | open FirstOrder |
| 170 | |
| 171 | open Language Structure |
| 172 | |
| 173 | namespace ParamTCSpec |
| 174 | |
| 175 | variable {L : Language.{0, 0}} (s : ParamTCSpec L) |
| 176 | |
| 177 | /-- The renaming used by the uniqueness clause: the step formula is re-read |
| 178 | with its first tuple still the current one, its second tuple the freshly |
| 179 | quantified `w̄`, and its parameters unchanged. -/ |
| 180 | def detVar : ((Fin s.k ⊕ Fin s.k) ⊕ Fin s.par) → (((Fin s.k ⊕ Fin s.k) ⊕ Fin s.par) ⊕ Fin s.k) |
| 181 | | Sum.inl (Sum.inl i) => Sum.inl (Sum.inl (Sum.inl i)) |
| 182 | | Sum.inl (Sum.inr i) => Sum.inr i |
| 183 | | Sum.inr j => Sum.inl (Sum.inr j) |
| 184 | |
| 185 | open Classical in |
| 186 | /-- **The determinized step formula** at a pair of modes: this step, and no |
| 187 | other step out of the current node. As in |
| 188 | `TCSpec.detStep`, the competing successor's mode is |
| 189 | compared statically, so the uniqueness clause has one conjunct per mode. -/ |
| 190 | noncomputable def detStep (m n : s.Mode) : L.Formula ((Fin s.k ⊕ Fin s.k) ⊕ Fin s.par) := |
| 191 | s.step m n ⊓ |
| 192 | Formula.iInf fun m' : s.Mode => |
| 193 | Formula.iAlls (Fin s.k) |
| 194 | (((s.step m m').relabel s.detVar).imp |
| 195 | (if m' = n then |
| 196 | Formula.iInf fun i : Fin s.k => |
| 197 | Term.equal (Term.var (Sum.inr i)) (Term.var (Sum.inl (Sum.inl (Sum.inr i)))) |
| 198 | else ⊥)) |
| 199 | |
| 200 | /-- **The deterministic reading of a walk**: the same modes, arity and |
| 201 | parameters, with the step formula replaced by its determinization. |
| 202 | |
| 203 | Reducible, so that the modes, the arity, and the parameter count of `s.det` are |
| 204 | those of `s` transparently – a node of the deterministic reading *is* a node, |
| 205 | and the block of a determinized family *is* the block of the family. -/ |
| 206 | @[reducible] |
| 207 | noncomputable def det : ParamTCSpec L where |
| 208 | Mode := s.Mode |
| 209 | k := s.k |
| 210 | par := s.par |
| 211 | step := s.detStep |
| 212 | |
| 213 | end ParamTCSpec |
| 214 | |
| 215 | namespace TCFamily |
| 216 | |
| 217 | variable {L : Language.{0, 0}} (F : TCFamily L) |
| 218 | |
| 219 | /-- The deterministic reading of a family: every walk read through its |
| 220 | determinization. Reducible, so that `F.det.block` *is* `F.block`. -/ |
| 221 | @[reducible] |
| 222 | noncomputable def det : TCFamily L where |
| 223 | Ix := F.Ix |
| 224 | spec := fun i => (F.spec i).det |
| 225 | |
| 226 | end TCFamily |
| 227 | |
| 228 | /-- An **FO(DTC) reduction** from `P` to `Q` – a deterministic |
| 229 | logarithmic-space reduction, in the logical form of Immerman: an interpretation over the ordered |
| 230 | expansion whose formulas may read the reachability relations of a family of |
| 231 | walks, each read through its determinization. -/ |
| 232 | structure DTCReduction {L L' : Language.{0, 0}} [L.IsRelational] [L'.IsRelational] |
| 233 | (P : DecisionProblem L) |
| 234 | (Q : DecisionProblem L') : Type 1 where |
| 235 | /-- The tags used by the underlying interpretation. -/ |
| 236 | Tag : Type |
| 237 | /-- Tags are finite, so that finite structures map to finite structures. -/ |
| 238 | [tagFinite : Finite Tag] |
| 239 | /-- The dimension of the underlying interpretation. -/ |
| 240 | dim : ℕ |
| 241 | /-- The walks the formulas may read – *before* determinization, which is how |
| 242 | they are read. -/ |
| 243 | fam : TCFamily (L.sum Language.order) |
| 244 | /-- The interpretation, over the base expanded by the walks' relation |
| 245 | variables. -/ |
| 246 | toRel : RelFOInterpretation ((L.sum Language.order).sum fam.block.lang) L' Tag dim |
| 247 | /-- The interpreted structure is nonempty on nonempty finite ordered |
| 248 | inputs. -/ |
| 249 | map_nonempty : ∀ (A : Type) [L.Structure A] [LinearOrder A] [Finite A] [Nonempty A], |
| 250 | Nonempty (TCInterpretation.Map ⟨fam.det, toRel⟩ A) |
| 251 | /-- Yes-instances map exactly to yes-instances, whatever the linear order. -/ |
| 252 | correct : ∀ (A : Type) [L.Structure A] [LinearOrder A] [Finite A] [Nonempty A], |
| 253 | P A ↔ Q (TCInterpretation.Map ⟨fam.det, toRel⟩ A) |
| 254 | |
| 255 | end Lax945089.TransitiveClosureReductions |
| 256 |
Builds on
Used by
Lax945089.EhrenfeuchtMethodologyLax945089.EvenInvarianceLax945089.EvenNotFirstOrderLax945089.FirstOrderBelowACZeroLax945089.FirstOrderBelowTransitiveClosureLax945089.GamesOnLinearOrdersLax945089.GamesOnSetsLax945089.NoDefinableOrderLax945089.OrderFreeInductionMissesPTIMELax945089.ParityInLogSpaceLax945089.PebbleInvarianceLax945089.ReductionsBelowLogSpace
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments