Lax554803.MachineModels
Finite-stack and elementary single-tape definitions of P
concepts/Lax554803/MachineModels.lean · lax-554803
No public endorsements yet.
Loading review…
Sign in with ORCIDConcept map
Definition
The finite-stack class requires every stack alphabet to be finite. The single-tape class uses a deterministic machine whose transitions each move the head one square or write one symbol. Its alphabet and control states are finite. The input is written in its original order, starting at the head, with blank tape elsewhere. The two input symbols are distinct and different from blank. A halted control state determines the Boolean answer; work tape need not be erased.
Lean source view on GitHub
| 1 | import Lax554803.PolynomialTime |
| 2 | import Mathlib.Computability.TuringMachine.PostTuringMachine |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Finite-stack and elementary single-tape definitions of P |
| 7 | type: definition |
| 8 | --- |
| 9 | The finite-stack class requires every stack alphabet to be finite. The |
| 10 | single-tape class uses a deterministic machine whose transitions each move |
| 11 | the head one square or write one symbol. Its alphabet and control states |
| 12 | are finite. The input is |
| 13 | written in its original order, starting at the head, with blank tape elsewhere. |
| 14 | The two input symbols are distinct and different from blank. A halted control |
| 15 | state determines the Boolean answer; work tape need not be erased. |
| 16 | -/ |
| 17 | |
| 18 | namespace Lax554803.MachineModels |
| 19 | |
| 20 | open Turing PolynomialTime |
| 21 | |
| 22 | /-- Polynomial-time stack deciders with finite alphabets at every stack. -/ |
| 23 | def FiniteStackP : Set Language := |
| 24 | {L | ∃ (f : Word → Bool) |
| 25 | (M : TM2ComputableInPolyTime id Computability.encodeBool f), |
| 26 | (∀ w, f w = true ↔ w ∈ L) ∧ ∀ k, Finite (M.tm.Γ k)} |
| 27 | |
| 28 | /-- A finite elementary single-tape machine, with ordinary binary input. -/ |
| 29 | structure SingleTape where |
| 30 | Γ : Type |
| 31 | Q : Type |
| 32 | [alphabet : Fintype Γ] |
| 33 | [control : Fintype Q] |
| 34 | [blank : Inhabited Γ] |
| 35 | [initial : Inhabited Q] |
| 36 | input : Bool ↪ Γ |
| 37 | input_ne_blank : ∀ b, input b ≠ default |
| 38 | transition : TM0.Machine Γ Q |
| 39 | accept : Q → Bool |
| 40 | |
| 41 | attribute [instance] SingleTape.alphabet SingleTape.control SingleTape.blank SingleTape.initial |
| 42 | |
| 43 | /-- The standard single-tape formulation: one machine and one polynomial, |
| 44 | halting on every input, with acceptance exactly matching membership. -/ |
| 45 | def SingleTapeP : Set Language := |
| 46 | {L | ∃ (M : SingleTape) (p : Polynomial ℕ), ∀ w : Word, |
| 47 | ∃ c : TM0.Cfg M.Γ M.Q, |
| 48 | Nonempty (StateTransition.EvalsToInTime (TM0.step M.transition) |
| 49 | (TM0.init (w.map M.input)) (some c) (p.eval w.length)) ∧ |
| 50 | TM0.step M.transition c = none ∧ (M.accept c.q = true ↔ w ∈ L)} |
| 51 | |
| 52 | end Lax554803.MachineModels |
| 53 |
Community review
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.
0 comments