cfahlgren1's picture
download
raw
20.8 kB
13
abbrev Word (α : Type u) := FreeMonoid α
14
abbrev Polynomial (K : Type v) (α : Type u) [Semiring K] := MonoidAlgebra K (Word α)
16
structure Table (α : Type u) where
body · 2 lines
  rep : Word α → Word α → Prop
  zero : Set (Word α)
22
noncomputable def monomial (w : Word α) : Polynomial K α := MonoidAlgebra.single w 1
24
@[simp] theorem monomial_one : monomial (K := K) (1 : Word α) = 1 := rfl
25
@[simp] theorem monomial_mul (u v : Word α) :
    monomial (K := K) (u * v) = monomial u * monomial v := by
proof · 1 line
  simp [monomial, MonoidAlgebra.single_mul_single]
33
abbrev Reach : Word α → Word α → Prop := conGen T.rep
35
def Vanishes (w : Word α) : Prop :=
body · 1 line
  ∃ p z s, z ∈ T.zero ∧ T.Reach w (p * z * s)
38
lemma reach_context {v w : Word α} (h : T.Reach v w) (p s : Word α) :
    T.Reach (p * v * s) (p * w * s) :=
proof · 2 lines
  (conGen T.rep).mul ((conGen T.rep).mul ((conGen T.rep).refl p) h)
    ((conGen T.rep).refl s)
43
lemma vanishes_of_reach {v w : Word α} (h : T.Reach v w) (hw : T.Vanishes w) :
    T.Vanishes v := by
proof · 2 lines
  obtain ⟨p, z, s, hz, hr⟩ := hw
  exact ⟨p, z, s, hz, (conGen T.rep).trans h hr⟩
48
def relations : Set (Polynomial K α) :=
body · 2 lines
  {f | (∃ v w, T.rep v w ∧ f = monomial v - monomial w) ∨
    (∃ z ∈ T.zero, f = monomial z)}
52
abbrev ideal : TwoSidedIdeal (Polynomial K α) := TwoSidedIdeal.span T.relations
54
abbrev Algebra := (T.ideal (K := K)).ringCon.Quotient
56
noncomputable abbrev quotient : Polynomial K α →+* T.Algebra (K := K) :=
body · 1 line
  (T.ideal (K := K)).ringCon.mk'
59
noncomputable def word (w : Word α) : T.Algebra (K := K) := T.quotient (monomial w)
61
@[simp] theorem word_one : T.word (K := K) 1 = 1 := map_one T.quotient
63
@[simp] theorem word_mul (v w : Word α) :
    T.word (K := K) (v * w) = T.word v * T.word w := by
proof · 1 line
  rw [word, monomial_mul, map_mul]; rfl
67
lemma word_rep {v w : Word α} (h : T.rep v w) : T.word (K := K) v = T.word w := by
proof · 3 lines
  apply ((T.ideal (K := K)).ringCon.eq).mpr
  apply ((T.ideal (K := K)).rel_iff _ _).mpr
  exact TwoSidedIdeal.subset_span (Or.inl ⟨v, w, h, rfl⟩)
