introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.71 kB
import OAI.Combinatorics.EditApproximation.Geometry.ChildIncrements
import OAI.Combinatorics.EditApproximation.Probability.ExactSampling
import OAI.Combinatorics.EditApproximation.Probability.FiniteSampling
namespace OAI
/-!
# Exact sampled action costs
The sampler's finite law translates the computed rational vector into its
expected linear cost. Correlation with a group-estimation failure is not
excluded or needed in this identity.
-/
namespace EditApproximation
open Finset
theorem uniformMean_mono {Ξ© : Type*} [Fintype Ξ©] (f g : Ξ© β†’ ℝ)
(h : βˆ€ Ο‰, f Ο‰ ≀ g Ο‰) : uniformMean f ≀ uniformMean g := by
exact div_le_div_of_nonneg_right (sum_le_sum fun Ο‰ _ => h Ο‰) (Nat.cast_nonneg _)
theorem uniformMean_add {Ξ© : Type*} [Fintype Ξ©] (f g : Ξ© β†’ ℝ) :
uniformMean (fun Ο‰ => f Ο‰ + g Ο‰) = uniformMean f + uniformMean g := by
simp only [uniformMean, sum_add_distrib, add_div]
theorem uniformMean_mul {Ξ© : Type*} [Fintype Ξ©] (a : ℝ) (f : Ξ© β†’ ℝ) :
uniformMean (fun Ο‰ => a * f Ο‰) = a * uniformMean f := by
simp only [uniformMean, ← mul_sum, mul_div_assoc]
theorem uniformMean_const {Ξ© : Type*} [Fintype Ξ©] [Nonempty Ξ©] (a : ℝ) :
uniformMean (fun _ : Ξ© => a) = a := by
simp only [uniformMean, sum_const, card_univ, nsmul_eq_mul]
have hcard : (Fintype.card Ξ© : ℝ) β‰  0 := by exact_mod_cast Fintype.card_ne_zero
exact mul_div_cancel_leftβ‚€ a hcard
theorem uniformMean_sum {Ξ© ΞΉ : Type*} [Fintype Ξ©] (indices : Finset ΞΉ) (f : ΞΉ β†’ Ξ© β†’ ℝ) :
uniformMean (fun Ο‰ => βˆ‘ i ∈ indices, f i Ο‰) = βˆ‘ i ∈ indices, uniformMean (f i) := by
unfold uniformMean
rw [sum_comm, sum_div]
theorem finiteRationalOptimizer_sampler_linear_mean {ΞΉ : Type*}
(coordinates : Finset ΞΉ) (vertices : List (ΞΉ β†’ β„š)) (linear : ΞΉ β†’ β„š)
(G K : β„•) (hK : 0 < K) (payoff : ΞΉ β†’ ℝ) :
let : NeZero (optimizerTriangularMass K) := ⟨Nat.ne_of_gt (optimizerTriangularMass_positive K hK)⟩
uniformMean (fun integer : Fin (optimizerTriangularMass K) =>
βˆ‘ i ∈ coordinates, payoff i *
(finiteOptimizerSelection coordinates vertices linear G (triangularChoice K integer).val i : ℝ)) =
βˆ‘ i ∈ coordinates, payoff i * (finiteRationalOptimizer coordinates vertices linear G K i : ℝ) := by
let : NeZero (optimizerTriangularMass K) := ⟨Nat.ne_of_gt (optimizerTriangularMass_positive K hK)⟩
dsimp only
unfold uniformMean
rw [Fintype.card_fin, sum_comm, sum_div]
apply sum_congr rfl
intro i _
rw [← mul_sum, mul_div_assoc]
congr 1
have hmean := finiteRationalOptimizer_sampler_mean coordinates vertices linear G K hK i
exact_mod_cast hmean
theorem actionVector_child_cost_identity {Ξ² Οƒ : Type*} [Fintype Ξ²] [Nonempty Ξ²]
[DecidableEq Ξ²] [DecidableEq Οƒ] (band : Finset (Ξ² β†’ Οƒ))
(mass : Ξ² β†’ β„š) (hpos : βˆ€ child, 0 < mass child)
(table : β„• β†’ Ξ² Γ— Οƒ β†’ β„š) (ΞΊ : β„š) (t : β„•)
{action : Ξ² β†’ Οƒ} (ha : action ∈ band) :
-((βˆ‘ child, mass child : β„š) : ℝ) *
(βˆ‘ i ∈ bandCoordinates band,
((childGain mass table t i : ℝ) + (1 - (ΞΊ : ℝ)) * childDecrement mass table t i) *
(actionVector mass action i : ℝ)) =
(βˆ‘ child, (table (t + 1) (child, action child) : ℝ)) +
(ΞΊ : ℝ) * ((βˆ‘ child, (table t (child, action child) : ℝ)) -
βˆ‘ child, (table (t + 1) (child, action child) : ℝ)) := by
have hidentity := actionVector_cost_identity band mass hpos
(fun i => (ΞΊ : ℝ) * table t i + (1 - (ΞΊ : ℝ)) * table (t + 1) i) ha
have hgain i : (childGain mass table t i : ℝ) + (1 - (ΞΊ : ℝ)) * childDecrement mass table t i =
-((ΞΊ : ℝ) * table t i + (1 - (ΞΊ : ℝ)) * table (t + 1) i) / (mass i.1 : ℝ) := by
have hid := childGain_decrement_identity mass table ΞΊ t i
exact_mod_cast hid
simp_rw [hgain]
rw [hidentity]
simp only [sum_add_distrib, ← mul_sum]
ring
theorem actionVector_comparator_cost_identity {Ξ² Οƒ : Type*} [Fintype Ξ²] [Nonempty Ξ²]
[DecidableEq Ξ²] [DecidableEq Οƒ] (band : Finset (Ξ² β†’ Οƒ))
(mass : Ξ² β†’ β„š) (hpos : βˆ€ child, 0 < mass child)
(table : β„• β†’ Ξ² Γ— Οƒ β†’ β„š) (t : β„•)
{action : Ξ² β†’ Οƒ} (ha : action ∈ band) :
-((βˆ‘ child, mass child : β„š) : ℝ) *
(βˆ‘ i ∈ bandCoordinates band,
((childGain mass table t i : ℝ) + childDecrement mass table t i) *
(actionVector mass action i : ℝ)) =
βˆ‘ child, (table (t + 1) (child, action child) : ℝ) := by
simpa only [Rat.cast_zero, sub_zero, one_mul, zero_mul, add_zero] using
actionVector_child_cost_identity band mass hpos table 0 t ha
end EditApproximation
end OAI