Shared-site coefficient context · WordGeometry
DefinitionMarkovScatteringCharged_WordGeometrymarkov-scattering
Source context from the finite shared-site cubic model and its supporting definitions and checked lemmas.
Definition code
import Definitions.Def_MarkovScatteringCharged_WordChain
import Definitions.Def_MarkovScatteringCharged_GraphRecursion
open scoped BigOperators
namespace MarkovScattering.WordGeometry
variable {m : ℕ}
/-- The path on the ordered gap labels. -/
def lineGraph (m : ℕ) : SimpleGraph (Fin m) where
Adj a b := a.val + 1 = b.val ∨ b.val + 1 = a.val
symm := ⟨fun _ _ h => h.symm⟩
loopless := ⟨fun a h => by rcases h with h | h <;> omega⟩
instance : DecidableRel (lineGraph m).Adj := fun _ _ =>
inferInstanceAs (Decidable (_ ∨ _))
/-- A consecutive subset of gaps. The empty set is included for recursion. -/
def Interval (S : Finset (Fin m)) : Prop :=
∀ a ∈ S, ∀ b ∈ S, ∀ x : Fin m, a ≤ x → x ≤ b → x ∈ S
theorem interval_univ (m : ℕ) : Interval (Finset.univ : Finset (Fin m)) :=
fun _ _ _ _ _ _ _ => Finset.mem_univ _
theorem interval_singleton (a : Fin m) : Interval ({a} : Finset (Fin m)) := by
intro x hx y hy c hxc hcy
rw [Finset.mem_singleton.mp hx] at hxc
rw [Finset.mem_singleton.mp hy] at hcy
exact Finset.mem_singleton.mpr (le_antisymm hcy hxc)
/-- The part of a gap set strictly to the left of a split. -/
def left (S : Finset (Fin m)) (a : Fin m) : Finset (Fin m) :=
S.filter fun x => x < a
/-- The part of a gap set strictly to the right of a split. -/
def right (S : Finset (Fin m)) (a : Fin m) : Finset (Fin m) :=
S.filter fun x => a < x
theorem erase_eq_split (S : Finset (Fin m)) (a : Fin m) :
S.erase a = left S a ∪ right S a := by
ext x
simp only [left, right, Finset.mem_erase, Finset.mem_union, Finset.mem_filter]
constructor
· rintro ⟨hne, hx⟩
exact (lt_or_gt_of_ne hne).imp (⟨hx, ·⟩) (⟨hx, ·⟩)
· rintro (⟨hx, hxa⟩ | ⟨hx, hax⟩)
· exact ⟨ne_of_lt hxa, hx⟩
· exact ⟨ne_of_gt hax, hx⟩
theorem split_separated (S : Finset (Fin m)) (a : Fin m) :
Separated (lineGraph m) (left S a) (right S a) := by
refine ⟨Finset.disjoint_left.mpr ?_, ?_⟩
· intro x hx hy
exact (lt_asymm (Finset.mem_filter.mp hx).2 (Finset.mem_filter.mp hy).2)
· intro x hx y hy hadj
have hx := (Finset.mem_filter.mp hx).2
have hy := (Finset.mem_filter.mp hy).2
change x.val < a.val at hx
change a.val < y.val at hy
change x.val + 1 = y.val ∨ y.val + 1 = x.val at hadj
omega
theorem Interval.left {S : Finset (Fin m)} (hS : Interval S) (a : Fin m) :
Interval (left S a) := by
intro x hx y hy c hxc hcy
obtain ⟨hx, _⟩ := Finset.mem_filter.mp hx
obtain ⟨hy, hya⟩ := Finset.mem_filter.mp hy
exact Finset.mem_filter.mpr ⟨hS x hx y hy c hxc hcy, hcy.trans_lt hya⟩
theorem Interval.right {S : Finset (Fin m)} (hS : Interval S) (a : Fin m) :
Interval (right S a) := by
intro x hx y hy c hxc hcy
obtain ⟨hx, hax⟩ := Finset.mem_filter.mp hx
obtain ⟨hy, _⟩ := Finset.mem_filter.mp hy
exact Finset.mem_filter.mpr ⟨hS x hx y hy c hxc hcy, hax.trans_le hxc⟩
theorem left_ssubset {S : Finset (Fin m)} {a : Fin m} (ha : a ∈ S) : left S a ⊂ S := by
exact Finset.ssubset_of_subset_of_ssubset (by rw [erase_eq_split]; exact Finset.subset_union_left)
(Finset.erase_ssubset ha)
theorem right_ssubset {S : Finset (Fin m)} {a : Fin m} (ha : a ∈ S) : right S a ⊂ S :=
Finset.ssubset_of_subset_of_ssubset (by rw [erase_eq_split]; exact Finset.subset_union_right)
(Finset.erase_ssubset ha)
/-- Consecutive gaps are connected in the induced path. -/
private theorem interval_reachable_le {S : Finset (Fin m)} (hS : Interval S)
(a b : {v // v ∈ S}) (hab : a.val ≤ b.val) :
((lineGraph m).induce (↑S : Set (Fin m))).Reachable a b := by
by_cases hEq : a = b
· rw [hEq]
· have hlt : a.val.val < b.val.val := by
exact lt_of_le_of_ne hab (fun h => hEq (Subtype.ext (Fin.ext h)))
let pred : Fin m := ⟨b.val.val - 1, by have := b.val.isLt; omega⟩
have haPred : a.val ≤ pred := by change a.val.val ≤ b.val.val - 1; omega
have hPredB : pred ≤ b.val := by change b.val.val - 1 ≤ b.val.val; omega
let c : {v // v ∈ S} := ⟨pred, hS a.val a.property b.val b.property pred haPred hPredB⟩
have hadj : ((lineGraph m).induce (↑S : Set (Fin m))).Adj c b := by
change pred.val + 1 = b.val.val ∨ b.val.val + 1 = pred.val
left
change b.val.val - 1 + 1 = b.val.val
omega
exact (interval_reachable_le hS a c haPred).trans hadj.reachable
termination_by b.val.val
decreasing_by omega
private theorem interval_reachable {S : Finset (Fin m)} (hS : Interval S)
(a b : {v // v ∈ S}) :
((lineGraph m).induce (↑S : Set (Fin m))).Reachable a b :=
(le_total a.val b.val).elim (interval_reachable_le hS a b)
(fun h => (interval_reachable_le hS b a h).symm)
private theorem walk_same_side {S A B : Finset (Fin m)} (hU : S ⊆ A ∪ B)
(hsep : Separated (lineGraph m) A B) {u v : {w // w ∈ S}}
(walk : ((lineGraph m).induce (↑S : Set (Fin m))).Walk u v) :
u.val ∈ A → v.val ∈ A := by
induction walk with
| nil => exact id
| @cons x y z hadj tail ih =>
intro hx
apply ih
exact (Finset.mem_union.mp (hU y.property)).resolve_right
(fun hy => hsep.2 x.val hx y.val hy hadj)
/-- An interval in a union of separated sets lies on one side. -/
theorem interval_subset_split {I A B : Finset (Fin m)} (hI : Interval I)
(hAB : I ⊆ A ∪ B) (hsep : Separated (lineGraph m) A B) : I ⊆ A ∨ I ⊆ B := by
by_cases h : ∃ a ∈ I, a ∈ A
· obtain ⟨a, haI, haA⟩ := h
left
intro b hbI
obtain ⟨walk⟩ := interval_reachable hI ⟨a, haI⟩ ⟨b, hbI⟩
exact walk_same_side hAB hsep walk haA
· right
intro b hbI
exact (Finset.mem_union.mp (hAB hbI)).resolve_left (fun hbA => h ⟨b, hbI, hbA⟩)
section Slacks
variable {K : Type*} [Field K]
/-- The nonsingleton intervals contained in a gap set, indexing its fixed kinematic terms. -/
noncomputable def intervalTerms (S : Finset (Fin m)) : Finset (Finset (Fin m)) := by
classical
exact S.powerset.filter fun I => 2 ≤ I.card ∧ Interval I
theorem mem_intervalTerms (I S : Finset (Fin m)) :
I ∈ intervalTerms S ↔ I ⊆ S ∧ 2 ≤ I.card ∧ Interval I := by
classical
simp [intervalTerms]
/-- The total fixed interval weight on the full gap set. -/
noncomputable def scale (c : Finset (Fin m) → K) : K :=
∑ I ∈ intervalTerms Finset.univ, c I
/-- The kinematic slack, including the slacks of disconnected gap sets. -/
noncomputable def slack (c : Finset (Fin m) → K) (y : Fin m → K) (S : Finset (Fin m)) : K :=
(∑ a ∈ S, y a) - ∑ I ∈ intervalTerms S, c I
private theorem intervalTerms_split {A B : Finset (Fin m)}
(hsep : Separated (lineGraph m) A B) :
intervalTerms (A ∪ B) = intervalTerms A ∪ intervalTerms B := by
ext I
simp only [Finset.mem_union, mem_intervalTerms]
constructor
· rintro ⟨hsub, hcard, hconv⟩
exact (interval_subset_split hconv hsub hsep).imp
(fun h => ⟨h, hcard, hconv⟩) (fun h => ⟨h, hcard, hconv⟩)
· rintro (⟨hs, hc, hi⟩ | ⟨hs, hc, hi⟩)
· exact ⟨hs.trans Finset.subset_union_left, hc, hi⟩
· exact ⟨hs.trans Finset.subset_union_right, hc, hi⟩
private theorem intervalTerms_disjoint {A B : Finset (Fin m)} (h : Disjoint A B) :
Disjoint (intervalTerms A) (intervalTerms B) := by
rw [Finset.disjoint_left]
intro I hIA hIB
obtain ⟨hsA, hc, _⟩ := (mem_intervalTerms I A).mp hIA
have hsB := ((mem_intervalTerms I B).mp hIB).1
obtain ⟨x, hx⟩ := Finset.card_pos.mp (by omega : 0 < I.card)
exact Finset.disjoint_left.mp h (hsA hx) (hsB hx)
theorem slack_additive (c : Finset (Fin m) → K) (y : Fin m → K) :
AdditiveOn (lineGraph m) (slack c y) Finset.univ := by
intro A B _ hsep
unfold slack
rw [intervalTerms_split hsep, Finset.sum_union hsep.1,
Finset.sum_union (intervalTerms_disjoint hsep.1), add_sub_add_comm]
theorem slack_full (c : Finset (Fin m) → K) (y : Fin m → K)
(hy : ∑ a, y a = scale c) : slack c y Finset.univ = 0 := by
exact sub_eq_zero.mpr hy
@[simp] theorem slack_singleton (c : Finset (Fin m) → K) (y : Fin m → K) (a : Fin m) :
slack c y {a} = y a := by
have hEmpty : intervalTerms ({a} : Finset (Fin m)) = ∅ := by
apply Finset.eq_empty_iff_forall_notMem.mpr
intro I hI
obtain ⟨hsub, hcard, _⟩ := (mem_intervalTerms I {a}).mp hI
have hc := Finset.card_le_card hsub
rw [Finset.card_singleton] at hc
omega
simp [slack, hEmpty]
/-- A gap in a noninterval set splits it into two smaller, nonempty separated sets. -/
theorem split_of_not_interval {S : Finset (Fin m)} (h : ¬ Interval S) :
∃ x : Fin m, S = left S x ∪ right S x ∧ (left S x).Nonempty ∧
(right S x).Nonempty ∧ left S x ⊂ S ∧ right S x ⊂ S := by
classical
unfold Interval at h
push Not at h
obtain ⟨a, ha, b, hb, x, hax, hxb, hx⟩ := h
have hxl : a < x := lt_of_le_of_ne hax (fun he => hx (he ▸ ha))
have hxr : x < b := lt_of_le_of_ne hxb (fun he => hx (he.symm ▸ hb))
have h := erase_eq_split S x
rw [Finset.erase_eq_of_notMem hx] at h
have hleft : left S x ⊂ S := Finset.ssubset_iff_subset_ne.mpr
⟨Finset.filter_subset _ _, by
intro he
have hb' : b ∈ left S x := he.symm ▸ hb
exact lt_asymm hxr (Finset.mem_filter.mp hb').2⟩
have hright : right S x ⊂ S := Finset.ssubset_iff_subset_ne.mpr
⟨Finset.filter_subset _ _, by
intro he
have ha' : a ∈ right S x := he.symm ▸ ha
exact lt_asymm hxl (Finset.mem_filter.mp ha').2⟩
have hL : (left S x).Nonempty := ⟨a, Finset.mem_filter.mpr ⟨ha, hxl⟩⟩
have hR : (right S x).Nonempty := ⟨b, Finset.mem_filter.mpr ⟨hb, hxr⟩⟩
exact ⟨x, h, hL, hR, hleft, hright⟩
private theorem all_proper_of_intervals (D : Finset (Fin m) → K) (P : K → Prop)
(hAdditive : AdditiveOn (lineGraph m) D Finset.univ)
(hadd : ∀ a b, P a → P b → P (a + b))
(hI : ∀ S, S.Nonempty → S ≠ Finset.univ → Interval S → P (D S))
(S : Finset (Fin m)) (hs : S.Nonempty) (hp : S ≠ Finset.univ) : P (D S) := by
by_cases h : Interval S
· exact hI S hs hp h
· obtain ⟨x, hSplit, hL, hR, hleft, hright⟩ := split_of_not_interval h
have hlp : left S x ≠ Finset.univ :=
(Finset.ssubset_of_ssubset_of_subset hleft (Finset.subset_univ S)).ne
have hrp : right S x ≠ Finset.univ :=
(Finset.ssubset_of_ssubset_of_subset hright (Finset.subset_univ S)).ne
rw [hSplit, hAdditive (Finset.subset_univ _) (split_separated S x)]
exact hadd _ _ (all_proper_of_intervals D P hAdditive hadd hI _ hL hlp)
(all_proper_of_intervals D P hAdditive hadd hI _ hR hrp)
termination_by S.card
decreasing_by all_goals exact Finset.card_lt_card (by assumption)
section Ordered
variable [LinearOrder K] [IsStrictOrderedRing K]
/-- Nonnegativity on proper intervals is equivalent to nonnegativity on all proper
nonempty subsets, because each subset splits into separated runs. -/
theorem interval_nonneg_iff (D : Finset (Fin m) → K)
(hAdditive : AdditiveOn (lineGraph m) D Finset.univ) :
(∀ S, S.Nonempty → S ≠ Finset.univ → Interval S → 0 ≤ D S) ↔
(∀ S, S.Nonempty → S ≠ Finset.univ → 0 ≤ D S) :=
⟨all_proper_of_intervals D (0 ≤ ·) hAdditive (fun _ _ => add_nonneg),
fun h S hn hp _ => h S hn hp⟩
/-- Strict positivity on proper intervals is likewise sufficient for every proper subset. -/
theorem interval_pos_iff (D : Finset (Fin m) → K)
(hAdditive : AdditiveOn (lineGraph m) D Finset.univ) :
(∀ S, S.Nonempty → S ≠ Finset.univ → Interval S → 0 < D S) ↔
(∀ S, S.Nonempty → S ≠ Finset.univ → 0 < D S) :=
⟨all_proper_of_intervals D (0 < ·) hAdditive (fun _ _ => add_pos),
fun h S hn hp _ => h S hn hp⟩
theorem scale_pos (c : Finset (Fin m) → K) (hm : 2 ≤ m)
(hc : ∀ I ∈ intervalTerms Finset.univ, 0 < c I) : 0 < scale c := by
have hFull : Finset.univ ∈ intervalTerms (Finset.univ : Finset (Fin m)) := by
apply (mem_intervalTerms _ _).mpr
exact ⟨Finset.Subset.refl _, by simpa using hm, interval_univ m⟩
exact Finset.sum_pos hc ⟨_, hFull⟩
theorem singleton_proper (hm : 2 ≤ m) (a : Fin m) :
({a} : Finset (Fin m)) ≠ Finset.univ := by
intro h
have hc := congrArg Finset.card h
simp at hc
omega
/-- For nonnegative fixed weights and nonnegative coordinates summing to the scale,
each slack is bounded above by the scale. -/
theorem slack_upper (c : Finset (Fin m) → K) (y : Fin m → K)
(hc : ∀ I ∈ intervalTerms Finset.univ, 0 ≤ c I)
(hy : ∀ a, 0 ≤ y a) (hsum : ∑ a, y a = scale c) (S : Finset (Fin m)) :
slack c y S ≤ scale c := by
unfold slack
have hSum : 0 ≤ ∑ I ∈ intervalTerms S, c I := Finset.sum_nonneg fun I hI =>
hc I ((mem_intervalTerms I _).mpr ⟨Finset.subset_univ _, ((mem_intervalTerms I S).mp hI).2⟩)
calc
_ ≤ ∑ a ∈ S, y a := sub_le_self _ hSum
_ ≤ ∑ a, y a := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _)
(fun a _ _ => hy a)
_ = scale c := hsum
/-- Membership in the closed positive-slice region, expressed by its planar slacks. -/
def InRegion (c : Finset (Fin m) → K) (y : Fin m → K) : Prop :=
∀ S, S.Nonempty → S ≠ Finset.univ → Interval S → 0 ≤ slack c y S
/-- Strict positivity on the proper planar intervals. -/
def InInterior (c : Finset (Fin m) → K) (y : Fin m → K) : Prop :=
∀ S, S.Nonempty → S ≠ Finset.univ → Interval S → 0 < slack c y S
omit [IsStrictOrderedRing K] in
theorem InInterior.inRegion {c : Finset (Fin m) → K} {y : Fin m → K}
(hint : InInterior c y) : InRegion c y :=
fun S hn hp hi => (hint S hn hp hi).le
theorem positiveSlacks (c : Finset (Fin m) → K) (y : Fin m → K) (hm : 2 ≤ m)
(hc : ∀ I ∈ intervalTerms Finset.univ, 0 < c I) (hint : InInterior c y) :
WordChain.PositiveSlacks (slack c y) (scale c) :=
⟨scale_pos c hm hc, (interval_pos_iff _ (slack_additive c y)).mp hint⟩
theorem slack_upper_of_region (c : Finset (Fin m) → K) (y : Fin m → K) (hm : 2 ≤ m)
(hc : ∀ I ∈ intervalTerms Finset.univ, 0 ≤ c I)
(hsum : ∑ a, y a = scale c) (hR : InRegion c y) (S : Finset (Fin m)) :
slack c y S ≤ scale c := by
apply slack_upper c y hc _ hsum
intro a
simpa using hR {a} (Finset.singleton_nonempty a) (singleton_proper hm a) (interval_singleton a)
/-- On the positive slice, the kernel is entrywise nonnegative exactly on the closed
region cut out by the proper interval slacks. Its rows always sum to one. -/
theorem kernel_nonneg_iff_region (c : Finset (Fin m) → K) (y : Fin m → K) (hm : 2 ≤ m)
(hc : ∀ I ∈ intervalTerms Finset.univ, 0 < c I)
(hsum : ∑ a, y a = scale c) :
(∀ w v, 0 ≤ WordChain.kernel (slack c y) (scale c) w v) ↔ InRegion c y := by
have hC := scale_pos c hm hc
constructor
· intro hQ S hn hp _
exact WordChain.slacks_nonneg _ _ hC hQ S hn hp
· intro hR w v
exact WordChain.kernel_nonneg _ _ hC
((interval_nonneg_iff _ (slack_additive c y)).mp hR)
(fun S _ _ => slack_upper_of_region c y hm (fun I hI => (hc I hI).le) hsum hR S)
w v
/-- Inside the closed slice, the word chain is irreducible exactly where all proper
interval slacks are strictly positive. -/
theorem irreducible_iff_interior (c : Finset (Fin m) → K) (y : Fin m → K)
(hm : 2 ≤ m) (hc : ∀ I ∈ intervalTerms Finset.univ, 0 < c I)
(hR : InRegion c y) :
(∀ w v, Relation.ReflTransGen
(fun x z => 0 < WordChain.kernel (slack c y) (scale c) x z) w v) ↔
InInterior c y := by
have hm₀ : 0 < m := by omega
constructor
· intro hQ S hn hp hi
have h0 := hR S hn hp hi
by_contra! h
obtain ⟨w, hw⟩ := WordChain.exists_letters S hp
have hword : w.val ≠ [] := by
intro hnil
exact hn.ne_empty (by simpa [WordChain.letters, hnil] using hw.symm)
have hZero : slack c y (WordChain.letters w) = 0 := by
rw [hw]
exact le_antisymm h h0
exact WordChain.not_reaches_root_of_zero _ _ hm₀ w hword hZero (hQ _ _)
· intro hi w v
exact (WordChain.reaches_root _ _ (positiveSlacks c y hm hc hi) hm₀ w).trans
(WordChain.root_reaches _ _ hm₀ v)
end Ordered
end Slacks
end MarkovScattering.WordGeometry
Source