72
lemma word_reach {v w : Word α} (h : T.Reach v w) : T.word (K := K) v = T.word w := by
proof · 9 lines
  let f : Word α →* T.Algebra (K := K) :=
    { toFun := T.word
      map_one' := T.word_one
      map_mul' := T.word_mul }
  have hc : conGen T.rep ≤ Con.ker f := by
    apply Con.conGen_le.mpr
    intro a b hab
    exact T.word_rep hab
  exact hc h
83
lemma word_zero {z : Word α} (hz : z ∈ T.zero) : T.word (K := K) z = 0 := by
proof · 2 lines
  apply ((T.ideal (K := K)).ringCon.eq).mpr
  exact TwoSidedIdeal.subset_span (Or.inr ⟨z, hz, rfl⟩)
87
lemma word_eq_zero_of_vanishes {w : Word α} (h : T.Vanishes w) : T.word (K := K) w = 0 := by
proof · 2 lines
  obtain ⟨p, z, s, hz, hr⟩ := h
  rw [T.word_reach hr, word_mul, word_mul, T.word_zero hz, mul_zero, zero_mul]
91
noncomputable def detect (target : Word α) : Polynomial K α →+ K := by
body · 4 lines
  classical
  exact (Finsupp.liftAddHom (fun w : Word α =>
    if T.Reach target w then AddMonoidHom.id K else 0)).comp
      MonoidAlgebra.coeffAddEquiv.toAddMonoidHom
97
@[simp] lemma detect_single (target w : Word α) (a : K) :
    T.detect target (MonoidAlgebra.single w a) = if T.Reach target w then a else 0 := by
proof · 5 lines
  classical
  change (Finsupp.liftAddHom (fun v : Word α =>
    if T.Reach target v then AddMonoidHom.id K else 0)) (Finsupp.single w a) = _
  rw [Finsupp.liftAddHom_apply_single]
  split <;> simp_all
105
@[simp] lemma detect_self (w : Word α) : T.detect w (monomial (K := K) w) = 1 := by
proof · 1 line
  rw [monomial, detect_single, ite_eq_left ((conGen T.rep).refl w)]
108
lemma detect_eq_of_reach (target : Word α) {v w : Word α} (h : T.Reach v w) (a : K) :
    T.detect target (MonoidAlgebra.single v a) =
      T.detect target (MonoidAlgebra.single w a) := by
proof · 5 lines
  classical
  have he : T.Reach target v ↔ T.Reach target w :=
    ⟨fun ht => (conGen T.rep).trans ht h,
     fun ht => (conGen T.rep).trans ht ((conGen T.rep).symm h)⟩
  simp only [detect_single, he]
117
def annihilator (L : Polynomial K α →+ K) : TwoSidedIdeal (Polynomial K α) :=
body · 6 lines
  TwoSidedIdeal.mk' {f | ∀ a b, L (a * f * b) = 0}
    (by intro a b; simp)
    (by intro f g hf hg a b; simp [mul_add, add_mul, hf a b, hg a b])
    (by intro f hf a b; simp [hf a b])
    (by intro f g hg a b; simpa only [mul_assoc] using hg (a * f) b)
    (by intro f g hf a b; simpa only [mul_assoc] using hf a (g * b))
125
@[simp] lemma mem_annihilator (L : Polynomial K α →+ K) (f : Polynomial K α) :
    f ∈ annihilator L ↔ ∀ a b, L (a * f * b) = 0 := by simp [annihilator]
128
lemma relation_in_annihilator (target : Word α) (hnz : ¬ T.Vanishes target)
    {f : Polynomial K α} (hf : f ∈ T.relations) : f ∈ annihilator (T.detect target) := by
proof · 20 lines
  classical
  apply (mem_annihilator _ _).mpr
  intro A B
  induction A using MonoidAlgebra.induction_linear with
  | zero => simp
  | add A₁ A₂ h₁ h₂ => simp [add_mul, h₁, h₂]
  | single p a =>
    induction B using MonoidAlgebra.induction_linear with
    | zero => simp
    | add B₁ B₂ h₁ h₂ => simp [mul_add, h₁, h₂]
    | single s b =>
      rcases hf with ⟨v, w, hvw, rfl⟩ | ⟨z, hz, rfl⟩
      · simp only [monomial, mul_sub, sub_mul, MonoidAlgebra.single_mul_single,
          mul_one, map_sub]
        exact sub_eq_zero.mpr (T.detect_eq_of_reach target
          (T.reach_context (ConGen.Rel.of _ _ hvw) p s) (a * b))
      · simp only [monomial, MonoidAlgebra.single_mul_single, mul_one, detect_single]
        apply ite_eq_right
        intro hr
        exact hnz ⟨p, z, s, hz, hr⟩
151
lemma ideal_le_annihilator (target : Word α) (hnz : ¬ T.Vanishes target) :
    T.ideal (K := K) ≤ annihilator (T.detect target) :=
proof · 1 line
  TwoSidedIdeal.span_le.mpr (fun _ hf => T.relation_in_annihilator target hnz hf)
155
theorem word_ne_zero [Nontrivial K] {w : Word α} (hw : ¬ T.Vanishes w) :
    T.word (K := K) w ≠ 0 := by
proof · 5 lines
  intro h
  have hm : monomial (K := K) w ∈ T.ideal := ((T.ideal (K := K)).ringCon.eq).mp h
  have hd := (mem_annihilator (T.detect w) _).mp (T.ideal_le_annihilator w hw hm) 1 1
  simp only [one_mul, mul_one, detect_self] at hd
  exact one_ne_zero hd
163
theorem word_eq_zero_iff [Nontrivial K] (w : Word α) :
    T.word (K := K) w = 0 ↔ T.Vanishes w :=
proof · 1 line
  ⟨fun h => by by_contra hn; exact T.word_ne_zero hn h, T.word_eq_zero_of_vanishes⟩
167
theorem word_eq_word_iff [Nontrivial K] (v w : Word α) :
    T.word (K := K) v = T.word w ↔
      T.Reach v w ∨ (T.Vanishes v ∧ T.Vanishes w) := by
proof · 17 lines
  constructor
  · intro h
    by_cases hv : T.Vanishes v
    · right
      exact ⟨hv, (T.word_eq_zero_iff w).mp (h.symm.trans (T.word_eq_zero_of_vanishes hv))⟩
    · left
      by_contra hr
      have hm : monomial (K := K) v - monomial w ∈ T.ideal :=
        ((T.ideal (K := K)).rel_iff _ _).mp (((T.ideal (K := K)).ringCon.eq).mp h)
      have hd := (mem_annihilator (T.detect v) _).mp
        (T.ideal_le_annihilator v hv hm) 1 1
      simp only [one_mul, mul_one, map_sub, monomial, detect_single,
        ite_eq_left ((conGen T.rep).refl v), ite_eq_right hr, sub_zero] at hd
      exact one_ne_zero hd
  · rintro (hr | ⟨hv, hw⟩)
    · exact T.word_reach hr
    · exact (T.word_eq_zero_of_vanishes hv).trans (T.word_eq_zero_of_vanishes hw).symm
188
def Homogeneous : Prop := ∀ v w, T.rep v w → v.length = w.length
190
lemma length_eq_of_reach (hh : T.Homogeneous) {v w : Word α} (h : T.Reach v w) :
    v.length = w.length := by
proof · 6 lines
  let C : Con (Word α) :=
    { r := fun v w => v.length = w.length
      iseqv := ⟨fun _ => rfl, Eq.symm, Eq.trans⟩
      mul' := by intro a b c d h₁ h₂; simp only [FreeMonoid.length_mul, h₁, h₂] }
  have hC : conGen T.rep ≤ C := Con.conGen_le.mpr hh
  exact hC h
199
lemma not_vanishes_one (hh : T.Homogeneous) (hz : ∀ z ∈ T.zero, z ≠ 1) :
    ¬ T.Vanishes 1 := by
proof · 5 lines
  rintro ⟨p, z, s, hzero, hreach⟩
  have hl := T.length_eq_of_reach hh hreach
  simp only [FreeMonoid.length_one, FreeMonoid.length_mul] at hl
  have : z.length = 0 := by omega
  exact hz z hzero (FreeMonoid.length_eq_zero.mp this)
207
theorem nontrivial_algebra [Nontrivial K] (hh : T.Homogeneous)
    (hz : ∀ z ∈ T.zero, z ≠ 1) : Nontrivial (T.Algebra (K := K)) := by
proof · 3 lines
  have h := T.word_ne_zero (K := K) (T.not_vanishes_one hh hz)
  rw [word_one] at h
  exact ⟨⟨1, 0, h⟩⟩
213
theorem infinite_algebra [Nontrivial K] (hh : T.Homogeneous)
    (hw : ∀ N : ℕ, ∃ w : Word α, N < w.length ∧ ¬ T.Vanishes w) :
    Infinite (T.Algebra (K := K)) := by
proof · 10 lines
  obtain ⟨φ, hφ, hwφ⟩ := Nat.exists_strictMono_subsequence
    (P := fun n => ∃ w : Word α, w.length = n ∧ ¬ T.Vanishes w)
    (fun N => by obtain ⟨w, hn, hsurv⟩ := hw N; exact ⟨w.length, hn, w, rfl, hsurv⟩)
  choose w hwlen hwsurv using hwφ
  apply Infinite.of_injective (fun n => T.word (K := K) (w n))
  intro m n he
  rcases (T.word_eq_word_iff _ _).mp he with hreach | hzero
  · apply hφ.injective
    simpa only [hwlen] using T.length_eq_of_reach hh hreach
  · exact (hwsurv m hzero.1).elim
236
lemma step_context {v w : List (Raw h)} (he : Step hh S d v w) (p s : List (Raw h)) :
    Step hh S d (p++v++s) (p++w++s) := by
proof · 2 lines
  obtain ⟨a,b,c,e,rfl,rfl,he⟩ := he
  exact ⟨p++a,b++s,c,e,by simp [List.append_assoc],by simp [List.append_assoc],he⟩
240
lemma reach_context {v w : List (Raw h)} (he : Reach hh S d v w) (p s : List (Raw h)) :
    Reach hh S d (p++v++s) (p++w++s) := by
proof · 3 lines
  induction he with
  | refl => exact .refl
  | tail h e ih => exact ih.tail (step_context e p s)
245
lemma reach_symm {v w : List (Raw h)} (he : Reach hh S d v w) : Reach hh S d w v := by
proof · 3 lines
  induction he with
  | refl => exact .refl
  | tail h e ih => exact (Relation.ReflTransGen.single (step_symm e)).trans ih
250
def algebraTable (hh : 0<h) (S : Schedule (2^h)) (d : ℕ) : WordAlgebra.Table (Raw h) where
body · 2 lines
  rep := fun v w => replacement hh S d v.toList w.toList
  zero := {w | zero hh S d w.toList}
253
def reachCon (hh : 0<h) (S : Schedule (2^h)) (d : ℕ) : Con (FreeMonoid (Raw h)) where
body · 10 lines
  r v w := Reach hh S d v.toList w.toList
  iseqv := ⟨fun _ => .refl,fun h => reach_symm h,fun h k => h.trans k⟩
  mul' := by
    intro a b c e hab hce
    change Reach hh S d (a.toList++c.toList) (b.toList++e.toList)
    have h₁ : Reach hh S d (a.toList++c.toList) (b.toList++c.toList) := by
      simpa using reach_context hab [] c.toList
    have h₂ : Reach hh S d (b.toList++c.toList) (b.toList++e.toList) := by
      simpa using reach_context hce b.toList []
    exact h₁.trans h₂
264
lemma reach_iff_table {v w : List (Raw h)} :
    Reach hh S d v w ↔ (algebraTable hh S d).Reach (FreeMonoid.ofList v) (FreeMonoid.ofList w) := by
proof · 17 lines
  constructor
  · intro hr
    induction hr with
    | refl => exact (conGen (algebraTable hh S d).rep).refl _
    | tail h e ih =>
      obtain ⟨p,s,a,b,rfl,rfl,he⟩ := e
      apply (conGen (algebraTable hh S d).rep).trans ih
      exact (conGen (algebraTable hh S d).rep).mul
        ((conGen (algebraTable hh S d).rep).mul ((conGen (algebraTable hh S d).rep).refl (FreeMonoid.ofList p))
          (ConGen.Rel.of (FreeMonoid.ofList a) (FreeMonoid.ofList b) he))
        ((conGen (algebraTable hh S d).rep).refl (FreeMonoid.ofList s))
  · intro h
    have hle : conGen (algebraTable hh S d).rep ≤ reachCon hh S d := by
      apply Con.conGen_le.mpr
      intro a b he
      exact Relation.ReflTransGen.single ⟨[],[],a.toList,b.toList,by simp,by simp,he⟩
    exact hle h
283
lemma survives_iff_not_vanishes (w : List (Raw h)) :
    Survives hh S d w ↔ ¬(algebraTable hh S d).Vanishes (FreeMonoid.ofList w) := by
proof · 6 lines
  constructor
  · intro hw ⟨p,z,s,hz,hr⟩
    have he : Reach hh S d w (p.toList++z.toList++s.toList) := reach_iff_table.mpr hr
    exact hw p.toList z.toList s.toList he hz
  · intro hw p z s hr hz
    exact hw ⟨FreeMonoid.ofList p,FreeMonoid.ofList z,FreeMonoid.ofList s,hz,reach_iff_table.mp hr⟩
291
lemma algebraTable_homogeneous (hh4 : 4≤h) : (algebraTable hh S d).Homogeneous := by
proof · 2 lines
  intro v w he
  exact (replacement_lengths hh4 S d v.toList w.toList he).1
299
def table (h : ℕ) (hh : A.threshold≤h) :=
body · 1 line
  Codec.algebraTable (A.height_pos hh) (A.schedule h hh) (10000*(D*h))
302
abbrev Algebra (K : Type*) [Ring K] (h : ℕ) (hh : A.threshold≤h) := (A.table h hh).Algebra (K:=K)
304
theorem infinite_algebra (K : Type*) [Ring K] [Nontrivial K] (h : ℕ) (hh : A.threshold≤h) :
    Infinite (A.Algebra K h hh) := by
proof · 5 lines
  apply (A.table h hh).infinite_algebra
  · exact Codec.algebraTable_homogeneous (A.threshold_four.trans hh)
  · intro N
    obtain ⟨w,hw,hs⟩ := A.unbounded_survivors N h hh
    exact ⟨FreeMonoid.ofList w,hw,Codec.survives_iff_not_vanishes w |>.mp hs⟩
320
noncomputable def alternatingSum {d m : ℕ} (X : Fin m → Matrix (Fin d) (Fin d) K) :
    Matrix (Fin d) (Fin d) K :=
body · 1 line
  ∑ σ : Equiv.Perm (Fin m), (List.ofFn (X ∘ σ)).prod
324
theorem alternating_eq_zero_of_card_lt {S : Type u} [CommSemiring S]
    {V : Type v} [AddCommMonoid V] [Module S V]
    {W : Type w} [AddCommMonoid W] [Module S W]
    {ι κ : Type*} [Fintype ι] [Fintype κ]
    (b : Module.Basis κ S V) (f : AlternatingMap S V W ι)
    (h : Fintype.card κ < Fintype.card ι) : f = 0 := by
proof · 3 lines
  apply b.ext_alternating
  intro t ht
  exact ((not_le_of_gt h) (Fintype.card_le_of_injective t ht)).elim
334
lemma sign_smul_matrix {d : ℕ} (σ : ℤˣ) (X : Matrix (Fin d) (Fin d) K) :
    σ • X = X := by
proof · 7 lines
  rcases Int.units_eq_one_or σ with h | h
  · rw [h, one_smul]
  · rw [h, Units.smul_def]
    change (-1 : ℤ) • X = X
    rw [neg_one_zsmul]
    ext i j
    exact CharTwo.neg_eq (X i j)
344
theorem alternatingSum_eq_zero {d m : ℕ}
    (X : Fin m → Matrix (Fin d) (Fin d) K) (h : d ^ 2 < m) :
    alternatingSum X = 0 := by
proof · 9 lines
  let f := MultilinearMap.mkPiAlgebraFin K m (Matrix (Fin d) (Fin d) K)
  have hz : MultilinearMap.alternatization f = 0 :=
    alternating_eq_zero_of_card_lt (Matrix.stdBasis K (Fin d) (Fin d)) _ (by
      simpa only [Fintype.card_prod, Fintype.card_fin, pow_two] using h)
  have hv := congrArg (fun F : AlternatingMap K
    (Matrix (Fin d) (Fin d) K) (Matrix (Fin d) (Fin d) K) (Fin m) => F X) hz
  simpa only [MultilinearMap.alternatization_apply, MultilinearMap.domDomCongr_apply,
    sign_smul_matrix, MultilinearMap.mkPiAlgebraFin_apply, AlternatingMap.zero_apply,
    alternatingSum, Function.comp_def, f] using hv
366
def chunkWeight {d : ℕ} (W : Γ → Matrix (Fin d) (Fin d) K) (s : List Γ) :=
body · 1 line
  (s.map W).prod
370
lemma chunkWeight_append {d : ℕ} (W : Γ → Matrix (Fin d) (Fin d) K) (s t : List Γ) :
    chunkWeight W (s ++ t) = chunkWeight W s * chunkWeight W t := by
proof · 1 line
  simp [chunkWeight]
374
structure Packet (Γ : Type*) where
body · 3 lines
  before : List Γ
  inside : List Γ
  after : List Γ
379
def Packet.join (p : Packet Γ) : List Γ := p.before ++ p.inside ++ p.after
381
def Packet.key (p : Packet Γ) : List Γ × List Γ × Multiset Γ :=
body · 1 line
  (p.before, p.after, p.inside)
384
lemma perm_of_key_eq {p q : Packet Γ} (h : p.key = q.key) :
    p.before = q.before ∧ p.after = q.after ∧ p.inside.Perm q.inside := by
proof · 4 lines
  have hp := congrArg Prod.fst h
  have hq := congrArg (fun x => x.2.1) h
  have hi := congrArg (fun x => x.2.2) h
  exact ⟨hp, hq, Quotient.exact hi⟩
391
lemma packet_perm_exists (s : List Γ) (hs : s.Nodup) (t : List Γ) (ht : t.Perm s) :
    ∃ σ : Equiv.Perm (Fin s.length), List.ofFn (s.get ∘ σ) = t := by
proof · 25 lines
  let f : Fin t.length → Γ := t.get
  have hlen := ht.length_eq
  let e : Fin t.length ≃ Fin s.length := finCongr hlen
  have hf : Function.Injective f := List.nodup_iff_injective_get.mp (ht.nodup_iff.mpr hs)
  have hg : Function.Injective s.get := List.nodup_iff_injective_get.mp hs
  let τ : Fin t.length ≃ Fin s.length := Equiv.ofBijective
    (fun i => ⟨s.idxOf (t.get i), List.idxOf_lt_length_iff.mpr (ht.mem_iff.mp (List.get_mem t i))⟩)
    (by
      constructor
      · intro i j hij
        apply hf
        have hij' := congrArg (fun x : Fin s.length => s.get x) hij
        simpa [f] using hij'
      · intro j
        have hm : s.get j ∈ t := ht.mem_iff.mpr (List.get_mem s j)
        refine ⟨⟨t.idxOf (s.get j), List.idxOf_lt_length_iff.mpr hm⟩, ?_⟩
        apply hg
        simp)
  refine ⟨e.symm.trans τ, ?_⟩
  apply List.ext_getElem
  · simp
    exact hlen.symm
  · intro i hi hj
    simp only [List.getElem_ofFn, Function.comp_apply, Equiv.trans_apply]
    simp [τ, e]
419
lemma packet_perm_injective (s : List Γ) (hs : s.Nodup) :
    Function.Injective (fun σ : Equiv.Perm (Fin s.length) => List.ofFn (s.get ∘ σ)) := by
proof · 5 lines
  intro σ τ h
  have he := List.ofFn_injective h
  apply Equiv.ext
  intro i
  exact List.nodup_iff_injective_get.mp hs (congrFun he i)
427
lemma sum_packet_permutations {d : ℕ} (W : Γ → Matrix (Fin d) (Fin d) K)
    (s : List Γ) (hm : d^2 < s.length) :
    (∑ σ : Equiv.Perm (Fin s.length), chunkWeight W (List.ofFn (s.get ∘ σ))) = 0 := by
proof · 2 lines
  simpa only [chunkWeight, List.map_ofFn, Function.comp_def, alternatingSum] using
    (alternatingSum_eq_zero (fun i : Fin s.length => W (s.get i)) hm)
433
def Packet.reorder (p : Packet Γ) (σ : Equiv.Perm (Fin p.inside.length)) : List Γ :=
body · 1 line
  p.before ++ List.ofFn (p.inside.get ∘ σ) ++ p.after
436
lemma Packet.reorder_injective (p : Packet Γ) (hp : p.inside.Nodup) :
    Function.Injective p.reorder := by
proof · 3 lines
  intro σ τ h
  apply packet_perm_injective p.inside hp
  exact List.append_cancel_left (List.append_cancel_right h)
442
lemma Packet.reorder_one (p : Packet Γ) : p.reorder 1 = p.join := by
proof · 1 line
  simp [Packet.reorder, Packet.join]
445
lemma sum_reorder_weight {d : ℕ} (W : Γ → Matrix (Fin d) (Fin d) K)
    (p : Packet Γ) (hm : d^2 < p.inside.length) :
    (∑ σ : Equiv.Perm (Fin p.inside.length), chunkWeight W (p.reorder σ)) = 0 := by
proof · 3 lines
  simp only [Packet.reorder, chunkWeight_append]
  rw [← Finset.sum_mul, ← Finset.mul_sum, sum_packet_permutations W p.inside hm,
    mul_zero, zero_mul]
452
theorem packet_cancellation {d : ℕ} {V : Type*} [AddCommGroup V] [Module K V]
    (S : Finset (List Γ)) (W : Γ → Matrix (Fin d) (Fin d) K)
    (value : List Γ → V) (pick : List Γ → Packet Γ)
    (joins : ∀ s ∈ S, (pick s).join = s)
    (nodup : ∀ s ∈ S, (pick s).inside.Nodup)
    (long : ∀ s ∈ S, d^2 < (pick s).inside.length)
    (closed : ∀ s ∈ S, ∀ σ, (pick s).reorder σ ∈ S)
    (stable : ∀ s ∈ S, ∀ σ, (pick ((pick s).reorder σ)).key = (pick s).key)
    (same_value : ∀ s ∈ S, ∀ σ, value ((pick s).reorder σ) = value s)
    (i j : Fin d) :
    (∑ s ∈ S, chunkWeight W s i j • value s) = 0 := by
proof · 29 lines
  let key := fun s => (pick s).key
  rw [← Finset.sum_fiberwise_of_maps_to (s := S) (t := S.image key)
    (fun s hs => Finset.mem_image.mpr ⟨s, hs, rfl⟩)
    (fun s => chunkWeight W s i j • value s)]
  apply Finset.sum_eq_zero
  intro z hz
  obtain ⟨s,hs,rfl⟩ := Finset.mem_image.mp hz
  have hfiber : S.filter (fun t => key t = key s) =
      Finset.univ.image (pick s).reorder := by
    ext t
    constructor
    · intro ht
      obtain ⟨htS,htkey⟩ := Finset.mem_filter.mp ht
      obtain ⟨hb,ha,hp⟩ := perm_of_key_eq htkey
      obtain ⟨σ,hσ⟩ := packet_perm_exists (pick s).inside (nodup s hs) (pick t).inside hp
      refine Finset.mem_image.mpr ⟨σ,Finset.mem_univ _,?_⟩
      rw [Packet.reorder, hσ, ← hb, ← ha]
      exact joins t htS
    · intro ht
      obtain ⟨σ,_,rfl⟩ := Finset.mem_image.mp ht
      exact Finset.mem_filter.mpr ⟨closed s hs σ, stable s hs σ⟩
  rw [hfiber, Finset.sum_image]
  · simp_rw [same_value s hs]
    rw [← Finset.sum_smul]
    have hw := congrArg (fun A : Matrix (Fin d) (Fin d) K => A i j)
      (sum_reorder_weight W (pick s) (long s hs))
    simp only [Matrix.sum_apply, Matrix.zero_apply] at hw
    rw [hw, zero_smul]
  · exact (Packet.reorder_injective (pick s) (nodup s hs)).injOn

Xet Storage Details

Size:
20.8 kB
·
Xet hash:
fa8e8bbdc30f45e9f874b8117d3c0aa8950c6571e587cee31a400724ae7d9787

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.