File size: 3,253 Bytes
135052a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import Mathlib
import OAI.Probability.SKBarriers.Locking.NarrowRetainedExpansion

namespace OAI

section

noncomputable section
open scoped BigOperators
open MeasureTheory ProbabilityTheory Set
namespace SK.Analytic

theorem narrowRetainedCommon_variance (c : List (ℝ × (ℝ × ℝ))) :
    ((narrowRetainedCommon c).map (fun p => (p.2.1.2+p.2.2.2)^2)).sum=weightedVariance c := by
  simp only [narrowRetainedCommon,List.map_map,Function.comp_def,zero_add,weightedVariance]

theorem narrowRetainedCommon_score (c : List (ℝ × (ℝ × ℝ))) :
    ((narrowRetainedCommon c).map (fun p => |p.2.1.2+p.2.2.2| * (|p.2.1.1|+2*|p.2.2.1|))).sum=
      3*weightedAbsCross c := by
  simp only [narrowRetainedCommon,List.map_map,Function.comp_def,zero_add,weightedAbsCross]
  rw [← List.sum_map_mul_left]
  congr 1
  apply List.map_congr_left
  intro p _
  ring

theorem narrowRetainedMiddle_variance (l : List NarrowMiddleIncrement) :
    ((narrowRetainedMiddle l).map (fun p => (p.2.1.2+p.2.2.2)^2)).sum=
      weightedVariance (productLeft l)+weightedVariance (productRight l) := by
  induction l with
  | nil => simp [narrowRetainedMiddle,productLeft,productRight,weightedVariance]
  | cons p l ih =>
    cases p <;> simp only [narrowRetainedMiddle,List.map_cons,List.map_map,Function.comp_def,List.sum_cons,
      productVector,Prod.snd_zero,productLeft,productRight,List.filterMap_cons,weightedVariance,List.map_cons,List.sum_cons,
      add_zero,zero_add] at ih ⊢ <;> rw [ih] <;> ring

theorem narrowRetainedMiddle_score (l : List NarrowMiddleIncrement) :
    ((narrowRetainedMiddle l).map (fun p => |p.2.1.2+p.2.2.2| * (|p.2.1.1|+2*|p.2.2.1|))).sum=
      weightedAbsCross (productLeft l)+2*weightedAbsCross (productRight l) := by
  induction l with
  | nil => simp [narrowRetainedMiddle,productLeft,productRight,weightedAbsCross]
  | cons p l ih =>
    cases p <;> simp only [narrowRetainedMiddle,List.map_cons,List.map_map,Function.comp_def,List.sum_cons,
      productVector,Prod.fst_zero,Prod.snd_zero,productLeft,productRight,List.filterMap_cons,weightedAbsCross,List.map_cons,List.sum_cons,
      abs_zero,mul_zero,add_zero,zero_add] at ih ⊢ <;> rw [ih] <;> ring

def narrowVariance (c v w : List (ℝ × (ℝ × ℝ))) := weightedVariance c+weightedVariance v+weightedVariance w
def narrowAbsCross (c v w : List (ℝ × (ℝ × ℝ))) := 3*weightedAbsCross c+weightedAbsCross v+2*weightedAbsCross w

theorem narrowRetainedPrefix_variance (c v w : List (ℝ × (ℝ × ℝ))) :
    ((narrowRetainedPrefix c v w).map (fun p => (p.2.1.2+p.2.2.2)^2)).sum=narrowVariance c v w := by
  simp only [narrowRetainedPrefix,List.map_append,List.sum_append,narrowRetainedCommon_variance,
    narrowRetainedMiddle_variance,mergedProductBranches_left,mergedProductBranches_right,narrowVariance,add_assoc]

theorem narrowRetainedPrefix_score (c v w : List (ℝ × (ℝ × ℝ))) :
    ((narrowRetainedPrefix c v w).map (fun p => |p.2.1.2+p.2.2.2| * (|p.2.1.1|+2*|p.2.2.1|))).sum=
      narrowAbsCross c v w := by
  simp only [narrowRetainedPrefix,List.map_append,List.sum_append,narrowRetainedCommon_score,
    narrowRetainedMiddle_score,mergedProductBranches_left,mergedProductBranches_right,narrowAbsCross,add_assoc]

end SK.Analytic

end
end

end OAI