File size: 4,568 Bytes
7d9f027
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import Mathlib
import OAI.Probability.SKGap.Localization.Append
import OAI.Probability.SKGap.Localization.NoiseSplit

namespace OAI

section
noncomputable section
noncomputable section
open scoped BigOperators
noncomputable section
noncomputable section
noncomputable section
open scoped BigOperators
noncomputable section
open scoped BigOperators
noncomputable section
open scoped BigOperators
noncomputable section
open scoped BigOperators
noncomputable section
open scoped BigOperators
namespace SKGap.Noncrossing
namespace Diagram
variable {D E : Type*}

@[simp] lemma map_size (f : D→E) (d : Diagram D) : (d.map f).size=d.size := by
  induction d <;> simp_all [map,size]
lemma map_map {G : Type*} (f : D→E) (g : E→G) (d : Diagram D) :
    (d.map f).map g=d.map (g∘f) := by induction d <;> simp_all [map]

lemma fiber_map_injective (f : D→E) (d e : Diagram D)
    (hw : d.word=e.word) (he : d.map f=e.map f) : d=e := by
  induction d generalizing e with
  | nil => cases e <;> simp_all [word,map]
  | diag a d ih =>
    cases e with
    | nil => simp [word] at hw
    | arch u v => simp [word] at hw
    | diag b e =>
      simp only [word,List.cons.injEq,Letter.diag.injEq] at hw
      simp only [map,Diagram.diag.injEq] at he
      obtain ⟨rfl,hw⟩ := hw
      exact congrArg (Diagram.diag a) (ih e hw he.2)
  | arch d r hd hr =>
    cases e with
    | nil => simp [word] at hw
    | diag b e => simp [word] at hw
    | arch u v =>
      simp only [map,Diagram.arch.injEq] at he
      have hlen : d.word.length=u.word.length := by
        simpa only [word_length,map_size] using congrArg Diagram.size he.1
      simp only [word,List.cons.injEq,true_and] at hw
      have hw' := List.append_inj hw hlen
      have hu := hd u hw'.1 he.1
      have hv := hr v (List.cons.inj hw'.2).2 he.2
      subst u; subst v; rfl

lemma exists_map_of_word (f : D→E) (d : Diagram E) (F : List (Letter D))
    (hw : F.map (Letter.map f)=d.word) :
    ∃ e : Diagram D, e.word=F ∧ e.map f=d := by
  induction d generalizing F with
  | nil =>
    have hF : F=[] := List.map_eq_nil_iff.mp hw
    subst F
    exact ⟨.nil,rfl,rfl⟩
  | diag a d ih =>
    cases F with
    | nil => simp [word] at hw
    | cons l F =>
      cases l with
      | noise => simp [Letter.map,word] at hw
      | diag b =>
        simp only [List.map_cons,Letter.map,word,List.cons.injEq,Letter.diag.injEq] at hw
        obtain ⟨e,he,hef⟩ := ih F hw.2
        exact ⟨.diag b e,by simp [word,he],by simp [map,hef,hw.1]⟩
  | arch d e hd he =>
    cases F with
    | nil => simp [word] at hw
    | cons l F =>
      cases l with
      | diag b => simp [Letter.map,word] at hw
      | noise =>
        simp only [List.map_cons,Letter.map,word,List.cons.injEq,true_and] at hw
        obtain ⟨P,Q,hF,hP,hQ⟩ := List.map_eq_append_iff.mp hw
        cases Q with
        | nil => simp at hQ
        | cons l Q =>
          cases l with
          | diag b => simp [Letter.map] at hQ
          | noise =>
            simp only [List.map_cons,Letter.map,List.cons.injEq,true_and] at hQ
            obtain ⟨u,hu,huf⟩ := hd P hP
            obtain ⟨v,hv,hvf⟩ := he Q hQ
            exact ⟨.arch u v,by simp [word,hu,hv,hF],by simp [map,huf,hvf]⟩

def Paired.map (f : D→E) (F : List (Letter D)) (d : Paired F) :
    Paired (F.map (Letter.map f)) := ⟨d.val.map f,by rw [map_word,d.property]⟩
lemma Paired.map_bijective (f : D→E) (F : List (Letter D)) :
    Function.Bijective (Paired.map f F) := by
  constructor
  · intro d e h
    apply Subtype.ext
    exact fiber_map_injective f d.val e.val (d.property.trans e.property.symm)
      (congrArg (fun z => z.val) h)
  · intro d
    obtain ⟨e,he,hef⟩ := exists_map_of_word f d.val F d.property.symm
    exact ⟨⟨e,he⟩,Subtype.ext hef⟩
def Paired.mapEquiv (f : D→E) (F : List (Letter D)) :
    Paired F ≃ Paired (F.map (Letter.map f)) :=
  Equiv.ofBijective (Paired.map f F) (Paired.map_bijective f F)

variable {ι : Type*} [Fintype ι]
lemma evaluate_map (j : ℝ) (v : E→ι→ℝ) (f : D→E) (d : Diagram D) :
    evaluate j v (d.map f)=evaluate j (v∘f) d := by simp [evaluate,map_map]

lemma expect_map (j : ℝ) (v : E→ι→ℝ) (f : D→E) (F : List (Letter D)) (i : ι) :
    expect j v (F.map (Letter.map f)) i=expect j (v∘f) F i := by
  symm
  apply Fintype.sum_equiv (Paired.mapEquiv f F)
  intro d
  exact congrFun (evaluate_map j v f d.val).symm i

end Diagram
end SKGap.Noncrossing

noncomputable section
open scoped BigOperators

end
end
end
end
end
end
end
end
end
end
end

end OAI