Polynomial-time computation by a word RAM

Lax759944.RamPolytime · concepts/Lax759944/RamPolytime.lean · lax-759944

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

    A total function from finite lists of natural numbers to finite lists of natural numbers is computable in polynomial time by a word RAM when there are one uniform program, a polynomial word-length bound, and a polynomial running-time bound with the following property.

    For an input whose canonical binary encoding has length n, the RAM receives the physical tape x.length::xx.length :: x. Every tape and output entry fits in a word of the bounded length, and at every word length at least that bound the program returns the exact output within the bounded number of RAM instructions. Both polynomials are evaluated at n.

    The length prefix is this submission's explicit encoding, supplied unchanged to Lax808846's read-only input array and sequential tape. It is not added by the machine. Working memory starts at zero and output is append-only. Programs may use EOF testing, input length, and indexed input; an executed terminal instruction is included in the time bound.

    Measuring input size in bits, rather than in the number of entries, puts the RAM and Turing machine on the same input-size scale. Requiring correctness at every sufficiently large word length makes the program uniform in the word length. Requiring a polynomial sufficient word length is what permits a Turing machine to simulate each operation on a word in polynomial time. No lower bound such as logarithmic word length is separately necessary: the explicit fitting condition says directly that the length prefix, all native input entries, and all exact output entries are representable.

    Concept map
    3 concepts; 6 descendants hidden
    100%
    Proven claimOpen claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Lax808846.Ram
    2import Lax759944.BinaryWordEncoding
    3import Mathlib.Algebra.Polynomial.Eval.Defs
    4
    5/-!
    6---
    7title: Polynomial-time computation by a word RAM
    8type: definition
    9---
    10A total function from finite lists of natural numbers to finite lists of
    11natural numbers is computable in polynomial time by a word RAM when there
    12are one uniform program, a polynomial word-length bound, and a polynomial
    13running-time bound with the following property.
    14
    15For an input whose canonical binary encoding has length *n*, the RAM receives
    16the physical tape `x.length :: x`. Every tape and output entry fits in a word
    17of the bounded length, and at every word length at least that bound the program
    18returns the exact output within the bounded number of RAM instructions. Both
    19polynomials are evaluated at *n*.
    20
    21The length prefix is this submission's explicit encoding, supplied unchanged
    22to Lax808846's read-only input array and sequential tape. It is not added by
    23the machine. Working memory starts at zero and output is append-only. Programs
    24may use EOF testing, input length, and indexed input; an executed terminal
    25instruction is included in the time bound.
    26
    27Measuring input size in bits, rather than in the number of entries, puts the
    28RAM and Turing machine on the same input-size scale. Requiring correctness
    29at every sufficiently large word length makes the program uniform in the
    30word length. Requiring a polynomial sufficient word length is what permits
    31a Turing machine to simulate each operation on a word in polynomial time.
    32No lower bound such as logarithmic word length is separately necessary:
    33the explicit fitting condition says directly that the length prefix, all
    34native input entries, and all exact output entries are representable.
    35-/
    36
    37namespace Lax759944.RamPolytime
    38
    39open Lax808846.Ram
    40open Lax759944.BinaryWordEncoding
    41
    42/-- Every entry of `x` is representable by a word of `w` bits. -/
    43def FitsInWords (w : ℕ) (x : List ℕ) : Prop :=
    44 ∀ a ∈ x, a < 2 ^ w
    45
    46/-- Polynomial-time computation by one uniform word-RAM program, measured
    47in the bit-size of the logical word-list input. The physical input is explicitly
    48length-prefixed. All instructions of Lax808846 are available, including access
    49to the immutable original input independently of sequential reads. -/
    50def RamPolytime (f : List ℕ → List ℕ) : Prop :=
    51 ∃ (p : Program) (wordBound timeBound : Polynomial ℕ),
    52 ∀ x : List ℕ,
    53 FitsInWords (wordBound.eval (bitSize x)) ((x.length :: x) ++ f x) ∧
    54 ∀ w : ℕ, wordBound.eval (bitSize x) ≤ w →
    55 ∃ t ≤ timeBound.eval (bitSize x),
    56 RunsTo w p (x.length :: x) (f x) t
    57
    58end Lax759944.RamPolytime
    59

    Discussion

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

    Loading discussion…