analysis.convex.cone.proper ⟷ Mathlib.Analysis.Convex.Cone.Proper

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

feat(analysis/convex/cone/proper): add hyperplane_separation and comap (#19008)

We add the theorem hyperplane_separation which is a relative version of convex_cone.hyperplane_separation_of_nonempty_of_is_closed_of_nmem. This is the most general form of Farkas' lemma (that I know of) for convex cones.

We also add proper_cone.comap and a few theorems about it.

Co-authored-by: Apurva Nakade <apurvnakade@gmail.com@>

Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 -/
 import analysis.convex.cone.dual
+import analysis.inner_product_space.adjoint
 
 /-!
 # Proper cones
@@ -17,8 +18,6 @@ linear programs, the results from this file can be used to prove duality theorem
 ## TODO
 
 The next steps are:
-- Prove the cone version of Farkas' lemma (2.3.4 in the reference).
-- Add comap, adjoint
 - Add convex_cone_class that extends set_like and replace the below instance
 - Define the positive cone as a proper cone.
 - Define primal and dual cone programs and prove weak duality.
@@ -33,6 +32,8 @@ The next steps are:
 
 -/
 
+open continuous_linear_map filter set
+
 namespace convex_cone
 
 variables {π•œ : Type*} [ordered_semiring π•œ]
@@ -118,12 +119,13 @@ section inner_product_space
 
 variables {E : Type*} [normed_add_comm_group E] [inner_product_space ℝ E]
 variables {F : Type*} [normed_add_comm_group F] [inner_product_space ℝ F]
+variables {G : Type*} [normed_add_comm_group G] [inner_product_space ℝ G]
 
 protected lemma pointed (K : proper_cone ℝ E) : (K : convex_cone ℝ E).pointed :=
 (K : convex_cone ℝ E).pointed_of_nonempty_of_is_closed K.nonempty K.is_closed
 
 /-- The closure of image of a proper cone under a continuous `ℝ`-linear map is a proper cone. We
-use continuous maps here so that the adjoint of f is also a map between proper cones. -/
+use continuous maps here so that the comap of f is also a map between proper cones. -/
 noncomputable def map (f : E β†’L[ℝ] F) (K : proper_cone ℝ E) : proper_cone ℝ F :=
 { to_convex_cone := convex_cone.closure (convex_cone.map (f : E β†’β‚—[ℝ] F) ↑K),
   nonempty' := ⟨ 0, subset_closure $ set_like.mem_coe.2 $ convex_cone.mem_map.2
@@ -152,18 +154,90 @@ lemma coe_dual (K : proper_cone ℝ E) : ↑(dual K) = (K : set E).inner_dual_co
   y ∈ dual K ↔ βˆ€ ⦃x⦄, x ∈ K β†’ 0 ≀ βŸͺx, y⟫_ℝ :=
 by {rw [← mem_coe, coe_dual, mem_inner_dual_cone _ _], refl}
 
--- TODO: add comap, adjoint
+/-- The preimage of a proper cone under a continuous `ℝ`-linear map is a proper cone. -/
+noncomputable def comap (f : E β†’L[ℝ] F) (S : proper_cone ℝ F) : proper_cone ℝ E :=
+{ to_convex_cone := convex_cone.comap (f : E β†’β‚—[ℝ] F) S,
+  nonempty' := ⟨ 0,
+  begin
+    simp only [convex_cone.comap, mem_preimage, map_zero, set_like.mem_coe, mem_coe],
+    apply proper_cone.pointed,
+  end ⟩,
+  is_closed' :=
+  begin
+    simp only [convex_cone.comap, continuous_linear_map.coe_coe],
+    apply is_closed.preimage f.2 S.is_closed,
+  end }
+
+@[simp] lemma coe_comap (f : E β†’L[ℝ] F) (S : proper_cone ℝ F) : (S.comap f : set E) = f ⁻¹' S :=
+rfl
+
+@[simp] lemma comap_id (S : convex_cone ℝ E) : S.comap linear_map.id = S :=
+set_like.coe_injective preimage_id
+
+lemma comap_comap (g : F β†’L[ℝ] G) (f : E β†’L[ℝ] F) (S : proper_cone ℝ G) :
+  (S.comap g).comap f = S.comap (g.comp f) :=
+set_like.coe_injective $ preimage_comp.symm
+
+@[simp] lemma mem_comap {f : E β†’L[ℝ] F} {S : proper_cone ℝ F} {x : E} : x ∈ S.comap f ↔ f x ∈ S :=
+iff.rfl
 
 end inner_product_space
 
 section complete_space
 
 variables {E : Type*} [normed_add_comm_group E] [inner_product_space ℝ E] [complete_space E]
+variables {F : Type*} [normed_add_comm_group F] [inner_product_space ℝ F] [complete_space F]
 
 /-- The dual of the dual of a proper cone is itself. -/
 @[simp] theorem dual_dual (K : proper_cone ℝ E) : K.dual.dual = K := proper_cone.ext' $
   (K : convex_cone ℝ E).inner_dual_cone_of_inner_dual_cone_eq_self K.nonempty K.is_closed
 
+/-- This is a relative version of
+`convex_cone.hyperplane_separation_of_nonempty_of_is_closed_of_nmem`, which we recover by setting
+`f` to be the identity map. This is a geometric interpretation of the Farkas' lemma
+stated using proper cones. -/
+theorem hyperplane_separation (K : proper_cone ℝ E) {f : E β†’L[ℝ] F} {b : F} :
+  b ∈ K.map f ↔ βˆ€ y : F, (adjoint f y) ∈ K.dual β†’ 0 ≀ βŸͺy, b⟫_ℝ := iff.intro
+begin
+  -- suppose `b ∈ K.map f`
+  simp only [proper_cone.mem_map, proper_cone.mem_dual, adjoint_inner_right,
+    convex_cone.mem_closure, mem_closure_iff_seq_limit],
+
+  -- there is a sequence `seq : β„• β†’ F` in the image of `f` that converges to `b`
+  rintros ⟨seq, hmem, htends⟩ y hinner,
+
+  suffices h : βˆ€ n, 0 ≀ βŸͺy, seq n⟫_ℝ, from ge_of_tendsto' (continuous.seq_continuous
+    (continuous.inner (@continuous_const _ _ _ _ y) continuous_id) htends) h,
+
+  intro n,
+  obtain ⟨_, h, hseq⟩ := hmem n,
+  simpa only [← hseq, real_inner_comm] using (hinner h),
+end
+begin
+  -- proof by contradiction
+  -- suppose `b βˆ‰ K.map f`
+  intro h,
+  contrapose! h,
+
+  -- as `b βˆ‰ K.map f`, there is a hyperplane `y` separating `b` from `K.map f`
+  obtain ⟨y, hxy, hyb⟩ := convex_cone.hyperplane_separation_of_nonempty_of_is_closed_of_nmem _
+    (K.map f).nonempty (K.map f).is_closed h,
+
+  -- the rest of the proof is a straightforward algebraic manipulation
+  refine ⟨y, _, hyb⟩,
+  simp_rw [proper_cone.mem_dual, adjoint_inner_right],
+  intros x hxK,
+  apply hxy (f x),
+  rw [to_convex_cone_eq_coe, proper_cone.coe_map],
+  apply subset_closure,
+  rw [set_like.mem_coe, convex_cone.mem_map],
+  use ⟨x, hxK, rfl⟩,
+end
+
+theorem hyperplane_separation_of_nmem (K : proper_cone ℝ E) {f : E β†’L[ℝ] F} {b : F}
+  (disj : b βˆ‰ K.map f) : βˆƒ y : F, (adjoint f y) ∈ K.dual ∧ βŸͺy, b⟫_ℝ < 0 :=
+by { contrapose! disj, rwa K.hyperplane_separation }
+
 end complete_space
 
 end proper_cone

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2022 Apurva Nakade All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 -/
-import Analysis.Convex.Cone.Dual
+import Analysis.Convex.Cone.InnerDual
 import Analysis.InnerProductSpace.Adjoint
 
 #align_import analysis.convex.cone.proper from "leanprover-community/mathlib"@"728ef9dbb281241906f25cbeb30f90d83e0bb451"
Diff
@@ -110,17 +110,17 @@ theorem toConvexCone_eq_coe (K : ProperCone π•œ E) : K.toConvexCone = K :=
   rfl
 #align proper_cone.to_convex_cone_eq_coe ProperCone.toConvexCone_eq_coe
 
-#print ProperCone.ext' /-
-theorem ext' : Function.Injective (coe : ProperCone π•œ E β†’ ConvexCone π•œ E) := fun S T h => by
-  cases S <;> cases T <;> congr
-#align proper_cone.ext' ProperCone.ext'
+#print ProperCone.toPointedCone_injective /-
+theorem toPointedCone_injective : Function.Injective (coe : ProperCone π•œ E β†’ ConvexCone π•œ E) :=
+  fun S T h => by cases S <;> cases T <;> congr
+#align proper_cone.ext' ProperCone.toPointedCone_injective
 -/
 
 -- TODO: add convex_cone_class that extends set_like and replace the below instance
 instance : SetLike (ProperCone π•œ E) E
     where
   coe K := K.carrier
-  coe_injective' _ _ h := ProperCone.ext' (SetLike.coe_injective h)
+  coe_injective' _ _ h := ProperCone.toPointedCone_injective (SetLike.coe_injective h)
 
 #print ProperCone.ext /-
 @[ext]
@@ -230,7 +230,7 @@ theorem mem_map {f : E β†’L[ℝ] F} {K : ProperCone ℝ E} {y : F} :
 #print ProperCone.map_id /-
 @[simp]
 theorem map_id (K : ProperCone ℝ E) : K.map (ContinuousLinearMap.id ℝ E) = K :=
-  ProperCone.ext' <| by simpa using IsClosed.closure_eq K.is_closed
+  ProperCone.toPointedCone_injective <| by simpa using IsClosed.closure_eq K.is_closed
 #align proper_cone.map_id ProperCone.map_id
 -/
 
@@ -313,7 +313,7 @@ variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [Complete
 /-- The dual of the dual of a proper cone is itself. -/
 @[simp]
 theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
-  ProperCone.ext' <|
+  ProperCone.toPointedCone_injective <|
     (K : ConvexCone ℝ E).innerDualCone_of_innerDualCone_eq_self K.Nonempty K.IsClosed
 #align proper_cone.dual_dual ProperCone.dual_dual
 -/
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2022 Apurva Nakade All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 -/
-import Mathbin.Analysis.Convex.Cone.Dual
-import Mathbin.Analysis.InnerProductSpace.Adjoint
+import Analysis.Convex.Cone.Dual
+import Analysis.InnerProductSpace.Adjoint
 
 #align_import analysis.convex.cone.proper from "leanprover-community/mathlib"@"728ef9dbb281241906f25cbeb30f90d83e0bb451"
 
Diff
@@ -358,7 +358,7 @@ theorem hyperplane_separation (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
       rw [to_convex_cone_eq_coe, ProperCone.coe_map]
       apply subset_closure
       rw [SetLike.mem_coe, ConvexCone.mem_map]
-      use ⟨x, hxK, rfl⟩)
+      use⟨x, hxK, rfl⟩)
 #align proper_cone.hyperplane_separation ProperCone.hyperplane_separation
 -/
 
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Apurva Nakade All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
-
-! This file was ported from Lean 3 source module analysis.convex.cone.proper
-! leanprover-community/mathlib commit 728ef9dbb281241906f25cbeb30f90d83e0bb451
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Analysis.Convex.Cone.Dual
 import Mathbin.Analysis.InnerProductSpace.Adjoint
 
+#align_import analysis.convex.cone.proper from "leanprover-community/mathlib"@"728ef9dbb281241906f25cbeb30f90d83e0bb451"
+
 /-!
 # Proper cones
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 
 ! This file was ported from Lean 3 source module analysis.convex.cone.proper
-! leanprover-community/mathlib commit 147b294346843885f952c5171e9606616a8fd869
+! leanprover-community/mathlib commit 728ef9dbb281241906f25cbeb30f90d83e0bb451
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,9 @@ import Mathbin.Analysis.InnerProductSpace.Adjoint
 /-!
 # Proper cones
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 We define a proper cone as a nonempty, closed, convex cone. Proper cones are used in defining conic
 programs which generalize linear programs. A linear program is a conic program for the positive
 cone. We then prove Farkas' lemma for conic programs following the proof in the reference below.
Diff
@@ -258,6 +258,7 @@ theorem mem_dual {K : ProperCone ℝ E} {y : E} : y ∈ dual K ↔ βˆ€ ⦃x⦄,
 #align proper_cone.mem_dual ProperCone.mem_dual
 -/
 
+#print ProperCone.comap /-
 /-- The preimage of a proper cone under a continuous `ℝ`-linear map is a proper cone. -/
 noncomputable def comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : ProperCone ℝ E
     where
@@ -270,26 +271,35 @@ noncomputable def comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : ProperCone
     simp only [ConvexCone.comap, ContinuousLinearMap.coe_coe]
     apply IsClosed.preimage f.2 S.is_closed
 #align proper_cone.comap ProperCone.comap
+-/
 
+#print ProperCone.coe_comap /-
 @[simp]
 theorem coe_comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : (S.comap f : Set E) = f ⁻¹' S :=
   rfl
 #align proper_cone.coe_comap ProperCone.coe_comap
+-/
 
+#print ProperCone.comap_id /-
 @[simp]
 theorem comap_id (S : ConvexCone ℝ E) : S.comap LinearMap.id = S :=
   SetLike.coe_injective preimage_id
 #align proper_cone.comap_id ProperCone.comap_id
+-/
 
+#print ProperCone.comap_comap /-
 theorem comap_comap (g : F β†’L[ℝ] G) (f : E β†’L[ℝ] F) (S : ProperCone ℝ G) :
     (S.comap g).comap f = S.comap (g.comp f) :=
   SetLike.coe_injective <| preimage_comp.symm
 #align proper_cone.comap_comap ProperCone.comap_comap
+-/
 
+#print ProperCone.mem_comap /-
 @[simp]
 theorem mem_comap {f : E β†’L[ℝ] F} {S : ProperCone ℝ F} {x : E} : x ∈ S.comap f ↔ f x ∈ S :=
   Iff.rfl
 #align proper_cone.mem_comap ProperCone.mem_comap
+-/
 
 end InnerProductSpace
 
@@ -308,6 +318,7 @@ theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
 #align proper_cone.dual_dual ProperCone.dual_dual
 -/
 
+#print ProperCone.hyperplane_separation /-
 /-- This is a relative version of
 `convex_cone.hyperplane_separation_of_nonempty_of_is_closed_of_nmem`, which we recover by setting
 `f` to be the identity map. This is a geometric interpretation of the Farkas' lemma
@@ -349,11 +360,14 @@ theorem hyperplane_separation (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
       rw [SetLike.mem_coe, ConvexCone.mem_map]
       use ⟨x, hxK, rfl⟩)
 #align proper_cone.hyperplane_separation ProperCone.hyperplane_separation
+-/
 
+#print ProperCone.hyperplane_separation_of_nmem /-
 theorem hyperplane_separation_of_nmem (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
     (disj : b βˆ‰ K.map f) : βˆƒ y : F, adjoint f y ∈ K.dual ∧ βŸͺy, b⟫_ℝ < 0 := by contrapose! disj;
   rwa [K.hyperplane_separation]
 #align proper_cone.hyperplane_separation_of_nmem ProperCone.hyperplane_separation_of_nmem
+-/
 
 end CompleteSpace
 
Diff
@@ -47,6 +47,7 @@ variable {π•œ : Type _} [OrderedSemiring π•œ]
 variable {E : Type _} [AddCommMonoid E] [TopologicalSpace E] [ContinuousAdd E] [SMul π•œ E]
   [ContinuousConstSMul π•œ E]
 
+#print ConvexCone.closure /-
 /-- The closure of a convex cone inside a topological space as a convex cone. This
 construction is mainly used for defining maps between proper cones. -/
 protected def closure (K : ConvexCone π•œ E) : ConvexCone π•œ E
@@ -56,25 +57,33 @@ protected def closure (K : ConvexCone π•œ E) : ConvexCone π•œ E
     map_mem_closure (continuous_id'.const_smul c) h₁ fun _ hβ‚‚ => K.smul_mem hc hβ‚‚
   add_mem' _ h₁ _ hβ‚‚ := map_mem_closureβ‚‚ continuous_add h₁ hβ‚‚ K.add_mem
 #align convex_cone.closure ConvexCone.closure
+-/
 
+#print ConvexCone.coe_closure /-
 @[simp, norm_cast]
 theorem coe_closure (K : ConvexCone π•œ E) : (K.closure : Set E) = closure K :=
   rfl
 #align convex_cone.coe_closure ConvexCone.coe_closure
+-/
 
+#print ConvexCone.mem_closure /-
 @[simp]
 protected theorem mem_closure {K : ConvexCone π•œ E} {a : E} :
     a ∈ K.closure ↔ a ∈ closure (K : Set E) :=
   Iff.rfl
 #align convex_cone.mem_closure ConvexCone.mem_closure
+-/
 
+#print ConvexCone.closure_eq /-
 @[simp]
 theorem closure_eq {K L : ConvexCone π•œ E} : K.closure = L ↔ closure (K : Set E) = L :=
   SetLike.ext'_iff
 #align convex_cone.closure_eq ConvexCone.closure_eq
+-/
 
 end ConvexCone
 
+#print ProperCone /-
 /-- A proper cone is a convex cone `K` that is nonempty and closed. Proper cones have the nice
 property that the dual of the dual of a proper cone is itself. This makes them useful for defining
 cone programs and proving duality theorems. -/
@@ -83,6 +92,7 @@ structure ProperCone (π•œ : Type _) (E : Type _) [OrderedSemiring π•œ] [AddCom
   nonempty' : (carrier : Set E).Nonempty
   is_closed' : IsClosed (carrier : Set E)
 #align proper_cone ProperCone
+-/
 
 namespace ProperCone
 
@@ -100,9 +110,11 @@ theorem toConvexCone_eq_coe (K : ProperCone π•œ E) : K.toConvexCone = K :=
   rfl
 #align proper_cone.to_convex_cone_eq_coe ProperCone.toConvexCone_eq_coe
 
+#print ProperCone.ext' /-
 theorem ext' : Function.Injective (coe : ProperCone π•œ E β†’ ConvexCone π•œ E) := fun S T h => by
   cases S <;> cases T <;> congr
 #align proper_cone.ext' ProperCone.ext'
+-/
 
 -- TODO: add convex_cone_class that extends set_like and replace the below instance
 instance : SetLike (ProperCone π•œ E) E
@@ -110,23 +122,31 @@ instance : SetLike (ProperCone π•œ E) E
   coe K := K.carrier
   coe_injective' _ _ h := ProperCone.ext' (SetLike.coe_injective h)
 
+#print ProperCone.ext /-
 @[ext]
 theorem ext {S T : ProperCone π•œ E} (h : βˆ€ x, x ∈ S ↔ x ∈ T) : S = T :=
   SetLike.ext h
 #align proper_cone.ext ProperCone.ext
+-/
 
+#print ProperCone.mem_coe /-
 @[simp]
 theorem mem_coe {x : E} {K : ProperCone π•œ E} : x ∈ (K : ConvexCone π•œ E) ↔ x ∈ K :=
   Iff.rfl
 #align proper_cone.mem_coe ProperCone.mem_coe
+-/
 
+#print ProperCone.nonempty /-
 protected theorem nonempty (K : ProperCone π•œ E) : (K : Set E).Nonempty :=
   K.nonempty'
 #align proper_cone.nonempty ProperCone.nonempty
+-/
 
+#print ProperCone.isClosed /-
 protected theorem isClosed (K : ProperCone π•œ E) : IsClosed (K : Set E) :=
   K.is_closed'
 #align proper_cone.is_closed ProperCone.isClosed
+-/
 
 end SMul
 
@@ -144,18 +164,24 @@ instance : Zero (ProperCone π•œ E) :=
 instance : Inhabited (ProperCone π•œ E) :=
   ⟨0⟩
 
+#print ProperCone.mem_zero /-
 @[simp]
 theorem mem_zero (x : E) : x ∈ (0 : ProperCone π•œ E) ↔ x = 0 :=
   Iff.rfl
 #align proper_cone.mem_zero ProperCone.mem_zero
+-/
 
+#print ProperCone.coe_zero /-
 @[simp, norm_cast]
 theorem coe_zero : ↑(0 : ProperCone π•œ E) = (0 : ConvexCone π•œ E) :=
   rfl
 #align proper_cone.coe_zero ProperCone.coe_zero
+-/
 
+#print ProperCone.pointed_zero /-
 theorem pointed_zero : (0 : ProperCone π•œ E).Pointed := by simp [ConvexCone.pointed_zero]
 #align proper_cone.pointed_zero ProperCone.pointed_zero
+-/
 
 end Module
 
@@ -167,10 +193,13 @@ variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
 
 variable {G : Type _} [NormedAddCommGroup G] [InnerProductSpace ℝ G]
 
+#print ProperCone.pointed /-
 protected theorem pointed (K : ProperCone ℝ E) : (K : ConvexCone ℝ E).Pointed :=
   (K : ConvexCone ℝ E).pointed_of_nonempty_of_isClosed K.Nonempty K.IsClosed
 #align proper_cone.pointed ProperCone.pointed
+-/
 
+#print ProperCone.map /-
 /-- The closure of image of a proper cone under a continuous `ℝ`-linear map is a proper cone. We
 use continuous maps here so that the comap of f is also a map between proper cones. -/
 noncomputable def map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) : ProperCone ℝ F
@@ -180,24 +209,32 @@ noncomputable def map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) : ProperCone 
     ⟨0, subset_closure <| SetLike.mem_coe.2 <| ConvexCone.mem_map.2 ⟨0, K.Pointed, map_zero _⟩⟩
   is_closed' := isClosed_closure
 #align proper_cone.map ProperCone.map
+-/
 
+#print ProperCone.coe_map /-
 @[simp, norm_cast]
 theorem coe_map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) :
     ↑(K.map f) = (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
   rfl
 #align proper_cone.coe_map ProperCone.coe_map
+-/
 
+#print ProperCone.mem_map /-
 @[simp]
 theorem mem_map {f : E β†’L[ℝ] F} {K : ProperCone ℝ E} {y : F} :
     y ∈ K.map f ↔ y ∈ (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
   Iff.rfl
 #align proper_cone.mem_map ProperCone.mem_map
+-/
 
+#print ProperCone.map_id /-
 @[simp]
 theorem map_id (K : ProperCone ℝ E) : K.map (ContinuousLinearMap.id ℝ E) = K :=
   ProperCone.ext' <| by simpa using IsClosed.closure_eq K.is_closed
 #align proper_cone.map_id ProperCone.map_id
+-/
 
+#print ProperCone.dual /-
 /-- The inner dual cone of a proper cone is a proper cone. -/
 def dual (K : ProperCone ℝ E) : ProperCone ℝ E
     where
@@ -205,16 +242,21 @@ def dual (K : ProperCone ℝ E) : ProperCone ℝ E
   nonempty' := ⟨0, pointed_innerDualCone _⟩
   is_closed' := isClosed_innerDualCone _
 #align proper_cone.dual ProperCone.dual
+-/
 
+#print ProperCone.coe_dual /-
 @[simp, norm_cast]
 theorem coe_dual (K : ProperCone ℝ E) : ↑(dual K) = (K : Set E).innerDualCone :=
   rfl
 #align proper_cone.coe_dual ProperCone.coe_dual
+-/
 
+#print ProperCone.mem_dual /-
 @[simp]
 theorem mem_dual {K : ProperCone ℝ E} {y : E} : y ∈ dual K ↔ βˆ€ ⦃x⦄, x ∈ K β†’ 0 ≀ βŸͺx, y⟫_ℝ := by
   rw [← mem_coe, coe_dual, mem_innerDualCone _ _]; rfl
 #align proper_cone.mem_dual ProperCone.mem_dual
+-/
 
 /-- The preimage of a proper cone under a continuous `ℝ`-linear map is a proper cone. -/
 noncomputable def comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : ProperCone ℝ E
@@ -257,12 +299,14 @@ variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [Complete
 
 variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F]
 
+#print ProperCone.dual_dual /-
 /-- The dual of the dual of a proper cone is itself. -/
 @[simp]
 theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
   ProperCone.ext' <|
     (K : ConvexCone ℝ E).innerDualCone_of_innerDualCone_eq_self K.Nonempty K.IsClosed
 #align proper_cone.dual_dual ProperCone.dual_dual
+-/
 
 /-- This is a relative version of
 `convex_cone.hyperplane_separation_of_nonempty_of_is_closed_of_nmem`, which we recover by setting
Diff
@@ -4,11 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 
 ! This file was ported from Lean 3 source module analysis.convex.cone.proper
-! leanprover-community/mathlib commit 74f1d61944a5a793e8c939d47608178c0a0cb0c2
+! leanprover-community/mathlib commit 147b294346843885f952c5171e9606616a8fd869
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathbin.Analysis.Convex.Cone.Dual
+import Mathbin.Analysis.InnerProductSpace.Adjoint
 
 /-!
 # Proper cones
@@ -22,8 +23,6 @@ linear programs, the results from this file can be used to prove duality theorem
 ## TODO
 
 The next steps are:
-- Prove the cone version of Farkas' lemma (2.3.4 in the reference).
-- Add comap, adjoint
 - Add convex_cone_class that extends set_like and replace the below instance
 - Define the positive cone as a proper cone.
 - Define primal and dual cone programs and prove weak duality.
@@ -39,6 +38,8 @@ The next steps are:
 -/
 
 
+open ContinuousLinearMap Filter Set
+
 namespace ConvexCone
 
 variable {π•œ : Type _} [OrderedSemiring π•œ]
@@ -164,12 +165,14 @@ variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
 
 variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
 
+variable {G : Type _} [NormedAddCommGroup G] [InnerProductSpace ℝ G]
+
 protected theorem pointed (K : ProperCone ℝ E) : (K : ConvexCone ℝ E).Pointed :=
   (K : ConvexCone ℝ E).pointed_of_nonempty_of_isClosed K.Nonempty K.IsClosed
 #align proper_cone.pointed ProperCone.pointed
 
 /-- The closure of image of a proper cone under a continuous `ℝ`-linear map is a proper cone. We
-use continuous maps here so that the adjoint of f is also a map between proper cones. -/
+use continuous maps here so that the comap of f is also a map between proper cones. -/
 noncomputable def map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) : ProperCone ℝ F
     where
   toConvexCone := ConvexCone.closure (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K)
@@ -213,13 +216,47 @@ theorem mem_dual {K : ProperCone ℝ E} {y : E} : y ∈ dual K ↔ βˆ€ ⦃x⦄,
   rw [← mem_coe, coe_dual, mem_innerDualCone _ _]; rfl
 #align proper_cone.mem_dual ProperCone.mem_dual
 
--- TODO: add comap, adjoint
+/-- The preimage of a proper cone under a continuous `ℝ`-linear map is a proper cone. -/
+noncomputable def comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : ProperCone ℝ E
+    where
+  toConvexCone := ConvexCone.comap (f : E β†’β‚—[ℝ] F) S
+  nonempty' :=
+    ⟨0, by
+      simp only [ConvexCone.comap, mem_preimage, map_zero, SetLike.mem_coe, mem_coe]
+      apply ProperCone.pointed⟩
+  is_closed' := by
+    simp only [ConvexCone.comap, ContinuousLinearMap.coe_coe]
+    apply IsClosed.preimage f.2 S.is_closed
+#align proper_cone.comap ProperCone.comap
+
+@[simp]
+theorem coe_comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : (S.comap f : Set E) = f ⁻¹' S :=
+  rfl
+#align proper_cone.coe_comap ProperCone.coe_comap
+
+@[simp]
+theorem comap_id (S : ConvexCone ℝ E) : S.comap LinearMap.id = S :=
+  SetLike.coe_injective preimage_id
+#align proper_cone.comap_id ProperCone.comap_id
+
+theorem comap_comap (g : F β†’L[ℝ] G) (f : E β†’L[ℝ] F) (S : ProperCone ℝ G) :
+    (S.comap g).comap f = S.comap (g.comp f) :=
+  SetLike.coe_injective <| preimage_comp.symm
+#align proper_cone.comap_comap ProperCone.comap_comap
+
+@[simp]
+theorem mem_comap {f : E β†’L[ℝ] F} {S : ProperCone ℝ F} {x : E} : x ∈ S.comap f ↔ f x ∈ S :=
+  Iff.rfl
+#align proper_cone.mem_comap ProperCone.mem_comap
+
 end InnerProductSpace
 
 section CompleteSpace
 
 variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
 
+variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F]
+
 /-- The dual of the dual of a proper cone is itself. -/
 @[simp]
 theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
@@ -227,6 +264,53 @@ theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
     (K : ConvexCone ℝ E).innerDualCone_of_innerDualCone_eq_self K.Nonempty K.IsClosed
 #align proper_cone.dual_dual ProperCone.dual_dual
 
+/-- This is a relative version of
+`convex_cone.hyperplane_separation_of_nonempty_of_is_closed_of_nmem`, which we recover by setting
+`f` to be the identity map. This is a geometric interpretation of the Farkas' lemma
+stated using proper cones. -/
+theorem hyperplane_separation (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F} :
+    b ∈ K.map f ↔ βˆ€ y : F, adjoint f y ∈ K.dual β†’ 0 ≀ βŸͺy, b⟫_ℝ :=
+  Iff.intro
+    (by
+      -- suppose `b ∈ K.map f`
+      simp only [ProperCone.mem_map, ProperCone.mem_dual, adjoint_inner_right,
+        ConvexCone.mem_closure, mem_closure_iff_seq_limit]
+      -- there is a sequence `seq : β„• β†’ F` in the image of `f` that converges to `b`
+      rintro ⟨seq, hmem, htends⟩ y hinner
+      suffices h : βˆ€ n, 0 ≀ βŸͺy, seq n⟫_ℝ;
+      exact
+        ge_of_tendsto'
+          (Continuous.seqContinuous (Continuous.inner (@continuous_const _ _ _ _ y) continuous_id)
+            htends)
+          h
+      intro n
+      obtain ⟨_, h, hseq⟩ := hmem n
+      simpa only [← hseq, real_inner_comm] using hinner h)
+    (by
+      -- proof by contradiction
+      -- suppose `b βˆ‰ K.map f`
+      intro h
+      contrapose! h
+      -- as `b βˆ‰ K.map f`, there is a hyperplane `y` separating `b` from `K.map f`
+      obtain ⟨y, hxy, hyb⟩ :=
+        ConvexCone.hyperplane_separation_of_nonempty_of_isClosed_of_nmem _ (K.map f).Nonempty
+          (K.map f).IsClosed h
+      -- the rest of the proof is a straightforward algebraic manipulation
+      refine' ⟨y, _, hyb⟩
+      simp_rw [ProperCone.mem_dual, adjoint_inner_right]
+      intro x hxK
+      apply hxy (f x)
+      rw [to_convex_cone_eq_coe, ProperCone.coe_map]
+      apply subset_closure
+      rw [SetLike.mem_coe, ConvexCone.mem_map]
+      use ⟨x, hxK, rfl⟩)
+#align proper_cone.hyperplane_separation ProperCone.hyperplane_separation
+
+theorem hyperplane_separation_of_nmem (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
+    (disj : b βˆ‰ K.map f) : βˆƒ y : F, adjoint f y ∈ K.dual ∧ βŸͺy, b⟫_ℝ < 0 := by contrapose! disj;
+  rwa [K.hyperplane_separation]
+#align proper_cone.hyperplane_separation_of_nmem ProperCone.hyperplane_separation_of_nmem
+
 end CompleteSpace
 
 end ProperCone
Diff
@@ -4,14 +4,14 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 
 ! This file was ported from Lean 3 source module analysis.convex.cone.proper
-! leanprover-community/mathlib commit 915591b2bb3ea303648db07284a161a7f2a9e3d4
+! leanprover-community/mathlib commit 74f1d61944a5a793e8c939d47608178c0a0cb0c2
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathbin.Analysis.Convex.Cone.Basic
-import Mathbin.Topology.Algebra.Monoid
+import Mathbin.Analysis.Convex.Cone.Dual
 
 /-!
+# Proper cones
 
 We define a proper cone as a nonempty, closed, convex cone. Proper cones are used in defining conic
 programs which generalize linear programs. A linear program is a conic program for the positive
@@ -21,13 +21,16 @@ linear programs, the results from this file can be used to prove duality theorem
 
 ## TODO
 
-In the next few PRs (already sorry-free), we will add the definition and prove several properties
-of proper cones and finally prove the cone version of Farkas' lemma (2.3.4 in the reference).
-
 The next steps are:
+- Prove the cone version of Farkas' lemma (2.3.4 in the reference).
+- Add comap, adjoint
+- Add convex_cone_class that extends set_like and replace the below instance
+- Define the positive cone as a proper cone.
 - Define primal and dual cone programs and prove weak duality.
 - Prove regular and strong duality for cone programs using Farkas' lemma (see reference).
 - Define linear programs and prove LP duality as a special case of cone duality.
+- Find a better reference (textbook instead of lecture notes).
+- Show submodules are (proper) cones.
 
 ## References
 
@@ -38,12 +41,14 @@ The next steps are:
 
 namespace ConvexCone
 
-variable {E : Type _} [AddCommMonoid E] [SMul ℝ E] [TopologicalSpace E] [ContinuousConstSMul ℝ E]
-  [ContinuousAdd E]
+variable {π•œ : Type _} [OrderedSemiring π•œ]
+
+variable {E : Type _} [AddCommMonoid E] [TopologicalSpace E] [ContinuousAdd E] [SMul π•œ E]
+  [ContinuousConstSMul π•œ E]
 
-/-- The closure of a convex cone inside a real inner product space is a convex cone. This
+/-- The closure of a convex cone inside a topological space as a convex cone. This
 construction is mainly used for defining maps between proper cones. -/
-protected def closure (K : ConvexCone ℝ E) : ConvexCone ℝ E
+protected def closure (K : ConvexCone π•œ E) : ConvexCone π•œ E
     where
   carrier := closure ↑K
   smul_mem' c hc _ h₁ :=
@@ -52,14 +57,177 @@ protected def closure (K : ConvexCone ℝ E) : ConvexCone ℝ E
 #align convex_cone.closure ConvexCone.closure
 
 @[simp, norm_cast]
-theorem coe_closure (K : ConvexCone ℝ E) : (K.closure : Set E) = closure K :=
+theorem coe_closure (K : ConvexCone π•œ E) : (K.closure : Set E) = closure K :=
   rfl
 #align convex_cone.coe_closure ConvexCone.coe_closure
 
-protected theorem mem_closure {K : ConvexCone ℝ E} {a : E} :
+@[simp]
+protected theorem mem_closure {K : ConvexCone π•œ E} {a : E} :
     a ∈ K.closure ↔ a ∈ closure (K : Set E) :=
   Iff.rfl
 #align convex_cone.mem_closure ConvexCone.mem_closure
 
+@[simp]
+theorem closure_eq {K L : ConvexCone π•œ E} : K.closure = L ↔ closure (K : Set E) = L :=
+  SetLike.ext'_iff
+#align convex_cone.closure_eq ConvexCone.closure_eq
+
 end ConvexCone
 
+/-- A proper cone is a convex cone `K` that is nonempty and closed. Proper cones have the nice
+property that the dual of the dual of a proper cone is itself. This makes them useful for defining
+cone programs and proving duality theorems. -/
+structure ProperCone (π•œ : Type _) (E : Type _) [OrderedSemiring π•œ] [AddCommMonoid E]
+    [TopologicalSpace E] [SMul π•œ E] extends ConvexCone π•œ E where
+  nonempty' : (carrier : Set E).Nonempty
+  is_closed' : IsClosed (carrier : Set E)
+#align proper_cone ProperCone
+
+namespace ProperCone
+
+section SMul
+
+variable {π•œ : Type _} [OrderedSemiring π•œ]
+
+variable {E : Type _} [AddCommMonoid E] [TopologicalSpace E] [SMul π•œ E]
+
+instance : Coe (ProperCone π•œ E) (ConvexCone π•œ E) :=
+  ⟨fun K => K.1⟩
+
+@[simp]
+theorem toConvexCone_eq_coe (K : ProperCone π•œ E) : K.toConvexCone = K :=
+  rfl
+#align proper_cone.to_convex_cone_eq_coe ProperCone.toConvexCone_eq_coe
+
+theorem ext' : Function.Injective (coe : ProperCone π•œ E β†’ ConvexCone π•œ E) := fun S T h => by
+  cases S <;> cases T <;> congr
+#align proper_cone.ext' ProperCone.ext'
+
+-- TODO: add convex_cone_class that extends set_like and replace the below instance
+instance : SetLike (ProperCone π•œ E) E
+    where
+  coe K := K.carrier
+  coe_injective' _ _ h := ProperCone.ext' (SetLike.coe_injective h)
+
+@[ext]
+theorem ext {S T : ProperCone π•œ E} (h : βˆ€ x, x ∈ S ↔ x ∈ T) : S = T :=
+  SetLike.ext h
+#align proper_cone.ext ProperCone.ext
+
+@[simp]
+theorem mem_coe {x : E} {K : ProperCone π•œ E} : x ∈ (K : ConvexCone π•œ E) ↔ x ∈ K :=
+  Iff.rfl
+#align proper_cone.mem_coe ProperCone.mem_coe
+
+protected theorem nonempty (K : ProperCone π•œ E) : (K : Set E).Nonempty :=
+  K.nonempty'
+#align proper_cone.nonempty ProperCone.nonempty
+
+protected theorem isClosed (K : ProperCone π•œ E) : IsClosed (K : Set E) :=
+  K.is_closed'
+#align proper_cone.is_closed ProperCone.isClosed
+
+end SMul
+
+section Module
+
+variable {π•œ : Type _} [OrderedSemiring π•œ]
+
+variable {E : Type _} [AddCommMonoid E] [TopologicalSpace E] [T1Space E] [Module π•œ E]
+
+instance : Zero (ProperCone π•œ E) :=
+  ⟨{  toConvexCone := 0
+      nonempty' := ⟨0, rfl⟩
+      is_closed' := isClosed_singleton }⟩
+
+instance : Inhabited (ProperCone π•œ E) :=
+  ⟨0⟩
+
+@[simp]
+theorem mem_zero (x : E) : x ∈ (0 : ProperCone π•œ E) ↔ x = 0 :=
+  Iff.rfl
+#align proper_cone.mem_zero ProperCone.mem_zero
+
+@[simp, norm_cast]
+theorem coe_zero : ↑(0 : ProperCone π•œ E) = (0 : ConvexCone π•œ E) :=
+  rfl
+#align proper_cone.coe_zero ProperCone.coe_zero
+
+theorem pointed_zero : (0 : ProperCone π•œ E).Pointed := by simp [ConvexCone.pointed_zero]
+#align proper_cone.pointed_zero ProperCone.pointed_zero
+
+end Module
+
+section InnerProductSpace
+
+variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
+
+protected theorem pointed (K : ProperCone ℝ E) : (K : ConvexCone ℝ E).Pointed :=
+  (K : ConvexCone ℝ E).pointed_of_nonempty_of_isClosed K.Nonempty K.IsClosed
+#align proper_cone.pointed ProperCone.pointed
+
+/-- The closure of image of a proper cone under a continuous `ℝ`-linear map is a proper cone. We
+use continuous maps here so that the adjoint of f is also a map between proper cones. -/
+noncomputable def map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) : ProperCone ℝ F
+    where
+  toConvexCone := ConvexCone.closure (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K)
+  nonempty' :=
+    ⟨0, subset_closure <| SetLike.mem_coe.2 <| ConvexCone.mem_map.2 ⟨0, K.Pointed, map_zero _⟩⟩
+  is_closed' := isClosed_closure
+#align proper_cone.map ProperCone.map
+
+@[simp, norm_cast]
+theorem coe_map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) :
+    ↑(K.map f) = (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
+  rfl
+#align proper_cone.coe_map ProperCone.coe_map
+
+@[simp]
+theorem mem_map {f : E β†’L[ℝ] F} {K : ProperCone ℝ E} {y : F} :
+    y ∈ K.map f ↔ y ∈ (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
+  Iff.rfl
+#align proper_cone.mem_map ProperCone.mem_map
+
+@[simp]
+theorem map_id (K : ProperCone ℝ E) : K.map (ContinuousLinearMap.id ℝ E) = K :=
+  ProperCone.ext' <| by simpa using IsClosed.closure_eq K.is_closed
+#align proper_cone.map_id ProperCone.map_id
+
+/-- The inner dual cone of a proper cone is a proper cone. -/
+def dual (K : ProperCone ℝ E) : ProperCone ℝ E
+    where
+  toConvexCone := (K : Set E).innerDualCone
+  nonempty' := ⟨0, pointed_innerDualCone _⟩
+  is_closed' := isClosed_innerDualCone _
+#align proper_cone.dual ProperCone.dual
+
+@[simp, norm_cast]
+theorem coe_dual (K : ProperCone ℝ E) : ↑(dual K) = (K : Set E).innerDualCone :=
+  rfl
+#align proper_cone.coe_dual ProperCone.coe_dual
+
+@[simp]
+theorem mem_dual {K : ProperCone ℝ E} {y : E} : y ∈ dual K ↔ βˆ€ ⦃x⦄, x ∈ K β†’ 0 ≀ βŸͺx, y⟫_ℝ := by
+  rw [← mem_coe, coe_dual, mem_innerDualCone _ _]; rfl
+#align proper_cone.mem_dual ProperCone.mem_dual
+
+-- TODO: add comap, adjoint
+end InnerProductSpace
+
+section CompleteSpace
+
+variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+/-- The dual of the dual of a proper cone is itself. -/
+@[simp]
+theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
+  ProperCone.ext' <|
+    (K : ConvexCone ℝ E).innerDualCone_of_innerDualCone_eq_self K.Nonempty K.IsClosed
+#align proper_cone.dual_dual ProperCone.dual_dual
+
+end CompleteSpace
+
+end ProperCone
+
Diff
@@ -4,11 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 
 ! This file was ported from Lean 3 source module analysis.convex.cone.proper
-! leanprover-community/mathlib commit f0c8bf9245297a541f468be517f1bde6195105e9
+! leanprover-community/mathlib commit 915591b2bb3ea303648db07284a161a7f2a9e3d4
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathbin.Analysis.Convex.Cone.Basic
+import Mathbin.Topology.Algebra.Monoid
 
 /-!
 
@@ -35,8 +36,6 @@ The next steps are:
 -/
 
 
-open ContinuousLinearMap Filter
-
 namespace ConvexCone
 
 variable {E : Type _} [AddCommMonoid E] [SMul ℝ E] [TopologicalSpace E] [ContinuousConstSMul ℝ E]
Diff
@@ -4,11 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 
 ! This file was ported from Lean 3 source module analysis.convex.cone.proper
-! leanprover-community/mathlib commit 620ba06c7f173d79b3cad91294babde6b4eab79c
+! leanprover-community/mathlib commit f0c8bf9245297a541f468be517f1bde6195105e9
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathbin.Analysis.InnerProductSpace.Adjoint
+import Mathbin.Analysis.Convex.Cone.Basic
 
 /-!
 

Changes in mathlib4

mathlib3
mathlib4
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -46,7 +46,6 @@ namespace ProperCone
 section Module
 
 variable {π•œ : Type*} [OrderedSemiring π•œ]
-
 variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [Module π•œ E]
 
 /-- A `PointedCone` is defined as an alias of submodule. We replicate the abbreviation here and
@@ -120,7 +119,6 @@ end PositiveCone
 section Module
 
 variable {π•œ : Type*} [OrderedSemiring π•œ]
-
 variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [T1Space E] [Module π•œ E]
 
 instance : Zero (ProperCone π•œ E) :=
@@ -149,9 +147,7 @@ end Module
 section InnerProductSpace
 
 variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
-
 variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
-
 variable {G : Type*} [NormedAddCommGroup G] [InnerProductSpace ℝ G]
 
 protected theorem pointed (K : ProperCone ℝ E) : (K : ConvexCone ℝ E).Pointed :=
@@ -231,7 +227,6 @@ end InnerProductSpace
 section CompleteSpace
 
 variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
-
 variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F]
 
 /-- The dual of the dual of a proper cone is itself. -/
chore: move Mathlib to v4.7.0-rc1 (#11162)

This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0 branch as we update to intermediate nightlies.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>

Diff
@@ -281,7 +281,7 @@ theorem hyperplane_separation (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
       simp_rw [ProperCone.mem_dual, adjoint_inner_right]
       intro x hxK
       apply hxy (f x)
-      simp_rw [coe_map]
+      simp_rw [C, coe_map]
       apply subset_closure
       simp_rw [PointedCone.toConvexCone_map, ConvexCone.coe_map, coe_coe, mem_image,
         SetLike.mem_coe]
chore: uneven spacing for ⟨ ⟩ (#10014)

This cleans up instances of

⟨ foo, bar⟩

and

⟨foo, bar ⟩

where spaces a on the inside one side, but not on the other side. Fixing this by removing the extra space.

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -86,7 +86,7 @@ theorem mem_coe {x : E} {K : ProperCone π•œ E} : x ∈ (K : PointedCone π•œ E)
 instance instZero (K : ProperCone π•œ E) : Zero K := PointedCone.instZero (K.toSubmodule)
 
 protected theorem nonempty (K : ProperCone π•œ E) : (K : Set E).Nonempty :=
-  ⟨0, by { simp_rw [SetLike.mem_coe, ← ProperCone.mem_coe, Submodule.zero_mem] } ⟩
+  ⟨0, by { simp_rw [SetLike.mem_coe, ← ProperCone.mem_coe, Submodule.zero_mem] }⟩
 #align proper_cone.nonempty ProperCone.nonempty
 
 protected theorem isClosed (K : ProperCone π•œ E) : IsClosed (K : Set E) :=
chore: reduce imports (#9830)

This uses the improved shake script from #9772 to reduce imports across mathlib. The corresponding noshake.json file has been added to #9772.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 -/
 import Mathlib.Analysis.Convex.Cone.Closure
+import Mathlib.Analysis.InnerProductSpace.Adjoint
 
 #align_import analysis.convex.cone.proper from "leanprover-community/mathlib"@"147b294346843885f952c5171e9606616a8fd869"
 
refactor(ProperCone): redefine ProperCone using PointedCone (#8878)

We change the definition of a ProperCone from being a nonempty, closed, ConvexCone to a closed, PointedCone. This is mathematically (not definitionally) equivalent to the earlier definition as a PointedCone is mathematically (not definitionally) the same as a nonempty, ConvexCone.

The definition of PointedCone was added after ProperCone. Hence, needed to go back and update the definition.

Co-authored-by: apurvanakade <53553755+apurvanakade@users.noreply.github.com>

Diff
@@ -3,18 +3,17 @@ Copyright (c) 2022 Apurva Nakade All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 -/
-import Mathlib.Analysis.Convex.Cone.Dual
-import Mathlib.Analysis.InnerProductSpace.Adjoint
+import Mathlib.Analysis.Convex.Cone.Closure
 
 #align_import analysis.convex.cone.proper from "leanprover-community/mathlib"@"147b294346843885f952c5171e9606616a8fd869"
 
 /-!
 # Proper cones
 
-We define a proper cone as a nonempty, closed, convex cone. Proper cones are used in defining conic
+We define a *proper cone* as a closed, pointed cone. Proper cones are used in defining conic
 programs which generalize linear programs. A linear program is a conic program for the positive
 cone. We then prove Farkas' lemma for conic programs following the proof in the reference below.
-Farkas' lemma is equivalent to strong duality. So, once have the definitions of conic programs and
+Farkas' lemma is equivalent to strong duality. So, once we have the definitions of conic and
 linear programs, the results from this file can be used to prove duality theorems.
 
 ## TODO
@@ -25,7 +24,6 @@ The next steps are:
 - Prove regular and strong duality for cone programs using Farkas' lemma (see reference).
 - Define linear programs and prove LP duality as a special case of cone duality.
 - Find a better reference (textbook instead of lecture notes).
-- Show submodules are (proper) cones.
 
 ## References
 
@@ -35,61 +33,29 @@ The next steps are:
 
 open ContinuousLinearMap Filter Set
 
-namespace ConvexCone
-
-variable {π•œ : Type*} [OrderedSemiring π•œ]
-
-variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [ContinuousAdd E] [SMul π•œ E]
-  [ContinuousConstSMul π•œ E]
-
-/-- The closure of a convex cone inside a topological space as a convex cone. This
-construction is mainly used for defining maps between proper cones. -/
-protected def closure (K : ConvexCone π•œ E) : ConvexCone π•œ E where
-  carrier := closure ↑K
-  smul_mem' c hc _ h₁ :=
-    map_mem_closure (continuous_id'.const_smul c) h₁ fun _ hβ‚‚ => K.smul_mem hc hβ‚‚
-  add_mem' _ h₁ _ hβ‚‚ := map_mem_closureβ‚‚ continuous_add h₁ hβ‚‚ K.add_mem
-#align convex_cone.closure ConvexCone.closure
-
-@[simp, norm_cast]
-theorem coe_closure (K : ConvexCone π•œ E) : (K.closure : Set E) = closure K :=
-  rfl
-#align convex_cone.coe_closure ConvexCone.coe_closure
-
-@[simp]
-protected theorem mem_closure {K : ConvexCone π•œ E} {a : E} :
-    a ∈ K.closure ↔ a ∈ closure (K : Set E) :=
-  Iff.rfl
-#align convex_cone.mem_closure ConvexCone.mem_closure
-
-@[simp]
-theorem closure_eq {K L : ConvexCone π•œ E} : K.closure = L ↔ closure (K : Set E) = L :=
-  SetLike.ext'_iff
-#align convex_cone.closure_eq ConvexCone.closure_eq
-
-end ConvexCone
-
-/-- A proper cone is a convex cone `K` that is nonempty and closed. Proper cones have the nice
-property that the dual of the dual of a proper cone is itself. This makes them useful for defining
-cone programs and proving duality theorems. -/
+/-- A proper cone is a pointed cone `K` that is closed. Proper cones have the nice property that
+they are equal to their double dual, see `ProperCone.dual_dual`.
+This makes them useful for defining cone programs and proving duality theorems. -/
 structure ProperCone (π•œ : Type*) (E : Type*) [OrderedSemiring π•œ] [AddCommMonoid E]
-    [TopologicalSpace E] [SMul π•œ E] extends ConvexCone π•œ E where
-  nonempty' : (carrier : Set E).Nonempty
+    [TopologicalSpace E] [Module π•œ E] extends Submodule {c : π•œ // 0 ≀ c} E where
   isClosed' : IsClosed (carrier : Set E)
 #align proper_cone ProperCone
 
 namespace ProperCone
-
-section SMul
+section Module
 
 variable {π•œ : Type*} [OrderedSemiring π•œ]
 
-variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [SMul π•œ E]
+variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [Module π•œ E]
+
+/-- A `PointedCone` is defined as an alias of submodule. We replicate the abbreviation here and
+define `toPointedCone` as an alias of `toSubmodule`. -/
+abbrev toPointedCone (C : ProperCone π•œ E) := C.toSubmodule
 
-attribute [coe] toConvexCone
+attribute [coe] toPointedCone
 
-instance : Coe (ProperCone π•œ E) (ConvexCone π•œ E) :=
-  ⟨toConvexCone⟩
+instance : Coe (ProperCone π•œ E) (PointedCone π•œ E) :=
+  ⟨toPointedCone⟩
 
 -- Porting note: now a syntactic tautology
 -- @[simp]
@@ -97,14 +63,14 @@ instance : Coe (ProperCone π•œ E) (ConvexCone π•œ E) :=
 --   rfl
 #noalign proper_cone.to_convex_cone_eq_coe
 
-theorem ext' : Function.Injective ((↑) : ProperCone π•œ E β†’ ConvexCone π•œ E) := fun S T h => by
-  cases S; cases T; congr
-#align proper_cone.ext' ProperCone.ext'
+theorem toPointedCone_injective : Function.Injective ((↑) : ProperCone π•œ E β†’ PointedCone π•œ E) :=
+  fun S T h => by cases S; cases T; congr
+#align proper_cone.ext' ProperCone.toPointedCone_injective
 
 -- TODO: add `ConvexConeClass` that extends `SetLike` and replace the below instance
 instance : SetLike (ProperCone π•œ E) E where
   coe K := K.carrier
-  coe_injective' _ _ h := ProperCone.ext' (SetLike.coe_injective h)
+  coe_injective' _ _ h := ProperCone.toPointedCone_injective (SetLike.coe_injective h)
 
 @[ext]
 theorem ext {S T : ProperCone π•œ E} (h : βˆ€ x, x ∈ S ↔ x ∈ T) : S = T :=
@@ -112,19 +78,21 @@ theorem ext {S T : ProperCone π•œ E} (h : βˆ€ x, x ∈ S ↔ x ∈ T) : S = T :
 #align proper_cone.ext ProperCone.ext
 
 @[simp]
-theorem mem_coe {x : E} {K : ProperCone π•œ E} : x ∈ (K : ConvexCone π•œ E) ↔ x ∈ K :=
+theorem mem_coe {x : E} {K : ProperCone π•œ E} : x ∈ (K : PointedCone π•œ E) ↔ x ∈ K :=
   Iff.rfl
 #align proper_cone.mem_coe ProperCone.mem_coe
 
+instance instZero (K : ProperCone π•œ E) : Zero K := PointedCone.instZero (K.toSubmodule)
+
 protected theorem nonempty (K : ProperCone π•œ E) : (K : Set E).Nonempty :=
-  K.nonempty'
+  ⟨0, by { simp_rw [SetLike.mem_coe, ← ProperCone.mem_coe, Submodule.zero_mem] } ⟩
 #align proper_cone.nonempty ProperCone.nonempty
 
 protected theorem isClosed (K : ProperCone π•œ E) : IsClosed (K : Set E) :=
   K.isClosed'
 #align proper_cone.is_closed ProperCone.isClosed
 
-end SMul
+end Module
 
 section PositiveCone
 
@@ -135,8 +103,7 @@ variable [OrderedSemiring π•œ] [OrderedAddCommGroup E] [Module π•œ E] [Ordered
 /-- The positive cone is the proper cone formed by the set of nonnegative elements in an ordered
 module. -/
 def positive : ProperCone π•œ E where
-  toConvexCone := ConvexCone.positive π•œ E
-  nonempty' := ⟨0, ConvexCone.pointed_positive _ _⟩
+  toSubmodule := PointedCone.positive π•œ E
   isClosed' := isClosed_Ici
 
 @[simp]
@@ -156,9 +123,8 @@ variable {π•œ : Type*} [OrderedSemiring π•œ]
 variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [T1Space E] [Module π•œ E]
 
 instance : Zero (ProperCone π•œ E) :=
-  ⟨{  toConvexCone := 0
-      nonempty' := ⟨0, rfl⟩
-      isClosed' := isClosed_singleton }⟩
+  ⟨{ toSubmodule := 0
+     isClosed' := isClosed_singleton }⟩
 
 instance : Inhabited (ProperCone π•œ E) :=
   ⟨0⟩
@@ -173,7 +139,8 @@ theorem coe_zero : ↑(0 : ProperCone π•œ E) = (0 : ConvexCone π•œ E) :=
   rfl
 #align proper_cone.coe_zero ProperCone.coe_zero
 
-theorem pointed_zero : (0 : ProperCone π•œ E).Pointed := by simp [ConvexCone.pointed_zero]
+theorem pointed_zero : ((0 : ProperCone π•œ E) : ConvexCone π•œ E).Pointed := by
+  simp [ConvexCone.pointed_zero]
 #align proper_cone.pointed_zero ProperCone.pointed_zero
 
 end Module
@@ -187,61 +154,54 @@ variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
 variable {G : Type*} [NormedAddCommGroup G] [InnerProductSpace ℝ G]
 
 protected theorem pointed (K : ProperCone ℝ E) : (K : ConvexCone ℝ E).Pointed :=
-  (K : ConvexCone ℝ E).pointed_of_nonempty_of_isClosed K.nonempty' K.isClosed
+  (K : ConvexCone ℝ E).pointed_of_nonempty_of_isClosed K.nonempty K.isClosed
 #align proper_cone.pointed ProperCone.pointed
 
 /-- The closure of image of a proper cone under a continuous `ℝ`-linear map is a proper cone. We
 use continuous maps here so that the comap of f is also a map between proper cones. -/
 noncomputable def map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) : ProperCone ℝ F where
-  toConvexCone := ConvexCone.closure (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K)
-  nonempty' :=
-    ⟨0, subset_closure <| SetLike.mem_coe.2 <| ConvexCone.mem_map.2 ⟨0, K.pointed, map_zero _⟩⟩
+  toSubmodule := PointedCone.closure (PointedCone.map (f : E β†’β‚—[ℝ] F) ↑K)
   isClosed' := isClosed_closure
 #align proper_cone.map ProperCone.map
 
 @[simp, norm_cast]
 theorem coe_map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) :
-    ↑(K.map f) = (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
+    ↑(K.map f) = (PointedCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
   rfl
 #align proper_cone.coe_map ProperCone.coe_map
 
 @[simp]
 theorem mem_map {f : E β†’L[ℝ] F} {K : ProperCone ℝ E} {y : F} :
-    y ∈ K.map f ↔ y ∈ (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
+    y ∈ K.map f ↔ y ∈ (PointedCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
   Iff.rfl
 #align proper_cone.mem_map ProperCone.mem_map
 
 @[simp]
 theorem map_id (K : ProperCone ℝ E) : K.map (ContinuousLinearMap.id ℝ E) = K :=
-  ProperCone.ext' <| by simpa using IsClosed.closure_eq K.isClosed
+  ProperCone.toPointedCone_injective <| by simpa using IsClosed.closure_eq K.isClosed
 #align proper_cone.map_id ProperCone.map_id
 
 /-- The inner dual cone of a proper cone is a proper cone. -/
 def dual (K : ProperCone ℝ E) : ProperCone ℝ E where
-  toConvexCone := (K : Set E).innerDualCone
-  nonempty' := ⟨0, pointed_innerDualCone _⟩
+  toSubmodule := PointedCone.dual (K : PointedCone ℝ E)
   isClosed' := isClosed_innerDualCone _
 #align proper_cone.dual ProperCone.dual
 
 @[simp, norm_cast]
-theorem coe_dual (K : ProperCone ℝ E) : ↑(dual K) = (K : Set E).innerDualCone :=
+theorem coe_dual (K : ProperCone ℝ E) : K.dual = (K : Set E).innerDualCone :=
   rfl
 #align proper_cone.coe_dual ProperCone.coe_dual
 
 @[simp]
 theorem mem_dual {K : ProperCone ℝ E} {y : E} : y ∈ dual K ↔ βˆ€ ⦃x⦄, x ∈ K β†’ 0 ≀ βŸͺx, y⟫_ℝ := by
-  rw [← mem_coe, coe_dual, mem_innerDualCone _ _]; rfl
+  aesop
 #align proper_cone.mem_dual ProperCone.mem_dual
 
 /-- The preimage of a proper cone under a continuous `ℝ`-linear map is a proper cone. -/
 noncomputable def comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : ProperCone ℝ E where
-  toConvexCone := ConvexCone.comap (f : E β†’β‚—[ℝ] F) S
-  nonempty' :=
-    ⟨0, by
-      simp only [ConvexCone.comap, mem_preimage, map_zero, SetLike.mem_coe, mem_coe]
-      apply ProperCone.pointed⟩
+  toSubmodule := PointedCone.comap (f : E β†’β‚—[ℝ] F) S
   isClosed' := by
-    simp only [ConvexCone.comap, ContinuousLinearMap.coe_coe]
+    rw [PointedCone.comap]
     apply IsClosed.preimage f.2 S.isClosed
 #align proper_cone.comap ProperCone.comap
 
@@ -276,23 +236,25 @@ variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteS
 /-- The dual of the dual of a proper cone is itself. -/
 @[simp]
 theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
-  ProperCone.ext' <|
-    (K : ConvexCone ℝ E).innerDualCone_of_innerDualCone_eq_self K.nonempty' K.isClosed
+  ProperCone.toPointedCone_injective <| PointedCone.toConvexCone_injective <|
+    (K : ConvexCone ℝ E).innerDualCone_of_innerDualCone_eq_self K.nonempty K.isClosed
 #align proper_cone.dual_dual ProperCone.dual_dual
 
 /-- This is a relative version of
 `ConvexCone.hyperplane_separation_of_nonempty_of_isClosed_of_nmem`, which we recover by setting
-`f` to be the identity map. This is a geometric interpretation of the Farkas' lemma
+`f` to be the identity map. This is also a geometric interpretation of the Farkas' lemma
 stated using proper cones. -/
 theorem hyperplane_separation (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F} :
     b ∈ K.map f ↔ βˆ€ y : F, adjoint f y ∈ K.dual β†’ 0 ≀ βŸͺy, b⟫_ℝ :=
   Iff.intro
     (by
       -- suppose `b ∈ K.map f`
-      simp only [ProperCone.mem_map, ProperCone.mem_dual, adjoint_inner_right,
-        ConvexCone.mem_closure, mem_closure_iff_seq_limit]
+      simp_rw [mem_map, PointedCone.mem_closure, PointedCone.coe_map, coe_coe,
+        mem_closure_iff_seq_limit, mem_image, SetLike.mem_coe, mem_coe, mem_dual,
+        adjoint_inner_right, forall_exists_index, and_imp]
+
       -- there is a sequence `seq : β„• β†’ F` in the image of `f` that converges to `b`
-      rintro ⟨seq, hmem, htends⟩ y hinner
+      rintro seq hmem htends y hinner
       suffices h : βˆ€ n, 0 ≀ βŸͺy, seq n⟫_ℝ from
         ge_of_tendsto'
           (Continuous.seqContinuous (Continuous.inner (@continuous_const _ _ _ _ y) continuous_id)
@@ -306,19 +268,23 @@ theorem hyperplane_separation (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
       -- suppose `b βˆ‰ K.map f`
       intro h
       contrapose! h
+
       -- as `b βˆ‰ K.map f`, there is a hyperplane `y` separating `b` from `K.map f`
+      let C := @PointedCone.toConvexCone ℝ F _ _ _ (K.map f)
       obtain ⟨y, hxy, hyb⟩ :=
-        ConvexCone.hyperplane_separation_of_nonempty_of_isClosed_of_nmem _ (K.map f).nonempty
-          (K.map f).isClosed h
+        @ConvexCone.hyperplane_separation_of_nonempty_of_isClosed_of_nmem
+        _ _ _ _ C (K.map f).nonempty (K.map f).isClosed b h
+
       -- the rest of the proof is a straightforward algebraic manipulation
       refine' ⟨y, _, hyb⟩
       simp_rw [ProperCone.mem_dual, adjoint_inner_right]
       intro x hxK
       apply hxy (f x)
-      rw [ProperCone.coe_map]
+      simp_rw [coe_map]
       apply subset_closure
-      rw [SetLike.mem_coe, ConvexCone.mem_map]
-      refine' ⟨x, hxK, by rw [coe_coe]⟩)
+      simp_rw [PointedCone.toConvexCone_map, ConvexCone.coe_map, coe_coe, mem_image,
+        SetLike.mem_coe]
+      exact ⟨x, hxK, rfl⟩)
 #align proper_cone.hyperplane_separation ProperCone.hyperplane_separation
 
 theorem hyperplane_separation_of_nmem (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
chore: tidy various files (#8409)
Diff
@@ -75,7 +75,7 @@ cone programs and proving duality theorems. -/
 structure ProperCone (π•œ : Type*) (E : Type*) [OrderedSemiring π•œ] [AddCommMonoid E]
     [TopologicalSpace E] [SMul π•œ E] extends ConvexCone π•œ E where
   nonempty' : (carrier : Set E).Nonempty
-  is_closed' : IsClosed (carrier : Set E)
+  isClosed' : IsClosed (carrier : Set E)
 #align proper_cone ProperCone
 
 namespace ProperCone
@@ -86,14 +86,16 @@ variable {π•œ : Type*} [OrderedSemiring π•œ]
 
 variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [SMul π•œ E]
 
+attribute [coe] toConvexCone
+
 instance : Coe (ProperCone π•œ E) (ConvexCone π•œ E) :=
-  ⟨fun K => K.1⟩
+  ⟨toConvexCone⟩
 
 -- Porting note: now a syntactic tautology
 -- @[simp]
 -- theorem toConvexCone_eq_coe (K : ProperCone π•œ E) : K.toConvexCone = K :=
 --   rfl
--- #align proper_cone.to_convex_cone_eq_coe ProperCone.toConvexCone_eq_coe
+#noalign proper_cone.to_convex_cone_eq_coe
 
 theorem ext' : Function.Injective ((↑) : ProperCone π•œ E β†’ ConvexCone π•œ E) := fun S T h => by
   cases S; cases T; congr
@@ -119,7 +121,7 @@ protected theorem nonempty (K : ProperCone π•œ E) : (K : Set E).Nonempty :=
 #align proper_cone.nonempty ProperCone.nonempty
 
 protected theorem isClosed (K : ProperCone π•œ E) : IsClosed (K : Set E) :=
-  K.is_closed'
+  K.isClosed'
 #align proper_cone.is_closed ProperCone.isClosed
 
 end SMul
@@ -135,7 +137,7 @@ module. -/
 def positive : ProperCone π•œ E where
   toConvexCone := ConvexCone.positive π•œ E
   nonempty' := ⟨0, ConvexCone.pointed_positive _ _⟩
-  is_closed' := isClosed_Ici
+  isClosed' := isClosed_Ici
 
 @[simp]
 theorem mem_positive {x : E} : x ∈ positive π•œ E ↔ 0 ≀ x :=
@@ -156,7 +158,7 @@ variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [T1Space E] [Module
 instance : Zero (ProperCone π•œ E) :=
   ⟨{  toConvexCone := 0
       nonempty' := ⟨0, rfl⟩
-      is_closed' := isClosed_singleton }⟩
+      isClosed' := isClosed_singleton }⟩
 
 instance : Inhabited (ProperCone π•œ E) :=
   ⟨0⟩
@@ -166,7 +168,7 @@ theorem mem_zero (x : E) : x ∈ (0 : ProperCone π•œ E) ↔ x = 0 :=
   Iff.rfl
 #align proper_cone.mem_zero ProperCone.mem_zero
 
-@[simp] -- Porting note: removed `norm_cast` (new-style structures)
+@[simp, norm_cast]
 theorem coe_zero : ↑(0 : ProperCone π•œ E) = (0 : ConvexCone π•œ E) :=
   rfl
 #align proper_cone.coe_zero ProperCone.coe_zero
@@ -194,10 +196,10 @@ noncomputable def map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) : ProperCone 
   toConvexCone := ConvexCone.closure (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K)
   nonempty' :=
     ⟨0, subset_closure <| SetLike.mem_coe.2 <| ConvexCone.mem_map.2 ⟨0, K.pointed, map_zero _⟩⟩
-  is_closed' := isClosed_closure
+  isClosed' := isClosed_closure
 #align proper_cone.map ProperCone.map
 
-@[simp] -- Porting note: removed `norm_cast` (new-style structures)
+@[simp, norm_cast]
 theorem coe_map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) :
     ↑(K.map f) = (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K).closure :=
   rfl
@@ -218,10 +220,10 @@ theorem map_id (K : ProperCone ℝ E) : K.map (ContinuousLinearMap.id ℝ E) = K
 def dual (K : ProperCone ℝ E) : ProperCone ℝ E where
   toConvexCone := (K : Set E).innerDualCone
   nonempty' := ⟨0, pointed_innerDualCone _⟩
-  is_closed' := isClosed_innerDualCone _
+  isClosed' := isClosed_innerDualCone _
 #align proper_cone.dual ProperCone.dual
 
-@[simp] -- Porting note: removed `norm_cast` (new-style structures)
+@[simp, norm_cast]
 theorem coe_dual (K : ProperCone ℝ E) : ↑(dual K) = (K : Set E).innerDualCone :=
   rfl
 #align proper_cone.coe_dual ProperCone.coe_dual
@@ -232,14 +234,13 @@ theorem mem_dual {K : ProperCone ℝ E} {y : E} : y ∈ dual K ↔ βˆ€ ⦃x⦄,
 #align proper_cone.mem_dual ProperCone.mem_dual
 
 /-- The preimage of a proper cone under a continuous `ℝ`-linear map is a proper cone. -/
-noncomputable def comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : ProperCone ℝ E
-    where
+noncomputable def comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : ProperCone ℝ E where
   toConvexCone := ConvexCone.comap (f : E β†’β‚—[ℝ] F) S
   nonempty' :=
     ⟨0, by
       simp only [ConvexCone.comap, mem_preimage, map_zero, SetLike.mem_coe, mem_coe]
       apply ProperCone.pointed⟩
-  is_closed' := by
+  isClosed' := by
     simp only [ConvexCone.comap, ContinuousLinearMap.coe_coe]
     apply IsClosed.preimage f.2 S.isClosed
 #align proper_cone.comap ProperCone.comap
@@ -292,8 +293,7 @@ theorem hyperplane_separation (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
         ConvexCone.mem_closure, mem_closure_iff_seq_limit]
       -- there is a sequence `seq : β„• β†’ F` in the image of `f` that converges to `b`
       rintro ⟨seq, hmem, htends⟩ y hinner
-      suffices h : βˆ€ n, 0 ≀ βŸͺy, seq n⟫_ℝ;
-      exact
+      suffices h : βˆ€ n, 0 ≀ βŸͺy, seq n⟫_ℝ from
         ge_of_tendsto'
           (Continuous.seqContinuous (Continuous.inner (@continuous_const _ _ _ _ y) continuous_id)
             htends)
style: remove trailing whitespace and modify the linter to detect it (#6519)
Diff
@@ -126,7 +126,7 @@ end SMul
 
 section PositiveCone
 
-variable (π•œ E) 
+variable (π•œ E)
 variable [OrderedSemiring π•œ] [OrderedAddCommGroup E] [Module π•œ E] [OrderedSMul π•œ E]
   [TopologicalSpace E] [OrderClosedTopology E]
 
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -37,9 +37,9 @@ open ContinuousLinearMap Filter Set
 
 namespace ConvexCone
 
-variable {π•œ : Type _} [OrderedSemiring π•œ]
+variable {π•œ : Type*} [OrderedSemiring π•œ]
 
-variable {E : Type _} [AddCommMonoid E] [TopologicalSpace E] [ContinuousAdd E] [SMul π•œ E]
+variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [ContinuousAdd E] [SMul π•œ E]
   [ContinuousConstSMul π•œ E]
 
 /-- The closure of a convex cone inside a topological space as a convex cone. This
@@ -72,7 +72,7 @@ end ConvexCone
 /-- A proper cone is a convex cone `K` that is nonempty and closed. Proper cones have the nice
 property that the dual of the dual of a proper cone is itself. This makes them useful for defining
 cone programs and proving duality theorems. -/
-structure ProperCone (π•œ : Type _) (E : Type _) [OrderedSemiring π•œ] [AddCommMonoid E]
+structure ProperCone (π•œ : Type*) (E : Type*) [OrderedSemiring π•œ] [AddCommMonoid E]
     [TopologicalSpace E] [SMul π•œ E] extends ConvexCone π•œ E where
   nonempty' : (carrier : Set E).Nonempty
   is_closed' : IsClosed (carrier : Set E)
@@ -82,9 +82,9 @@ namespace ProperCone
 
 section SMul
 
-variable {π•œ : Type _} [OrderedSemiring π•œ]
+variable {π•œ : Type*} [OrderedSemiring π•œ]
 
-variable {E : Type _} [AddCommMonoid E] [TopologicalSpace E] [SMul π•œ E]
+variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [SMul π•œ E]
 
 instance : Coe (ProperCone π•œ E) (ConvexCone π•œ E) :=
   ⟨fun K => K.1⟩
@@ -149,9 +149,9 @@ end PositiveCone
 
 section Module
 
-variable {π•œ : Type _} [OrderedSemiring π•œ]
+variable {π•œ : Type*} [OrderedSemiring π•œ]
 
-variable {E : Type _} [AddCommMonoid E] [TopologicalSpace E] [T1Space E] [Module π•œ E]
+variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [T1Space E] [Module π•œ E]
 
 instance : Zero (ProperCone π•œ E) :=
   ⟨{  toConvexCone := 0
@@ -178,11 +178,11 @@ end Module
 
 section InnerProductSpace
 
-variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
 
-variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
+variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
 
-variable {G : Type _} [NormedAddCommGroup G] [InnerProductSpace ℝ G]
+variable {G : Type*} [NormedAddCommGroup G] [InnerProductSpace ℝ G]
 
 protected theorem pointed (K : ProperCone ℝ E) : (K : ConvexCone ℝ E).Pointed :=
   (K : ConvexCone ℝ E).pointed_of_nonempty_of_isClosed K.nonempty' K.isClosed
@@ -268,9 +268,9 @@ end InnerProductSpace
 
 section CompleteSpace
 
-variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
 
-variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F]
+variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F]
 
 /-- The dual of the dual of a proper cone is itself. -/
 @[simp]
feat(Analysis/Convex/Cone/Proper): define ProperCone.positive extending ConvexCone.positive (#6059)

Defines ProperCone.positive extending ConvexCone.positive.

Part of #6058

Diff
@@ -21,7 +21,6 @@ linear programs, the results from this file can be used to prove duality theorem
 
 The next steps are:
 - Add convex_cone_class that extends set_like and replace the below instance
-- Define the positive cone as a proper cone.
 - Define primal and dual cone programs and prove weak duality.
 - Prove regular and strong duality for cone programs using Farkas' lemma (see reference).
 - Define linear programs and prove LP duality as a special case of cone duality.
@@ -125,6 +124,29 @@ protected theorem isClosed (K : ProperCone π•œ E) : IsClosed (K : Set E) :=
 
 end SMul
 
+section PositiveCone
+
+variable (π•œ E) 
+variable [OrderedSemiring π•œ] [OrderedAddCommGroup E] [Module π•œ E] [OrderedSMul π•œ E]
+  [TopologicalSpace E] [OrderClosedTopology E]
+
+/-- The positive cone is the proper cone formed by the set of nonnegative elements in an ordered
+module. -/
+def positive : ProperCone π•œ E where
+  toConvexCone := ConvexCone.positive π•œ E
+  nonempty' := ⟨0, ConvexCone.pointed_positive _ _⟩
+  is_closed' := isClosed_Ici
+
+@[simp]
+theorem mem_positive {x : E} : x ∈ positive π•œ E ↔ 0 ≀ x :=
+  Iff.rfl
+
+@[simp]
+theorem coe_positive : ↑(positive π•œ E) = ConvexCone.positive π•œ E :=
+  rfl
+
+end PositiveCone
+
 section Module
 
 variable {π•œ : Type _} [OrderedSemiring π•œ]
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Apurva Nakade All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
-
-! This file was ported from Lean 3 source module analysis.convex.cone.proper
-! leanprover-community/mathlib commit 147b294346843885f952c5171e9606616a8fd869
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Analysis.Convex.Cone.Dual
 import Mathlib.Analysis.InnerProductSpace.Adjoint
 
+#align_import analysis.convex.cone.proper from "leanprover-community/mathlib"@"147b294346843885f952c5171e9606616a8fd869"
+
 /-!
 # Proper cones
 
fix: re-port Mathlib.Analysis.Convex.Cone.Proper (#5646)

Forward port [#19008](https://github.com/leanprover-community/mathlib/pull/19008)

When I ported this file (Mathlib/Analysis/Convex/Cone/Proper.lean) I did not realize that mathport had used an older commit without the latest PR. I'm forward porting it now.

Diff
@@ -4,11 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Apurva Nakade
 
 ! This file was ported from Lean 3 source module analysis.convex.cone.proper
-! leanprover-community/mathlib commit 74f1d61944a5a793e8c939d47608178c0a0cb0c2
+! leanprover-community/mathlib commit 147b294346843885f952c5171e9606616a8fd869
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathlib.Analysis.Convex.Cone.Dual
+import Mathlib.Analysis.InnerProductSpace.Adjoint
 
 /-!
 # Proper cones
@@ -22,8 +23,6 @@ linear programs, the results from this file can be used to prove duality theorem
 ## TODO
 
 The next steps are:
-- Prove the cone version of Farkas' lemma (2.3.4 in the reference).
-- Add comap, adjoint
 - Add convex_cone_class that extends set_like and replace the below instance
 - Define the positive cone as a proper cone.
 - Define primal and dual cone programs and prove weak duality.
@@ -38,6 +37,7 @@ The next steps are:
 
 -/
 
+open ContinuousLinearMap Filter Set
 
 namespace ConvexCone
 
@@ -163,12 +163,14 @@ variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
 
 variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
 
+variable {G : Type _} [NormedAddCommGroup G] [InnerProductSpace ℝ G]
+
 protected theorem pointed (K : ProperCone ℝ E) : (K : ConvexCone ℝ E).Pointed :=
   (K : ConvexCone ℝ E).pointed_of_nonempty_of_isClosed K.nonempty' K.isClosed
 #align proper_cone.pointed ProperCone.pointed
 
 /-- The closure of image of a proper cone under a continuous `ℝ`-linear map is a proper cone. We
-use continuous maps here so that the adjoint of f is also a map between proper cones. -/
+use continuous maps here so that the comap of f is also a map between proper cones. -/
 noncomputable def map (f : E β†’L[ℝ] F) (K : ProperCone ℝ E) : ProperCone ℝ F where
   toConvexCone := ConvexCone.closure (ConvexCone.map (f : E β†’β‚—[ℝ] F) ↑K)
   nonempty' :=
@@ -210,13 +212,47 @@ theorem mem_dual {K : ProperCone ℝ E} {y : E} : y ∈ dual K ↔ βˆ€ ⦃x⦄,
   rw [← mem_coe, coe_dual, mem_innerDualCone _ _]; rfl
 #align proper_cone.mem_dual ProperCone.mem_dual
 
--- TODO: add comap, adjoint
+/-- The preimage of a proper cone under a continuous `ℝ`-linear map is a proper cone. -/
+noncomputable def comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : ProperCone ℝ E
+    where
+  toConvexCone := ConvexCone.comap (f : E β†’β‚—[ℝ] F) S
+  nonempty' :=
+    ⟨0, by
+      simp only [ConvexCone.comap, mem_preimage, map_zero, SetLike.mem_coe, mem_coe]
+      apply ProperCone.pointed⟩
+  is_closed' := by
+    simp only [ConvexCone.comap, ContinuousLinearMap.coe_coe]
+    apply IsClosed.preimage f.2 S.isClosed
+#align proper_cone.comap ProperCone.comap
+
+@[simp]
+theorem coe_comap (f : E β†’L[ℝ] F) (S : ProperCone ℝ F) : (S.comap f : Set E) = f ⁻¹' S :=
+  rfl
+#align proper_cone.coe_comap ProperCone.coe_comap
+
+@[simp]
+theorem comap_id (S : ConvexCone ℝ E) : S.comap LinearMap.id = S :=
+  SetLike.coe_injective preimage_id
+#align proper_cone.comap_id ProperCone.comap_id
+
+theorem comap_comap (g : F β†’L[ℝ] G) (f : E β†’L[ℝ] F) (S : ProperCone ℝ G) :
+    (S.comap g).comap f = S.comap (g.comp f) :=
+  SetLike.coe_injective <| by congr
+#align proper_cone.comap_comap ProperCone.comap_comap
+
+@[simp]
+theorem mem_comap {f : E β†’L[ℝ] F} {S : ProperCone ℝ F} {x : E} : x ∈ S.comap f ↔ f x ∈ S :=
+  Iff.rfl
+#align proper_cone.mem_comap ProperCone.mem_comap
+
 end InnerProductSpace
 
 section CompleteSpace
 
 variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
 
+variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F]
+
 /-- The dual of the dual of a proper cone is itself. -/
 @[simp]
 theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
@@ -224,6 +260,53 @@ theorem dual_dual (K : ProperCone ℝ E) : K.dual.dual = K :=
     (K : ConvexCone ℝ E).innerDualCone_of_innerDualCone_eq_self K.nonempty' K.isClosed
 #align proper_cone.dual_dual ProperCone.dual_dual
 
+/-- This is a relative version of
+`ConvexCone.hyperplane_separation_of_nonempty_of_isClosed_of_nmem`, which we recover by setting
+`f` to be the identity map. This is a geometric interpretation of the Farkas' lemma
+stated using proper cones. -/
+theorem hyperplane_separation (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F} :
+    b ∈ K.map f ↔ βˆ€ y : F, adjoint f y ∈ K.dual β†’ 0 ≀ βŸͺy, b⟫_ℝ :=
+  Iff.intro
+    (by
+      -- suppose `b ∈ K.map f`
+      simp only [ProperCone.mem_map, ProperCone.mem_dual, adjoint_inner_right,
+        ConvexCone.mem_closure, mem_closure_iff_seq_limit]
+      -- there is a sequence `seq : β„• β†’ F` in the image of `f` that converges to `b`
+      rintro ⟨seq, hmem, htends⟩ y hinner
+      suffices h : βˆ€ n, 0 ≀ βŸͺy, seq n⟫_ℝ;
+      exact
+        ge_of_tendsto'
+          (Continuous.seqContinuous (Continuous.inner (@continuous_const _ _ _ _ y) continuous_id)
+            htends)
+          h
+      intro n
+      obtain ⟨_, h, hseq⟩ := hmem n
+      simpa only [← hseq, real_inner_comm] using hinner h)
+    (by
+      -- proof by contradiction
+      -- suppose `b βˆ‰ K.map f`
+      intro h
+      contrapose! h
+      -- as `b βˆ‰ K.map f`, there is a hyperplane `y` separating `b` from `K.map f`
+      obtain ⟨y, hxy, hyb⟩ :=
+        ConvexCone.hyperplane_separation_of_nonempty_of_isClosed_of_nmem _ (K.map f).nonempty
+          (K.map f).isClosed h
+      -- the rest of the proof is a straightforward algebraic manipulation
+      refine' ⟨y, _, hyb⟩
+      simp_rw [ProperCone.mem_dual, adjoint_inner_right]
+      intro x hxK
+      apply hxy (f x)
+      rw [ProperCone.coe_map]
+      apply subset_closure
+      rw [SetLike.mem_coe, ConvexCone.mem_map]
+      refine' ⟨x, hxK, by rw [coe_coe]⟩)
+#align proper_cone.hyperplane_separation ProperCone.hyperplane_separation
+
+theorem hyperplane_separation_of_nmem (K : ProperCone ℝ E) {f : E β†’L[ℝ] F} {b : F}
+    (disj : b βˆ‰ K.map f) : βˆƒ y : F, adjoint f y ∈ K.dual ∧ βŸͺy, b⟫_ℝ < 0 := by
+  contrapose! disj; rwa [K.hyperplane_separation]
+#align proper_cone.hyperplane_separation_of_nmem ProperCone.hyperplane_separation_of_nmem
+
 end CompleteSpace
 
 end ProperCone
feat: port Analysis.Convex.Cone.Proper (#5607)

The remaining errors are about coe and norm_cast. I do not understand these well enough in Lean 4. Please feel free to push changes.

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Dependencies 12 + 918

919 files ported (98.7%)
406175 lines ported (98.6%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file