fact
stringlengths
5
7.52k
type
stringclasses
9 values
library
stringclasses
2 values
imports
listlengths
0
15
filename
stringclasses
121 values
symbolic_name
stringlengths
1
53
docstring
stringlengths
6
446
sminₚ_pos : StrongLT 0 sminₚ := by intro i; fin_cases i <;> norm_num @[simp]
lemma
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
sminₚ_pos
null
sminₚ_nonneg : 0 ≤ sminₚ := le_of_strongLT sminₚ_pos
lemma
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
sminₚ_nonneg
null
sminₚ_le_smaxₚ : sminₚ ≤ smaxₚ := by intro i; fin_cases i <;> (dsimp [sminₚ, smaxₚ]; norm_num) @[simp]
lemma
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
sminₚ_le_smaxₚ
null
smaxₚ_nonneg : 0 ≤ smaxₚ := le_trans sminₚ_nonneg sminₚ_le_smaxₚ @[optimization_param]
lemma
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
smaxₚ_nonneg
null
aₚ : ℝ := 1 @[simp]
def
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
aₚ
null
aₚ_nonneg : 0 ≤ aₚ := by unfold aₚ; norm_num @[simp]
lemma
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
aₚ_nonneg
null
aₚdₚ2_nonneg : 0 ≤ aₚ • (dₚ ^ (2 : ℝ)) := by intros i; fin_cases i <;> (dsimp [aₚ, dₚ]; norm_num) @[optimization_param]
lemma
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
aₚdₚ2_nonneg
null
bₚ : ℝ := 6 @[optimization_param]
def
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
bₚ
null
cₚ : ℝ := 10 solve vehSpeedSchedQuadratic nₚ dₚ τminₚ τmaxₚ sminₚ smaxₚ aₚ bₚ cₚ nₚ_pos dₚ_pos sminₚ_pos #eval vehSpeedSchedQuadratic.status -- "PRIMAL_AND_DUAL_FEASIBLE" #eval vehSpeedSchedQuadratic.value -- 275.042133 #eval vehSpeedSchedQuadratic.solution -- ... -- NOTE: F is not really used here, but it is a paramet...
def
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
cₚ
null
eqv₁.backward_mapₚ := eqv₁.backward_map nₚ dₚ.float τminₚ.float τmaxₚ.float sminₚ.float smaxₚ.float (fun s => aₚ.float * s ^ 2 + bₚ.float * s + cₚ.float)
def
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
eqv₁.backward_mapₚ
null
eqv₂.backward_mapₚ := eqv₂.backward_map nₚ dₚ.float τminₚ.float τmaxₚ.float sminₚ.float smaxₚ.float aₚ.float bₚ.float cₚ.float -- Finally, we can obtain the solution to the original problem.
def
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
eqv₂.backward_mapₚ
null
sₚ_opt := eqv₁.backward_mapₚ (eqv₂.backward_mapₚ vehSpeedSchedQuadratic.solution) #eval sₚ_opt -- ![0.955578, 0.955548, 0.955565, 0.955532, 0.955564, 0.955560, 0.912362, 0.960401, 0.912365, -- 0.912375]
def
CvxLean
[ "import CvxLean" ]
CvxLean/Examples/VehicleSpeedScheduling.lean
sₚ_opt
null
Equivalence where phi : D → E psi : E → D phi_optimality : ∀ x, p.optimal x → q.optimal (phi x) psi_optimality : ∀ x, q.optimal x → p.optimal (psi x) namespace Equivalence variable {p q r} notation p " ≡ " q => Equivalence p q @[equiv]
structure
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
Equivalence
/-- Regular notion of equivalence between optimization problems. We require maps `(φ, ψ)` between teh domains of `p` and `q` such that they map optimal points to optimal points. -/
refl : p ≡ p := { phi := id, psi := id, phi_optimality := fun _ hx => hx, psi_optimality := fun _ hx => hx } @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
refl
/-- Regular notion of equivalence between optimization problems. We require maps `(φ, ψ)` between teh domains of `p` and `q` such that they map optimal points to optimal points. -/
symm (E : p ≡ q) : q ≡ p := { phi := E.psi, psi := E.phi, phi_optimality := E.psi_optimality, psi_optimality := E.phi_optimality } @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
symm
null
trans (E₁ : p ≡ q) (E₂ : q ≡ r) : p ≡ r := { phi := E₂.phi ∘ E₁.phi, psi := E₁.psi ∘ E₂.psi, phi_optimality := fun x hx => E₂.phi_optimality (E₁.phi x) (E₁.phi_optimality x hx), psi_optimality := fun y hy => E₁.psi_optimality (E₂.psi y) (E₂.psi_optimality y hy) }
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
trans
null
toFwd (E : p ≡ q) : Solution p → Solution q := fun sol => { point := E.phi sol.point, isOptimal := E.phi_optimality sol.point sol.isOptimal } /-- An equivalence induces a map between the solution set of `q` and the solution set of `p`. -/
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
toFwd
/-- An equivalence induces a map between the solution set of `p` and the solution set of `q`. -/
toBwd (E : p ≡ q) : Solution q → Solution p := fun sol => { point := E.psi sol.point, isOptimal := E.psi_optimality sol.point sol.isOptimal }
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
toBwd
/-- An equivalence induces a map between the solution set of `q` and the solution set of `p`. -/
StrongEquivalence where phi : D → E psi : E → D phi_feasibility : ∀ x, p.feasible x → q.feasible (phi x) psi_feasibility : ∀ y, q.feasible y → p.feasible (psi y) phi_optimality : ∀ x, p.feasible x → q.objFun (phi x) ≤ p.objFun x psi_optimality : ∀ y, q.feasible y → p.objFun (psi y) ≤ q.objFun y namespace StrongEquivale...
structure
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
StrongEquivalence
/-- Notion of equivalence used by the DCP procedure. It makes some proofs simpler. The optimality-preserving requirements of `(φ, ψ)` are replaced by: * for every `p`-feasible `x`, `g(φ(x)) ≤ f(x)`, i.e. `φ` gives a lower bound of `f`. * for every `q`-feasible `y`, `f(ψ(y)) ≤ g(y)`, i.e. `ψ` fives a lower bound of `g`....
refl : p ≡' p := { phi := id, psi := id, phi_feasibility := fun _ hx => hx, psi_feasibility := fun _ hy => hy, phi_optimality := fun _ _ => le_refl _, psi_optimality := fun _ _ => le_refl _ } @[strong_equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
refl
null
symm (E : p ≡' q) : q ≡' p := { phi := E.psi, psi := E.phi, phi_feasibility := E.psi_feasibility, psi_feasibility := E.phi_feasibility, phi_optimality := E.psi_optimality, psi_optimality := E.phi_optimality } @[strong_equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
symm
null
trans (E₁ : p ≡' q) (E₂ : q ≡' r) : p ≡' r := { phi := E₂.phi ∘ E₁.phi, psi := E₁.psi ∘ E₂.psi, phi_feasibility := fun x hx => E₂.phi_feasibility (E₁.phi x) (E₁.phi_feasibility x hx), psi_feasibility := fun y hy => E₁.psi_feasibility (E₂.psi y) (E₂.psi_feasibility y hy), phi_optimality := fun x hx => -- `h(φ₂(φ₁(x))) ≤...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
trans
null
ofEq (h : p = q) : p ≡ q := { phi := id, psi := id, phi_optimality := fun _ hx => h ▸ hx, psi_optimality := fun _ hy => h ▸ hy }
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
ofEq
/-- Equal problems are equivalent. Note that the domain needs to be the same. We intentionally do not define this as `h ▸ Equivalence.refl (p := p)` so that `phi` and `psi` can be easily extracted. -/
ofStrongEquivalence (E : p ≡' q) : p ≡ q := { phi := E.phi, psi := E.psi, phi_optimality := fun x ⟨h_feas_x, h_opt_x⟩ => ⟨E.phi_feasibility x h_feas_x, fun y h_feas_y => -- `g(φ(x)) ≤ f(x)` have h₁ := E.phi_optimality x h_feas_x -- `f(x) ≤ f(ψ(y))` have h₂ := h_opt_x (E.psi y) (E.psi_feasibility y h_feas_y) -- `f(ψ(y))...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
ofStrongEquivalence
/-- As expected, an `Equivalence` can be built from a `StrongEquivalence`. -/
toFwd (E : p ≡' q) : Solution p → Solution q := (ofStrongEquivalence E).toFwd
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
toFwd
null
toBwd (E : p ≡' q) : Solution q → Solution p := (ofStrongEquivalence E).toBwd
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
toBwd
null
map_objFun {g : R → R} (h : ∀ {r s}, cs r → cs s → (g (f r) ≤ g (f s) ↔ f r ≤ f s)) : ⟨f, cs⟩ ≡ ⟨fun x => g (f x), cs⟩ := { phi := id, psi := id, phi_optimality := fun _ ⟨h_feas_x, h_opt_x⟩ => ⟨h_feas_x, fun y h_feas_y => (h h_feas_x h_feas_y).mpr (h_opt_x y h_feas_y)⟩, psi_optimality := fun _ ⟨h_feas_x, h_opt_x⟩ => ⟨h...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
map_objFun
/-- See [BV04,p.131] where `g` is `ψ₀`. -/
map_objFun_log {f : D → ℝ} (h : ∀ x, cs x → f x > 0) : ⟨f, cs⟩ ≡ ⟨fun x => (Real.log (f x)), cs⟩ := by apply map_objFun intros r s h_feas_r h_feas_s exact Real.log_le_log_iff (h r h_feas_r) (h s h_feas_s) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
map_objFun_log
/-- See [BV04,p.131] where `g` is `ψ₀`. -/
map_objFun_sq {f : D → ℝ} (h : ∀ x, cs x → f x ≥ 0) : ⟨f, cs⟩ ≡ ⟨fun x => (f x) ^ (2 : ℝ), cs⟩ := by apply map_objFun (g := fun x => x ^ (2 : ℝ)) intros r s h_feas_r h_feas_s simp [sq_le_sq, abs_of_nonneg (h r h_feas_r), abs_of_nonneg (h s h_feas_s)] /-- This is simply a change of variables, see `ChangeOfVariables.toEq...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
map_objFun_sq
null
map_domain {f : D → R} {cs : D → Prop} {fwd : D → E} {bwd : E → D} (h : ∀ x, cs x → bwd (fwd x) = x) : ⟨f, cs⟩ ≡ ⟨fun x => f (bwd x), fun x => cs (bwd x)⟩ := Equivalence.ofStrongEquivalence <| { phi := fwd, psi := bwd, phi_feasibility := fun {x} hx => by simp [feasible, h x hx]; exact hx, psi_feasibility := fun _ hx =>...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
map_domain
/-- This is simply a change of variables, see `ChangeOfVariables.toEquivalence` and [BV04,p.130]. -/
rewrite_objFun (hrw : ∀ x, cs x → f x = g x) : ⟨f, cs⟩ ≡ ⟨g, cs⟩ := Equivalence.ofStrongEquivalence <| { phi := id, psi := id, phi_feasibility := fun _ hx => hx psi_feasibility := fun _ hx => hx phi_optimality := fun {x} hx => le_of_eq (hrw x hx).symm psi_optimality := fun {x} hx => le_of_eq (hrw x hx) } @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun
null
rewrite_objFun_1 (hrw : ∀ x, c1 x → f x = g x) : ⟨f, c1⟩ ≡ ⟨g, c1⟩ := rewrite_objFun hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_1
null
rewrite_objFun_2 (hrw : ∀ x, c1 x → c2 x → f x = g x) : ⟨f, [[c1, c2]]⟩ ≡ ⟨g, [[c1, c2]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_2
null
rewrite_objFun_3 (hrw : ∀ x, c1 x → c2 x → c3 x → f x = g x) : ⟨f, [[c1, c2, c3]]⟩ ≡ ⟨g, [[c1, c2, c3]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_3
null
rewrite_objFun_4 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → f x = g x) : ⟨f, [[c1, c2, c3, c4]]⟩ ≡ ⟨g, [[c1, c2, c3, c4]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_4
null
rewrite_objFun_5 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → f x = g x) : ⟨f, [[c1, c2, c3, c4, c5]]⟩ ≡ ⟨g, [[c1, c2, c3, c4, c5]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_5
null
rewrite_objFun_6 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → f x = g x) : ⟨f, [[c1, c2, c3, c4, c5, c6]]⟩ ≡ ⟨g, [[c1, c2, c3, c4, c5, c6]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_6
null
rewrite_objFun_7 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → f x = g x) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7]]⟩ ≡ ⟨g, [[c1, c2, c3, c4, c5, c6, c7]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_7
null
rewrite_objFun_8 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → c8 x → f x = g x) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8]]⟩ ≡ ⟨g, [[c1, c2, c3, c4, c5, c6, c7, c8]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_8
null
rewrite_objFun_9 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → c8 x → c9 x → f x = g x) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9]]⟩ ≡ ⟨g, [[c1, c2, c3, c4, c5, c6, c7, c8, c9]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_9
null
rewrite_objFun_10 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → c8 x → c9 x → c10 x → f x = g x) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10]]⟩ ≡ ⟨g, [[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10]]⟩ := rewrite_objFun (fun x _ => by apply hrw x <;> tauto) /- Helper tactics to build equivalences from rewri...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_objFun_10
null
rewrite_constraints (hrw : ∀ x, cs x ↔ cs' x) : ⟨f, [[cs]]⟩ ≡ ⟨f, [[cs']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraints
null
rewrite_constraint_1 (hrw : ∀ x, cs x → (c1 x ↔ c1' x)) : ⟨f, [[c1, cs]]⟩ ≡ ⟨f, [[c1', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_1
null
rewrite_constraint_1_last (hrw : ∀ x, c1 x ↔ c1' x) : ⟨f, [[c1]]⟩ ≡ ⟨f, [[c1']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_1_last
null
rewrite_constraint_2 (hrw : ∀ x, c1 x → cs x → (c2 x ↔ c2' x)) : ⟨f, [[c1, c2, cs]]⟩ ≡ ⟨f, [[c1, c2', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_2
null
rewrite_constraint_2_last (hrw : ∀ x, c1 x → (c2 x ↔ c2' x)) : ⟨f, [[c1, c2]]⟩ ≡ ⟨f, [[c1, c2']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_2_last
null
rewrite_constraint_3 (hrw : ∀ x, c1 x → c2 x → cs x → (c3 x ↔ c3' x)) : ⟨f, [[c1, c2, c3, cs]]⟩ ≡ ⟨f, [[c1, c2, c3', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_3
null
rewrite_constraint_3_last (hrw : ∀ x, c1 x → c2 x → (c3 x ↔ c3' x)) : ⟨f, [[c1, c2, c3]]⟩ ≡ ⟨f, [[c1, c2, c3']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_3_last
null
rewrite_constraint_4 (hrw : ∀ x, c1 x → c2 x → c3 x → cs x → (c4 x ↔ c4' x)) : ⟨f, [[c1, c2, c3, c4, cs]]⟩ ≡ ⟨f, [[c1, c2, c3, c4', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_4
null
rewrite_constraint_4_last (hrw : ∀ x, c1 x → c2 x → c3 x → (c4 x ↔ c4' x)) : ⟨f, [[c1, c2, c3, c4]]⟩ ≡ ⟨f, [[c1, c2, c3, c4']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_4_last
null
rewrite_constraint_5 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → cs x → (c5 x ↔ c5' x)) : ⟨f, [[c1, c2, c3, c4, c5, cs]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_5
null
rewrite_constraint_5_last (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → (c5 x ↔ c5' x)) : ⟨f, [[c1, c2, c3, c4, c5]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_5_last
null
rewrite_constraint_6 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → cs x → (c6 x ↔ c6' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, cs]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_6
null
rewrite_constraint_6_last (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → (c6 x ↔ c6' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_6_last
null
rewrite_constraint_7 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → cs x → (c7 x ↔ c7' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, cs]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6, c7', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_7
null
rewrite_constraint_7_last (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → (c7 x ↔ c7' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6, c7']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_7_last
null
rewrite_constraint_8 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → cs x → (c8 x ↔ c8' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, cs]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_8
null
rewrite_constraint_8_last (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → (c8 x ↔ c8' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_8_last
null
rewrite_constraint_9 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → c8 x → cs x → (c9 x ↔ c9' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9, cs]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_9
null
rewrite_constraint_9_last (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → c8 x → (c9 x ↔ c9' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9']]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_9_last
null
rewrite_constraint_10 (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → c8 x → c9 x → cs x → (c10 x ↔ c10' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, cs]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10', cs]]⟩ := equivalence_of_rw_constr hrw @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_10
null
rewrite_constraint_10_last (hrw : ∀ x, c1 x → c2 x → c3 x → c4 x → c5 x → c6 x → c7 x → c8 x → c9 x → (c10 x ↔ c10' x)) : ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10]]⟩ ≡ ⟨f, [[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10']]⟩ := equivalence_of_rw_constr hrw
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
rewrite_constraint_10_last
null
add_constraint {cs' : D → Prop} (h : ∀ x, cs x → cs' x) : ⟨f, cs⟩ ≡ ⟨f, [[cs', cs]]⟩ := Equivalence.ofStrongEquivalence <| { phi := id, psi := id, phi_feasibility := fun _ hcs => ⟨h _ hcs, hcs⟩, psi_feasibility := fun _ ⟨_, hcs⟩ => hcs, phi_optimality := fun _ _ => le_refl _, psi_optimality := fun _ _ => le_refl _ } /-...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
add_constraint
/-- We can always add a redundant constraint. This might be useful to help the reduction algorithm infer some constraints that cannot be easily infered by `arith`. -/
map_le_constraint_standard_form [Zero R] {cs' : D → Prop} {fi : D → R} {g : R → R} (hcs : ∀ x, cs x ↔ fi x ≤ 0 ∧ cs' x) (hg : ∀ x, g x ≤ 0 ↔ x ≤ 0) : ⟨f, cs⟩ ≡ ⟨f, fun x => g (fi x) ≤ 0 ∧ cs' x⟩ := by apply rewrite_constraints; intros x; rw [hcs x, hg (fi x)] /-- See [BV04,p.131] where `g` is `ψₘ₊ᵢ`. -/ @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
map_le_constraint_standard_form
/-- See [BV04,p.131] where `g` is `ψᵢ`. -/
map_eq_constraint_standard_form [Zero R] {cs' : D → Prop} {hi : D → R} {g : R → R} (hcs : ∀ x, cs x ↔ hi x = 0 ∧ cs' x) (hg : ∀ x, g x = 0 ↔ x = 0) : ⟨f, cs⟩ ≡ ⟨f, fun x => g (hi x) = 0 ∧ cs' x⟩ := by apply rewrite_constraints; intros x; rw [hcs x, hg (hi x)] /-- Adding a slack variable [BV04,p.131]. -/ @[equiv]
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
map_eq_constraint_standard_form
/-- See [BV04,p.131] where `g` is `ψₘ₊ᵢ`. -/
add_slack_variable_standard_form {cs' : D → Prop} {fi : D → ℝ} (hcs : ∀ x, cs x ↔ fi x ≤ 0 ∧ cs' x) : ⟨f, cs⟩ ≡ ⟨fun (_, x) => f x, fun (si, x) => 0 ≤ (si : ℝ) ∧ fi x + si = 0 ∧ cs' x⟩ := Equivalence.ofStrongEquivalence <| { phi := fun x => (-fi x, x), psi := fun (_, x) => x, phi_feasibility := fun {x} h_feas_x => by s...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
add_slack_variable_standard_form
/-- Adding a slack variable [BV04,p.131]. -/
eliminate_eq_constraint_standard_form [Inhabited E] {cs' : D → Prop} {hi : D → ℝ} {g : E → D} (hcs : ∀ x, cs x ↔ hi x = 0 ∧ cs' x) (hg : ∀ x, hi x = 0 ↔ ∃ z, x = g z) : ⟨f, cs⟩ ≡ ⟨fun x => f (g x), fun x => cs' (g x)⟩ := Equivalence.ofStrongEquivalence <| { phi := fun x => if h : hi x = 0 then Classical.choose ((hg x)....
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
eliminate_eq_constraint_standard_form
/-- Eliminate equality constraints [BV04,p.132]. -/
decompose_constraint (g : D → E) (cs' : D → E → Prop) (hc : ∀ x, cs x ↔ cs' x (g x)) : ⟨f, cs⟩ ≡ ⟨fun (x, _) => f x, fun (x, y) => y = g x ∧ cs' x y⟩ := Equivalence.ofStrongEquivalence <| { phi := fun x => (x, g x), psi := fun (x, _) => x, phi_feasibility := fun {x} h_feas_x => by simpa [feasible, ← hc, h_feas_x], psi_...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
decompose_constraint
/-- Decompose constraint by introducing another equality constraint [BV04,p.132]. -/
epigraph_form : ⟨f, cs⟩ ≡ ⟨fun (t, _) => t, fun (t, x) => f x ≤ t ∧ cs x⟩ := Equivalence.ofStrongEquivalence <| { phi := fun x => (f x, x), psi := fun (_, x) => x, phi_feasibility := fun {x} h_feas_x => by simpa [feasible], psi_feasibility := fun (t, x) ⟨_, h_csx⟩ => by simpa [feasible], phi_optimality := fun {_} _ => ...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
epigraph_form
/-- Epigraph form [BV04,p.134]. -/
eq_to_le_left {S} [Preorder S] (e : D ≃ S × E) (g : E → S) (cs' : D → Prop) (hcs : ∀ {x}, cs x ↔ ((e x).1 = g (e x).2 ∧ cs' x)) (hf : ∀ y r s, f (e.symm (r, y)) = f (e.symm (s, y))) (h_mono: ∀ y r s, r ≤ s → cs' (e.symm (r, y)) → cs' (e.symm (s, y))) : ⟨f, cs⟩ ≡ ⟨f, fun x => (e x).1 ≤ g (e x).2 ∧ cs' x⟩ := Equivalence....
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
eq_to_le_left
/-- Suppose `D ≃ S × E`. Let problem `p := ⟨f, cs⟩` be defined over `D`. Every `x : D` maps one-to-one to `(s, y) : S × E`. Assume that `x` is `p`-feasible iff `s = g y` and `cs' x`. We can think of `s` as a new variable. If changing `s` does not change the objective function and the new constraints `c` respect monoton...
eq_to_le_right {S} [Preorder S] (e : Equiv D (S × E)) (g : E → S) (cs' : D → Prop) (hcs : ∀ {x}, cs x ↔ (g (e x).2 = (e x).1 ∧ cs' x)) (hf : ∀ x r s, f (e.symm ⟨r, x⟩) = f (e.symm ⟨s, x⟩)) (h_mono : ∀ x r s, r ≤ s → cs' (e.symm (s, x)) → cs' (e.symm ⟨r, x⟩)) : ⟨f, cs⟩ ≡ ⟨f, fun x => g (e x).2 ≤ (e x).1 ∧ cs' x⟩ := Equi...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
eq_to_le_right
/-- Similar to `eq_to_le_left` with the monotonicity condition on `c` flipped. In this case we have that `P` is equivalent to `⟨f, g y ≤ s ∧ cs' x⟩`. -/
domain_equiv (e : E ≃ D) : ⟨f, cs⟩ ≡ ⟨f ∘ e, cs ∘ e⟩ := Equivalence.ofStrongEquivalence <| { phi := e.symm, psi := e, phi_feasibility := fun {x} h_feas_x => by simpa [feasible], psi_feasibility := fun {x} h_feas_x => by simpa [feasible], phi_optimality := fun {x} _ => by simp, psi_optimality := fun {x} _ => by simp } /...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
domain_equiv
/-- Changing the domain to an equivalent type yields an equivalent problem. -/
linearization_mono {S} [Preorder S] (g : D → S) (c : S → D → Prop) (h : S → D → R) (hf : ∀ x, f x = h (g x) x) (hcs : ∀ x, cs x = c (g x) x) (h_mono_f : ∀ x r s, r ≤ s → h s x ≤ h r x) (h_mono_cs : ∀ x r s, r ≤ s → c r x → c s x) : ⟨f, cs⟩ ≡ ⟨fun (s, y) => h s y, fun (s, y) => s ≤ g y ∧ c s y⟩ := Equivalence.ofStrongEq...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
linearization_mono
/-- Introduce a new variable `s` that replaces occurrences of (non-linear) `g x` in the original problem. The resulting problem has an extra constraint `s ≤ g y`. The objective funciton and the rest of the constraints need to satisfy the appropriate monotonicity conditions [Gra05,4.2.1]. -/
linearization_antimono {S} [Preorder S] (g : D → S) (c : S → D → Prop) (h : S → D → R) (hf : ∀ x, f x = h (g x) x) (hcs : ∀ x, cs x = c (g x) x) (h_mono_f : ∀ x r s, r ≤ s → h r x ≤ h s x) (h_mono_cs : ∀ x r s, r ≤ s → c s x → c r x) : ⟨f, cs⟩ ≡ ⟨fun (s, y) => h s y, fun (s, y) => g y ≤ s ∧ c s y⟩ := Equivalence.ofStro...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
linearization_antimono
/-- Similar to `linearization_mono` with the monotonicity conditions flipped. The resulting problem adds the exactra constraint `g y ≤ s` in this case [Gra05,4.2.1]. -/
graph_expansion_greatest {S} [Preorder S] (g : D → S) (c d : S → D → Prop) (h : S → D → R) (hg : ∀ x v, c v x → IsGreatest {y | d y x} (g x)) (hf : ∀ x, f x = h (g x) x) (hcs : ∀ x, cs x = c (g x) x) (h_mono_f : ∀ x r s, r ≤ s → h s x ≤ h r x) (h_mono_cs : ∀ x r s, r ≤ s → c r x → c s x) : ⟨f, cs⟩ ≡ ⟨fun (s, y) => h s ...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
graph_expansion_greatest
/-- This can be seen as a generalization of `linearization_mono`, where `d` is the graph implementation of `g`. This is not used by the DCP procedure. -/
graph_expansion_least {S} [Preorder S] (g : D → S) (c d : S → D → Prop) (h : S → D → R) (hg : ∀ x v, c v x → IsLeast {y | d y x} (g x)) (hf : ∀ x, f x = h (g x) x) (hcs : ∀ x, cs x = c (g x) x) (h_mono_f : ∀ x r s, r ≤ s → h r x ≤ h s x) (h_mono_cs : ∀ x r s, r ≤ s → c s x → c r x) : ⟨f, cs⟩ ≡ ⟨fun (s, y) => h s y, fun...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
graph_expansion_least
/-- Similar to `graph_expansion_greatest` but in the flipped monotonicity context, c.f. `linearization_antimono`. This is not used by the DCP procedure. -/
graph_expansion_least_forall {S I : Type} [Preorder S] [Inhabited I] (g : D → I → S) (c d : S → D → Prop) (hg : ∀ x v i, c v x → IsLeast {y | d y x} (g x i)) (hcs : ∀ x, cs x = ∀ i, c (g x i) x) (h_mono_cs : ∀ x r s, r ≤ s → c s x → c r x) : ⟨f, cs⟩ ≡ ⟨fun sy : (I → S) × D => f sy.2, fun sy : (I → S) × D => (∀ i, d (sy...
def
CvxLean
[ "import CvxLean.Lib.Math.Data.Real", "import CvxLean.Lib.Minimization", "import CvxLean.Meta.Attributes" ]
CvxLean/Lib/Equivalence.lean
graph_expansion_least_forall
/-- Version of `graph_expansion_least` that works with vectors. -/
Minimization (D R : Type) where objFun : D → R constraints : D → Prop namespace Minimization variable {D E R : Type} [Preorder R] variable (p : Minimization D R) (q : Minimization E R) /-- A point `x : D` is feasible in `p` if it satisfies the constraints. -/ @[reducible]
structure
CvxLean
[ "import Mathlib.Order.Bounds.Basic" ]
CvxLean/Lib/Minimization.lean
Minimization
/-- Type of an optimization problem. -/
feasible (x : D) : Prop := p.constraints x /-- A point `x : D` is optimal in `p` if it is feasible and for any feasible point `y : D` the value of `x` is a lower bound to the value of `y`. -/ @[reducible]
def
CvxLean
[ "import Mathlib.Order.Bounds.Basic" ]
CvxLean/Lib/Minimization.lean
feasible
/-- A point `x : D` is feasible in `p` if it satisfies the constraints. -/
optimal (x : D) : Prop := p.feasible x ∧ ∀ y, p.feasible y → p.objFun x ≤ p.objFun y /-- A solution is simply an optimal point. -/
def
CvxLean
[ "import Mathlib.Order.Bounds.Basic" ]
CvxLean/Lib/Minimization.lean
optimal
/-- A point `x : D` is optimal in `p` if it is feasible and for any feasible point `y : D` the value of `x` is a lower bound to the value of `y`. -/
Solution where point : D isOptimal : p.optimal point
structure
CvxLean
[ "import Mathlib.Order.Bounds.Basic" ]
CvxLean/Lib/Minimization.lean
Solution
/-- A solution is simply an optimal point. -/
Reduction where psi : E → D psi_optimality : ∀ x, q.optimal x → p.optimal (psi x) namespace Reduction variable {p q r} notation p " ≼ " q => Reduction p q @[red]
structure
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
Reduction
/-- We read `Reduction p q` as `p` reduces to `q` [Pap93,10.1]. -/
refl : p ≼ p := { psi := id, psi_optimality := fun _ hy => hy } @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
refl
/-- We read `Reduction p q` as `p` reduces to `q` [Pap93,10.1]. -/
trans (R₁ : p ≼ q) (R₂ : q ≼ r) : p ≼ r := { psi := R₁.psi ∘ R₂.psi, psi_optimality := fun x h => R₁.psi_optimality (R₂.psi x) (R₂.psi_optimality x h) }
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
trans
/-- We read `Reduction p q` as `p` reduces to `q` [Pap93,10.1]. -/
toBwd (R : p ≼ q) : Solution q → Solution p := fun sol => { point := R.psi sol.point, isOptimal := R.psi_optimality sol.point sol.isOptimal } @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
toBwd
null
ofEquivalence (E : p ≡ q) : p ≼ q := { psi := E.psi, psi_optimality := E.psi_optimality }
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
ofEquivalence
null
map_objFun_of_order_reflecting {D R} [Preorder R] {f : D → R} {g : R → R} {cs : D → Prop} (h : ∀ {r s}, cs r → cs s → g (f r) ≤ g (f s) → f r ≤ f s) : ⟨f, cs⟩ ≼ ⟨fun x => g (f x), cs⟩ := { psi := id, psi_optimality := fun x ⟨h_feas_x, h_opt_x⟩ => ⟨h_feas_x, fun y h_feas_y => have h_gfx_le_gfy : g (f x) ≤ g (f y) := h_o...
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
map_objFun_of_order_reflecting
/-- Weaker version of `Equivalence.map_objFun`. For a reduction we only need the map to be order-reflecting on the image of the objective function. Note that for an equivalence we also need it to be order-preserving (order-reflecting + order-preserving = order embedding). -/
map_objFun {D R} [Preorder R] {f : D → R} {g : R → R} {cs : D → Prop} (h : ∀ {r s}, cs r → cs s → (g (f r) ≤ g (f s) ↔ f r ≤ f s)) : ⟨f, cs⟩ ≼ ⟨fun x => g (f x), cs⟩ := ofEquivalence <| Equivalence.map_objFun h /-- See `Equivalence.map_objFun_log`. -/ @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
map_objFun
/-- See `Equivalence.map_objFun`. -/
map_objFun_log {f : D → ℝ} (h : ∀ x, cs x → f x > 0) : ⟨f, cs⟩ ≼ ⟨fun x => (Real.log (f x)), cs⟩ := ofEquivalence <| Equivalence.map_objFun_log h /-- See `Equivalence.map_objFun_sq`. -/ @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
map_objFun_log
/-- See `Equivalence.map_objFun_log`. -/
map_objFun_sq {f : D → ℝ} (h : ∀ x, cs x → f x ≥ 0) : ⟨f, cs⟩ ≼ ⟨fun x => (f x) ^ (2 : ℝ), cs⟩ := ofEquivalence <| Equivalence.map_objFun_sq h /-- See `Equivalence.map_domain`. -/ @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
map_objFun_sq
/-- See `Equivalence.map_objFun_sq`. -/
map_domain {f : D → R} {cs : D → Prop} {fwd : D → E} {bwd : E → D} (h : ∀ x, cs x → bwd (fwd x) = x) : ⟨f, cs⟩ ≼ ⟨fun x => f (bwd x), (fun x => cs (bwd x))⟩ := ofEquivalence <| Equivalence.map_domain h
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
map_domain
/-- See `Equivalence.map_domain`. -/
rewrite_objFun (hrw : ∀ x, cs x → f x = g x) : ⟨f, cs⟩ ≼ ⟨g, cs⟩ := ofEquivalence <| Equivalence.rewrite_objFun hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_objFun
/-- See `Equivalence.map_domain`. -/
rewrite_constraints (hrw : ∀ x, cs x ↔ cs' x) : ⟨f, [[cs]]⟩ ≼ ⟨f, [[cs']]⟩ := ofEquivalence <| Equivalence.rewrite_constraints hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_constraints
null
rewrite_constraint_1 (hrw : ∀ x, cs x → (c1 x ↔ c1' x)) : ⟨f, [[c1, cs]]⟩ ≼ ⟨f, [[c1', cs]]⟩ := ofEquivalence <| Equivalence.rewrite_constraint_1 hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_constraint_1
null
rewrite_constraint_1_last (hrw : ∀ x, c1 x ↔ c1' x) : ⟨f, [[c1]]⟩ ≼ ⟨f, [[c1']]⟩ := ofEquivalence <| Equivalence.rewrite_constraint_1_last hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_constraint_1_last
null
rewrite_constraint_2 (hrw : ∀ x, c1 x → cs x → (c2 x ↔ c2' x)) : ⟨f, [[c1, c2, cs]]⟩ ≼ ⟨f, [[c1, c2', cs]]⟩ := ofEquivalence <| Equivalence.rewrite_constraint_2 hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_constraint_2
null
rewrite_constraint_2_last (hrw : ∀ x, c1 x → (c2 x ↔ c2' x)) : ⟨f, [[c1, c2]]⟩ ≼ ⟨f, [[c1, c2']]⟩ := ofEquivalence <| Equivalence.rewrite_constraint_2_last hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_constraint_2_last
null
rewrite_constraint_3 (hrw : ∀ x, c1 x → c2 x → cs x → (c3 x ↔ c3' x)) : ⟨f, [[c1, c2, c3, cs]]⟩ ≼ ⟨f, [[c1, c2, c3', cs]]⟩ := ofEquivalence <| Equivalence.rewrite_constraint_3 hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_constraint_3
null
rewrite_constraint_3_last (hrw : ∀ x, c1 x → c2 x → (c3 x ↔ c3' x)) : ⟨f, [[c1, c2, c3]]⟩ ≼ ⟨f, [[c1, c2, c3']]⟩ := ofEquivalence <| Equivalence.rewrite_constraint_3_last hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_constraint_3_last
null
rewrite_constraint_4 (hrw : ∀ x, c1 x → c2 x → c3 x → cs x → (c4 x ↔ c4' x)) : ⟨f, [[c1, c2, c3, c4, cs]]⟩ ≼ ⟨f, [[c1, c2, c3, c4', cs]]⟩ := ofEquivalence <| Equivalence.rewrite_constraint_4 hrw @[red]
def
CvxLean
[ "import CvxLean.Lib.Equivalence" ]
CvxLean/Lib/Reduction.lean
rewrite_constraint_4
null