File size: 5,419 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | import OAI.Combinatorics.ContingencyTables.Rooted.ForestCut
namespace OAI
/-!
# Actual bipartite cell forests and their completion intervals
The graph vertices are the original row and column labels. Capacities
are attached to unordered row-column edges. The deletion-component cut
is constructed from the maximizing forest, so the hypotheses of the
physical cut estimate follow from actual graph properties.
-/
namespace ContingencyTables.ForestCapacity
open scoped BigOperators Classical
open SimpleGraph
open MaximumForest ForestCut
variable {I J : Type*} [Fintype I] [Fintype J]
def cellAdj (small : I β J β Bool) : IβJ β IβJ β Prop
| .inl i,.inr j => small i j=false
| .inr j,.inl i => small i j=false
| _,_ => False
def cellGraph (small : I β J β Bool) : SimpleGraph (IβJ) where
Adj := cellAdj small
symm := β¨by intro v w; cases v <;> cases w <;> exact idβ©
loopless := β¨by intro v; cases v <;> exact idβ©
def pairCapacity (b : I β J β β) : IβJ β IβJ β β
| .inl i,.inr j => b i j
| .inr j,.inl i => b i j
| _,_ => 0
def capacity (b : I β J β β) : Sym2 (IβJ) β β :=
Sym2.lift β¨pairCapacity b,by intro v w; cases v <;> cases w <;> rflβ©
omit [Fintype I] [Fintype J] in
@[simp] lemma capacity_cell (b : I β J β β) (i : I) (j : J) :
capacity b s(Sum.inl i,Sum.inr j)=b i j := rfl
omit [Fintype I] [Fintype J] in
lemma cell_edge_injective : Function.Injective
(fun a : IΓJ => s(Sum.inl a.1,Sum.inr a.2)) := by
rintro β¨i,jβ© β¨i',j'β© h
simpa only [Sym2.eq_iff,Prod.mk.injEq,Sum.inl.injEq,Sum.inr.injEq,
Sum.inl_ne_inr,Sum.inr_ne_inl,false_and,or_false] using h
noncomputable def treeCell (T : SimpleGraph (IβJ)) (i : I) (j : J) : Bool :=
decide (T.Adj (.inl i) (.inr j))
/-- The actual maximum-forest cut gives the source's displacement and
interval bounds for every solution of the selected nonroot equations. -/
theorem completion_interval (small : I β J β Bool) (b : I β J β β)
(T : SimpleGraph (IβJ)) (hTG : Tβ€cellGraph small) (hT : T.IsAcyclic)
(hmax : β F : SimpleGraph (IβJ), Fβ€cellGraph small β F.IsAcyclic β
weight F (capacity b)β€weight T (capacity b))
(iβ : I) (jβ : J) (ht : T.Adj (.inl iβ) (.inr jβ)) (root : IβJ)
(hroot : T.Reachable root (.inl iβ))
(x q z X : I β J β β) (d : β) (W : β)
(hd : 1β€d) (hcard : (Fintype.card I*Fintype.card J:β)β€d)
(hlarge : β i j, small i j=false β Wβ€b i j β§ 1β€b i j)
(hsmall : β i j, small i j=true β b i j<W β§
(0β€x i j β§ x i jβ€b i j) β§ (0β€q i j β§ q i jβ€b i j))
(hX : β i j, 0β€X i j β§ X i jβ€b i j)
(hfree : β i j, small i j=false β treeCell T i j=false β
0β€z i j β§ z i jβ€b i j+1)
(hr : β i, T.Reachable root (.inl i) β Sum.inl iβ root β rowDifference small x z X i=0)
(hc : β j, T.Reachable root (.inr j) β Sum.inr jβ root β columnDifference small q z X j=0) :
-10*d*b iβ jββ€z iβ jβ β§ z iβ jββ€10*d*b iβ jβ := by
let t : Sym2 (IβJ) := s(Sum.inl iβ,Sum.inr jβ)
let D := T.deleteEdges {t}
obtain β¨r,hrr,hrootSide,hcrossβ© := exists_root_avoiding_side T hT ht root hroot
let rowU : I β Bool := fun i => side D r (.inl i)
let colU : J β Bool := fun j => side D r (.inr j)
have hsβ : small iβ jβ=false := hTG ht
have hB : (1:β)β€b iβ jβ := by exact_mod_cast (hlarge iβ jβ hsβ).2
have hdisp : |z iβ jβ-X iβ jβ|β€4*d*b iβ jβ := by
apply displacement_bound small (treeCell T) rowU colU x q z X
(fun i j => (b i j:β)) iβ jβ d hcard hB hsβ hcross
Β· intro i hi
change side D r (.inl i)=true at hi
apply hr i
Β· have hri : D.Reachable r (.inl i) := by
simpa only [side,decide_eq_true_eq] using hi
exact hrr.trans (hri.mono
(T.deleteEdges_le {t}))
Β· intro he
have hbad : side D r root=true := by simpa only [he] using hi
exact Bool.false_ne_true (hrootSide.symm.trans hbad)
Β· intro j hj
change side D r (.inr j)=true at hj
apply hc j
Β· have hrj : D.Reachable r (.inr j) := by
simpa only [side,decide_eq_true_eq] using hj
exact hrr.trans (hrj.mono
(T.deleteEdges_le {t}))
Β· intro he
have hbad : side D r root=true := by simpa only [he] using hj
exact Bool.false_ne_true (hrootSide.symm.trans hbad)
Β· exact hX
Β· intro i j hs
have hcap : b i jβ€b iβ jβ := (Nat.le_of_lt (hsmall i j hs).1).trans
(hlarge iβ jβ hsβ).1
exact β¨by exact_mod_cast hcap,(hsmall i j hs).2β©
Β· intro i j htree hne
apply side_eq_of_tree_edge T t r
Β· exact of_decide_eq_true htree
Β· exact fun he => hne (cell_edge_injective he)
Β· intro i j hs htree
refine β¨hfree i j hs htree,?_β©
intro hcut
have hgraph : (cellGraph small).Adj (.inl i) (.inr j) := hs
have hcap := crossing_free_edge_le (cellGraph small) T (capacity b)
hTG hT hmax t (by simpa [t] using ht) r hgraph
(by simpa only [treeCell,decide_eq_false_iff_not] using htree) hcut
exact_mod_cast hcap
exact physical_interval_of_displacement d (b iβ jβ) (X iβ jβ) (z iβ jβ)
hd (Nat.cast_nonneg _) (hX iβ jβ) hdisp
end ContingencyTables.ForestCapacity
end OAI
|