Polynomial-time implementations of encoded functions and contracts
Lax218471.PolynomialTime · concepts/Lax218471/PolynomialTime.lean · lax-218471
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
Polynomial time is measured in the length of the specified input encoding. An implementation contains an actual finite TM2 and a polynomial time bound. A contract may restrict the valid inputs: callers must establish the contract at every call. This permits direct use of algorithms whose correctness is known only on well-formed encodings.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Computability.TuringMachine.Computable |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Polynomial-time implementations of encoded functions and contracts |
| 6 | type: definition |
| 7 | --- |
| 8 | Polynomial time is measured in the length of the specified input encoding. |
| 9 | An implementation contains an actual finite TM2 and a polynomial time bound. |
| 10 | A contract may restrict the valid inputs: callers must establish the contract |
| 11 | at every call. This permits direct use of algorithms whose correctness is |
| 12 | known only on well-formed encodings. |
| 13 | -/ |
| 14 | |
| 15 | namespace Lax218471.PolynomialTime |
| 16 | |
| 17 | open Turing |
| 18 | |
| 19 | /-- Existence of a finite machine computing an encoded function in polynomial time. -/ |
| 20 | def Polytime {α β A B : Type} (ea : α → List A) (eb : β → List B) (f : α → β) : Prop := |
| 21 | Nonempty (TM2ComputableInPolyTime ea eb f) |
| 22 | |
| 23 | /-- A finite machine and a time bound realizing every input/output pair of a contract. -/ |
| 24 | structure Implementation {A : Type} (R : List A → List A → Prop) extends |
| 25 | TM2ComputableAux A A where |
| 26 | time : Polynomial ℕ |
| 27 | correct : ∀ x y, R x y → |
| 28 | Nonempty (TM2OutputsInTime tm (x.map inputAlphabet.symm) |
| 29 | (some (y.map outputAlphabet.symm)) (time.eval x.length)) |
| 30 | |
| 31 | /-- The input/output relation of an encoded function. -/ |
| 32 | def Graph {α β A : Type} (ea : α → List A) (eb : β → List A) (f : α → β) |
| 33 | (x y : List A) : Prop := ∃ a, ea a = x ∧ eb (f a) = y |
| 34 | |
| 35 | end Lax218471.PolynomialTime |
| 36 |
Builds on
none
From Mathlib
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments