File size: 3,743 Bytes
4a56cd6 | 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 | import OAI.Combinatorics.ContingencyTables.Counting.CompanionRestartPadding
namespace OAI
/-! # Padding preserves the joint law with every unused suffix bit -/
namespace ContingencyTables.FiniteObservableTransport
open CommonBasesFPRAS FairBits
open scoped BigOperators Classical
noncomputable section
theorem SameLaw.append_joint {Z : Type*} {n q : β}
{f : (Fin n β Bool) β Z} {g : (Fin q β Bool) β Z}
(h : SameLaw f g) (t : β) :
SameLaw (fun bits : Fin (n+t) β Bool =>
(f (splitWordEquiv n t bits).1,(splitWordEquiv n t bits).2))
(fun bits : Fin (q+t) β Bool =>
(g (splitWordEquiv q t bits).1,(splitWordEquiv q t bits).2)) := by
have hp := h.prod (show SameLaw (fun bits : Fin t β Bool => bits) (fun bits : Fin t β Bool => bits)
from fun _ => rfl)
intro phi
have hl := uniformAverage_equiv (splitWordEquiv n t)
(fun p : (Fin n β Bool)Γ(Fin t β Bool) => phi (f p.1,p.2))
have hr := uniformAverage_equiv (splitWordEquiv q t)
(fun p : (Fin q β Bool)Γ(Fin t β Bool) => phi (g p.1,p.2))
exact hl.trans ((hp phi).trans hr.symm)
theorem restart_append_joint_sameLaw
(base : List CompanionRestartProgram.StageΓList β) (n q : β)
(hn : (β i : Fin base.1.length,CompanionRestartProgram.widthAt base i.val)=n)
(g : (Fin q β Bool) β List β)
(h : SameLaw (fun bits : Fin n β Bool =>
CompanionRestartProgram.output (base,List.ofFn bits)) g) (t : β) :
SameLaw (fun bits : Fin (n+t) β Bool =>
(CompanionRestartProgram.output (base,List.ofFn bits),(splitWordEquiv n t bits).2))
(fun bits : Fin (q+t) β Bool =>
(g (splitWordEquiv q t bits).1,(splitWordEquiv q t bits).2)) := by
have hp := h.append_joint t
have he (bits : Fin (n+t) β Bool) :
CompanionRestartProgram.output (base,List.ofFn bits)=
CompanionRestartProgram.output (base,List.ofFn (splitWordEquiv n t bits).1) := by
have hs := (CompanionRestartProgram.output_take_sum base (List.ofFn bits)).symm
rw [hn,DensePrograms.ofFn_split_take] at hs
exact hs
intro phi
simp_rw [he]
exact hp phi
/-- Flattening the first two independent blocks preserves their joint
law with the untouched third block. -/
theorem nested_word_joint {Z : Type*} (a b t : β)
(f : (Fin a β Bool) β (Fin b β Bool) β Z) :
SameLaw (fun bits : Fin (a+(b+t)) β Bool =>
(f (splitWordEquiv a (b+t) bits).1
(splitWordEquiv b t (splitWordEquiv a (b+t) bits).2).1,
(splitWordEquiv b t (splitWordEquiv a (b+t) bits).2).2))
(fun bits : (Fin (a+b) β Bool)Γ(Fin t β Bool) =>
(f (splitWordEquiv a b bits.1).1 (splitWordEquiv a b bits.1).2,bits.2)) := by
intro phi
have houter := uniformAverage_equiv (splitWordEquiv a (b+t))
(fun p : (Fin a β Bool)Γ(Fin (b+t) β Bool) =>
phi (f p.1 (splitWordEquiv b t p.2).1,(splitWordEquiv b t p.2).2))
have hinner (u : Fin a β Bool) := uniformAverage_equiv (splitWordEquiv b t)
(fun p : (Fin b β Bool)Γ(Fin t β Bool) => phi (f u p.1,p.2))
have hfirst := uniformAverage_equiv (splitWordEquiv a b)
(fun p : (Fin a β Bool)Γ(Fin b β Bool) =>
uniformAverage (fun tail : Fin t β Bool => phi (f p.1 p.2,tail)))
rw [uniformAverage_prod] at hfirst
rw [uniformAverage_prod]
refine houter.trans ?_
rw [uniformAverage_prod]
calc
_ = uniformAverage (fun u : Fin a β Bool =>
uniformAverage (fun v : Fin b β Bool =>
uniformAverage (fun tail : Fin t β Bool => phi (f u v,tail)))) := by
apply congrArg uniformAverage
funext u
exact (hinner u).trans (uniformAverage_prod _)
_ = _ := hfirst.symm
end
end ContingencyTables.FiniteObservableTransport
end OAI
|