Mathlib.Optimization.Affine­Sign­Cell­Closure

Finite real affine sign cells: mixed strict and weak inequalities, common-slack feasibility, closure by segment approximation, preserved extrema, and a checked degree-one polynomial bridge.

Basic 10 core · 8 supporting This module defines finite systems of real affine inequalities with individually weak or strict comparisons, together with their strict cells and weak relaxations. ★ isClosed_weakCell

Finite affine sign cells

This module defines finite systems of real affine inequalities with individually weak or strict comparisons, together with their strict cells and weak relaxations. It proves that the weak relaxation is a closed convex set.

structure AffineFn reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a finite number of coordinates, an affine real-valued function is specified by one coefficient for each coordinate and one constant term.

Definition (Lean source)
n :
The coefficient of each coordinate.
coeff :
Fin n → ℝ
The constant term.
constant :
Causalean.Mathlib.Optimization.AffineSignCellClosure.AffineFn · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:21
def eval reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure.AffineFn

Given an affine function and a coordinate vector, its evaluated real value is given by the finite coefficient-weighted sum plus the constant.

Definition (Lean source)
n :
f :
x :
Fin n → ℝ
eval f x :
∑ i, f.coeff i * x i + f.constant
Causalean.Mathlib.Optimization.AffineSignCellClosure.AffineFn.eval · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:33 · uses AffineFn
inductive ConstraintKind reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

A constraint kind records whether its affine inequality is weak or strict.

Definition (Lean source)
ConstraintKind :
Type
weak :

The constraint is interpreted with a weak comparison.

strict :

The constraint is interpreted with a strict comparison.

deriving DecidableEq, Repr
Causalean.Mathlib.Optimization.AffineSignCellClosure.ConstraintKind · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:66
structure Constraint reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a finite number of coordinates, a marked affine constraint contains its normalized affine left-hand side and its weak-or-strict mark.

Definition (Lean source)
n :
The affine left-hand side, normalized against zero.
fn :
Whether the normalized inequality is weak or strict.
Causalean.Mathlib.Optimization.AffineSignCellClosure.Constraint · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:75
abbrev AffineSystem reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a finite number of coordinates, an affine constraint system is given by a finite list of marked affine constraints.

Definition (Lean source)
n :
AffineSystem n :
Type
Causalean.Mathlib.Optimization.AffineSignCellClosure.AffineSystem · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:85
def strictHolds reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure.Constraint

Given a marked affine constraint and a coordinate vector, the original constraint-satisfaction condition uses the comparison selected by the constraint's mark.

Definition (Lean source)
n :
c :
x :
Fin n → ℝ
strictHolds c x :
Prop
match c.kind with | .weak => c.fn.eval x ≤ 0 | .strict => c.fn.eval x < 0
Causalean.Mathlib.Optimization.AffineSignCellClosure.Constraint.strictHolds · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:91 · uses Constraint
def weakHolds reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure.Constraint

Given a marked affine constraint and a coordinate vector, the weak constraint-satisfaction condition is given by the nonpositive affine evaluation.

Definition (Lean source)
n :
c :
x :
Fin n → ℝ
weakHolds c x :
Prop
c.fn.eval x ≤ 0
Causalean.Mathlib.Optimization.AffineSignCellClosure.Constraint.weakHolds · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:100 · uses Constraint
def strictCell reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given an affine constraint system, its strict cell is given by the points satisfying every listed constraint using its original comparison.

Definition (Lean source)
n :
Γ :
strictCell Γ :
Set (Fin n → ℝ)
{x | ∀ c ∈ Γ, c.strictHolds x}
Causalean.Mathlib.Optimization.AffineSignCellClosure.strictCell · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:109 · uses AffineSystem
def weakCell reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given an affine constraint system, its weak relaxation is given by the points weakly satisfying every listed constraint.

Definition (Lean source)
n :
Γ :
weakCell Γ :
Set (Fin n → ℝ)
{x | ∀ c ∈ Γ, c.weakHolds x}
Causalean.Mathlib.Optimization.AffineSignCellClosure.weakCell · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:116 · uses AffineSystem
theorem isClosed_weakCell reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given an affine constraint system, its weak relaxation is closed.

