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