cfahlgren1's picture
download
raw
22.6 kB
import Mathlib
import OAI.Geometry.BallPacking.Moments.ExponentialMoment
namespace OAI
noncomputable section
namespace PackingSufficiencySupport.FiniteMoment.Radial
open scoped BigOperators Topology ContDiff
open Set Filter Function
variable {ι : Type*} [Fintype ι]
def slopeNumerator (k : ι → ℕ × ℕ) (a : ι → ℝ) (r : Plane) : Plane :=
(∑ i,((k i).1:ℝ)*a i*r.1^((k i).1-1)*r.2^(k i).2,
∑ i,((k i).2:ℝ)*a i*r.1^(k i).1*r.2^((k i).2-1))
def slope (k : ι → ℕ × ℕ) (a : ι → ℝ) (r : Plane) : Plane :=
(polynomial k a r)⁻¹ • slopeNumerator k a r
theorem slopeNumerator_contDiff (k : ι → ℕ × ℕ) :
ContDiff ℝ ∞ (fun q : (ι → ℝ) × Plane => slopeNumerator k q.1 q.2) := by
apply ContDiff.prodMk <;> apply ContDiff.sum <;> intro i _ <;> fun_prop
theorem slope_contDiffAt {k : ι → ℕ × ℕ} {a : ι → ℝ} {r : Plane}
(hP : polynomial k a r≠0) :
ContDiffAt ℝ ∞ (fun q : (ι → ℝ) × Plane => slope k q.1 q.2) (a,r) :=
((polynomial_contDiff k).contDiffAt.inv hP).smul (slopeNumerator_contDiff k).contDiffAt
theorem slopeNumerator_fst_pos {k : ι → ℕ × ℕ} {a : ι → ℝ} (ha : ∀ i,0<a i)
(he : ∃ i,k i=(1,0)) {r : Plane} (hr : 0≤r.1 ∧ 0≤r.2) :
0<(slopeNumerator k a r).1 := by
classical
apply Finset.sum_pos'
· intro i _
exact mul_nonneg (mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (ha i).le)
(pow_nonneg hr.1 _)) (pow_nonneg hr.2 _)
· obtain ⟨i,hi⟩ := he
exact ⟨i,Finset.mem_univ i,by simpa [hi] using ha i⟩
theorem slopeNumerator_snd_pos {k : ι → ℕ × ℕ} {a : ι → ℝ} (ha : ∀ i,0<a i)
(he : ∃ i,k i=(0,1)) {r : Plane} (hr : 0≤r.1 ∧ 0≤r.2) :
0<(slopeNumerator k a r).2 := by
classical
apply Finset.sum_pos'
· intro i _
exact mul_nonneg (mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (ha i).le)
(pow_nonneg hr.1 _)) (pow_nonneg hr.2 _)
· obtain ⟨i,hi⟩ := he
exact ⟨i,Finset.mem_univ i,by simpa [hi] using ha i⟩
theorem slope_pos {k : ι → ℕ × ℕ} {a : ι → ℝ} (ha : ∀ i,0<a i)
(hzero : ∃ i,k i=(0,0)) (he0 : ∃ i,k i=(1,0)) (he1 : ∃ i,k i=(0,1))
{r : Plane} (hr : 0≤r.1 ∧ 0≤r.2) : 0<(slope k a r).1 ∧ 0<(slope k a r).2 := by
have hP := inv_pos.mpr (polynomial_pos ha hzero hr)
exact ⟨mul_pos hP (slopeNumerator_fst_pos ha he0 hr),
mul_pos hP (slopeNumerator_snd_pos ha he1 hr)⟩
theorem moment_eq_radius_slope (k : ι → ℕ × ℕ) (a : ι → ℝ) (r : Plane) :
moment k a r=(r.1*(slope k a r).1,r.2*(slope k a r).2) := by
have h0 : (numerator k a r).1=r.1*(slopeNumerator k a r).1 := by
change (∑ i,((k i).1:ℝ)*a i*monomial (k i) r)=
r.1*(∑ i,((k i).1:ℝ)*a i*r.1^((k i).1-1)*r.2^(k i).2)
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
unfold monomial
calc
_=a i*r.2^(k i).2*(((k i).1:ℝ)*r.1^(k i).1) := by ring
_=_ := by rw [← nat_mul_power]; ring
have h1 : (numerator k a r).2=r.2*(slopeNumerator k a r).2 := by
change (∑ i,((k i).2:ℝ)*a i*monomial (k i) r)=
r.2*(∑ i,((k i).2:ℝ)*a i*r.1^(k i).1*r.2^((k i).2-1))
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
unfold monomial
calc
_=a i*r.1^(k i).1*(((k i).2:ℝ)*r.2^(k i).2) := by ring
_=_ := by rw [← nat_mul_power]; ring
apply Prod.ext
· change (polynomial k a r)⁻¹*(numerator k a r).1=
r.1*((polynomial k a r)⁻¹*(slopeNumerator k a r).1)
rw [h0]
ring
· change (polynomial k a r)⁻¹*(numerator k a r).2=
r.2*((polynomial k a r)⁻¹*(slopeNumerator k a r).2)
rw [h1]
ring
theorem moment_eq_of_centered {k : ι → ℕ × ℕ} {a : ι → ℝ} {p r : Plane}
(hP : polynomial k a r≠0) (hz : centered k a p r=0) : moment k a r=p := by
rw [centered_eq,sub_eq_zero] at hz
rw [moment,hz,smul_smul,inv_mul_cancel₀ hP,one_smul]
end PackingSufficiencySupport.FiniteMoment.Radial
namespace PackingSufficiencySupport.FiniteMoment
open scoped BigOperators Topology ContDiff
open Set Function
abbrev MomentPlane := EuclideanSpace ℝ (Fin 2)
def planeVector (x y : ℝ) : MomentPlane := WithLp.toLp 2 ![x,y]
def trapezoidCorners (A B : ℝ) : Fin 4 → MomentPlane :=
![planeVector 0 0,planeVector A 0,planeVector A (B-A),planeVector 0 B]
def openTrapezoid (A B : ℝ) : Set MomentPlane :=
{p | 0<p 0 ∧ p 0<A ∧ 0<p 1 ∧ p 0+p 1<B}
theorem openTrapezoid_isOpen (A B : ℝ) : IsOpen (openTrapezoid A B) := by
have hc (j : Fin 2) : Continuous (fun p : MomentPlane => p j) := by fun_prop
exact ((isOpen_lt continuous_const (hc 0)).inter
((isOpen_lt (hc 0) continuous_const).inter
((isOpen_lt continuous_const (hc 1)).inter
(isOpen_lt ((hc 0).add (hc 1)) continuous_const))))
theorem trapezoid_mem_convexHull {A B : ℝ} {p : MomentPlane} (hp : p∈openTrapezoid A B) :
p∈convexHull ℝ (range (trapezoidCorners A B)) := by
have hA : 0<A := hp.1.trans hp.2.1
have hB : 0<B-p 0 := by linarith [hp.2.2.1,hp.2.2.2]
let l := p 0/A
let t := p 1/(B-p 0)
have hl0 : 0<l := div_pos hp.1 hA
have hl1 : l<1 := (div_lt_one hA).mpr hp.2.1
have ht0 : 0<t := div_pos hp.2.2.1 hB
have ht1 : t<1 := (div_lt_one hB).mpr (by linarith [hp.2.2.2])
let c : Fin 4 → ℝ := ![(1-l)*(1-t),l*(1-t),l*t,(1-l)*t]
apply mem_convexHull_of_exists_fintype c (trapezoidCorners A B)
· intro i
fin_cases i <;> dsimp [c] <;> positivity
· simp only [c,Fin.sum_univ_succ]
dsimp
ring
· intro i
exact mem_range_self i
· ext j
fin_cases j <;>
simp [c,trapezoidCorners,planeVector,Fin.sum_univ_succ,l,t] <;>
field_simp <;> ring
theorem trapezoid_interior {ι : Type*} {w : ι → MomentPlane} {A B : ℝ}
(hw : range (trapezoidCorners A B)⊆range w) {p : MomentPlane}
(hp : p∈openTrapezoid A B) : p∈interior (convexHull ℝ (range w)) := by
have hsub : openTrapezoid A B⊆convexHull ℝ (range w) := by
intro q hq
exact convexHull_mono hw (trapezoid_mem_convexHull hq)
exact interior_maximal hsub (openTrapezoid_isOpen A B) hp
def TrapezoidWeight (A B : ℕ) :=
{k : Fin (B+1) × Fin (B+1) // k.1.val≤A ∧ k.1.val+k.2.val≤B}
deriving Fintype, DecidableEq
def trapezoidWeight (A B : ℕ) (k : TrapezoidWeight A B) : MomentPlane :=
planeVector k.val.1.val k.val.2.val
instance trapezoidWeight_nonempty (A B : ℕ) : Nonempty (TrapezoidWeight A B) :=
⟨⟨(⟨0,Nat.zero_lt_succ B⟩,⟨0,Nat.zero_lt_succ B⟩),by simp⟩⟩
theorem trapezoidWeight_corners {A B : ℕ} (hAB : A≤B) :
range (trapezoidCorners A B)⊆range (trapezoidWeight A B) := by
rintro _ ⟨i,rfl⟩
fin_cases i
· refine ⟨⟨(⟨0,by omega⟩,⟨0,by omega⟩),by simp⟩,?_⟩
simp [trapezoidWeight,trapezoidCorners]
· refine ⟨⟨(⟨A,by omega⟩,⟨0,by omega⟩),by simp [hAB]⟩,?_⟩
simp [trapezoidWeight,trapezoidCorners]
· refine ⟨⟨(⟨A,by omega⟩,⟨B-A,by omega⟩),by simp [Nat.add_sub_of_le hAB]⟩,?_⟩
simp [trapezoidWeight,trapezoidCorners,Nat.cast_sub hAB]
· refine ⟨⟨(⟨0,by omega⟩,⟨B,by omega⟩),by simp⟩,?_⟩
simp [trapezoidWeight,trapezoidCorners]
theorem trapezoidWeight_surrounds {A B : ℕ} (hAB : A≤B) {p : MomentPlane}
(hp : p∈openTrapezoid A B) : Surrounds (trapezoidWeight A B) p :=
surrounds_of_interior (trapezoid_interior (trapezoidWeight_corners hAB) hp)
theorem trapezoidWeight_unique_moment {A B : ℕ} (hAB : A≤B)
{a : TrapezoidWeight A B → ℝ} (ha : ∀ k,0<a k) {p : MomentPlane}
(hp : p∈openTrapezoid A B) : ∃! x,moment (trapezoidWeight A B) a x=p :=
exists_unique_moment ha (trapezoidWeight_surrounds hAB hp)
end PackingSufficiencySupport.FiniteMoment
namespace PackingSufficiencySupport.FiniteMoment.Radial
open scoped BigOperators Topology ContDiff
open Set Filter Function
variable {ι : Type*} [Fintype ι]
def weight (k : ι → ℕ × ℕ) (i : ι) : MomentPlane := planeVector (k i).1 (k i).2
def logRadius (r : Plane) : MomentPlane := planeVector (Real.log r.1) (Real.log r.2)
def expRadius (x : MomentPlane) : Plane := (Real.exp (x 0),Real.exp (x 1))
theorem expRadius_logRadius {r : Plane} (hr : 0<r.1 ∧ 0<r.2) :
expRadius (logRadius r)=r := by
apply Prod.ext <;> simp [expRadius,logRadius,planeVector,Real.exp_log,hr.1,hr.2]
theorem monomial_expRadius (k : ℕ × ℕ) (x : MomentPlane) :
monomial k (expRadius x)=Real.exp (inner ℝ (planeVector k.1 k.2) x) := by
simp [monomial,expRadius,planeVector,PiLp.inner_apply,Fin.sum_univ_succ,
← Real.exp_nat_mul,← Real.exp_add,mul_comm]
theorem polynomial_expRadius (k : ι → ℕ × ℕ) (a : ι → ℝ) (x : MomentPlane) :
polynomial k a (expRadius x)=partition (weight k) a x := by
apply Finset.sum_congr rfl
intro i _
rw [monomial_expRadius]
rfl
theorem moment_expRadius (k : ι → ℕ × ℕ) (a : ι → ℝ) (x : MomentPlane) :
planeVector (moment k a (expRadius x)).1 (moment k a (expRadius x)).2=
FiniteMoment.moment (weight k) a x := by
rw [FiniteMoment.moment,← polynomial_expRadius]
ext j
fin_cases j <;>
simp [moment,numerator,gradient,weight,planeVector,monomial_expRadius,
mul_assoc,mul_comm,mul_left_comm]
theorem exists_positive_radial_solution [Nonempty ι] {k : ι → ℕ × ℕ} {a : ι → ℝ}
(ha : ∀ i,0<a i) {p : Plane} (hp : Surrounds (weight k) (planeVector p.1 p.2)) :
∃ r : Plane, (0<r.1 ∧ 0<r.2) ∧ moment k a r=p := by
let x := inverse (weight k) a (planeVector p.1 p.2)
refine ⟨expRadius x,⟨Real.exp_pos _,Real.exp_pos _⟩,?_⟩
have he := moment_expRadius k a x
rw [inverse_spec ha hp] at he
exact Prod.ext (congrArg (fun z : MomentPlane => z 0) he)
(congrArg (fun z : MomentPlane => z 1) he)
theorem positive_radial_unique [Nonempty ι] {k : ι → ℕ × ℕ} {a : ι → ℝ}
(ha : ∀ i,0<a i) {p : Plane} (hp : Surrounds (weight k) (planeVector p.1 p.2))
{r s : Plane} (hr : 0<r.1 ∧ 0<r.2) (hs : 0<s.1 ∧ 0<s.2)
(hrp : moment k a r=p) (hsp : moment k a s=p) : r=s := by
have hre : FiniteMoment.moment (weight k) a (logRadius r)=planeVector p.1 p.2 := by
rw [← moment_expRadius,expRadius_logRadius hr,hrp]
have hse : FiniteMoment.moment (weight k) a (logRadius s)=planeVector p.1 p.2 := by
rw [← moment_expRadius,expRadius_logRadius hs,hsp]
have he : logRadius r=logRadius s := (inverse_unique ha hp hre).trans
(inverse_unique ha hp hse).symm
have h := congrArg expRadius he
simpa only [expRadius_logRadius hr,expRadius_logRadius hs] using h
theorem moment_axis_fst (k : ι → ℕ × ℕ) (a : ι → ℝ) (t : ℝ) :
(moment k a (0,t)).1=0 := by
change (polynomial k a (0,t))⁻¹*(∑ i,((k i).1:ℝ)*a i*monomial (k i) (0,t))=0
have h : (∑ i,((k i).1:ℝ)*a i*monomial (k i) (0,t))=0 := by
apply Finset.sum_eq_zero
intro i _
rw [monomial_axis]
by_cases h : (k i).1=0 <;> simp [h]
rw [h,mul_zero]
theorem moment_origin (k : ι → ℕ × ℕ) (a : ι → ℝ) : moment k a (0,0)=(0,0) := by
apply Prod.ext
· exact moment_axis_fst k a 0
· change (polynomial k a (0,0))⁻¹*(∑ i,((k i).2:ℝ)*a i*monomial (k i) (0,0))=0
have h : (∑ i,((k i).2:ℝ)*a i*monomial (k i) (0,0))=0 := by
apply Finset.sum_eq_zero
intro i _
by_cases h : (k i).2=0
· simp [monomial,h]
· simp [monomial,zero_pow h]
rw [h,mul_zero]
theorem active_origin_pos {k : ι → ℕ × ℕ} {a : ι → ℝ} (ha : ∀ i,0<a i)
(he : ∃ i,k i=(0,1)) : 0<active k a 0 0 := by
classical
have heq : active k a 0 0=∑ i,if (k i).1=0 ∧ (k i).2=1 then a i else 0 := by
apply Finset.sum_congr rfl
intro i _
by_cases h : (k i).1=0
· simp only [ite_eq_left h,sub_zero]
have hmul : ((k i).2:ℝ)*a i*((k i).2:ℝ)*(0:ℝ)^((k i).2-1)=
((k i).2:ℝ)*a i*(((k i).2:ℝ)*(0:ℝ)^((k i).2-1)) := by ring
rw [hmul,zero_power_derivative]
by_cases h1 : (k i).2=1 <;> simp [h,h1]
· simp [h]
rw [heq]
apply Finset.sum_pos'
· intro i _
split_ifs
· exact (ha i).le
· rfl
· obtain ⟨i,hi⟩ := he
exact ⟨i,Finset.mem_univ i,by simpa [hi] using ha i⟩
theorem centeredDerivative_axis_isInvertible {k : ι → ℕ × ℕ} {a : ι → ℝ}
(ha : ∀ i,0<a i) (hzero : ∃ i,k i=(0,0))
(he0 : ∃ i,k i=(1,0)) (he1 : ∃ i,k i=(0,1)) {t : ℝ} (ht : 0≤t) :
(centeredDerivative k a (moment k a (0,t)) (0,t)).IsInvertible := by
let p := (moment k a (0,t)).2
have hm : moment k a (0,t)=(0,p) := Prod.ext (moment_axis_fst k a t) rfl
rw [hm]
have hz : (centered k a (0,p) (0,t)).2=0 := by
have h := centered_moment (polynomial_pos (r := (0,t)) ha hzero ⟨le_rfl,ht⟩).ne'
rw [hm] at h
exact congrArg Prod.snd h
have hA : 0<transverse k a t := transverse_pos ha he0 ht
have hB : 0<active k a p t := by
rcases eq_or_lt_of_le ht with ht0|htp
· have hp : p=0 := by simp [p,← ht0,moment_origin]
rw [← ht0,hp]
exact active_origin_pos ha he1
· exact active_pos ha hzero he1 htp hz
have hker : ∀ v,centeredDerivative k a (0,p) (0,t) v=0 → v=0 := by
intro v hv
have h0 := congrArg Prod.fst hv
rw [centeredDerivative_axis_fst] at h0
change transverse k a t*v.1=0 at h0
have hv0 : v.1=0 := (mul_eq_zero.mp h0).resolve_left hA.ne'
have heq : v=(0,v.2) := Prod.ext hv0 rfl
have h1 := congrArg Prod.snd hv
rw [heq,centeredDerivative_axis_snd] at h1
change active k a p t*v.2=0 at h1
exact Prod.ext hv0 ((mul_eq_zero.mp h1).resolve_left hB.ne')
have hi : Injective (centeredDerivative k a (0,p) (0,t)) := by
intro v u h
apply sub_eq_zero.mp
apply hker
rw [map_sub,h,sub_self]
let L := ContinuousLinearEquiv.ofBijective (centeredDerivative k a (0,p) (0,t))
(LinearMap.ker_eq_bot.mpr hi)
(LinearMap.range_eq_top.mpr (LinearMap.injective_iff_surjective.mp hi))
exact ⟨L,rfl⟩
theorem exists_smooth_axis_radial_solution {k : ι → ℕ × ℕ} {a : ι → ℝ}
(ha : ∀ i,0<a i) (hzero : ∃ i,k i=(0,0))
(he0 : ∃ i,k i=(1,0)) (he1 : ∃ i,k i=(0,1)) {t : ℝ} (ht : 0≤t) :
∃ f : ((ι → ℝ) × Plane) → Plane,
f (a,moment k a (0,t))=(0,t) ∧
ContDiffAt ℝ ∞ f (a,moment k a (0,t)) ∧
∀ᶠ q in 𝓝 (a,moment k a (0,t)),centered k q.1 q.2 (f q)=0 := by
let q := (a,moment k a (0,t))
let r : Plane := (0,t)
let F : ((ι → ℝ) × Plane) × Plane → Plane := fun s => centered k s.1.1 s.1.2 s.2
have hF : ContDiff ℝ ∞ F := centered_contDiff k
have hpartial : (fderiv ℝ F (q,r)).comp (ContinuousLinearMap.inr ℝ ((ι → ℝ) × Plane) Plane)=
centeredDerivative k a (moment k a (0,t)) r := by
have hc := ((hF.differentiable (by simp) (q,r)).hasFDerivAt.comp r
((hasFDerivAt_const q r).prodMk (hasFDerivAt_id r)))
exact hc.unique (centered_hasFDerivAt k a (moment k a (0,t)) r)
have hinv : (fderiv ℝ F (q,r) ∘L ContinuousLinearMap.inr ℝ ((ι → ℝ) × Plane) Plane).IsInvertible := by
rw [hpartial]
exact centeredDerivative_axis_isInvertible ha hzero he0 he1 ht
have hz : F (q,r)=0 := centered_moment (polynomial_pos (r := (0,t)) ha hzero ⟨le_rfl,ht⟩).ne'
refine ⟨hF.contDiffAt.implicitFunction (by simp) hinv,?_,
hF.contDiffAt.contDiffAt_implicitFunction (by simp) hinv,?_⟩
· exact hF.contDiffAt.implicitFunction_apply_self (by simp) hinv
· simpa only [hz] using hF.contDiffAt.eventually_apply_implicitFunction (by simp) hinv
end PackingSufficiencySupport.FiniteMoment.Radial
namespace PackingSufficiencySupport.FiniteMoment
open scoped BigOperators
open Function
variable {ι E : Type*} [Fintype ι]
[NormedAddCommGroup E] [InnerProductSpace ℝ E]
theorem exp_difference_strict {u v : ℝ} (h : u≠v) :
0<(Real.exp u-Real.exp v)*(u-v) := by
rcases lt_or_gt_of_ne h with hlt|hgt
· have h := exp_difference_pos hlt
nlinarith
· exact exp_difference_pos hgt
theorem gradient_zero_unique_of_separates {w : ι → E} {a : ι → ℝ}
(ha : ∀ i,0<a i) (hw : ∀ v : E,v≠0 → ∃ i,inner ℝ (w i) v≠0)
{x y : E} (hx : gradient w a x=0) (hy : gradient w a y=0) : x=y := by
classical
by_contra hxy
obtain ⟨j,hj⟩ := hw (x-y) (sub_ne_zero.mpr hxy)
have hjn : inner ℝ (w j) x≠inner ℝ (w j) y := by
rwa [inner_sub_right,sub_ne_zero] at hj
have hs : 0<∑ i,a i*((Real.exp (inner ℝ (w i) x)-Real.exp (inner ℝ (w i) y))*
(inner ℝ (w i) x-inner ℝ (w i) y)) := by
apply Finset.sum_pos'
· intro i _
exact mul_nonneg (ha i).le (exp_difference_nonneg _ _)
· exact ⟨j,Finset.mem_univ j,mul_pos (ha j) (exp_difference_strict hjn)⟩
have he : ∑ i,a i*((Real.exp (inner ℝ (w i) x)-Real.exp (inner ℝ (w i) y))*
(inner ℝ (w i) x-inner ℝ (w i) y))=
inner ℝ (gradient w a x-gradient w a y) (x-y) := by
simp only [gradient,inner_sub_left,sum_inner,real_inner_smul_left,inner_sub_right,←Finset.sum_sub_distrib]
apply Finset.sum_congr rfl
intro i _
ring
rw [he,hx,hy,sub_self,inner_zero_left] at hs
exact (lt_irrefl (0:ℝ)) hs
theorem moment_unique_of_separates [Nonempty ι] {w : ι → E} {a : ι → ℝ}
(ha : ∀ i,0<a i) {p : E}
(hw : ∀ v : E,v≠0 → ∃ i,inner ℝ (w i-p) v≠0)
{x y : E} (hx : moment w a x=p) (hy : moment w a y=p) : x=y :=
gradient_zero_unique_of_separates ha hw
((moment_eq_iff_gradient_center_zero ha p x).mp hx)
((moment_eq_iff_gradient_center_zero ha p y).mp hy)
end PackingSufficiencySupport.FiniteMoment
namespace PackingSufficiencySupport.FiniteMoment.Radial
open scoped BigOperators Topology ContDiff
open Set Filter Function
variable {ι : Type*} [Fintype ι]
abbrev Face (k : ι → ℕ × ℕ) := {i : ι // (k i).1=0}
def faceWeight (k : ι → ℕ × ℕ) (i : Face k) : ℝ := (k i.val).2
theorem sum_face (k : ι → ℕ × ℕ) (f : ι → ℝ) :
(∑ i, if (k i).1=0 then f i else 0)=∑ i : Face k,f i.val := by
classical
rw [← Finset.sum_filter]
exact Finset.sum_subtype _ (by simp) f
theorem polynomial_face_exp (k : ι → ℕ × ℕ) (a : ι → ℝ) (x : ℝ) :
polynomial k a (0,Real.exp x)=partition (faceWeight k) (fun i => a i.val) x := by
calc
_=∑ i,if (k i).1=0 then a i*Real.exp (((k i).2:ℝ)*x) else 0 := by
apply Finset.sum_congr rfl
intro i _
rw [monomial_axis]
by_cases h : (k i).1=0 <;> simp [h,Real.exp_nat_mul]
_=_ := by
rw [sum_face]
apply Finset.sum_congr rfl
intro i _
simp [faceWeight,mul_comm]
theorem numerator_face_exp_snd (k : ι → ℕ × ℕ) (a : ι → ℝ) (x : ℝ) :
(numerator k a (0,Real.exp x)).2=
gradient (faceWeight k) (fun i => a i.val) x := by
calc
_=∑ i,if (k i).1=0 then ((k i).2:ℝ)*a i*Real.exp (((k i).2:ℝ)*x) else 0 := by
apply Finset.sum_congr rfl
intro i _
rw [monomial_axis]
by_cases h : (k i).1=0 <;> simp [h,Real.exp_nat_mul]
_=_ := by
rw [sum_face]
apply Finset.sum_congr rfl
intro i _
simp [faceWeight,mul_comm,mul_left_comm,mul_assoc]
theorem moment_face_exp (k : ι → ℕ × ℕ) (a : ι → ℝ) (x : ℝ) :
moment k a (0,Real.exp x)=
(0,FiniteMoment.moment (faceWeight k) (fun i => a i.val) x) := by
apply Prod.ext
· exact moment_axis_fst k a _
· change (polynomial k a (0,Real.exp x))⁻¹*(numerator k a (0,Real.exp x)).2=_
rw [polynomial_face_exp,numerator_face_exp_snd]
rfl
omit [Fintype ι] in
theorem interval_surrounds {w : ι → ℝ} {B p : ℝ}
(h0 : ∃ i,w i=0) (hB : ∃ i,w i=B) (hp : 0<p ∧ p<B) : Surrounds w p := by
refine ⟨min p (B-p),lt_min hp.1 (sub_pos.mpr hp.2),?_⟩
intro v
rcases le_total 0 v with hv|hv
· obtain ⟨i,hi⟩ := hB
refine ⟨i,?_⟩
simp only [hi,Real.norm_eq_abs,abs_of_nonneg hv]
change min p (B-p)*v≤v*(B-p)
nlinarith [min_le_right p (B-p)]
· obtain ⟨i,hi⟩ := h0
refine ⟨i,?_⟩
simp only [hi,Real.norm_eq_abs,abs_of_nonpos hv,zero_sub]
change min p (B-p)*(-v)≤v*(-p)
nlinarith [min_le_left p (B-p)]
omit [Fintype ι] in
theorem interval_separates {w : ι → ℝ} {B : ℝ} (hB : B≠0)
(h0 : ∃ i,w i=0) (h1 : ∃ i,w i=B) (p : ℝ) {v : ℝ} (hv : v≠0) :
∃ i,inner ℝ (w i-p) v≠0 := by
by_cases hp : p=0
· obtain ⟨i,hi⟩ := h1
refine ⟨i,?_⟩
simpa [hi,hp] using mul_ne_zero hv hB
· obtain ⟨i,hi⟩ := h0
refine ⟨i,?_⟩
simpa [hi] using mul_ne_zero hv (neg_ne_zero.mpr hp)
theorem exists_axis_solution {k : ι → ℕ × ℕ} {a : ι → ℝ} (ha : ∀ i,0<a i)
(h0 : ∃ i,k i=(0,0)) {B : ℕ} (hB : ∃ i,k i=(0,B)) {p : ℝ}
(hp : 0<p ∧ p<B) : ∃ t : ℝ,0<t ∧ moment k a (0,t)=(0,p) := by
obtain ⟨i0,hi0⟩ := h0
obtain ⟨iB,hiB⟩ := hB
let : Nonempty (Face k) := ⟨⟨i0,by simp [hi0]⟩⟩
have hw0 : ∃ i : Face k,faceWeight k i=0 := ⟨⟨i0,by simp [hi0]⟩,by simp [faceWeight,hi0]⟩
have hwB : ∃ i : Face k,faceWeight k i=(B:ℝ) := ⟨⟨iB,by simp [hiB]⟩,by simp [faceWeight,hiB]⟩
obtain ⟨x,hx,_⟩ := exists_unique_moment (fun i : Face k => ha i.val)
(interval_surrounds hw0 hwB hp)
exact ⟨Real.exp x,Real.exp_pos _,by rw [moment_face_exp,hx]⟩
theorem positive_axis_unique {k : ι → ℕ × ℕ} {a : ι → ℝ} (ha : ∀ i,0<a i)
(h0 : ∃ i,k i=(0,0)) (h1 : ∃ i,k i=(0,1)) {t u p : ℝ} (ht : 0<t) (hu : 0<u)
(htp : moment k a (0,t)=(0,p)) (hup : moment k a (0,u)=(0,p)) : t=u := by
obtain ⟨i0,hi0⟩ := h0
obtain ⟨i1,hi1⟩ := h1
let : Nonempty (Face k) := ⟨⟨i0,by simp [hi0]⟩⟩
have hw0 : ∃ i : Face k,faceWeight k i=0 := ⟨⟨i0,by simp [hi0]⟩,by simp [faceWeight,hi0]⟩
have hw1 : ∃ i : Face k,faceWeight k i=(1:ℝ) := ⟨⟨i1,by simp [hi1]⟩,by simp [faceWeight,hi1]⟩
have hmt : FiniteMoment.moment (faceWeight k) (fun i => a i.val) (Real.log t)=p := by
have h := moment_face_exp k a (Real.log t)
rw [Real.exp_log ht,htp] at h
exact (congrArg Prod.snd h).symm
have hmu : FiniteMoment.moment (faceWeight k) (fun i => a i.val) (Real.log u)=p := by
have h := moment_face_exp k a (Real.log u)
rw [Real.exp_log hu,hup] at h
exact (congrArg Prod.snd h).symm
have he := moment_unique_of_separates (fun i : Face k => ha i.val)
(fun v hv => interval_separates one_ne_zero hw0 hw1 p hv) hmt hmu
have h := congrArg Real.exp he
simpa only [Real.exp_log ht,Real.exp_log hu] using h
end PackingSufficiencySupport.FiniteMoment.Radial
end
end OAI

Xet Storage Details

Size:
22.6 kB
·
Xet hash:
f6463d940d45e82609f2c12fc96e41ed240283cf5112d04d23ee43b6daf5fdba

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.