Documentation

CslibFrontier.Computability.Complexity.Polyhedra.QuasiPolynomial

Piecewise Quasi-Polynomials, Faulhaber Summation, and Polynomial-Time Evaluation #

This module defines quasi-polynomials, rational polyhedral chambers, and piecewise quasi-polynomials on ℤ^d, establishes their algebraic closure laws and Faulhaber summation over arbitrary integer intervals, and proves that any fixed integer-valued piecewise quasi-polynomial is computable in polynomial time on a multi-tape Turing machine from binary-encoded inputs (Turing.MultiTapeTM.ComputableInPolyTime) with positivity decidable in Cslib.Complexity.P.

1. Quasi-polynomials #

A quasi-polynomial on ℤ^d: a finite-index sublattice sublattice ≤ (Fin d → ℤ) together with a rational multivariate polynomial poly z ∈ ℚ[X₁, …, X_d] for each coset z ∈ (Fin d → ℤ) ⧸ sublattice.

noncomputable def Cslib.Complexity.Polyhedra.QuasiPolynomial.eval {d : ℕ} (q : QuasiPolynomial d) (y : Fin d → ℤ) :

Evaluate a quasi-polynomial at an integer vector y : Fin d → ℤ.

The zero quasi-polynomial.

A constant rational quasi-polynomial.

@[simp]
theorem Cslib.Complexity.Polyhedra.QuasiPolynomial.eval_const {d : ℕ} (c : ℚ) (y : Fin d → ℤ) :
(const d c).eval y = c

A pure multivariate polynomial viewed as a quasi-polynomial with trivial period.

The sublattice M • ℤ^d of integer vectors divisible entrywise by M.

noncomputable def Cslib.Complexity.Polyhedra.QuasiPolynomial.ofPeriod {d M : ℕ} (hM : 0 < M) (P : (Fin d → ZMod M) → MvPolynomial (Fin d) ℚ) :

Construct a quasi-polynomial from an explicit positive modulus M and polynomials indexed by Fin d → ZMod M.

@[simp]
theorem Cslib.Complexity.Polyhedra.QuasiPolynomial.eval_ofPeriod {d M : ℕ} (hM : 0 < M) (P : (Fin d → ZMod M) → MvPolynomial (Fin d) ℚ) (y : Fin d → ℤ) :
(ofPeriod hM P).eval y = (MvPolynomial.eval fun (i : Fin d) => ↑(y i)) (P fun (i : Fin d) => ↑(y i))

Every quasi-polynomial has a positive integer period M such that M • ℤ^d ≤ q.sublattice.

noncomputable def Cslib.Complexity.Polyhedra.QuasiPolynomial.restrictSublattice {d : ℕ} (q : QuasiPolynomial d) (L' : AddSubgroup (Fin d → ℤ)) (hL' : L' ≤ q.sublattice) (hfin : Finite ((Fin d → ℤ) ⧸ L')) :

Refine the sublattice of a quasi-polynomial to a smaller finite-index sublattice L' ≤ L.

@[simp]
theorem Cslib.Complexity.Polyhedra.QuasiPolynomial.eval_restrictSublattice {d : ℕ} (q : QuasiPolynomial d) (L' : AddSubgroup (Fin d → ℤ)) (hL' : L' ≤ q.sublattice) (hfin : Finite ((Fin d → ℤ) ⧸ L')) (y : Fin d → ℤ) :
(q.restrictSublattice L' hL' hfin).eval y = q.eval y

Pointwise sum of two quasi-polynomials.

@[simp]
theorem Cslib.Complexity.Polyhedra.QuasiPolynomial.eval_add {d : ℕ} (q₁ q₂ : QuasiPolynomial d) (y : Fin d → ℤ) :
(q₁.add q₂).eval y = q₁.eval y + q₂.eval y

Pointwise scalar multiplication of a quasi-polynomial by a rational scalar.

@[simp]
theorem Cslib.Complexity.Polyhedra.QuasiPolynomial.eval_smul {d : ℕ} (c : ℚ) (q : QuasiPolynomial d) (y : Fin d → ℤ) :
(smul c q).eval y = c * q.eval y
noncomputable def Cslib.Complexity.Polyhedra.QuasiPolynomial.compAffine {d k : ℕ} (q : QuasiPolynomial k) (B : (Fin d → ℤ) →+ Fin k → ℤ) (c : Fin k → ℤ) :

Pull back a quasi-polynomial along an affine map y ↦ B y + c.

@[simp]
theorem Cslib.Complexity.Polyhedra.QuasiPolynomial.eval_compAffine {d k : ℕ} (q : QuasiPolynomial k) (B : (Fin d → ℤ) →+ Fin k → ℤ) (c : Fin k → ℤ) (y : Fin d → ℤ) :
(q.compAffine B c).eval y = q.eval (B y + c)
noncomputable def Cslib.Complexity.Polyhedra.QuasiPolynomial.mulPeriodicIndicator {d M : ℕ} (hM : 0 < M) (pred : (Fin d → ZMod M) → Prop) [DecidablePred pred] (q : QuasiPolynomial d) :

