File size: 3,070 Bytes
cdec422
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.LinearAlgebra.MatrixMultiplication.FieldHistory.Support

namespace OAI

/-! Finite extraction histories, inherited masks and recovery bounds. -/

noncomputable section

namespace MatrixMultiplication.AllFieldHistoryBranchWeights

open AllFieldHistory AllFieldHistorySupport AllFieldParameters
open scoped BigOperators
attribute [local instance] Classical.propDecidable Classical.decEq

theorem stageB_branchPopulation_rat {K : ℕ} (allocation : Allocation) (dilation : ℕ)
    (h : APositive K) (b : BSplit h) (phi : Placement) :
    (branchPopulation allocation dilation (.stageB h, phi) b : ℚ) =
      (population allocation dilation (.afterA h.val, phi) : ℚ) *
        stageBLaw (aShape h.val) (bSplit ⟨h, b, false⟩) := by
  simp only [branchPopulation, Work.child, population_cast, amount, canonicalAmount, bAmount]
  ring

theorem stageB_branchPopulation_real {K : ℕ} (allocation : Allocation) (dilation : ℕ)
    (h : APositive K) (b : BSplit h) (phi : Placement) :
    (branchPopulation allocation dilation (.stageB h, phi) b : ℝ) =
      (population allocation dilation (.afterA h.val, phi) : ℝ) *
        (stageBLaw (aShape h.val) (bSplit ⟨h, b, false⟩) : ℝ) := by
  exact_mod_cast stageB_branchPopulation_rat allocation dilation h b phi

theorem stageB_branchWeight_rat {K dilation : ℕ} (allocation : Allocation)
    (hd : 0 < dilation) (h : APositive K) (b : BSplit h) (phi : Placement) :
    (branchPopulation allocation dilation (.stageB h, phi) b : ℚ) /
      (population allocation dilation (.afterA h.val, phi) : ℚ) =
        stageBLaw (aShape h.val) (bSplit ⟨h, b, false⟩) := by
  have hpos := work_source_population_pos allocation hd (.stageB h, phi)
  have hden : (population allocation dilation (.afterA h.val, phi) : ℚ) ≠ 0 := by
    exact_mod_cast Nat.ne_of_gt hpos
  apply (div_eq_iff hden).2
  rw [stageB_branchPopulation_rat]
  exact mul_comm _ _

theorem stageB_branchWeight_real {K dilation : ℕ} (allocation : Allocation)
    (hd : 0 < dilation) (h : APositive K) (b : BSplit h) (phi : Placement) :
    (branchPopulation allocation dilation (.stageB h, phi) b : ℝ) /
      (population allocation dilation (.afterA h.val, phi) : ℝ) =
        (stageBLaw (aShape h.val) (bSplit ⟨h, b, false⟩) : ℝ) := by
  have hpos := work_source_population_pos allocation hd (.stageB h, phi)
  have hden : (population allocation dilation (.afterA h.val, phi) : ℝ) ≠ 0 := by
    exact_mod_cast Nat.ne_of_gt hpos
  apply (div_eq_iff hden).2
  rw [stageB_branchPopulation_real]
  exact mul_comm _ _

theorem shapeCounts_weighted_sum {I : Type*} [Fintype I]
    (code : I → JointPopulation.Shape) (weight : I → ℕ)
    (f : JointPopulation.Shape → ℝ) :
    (∑ u, (shapeCounts code weight u : ℝ) * f u) =
      ∑ b, (weight b : ℝ) * f (code b) := by
  simp only [shapeCounts, Nat.cast_sum, Nat.cast_ite, Nat.cast_zero, Finset.sum_mul]
  rw [Finset.sum_comm]
  apply Finset.sum_congr rfl
  intro b _
  simp [ite_mul]

end MatrixMultiplication.AllFieldHistoryBranchWeights

end

end OAI