File size: 3,086 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 | import Mathlib.Combinatorics.Matroid.Closure
import Mathlib.Data.Finset.Powerset
import Mathlib.Data.Nat.Choose.Basic
import Mathlib.Order.Interval.Finset.Nat
namespace OAI
namespace MatroidProphet.MarkedPivots
open scoped BigOperators
abbrev Occurrences (r q : β) := Fin r β Fin q
def label {Ξ± : Type*} {r q : β} (old : Fin r β Ξ±) (movable : Fin q β Ξ±) :
Occurrences r q β Ξ± := Sum.elim old movable
def mark {r q : β} (oldMark : Fin r β Bool) (movableMark : Fin q β Bool) :
Occurrences r q β Bool := Sum.elim oldMark movableMark
def OldOrdered {r q : β} (time : Occurrences r q β β) : Prop :=
β i j : Fin r, i < j β time (Sum.inl i) < time (Sum.inl j)
/-- The label is first spanned at this occurrence, and not before it. -/
def FirstSpans {Ξ± : Type*} {r q : β} (M : Matroid Ξ±)
(labels : Occurrences r q β Ξ±) (time : Occurrences r q β β)
(e : Ξ±) (o : Occurrences r q) : Prop :=
e β M.closure (labels '' {p | time p β€ time o}) β§
e β M.closure (labels '' {p | time p < time o})
/-- The finite set encodes precisely those test coordinates whose pivot has mark one. -/
def Records {Ξ± : Type*} {r q n : β} (M : Matroid Ξ±)
(old : Fin r β Ξ±) (movable : Fin q β Ξ±) (test : Fin n β Ξ±)
(time : Occurrences r q β β) (oldMark : Fin r β Bool)
(movableMark : Fin q β Bool) (pattern : Finset (Fin n)) : Prop :=
β f, β o, FirstSpans M (label old movable) time (test f) o β§
(mark oldMark movableMark o = true β f β pattern)
/-- All actual pivot-mark vectors over all interleavings and all movable marks. -/
noncomputable def patterns {Ξ± : Type*} {r q n : β} (M : Matroid Ξ±)
(old : Fin r β Ξ±) (movable : Fin q β Ξ±) (test : Fin n β Ξ±)
(oldMark : Fin r β Bool) : Finset (Finset (Fin n)) := by
classical
exact Finset.univ.filter fun pattern =>
β time : Occurrences r q β β, OldOrdered time β§ Function.Injective time β§
β movableMark : Fin q β Bool, Records M old movable test time oldMark movableMark pattern
/-- Full named source obligation, including well-definedness for every interleaving.
The test function is injective because the manuscript tests a set of `n` nonloops.
The conclusion actually remains true without that injectivity assumption. -/
def SourceContract.{u} : Prop :=
β {Ξ± : Type u} [Fintype Ξ±] (M : Matroid Ξ±) (r q n s : β)
(old : Fin r β Ξ±) (movable : Fin q β Ξ±) (test : Fin n β Ξ±)
(oldMark : Fin r β Bool),
q β€ s β (β i, old i β M.E) β (β i, movable i β M.E) β
M.closure (Set.range old) = M.E β Function.Injective test β
(β f, test f β M.E β§ test f β M.closure β
) β
(patterns M old movable test oldMark).card β€
4 ^ s * β k β Finset.Iic s, n.choose k β§
β (time : Occurrences r q β β), OldOrdered time β Function.Injective time β
β movableMark : Fin q β Bool,
β! pattern, Records M old movable test time oldMark movableMark pattern
end MatroidProphet.MarkedPivots
end OAI
|