While this submission is a draft, it cannot be used by other submissions.

Counting the accepting runs of a Turing machine

Lax366625.CountingRuns · concepts/Lax366625/CountingRuns.lean · lax-366625

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    On a machine instance of the NP core, a walk lays a run out along the positions: a configuration for each position, initial at the least one, related to the next one by a step, or kept unchanged in an accepting state, and accepting at the greatest. A halting walk moreover repeats an accepting configuration once it has reached one, and carries the initial configuration at the elements that are not positions, so that every run reaching an accepting state within the bound has exactly one halting walk. Counting accepting runs is the number of halting walks of a well-formed instance, and 00 for an ill-formed one.

    Concept map
    10 concepts; 12 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Mathlib.Tactic.FinCases
    2import Mathlib.Order.PiLex
    3import Mathlib.Data.Prod.Lex
    4import Mathlib.Data.Fintype.EquivFin
    5import Mathlib.ModelTheory.Order
    6import Mathlib.ModelTheory.Semantics
    7import Mathlib.ModelTheory.Complexity
    8import Mathlib.Logic.Equiv.Fin.Basic
    9import Mathlib.Data.Fintype.Lattice
    10import Mathlib.Data.Finite.Sigma
    11import Mathlib.Order.Lattice.Nat
    12import Mathlib.Data.Set.Card
    13import Mathlib.Data.Fintype.Pigeonhole
    14import Mathlib.Dynamics.FixedPoints.Basic
    15import Mathlib.ModelTheory.Syntax
    16import Mathlib.Algebra.Order.BigOperators.Group.Finset
    17import Mathlib.Data.Fintype.Card
    18import Mathlib.SetTheory.Cardinal.Finite
    19import Mathlib.Algebra.BigOperators.Finprod
    20import Mathlib.Data.Set.Finite.Lemmas
    21import Mathlib.Logic.Equiv.Prod
    22import Lax366625.MachineNumbers
    23import Lax904597.Machines
    24import Lax366625.CountingProblems
    25import Lax904597.SecondOrder
    26
    27/-!
    28---
    29title: Counting the accepting runs of a Turing machine
    30type: definition
    31---
    32On a machine instance of the NP core, a walk lays a run out along the
    33positions: a configuration for each position, initial at the least one,
    34related to the next one by a step, or kept unchanged in an accepting state,
    35and accepting at the greatest. A halting walk moreover repeats an accepting
    36configuration once it has reached one, and carries the initial configuration
    37at the elements that are not positions, so that every run reaching an
    38accepting state within the bound has exactly one halting walk. Counting
    39accepting runs is the number of halting walks of a well-formed instance, and
    4000 for an ill-formed one.
    41-/
    42
    43namespace Lax366625.CountingRuns
    44
    45open Lax366625.MachineNumbers Lax904597.Machines
    46
    47open FirstOrder
    48
    49open Language Structure Lax904597.SecondOrder.SOBlock
    50
    51namespace TMData
    52
    53variable {A : Type} (M : TMData A)
    54
    55/-- **A run laid out along the positions**: a configuration for each position,
    56initial at the lowest, related by a step – or by a stutter in an accepting
    57state, for a machine that has already accepted – at each immediate successor,
    58and accepting at the highest. -/
    59def IsWalk (conf : A → Config A) : Prop :=
    60 (∀ p, MinPos M.Le M.Posn p → M.IsInit (conf p)) ∧
    61 (∀ p q, SuccPos M.Le M.Posn p q →
    62 M.Step (conf p) (conf q) ∨ (M.Acc (conf p).state ∧ conf q = conf p)) ∧
    63 ∀ p, MaxPos M.Le M.Posn p → M.Acc (conf p).state
    64
    65
    66/-- **A halting walk**: a walk that repeats an accepting configuration once it
    67has reached one, and carries the initial configuration at the times that are
    68not positions. A run from an initial configuration to the first accepting one,
    69within the budget, has exactly one such layout. -/
    70def IsHaltWalk (conf : A → Config A) : Prop :=
    71 TMData.IsWalk M conf ∧
    72 (∀ p q, SuccPos M.Le M.Posn p q → M.Acc (conf p).state → conf q = conf p) ∧
    73 ∀ t p₀, ¬ M.Posn t → MinPos M.Le M.Posn p₀ → conf t = conf p₀
    74
    75end TMData
    76
    77open Lax366625.CountingProblems
    78
    79/-- **Counting accepting runs**: the number of halting walks of the machine
    80described by the instance, an ill-formed instance having none. -/
    81noncomputable def SharpNTMAccept : CountingProblem turing :=
    82 CountingProblem.ofFun fun A _ =>
    83 Nat.card {conf : A → Config A // (tmData A).WellFormed ∧ TMData.IsHaltWalk (tmData A) conf}
    84
    85end Lax366625.CountingRuns
    86

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…