Formal statement
n :
Γ :
Proof (Lean source)
theorem isClosed_weakCell {n : ℕ} (Γ : AffineSystem n) : IsClosed (weakCell Γ) := by induction Γ with | nil => simp [weakCell] | cons c Γ ih => rw [show weakCell (c :: Γ) = {x | c.fn.eval x ≤ 0} ∩ weakCell Γ by ext x simp [weakCell, Constraint.weakHolds]] exact (isClosed_le c.fn.continuous_eval continuous_const).inter ih
Causalean.Mathlib.Optimization.AffineSignCellClosure.isClosed_weakCell · Causalean/Mathlib/Optimization/AffineSignCellClosure/Basic.lean:143 · uses AffineSystem , weakCell
8 supporting declarations (lemmas, instances)
Closure 2 core · 4 supporting Given one point satisfying every strict comparison, this module approximates every weakly feasible point by strictly feasible segment points and identifies the weak relaxation as the closure of the strict cell. ★ closure_strictCell_eq_weakCell

Segment approximation and closure of affine sign cells

Given one point satisfying every strict comparison, this module approximates every weakly feasible point by strictly feasible segment points and identifies the weak relaxation as the closure of the strict cell.

def segmentPoint reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a weak endpoint, a distinguished strict endpoint, and a real weight, the segment point is given by placing weight ε on the strict endpoint.

Definition (Lean source)
n :
x x₀ :
Fin n → ℝ
ε :
segmentPoint x x₀ ε :
Fin n → ℝ
(1 - ε) • x + ε • x₀
Causalean.Mathlib.Optimization.AffineSignCellClosure.segmentPoint · Causalean/Mathlib/Optimization/AffineSignCellClosure/Closure.lean:20
theorem closure_strictCell_eq_weakCell reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a nonempty strict cell, the closure of that strict cell equals its weak relaxation.

Formal statement
n :
:
(strictCell Γ).Nonempty
Proof (Lean source)
theorem closure_strictCell_eq_weakCell {n : ℕ} {Γ : AffineSystem n} (hΓ : (strictCell Γ).Nonempty) : closure (strictCell Γ) = weakCell Γ := by apply Set.Subset.antisymm · exact closure_minimal (strictCell_subset_weakCell Γ) (isClosed_weakCell Γ) · exact weakCell_subset_closure_strictCell
Causalean.Mathlib.Optimization.AffineSignCellClosure.closure_strictCell_eq_weakCell · Causalean/Mathlib/Optimization/AffineSignCellClosure/Closure.lean:86 · uses AffineSystem , strictCell , weakCell
4 supporting declarations (lemmas, instances)
Common­Slack 4 core · 6 supporting This module gives the bounded Phase-I common-slack characterization of strict feasibility: one positive margin is shared by all strict affine inequalities, while weak inequalities stay weak. ★ strictFeasible_iff_commonSlackValue_pos

Common-slack strict feasibility

This module gives the bounded Phase-I common-slack characterization of strict feasibility: one positive margin is shared by all strict affine inequalities, while weak inequalities stay weak.

def commonSlackFeasible reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given an affine constraint system, a coordinate vector, and a real slack, the common-slack feasibility condition is given by the slack being nonnegative, the slack being at most one, and every weak constraint evaluating to at most zero while every strict constraint evaluates to at most the negative slack.

Definition (Lean source)
n :
Γ :
x :
Fin n → ℝ
δ :
commonSlackFeasible Γ x δ :
Prop
clause 1
0 ≤ δ
clause 2
δ ≤ 1
clause 3
c ∈ Γ :
c.fn.eval x ≤ match c.kind with | .weak => 0 | .strict => -δ
Causalean.Mathlib.Optimization.AffineSignCellClosure.commonSlackFeasible · Causalean/Mathlib/Optimization/AffineSignCellClosure/CommonSlack.lean:20 · uses AffineSystem
def commonSlackSet reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given an affine constraint system, its feasible slack set is given by the slacks for which some coordinate vector is common-slack feasible.

Definition (Lean source)
n :
Γ :
commonSlackSet Γ :
Set
{δ | ∃ x, commonSlackFeasible Γ x δ}
Causalean.Mathlib.Optimization.AffineSignCellClosure.commonSlackSet · Causalean/Mathlib/Optimization/AffineSignCellClosure/CommonSlack.lean:30 · uses AffineSystem
def commonSlackValue reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given an affine constraint system, its common-slack value is given by the supremum of its feasible slack set.

Definition (Lean source)
n :
Γ :
commonSlackValue Γ :
Causalean.Mathlib.Optimization.AffineSignCellClosure.commonSlackValue · Causalean/Mathlib/Optimization/AffineSignCellClosure/CommonSlack.lean:37 · uses AffineSystem
theorem strictFeasible_iff_commonSlackValue_pos reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given an affine constraint system, its strict cell is nonempty exactly when its bounded common-slack value is positive.

Formal statement
n :
Γ :
(strictCell Γ).Nonempty ↔ 0 < commonSlackValue Γ
Proof (Lean source)
theorem strictFeasible_iff_commonSlackValue_pos {n : ℕ} (Γ : AffineSystem n) : (strictCell Γ).Nonempty ↔ 0 < commonSlackValue Γ := by constructor · rintro ⟨x, hx⟩ rcases positiveSlackWitness_of_strictPoint hx with ⟨δ, hδ, hfeas⟩ exact commonSlackValue_pos_of_witness hδ hfeas · intro hval rcases positiveSlackWitness_of_commonSlackValue_pos hval with ⟨δ, hδ, x, hx⟩ exact ⟨x, strictPoint_of_positiveSlack hδ hx⟩
Causalean.Mathlib.Optimization.AffineSignCellClosure.strictFeasible_iff_commonSlackValue_pos · Causalean/Mathlib/Optimization/AffineSignCellClosure/CommonSlack.lean:135 · uses AffineSystem , commonSlackValue , strictCell
6 supporting declarations (lemmas, instances)
Example 2 core · 3 supporting This module instantiates the API with the interval cut out by the strict inequality 0 < x and the weak inequality x ≤ 1. ★ closure_strictCell_mixedExample

Mixed strict/weak sign-cell example

This module instantiates the API with the interval cut out by the strict inequality 0 < x and the weak inequality x ≤ 1.

def mixedExample reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

The mixed one-dimensional example system is given by the strict lower inequality -x < 0 and the weak upper inequality x - 1 ≤ 0.

Definition (Lean source)
mixedExample :
[ { fn := { coeff := fun _ => -1, constant := 0 }, kind := .strict }, { fn := { coeff := fun _ => 1, constant := -1 }, kind := .weak } ]
Causalean.Mathlib.Optimization.AffineSignCellClosure.mixedExample · Causalean/Mathlib/Optimization/AffineSignCellClosure/Example.lean:19 · uses AffineSystem
theorem closure_strictCell_mixedExample reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

The closure of the example's half-open strict interval equals its closed weak interval.

Formal statement
Proof (Lean source)
theorem closure_strictCell_mixedExample : closure (strictCell mixedExample) = weakCell mixedExample := by apply closure_strictCell_eq_weakCell exact ⟨_, half_mem_strictCell_mixedExample⟩
Causalean.Mathlib.Optimization.AffineSignCellClosure.closure_strictCell_mixedExample · Causalean/Mathlib/Optimization/AffineSignCellClosure/Example.lean:43 · uses mixedExample , strictCell , weakCell
3 supporting declarations (lemmas, instances)
Extrema 1 core · 6 supporting Continuous real objectives have the same bounded infima and suprema on a nonempty strict affine cell and on its weak relaxation. ★ sInf_image_strictCell_eq_weakCell

Preservation of bounded extrema

Continuous real objectives have the same bounded infima and suprema on a nonempty strict affine cell and on its weak relaxation.

theorem sInf_image_strictCell_eq_weakCell reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a nonempty strict cell, a continuous real objective, and a lower bound for its strict-cell image, the strict and weak image sets have the same infimum.