Multiply a quasi-polynomial by a periodic {0, 1} indicator pred : (Fin d → ZMod M) → Prop.

@[simp]
theorem Cslib.Complexity.Polyhedra.QuasiPolynomial.eval_mulPeriodicIndicator {d M : ℕ} (hM : 0 < M) (pred : (Fin d → ZMod M) → Prop) [DecidablePred pred] (q : QuasiPolynomial d) (y : Fin d → ℤ) :
(mulPeriodicIndicator hM pred q).eval y = if pred fun (i : Fin d) => ↑(y i) then q.eval y else 0

2. Polyhedral Chambers and Piecewise Quasi-Polynomials #

A rational polyhedral chamber in ℤ^d, defined as the intersection of finitely many closed rational half-spaces {y ∈ ℤ^d : ∑ i, a i * y i ≤ c}.

  • ineqs : List ((Fin d → ℤ) × ℤ)

    List of linear inequality constraints (a, c) representing ∑ i, a i * y i ≤ c.

The set of integer lattice points belonging to a polyhedral chamber.

The underlying real rational convex polyhedron {x ∈ ℝ^d : ∀ (a, c) ∈ ineqs, a · x ≤ c}.

theorem Cslib.Complexity.Polyhedra.PolyhedralChamber.mem_carrier_iff {d : ℕ} {C : PolyhedralChamber d} {y : Fin d → ℤ} :
y ∈ C.carrier ↔ ∀ p ∈ C.ineqs, ∑ i : Fin d, p.1 i * y i ≤ p.2

Every polyhedral chamber's real locus is a convex polyhedron.

The whole space ℤ^d as a chamber with no constraints.

Intersection of two polyhedral chambers.

Add a single linear inequality a · y ≤ c to a chamber.

theorem Cslib.Complexity.Polyhedra.PolyhedralChamber.mem_addIneq_iff {d : ℕ} {C : PolyhedralChamber d} {a : Fin d → ℤ} {c : ℤ} {y : Fin d → ℤ} :
y ∈ (C.addIneq a c).carrier ↔ ∑ i : Fin d, a i * y i ≤ c ∧ y ∈ C.carrier

Pull back a chamber along an affine map y ↦ B y + c.

Decidable check whether y : Fin d → ℤ belongs to a polyhedral chamber.

@[instance_reducible]

Decidability of membership in a rational polyhedral chamber.

A piecewise quasi-polynomial function on ℤ^d: a finite partition of ℤ^d into pairwise disjoint rational polyhedral chambers together with a quasi-polynomial on each chamber.

Evaluate a piecewise quasi-polynomial at y : Fin d → ℤ.

A single quasi-polynomial viewed as a piecewise quasi-polynomial on ℤ^d.

The zero piecewise quasi-polynomial.

Scalar multiplication of a piecewise quasi-polynomial by a rational scalar.

Pointwise sum of two piecewise quasi-polynomials on the common refinement of their chambers.

@[simp]
theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.eval_add {d : ℕ} (f₁ f₂ : PiecewiseQuasiPolynomial d) (y : Fin d → ℤ) :
(f₁.add f₂).eval y = f₁.eval y + f₂.eval y

Pull back a piecewise quasi-polynomial along an affine map y ↦ B y + c.

@[simp]
theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.eval_compAffine {d k : ℕ} (f : PiecewiseQuasiPolynomial k) (B : (Fin d → ℤ) →+ Fin k → ℤ) (c : Fin k → ℤ) (y : Fin d → ℤ) :
(f.compAffine B c).eval y = f.eval (B y + c)

Multiply a piecewise quasi-polynomial by a periodic {0, 1} indicator.

@[simp]
theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.eval_mulPeriodicIndicator {d M : ℕ} (hM : 0 < M) (pred : (Fin d → ZMod M) → Prop) [DecidablePred pred] (f : PiecewiseQuasiPolynomial d) (y : Fin d → ℤ) :
(mulPeriodicIndicator hM pred f).eval y = if pred fun (i : Fin d) => ↑(y i) then f.eval y else 0

Split a chamber partition by a single linear inequality a · y ≤ c and its complement (-a) · y ≤ -c - 1.

theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.splitPartition_cover {d : ℕ} {chambers : List (PolyhedralChamber d)} (hcov : ∀ (y : Fin d → ℤ), ∃ C ∈ chambers, y ∈ C.carrier) (a : Fin d → ℤ) (c : ℤ) (y : Fin d → ℤ) :
∃ C ∈ splitPartition chambers a c, y ∈ C.carrier
theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.splitPartition_disjoint {d : ℕ} {chambers : List (PolyhedralChamber d)} (hdisj : List.Pairwise (fun (C₁ C₂ : PolyhedralChamber d) => Disjoint C₁.carrier C₂.carrier) chambers) (a : Fin d → ℤ) (c : ℤ) :
List.Pairwise (fun (C₁ C₂ : PolyhedralChamber d) => Disjoint C₁.carrier C₂.carrier) (splitPartition chambers a c)

Split a chamber partition successively by a finite list of linear inequalities.

theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.splitPartitionList_cover {d : ℕ} {chambers : List (PolyhedralChamber d)} (hcov : ∀ (y : Fin d → ℤ), ∃ C ∈ chambers, y ∈ C.carrier) (ineqs : List ((Fin d → ℤ) × ℤ)) (y : Fin d → ℤ) :
∃ C ∈ splitPartitionList chambers ineqs, y ∈ C.carrier
theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.splitPartitionList_disjoint {d : ℕ} {chambers : List (PolyhedralChamber d)} (hdisj : List.Pairwise (fun (C₁ C₂ : PolyhedralChamber d) => Disjoint C₁.carrier C₂.carrier) chambers) (ineqs : List ((Fin d → ℤ) × ℤ)) :
List.Pairwise (fun (C₁ C₂ : PolyhedralChamber d) => Disjoint C₁.carrier C₂.carrier) (splitPartitionList chambers ineqs)
theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.splitPartitionList_decides {d : ℕ} (chambers : List (PolyhedralChamber d)) (ineqs : List ((Fin d → ℤ) × ℤ)) (C : PolyhedralChamber d) :
C ∈ splitPartitionList chambers ineqs → ∀ p ∈ ineqs, (∀ y ∈ C.carrier, ∑ i : Fin d, p.1 i * y i ≤ p.2) ∨ ∀ y ∈ C.carrier, ¬∑ i : Fin d, p.1 i * y i ≤ p.2

Every chamber in splitPartitionList decides every inequality in ineqs uniformly.

Predicate stating that a function g : (Fin d → ℤ) → ℚ is piecewise quasi-polynomial.

theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.isPiecewiseQuasiPolynomial_sum {d : ℕ} {ι : Type u_1} (s : Finset ι) (g : ι → (Fin d → ℤ) → ℚ) (hg : ∀ i ∈ s, IsPiecewiseQuasiPolynomial (g i)) :
IsPiecewiseQuasiPolynomial fun (y : Fin d → ℤ) => ∑ i ∈ s, g i y
theorem Cslib.Complexity.Polyhedra.PiecewiseQuasiPolynomial.isPiecewiseQuasiPolynomial_mulPeriodicIndicator {d M : ℕ} (hM : 0 < M) (pred : (Fin d → ZMod M) → Prop) [DecidablePred pred] {g : (Fin d → ℤ) → ℚ} (h : IsPiecewiseQuasiPolynomial g) :
IsPiecewiseQuasiPolynomial fun (y : Fin d → ℤ) => if pred fun (i : Fin d) => ↑(y i) then g y else 0

3. Faulhaber Polynomial Summation over Arbitrary Integer Intervals #

For each degree j : ℕ, there exists a rational polynomial Q : ℚ[X] satisfying the forward-difference identity Q(X + 1) - Q(X) = X ^ j.

Chosen Faulhaber antiderivative polynomial satisfying Q(X + 1) - Q(X) = X ^ j.

theorem Cslib.Complexity.Polyhedra.sum_Icc_pow_eq_faulhaber (j : ℕ) {a b : ℤ} (hab : a ≤ b + 1) :
∑ m ∈ Finset.Icc a b, ↑m ^ j = Polynomial.eval (↑(b + 1)) (faulhaberPoly j) - Polynomial.eval (↑a) (faulhaberPoly j)

Summing m ^ j over any integer interval Finset.Icc a b with a ≤ b + 1 equals faulhaberPoly j (b + 1) - faulhaberPoly j a.

theorem Cslib.Complexity.Polyhedra.exists_mvPoly_sum_Icc_ray {k : ℕ} (P : MvPolynomial (Fin k) ℚ) (v : Fin k → ℤ) :
∃ (Q : MvPolynomial (Fin (k + 2)) ℚ), ∀ (b : Fin k → ℤ) (lo hi : ℤ), lo ≤ hi + 1 → ∑ m ∈ Finset.Icc lo hi, (MvPolynomial.eval fun (i : Fin k) => ↑(b i - m * v i)) P = (MvPolynomial.eval fun (j : Fin (k + 2)) => if h : ↑j < k then ↑(b ⟨↑j, h⟩) else if ↑j = k then ↑lo else ↑hi) Q

Summing a multivariate polynomial P(b - m • v) over m ∈ Finset.Icc lo hi (lo ≤ hi + 1) yields a multivariate polynomial in (b, lo, hi).

4. Polynomial-Time Evaluation on Multi-Tape Turing Machines #

Evaluating a fixed integer multivariate polynomial P : MvPolynomial (Fin d) ℤ at binary integer inputs y : Fin d → ℤ is computable in polynomial time.

Polynomial-Time Evaluation of Fixed Piecewise Quasi-Polynomials: any integer-valued function g : (Fin d → ℤ) → ℤ given by a fixed piecewise quasi-polynomial is computable in polynomial time on a multi-tape Turing machine from binary-encoded inputs.

Polynomial-time evaluation of a nonnegative-integer-valued piecewise quasi-polynomial, outputting binary natural numbers (encNat).

Polynomial-Time Positivity Decision: deciding whether a fixed integer-valued piecewise quasi-polynomial is strictly positive lies in Cslib.Complexity.P.