Documentation

CslibFrontier.Computability.Complexity.RealAlgebraic.Controlled

Controlled integer polynomial families #

A polynomial is a mathematical specification, not machine input. A controlled family supplies polynomial-time binary degree, logarithmic coefficient-mass and prime-cutoff bounds, a polynomial-time unary arity, and one total modular evaluator at a fixed counting level. Bounds depend only on the primary instance. Evaluation points are lists of binary naturals; missing coordinates are zero.

The interface allows exponential degrees and exponentially long coefficients without assuming their expanded encodings are available. Constants, variables, addition, multiplication and binary powers construct actual evaluators at the original function level. Adapted from lean-canny’s controlled-polynomial interface.

Main definitions #

Main results #

@[reducible, inline]

An instance, a binary modulus and a list of binary coordinates. The instance and modulus are framed; the coordinate list uses the native list encoding.

noncomputable def Cslib.Complexity.RealAlgebraic.evaluation {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (p : ℕ) (z : List ℕ) :

Polynomial evaluation at the supplied coordinates, padded by zeros.

structure Cslib.Complexity.RealAlgebraic.Controlled {α : Type} {n : α → ℕ} (P : (w : α) → MvPolynomial (Fin (n w)) ℤ) (enc : α ↪ List Bool) (a : ℕ) :

Uniform finite-field access with bounds independent of the evaluation prime. The polynomial family is never passed to the realizing machine.

noncomputable def Cslib.Complexity.RealAlgebraic.Controlled.preprocess {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} {P : (w : α) → MvPolynomial (Fin (n w)) ℤ} {β : Type} {enc' : β ↪ List Bool} (C : Controlled P enc a) (g : β → α) (hg : Turing.MultiTapeTM.ComputableInPolyTime g enc' enc) :
Controlled (fun (w : β) => P (g w)) enc' a

Reindex a controlled family along a polynomial-time map, keeping the source's arity, bounds and modular evaluator at the same counting level.

def Cslib.Complexity.RealAlgebraic.Controlled.mono {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a b : ℕ} {P : (w : α) → MvPolynomial (Fin (n w)) ℤ} (C : Controlled P enc a) (hab : a ≤ b) :
Controlled P enc b

Increasing the fixed counting level retains the same bounds and evaluator.

noncomputable def Cslib.Complexity.RealAlgebraic.Controlled.ite {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} {P Q : (w : α) → MvPolynomial (Fin (n w)) ℤ} (CP : Controlled P enc a) (CQ : Controlled Q enc a) (guard : α → Bool) (hguard : Turing.MultiTapeTM.ComputableInPolyTime guard enc Turing.MultiTapeTM.encBool) :
Controlled (fun (w : α) => if guard w = true then P w else Q w) enc a

A polynomial-time guard selects one of two controlled families at their common counting level. The degree, norm exponent and prime cutoff are the maxima of the two branch bounds.

@[simp]
theorem Cslib.Complexity.RealAlgebraic.Controlled.degreeBound_ite {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} {P Q : (w : α) → MvPolynomial (Fin (n w)) ℤ} (CP : Controlled P enc a) (CQ : Controlled Q enc a) (guard : α → Bool) (hguard : Turing.MultiTapeTM.ComputableInPolyTime guard enc Turing.MultiTapeTM.encBool) (w : α) :
(CP.ite CQ guard hguard).degreeBound w = max (CP.degreeBound w) (CQ.degreeBound w)

A guarded family uses the maximum degree bound of its two branches.

@[simp]
theorem Cslib.Complexity.RealAlgebraic.Controlled.massExponent_ite {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} {P Q : (w : α) → MvPolynomial (Fin (n w)) ℤ} (CP : Controlled P enc a) (CQ : Controlled Q enc a) (guard : α → Bool) (hguard : Turing.MultiTapeTM.ComputableInPolyTime guard enc Turing.MultiTapeTM.encBool) (w : α) :
(CP.ite CQ guard hguard).massExponent w = max (CP.massExponent w) (CQ.massExponent w)

A guarded family uses the maximum norm exponent of its two branches.

@[simp]
theorem Cslib.Complexity.RealAlgebraic.Controlled.cutoff_ite {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} {P Q : (w : α) → MvPolynomial (Fin (n w)) ℤ} (CP : Controlled P enc a) (CQ : Controlled Q enc a) (guard : α → Bool) (hguard : Turing.MultiTapeTM.ComputableInPolyTime guard enc Turing.MultiTapeTM.encBool) (w : α) :
(CP.ite CQ guard hguard).cutoff w = max (CP.cutoff w) (CQ.cutoff w)

A guarded family uses the maximum prime cutoff of its two branches.

A polynomial-time integer family gives a controlled constant polynomial.

noncomputable def Cslib.Complexity.RealAlgebraic.Controlled.coordinate {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} (hn : Turing.MultiTapeTM.ComputableInPolyTime n enc Turing.MultiTapeTM.encUnary) (i : (w : α) → Fin (n w)) (hi : Turing.MultiTapeTM.ComputableInPolyTime (fun (w : α) => ↑(i w)) enc Turing.MultiTapeTM.encUnary) :
Controlled (fun (w : α) => MvPolynomial.X (i w)) enc a

A selected coordinate is controlled. The index is unary because it is bounded by the polynomially many variables, whereas coordinate values are binary.

noncomputable def Cslib.Complexity.RealAlgebraic.Controlled.add {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} {P Q : (w : α) → MvPolynomial (Fin (n w)) ℤ} (CP : Controlled P enc a) (CQ : Controlled Q enc a) :
Controlled (fun (w : α) => P w + Q w) enc a

Adding controlled polynomials preserves the common counting level.

noncomputable def Cslib.Complexity.RealAlgebraic.Controlled.mul {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} {P Q : (w : α) → MvPolynomial (Fin (n w)) ℤ} (CP : Controlled P enc a) (CQ : Controlled Q enc a) :
Controlled (fun (w : α) => P w * Q w) enc a

Multiplication uses only the two modular values and ordinary modular arithmetic.

noncomputable def Cslib.Complexity.RealAlgebraic.Controlled.pow {α : Type} {n : α → ℕ} {enc : α ↪ List Bool} {a : ℕ} {P : (w : α) → MvPolynomial (Fin (n w)) ℤ} (CP : Controlled P enc a) (e : α → ℕ) (he : Turing.MultiTapeTM.ComputableInPolyTime e enc Turing.MultiTapeTM.encNat) :
Controlled (fun (w : α) => P w ^ e w) enc a

Binary exponents may have exponential value. Modular powering preserves the level, while degree and logarithmic mass bounds require only binary multiplication.