File size: 3,881 Bytes
e320e82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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