Formal statement
n :
(Fin n → ℝ) → ℝ
:
(strictCell Γ).Nonempty
:
hBdd :
BddBelow (φ '' strictCell Γ)
sInf (φ '' strictCell Γ) = sInf (φ '' weakCell Γ)
Proof (Lean source)
theorem sInf_image_strictCell_eq_weakCell {n : ℕ} {Γ : AffineSystem n} {φ : (Fin n → ℝ) → ℝ} (hΓ : (strictCell Γ).Nonempty) (hφ : Continuous φ) (hBdd : BddBelow (φ '' strictCell Γ)) : sInf (φ '' strictCell Γ) = sInf (φ '' weakCell Γ) := by have hcl := closure_image_strictCell_eq_closure_image_weakCell hΓ hφ have hlb : lowerBounds (φ '' strictCell Γ) = lowerBounds (φ '' weakCell Γ) := by rw [← lowerBounds_closure (φ '' strictCell Γ), hcl, lowerBounds_closure] have hBdd' := bddBelow_image_weakCell_of_strictCell hΓ hφ hBdd have hne : (φ '' strictCell Γ).Nonempty := hΓ.image φ have hne' : (φ '' weakCell Γ).Nonempty := hne.mono (image_mono (strictCell_subset_weakCell Γ)) rw [← csSup_lowerBounds_eq_csInf hBdd hne, ← csSup_lowerBounds_eq_csInf hBdd' hne', hlb]
Causalean.Mathlib.Optimization.AffineSignCellClosure.sInf_image_strictCell_eq_weakCell · Causalean/Mathlib/Optimization/AffineSignCellClosure/Extrema.lean:47 · uses AffineSystem , strictCell , weakCell
6 supporting declarations (lemmas, instances)
Polynomial 7 core · 2 supporting This module compiles checked real multivariate polynomials of total degree at most one into the explicit affine-constraint representation and proves that this compilation preserves both strict and weak cells. ★ affineFnOfMvPolynomial_eval

Degree-one polynomial bridge

This module compiles checked real multivariate polynomials of total degree at most one into the explicit affine-constraint representation and proves that this compilation preserves both strict and weak cells.

def affineFnOfMvPolynomial reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a real multivariate polynomial, its compiled affine function is given by the coefficients of its degree-one monomials and its constant coefficient.

Definition (Lean source)
n :
p :
affineFnOfMvPolynomial p :
clause 1
coeff i := coeff (Finsupp.single i 1) p
clause 2
Causalean.Mathlib.Optimization.AffineSignCellClosure.affineFnOfMvPolynomial · Causalean/Mathlib/Optimization/AffineSignCellClosure/Polynomial.lean:21 · uses AffineFn
theorem affineFnOfMvPolynomial_eval reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a real multivariate polynomial, a proof that its total degree is at most one, and a coordinate vector, evaluating its compiled affine function equals evaluating the polynomial.

Formal statement
n :
p :
hp :
p.totalDegree ≤ 1
x :
Fin n → ℝ
(affineFnOfMvPolynomial p).eval x = eval x p
Proof (Lean source)
theorem affineFnOfMvPolynomial_eval {n : ℕ} (p : MvPolynomial (Fin n) ℝ) (hp : p.totalDegree ≤ 1) (x : Fin n → ℝ) : (affineFnOfMvPolynomial p).eval x = eval x p := by classical have hp_eq : p = C (coeff 0 p) + ∑ i, C (coeff (Finsupp.single i 1) p) * X i := by ext d by_cases hd0 : d = 0 · subst d rw [MvPolynomial.coeff_add, MvPolynomial.coeff_C, coeff_linear_sum_zero] simp by_cases hd1 : ∃ i, d = Finsupp.single i 1 · obtain ⟨i, rfl⟩ := hd1 rw [MvPolynomial.coeff_add, MvPolynomial.coeff_C, coeff_linear_sum_single] have hs : (0 : Fin n →₀ ℕ) ≠ Finsupp.single i 1 := Ne.symm (Finsupp.single_ne_zero.mpr one_ne_zero) simp [hs] · have hd_not_mem : d ∉ p.support := by intro hd_mem have hsum : d.sum (fun _ e => e) ≤ 1 := (MvPolynomial.le_totalDegree hd_mem).trans hp exact (finsupp_eq_zero_or_single_of_sum_le_one d hsum).elim hd0 hd1 rw [MvPolynomial.notMem_support_iff.mp hd_not_mem, MvPolynomial.coeff_add, MvPolynomial.coeff_C] simp only [if_neg (Ne.symm hd0), zero_add] rw [MvPolynomial.coeff_sum] symm apply Finset.sum_eq_zero intro i hi have hs : Finsupp.single i 1 ≠ d := fun h => hd1 ⟨i, h.symm⟩ simp [MvPolynomial.coeff_C_mul, MvPolynomial.coeff_X, hs] unfold AffineFn.eval affineFnOfMvPolynomial calc (∑ i, coeff (Finsupp.single i 1) p * x i) + coeff 0 p = coeff 0 p + ∑ i, coeff (Finsupp.single i 1) p * x i := add_comm _ _ _ = eval x (C (coeff 0 p) + ∑ i, C (coeff (Finsupp.single i 1) p) * X i) := by simp _ = eval x p := by rw [← hp_eq]
Causalean.Mathlib.Optimization.AffineSignCellClosure.affineFnOfMvPolynomial_eval · Causalean/Mathlib/Optimization/AffineSignCellClosure/Polynomial.lean:63 · uses eval , affineFnOfMvPolynomial
structure PolynomialConstraint reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a finite number of coordinates, a checked polynomial constraint contains its polynomial left-hand side, its weak-or-strict mark, and a certificate that it is affine.

