Quantifier-free position tests #
A Subregular.Walk walks successor and predecessor steps from a position, and a
Subregular.WindowFormula is a boolean combination of label and definedness tests on such walks.
Because successor and predecessor are functions, a term reaches a bounded neighbourhood of its
position with no quantifiers, the syntactic source of strict locality. Satisfaction is
decidable, and a formula whose walks are backward with depth ≤ r reads only the r + 1
symbols ending at its position (BackBounded.realize_congr). These formulas are the guards of
logical transductions (Transduction.lean) and the term language of boolean monadic recursive
schemes (BMRS.lean).
Main definitions #
Subregular.succ?/Subregular.pred?: the next/previous position, as partial functions.Subregular.Walk: walks;Walk.evalreads the position a walk reaches,noneoff an edge.Walk.Backward/Walk.Forward/Walk.pdepth/Walk.sdepth: one-sided walks and how far back and forward a walk reaches.Subregular.WindowFormula: label/definedness tests on walks, closed under boolean combination;WindowFormula.Realizeis decidable satisfaction;initial/finalare the derived edge tests.WindowFormula.Bounded l r: every walk reaches at mostlback andrforward;WindowFormula.BackBounded risBounded r 0.
Main results #
Walk.eval_backward: a backward walk of depthjfrom positionnreads exactlyn - j.Walk.eval_bounded: a walk reads the same displacement from two positions whose windows have the same edges.Bounded.realize_congr: a bounded formula cannot distinguish positions whose windows agree;BackBounded.realize_congris the left-window case.
Implementation notes #
The logic is monadic — one position variable, so Walk.eval takes a position rather than an
assignment — since every consumer (transduction guards, BMRS) is; and there is no equality atom:
with a single position variable, two walks from one origin agree exactly when both are defined
with equal displacement, so equality tests reduce to definedness tests. It is a bespoke syntax
rather than a fragment of FirstOrder.Language: over a relational word signature,
quantifier-free formulas cannot leave their variables, so bounded-window reach requires
successor and predecessor as function symbols — but a mathlib Structure interprets function
symbols totally, whereas falling off an edge is the semantics here (defined, initial,
final).
References #
Positions #
The successor of n is the position after it, defined iff it is in range.
Equations
- Subregular.succ? w n = if n + 1 < w.length then some (n + 1) else none
Instances For
The predecessor of n is the position before it, defined iff n > 0.
Equations
- Subregular.pred? w 0 = none
- Subregular.pred? w n.succ = if n < w.length then some n else none
Instances For
The successor structure depends only on the length.
The predecessor structure depends only on the length.
Walks #
Equations
- Subregular.instDecidableEqWalk.decEq Subregular.Walk.var Subregular.Walk.var = isTrue ⋯
- Subregular.instDecidableEqWalk.decEq Subregular.Walk.var a.succ = isFalse ⋯
- Subregular.instDecidableEqWalk.decEq Subregular.Walk.var a.pred = isFalse ⋯
- Subregular.instDecidableEqWalk.decEq a.succ Subregular.Walk.var = isFalse ⋯
- Subregular.instDecidableEqWalk.decEq a.succ b.succ = if h : a = b then h ▸ have inst := Subregular.instDecidableEqWalk.decEq a a; isTrue ⋯ else isFalse ⋯
- Subregular.instDecidableEqWalk.decEq a.succ a_1.pred = isFalse ⋯
- Subregular.instDecidableEqWalk.decEq a.pred Subregular.Walk.var = isFalse ⋯
- Subregular.instDecidableEqWalk.decEq a.pred a_1.succ = isFalse ⋯
- Subregular.instDecidableEqWalk.decEq a.pred b.pred = if h : a = b then h ▸ have inst := Subregular.instDecidableEqWalk.decEq a a; isTrue ⋯ else isFalse ⋯
Instances For
The position a term reads, walking from position n of w; none once the walk falls off
an edge.
Equations
- Subregular.Walk.eval w n Subregular.Walk.var = if n < w.length then some n else none
- Subregular.Walk.eval w n t.succ = (Subregular.Walk.eval w n t).bind (Subregular.succ? w)
- Subregular.Walk.eval w n t.pred = (Subregular.Walk.eval w n t).bind (Subregular.pred? w)
Instances For
The variable reads its own in-domain position.
Terms read in-domain positions.
Directed walks #
Equations
- Subregular.Walk.var.instDecidableBackward = isTrue trivial
- t.pred.instDecidableBackward = t.instDecidableBackward
- a.succ.instDecidableBackward = isFalse not_false
Equations
- Subregular.Walk.var.instDecidableForward = isTrue trivial
- t.pred.instDecidableForward = isFalse not_false
- a.succ.instDecidableForward = a.instDecidableForward
A backward term of predecessor depth j, read from an in-range position n, reads exactly
position n - j — defined iff j ≤ n.
Bounded windows #
Window transport. From two in-range positions whose windows l back and r forward
have the same edges — an offset stays in range at one exactly when it does at the other — a
walk reaching at most l back and r forward reads the same displacement, or falls off at
both.
Quantifier-free formulas #
A quantifier-free formula is a boolean combination of label and definedness tests on term walks from a single position.
- label {α : Type u_2} : α → Walk → WindowFormula α
- defined {α : Type u_2} : Walk → WindowFormula α
- tru {α : Type u_2} : WindowFormula α
- fls {α : Type u_2} : WindowFormula α
- neg {α : Type u_2} : WindowFormula α → WindowFormula α
- conj {α : Type u_2} : WindowFormula α → WindowFormula α → WindowFormula α
- disj {α : Type u_2} : WindowFormula α → WindowFormula α → WindowFormula α
Instances For
Satisfaction of a formula at position n of w; tests on an undefined walk are false.
Equations
- Subregular.WindowFormula.Realize w n (Subregular.WindowFormula.label a t) = (((Subregular.Walk.eval w n t).bind fun (x : ℕ) => w[x]?) = some a)
- Subregular.WindowFormula.Realize w n (Subregular.WindowFormula.defined t) = (Subregular.Walk.eval w n t ≠ none)
- Subregular.WindowFormula.Realize w n Subregular.WindowFormula.tru = True
- Subregular.WindowFormula.Realize w n Subregular.WindowFormula.fls = False
- Subregular.WindowFormula.Realize w n φ.neg = ¬Subregular.WindowFormula.Realize w n φ
- Subregular.WindowFormula.Realize w n (φ.conj ψ) = (Subregular.WindowFormula.Realize w n φ ∧ Subregular.WindowFormula.Realize w n ψ)
- Subregular.WindowFormula.Realize w n (φ.disj ψ) = (Subregular.WindowFormula.Realize w n φ ∨ Subregular.WindowFormula.Realize w n ψ)
Instances For
Equations
- Subregular.WindowFormula.instDecidableRealize w n (Subregular.WindowFormula.label a t) = Subregular.WindowFormula.instDecidableRealize._aux_1 w n a t
- Subregular.WindowFormula.instDecidableRealize w n (Subregular.WindowFormula.defined t) = { decide := !decide (Subregular.Walk.eval w n t = none), reflects_decide := ⋯ }
- Subregular.WindowFormula.instDecidableRealize w n Subregular.WindowFormula.tru = isTrue trivial
- Subregular.WindowFormula.instDecidableRealize w n Subregular.WindowFormula.fls = isFalse not_false
- Subregular.WindowFormula.instDecidableRealize w n φ.neg = instDecidableNot
- Subregular.WindowFormula.instDecidableRealize w n (φ.conj ψ) = instDecidableAnd
- Subregular.WindowFormula.instDecidableRealize w n (φ.disj ψ) = instDecidableOr
t reads an initial position, one in the domain with no predecessor.
Equations
Instances For
t reads a final position, one in the domain with no successor.
Equations
Instances For
Bounded formulas read only a window #
A formula is bounded by l back and r forward if every walk it uses reaches at most l
positions back and r forward, so it reads only the window from l before its position to
r after.
Equations
- Subregular.WindowFormula.Bounded l r (Subregular.WindowFormula.label a t) = (t.pdepth ≤ l ∧ t.sdepth ≤ r)
- Subregular.WindowFormula.Bounded l r (Subregular.WindowFormula.defined t) = (t.pdepth ≤ l ∧ t.sdepth ≤ r)
- Subregular.WindowFormula.Bounded l r Subregular.WindowFormula.tru = True
- Subregular.WindowFormula.Bounded l r Subregular.WindowFormula.fls = True
- Subregular.WindowFormula.Bounded l r φ.neg = Subregular.WindowFormula.Bounded l r φ
- Subregular.WindowFormula.Bounded l r (φ.conj ψ) = (Subregular.WindowFormula.Bounded l r φ ∧ Subregular.WindowFormula.Bounded l r ψ)
- Subregular.WindowFormula.Bounded l r (φ.disj ψ) = (Subregular.WindowFormula.Bounded l r φ ∧ Subregular.WindowFormula.Bounded l r ψ)
Instances For
Equations
- Subregular.WindowFormula.instDecidableBounded l r (Subregular.WindowFormula.label a t) = { decide := decide (t.pdepth ≤ l) && decide (t.sdepth ≤ r), reflects_decide := ⋯ }
- Subregular.WindowFormula.instDecidableBounded l r (Subregular.WindowFormula.defined t) = { decide := decide (t.pdepth ≤ l) && decide (t.sdepth ≤ r), reflects_decide := ⋯ }
- Subregular.WindowFormula.instDecidableBounded l r Subregular.WindowFormula.tru = isTrue trivial
- Subregular.WindowFormula.instDecidableBounded l r Subregular.WindowFormula.fls = isTrue trivial
- Subregular.WindowFormula.instDecidableBounded l r φ.neg = Subregular.WindowFormula.instDecidableBounded l r φ
- Subregular.WindowFormula.instDecidableBounded l r (φ.conj ψ) = instDecidableAnd
- Subregular.WindowFormula.instDecidableBounded l r (φ.disj ψ) = instDecidableAnd
A formula is backward-bounded by r if it reads only the r + 1 positions ending at its
own, bounded by r back and nothing forward.
Equations
Instances For
A bounded formula reads only its window: it has the same truth value at (w, n) and
(w', n') whenever the windows l back and r forward agree — the same labels at each
offset, and the same offsets in range.
A backward-bounded formula reads only the r + 1 symbols ending at its position.