Repository navigation
Expand file tree
/
Copy pathSampleRelabel.lean
More file actions
156 lines (135 loc) · 7.92 KB
/
Copy pathSampleRelabel.lean
File metadata and controls
156 lines (135 loc) · 7.92 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
module
public import RandomSystems.Typed.Functional
public import RandomSystems.Typed.Game
/-!
# Relabeling retained draws on visible transcripts
A system that hides part of each reply sums over the internal histories displayed as a given
visible transcript `h`. When two systems draw `k` once from the same law `P`, their visible
probabilities at `h` agree if each contributing internal history `u` admits its own
`P`-preserving relabeling `s` matching the two systems' contributions on `supp P`.
## Main results
* `TypedSystem.sample_mass_eq_of_map`: one `P`-preserving relabeling matches transcript masses
* `TypedSystem.sample_mass_eq_of_sum_relabel`: per-history relabeling over a finite sum `S`
* `TypedSystem.sample_mass_eq_of_display_relabel`: explicit display-map specialization
* `TypedGame.sample_visible_mass_eq_of_relabel`: visible-system specialization for `TypedGame`
-/
@[expose] public section
namespace SystemAlgebra
open Probability
open scoped BigOperators
namespace TypedSystem
variable {A : Interface}
/-- Relabeling a retained draw by a `P`-preserving map `s` preserves the transcript mass at `h`
whenever `(R₀ k)(h) = (R₁ (s k))(h)` on `supp P`; `s` need not be bijective. -/
lemma sample_mass_eq_of_map
-- `P` is the shared initial draw; `R₀`, `R₁` are the compared sampled systems on `A`.
{K : Type} (P : Distribution K) [Distribution.IsProbability P]
(R₀ R₁ : K → TypedSystem A) (h : List ((Σ i, A.X i) × (Σ i, A.Y i)))
-- `s` preserves `P` and matches the transcript masses on `supp P`.
(s : K → K) (hs : Distribution.fTransform s P = P)
(heq : ∀ k ∈ P.support, (R₀ k).1 h = (R₁ (s k)).1 h) :
(TypedSystem.sample P R₀).1 h = (TypedSystem.sample P R₁).1 h :=
Distribution.sum_mul_eq_of_fTransform_eq P s hs (fun k => (R₀ k).1 h)
(fun k => (R₁ k).1 h) heq
/-- Two sampled systems give visible transcript `h` the same probability when each system's mass
at `h` sums internal contributions `w₀ k u`, `w₁ k u` over `u ∈ S`, and every `u ∈ S` admits a
`P`-preserving relabeling `s` matching `w₀ k u` to `w₁ (s k) u` on `supp P`. -/
lemma sample_mass_eq_of_sum_relabel
-- `P` is the shared initial draw; `S` indexes the internal histories contributing to `h`.
{K U : Type} (P : Distribution K) [Distribution.IsProbability P]
(R₀ R₁ : K → TypedSystem A) (h : List ((Σ i, A.X i) × (Σ i, A.Y i)))
(S : Finset U) (w₀ w₁ : K → U → ℝ)
-- `h₀`, `h₁` decompose each system's visible mass at `h` over `S`.
(h₀ : ∀ k ∈ P.support, (R₀ k).1 h = ∑ u ∈ S, w₀ k u)
(h₁ : ∀ k ∈ P.support, (R₁ k).1 h = ∑ u ∈ S, w₁ k u)
-- Each `u ∈ S` has its own `P`-preserving relabeling `s` matching `w₀` to `w₁`.
(hmatch : ∀ u ∈ S, ∃ s : K → K, Distribution.fTransform s P = P ∧
∀ k ∈ P.support, w₀ k u = w₁ (s k) u) :
(TypedSystem.sample P R₀).1 h = (TypedSystem.sample P R₁).1 h := by
rw [sample_mass, sample_mass]
calc
∑ k ∈ P.support, P k * (R₀ k).1 h
= ∑ k ∈ P.support, P k * ∑ u ∈ S, w₀ k u :=
Finset.sum_congr rfl fun k hk => by rw [h₀ k hk]
_ = ∑ k ∈ P.support, P k * ∑ u ∈ S, w₁ k u :=
Distribution.sum_mul_sum_eq_of_fTransform_eq P S w₀ w₁ hmatch
_ = ∑ k ∈ P.support, P k * (R₁ k).1 h :=
Finset.sum_congr rfl fun k hk => by rw [h₁ k hk]
open Classical in
/-- Visible transcript probabilities agree when each system sums internal probabilities `p₀`,
`p₁` over internal histories `u ∈ S` displayed as `h` (`display u = h`), and each such `u`
admits its own `P`-preserving relabeling `s` matching `p₀ k u` to `p₁ (s k) u` on `supp P`. -/
lemma sample_mass_eq_of_display_relabel
-- `P` is the shared initial draw; `S` contains all internal histories displayed as `h`.
{K U : Type} (P : Distribution K) [Distribution.IsProbability P]
(R₀ R₁ : K → TypedSystem A) (h : List ((Σ i, A.X i) × (Σ i, A.Y i)))
-- `display` projects internal histories to visible ones; `p₀`, `p₁` give internal masses.
(S : Finset U) (display : U → List ((Σ i, A.X i) × (Σ i, A.Y i)))
(p₀ p₁ : K → U → ℝ)
(h₀ : ∀ k ∈ P.support, (R₀ k).1 h = ∑ u ∈ S, if display u = h then p₀ k u else 0)
(h₁ : ∀ k ∈ P.support, (R₁ k).1 h = ∑ u ∈ S, if display u = h then p₁ k u else 0)
-- Only internal histories displayed as `h` need a `P`-preserving relabeling `s`.
(hmatch : ∀ u ∈ S, display u = h →
∃ s : K → K, Distribution.fTransform s P = P ∧
∀ k ∈ P.support, p₀ k u = p₁ (s k) u) :
(TypedSystem.sample P R₀).1 h = (TypedSystem.sample P R₁).1 h := by
refine sample_mass_eq_of_sum_relabel P R₀ R₁ h S
(fun k u => if display u = h then p₀ k u else 0)
(fun k u => if display u = h then p₁ k u else 0) h₀ h₁ fun u hu => ?_
by_cases hd : display u = h
· obtain ⟨s, hs, hEq⟩ := hmatch u hu hd
exact ⟨s, hs, fun k hk => by simp only [hd, ↓reduceIte, hEq k hk]⟩
· exact ⟨id, Distribution.fTransform_id P, fun _ _ => by simp only [hd, ↓reduceIte]⟩
end TypedSystem
namespace TypedGame
/-- Tag each entry of visible transcript `h` with the MBO bit given by `bs`. -/
def tagMBOs {A J : Type} {Y : J → Type} :
(h : List (A × Σ j, Y j)) → (Fin h.length → Bool) → List (A × Σ j, withMBO Y j)
| [], _ => []
| z :: t, bs => (z.1, tagMBO (bs 0) z.2) :: tagMBOs t (fun i => bs i.succ)
/-- Forgetting MBO bits recovers the original visible transcript. -/
lemma forgetMBOs_tagMBOs {A J : Type} {Y : J → Type} (h : List (A × Σ j, Y j))
(bs : Fin h.length → Bool) :
forgetMBOs (tagMBOs h bs) = h := by
induction h with
| nil => rfl
| cons z t ih =>
simp only [tagMBOs, forgetMBOs, List.map_cons]
exact congrArg (z :: ·) (ih (fun i => bs i.succ))
/-- `sumMBO f h` sums `f` over all MBO bit assignments for the entries of `h`. -/
lemma sumMBO_eq_sum_tagMBOs {A J : Type} {Y : J → Type}
(f : List (A × Σ j, withMBO Y j) → ℝ) (h : List (A × Σ j, Y j)) :
sumMBO f h = ∑ bs : Fin h.length → Bool, f (tagMBOs h bs) := by
induction h generalizing f with
| nil =>
simp only [sumMBO, tagMBOs, List.length_nil]
rw [Finset.sum_const, Finset.card_univ, Fintype.card_unique, one_smul]
| cons z t ih =>
simp only [sumMBO, List.length_cons]
rw [ih, ih]
let e : Bool × (Fin t.length → Bool) ≃ (Fin (t.length + 1) → Bool) :=
Fin.consEquiv (fun _ : Fin (t.length + 1) => Bool)
rw [← e.sum_comp, Fintype.sum_prod_type, Fintype.sum_bool, add_comm]
simp only [e, Fin.consEquiv, Equiv.coe_fn_mk, tagMBOs, Fin.cons_zero, Fin.cons_succ]
/-- Two sampled typed games induce the same visible probability on `h` when every internal
MBO-tagged transcript `u` displayed as `h` admits a `P`-preserving relabeling matching `G₀`
to `G₁` on `supp P`. -/
lemma sample_visible_mass_eq_of_relabel
-- `A` is the visible interface; `P` is the shared initial draw of `G₀` and `G₁`.
{A : Interface} {K : Type} (P : Distribution K) [Distribution.IsProbability P]
(G₀ G₁ : K → TypedGame A) (h : List ((Σ i, A.X i) × (Σ i, A.Y i)))
-- Each internal history `u` displayed as `h` has its own `P`-preserving relabeling `s`.
(hmatch : ∀ u, forgetMBOs u = h →
∃ s : K → K, Distribution.fTransform s P = P ∧
∀ k ∈ P.support, (G₀ k).1.1 u = (G₁ (s k)).1.1 u) :
(TypedSystem.sample P fun k => (G₀ k).visible).1 h =
(TypedSystem.sample P fun k => (G₁ k).visible).1 h := by
refine TypedSystem.sample_mass_eq_of_sum_relabel P (fun k => (G₀ k).visible)
(fun k => (G₁ k).visible) h Finset.univ
(fun k bs => (G₀ k).1.1 (tagMBOs h bs))
(fun k bs => (G₁ k).1.1 (tagMBOs h bs))
(fun k _ => sumMBO_eq_sum_tagMBOs (G₀ k).1.1 h)
(fun k _ => sumMBO_eq_sum_tagMBOs (G₁ k).1.1 h)
fun bs _ => hmatch (tagMBOs h bs) (forgetMBOs_tagMBOs h bs)
end TypedGame
end SystemAlgebra