Definition (Lean source)
n :
The polynomial left-hand side, normalized against zero.
polynomial :
Whether the normalized inequality is weak or strict.
The polynomial has total degree at most one.
degree_le_one :
polynomial.totalDegree ≤ 1
Causalean.Mathlib.Optimization.AffineSignCellClosure.PolynomialConstraint · Causalean/Mathlib/Optimization/AffineSignCellClosure/Polynomial.lean:104
def toConstraint reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure.PolynomialConstraint

Given a checked polynomial constraint, its affine constraint compilation is given by the compiled affine function with the original mark retained.

Definition (Lean source)
n :
toConstraint c :
clause 1
fn := affineFnOfMvPolynomial c.polynomial
clause 2
kind := c.kind
Causalean.Mathlib.Optimization.AffineSignCellClosure.PolynomialConstraint.toConstraint · Causalean/Mathlib/Optimization/AffineSignCellClosure/Polynomial.lean:117 · uses Constraint , PolynomialConstraint
def affineSystemOfPolynomials reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a finite list of checked polynomial constraints, its compiled affine system is given by compiling every listed constraint.

Definition (Lean source)
n :
affineSystemOfPolynomials Γ :
Γ.map PolynomialConstraint.toConstraint
Causalean.Mathlib.Optimization.AffineSignCellClosure.affineSystemOfPolynomials · Causalean/Mathlib/Optimization/AffineSignCellClosure/Polynomial.lean:125 · uses AffineSystem , PolynomialConstraint
def polynomialStrictCell reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a finite list of checked polynomial constraints, its direct strict polynomial cell is given by satisfaction of each original weak-or-strict polynomial comparison.

Definition (Lean source)
n :
polynomialStrictCell Γ :
Set (Fin n → ℝ)
{x | ∀ c ∈ Γ, match c.kind with | .weak => eval x c.polynomial ≤ 0 | .strict => eval x c.polynomial < 0}
Causalean.Mathlib.Optimization.AffineSignCellClosure.polynomialStrictCell · Causalean/Mathlib/Optimization/AffineSignCellClosure/Polynomial.lean:132 · uses PolynomialConstraint
def polynomialWeakCell reviewed
Causalean.Mathlib.Optimization.AffineSignCellClosure

Given a finite list of checked polynomial constraints, its direct weak polynomial cell is given by weak satisfaction of every polynomial constraint.

Definition (Lean source)
n :
polynomialWeakCell Γ :
Set (Fin n → ℝ)
{x | ∀ c ∈ Γ, eval x c.polynomial ≤ 0}
Causalean.Mathlib.Optimization.AffineSignCellClosure.polynomialWeakCell · Causalean/Mathlib/Optimization/AffineSignCellClosure/Polynomial.lean:141 · uses PolynomialConstraint
2 supporting declarations (lemmas, instances)