Download data/lean/OAI/Geometry/BallPacking/DiskMaps/SmoothConvexSelection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 24.9 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/BallPacking/DiskMaps/SmoothConvexSelection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Geometry/BallPacking/DiskMaps/SmoothConvexSelection.lean
-
curl -L -o SmoothConvexSelection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/BallPacking/DiskMaps/SmoothConvexSelection.lean
24.9 kB
| import Mathlib | |
| import OAI.Geometry.BallPacking.DiskMaps.CubicAreaExhaustion | |
| namespace OAI | |
| noncomputable section | |
| namespace PackingSufficiencySupport.Hamiltonian | |
| section | |
| open scoped ContDiff Topology Manifold | |
| open Set Function | |
| variable {P F : Type*} [NormedAddCommGroup P] [NormedSpace β P] [FiniteDimensional β P] | |
| [NormedAddCommGroup F] [NormedSpace β F] | |
| theorem exists_smooth_convex_selection {Y : Set P} (hY : IsClosed Y) | |
| (S : P β Set F) (hopen : β v, IsOpen {y | v β S y}) | |
| (hconv : β y β Y, Convex β (S y)) (hne : β y β Y, (S y).Nonempty) : | |
| β c : P β F, ContDiff β β c β§ β y β Y, c y β S y := by | |
| classical | |
| choose v hv using fun y : Y => hne y y.property | |
| let U : Y β Set P := fun y => {x | v y β S x} | |
| obtain β¨Ο,hΟβ© := SmoothPartitionOfUnity.exists_isSubordinate π(β,P) hY U | |
| (fun y => hopen (v y)) (by | |
| intro y hy | |
| exact mem_iUnion_of_mem β¨y,hyβ© (hv β¨y,hyβ©)) | |
| refine β¨fun y => βαΆ i, Ο i y β’ v i,?_,?_β© | |
| Β· apply contDiff_iff_contDiffAt.mpr | |
| intro y | |
| exact Ο.contDiffAt_finsum (fun _ _ => contDiffAt_const) | |
| Β· intro y hy | |
| apply Ο.finsum_smul_mem_convex hy _ (hconv y hy) | |
| intro i hi | |
| exact hΟ i (subset_tsupport (Ο i) hi) | |
| end | |
| section | |
| open Set Function | |
| theorem exists_strict_interval_extension {a b l u L : β} | |
| (hal : a < l) (hub : u < b) (hLu : u-l < L) (hLb : L < b-a) : | |
| β c, a < c β§ c+L < b β§ c < l β§ u < c+L := by | |
| have hh : max a (u-L) < min l (b-L) := by | |
| rw [max_lt_iff,lt_min_iff,lt_min_iff] | |
| constructor <;> constructor <;> linarith | |
| obtain β¨c,hlo,hhiβ© := exists_between hh | |
| exact β¨c,(le_max_left _ _).trans_lt hlo, | |
| by linarith [(lt_of_lt_of_le hhi (min_le_right _ _))], | |
| hhi.trans_le (min_le_left _ _), | |
| by linarith [(lt_of_le_of_lt (le_max_right _ _) hlo)]β© | |
| theorem exists_strict_nested_intervals {n : β} (a b L : Fin n β β) | |
| (ha : Antitone a) (hb : Monotone b) (hL : StrictMono L) | |
| (hfit : β i, L i < b i-a i) : | |
| β c : Fin n β β, (β i, a i < c i β§ c i+L i < b i) β§ | |
| β β¦i jβ¦, i < j β c j < c i β§ c i+L i < c j+L j := by | |
| induction n with | |
| | zero => exact β¨fun i => i.elim0,by simp,by simpβ© | |
| | succ n ih => | |
| cases n with | |
| | zero => | |
| refine β¨fun i => (a i+b i-L i)/2,?_,?_β© | |
| Β· intro i; have := hfit i; constructor <;> linarith | |
| Β· intro i j hij | |
| have : i = j := by omega | |
| exact (lt_irrefl _ (this βΈ hij)).elim | |
| | succ m => | |
| obtain β¨c,hc,hnestβ© := ih (a β Fin.castSucc) (b β Fin.castSucc) | |
| (L β Fin.castSucc) (ha.comp_monotone Fin.strictMono_castSucc.monotone) | |
| (hb.comp Fin.strictMono_castSucc.monotone) (hL.comp Fin.strictMono_castSucc) | |
| (fun i => hfit i.castSucc) | |
| let iβ : Fin (m+1) := Fin.last m | |
| let jβ : Fin (m+2) := Fin.last (m+1) | |
| have hij : iβ.castSucc < jβ := Fin.castSucc_lt_last _ | |
| obtain β¨d,hdβ© := exists_strict_interval_extension | |
| ((ha hij.le).trans_lt (hc iβ).1) | |
| ((hc iβ).2.trans_le (hb hij.le)) | |
| (by simpa only [Function.comp_apply,add_sub_cancel_left] using hL hij) | |
| (hfit jβ) | |
| refine β¨Fin.snoc c d,?_,?_β© | |
| Β· intro i | |
| refine Fin.lastCases ?_ (fun j => ?_) i | |
| Β· simpa only [Fin.snoc_last] using And.intro hd.1 hd.2.1 | |
| Β· simpa only [Fin.snoc_castSucc,Function.comp_apply] using hc j | |
| Β· intro i j hij' | |
| have hi : i β Fin.last (m+1) := by | |
| intro hh | |
| subst i | |
| exact not_lt_of_ge (Fin.le_last _) hij' | |
| obtain β¨i,rflβ© := Fin.eq_castSucc_of_ne_last hi | |
| revert hij' | |
| refine Fin.lastCases ?_ (fun j hj => ?_) j | |
| Β· intro _ | |
| simp only [Fin.snoc_castSucc,Fin.snoc_last] | |
| rcases lt_or_eq_of_le (Fin.le_last i) with hi | hi | |
| Β· have hh := hnest hi | |
| exact β¨hd.2.2.1.trans hh.1,hh.2.trans hd.2.2.2β© | |
| Β· subst i | |
| exact hd.2.2 | |
| Β· simpa only [Fin.snoc_castSucc,Function.comp_apply] using | |
| hnest (show i < j from hj) | |
| end | |
| section | |
| open scoped ContDiff Topology | |
| open Set Function | |
| variable {n : β} | |
| def StrictNestedStarts (L c : Fin n β β) : Prop := | |
| β β¦i j : Fin nβ¦, i < j β c j < c i β§ c i+L i < c j+L j | |
| def IntervalPlacements (L : Fin n β β) (V : Fin n β Set β) : Set (Fin n β β) := | |
| {c | (β i, c i β V i β§ c i+L i β V i) β§ StrictNestedStarts L c} | |
| theorem intervalPlacements_convex (L : Fin n β β) (V : Fin n β Set β) | |
| (hV : β i, Convex β (V i)) : Convex β (IntervalPlacements L V) := by | |
| intro c hc d hd Ξ± Ξ² hΞ± hΞ² hab | |
| refine β¨?_,?_β© | |
| Β· intro i | |
| have he : (Ξ± β’ c+Ξ² β’ d) i+L i = Ξ±*(c i+L i)+Ξ²*(d i+L i) := by | |
| simp only [Pi.add_apply,Pi.smul_apply,smul_eq_mul] | |
| have he := congrArg (fun t : β => t*L i) hab | |
| nlinarith only [he] | |
| constructor | |
| Β· exact hV i (hc.1 i).1 (hd.1 i).1 hΞ± hΞ² hab | |
| Β· rw [he] | |
| exact hV i (hc.1 i).2 (hd.1 i).2 hΞ± hΞ² hab | |
| Β· intro i j hij | |
| let A : (Fin n β β) ββ[β] β := (LinearMap.proj j : (Fin n β β) ββ[β] β) - LinearMap.proj i | |
| let B : (Fin n β β) ββ[β] β := (LinearMap.proj i : (Fin n β β) ββ[β] β) - LinearMap.proj j | |
| have ha : A c < 0 := sub_neg.mpr (hc.2 hij).1 | |
| have hb : A d < 0 := sub_neg.mpr (hd.2 hij).1 | |
| have ha' : B c < L j-L i := by change c i-c j < _; linarith [(hc.2 hij).2] | |
| have hb' : B d < L j-L i := by change d i-d j < _; linarith [(hd.2 hij).2] | |
| have hh := (convex_halfSpace_lt A.isLinear 0) ha hb hΞ± hΞ² hab | |
| have hh' := (convex_halfSpace_lt B.isLinear (L j-L i)) ha' hb' hΞ± hΞ² hab | |
| change (Ξ± β’ c+Ξ² β’ d) j-(Ξ± β’ c+Ξ² β’ d) i < 0 at hh | |
| change (Ξ± β’ c+Ξ² β’ d) i-(Ξ± β’ c+Ξ² β’ d) j < L j-L i at hh' | |
| exact β¨sub_neg.mp hh,by linarithβ© | |
| variable {P : Type*} [NormedAddCommGroup P] [NormedSpace β P] [FiniteDimensional β P] | |
| theorem exists_smooth_nested_intervals {Y : Set P} (hY : IsClosed Y) | |
| (L : Fin n β β) (hL : StrictMono L) (V : P β Fin n β Set β) | |
| (hopen : β i t, IsOpen {y | t β V y i}) | |
| (hconv : β y β Y, β i, Convex β (V y i)) | |
| (hroom : β y β Y, β a b : Fin n β β, Antitone a β§ Monotone b β§ | |
| (β i, L i < b i-a i) β§ β i, Ioo (a i) (b i) β V y i) | |
| (hpos : β i, 0 < L i) : | |
| β c : P β (Fin n β β), ContDiff β β c β§ | |
| β y β Y, (β i, Icc (c y i) (c y i+L i) β V y i) β§ | |
| StrictNestedStarts L (c y) := by | |
| have hsopen (c : Fin n β β) : IsOpen {y | c β IntervalPlacements L (V y)} := by | |
| change IsOpen {y | (β i, c i β V y i β§ c i+L i β V y i) β§ StrictNestedStarts L c} | |
| by_cases hn : StrictNestedStarts L c | |
| Β· simp only [hn,and_true,ofPred_forall,ofPred_and] | |
| exact isOpen_iInter_of_finite (fun i => (hopen i (c i)).inter (hopen i (c i+L i))) | |
| Β· simp only [hn,and_false,ofPred_false,isOpen_empty] | |
| have hsne (y : P) (hy : y β Y) : (IntervalPlacements L (V y)).Nonempty := by | |
| obtain β¨a,b,ha,hb,hfit,hsubβ© := hroom y hy | |
| obtain β¨c,hc,hnβ© := exists_strict_nested_intervals a b L ha hb hL hfit | |
| refine β¨c,?_,hnβ© | |
| intro i | |
| have hLi := hpos i | |
| exact β¨hsub i β¨(hc i).1,by linarith [(hc i).2]β©, | |
| hsub i β¨by linarith [(hc i).1],(hc i).2β©β© | |
| obtain β¨c,hc,hmemβ© := exists_smooth_convex_selection hY | |
| (fun y => IntervalPlacements L (V y)) hsopen | |
| (fun y hy => intervalPlacements_convex L (V y) (hconv y hy)) hsne | |
| refine β¨c,hc,?_β© | |
| intro y hy | |
| refine β¨?_,(hmem y hy).2β© | |
| intro i | |
| exact (hconv y hy i).ordConnected.out ((hmem y hy).1 i).1 ((hmem y hy).1 i).2 | |
| end | |
| section | |
| open scoped ContDiff Topology | |
| open Set Function | |
| variable {P : Type*} [TopologicalSpace P] | |
| def RoundedMargins {n : β} (C : P β Fin n β β) (L w : Fin n β β) | |
| (V : P β Fin n β Set β) (q s : β) (y : P) : Prop := | |
| 0 < s β§ | |
| (β i, C y i-s*L i/2 β V y i β§ C y i+s*L i/2 β V y i) β§ | |
| β β¦i jβ¦, i < j β | |
| C y j-q*s*L j/2 < C y i-s*L i/2 β§ | |
| C y i+s*L i/2 < C y j+q*s*L j/2 β§ w i < q*w j | |
| theorem roundedMargins_open {n : β} (C : P β Fin n β β) (hC : Continuous C) | |
| (L w : Fin n β β) (V : P β Fin n β Set β) | |
| (hV : β i, IsOpen {p : P Γ β | p.2 β V p.1 i}) : | |
| IsOpen {p : Plane Γ P | RoundedMargins C L w V p.1.1 p.1.2 p.2} := by | |
| have hlo (i : Fin n) : IsOpen {p : Plane Γ P | C p.2 i-p.1.2*L i/2 β V p.2 i} := | |
| (hV i).preimage (continuous_snd.prodMk | |
| (((continuous_apply i).comp (hC.comp continuous_snd)).sub | |
| ((continuous_fst.snd.mul continuous_const).div_const 2))) | |
| have hhi (i : Fin n) : IsOpen {p : Plane Γ P | C p.2 i+p.1.2*L i/2 β V p.2 i} := | |
| (hV i).preimage (continuous_snd.prodMk | |
| (((continuous_apply i).comp (hC.comp continuous_snd)).add | |
| ((continuous_fst.snd.mul continuous_const).div_const 2))) | |
| have hpair (i j : Fin n) : IsOpen {p : Plane Γ P | i < j β | |
| C p.2 j-p.1.1*p.1.2*L j/2 < C p.2 i-p.1.2*L i/2 β§ | |
| C p.2 i+p.1.2*L i/2 < C p.2 j+p.1.1*p.1.2*L j/2 β§ w i < p.1.1*w j} := by | |
| by_cases hij : i < j | |
| Β· simp only [hij,true_implies,ofPred_and] | |
| exact (isOpen_lt (by fun_prop) (by fun_prop)).inter | |
| ((isOpen_lt (by fun_prop) (by fun_prop)).inter (isOpen_lt (by fun_prop) (by fun_prop))) | |
| Β· simp only [hij,false_implies,ofPred_true,isOpen_univ] | |
| change IsOpen {p : Plane Γ P | 0 < p.1.2 β§ | |
| (β i, C p.2 i-p.1.2*L i/2 β V p.2 i β§ C p.2 i+p.1.2*L i/2 β V p.2 i) β§ | |
| β i j, i < j β _} | |
| simp only [ofPred_and,ofPred_forall] | |
| exact (isOpen_lt continuous_const continuous_fst.snd).inter | |
| ((isOpen_iInter_of_finite (fun i => (hlo i).inter (hhi i))).inter | |
| (isOpen_iInter_of_finite (fun i => isOpen_iInter_of_finite (fun j => by | |
| simpa only [ofPred_forall,ofPred_and] using hpair i j)))) | |
| theorem exists_exact_area_rounded_margins {n : β} {Y : Set P} (hY : IsCompact Y) | |
| (c : P β Fin n β β) (hc : Continuous c) (L w : Fin n β β) | |
| (hw : StrictMono w) (V : P β Fin n β Set β) | |
| (hV : β i, IsOpen {p : P Γ β | p.2 β V p.1 i}) | |
| (hplace : β y β Y, (β i, c y i β V y i β§ c y i+L i β V y i) β§ | |
| StrictNestedStarts L (c y)) : | |
| β q k : β, 0 < q β§ q < 1 β§ 0 < k β§ | |
| Icc (-q) q ΓΛ’ Icc (-q) q β squeezedDisk k β§ 0 < squeezedArea k β§ | |
| β y β Y, RoundedMargins (fun y i => c y i+L i/2) L w V q (4/squeezedArea k) y := by | |
| let C : P β Fin n β β := fun y i => c y i+L i/2 | |
| have hC : Continuous C := by | |
| apply continuous_pi | |
| intro i | |
| exact ((continuous_apply i).comp hc).add continuous_const | |
| apply exists_rounded_square_with_control hY continuous_id | |
| (roundedMargins_open C hC L w V hV) | |
| intro y hy | |
| change RoundedMargins C L w V 1 1 y | |
| refine β¨by norm_num,?_,?_β© | |
| Β· intro i | |
| simpa only [C,one_mul,add_sub_cancel_right,add_assoc,add_halves] using (hplace y hy).1 i | |
| Β· intro i j hij | |
| dsimp [C] | |
| simp only [one_mul,add_sub_cancel_right,add_assoc,add_halves] | |
| exact β¨((hplace y hy).2 hij).1,((hplace y hy).2 hij).2,hw hijβ© | |
| end | |
| section | |
| open scoped ContDiff Topology BigOperators | |
| open Set Function | |
| theorem exists_thin_rectangle_placement {m : β} (h : Fin m β β) | |
| (hh : β i, 0 < h i) (hmono : StrictMono h) {Ξ΄ : β} (hΞ΄ : 0 < Ξ΄) : | |
| β (L w c : Fin m β β), (β i, 0 < L i) β§ (β i, 0 < w i β§ w i < 1) β§ | |
| StrictMono w β§ (β i, L i*w i = h i) β§ StrictNestedStarts L c β§ | |
| β i, c i β Ioo 0 (h i+Ξ΄/2) β§ c i+L i β Ioo 0 (h i+Ξ΄/2) := by | |
| let B : β := 1+β i, h i | |
| have hB : 1 β€ B := by | |
| have hs : 0 β€ β i, h i := Finset.sum_nonneg (fun i _ => (hh i).le) | |
| dsimp [B]; linarith | |
| have hiB (i : Fin m) : h i < B := by | |
| have hi := Finset.single_le_sum (s := Finset.univ) (fun j _ => (hh j).le) (Finset.mem_univ i) | |
| dsimp [B]; linarith | |
| let Ξ΅ := min (Ξ΄/8) (1/4) | |
| have hΞ΅ : 0 < Ξ΅ := lt_min (by positivity) (by norm_num) | |
| have hΡδ : Ρ †δ/8 := min_le_left _ _ | |
| have hΞ΅1 : Ξ΅ β€ 1/4 := min_le_right _ _ | |
| let Ξ² := Ξ΅/(2*B) | |
| have hd : 0 < 2*B := by linarith | |
| have hΞ² : 0 < Ξ² := div_pos hΞ΅ hd | |
| have hΞ²1 : Ξ² < 1 := by apply (div_lt_one hd).mpr; linarith | |
| have hB0 : B β 0 := ne_of_gt (by linarith) | |
| have hΞ²B : Ξ²*B = Ξ΅/2 := by dsimp [Ξ²]; field_simp [hB0] | |
| have hsmall (i : Fin m) : Ξ²*h i < Ξ΅ := by | |
| have he := mul_lt_mul_of_pos_left (hiB i) hΞ² | |
| rw [hΞ²B] at he | |
| linarith | |
| let L i := h i+Ξ΅ | |
| let w i := h i/(h i+Ξ΅) | |
| let c i := Ξ΅-Ξ²*h i | |
| have hL i : 0 < L i := add_pos (hh i) hΞ΅ | |
| have hw i : 0 < w i β§ w i < 1 := | |
| β¨div_pos (hh i) (hL i),(div_lt_one (hL i)).mpr (by dsimp [L]; linarith)β© | |
| refine β¨L,w,c,hL,hw,?_,?_,?_,?_β© | |
| Β· intro i j hij | |
| apply (div_lt_div_iffβ (hL i) (hL j)).mpr | |
| dsimp [L] | |
| have he := mul_lt_mul_of_pos_right (hmono hij) hΞ΅ | |
| nlinarith | |
| Β· intro i | |
| dsimp [L,w] | |
| field_simp [show h i+Ξ΅ β 0 from (hL i).ne'] | |
| Β· intro i j hij | |
| dsimp [c,L] | |
| have he := hmono hij | |
| have he1 := mul_lt_mul_of_pos_left he hΞ² | |
| have he2 := mul_lt_mul_of_pos_left he (sub_pos.mpr hΞ²1) | |
| constructor <;> nlinarith | |
| Β· intro i | |
| have hc : 0 < c i := sub_pos.mpr (hsmall i) | |
| have hcΞ΅ : c i < Ξ΅ := by dsimp [c]; nlinarith [mul_pos hΞ² (hh i)] | |
| have hlower : 0 < c i+L i := add_pos hc (hL i) | |
| have hupper : c i+L i < h i+Ξ΄/2 := by dsimp [L]; linarith | |
| exact β¨β¨hc,(lt_add_of_pos_right (c i) (hL i)).trans hupperβ©,hlower,hupperβ© | |
| end | |
| section | |
| open scoped ContDiff Topology | |
| open Set Function MeasureTheory | |
| def box (c : Plane) (a b : β) : Set Plane := | |
| Icc (c.1-a) (c.1+a) ΓΛ’ Icc (c.2-b) (c.2+b) | |
| def openBox (c : Plane) (a b : β) : Set Plane := | |
| Ioo (c.1-a) (c.1+a) ΓΛ’ Ioo (c.2-b) (c.2+b) | |
| def roundedMap (k : β) (c : Plane) (a b : β) (x : Plane) : Plane := | |
| affineRectangle c a b (squareSqueeze k x) | |
| def roundedBox (k : β) (c : Plane) (a b : β) : Set Plane := | |
| roundedMap k c a b '' closedRoundDisk 1 | |
| theorem affineRectangle_injective {a b : β} (ha : a β 0) (hb : b β 0) (c : Plane) : | |
| Injective (affineRectangle c a b) := by | |
| intro x y he | |
| have h1 := congrArg Prod.fst he | |
| have h2 := congrArg Prod.snd he | |
| exact Prod.ext (mul_left_cancelβ ha (add_left_cancel h1)) | |
| (mul_left_cancelβ hb (add_left_cancel h2)) | |
| theorem affineRectangle_smooth (c : Plane) (a b : β) : | |
| ContDiff β β (affineRectangle c a b) := | |
| contDiff_const.add (diagonalScale a b).contDiff | |
| theorem roundedMap_smooth (k : β) (c : Plane) (a b : β) : | |
| ContDiff β β (roundedMap k c a b) := | |
| (affineRectangle_smooth c a b).comp (squareSqueeze_smooth k) | |
| theorem roundedMap_injective {k a b : β} (hk : k β 0) (ha : a β 0) (hb : b β 0) | |
| (c : Plane) : Injective (roundedMap k c a b) := | |
| (affineRectangle_injective ha hb c).comp (squareSqueeze_injective hk) | |
| theorem affineRectangle_fderiv (c : Plane) (a b : β) (x : Plane) : | |
| fderiv β (affineRectangle c a b) x = diagonalScale a b := by | |
| exact ((diagonalScale a b).hasFDerivAt.const_add c).fderiv | |
| theorem roundedMap_det {k a b : β} (c : Plane) (x : Plane) : | |
| (fderiv β (roundedMap k c a b) x).det = a*b*(fderiv β (squareSqueeze k) x).det := by | |
| change (fderiv β (affineRectangle c a b β squareSqueeze k) x).det = _ | |
| rw [fderiv_comp x ((affineRectangle_smooth c a b).differentiable (by simp) _) | |
| ((squareSqueeze_smooth k).differentiable (by simp) _),affineRectangle_fderiv, | |
| ContinuousLinearMap.det,ContinuousLinearMap.toLinearMap_comp,LinearMap.det_comp] | |
| change (diagonalScale a b).det * _ = _ | |
| rw [diagonalScale_det] | |
| theorem roundedMap_det_pos {k a b : β} (hk : 0 < k) (ha : 0 < a) (hb : 0 < b) | |
| (c : Plane) (x : Plane) : 0 < (fderiv β (roundedMap k c a b) x).det := by | |
| rw [roundedMap_det] | |
| exact mul_pos (mul_pos ha hb) (squareSqueeze_det_pos hk x) | |
| theorem roundedMap_mem_openBox {a b : β} (ha : 0 < a) (hb : 0 < b) | |
| (k : β) (c : Plane) (x : Plane) : roundedMap k c a b x β openBox c a b := by | |
| have hx1 := Real.neg_one_lt_tanh (k*x.1) | |
| have hx2 := Real.tanh_lt_one (k*x.1) | |
| have hy1 := Real.neg_one_lt_tanh (k*x.2) | |
| have hy2 := Real.tanh_lt_one (k*x.2) | |
| change (c.1-a < c.1+a*Real.tanh (k*x.1) β§ c.1+a*Real.tanh (k*x.1) < c.1+a) β§ | |
| (c.2-b < c.2+b*Real.tanh (k*x.2) β§ c.2+b*Real.tanh (k*x.2) < c.2+b) | |
| constructor <;> constructor <;> nlinarith | |
| theorem box_subset_roundedBox {q k a b : β} (ha : 0 < a) (hb : 0 < b) | |
| (hs : Icc (-q) q ΓΛ’ Icc (-q) q β squeezedDisk k) (c : Plane) : | |
| box c (q*a) (q*b) β roundedBox k c a b := by | |
| intro x hx | |
| let z : Plane := ((x.1-c.1)/a,(x.2-c.2)/b) | |
| have hz : z β Icc (-q) q ΓΛ’ Icc (-q) q := by | |
| change (-q β€ (x.1-c.1)/a β§ (x.1-c.1)/a β€ q) β§ | |
| (-q β€ (x.2-c.2)/b β§ (x.2-c.2)/b β€ q) | |
| constructor <;> constructor | |
| Β· apply (le_div_iffβ ha).mpr; linarith [hx.1.1] | |
| Β· apply (div_le_iffβ ha).mpr; linarith [hx.1.2] | |
| Β· apply (le_div_iffβ hb).mpr; linarith [hx.2.1] | |
| Β· apply (div_le_iffβ hb).mpr; linarith [hx.2.2] | |
| obtain β¨u,hu,heβ© := hs hz | |
| refine β¨u,hu,?_β© | |
| change affineRectangle c a b (squareSqueeze k u) = x | |
| rw [he] | |
| ext <;> simp [affineRectangle,z,mul_div_cancelβ _ ha.ne',mul_div_cancelβ _ hb.ne'] | |
| theorem openBox_subset_interior_roundedBox {q k a b : β} (ha : 0 < a) (hb : 0 < b) | |
| (hs : Icc (-q) q ΓΛ’ Icc (-q) q β squeezedDisk k) (c : Plane) : | |
| openBox c (q*a) (q*b) β interior (roundedBox k c a b) := by | |
| apply (isOpen_Ioo.prod isOpen_Ioo).subset_interior_iff.mpr | |
| exact (prod_mono Ioo_subset_Icc_self Ioo_subset_Icc_self).trans | |
| (box_subset_roundedBox ha hb hs c) | |
| theorem roundedBox_compact (k : β) (c : Plane) (a b : β) : | |
| IsCompact (roundedBox k c a b) := | |
| (closedRoundDisk_isCompact 1).image (roundedMap_smooth k c a b).continuous | |
| theorem roundedBox_volume {a b : β} (ha : 0 β€ a) (hb : 0 β€ b) | |
| (k : β) (c : Plane) : | |
| (volume (roundedBox k c a b)).toReal = a*b*squeezedArea k := by | |
| change (volume ((affineRectangle c a b β squareSqueeze k) '' closedRoundDisk 1)).toReal = _ | |
| rw [image_comp] | |
| exact affineRectangle_squeezedArea ha hb c k | |
| end | |
| section | |
| open scoped ContDiff Topology | |
| open Set Function Filter | |
| variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace β E] | |
| [NormedAddCommGroup F] [NormedSpace β F] | |
| variable [FiniteDimensional β E] | |
| theorem isInvertible_of_det_ne_zero {A : E βL[β] E} (hA : A.det β 0) : A.IsInvertible := | |
| β¨(A.toLinearMap.equivOfDetNeZero hA).toContinuousLinearEquiv,rflβ© | |
| theorem smooth_map_nhds_eq {f : E β E} {x : E} (hf : ContDiffAt β β f x) | |
| (hd : (fderiv β f x).det β 0) : map f (π x) = π (f x) := by | |
| obtain β¨e,heβ© := isInvertible_of_det_ne_zero hd | |
| have hs := hf.hasStrictFDerivAt (by simp) | |
| rw [β he] at hs | |
| exact hs.map_nhds_eq_of_equiv | |
| theorem image_interior_subset_of_det_ne_zero {f : E β E} {S : Set E} | |
| (hf : β x β interior S, ContDiffAt β β f x) | |
| (hd : β x β interior S, (fderiv β f x).det β 0) : | |
| f '' interior S β interior (f '' S) := by | |
| rintro _ β¨x,hx,rflβ© | |
| apply mem_interior_iff_mem_nhds.mpr | |
| have hh := Filter.image_mem_map (m := f) (mem_interior_iff_mem_nhds.mp hx) | |
| rwa [smooth_map_nhds_eq (hf x hx) (hd x hx)] at hh | |
| variable [FiniteDimensional β F] | |
| omit [FiniteDimensional β E] [FiniteDimensional β F] in | |
| theorem det_fderiv_conjugate (e : E βL[β] F) {f : F β F} {x : E} | |
| (hf : DifferentiableAt β f (e x)) : | |
| (fderiv β (fun x => e.symm (f (e x))) x).det = (fderiv β f (e x)).det := by | |
| have hd := e.symm.hasFDerivAt.comp x (hf.hasFDerivAt.comp x e.hasFDerivAt) | |
| change (fderiv β (e.symm β f β e) x).det = _ | |
| rw [hd.fderiv] | |
| change LinearMap.det (e.symm.toLinearEquiv.toLinearMap ββ | |
| (fderiv β f (e x)).toLinearMap ββ e.toLinearEquiv.toLinearMap) = _ | |
| exact LinearMap.det_conj _ e.symm.toLinearEquiv | |
| end | |
| open scoped ContDiff Topology | |
| open Set Function MeasureTheory | |
| def FitsPolar (c : Plane) (a b : β) : Prop := | |
| 0 < c.1-a β§ c.1+a < 1 β§ 0 < c.2-b β§ c.2+b < 1 | |
| theorem openBox_subset_polar {c : Plane} {a b : β} (hfit : FitsPolar c a b) : | |
| openBox c a b β areaPolarDomain := by | |
| intro x hx | |
| exact β¨hfit.1.trans hx.1.1,hfit.2.2.1.trans hx.2.1,hx.2.2.trans hfit.2.2.2β© | |
| def polarRoundedMap (k : β) (c : Plane) (a b : β) (x : Plane) : Plane := | |
| areaPolar (roundedMap k c a b x) | |
| def polarRoundedDisk (k : β) (c : Plane) (a b : β) : Set Plane := | |
| polarRoundedMap k c a b '' closedRoundDisk 1 | |
| theorem polarRoundedMap_injective {k a b : β} (hk : 0 < k) (ha : 0 < a) (hb : 0 < b) | |
| (c : Plane) (hfit : FitsPolar c a b) : Injective (polarRoundedMap k c a b) := by | |
| intro x y he | |
| apply roundedMap_injective hk.ne' ha.ne' hb.ne' c | |
| exact areaPolar_injOn (openBox_subset_polar hfit (roundedMap_mem_openBox ha hb k c x)) | |
| (openBox_subset_polar hfit (roundedMap_mem_openBox ha hb k c y)) he | |
| theorem polarRoundedMap_smooth {a b : β} (ha : 0 < a) (hb : 0 < b) | |
| (k : β) (c : Plane) (hfit : FitsPolar c a b) : ContDiff β β (polarRoundedMap k c a b) := by | |
| apply contDiff_iff_contDiffAt.mpr | |
| intro x | |
| exact (areaPolar_smoothAt (openBox_subset_polar hfit (roundedMap_mem_openBox ha hb k c x)).1).comp x | |
| (roundedMap_smooth k c a b).contDiffAt | |
| theorem polarRoundedMap_det {a b : β} (ha : 0 < a) (hb : 0 < b) | |
| (k : β) (c : Plane) (hfit : FitsPolar c a b) (x : Plane) : | |
| (fderiv β (polarRoundedMap k c a b) x).det = (fderiv β (roundedMap k c a b) x).det := by | |
| have hp := (openBox_subset_polar hfit (roundedMap_mem_openBox ha hb k c x)).1 | |
| change (fderiv β (areaPolar β roundedMap k c a b) x).det = _ | |
| rw [fderiv_comp x ((areaPolar_smoothAt hp).differentiableAt (by simp)) | |
| ((roundedMap_smooth k c a b).differentiable (by simp) _), | |
| ContinuousLinearMap.det,ContinuousLinearMap.toLinearMap_comp,LinearMap.det_comp] | |
| change (fderiv β areaPolar (roundedMap k c a b x)).det * _ = _ | |
| rw [areaPolar_det hp,one_mul] | |
| theorem polarRoundedMap_det_pos {k a b : β} (hk : 0 < k) (ha : 0 < a) (hb : 0 < b) | |
| (c : Plane) (hfit : FitsPolar c a b) (x : Plane) : | |
| 0 < (fderiv β (polarRoundedMap k c a b) x).det := by | |
| rw [polarRoundedMap_det ha hb k c hfit] | |
| exact roundedMap_det_pos hk ha hb c x | |
| theorem polarRoundedMap_capacity {a b : β} (ha : 0 < a) (hb : 0 < b) | |
| (k : β) (c : Plane) (hfit : FitsPolar c a b) (x : Plane) : | |
| Real.pi * radiusSq (polarRoundedMap k c a b x) = (roundedMap k c a b x).1 := | |
| areaPolar_capacity (openBox_subset_polar hfit (roundedMap_mem_openBox ha hb k c x)).1.le | |
| theorem polarRoundedDisk_volume {a b : β} (ha : 0 < a) (hb : 0 < b) | |
| (k : β) (c : Plane) (hfit : FitsPolar c a b) : | |
| (volume (polarRoundedDisk k c a b)).toReal = a*b*squeezedArea k := by | |
| change (volume ((areaPolar β roundedMap k c a b) '' closedRoundDisk 1)).toReal = _ | |
| rw [image_comp] | |
| change (volume (areaPolar '' roundedBox k c a b)).toReal = _ | |
| rw [areaPolar_image_volume (roundedBox_compact k c a b).measurableSet (by | |
| rintro z β¨x,_,rflβ© | |
| exact openBox_subset_polar hfit (roundedMap_mem_openBox ha hb k c x))] | |
| exact roundedBox_volume ha.le hb.le k c | |
| theorem polarRoundedDisk_nested {k a b a' b' : β} {c c' : Plane} | |
| (ha' : 0 < a') (hb' : 0 < b') (hfit' : FitsPolar c' a' b') | |
| (hnest : roundedBox k c a b β interior (roundedBox k c' a' b')) : | |
| polarRoundedDisk k c a b β interior (polarRoundedDisk k c' a' b') := by | |
| change (areaPolar β roundedMap k c a b) '' closedRoundDisk 1 β | |
| interior ((areaPolar β roundedMap k c' a' b') '' closedRoundDisk 1) | |
| rw [image_comp,image_comp] | |
| apply (image_mono hnest).trans | |
| apply image_interior_subset_of_det_ne_zero | |
| Β· intro x hx | |
| obtain β¨z,_,rflβ© := interior_subset hx | |
| exact areaPolar_smoothAt (openBox_subset_polar hfit' (roundedMap_mem_openBox ha' hb' k c' z)).1 | |
| Β· intro x hx | |
| obtain β¨z,_,rflβ© := interior_subset hx | |
| rw [areaPolar_det (openBox_subset_polar hfit' (roundedMap_mem_openBox ha' hb' k c' z)).1] | |
| norm_num | |
| variable {P : Type*} [NormedAddCommGroup P] [NormedSpace β P] | |
| theorem polarRoundedFamily_smoothOn {A : Set P} (_hA : IsOpen A) | |
| (C : P β Plane) (hC : ContDiff β β C) {a b : β} (ha : 0 < a) (hb : 0 < b) | |
| (k : β) (hfit : β y β A, FitsPolar (C y) a b) : | |
| ContDiffOn β β (fun p : P Γ Plane => polarRoundedMap k (C p.1) a b p.2) (A ΓΛ’ univ) := by | |
| intro p hp | |
| apply ContDiffAt.contDiffWithinAt | |
| have hg : ContDiff β β (fun p : P Γ Plane => roundedMap k (C p.1) a b p.2) := | |
| (hC.comp contDiff_fst).add | |
| ((diagonalScale a b).contDiff.comp ((squareSqueeze_smooth k).comp contDiff_snd)) | |
| exact (areaPolar_smoothAt | |
| (openBox_subset_polar (hfit p.1 hp.1) (roundedMap_mem_openBox ha hb k (C p.1) p.2)).1).comp p hg.contDiffAt | |
| end PackingSufficiencySupport.Hamiltonian | |
| end | |
| end OAI | |