File size: 1,882 Bytes
97c3405
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Combinatorics.ContingencyTables.Transport.FiniteObservableTransport
import OAI.Combinatorics.ContingencyTables.Machines.FiniteWordDependent

namespace OAI

/-! # Composing exact laws through a noninjective state encoding -/
namespace ContingencyTables.FiniteObservableTransport
open CommonBasesFPRAS FairBits
open scoped Classical
noncomputable section

theorem encoded_bind {A B U V C Z W : Type*}
    [Fintype A] [Fintype B] [Fintype U] [Fintype V]
    (f : A → C) (g : B → Z) (e : Z → C) (F : C → U → W) (G : Z → V → W)
    (hinit : SameLaw f (fun b => e (g b))) (hstep : ∀ z,SameLaw (F (e z)) (G z)) :
    SameLaw (fun p : A×U => F (f p.1) p.2) (fun p : B×V => G (g p.1) p.2) := by
  intro phi
  rw [uniformAverage_prod,uniformAverage_prod]
  have hi := hinit (fun c => uniformAverage (fun u : U => phi (F c u)))
  refine hi.trans ?_
  apply congrArg uniformAverage
  funext b
  exact hstep (g b) phi

theorem flat_encoded_bind {C Z W : Type*} (a b c d : ℕ)
    (f : (Fin a → Bool) → C) (g : (Fin c → Bool) → Z) (e : Z → C)
    (F : C → (Fin b → Bool) → W) (G : Z → (Fin d → Bool) → W)
    (hinit : SameLaw f (fun bits => e (g bits))) (hstep : ∀ z,SameLaw (F (e z)) (G z)) :
    SameLaw (fun bits : Fin (a+b) → Bool =>
      F (f (splitWordEquiv a b bits).1) (splitWordEquiv a b bits).2)
      (fun bits : Fin (c+d) → Bool =>
        G (g (splitWordEquiv c d bits).1) (splitWordEquiv c d bits).2) := by
  have h := encoded_bind f g e F G hinit hstep
  intro phi
  have hl := uniformAverage_equiv (splitWordEquiv a b)
    (fun p : (Fin a → Bool)×(Fin b → Bool) => phi (F (f p.1) p.2))
  have hr := uniformAverage_equiv (splitWordEquiv c d)
    (fun p : (Fin c → Bool)×(Fin d → Bool) => phi (G (g p.1) p.2))
  exact hl.trans ((h phi).trans hr.symm)

end
end ContingencyTables.FiniteObservableTransport

end OAI