math / data /lean /OAI /Combinatorics /GraphThreshold /ProbabilityTree.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3.88 kB
import OAI.Combinatorics.GraphThreshold.Basic
import Mathlib.Data.List.Pairwise
import Mathlib.Data.Fintype.Sigma
namespace OAI
noncomputable section
namespace LeanBlast.SecondKahnKalai
/-- Equal-depth trees carrying an actual strictly positive child law at every branch. -/
inductive ProbabilityTree (X : Type) : β„• β†’ Type 1
| leaf : ProbabilityTree X 0
| node {d : β„•} (B : Type) [Fintype B] (law : FiniteLaw B)
(positive : law.IsPositive) (label : B β†’ Finset X)
(child : B β†’ ProbabilityTree X d) : ProbabilityTree X (d + 1)
/-- A function inspects only the indicated coordinates of its input subset. -/
def DependsOnlyOn {X Ξ² : Type*} [DecidableEq X] (S : Finset X)
(f : Finset X β†’ Ξ²) : Prop :=
βˆ€ W V, W ∩ S = V ∩ S β†’ f W = f V
/-- A function is unchanged by modifications inside the indicated coordinates. -/
def DependsOutside {X Ξ² : Type*} [DecidableEq X] (A : Finset X)
(f : Finset X β†’ Ξ²) : Prop :=
βˆ€ W V, W \ A = V \ A β†’ f W = f V
namespace ProbabilityTree
variable {X : Type}
/-- Full root-to-leaf paths, retaining distinct child-index histories. -/
def Path : {d : β„•} β†’ ProbabilityTree X d β†’ Type
| _, .leaf => PUnit
| _, @node _ _ B _ _ _ _ child => Ξ£ b : B, Path (child b)
/-- The list of arc labels along a full path, in root-to-leaf order. -/
def pathLabels : {d : β„•} β†’ (T : ProbabilityTree X d) β†’ T.Path β†’ List (Finset X)
| _, .leaf => fun _ => []
| _, @node _ _ _B _ _ _ label child => fun p =>
label p.1 :: pathLabels (child p.1) p.2
/-- Every path family is finite; no quotient by labels is taken. -/
instance pathFintype : {d : β„•} β†’ (T : ProbabilityTree X d) β†’ Fintype T.Path
| _, .leaf => inferInstanceAs (Fintype PUnit)
| _, @node _ _ B _ _ _ _ child => by
letI : βˆ€ b : B, Fintype (Path (child b)) := fun b => pathFintype (child b)
exact inferInstanceAs (Fintype (Ξ£ b : B, Path (child b)))
section Labels
variable [DecidableEq X]
/-- Union of all arc labels along a specified full path. -/
def pathUnion : {d : β„•} β†’ (T : ProbabilityTree X d) β†’ T.Path β†’ Finset X
| _, .leaf => fun _ => βˆ…
| _, @node _ _ _B _ _ _ label child => fun p =>
label p.1 βˆͺ pathUnion (child p.1) p.2
/-- All coordinates used by any arc anywhere in the tree. -/
def support : {d : β„•} β†’ ProbabilityTree X d β†’ Finset X
| _, .leaf => βˆ…
| _, @node _ _ B inst _ _ label child =>
(@Finset.univ B inst).biUnion fun b => label b βˆͺ support (child b)
/-- A recursive form of disjointness, equivalent to pairwise disjoint labels on every full path. -/
def IsDisjoint : {d : β„•} β†’ ProbabilityTree X d β†’ Prop
| _, .leaf => True
| _, @node _ _ _ _ _ _ label child =>
(βˆ€ b, Disjoint (label b) (support (child b))) ∧ βˆ€ b, IsDisjoint (child b)
/-- Literal pairwise disjointness along every full root-to-leaf path. -/
def PathDisjoint {d : β„•} (T : ProbabilityTree X d) : Prop :=
βˆ€ p : T.Path, (T.pathLabels p).Pairwise Disjoint
/-- Per-level spread conditions, starting with index zero at the root. -/
def HasSpread : {d : β„•} β†’ ProbabilityTree X d β†’ (β„• β†’ ℝ) β†’ Prop
| _, .leaf, _ => True
| _, @node _ _ _ _ law _ label child, a =>
IsSpread law label (a 0) ∧ βˆ€ b, HasSpread (child b) (fun j => a (j + 1))
/-- The event that some full path is covered by a given set. -/
def CoveredBy {d : β„•} (T : ProbabilityTree X d) (W : Finset X) : Prop :=
βˆƒ p : T.Path, T.pathUnion p βŠ† W
end Labels
/-- Per-level cardinality capacities, starting with index zero at the root. -/
def HasCapacities : {d : β„•} β†’ ProbabilityTree X d β†’ (β„• β†’ β„•) β†’ Prop
| _, .leaf, _ => True
| _, @node _ _ _ _ _ _ label child, m =>
(βˆ€ b, (label b).card ≀ m 0) ∧ βˆ€ b, HasCapacities (child b) (fun j => m (j + 1))
end ProbabilityTree
end LeanBlast.SecondKahnKalai
end
end OAI