FormalConjecturesForMathlib/Computability/Complexity.lean
Explanation legend Lean4 Domain Explanation Language (L4DEL)
L4DEL explanations are a separate layer. They do not change the Lean source. Intuition is explanatory prose; numbered items are a reading path; sources link the wording back to evidence.
- L4DEL
- Lean4 Domain Explanation Language
Credit: The upstream authors and contributors retain credit for the project and mathematics. lean4-explainer only renders their pinned source and adds the separately disclosed explanation layer.
Project sources: Pinned project documentation, Formal Conjectures paper, arXiv v1
9 declarations, 0 contain sorry, 0 declared as axioms
Complexity Classes
This file contains formal definitions of notions from complexity theory, including the complexity classes P, NP, coNP, and BPP.
References:
- Sanjeev Arora and Boaz Barak. Computational Complexity: A Modern Approach. Cambridge University Press, 2009.
- Melissa Antonelli, Ugo Dal Lago, and Paolo Pistone. On Randomized Computational Models and Complexity Classes: a Historical Overview. 2024. arXiv:2409.11999
- Wikipedia: Complexity class
Imports (2)
Imported by 1 file
- abbrev
ComplexityTheory.DecisionProblemThe type of decision problems line 48 sourceSource documentation
The type of decision problems.
We define these as functions from lists of booleans to booleans, implicitly assuming the usual encodings.
no axioms what this means
Proof uses:
List,Boolabbrev DecisionProblem := List Bool → Bool
- abbrev
ComplexityTheory.DecisionComplexityClassThe type of complexity classes line 53 sourceSource documentation
The type of complexity classes. We define these as sets of decision problems.
no axioms what this means
Proof uses:
Set, ComplexityTheory.DecisionProblemabbrev DecisionComplexityClass := Set DecisionProblem
Mentions: ComplexityTheory.DecisionProblem
- def
ComplexityTheory.IsPolyTimeWithEncodingIsPolyTimeWithEncoding ea eb fasserts thatfis computable in polynomial time when its input and output are encoded via the givenEncodingseaandebline 59 sourceSource documentation
IsPolyTimeWithEncoding ea eb fasserts thatfis computable in polynomial time when its input and output are encoded via the givenEncodingseaandeb.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Computability.EncodingProof uses:
Nonempty,Turing.TM2ComputableInPolyTime,Computability.Encoding.encodedef IsPolyTimeWithEncoding {α β Γα Γβ : Type} (ea : Encoding α Γα) (eb : Encoding β Γβ) (f : α → β) := … - def
ComplexityTheory.IsPolyTimeDocumented declaration: IsPolyTime line 68 sourceSource documentation
A function is polynomial-time computable when it is
IsPolyTimeWithEncodingfor the canonicalBool-alphabet encodings of its domain and codomain as given by theBitstringEncodingtypeclass.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: BitstringEncoding
Proof uses: ComplexityTheory.IsPolyTimeWithEncoding,
Bool,BitstringEncoding.toEncodingdef IsPolyTime {α β : Type} [BitstringEncoding α] [BitstringEncoding β] (f : α → β) : Prop := …Mentions: BitstringEncoding
- theorem
ComplexityTheory.isPolyTime_idThe identity function is polynomial-time computable line 72 sourceSource documentation
The identity function is polynomial-time computable.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: BitstringEncoding, ComplexityTheory.IsPolyTime,
idProof uses:
Nonempty.intro,Turing.TM2ComputableInPolyTime,Bool,Computability.Encoding.encode,BitstringEncoding.toEncoding,Turing.idComputableInPolyTime, BitstringEncoding.bitEncode1 instances, coercions and auxiliary constants left out.
theorem isPolyTime_id {α : Type} [BitstringEncoding α] : IsPolyTime (id : α → α) := …Mentions: BitstringEncoding, ComplexityTheory.IsPolyTime
- def
ComplexityTheory.PThe class P is the set of decision problems decidable in polynomial time by a deterministic Turing machine line 81 sourceSource documentation
The class P is the set of decision problems decidable in polynomial time by a deterministic Turing machine.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: ComplexityTheory.DecisionComplexityClass
Proof uses:
Set.ofPred, ComplexityTheory.DecisionProblem, ComplexityTheory.IsPolyTime,List,Bool2 instances, coercions and auxiliary constants left out.
def P : DecisionComplexityClass := …
Mentions: ComplexityTheory.DecisionComplexityClass
- def
ComplexityTheory.NPThe class NP is the set of decision problems line 93 sourceSource documentation
The class NP is the set of decision problems $L$ such that there exists a polynomial $p$ over ℕ and a poly-time Turing machine computing a relation $R$ where for all $x$, $L(x)$ iff there exists a $w$ of length at most $p (|x|)$ such that $R(x,w)$ accepts.
See Definition 2.1 in Arora-Barak (2009).
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: ComplexityTheory.DecisionComplexityClass
Proof uses:
Set.ofPred, ComplexityTheory.DecisionProblem,Exists,Polynomial,Nat,Prod,List,Bool,And, ComplexityTheory.IsPolyTime,Iff,Eq,Bool.true,LE.le,List.length,Polynomial.eval,Prod.mk5 instances, coercions and auxiliary constants left out.
def NP : DecisionComplexityClass := …
Mentions: ComplexityTheory.DecisionComplexityClass
- def
ComplexityTheory.coNPThe class coNP is the set of decision problems whose complements are in NP line 102 sourceSource documentation
The class coNP is the set of decision problems whose complements are in NP.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: ComplexityTheory.DecisionComplexityClass
Proof uses:
Set.ofPred, ComplexityTheory.DecisionProblem,Membership.mem, ComplexityTheory.NP,Compl.compl,List,Bool4 instances, coercions and auxiliary constants left out.
def coNP : DecisionComplexityClass := …
Mentions: ComplexityTheory.DecisionComplexityClass
- def
ComplexityTheory.BPPThe class BPP is the set of decision problems line 114 sourceSource documentation
The class BPP is the set of decision problems $L$ such that there exists a polynomial $p$ over ℕ and a poly-time Turing machine computing a relation $R$ where for all $x$, a uniformly random string $r$ of length $p (|x|)$ satisfies $R (x, r) = L (x)$ with probability at least $2/3$.
See Definition 7.4 in Arora-Barak (2009), or Antonelli et al. (2024).
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: ComplexityTheory.DecisionComplexityClass
Proof uses:
Set.ofPred, ComplexityTheory.DecisionProblem,Exists,Polynomial,Nat,Prod,List,Bool,And, ComplexityTheory.IsPolyTime,LE.le,Rat,HDiv.hDiv,OfNat.ofNat,Finset.card,Fin,Polynomial.eval,List.length,Finset.filter,Eqand 4 more17 instances, coercions and auxiliary constants left out.
def BPP : DecisionComplexityClass := …
Mentions: ComplexityTheory.DecisionComplexityClass