Shared-site coefficient context · Orderings
DefinitionMarkovScatteringCharged_Orderingsmarkov-scattering
Source context from the finite shared-site cubic model and its supporting definitions and checked lemmas.
Definition code
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Field.Defs
import Mathlib.Data.Finset.Dedup
import Mathlib.Data.Finset.Union
import Mathlib.Data.List.Permutation
open scoped BigOperators
namespace MarkovScattering
variable {V K : Type*} [DecidableEq V]
/-- Attach the final letter when orders are stored in reverse. -/
def prependLetter (a : V) : List V ↪ List V where
toFun := List.cons a
inj' := fun _ _ h => (List.cons.inj h).2
noncomputable section
/-- All orderings of a finite set, represented as lists in reverse prefix order. -/
def orders (S : Finset V) : Finset (List V) :=
S.toList.permutations.toFinset
/-- An ordering contains each element of the set exactly once. -/
theorem mem_orders (S : Finset V) (l : List V) :
l ∈ orders S ↔ l.Nodup ∧ l.toFinset = S := by
rw [orders, List.mem_toFinset, List.mem_permutations]
constructor
· intro hp
exact ⟨hp.nodup_iff.mpr S.nodup_toList,
(List.toFinset_eq_of_perm _ _ hp).trans S.toList_toFinset⟩
· rintro ⟨hn, he⟩
exact List.perm_of_nodup_nodup_toFinset_eq hn S.nodup_toList
(he.trans S.toList_toFinset.symm)
private theorem orders_eq_biUnion (S : Finset V) (h : S.Nonempty) :
orders S = S.attach.biUnion fun a => (orders (S.erase a.val)).map (prependLetter a.val) := by
ext l
rw [mem_orders]
constructor
· rcases l with _ | ⟨a, t⟩
· rintro ⟨_, he⟩
exact (h.ne_empty (by simpa using he.symm)).elim
· rintro ⟨hn, hs⟩
have ha : a ∈ S := by rw [← hs]; simp
have hat : a ∉ t.toFinset := fun hm =>
(List.nodup_cons.mp hn).1 (List.mem_toFinset.mp hm)
have hst : t.toFinset = S.erase a := by
rw [← hs, List.toFinset_cons, Finset.erase_insert hat]
exact Finset.mem_biUnion.mpr
⟨⟨a, ha⟩, Finset.mem_attach _ _, Finset.mem_map.mpr
⟨t, (mem_orders (S.erase a) t).mpr ⟨(List.nodup_cons.mp hn).2, hst⟩, rfl⟩⟩
· intro hl
obtain ⟨a, _, ha⟩ := Finset.mem_biUnion.mp hl
obtain ⟨t, ht, rfl⟩ := Finset.mem_map.mp ha
obtain ⟨hnt, hst⟩ := (mem_orders (S.erase a.val) t).mp ht
change (a.val :: t).Nodup ∧ (a.val :: t).toFinset = S
refine ⟨List.nodup_cons.mpr ⟨?_, hnt⟩, ?_⟩
· intro hat
have hm : a.val ∈ t.toFinset := List.mem_toFinset.mpr hat
rw [hst] at hm
exact Finset.notMem_erase a.val S hm
· simp [hst, Finset.insert_erase a.property]
variable [Field K]
/-- Multiplying the reciprocal weights of the nonempty suffix sets of a reversed order
gives the reciprocal weights of the nonempty prefixes of the forward order. -/
def orderWeight (D : Finset V → K) : List V → K
| [] => 1
| a :: t => (D ((a :: t).toFinset))⁻¹ * orderWeight D t
/-- The finite sum of reciprocal prefix products over the orderings of `S`. -/
def orderSum (D : Finset V → K) (S : Finset V) : K :=
∑ l ∈ orders S, orderWeight D l
@[simp] theorem orderSum_empty (D : Finset V → K) : orderSum D ∅ = 1 := by
simp [orderSum, orders, List.permutations_nil, orderWeight]
private theorem sum_orders_delete (f : List V → K) (S : Finset V) (hS : S.Nonempty) :
(∑ l ∈ orders S, f l) = ∑ a ∈ S, ∑ t ∈ orders (S.erase a), f (a :: t) := by
conv_lhs => rw [orders_eq_biUnion S hS]
rw [Finset.sum_biUnion]
· simp only [Finset.sum_map, prependLetter]
exact Finset.sum_attach S (fun a => ∑ t ∈ orders (S.erase a), f (a :: t))
· intro a _ b _ hab
rw [Function.onFun, Finset.disjoint_left]
intro l ha hb
obtain ⟨t, _, rfl⟩ := Finset.mem_map.mp ha
obtain ⟨u, _, he⟩ := Finset.mem_map.mp hb
exact hab (Subtype.ext ((List.cons.inj he).1.symm))
/-- Grouping the orderings by their last element factors out the full-set weight. -/
theorem orderSum_delete (D : Finset V → K) (S : Finset V) (hS : S.Nonempty) :
orderSum D S = (∑ a ∈ S, orderSum D (S.erase a)) / D S := by
unfold orderSum
rw [sum_orders_delete _ _ hS, div_eq_mul_inv, mul_comm _ ((D S)⁻¹), Finset.mul_sum]
apply Finset.sum_congr rfl
intro a ha
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro t ht
have hst := ((mem_orders (S.erase a) t).mp ht).2
have hs : (a :: t).toFinset = S := by
simpa [hst] using Finset.insert_erase ha
rw [orderWeight, hs]
/-- The reciprocal product sum over proper nonempty prefixes, omitting the full set. -/
def rootOrderSum (D : Finset V → K) (S : Finset V) : K :=
∑ l ∈ orders S, orderWeight D l.tail
/-- Each last element contributes one full order sum on the set remaining after deletion. -/
theorem rootOrderSum_delete (D : Finset V → K) (S : Finset V) (hS : S.Nonempty) :
rootOrderSum D S = ∑ a ∈ S, orderSum D (S.erase a) := by
unfold rootOrderSum orderSum
rw [sum_orders_delete _ _ hS]
rfl
end
end MarkovScattering
Source