File size: 3,716 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | import OAI.Combinatorics.BalancedRyser.Probability.FiniteUniformConditioning
import OAI.Combinatorics.BalancedRyser.Probability.UniformRestriction
namespace OAI
namespace Balanced.ConditionalRestriction
open TupleAlignment
noncomputable section
attribute [local instance] Classical.propDecidable
variable {D ΞΉ A : Type*}
abbrev FixedArray (P : D β Prop) (a : D β A) :=
{o : D β A // β d, P d β o d = a d}
instance (P : D β Prop) (a : D β A) : Nonempty (FixedArray P a) :=
β¨β¨a, by intro d hd; rflβ©β©
def fixedFreshEquiv (P : D β Prop) (a : D β A) :
FixedArray P a β ({d : D // Β¬ P d} β A) where
toFun o d := o.1 d.1
invFun f := β¨fun d => if hd : P d then a d else f β¨d,hdβ©, by
intro d hd
simp only [dite_eq_left hd]β©
left_inv o := by
apply Subtype.ext
funext d
by_cases hd : P d
Β· simp only [dite_eq_left hd]
exact (o.2 d hd).symm
Β· simp only [dite_eq_right hd]
right_inv f := by
funext d
simp only [dite_eq_right d.2]
def fixedRestrict (e : ΞΉ βͺ D) (P : D β Prop) (a : D β A)
(o : FixedArray P a) : FixedArray (fun i => P (e i)) (fun i => a (e i)) :=
β¨fun i => o.1 (e i), fun i hi => o.2 (e i) hiβ©
def freshEmbedding (e : ΞΉ βͺ D) (P : D β Prop) :
{i : ΞΉ // Β¬ P (e i)} βͺ {d : D // Β¬ P d} where
toFun i := β¨e i.1, i.2β©
inj' := by
intro i j h
apply Subtype.ext
exact e.injective (congrArg Subtype.val h)
theorem fixedRestriction_commutes (e : ΞΉ βͺ D) (P : D β Prop) (a : D β A) :
fixedRestrict e P a β (fixedFreshEquiv P a).symm =
(fixedFreshEquiv (fun i => P (e i)) (fun i => a (e i))).symm β
(fun f i => f (freshEmbedding e P i)) := by
funext f
apply Subtype.ext
funext i
rfl
variable [Fintype D] [Fintype ΞΉ] [Fintype A]
[DecidableEq D] [DecidableEq ΞΉ] [Nonempty A]
theorem uniform_fixed_restrict (e : ΞΉ βͺ D) (P : D β Prop) (a : D β A) :
(PMF.uniformOfFintype (FixedArray P a)).map (fixedRestrict e P a) =
PMF.uniformOfFintype (FixedArray (fun i => P (e i)) (fun i => a (e i))) := by
have hsource := uniform_map_equiv (fixedFreshEquiv P a).symm
have htarget := uniform_map_equiv (fixedFreshEquiv (fun i => P (e i)) (fun i => a (e i))).symm
have hrestrict := uniform_map_restrict (A := A) (freshEmbedding e P)
rw [β hsource, PMF.map_comp, fixedRestriction_commutes,
β PMF.map_comp, hrestrict, htarget]
theorem fixed_supported (P : D β Prop) (a : D β A) :
β o β {o : D β A | β d, P d β o d = a d},
o β (PMF.uniformOfFintype (D β A)).support :=
β¨a, by intro d hd; rfl, PMF.mem_support_uniformOfFintype _β©
theorem uniform_fixed_filter (P : D β Prop) (a : D β A) :
(PMF.uniformOfFintype (D β A)).filter
{o | β d, P d β o d = a d} (fixed_supported P a) =
(PMF.uniformOfFintype (FixedArray P a)).map Subtype.val := by
let : Nonempty ({o : D β A | β d, P d β o d = a d} : Set (D β A)) :=
β¨β¨a, by intro d hd; rflβ©β©
exact Balanced.uniform_filter_eq_subtype_map _ _
theorem uniform_conditional_restrict (e : ΞΉ βͺ D) (P : D β Prop) (a : D β A) :
((PMF.uniformOfFintype (D β A)).filter
{o | β d, P d β o d = a d} (fixed_supported P a)).map
(fun o i => o (e i)) =
(PMF.uniformOfFintype (ΞΉ β A)).filter
{o | β i, P (e i) β o i = a (e i)}
(fixed_supported (fun i => P (e i)) (fun i => a (e i))) := by
rw [uniform_fixed_filter, uniform_fixed_filter, PMF.map_comp]
change (PMF.uniformOfFintype (FixedArray P a)).map
(Subtype.val β fixedRestrict e P a) = _
rw [β PMF.map_comp, uniform_fixed_restrict]
end
end Balanced.ConditionalRestriction
end OAI
|