File size: 4,120 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | import Mathlib
import OAI.Probability.BinarySweep.Processes.AssignmentWeight
namespace OAI
noncomputable section
open scoped BigOperators
namespace BinaryCoordinateSweeps
attribute [local instance] Classical.propDecidable
def localPathWeight {b h : β} {bits : Fin b β β} (H : PathFamily bits h)
(z : β) (j : Fin b) (y : GridOutside bits j) : β :=
assignmentWeight (lineLaw (bits j) z) (lineInput H j y) (lineOutput H j y)
lemma fallingCost_formula {m u : β} (hm : 0 < m) (hu : u β€ m) :
fallingCost m u = (u : β) * Real.log m - Real.log (m.descFactorial u : β) := by
have hmp : (m : β) β 0 := by exact_mod_cast hm.ne'
have hdf : (m.descFactorial u : β) β 0 := by exact_mod_cast (Nat.descFactorial_pos.mpr hu).ne'
rw [fallingCost, Real.log_div (pow_ne_zero _ hmp) hdf, Real.log_pow]
lemma assignmentWeight_eq_of_card_eq {X I J : Type*} [Fintype X] [Fintype I] [Fintype J]
(p : Equiv.Perm X β β) (A B : I βͺ X) (A' B' : J βͺ X) (f : I βͺ J)
(hA : β i, A' (f i) = A i) (hB : β i, B' (f i) = B i)
(hcard : Fintype.card I = Fintype.card J) : assignmentWeight p A' B' = assignmentWeight p A B := by
have hsur : Function.Surjective f := by
by_contra hn
have hc := Fintype.card_lt_of_injective_not_surjective f f.injective hn
omega
have he (Ο : Equiv.Perm X) : Assigns A' B' Ο β Assigns A B Ο := by
constructor
Β· intro hΟ i
simpa only [hA, hB] using hΟ (f i)
Β· intro hΟ j
obtain β¨i, rflβ© := hsur j
simpa only [hA, hB] using hΟ i
simp only [assignmentWeight, he]
lemma assignmentWeight_log_ratio_le {X I J : Type*} [Fintype X] [Fintype I] [Fintype J]
(hm : 0 < Fintype.card X) {p : Equiv.Perm X β β}
(hl : β Ο, (1 / 2 : β) * (Fintype.card (Equiv.Perm X) : β)β»ΒΉ β€ p Ο)
(hu : β Ο, p Ο β€ 2 * (Fintype.card (Equiv.Perm X) : β)β»ΒΉ)
(A B : I βͺ X) (A' B' : J βͺ X) (f : I βͺ J)
(hA : β i, A' (f i) = A i) (hB : β i, B' (f i) = B i) :
Real.log (assignmentWeight p A' B' / assignmentWeight p A B) β€
fallingCost (Fintype.card X) (Fintype.card J) - fallingCost (Fintype.card X) (Fintype.card I) -
((Fintype.card J : β) - Fintype.card I) * Real.log (Fintype.card X) +
Real.log 4 * ((Fintype.card J : β) - Fintype.card I) := by
have hI := Fintype.card_le_of_injective A A.injective
have hJ := Fintype.card_le_of_injective A' A'.injective
have hi : (0 : β) < Nat.descFactorial (Fintype.card X) (Fintype.card I) := by
exact_mod_cast Nat.descFactorial_pos.mpr hI
have hj : (0 : β) < Nat.descFactorial (Fintype.card X) (Fintype.card J) := by
exact_mod_cast Nat.descFactorial_pos.mpr hJ
have wi : 0 < assignmentWeight p A B := lt_of_lt_of_le (by positivity) (assignmentWeight_comparison hl hu A B).1
have wj : 0 < assignmentWeight p A' B' := lt_of_lt_of_le (by positivity) (assignmentWeight_comparison hl hu A' B').1
by_cases hc : Fintype.card I = Fintype.card J
Β· rw [assignmentWeight_eq_of_card_eq p A B A' B' f hA hB hc, div_self wi.ne', Real.log_one, hc]
simp
Β· have hIJ := Fintype.card_le_of_injective f f.injective
have hgap : (1 : β) β€ (Fintype.card J : β) - Fintype.card I := by
have hh : Fintype.card I + 1 β€ Fintype.card J := by omega
exact_mod_cast (show (1 : β€) β€ (Fintype.card J : β€) - Fintype.card I from by omega)
have hl4 : 0 β€ Real.log 4 := Real.log_nonneg (by norm_num)
calc
_ β€ Real.log (4 * (Nat.descFactorial (Fintype.card X) (Fintype.card I) : β) /
(Nat.descFactorial (Fintype.card X) (Fintype.card J) : β)) :=
Real.log_le_log (div_pos wj wi) (assignmentWeight_ratio_le hl hu A B A' B')
_ = Real.log 4 + Real.log (Nat.descFactorial (Fintype.card X) (Fintype.card I) : β) -
Real.log (Nat.descFactorial (Fintype.card X) (Fintype.card J) : β) := by
rw [Real.log_div (by positivity) hj.ne', Real.log_mul (by norm_num) hi.ne']
_ β€ _ := by
rw [fallingCost_formula hm hI, fallingCost_formula hm hJ]
nlinarith
end BinaryCoordinateSweeps
end
end OAI
|