File size: 4,563 Bytes
e63eb7f | 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | import OAI.Combinatorics.EditApproximation.Probability.RejectionRuntimeLaw
import Mathlib.MeasureTheory.Integral.Pi
namespace OAI
/-! Independent finite arrays of exact rejection executions. The accepted
array has the required product law; all discarded trial words are charged. -/
namespace EditApproximation
open MeasureTheory ProbabilityTheory
section Array
variable {ι : Type*} [Fintype ι] (range : ι → ℕ) [∀ i, NeZero (range i)]
abbrev RejectionArrayExecution := ∀ i, ℕ × Fin (range i)
noncomputable def rejectionArrayCoordinateLaw (i : ι) : Measure (ℕ × Fin (range i)) :=
rejectionExecutionLaw (range i) (2 ^ rejectionBitCount (range i))
(Nat.pos_of_ne_zero (NeZero.ne (range i)))
(rejectionWord_range (range i) (Nat.pos_of_ne_zero (NeZero.ne (range i)))).1
instance rejectionArrayCoordinateLaw_probability (i : ι) :
IsProbabilityMeasure (rejectionArrayCoordinateLaw range i) := by
unfold rejectionArrayCoordinateLaw
infer_instance
noncomputable def rejectionArrayLaw : Measure (RejectionArrayExecution range) :=
Measure.pi (rejectionArrayCoordinateLaw range)
instance rejectionArrayLaw_probability : IsProbabilityMeasure (rejectionArrayLaw range) := by
unfold rejectionArrayLaw
infer_instance
def rejectionArrayAccepted (execution : RejectionArrayExecution range) : ∀ i, Fin (range i) :=
fun i => (execution i).2
theorem rejectionArrayLaw_accepted :
(rejectionArrayLaw range).map (rejectionArrayAccepted range) =
Measure.pi (fun i => (PMF.uniformOfFintype (Fin (range i))).toMeasure) := by
have hout (i : ι) : (rejectionArrayCoordinateLaw range i).map
(Prod.snd : ℕ × Fin (range i) → Fin (range i)) =
(PMF.uniformOfFintype (Fin (range i))).toMeasure :=
rejectionExecutionLaw_output _ _ _ _
let (i : ι) : SigmaFinite ((rejectionArrayCoordinateLaw range i).map
(Prod.snd : ℕ × Fin (range i) → Fin (range i))) := by
rw [hout]
infer_instance
have h := Measure.pi_map_pi (X := fun i => ℕ × Fin (range i)) (Y := fun i => Fin (range i))
(f := fun _ => Prod.snd) (μ := rejectionArrayCoordinateLaw range)
(fun _ => measurable_snd.aemeasurable)
refine h.trans ?_
congr 1
funext i
exact rejectionExecutionLaw_output _ _ _ _
noncomputable def rejectionArrayConsumedBits (execution : RejectionArrayExecution range) : ℝ :=
∑ i, (((execution i).1 : ℝ) + 1) * rejectionBitCount (range i)
omit [Fintype ι] in
theorem rejectionArrayCoordinate_bits_integrable (i : ι) :
Integrable (fun value : ℕ × Fin (range i) =>
((value.1 : ℝ) + 1) * rejectionBitCount (range i)) (rejectionArrayCoordinateLaw range i) :=
((rejection_trials_integrable (range i) (2 ^ rejectionBitCount (range i))
(Nat.pos_of_ne_zero (NeZero.ne (range i)))
(rejectionWord_range (range i) (Nat.pos_of_ne_zero (NeZero.ne (range i)))).1).comp_fst
(PMF.uniformOfFintype (Fin (range i))).toMeasure).mul_const _
theorem rejectionArrayLaw_bits_integrable :
Integrable (rejectionArrayConsumedBits range) (rejectionArrayLaw range) := by
unfold rejectionArrayConsumedBits rejectionArrayLaw
apply integrable_finsetSum
intro i _
exact integrable_comp_eval (X := fun i => ℕ × Fin (range i))
(μ := rejectionArrayCoordinateLaw range) (i := i) (rejectionArrayCoordinate_bits_integrable range i)
theorem rejectionArrayLaw_bits_le :
(∫ execution, rejectionArrayConsumedBits range execution ∂rejectionArrayLaw range) ≤
2 * ∑ i, (rejectionBitCount (range i) : ℝ) := by
unfold rejectionArrayConsumedBits rejectionArrayLaw
rw [integral_finsetSum]
· rw [Finset.mul_sum]
apply Finset.sum_le_sum
intro i _
rw [integral_comp_eval (X := fun i => ℕ × Fin (range i))
(μ := rejectionArrayCoordinateLaw range) (i := i)
(f := fun value : ℕ × Fin (range i) => ((value.1 : ℝ) + 1) * rejectionBitCount (range i))
(rejectionArrayCoordinate_bits_integrable range i).aestronglyMeasurable]
unfold rejectionArrayCoordinateLaw rejectionExecutionLaw
rw [integral_fun_fst (ν := (PMF.uniformOfFintype (Fin (range i))).toMeasure)
(fun failures : ℕ => ((failures : ℝ) + 1) * rejectionBitCount (range i)),
probReal_univ, one_smul]
exact rejection_consumed_bits_moment (range i) (Nat.pos_of_ne_zero (NeZero.ne (range i)))
· intro i _
exact integrable_comp_eval (X := fun i => ℕ × Fin (range i))
(μ := rejectionArrayCoordinateLaw range) (i := i) (rejectionArrayCoordinate_bits_integrable range i)
end Array
end EditApproximation
end OAI
|