Two-way finite automata #
Adapted from OpenAI's one-way-liveness formalization (25 September 2026): https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/lean/OAI/Combinatorics/Automata/Model.lean
The input is enclosed by two distinct endmarkers. Transitions cannot cross
these boundaries. Acceptance means that a finite run reaches an accepting
state, with no requirement that rejected inputs halt. The Boolean positive
parameter selects whether a length-zero accepting run is permitted (false)
or excluded (true). NoLeft permits stationary moves as well as right moves.
State counts include all states. These are finite automata, independently of
the work tapes and time accounting of the library's Turing machines.
The relation between two head positions specified by a move.
Equations
- Complexity.FiniteAutomaton.Move.left.Rel x✝¹ x✝ = (x✝ + 1 = x✝¹)
- Complexity.FiniteAutomaton.Move.stay.Rel x✝¹ x✝ = (x✝ = x✝¹)
- Complexity.FiniteAutomaton.Move.right.Rel x✝¹ x✝ = (x✝ = x✝¹ + 1)
Instances For
A deterministic two-way finite automaton with exactly s named states.
- initial : Fin s
The initial control state.
The accepting control states.
The next control states and head moves for each scanned symbol.
Instances For
A nondeterministic two-way finite automaton with exactly n named states.
- initial : Fin n
The initial control state.
The accepting control states.
The next control states and head moves for each scanned symbol.
- left_boundary (q q' : Fin n) : (q', Move.left) ∉ self.transition q Symbol.left
- right_boundary (q q' : Fin n) : (q', Move.right) ∉ self.transition q Symbol.right
Instances For
A deterministic transition and its associated head movement.
Equations
- M.Step w c c' = ∃ (d : Complexity.FiniteAutomaton.Move), M.transition c.2 (Complexity.FiniteAutomaton.scanned w c.1) = some (c'.2, d) ∧ d.Rel ↑c.1 ↑c'.1
Instances For
A chosen nondeterministic transition and its associated head movement.
Equations
- M.Step w c c' = ∃ (d : Complexity.FiniteAutomaton.Move), (c'.2, d) ∈ M.transition c.2 (Complexity.FiniteAutomaton.scanned w c.1) ∧ d.Rel ↑c.1 ↑c'.1
Instances For
The positive convention explicitly excludes a length-zero computation.
Equations
- Complexity.FiniteAutomaton.FiniteRun positive step c c' = if positive = true then Relation.TransGen step c c' else Relation.ReflTransGen step c c'
Instances For
No transition moves the input head left; stationary moves are allowed.
Equations
- M.NoLeft = ∀ (q : Fin n) (a : Complexity.FiniteAutomaton.Symbol Alpha) (q' : Fin n), (q', Complexity.FiniteAutomaton.Move.left) ∉ M.transition q a
Instances For
An alphabet-independent polynomial bound for deterministic simulation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A polynomial deterministic simulation bound restricted to one-way nondeterministic inputs.
Equations
- One or more equations did not get rendered due to their size.