toFun :=fun b =>if b then some () else none
invFun :=fun o => o.isSome
left_inv b :=by cases b <;> rfl
right_inv o :=by cases o with | none => rfl | some u => cases u; rfl
theoremweight_count (w : FreeMonoidSlot) : degree weight w=2*degree acCount w+degree bCount w :=by
proof · 5
lines
induction w usingFreeMonoid.inductionOn' with
| one => simp
| of_mul a w ih =>
simp only [degree_mul,degree_of,ih]
cases a <;> simp [weight,acCount,bCount,aCount,cCount] <;> omega
theoremeval_comp (a b c d : FreeLieAlgebraRBool) (q : FreeLieAlgebraRBool) :
eval a b (eval c d q)=eval (eval a b c) (eval a b d) q :=AssociativeEvaluation.map_eval _ _ _ _
theoremdeletion_special {q : FreeLieAlgebraKBool}
(ha : antisymmetry q=0) (hs : special q=0) :
⁅(x : FreeLieAlgebraKBool),q+eval (x+y) y q⁆+⁅(y : FreeLieAlgebraKBool),eval (x+y) y q⁆=0:=by
proof · 6
lines
havehswap : eval y x q=q :=by
exact (TwoModule.eq_of_add_zero ha).symm
havehswap2 : eval y (x+y) q=eval (x+y) y q :=TwoModule.eq_of_add_zero (swapped ha y (x+y))
simp only [special,TwoModule.neg_eq,TwoModule.sub_eq_add,hswap,hswap2,add_lie] at hs
simpa only [lie_add,add_assoc] using hs
theoremderiv_lower (wt : α →ℕ) (c : ℕ) (f : α →AR α)
(hf : ∀ a,f a∈lower wt c (wt a)) {n : ℕ} {p : AR α}
(hp : p∈homogeneous wt n) : deriv f p∈lower wt c n :=by
proof · 10
lines
have hw (w : FreeMonoid α) : deriv f (word w)∈lower wt c (degree wt w) :=by
induction w usingFreeMonoid.inductionOn' with
| one => simp
| of_mul a w ih =>
rw [word_mul,word_of,AssociativeElimination.deriv_mul,deriv_atom]
simp only [degree_mul,degree_of]
exact (lower wt c _).add_mem
(lower_mul_homogeneous (hf a) (word_mem w rfl))
(homogeneous_mul_lower (word_mem (FreeMonoid.of a) (degree_of wt a)) ih)
exact map_space (deriv f) _ (by intro w h; simpa only [h] using hw w) hp
apply map_space (deriv f) _ ?_ hp
intro w hw
apply space_mono (P:=fun v => degree wt v+c=degree wt w) ?_
(deriv_lower wt c f hf (word_mem w rfl))
intro v hv
omega
have hg (a : Slot) : quad (delta a)=atom false*quad (atom a)-quad (atom a)*atom false:=by
cases a <;> simp only [delta,low,high,quad,lift_atom,map_add,map_mul,map_zero,
zero_add,add_zero,TwoModule.sub_eq_add,mul_add,add_mul]
· simp [mul_assoc,TwoModule.add_self]
· haveh : (atom false*atom true*atom false : AKBool)+atom false*atom true*atom false=0:=TwoModule.add_self _
simp only [mul_assoc] at h ⊢
apply eq_of_sub_eq_zero
calc _ = -(atom false*(atom true*atom false)+atom false*(atom true*atom false)) :=by abel
_ = 0:=by rw [h,neg_zero]
have hw (w : FreeMonoidSlot) : quad (deriv delta (word w))=atom false*quad (word w)-quad (word w)*atom false:=by
induction w usingFreeMonoid.inductionOn' with
| one => simp
| of_mul a w ih =>
rw [word_mul,word_of,AssociativeElimination.deriv_mul,map_add,map_mul,map_mul,deriv_atom,hg,ih,map_mul]
noncomm_ring
induction p usingMonoidAlgebra.induction_on with
| of w => exact hw w
| add p q hp hq => simp only [map_add,hp,hq,mul_add,add_mul]; abel
| smul c p hp => simp only [map_smul,hp,mul_smul_comm,smul_mul_assoc,smul_sub]
theoremembed_eval (a b : FreeLieAlgebraKBool) (ψ : FreeLieAlgebraKBool) :
embed (BaseChangeEquations.eval a b ψ)=algEval (embed a) (embed b) (embed ψ) :=by
apply QuadraticLeading.quad_injective
rw [map_zero,map_add,quad_delta,map_add,map_sub,map_mul,map_mul]
havehτ : quad (tau p)=embed (BaseChangeEquations.eval
(BaseChangeEquations.x+BaseChangeEquations.y) BaseChangeEquations.y ψ) :=by
rw [←AlgHom.comp_apply,quad_tau,AlgHom.comp_apply,hp,embed_eval]
simp only [map_add,BaseChangeEquations.x,BaseChangeEquations.y,embed_of]
rw [hp,hτ]
have h := congrArg embed (BaseChangeEquations.deletion_special ha hs)
simpa only [map_add,LieHom.map_lie,Ring.lie_def,map_zero,BaseChangeEquations.x,
BaseChangeEquations.y,embed_of,quad,lift_atom] using h
@[simp]theoremcoeff_atom_mul_cons (a b : Slot) (p : AKSlot) (s : ListSlot) :
coeff (atom a*p) (b::s)=if a=b then coeff p s else0:=by
proof · 12
lines
by_cases h : a=b
· subst b
change (MonoidAlgebra.single (FreeMonoid.of a) 1*p).coeff (FreeMonoid.of a*FreeMonoid.ofList s)=_
rw [MonoidAlgebra.coeff_single_mul_mul]
simp only [one_mul]
rfl
· rw [ite_eq_right h]
apply MonoidAlgebra.coeff_single_mul_of_forall_mul_ne
intro v hv
have he := congrArg FreeMonoid.toList hv
simp only [FreeMonoid.toList_mul,FreeMonoid.toList_of,FreeMonoid.toList_ofList,List.singleton_append] at he
exact h (List.cons.inj he).1
induction v generalizing s with
| nil => cases s <;> simp
| cons a v ih =>
obtain ⟨ha,hv'⟩ := noC_cons _ _ |>.mp hv
cases a with
| C=> exact (ha rfl).elim
| A=>
cases s with
| nil => simp [add_mul]
| cons b s => cases b <;> simp [add_mul,ih hv' s,collapse]
| B=>
cases s with
| nil => simp
| cons b s => cases b <;> simp [ih hv' s,collapse]
induction v generalizing s with
| nil =>
cases s with
| nil => simp [fills]
| cons a s =>
cases a <;> simp [fills,collapse,List.map_map,Function.comp_def]
| cons a v ih =>
obtain ⟨ha,hv'⟩ := noC_cons _ _ |>.mp hv
cases a with
| C=> exact (ha rfl).elim
| A=>
cases s with
| nil => simp [AssociativeElimination.deriv_mul,add_mul,low,fills]
| cons b s =>
cases b <;> simp [AssociativeElimination.deriv_mul,add_mul,low,fills,
ih hv' s,collapse,List.map_map,Function.comp_def]
| B=>
cases s with
| nil => simp [AssociativeElimination.deriv_mul,low,fills]
| cons b s =>
cases b <;> simp [AssociativeElimination.deriv_mul,low,fills,
ih hv' s,collapse,List.map_map,Function.comp_def,tau0_monomial_coeff v hv' s]
induction hp usingSubmodule.span_induction with
| mem p hp =>
obtain ⟨w,hw,rfl⟩ := hp
exact deriv_tau0_monomial_coeff w.toList hw s
| zero =>
simp only [map_zero]
change 0=(List.map (fun _ => (0 : K)) (fills s)).sum
simp
| add p q _ _ hp hq =>
simp only [map_add,coeff_add,hp,hq]
exact (List.sum_map_add ..).symm
| smul c p _ hp =>
simp only [map_smul,coeff_smul,hp]
exact (List.sum_map_mul_left ..).symm
theoremfills_prefix (u s : ListSlot) (hu : noC u) : fills (u++s)=(fills s).map (u++·) :=by
proof · 5
lines
induction u with
| nil => simp
| cons a u ih =>
obtain ⟨ha,hu'⟩ := (noC_cons a u).mp hu
simp [fills,ha,collapse_eq ha,ih hu',List.map_map,Function.comp_def]
theoremadjacent_exchange {p : AKSlot} (hp : p∈space (fun w => noC w.toList))
(he : deriv low (p+tau0 p)=0) (u v : ListSlot) (hu : noC u) (hv : noC v) :
coeff p (u++[Slot.A,Slot.B]++v)=coeff p (u++[Slot.B,Slot.A]++v) :=by
proof · 5
lines
havehc : 2≤count .C (u++[Slot.C,Slot.C]++v) :=by simp; omega
have h := fills_sum_zero hp he _ hc
rw [fills_two u v hu hv] at h
simp only [List.map_cons,List.map_nil,List.sum_cons,List.sum_nil,add_zero] at h
exact (TwoModule.eq_of_add_zero h).symm
theoremcoefficient_perm {p : AKSlot} (hp : p∈space (fun w => noC w.toList))
(he : deriv low (p+tau0 p)=0) {s t : ListSlot} (h : s.Perm t) (hs : noC s)
(u : ListSlot) (hu : noC u) : coeff p (u++s)=coeff p (u++t) :=by
proof · 15
lines
induction h generalizing u with
| nil => rfl
| @cons a s t h ih =>
obtain ⟨ha,hs'⟩ := (noC_cons a s).mp hs
havehuv : noC (u++[a]) := (noC_append _ _).mpr ⟨hu,by simpa using ha⟩
simpa only [List.append_assoc,List.singleton_append] using ih hs' (u++[a]) huv
| swap a b s =>
obtain ⟨ha,hbs⟩ := (noC_cons b (a::s)).mp hs
obtain ⟨hb,hss⟩ := (noC_cons a s).mp hbs
cases a <;> cases b
all_goals try first | exact (ha rfl).elim | exact (hb rfl).elim | rfl
· simpa only [List.append_assoc,List.cons_append,List.nil_append] using (adjacent_exchange hp he u s hu hss).symm
· simpa only [List.append_assoc,List.cons_append,List.nil_append] using adjacent_exchange hp he u s hu hss
| @trans s t v h₁ h₂ ih₁ ih₂ =>
exact (ih₁ hs u hu).trans (ih₂ ((noC_perm h₁).mp hs) u hu)
theoremtriple_zero {p : AKSlot} (hp : p∈space (fun w => noC w.toList))
(he : deriv low (p+tau0 p)=0) (u : ListSlot) (hu : noC u) :
coeff p (u++[Slot.B,Slot.A,Slot.A])=0:=by
proof · 11
lines
havehc : 2≤count .C (u++[Slot.C,Slot.C,Slot.C]++[]) :=by simp
have h := fills_sum_zero hp he _ hc
rw [fills_three u [] hu noC_nil] at h
simp only [List.append_nil,List.map_cons,List.map_nil,List.sum_cons,List.sum_nil,add_zero] at h
havehn1 : noC (u++[Slot.A,Slot.B,Slot.A]) :=by simpa using hu
havehn2 : noC (u++[Slot.A,Slot.A,Slot.B]) :=by simpa using hu
havehn3 : noC (u++[Slot.B,Slot.A,Slot.A]) :=by simpa using hu
have h1 := coefficient_eq_counts hp he hn1 hn3 (by simp) (by simp)
have h2 := coefficient_eq_counts hp he hn2 hn3 (by simp) (by simp)
rw [h1,h2,TwoModule.add_self,add_zero] at h
exact h
let u :=List.replicate (count .A s-2) Slot.A ++ List.replicate (count .B s-1) Slot.Bhavehu : noC u :=by
intro a ha
simp only [u,List.mem_append,List.mem_replicate] at ha
rcases ha with ⟨_,rfl⟩ | ⟨_,rfl⟩ <;> decide
haveht : noC (u++[Slot.B,Slot.A,Slot.A]) :=by simpa using hu
havehA : count .A s=count .A (u++[Slot.B,Slot.A,Slot.A]) :=by simp [u]; omega
havehB : count .B s=count .B (u++[Slot.B,Slot.A,Slot.A]) :=by simp [u]; omega
rw [coefficient_eq_counts hp he hs ht hA hB]
exact triple_zero hp he u hu
theoremsupport_of_mem {q : FreeLieAlgebraR α} (hq : q∈sub P) :
embed q∈space (fun w =>∀ a∈w.toList,P a) :=by
proof · 19
lines
have hm {p q : AR α}
(hp : p∈space (fun w =>∀ a∈w.toList,P a))
(hq : q∈space (fun w =>∀ a∈w.toList,P a)) :
p*q∈space (fun w =>∀ a∈w.toList,P a) :=by
apply mul_mem ?_ hp hq
intro u v hu hv a ha
simp only [FreeMonoid.toList_mul,List.mem_append] at ha
exact ha.elim (hu a) (hv a)
induction hq usingLieSubalgebra.lieSpan_induction with
| mem q hq =>
obtain ⟨a,ha,rfl⟩ := hq
rw [embed_of]
exact word_mem _ (by simpa using ha)
| zero => simp
| add p q _ _ hp hq => simpa only [map_add] using (space _).add_mem hp hq
| smul c p _ hp => simpa only [map_smul] using (space _).smul_mem c hp
| lie p q _ _ hp hq =>
rw [LieHom.map_lie]
exact (space _).sub_mem (hm hp hq) (hm hq hp)
havehe : acCount=(funa : Slot=>if a≠Slot.Bthen1else0) :=by funext a; cases a <;> rfl
rw [he] at hw
have h := (degree_indicator_zero (funa : Slot=> a≠Slot.B) w.toList).mp
(by simpa using hw)
intro a ha
exact not_ne_iff.mp (h a ha)
havehw : embed (p-q)∈homogeneous weight n :=by
simpa only [map_sub] using (homogeneous weight n).sub_mem hp hq
havehs : embed (p-q)∈space (fun w =>∀ a∈w.toList,a=Slot.B) :=by
apply mem_space
intro w hc
have h1 := mem_space_iff.mp hw w hc
have h2 := mem_space_iff.mp hh w (by simpa using hc)
have h3 := weight_count w
exact ac_zero w (by omega)
exact sub_eq_zero.mp (LetterRetraction.homogeneous_single_zero Slot.B (by simpa only [weight] using (byomega : n≠1)) hs hw)
theoremswap_quad_y (a : Slot) : swap (quad (atom a))∈homogeneous yWeight (xSlot a) :=by
proof · 13
lines
havehx : (atom false : AKBool)∈homogeneous yWeight 0:= word_mem _ rfl
havehy : (atom true : AKBool)∈homogeneous yWeight 1:= word_mem _ rfl
cases a with
| A=>
simp only [quad,lift_atom,map_mul,swap_atom]
have h := homogeneous_mul hy hy
exact h
| C=>
simp only [quad,lift_atom,map_sub,map_mul,swap_atom]
have h1 := homogeneous_mul hy hx
have h2 := homogeneous_mul hx hy
exact (homogeneous yWeight 1).sub_mem h1 h2
| B=> simpa only [quad,lift_atom,swap_atom,xSlot,Bool.not_true] using hx
havehY : embed p∈homogeneous ySlot r :=by
apply mem_space
intro w hw
rw [degree_congr_word w (g:=bCount) ?_]
· exact mem_space_iff.mp hb w hw
· intro a ha
have h := (mem_space_iff.mp hs w hw) a ha
cases a <;> simp_all [ySlot,bCount]
havehX : embed p∈homogeneous xSlot 2:=by
apply mem_space
intro w hw
rw [degree_congr_word w (g:=fun a =>2*acCount a) ?_,degree_scale]
· rw [mem_space_iff.mp ha w hw]
· intro a ha
have h := (mem_space_iff.mp hs w hw) a ha
cases a <;> simp_all [xSlot,acCount,aCount,cCount]
have h1 := algHom_homogeneous quad ySlot yWeight quad_y hY
have h2 := algHom_homogeneous (swap.comp quad) xSlot yWeight swap_quad_y hX
havehe : swap (under p)=under p :=by
rw [hp]
change ψ+BaseChangeEquations.eval BaseChangeEquations.y BaseChangeEquations.x ψ=0 at hanti
have h := congrArg embed ((TwoModule.eq_of_add_zero hanti).symm)
simpa only [ResidualKernel.embed_eval,BaseChangeEquations.x,BaseChangeEquations.y,embed_of,swap] using h
change swap (under p)∈_ at h2
rw [he] at h2
by_contra hne
apply hn
apply under_injective
rw [map_zero]
apply MonoidAlgebra.ext
apply Finsupp.ext
intro w
by_contra hw
exact hne ((mem_space_iff.mp h1 w hw).symm.trans (mem_space_iff.mp h2 w hw))
theoremoperator_collapse (p : AR (ℕ×α)) : operator (collapse p)=leftMul p :=by
proof · 6
lines
haveh : operator.comp collapse=(leftMul : AR (ℕ×α) →ₐ[R] Module.EndR (AR (ℕ×α))) :=by
apply hom_ext
rintro ⟨n,a⟩
simp only [AlgHom.comp_apply,collapse_atom,operator_embed,Elimination.expand_adWord,representation_inl]
simp [Elimination.E]
exact AlgHom.congr_fun h p
havehL : p∈LieGrading.homogeneousLie wt n :=LieGrading.homogeneous_iff.mpr hp
clear hp
change p∈Submodule.span R {p | ∃t : UniversalEmbedding.Tree (Option α),LieGrading.treeDegree wt t=n ∧ t.eval=p} at hL
induction hL usingSubmodule.span_induction with
| mem p hp =>
obtain ⟨t,ht,rfl⟩ := hp
cases t with
| leaf a =>
cases a with
| none => exact (hn (ht.symm)).elim
| some a => simp [Tree.eval,Elimination.expand]
| node t u => simp [Tree.eval,LieHom.map_lie,Ring.lie_def,mul_comm]
| zero => simp
| add p q _ _ hp hq => simp [hp,hq]
| smul c p _ hp => simp [hp]
localinstance {α : Type*} [CharPR2] : CharP (AR α) 2:=
body · 4
lines
charP_of_injective_ringHom (showFunction.Injective (algebraMap R (AR α)) fromby
intro r s h
have hc := congrArg (funp : AR α => p.coeff 1) h
simpa using hc) 2
theoremD_square [CharPR2] (p : SR) : D (D p)=0:=by
proof · 8
lines
induction p usingQuadraticAlphabet.algebra_induction with
| h1 => simp
| ha b => cases b <;> simp [D,C]
| hadd p q hp hq => simp [hp,hq]
| hs c p hp => simp [hp]
| hm p q hp hq =>
rw [D_mul,map_add,D_mul,D_mul,hp,hq]
simp only [zero_mul,mul_zero,zero_add,add_zero,CharTwo.add_self_eq_zero]
theoremP_above (hc : ⁅(C : SR),s⁆=0) (n : ℕ) : P s (n+1)∈above wt 1:=by
proof · 10
lines
induction n with
| zero =>
rw [P_one hc]
havehb : (B : SR)∈above wt 1:= word_mem _ (by simp [degree_of,wt])
have hh := above_lie hb (above_zero (C : SR))
simpa only [Nat.add_zero] using hh
| succ n ih =>
rw [P_succ]
have h := above_lie (above_zero (B+s)) ih
exact h
theoremDP_above (hs : D s=0) (hc : ⁅(C : SR),s⁆=0) (n : ℕ) : D (P s n)∈above wt 1:=by
proof · 10
lines
induction n with
| zero => simp
| succ n ih =>
cases n with
| zero => rw [DP_one hc]; exact (above wt 1).zero_mem
| succ n =>
rw [P_succ,D_lie,D_F hs]
have h1 := above_lie (above_zero (C : SR)) (P_above hc n)
have h2 := above_lie (above_zero (B+s)) ih
exact (above wt 1).add_mem h1 h2
theoremfactor_bounds (hs : D s=0) (hc : ⁅(C : SR),s⁆=0) (n : ℕ) :
P s n∈above wt (indexWt (n+1,())) ∧D (P s n)∈above wt (indexWt (n+1,())+1) :=by
proof · 10
lines
by_cases he : (n+1)%2=0
· havehn : n=n/2*2+1:=by omega
have hP :=P_above hc (n/2*2)
have hD :=DP_even hs hc (n/2)
havehn' : n=2*(n/2)+1:=by omega
constructor
· simpa only [←hn,indexWt,ite_eq_left he] using hP
· simpa only [←hn',indexWt,ite_eq_left he] using hD
· simp only [indexWt,ite_eq_right he,zero_add]
exact ⟨above_zero _,DP_above hs hc n⟩
theoremword_bound (hs : D s=0) (hc : ⁅(C : SR),s⁆=0) (w : FreeMonoid (ℕ×Unit)) :
constant s (word w)∈above wt (degree indexWt w) ∧D (constant s (word w))∈above wt (degree indexWt w+1) :=by
proof · 26
lines
induction w usingFreeMonoid.inductionOn' with
| one =>
simp only [word_one,constant_one,D_one,degree_one,Nat.zero_add]
exact ⟨above_zero _,(above wt 1).zero_mem⟩
| of_mul a w ih =>
obtain ⟨n,u⟩ := a
cases u
rw [word_mul,word_of,constant_atom_mul,degree_mul,degree_of]
cases n with
| zero =>
change D (constant s (word w))∈above wt (1+degree indexWt w) ∧D (D (constant s (word w)))∈above wt (1+degree indexWt w+1)
constructor
· simpa only [Nat.add_comm] using ih.2
· rw [D_square]; exact (above wt _).zero_mem
| succ n =>
simp only [factor,leftMul_apply]
obtain ⟨hp,hd⟩ := factor_bounds hs hc n
constructor
· exact above_mul hp ih.1
· rw [D_mul]
have h1 := above_mul hd ih.1have h2 := above_mul hp ih.2
apply (above wt (indexWt (n+1,())+degree indexWt w+1)).add_mem
· simpa only [Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using h1
· simpa only [Nat.add_assoc] using h2
toFun :=fun | none => .A | some false=> .B | some true=> .C
invFun :=fun | .A=> none | .B=> some false | .C=> some true
left_inv a :=by cases a with | none => rfl | some b => cases b <;> rfl
right_inv a :=by cases a <;> rfl
theoremswappedInput_degree (a : ℕ×Unit) :
swappedInput (atom a)∈homogeneous xWeight 1:=by
proof · 14
lines
obtain ⟨n,u⟩ := a
cases u
induction n with
| zero =>
rw [swappedInput,AlgHom.comp_apply,input_atom_zero,swap_atom]
exact word_mem _ rfl
| succ n ih =>
rw [swappedInput,AlgHom.comp_apply,input_atom_succ,map_lie,swap_atom]
havehy : (atom true : AKBool)∈homogeneous xWeight 0:= word_mem _ rfl
change ⁅atom true,swappedInput (atom (n,()))⁆∈_
change atom true*swappedInput (atom (n,()))-swappedInput (atom (n,()))*atom true∈_
have h1 := homogeneous_mul hy ih
have h2 := homogeneous_mul ih hy
exact (homogeneous xWeight 1).sub_mem h1 h2
change ψ+BaseChangeEquations.eval BaseChangeEquations.y BaseChangeEquations.x ψ=0 at hanti
have h := congrArg embed ((TwoModule.eq_of_add_zero hanti).symm)
simpa only [ResidualKernel.embed_eval,BaseChangeEquations.x,BaseChangeEquations.y,embed_of,swap] using h
localinstance {α : Type*} [CharPR2] : CharP (AR α) 2:=
body · 4
lines
charP_of_injective_ringHom (showFunction.Injective (algebraMap R (AR α)) fromby
intro r s h
have hc := congrArg (funp : AR α => p.coeff 1) h
simpa using hc) 2
theoremevaluate_swapped {s : S (ZMod2)} (hs : D s=0) :
(evaluate s).comp EvenIndex.swappedInput=operators s :=by
proof · 19
lines
apply hom_ext
rintro ⟨n,u⟩
cases u
simp only [AlgHom.comp_apply,operators,lift_atom]
induction n with
| zero =>
rw [EvenIndex.swappedInput,AlgHom.comp_apply,EvenIndex.input_atom_zero,swap_atom]
simp [evaluate,factor]
| succ n ih =>
rw [EvenIndex.swappedInput,AlgHom.comp_apply,EvenIndex.input_atom_succ,EvenIndex.map_lie,swap_atom]
rw [evaluate_lie]
simp only [Bool.not_false,evaluate_y]
change ⁅leftMul (B+s),evaluate s (EvenIndex.swappedInput (atom (n,())))⁆=leftMul (P s n)
rw [ih]
cases n with
| zero => exact left_comm_D hs
| succ n =>
change ⁅leftMul (B+s),leftMul (P s n)⁆=leftMul ⁅B+s,P s n⁆
simp only [Ring.lie_def,map_sub,map_mul]
theoremerase_selector (s : SR) {n m r : ℕ} (hn : n=2*m+r) {p : ARSlot}
(hp : p∈homogeneous weight n) :
eraseShift s (piece xSlot m p)=eraseShift s (piece bCount r p) :=by
proof · 17
lines
induction hp usingSubmodule.span_induction with
| mem p hp =>
obtain ⟨w,hw,rfl⟩ := hp
by_cases hno : ∀ a∈w.toList,a≠Slot.A
· havehe : degree xSlot w=degree acCount w :=by
apply degree_congr_word
intro a ha
have h := hno a ha
cases a <;> simp_all [xSlot,acCount,aCount,cCount]
have hwc := weight_count w
havehi : degree xSlot w=m ↔ degree bCount w=r :=by omega
simp only [piece,project_word,hi]
· simp only [piece,project_word]
split_ifs <;> simp [eraseShift_word s w hno]
| zero => simp
| add p q _ _ hp hq => simp only [map_add,hp,hq]
| smul c p _ hp => simp only [map_smul,hp]
theoremselected_constant {s : S (ZMod2)} (hs : D s=0)
{q : A (ZMod2) (ℕ×Unit)} {p : A (ZMod2) Slot}
(he : EvenIndex.swappedInput q=quad p) : constant s q=eraseShift s p :=by
proof · 5
lines
change operators s q 1=eraseShift s p
have h :=AlgHom.congr_fun (evaluate_swapped hs) q
rw [←h,AlgHom.comp_apply,he]
have h' :=AlgHom.congr_fun (evaluate_quad hs) p
rw [←AlgHom.comp_apply,h',AlgHom.comp_apply,leftMul_apply,mul_one]
theoremreplace_C_mul (u : S) (i : ℕ) (p : S) :
replace u i (atom false*p)=atom false*replace u i p :=by
proof · 7
lines
induction p usingMonoidAlgebra.induction_on with
| of w =>
change replace u i (word (FreeMonoid.of false)*word w)=word (FreeMonoid.of false)*replace u i (word w)
rw [←word_mul,replace_word,replace_word]
rfl
| add p q hp hq => simp only [mul_add,map_add,hp,hq]
| smul c p hp => simp only [mul_smul_comm,map_smul,hp]
theoremreplace_B_mul_zero (u p : S) : replace u 0 (atom true*p)=u*p :=by
proof · 7
lines
induction p usingMonoidAlgebra.induction_on with
| of w =>
change replace u 0 (word (FreeMonoid.of true)*word w)=u*word w
rw [←word_mul,replace_word]
rfl
| add p q hp hq => simp only [mul_add,map_add,hp,hq]
| smul c p hp => simp only [mul_smul_comm,map_smul,hp]
theoremreplace_B_mul_succ (u : S) (i : ℕ) (p : S) :
replace u (i+1) (atom true*p)=atom true*replace u i p :=by
proof · 7
lines
induction p usingMonoidAlgebra.induction_on with
| of w =>
change replace u (i+1) (word (FreeMonoid.of true)*word w)=word (FreeMonoid.of true)*replace u i (word w)
rw [←word_mul,replace_word,replace_word]
rfl
| add p q hp hq => simp only [mul_add,map_add,hp,hq]
| smul c p hp => simp only [mul_smul_comm,map_smul,hp]
theoremreplaceWord_missing (u : S) (i : ℕ) (w : ListBool) (h : countB w ≤ i) :
replaceWord u i w=0:=by
proof · 11
lines
induction w generalizing i with
| nil => rfl
| cons b w ih =>
cases b with
| false=> simp only [countB_false] at h; simp only [replaceWord,ih i h,mul_zero]
| true=>
cases i with
| zero => simp only [countB_true] at h; omega
| succ i =>
simp only [countB_true] at h
simp only [replaceWord,ih i (by omega),mul_zero]
theoremreplaceWord_append (u : S) (i : ℕ) (v w : ListBool) :
replaceWord u i (v++w)=if i<countB v then
replaceWord u i v*word (FreeMonoid.ofList w) else
word (FreeMonoid.ofList v)*replaceWord u (i-countB v) w :=by
proof · 16
lines
induction v generalizing i with
| nil => simp
| cons b v ih =>
cases b with
| false=>
simp only [List.cons_append,replaceWord,countB_false,ih,word_cons]
split_ifs <;> simp only [mul_assoc]
| true=>
cases i with
| zero =>
simp only [List.cons_append,replaceWord,countB_true,Nat.zero_lt_succ,ite_true]
rw [showFreeMonoid.ofList (v++w)=FreeMonoid.ofList v*FreeMonoid.ofList w from rfl,word_mul,mul_assoc]
| succ i =>
simp only [List.cons_append,replaceWord,countB_true,Nat.add_lt_add_iff_right,
Nat.add_sub_add_right,ih,word_cons]
split_ifs <;> simp only [mul_assoc]
obtain ⟨a,v⟩ := g
induction v generalizing a with
| nil => simpa [encode,decode,bump] using decode_false_prefix a []
| cons b v ih => simp [encode,decode_false_prefix,decode,ih,bump,prepend]
theoremerase_small (j i : ℕ) (g : G) (h : size g<j) : erase j i g=none :=by
proof · 11
lines
obtain ⟨a,v⟩ := g
induction v generalizing a i with
| nil => cases i <;> simp_all [erase,size]
| cons b v ih =>
cases i with
| zero =>haveha : ¬j≤a :=by simp only [size,List.sum_cons] at h; omega
simp only [erase,ite_eq_right ha]
| succ i =>havehb : size (b,v)<j :=by simp only [size,List.sum_cons] at *; omega
simp only [erase,ih i b hb,Option.map_none]
theoremerase_merge (j i k : ℕ) (g : G) (h : size g<j) :
(merge j k g).bind (erase j i)=if i=k then merge 0 k g else none :=by
proof · 41
lines
obtain ⟨a,v⟩ := g
induction v generalizing a i k with
| nil => simp [merge]
| cons b v ih =>haveha : a<j :=by simp only [size,List.sum_cons] at h; omega
havehb : size (b,v)<j :=by simp only [size,List.sum_cons] at *; omega
cases k with
| zero =>
cases i with
| zero =>
simp only [merge,Option.bind_some,erase]
rw [ite_eq_left (by omega)]
congr 2; omega
| succ i =>
simp only [merge,Option.bind_some,Nat.succ_ne_zero,ite_false]
cases v with
| nil => rfl
| cons c v =>havehv : size (c,v)<j :=by simp only [size,List.sum_cons] at hb ⊢; omega
simp only [erase,erase_small j i (c,v) hv,Option.map_none]
| succ k =>
cases i with
| zero =>
simp only [merge,Nat.zero_ne_add_one,ite_false]
cases hm : merge j k (b,v) with
| none => rfl
| some u => simp [Option.map,prepend,erase,show¬j≤a by omega]
| succ i =>
simp only [merge,Nat.add_right_cancel_iff]
have hi := ih i k b hb
cases hm : merge j k (b,v) with
| none =>
rw [hm] at hi
split_ifs at hi ⊢with he
· rw [← hi]; rfl
· rfl
| some u =>
rw [hm,Option.bind_some] at hi
change ((erase j i u).map (prepend a))=if i=k then (merge 0 k (b,v)).map (prepend a) else none
rw [hi]
split_ifs <;> rfl
theoremreplace_alg (j i : ℕ) (g : G) :
replace (C^j) i (alg g)=optionAlg (merge j i g) :=by
proof · 18
lines
obtain ⟨a,v⟩ := g
induction v generalizing i a with
| nil =>
rw [alg_nil,showC^a=C^a*1by rw [mul_one],replace_C_pow_mul,replace_one,mul_zero]
simp only [merge,optionAlg_none]
| cons b v ih =>
rw [alg_cons,replace_C_pow_mul]
cases i with
| zero =>
change C^a*replace (C^j) 0 (atom true*alg (b,v))=_
rw [replace_B_mul_zero]
simp only [merge,optionAlg_some]
change C^a*(C^j*alg (b,v))=alg (bump (a+j) (b,v))
rw [alg_bump,pow_add,mul_assoc]
| succ i =>
change C^a*replace (C^j) (i+1) (atom true*alg (b,v))=_
rw [replace_B_mul_succ,ih,merge]
exact (optionAlg_prepend a (merge j i (b,v))).symm
theoremeraseLinear_replace_alg (j i k : ℕ) (g : G) (h : size g<j) :
eraseLinear j i (replace (C^j) k (alg g))=if i=k then replace 1 k (alg g) else0:=by
proof · 4
lines
rw [replace_alg,eraseLinear_optionAlg,erase_merge j i k g h]
split_ifs with he
· simpa only [pow_zero] using (replace_alg (R:=R) 0 k g).symm
· rfl
theoremeraseLinear_replace_word (j i k : ℕ) (w : FreeMonoidBool)
(h : w.toList.count false<j) :
eraseLinear j i (replace (C^j) k (word w))=if i=k then replace 1 k (word w) else0:=by
proof · 3
lines
havehg : word (R:=R) w=alg (decode w.toList) :=by simp [alg,encode_decode]
rw [hg]
exact eraseLinear_replace_alg j i k _ (by simpa only [size_decode] using h)
theoremalgHom_difference_lower (f g : AR α →ₐ[R] AR β)
(wa : α →ℕ) (wb : β →ℕ)
(hf : ∀ a,f (atom a)∈below wb (wa a))
(hg : ∀ a,g (atom a)∈homogeneous wb (wa a))
(he : ∀ a,f (atom a)-g (atom a)∈space (fun w => degree wb w<wa a))
{n : ℕ} {p : AR α} (hp : p∈homogeneous wa n) :
f p-g p∈space (fun w => degree wb w<n) :=by
proof · 15
lines
have hw (w : FreeMonoid α) : f (word w)-g (word w)∈space (fun v => degree wb v<degree wa w) :=by
induction w usingFreeMonoid.inductionOn' with
| one => simp
| of_mul a w ih =>
simp only [word_mul,word_of,map_mul,degree_mul,degree_of]
havehfw : f (word w)∈below wb (degree wa w) :=
algHom_below f wa wb hf (word_mem w (le_refl _))
haveh1 : (f (atom a)-g (atom a))*f (word w)∈space (fun v => degree wb v<wa a+degree wa w) := mul_mem (by intro u v hu hv; simp only [degree_mul]; omega) (he a) hfw
haveh2 : g (atom a)*(f (word w)-g (word w))∈space (fun v => degree wb v<wa a+degree wa w) := mul_mem (by intro u v hu hv; simp only [degree_mul]; omega) (hg a) ih
haveeq : f (atom a)*f (word w)-g (atom a)*g (word w)=
(f (atom a)-g (atom a))*f (word w)+g (atom a)*(f (word w)-g (word w)) :=by noncomm_ring
rw [eq]
exact (space (fun v => degree wb v<wa a+degree wa w)).add_mem h1 h2
exact map_space (f.toLinearMap-g.toLinearMap) _
(by intro w hw'; simpa only [LinearMap.sub_apply,AlgHom.toLinearMap_apply,hw'] using hw w) hp
apply MonoidAlgebra.ext
apply Finsupp.ext
intro w
by_contra hn
havehne : p.coeff w≠0:=by simpa using hn
have h1 := mem_space_iff.mp hp w hne
have h2 := mem_space_iff.mp hl w hne
omega
letE : SR→ₗ[R] SR:= (translate s).toLinearMap-LinearMap.id-shiftDeriv s
have hw (w : FreeMonoidBool) : E (word w)∈space (fun v => degree wt v+1<degree wt w) :=by
induction w usingFreeMonoid.inductionOn' with
| one => simp [E]
| of_mul b w ih =>havehh : word (R:=R) w∈homogeneous wt (degree wt w) := word_mem w rfl
have hd := translate_difference hs hh
cases b with
| false=>havehe : E (word (FreeMonoid.of false*w))=C*E (word w) :=by
simp only [E,LinearMap.sub_apply,AlgHom.toLinearMap_apply,LinearMap.id_apply,
word_mul,word_of]
change translate s (C*word w)-C*word w-shiftDeriv s (C*word w)=_
rw [map_mul,translate_C,shiftDeriv_mul,shiftDeriv_C,zero_mul,zero_add]
noncomm_ring
rw [he]
havehc : (C : SR)∈homogeneous wt 0:= word_mem _ rfl
haveh1 : C*E (word w)∈space (fun v => degree wt v+1<0+degree wt w) :=
mul_mem (by intro u v hu hv; simp only [degree_mul]; omega) hc ih
exact h1
| true=>havehe : E (word (FreeMonoid.of true*w))=
B*E (word w)+s*(translate s (word w)-word w) :=by
simp only [E,LinearMap.sub_apply,AlgHom.toLinearMap_apply,LinearMap.id_apply,
word_mul,word_of]
change translate s (B*word w)-B*word w-shiftDeriv s (B*word w)=_
rw [map_mul,translate_B,shiftDeriv_mul,shiftDeriv_B]
noncomm_ring
rw [he]
havehb : (B : SR)∈homogeneous wt 1:= word_mem _ rfl
haveh1 : B*E (word w)∈space (fun v => degree wt v+1<1+degree wt w) :=
mul_mem (by intro u v hu hv; simp only [degree_mul]; omega) hb ih
haveh2 : s*(translate s (word w)-word w)∈space (fun v => degree wt v+1<1+degree wt w) :=
mul_mem (by intro u v hu hv; simp only [degree_mul]; omega) hs hd
exact (space _).add_mem h1 h2
exact map_space E _ (by intro w hw'; simpa only [hw'] using hw w) hp
have hd := shiftDeriv_degree hs hp
have hl := taylor_remainder hs hp
rw [he,sub_self,zero_sub] at hl
have hl' := (space (fun w => degree wt w+1<r)).neg_mem hl
rw [neg_neg] at hl'
apply MonoidAlgebra.ext
apply Finsupp.ext
intro w
by_contra hn
havehne : (shiftDeriv s p).coeff w≠0:=by simpa using hn
have h1 := mem_space_iff.mp hd w hne
have h2 := mem_space_iff.mp hl' w hne
omega
theoremdegree_countB (w : FreeMonoidBool) : degree OreShift.wt w=countB w.toList :=by
proof · 5
lines
induction w usingFreeMonoid.inductionOn' with
| one => rfl
| of_mul b w ih =>
rw [degree_mul,degree_of,ih]
cases b <;> simp [OreShift.wt,countB,FreeMonoid.toList_mul,Nat.add_comm]
theoremreplace_mul (u : S) (i : ℕ) (p q : S) {r : ℕ} (hp : p∈homogeneous OreShift.wt r) :
replace u i (p*q)=if i<r then replace u i p*q else p*replace u (i-r) q :=by
proof · 16
lines
induction hp usingSubmodule.span_induction with
| mem p hp =>
obtain ⟨v,hv,rfl⟩ := hp
havehv' : countB v.toList=r := (degree_countB v).symm.trans hv
induction q usingMonoidAlgebra.induction_on with
| of w =>
change replace u i (word v*word w)=if i<r then replace u i (word v)*word w else word v*replace u (i-r) (word w)
rw [←word_mul,replace_word,replace_word,replace_word]
change replaceWord u i (v.toList++w.toList)=_
rw [replaceWord_append,hv']
simp only [FreeMonoid.ofList_toList]
| add p q hp hq => simp only [mul_add,map_add,hp,hq]; split_ifs <;> simp
| smul c p hp => simp only [mul_smul_comm,map_smul,hp]; split_ifs <;> simp
| zero => simp
| add p q _ _ hp hq => simp only [add_mul,map_add,hp,hq]; split_ifs <;> simp
| smul c p _ hp => simp only [smul_mul_assoc,map_smul,hp]; split_ifs <;> simp
theoremshiftDeriv_word (u : S) (w : ListBool) :
OreShift.shiftDeriv u (word (FreeMonoid.ofList w))=
∑ i∈Finset.range (countB w), replaceWord u i w :=by
proof · 14
lines
induction w with
| nil => simp [countB]
| cons b w ih =>
rw [word_cons,OreShift.shiftDeriv_mul,ih]
cases b with
| false=>
change OreShift.shiftDeriv u OreShift.C*word (FreeMonoid.ofList w)+_= _
rw [OreShift.shiftDeriv_C,zero_mul,zero_add]
simp only [countB_false,replaceWord,Finset.mul_sum]
| true=>
change OreShift.shiftDeriv u OreShift.B*word (FreeMonoid.ofList w)+_= _
rw [OreShift.shiftDeriv_B,countB_true,Finset.sum_range_succ']
simp only [replaceWord,Finset.mul_sum]
abel
theoremshiftDeriv_eq_sum (u : S) (p : S) {r : ℕ} (hp : p∈homogeneous OreShift.wt r) :
OreShift.shiftDeriv u p=∑ i∈Finset.range r, replace u i p :=by
proof · 8
lines
induction hp usingSubmodule.span_induction with
| mem p hp =>
obtain ⟨w,hw,rfl⟩ := hp
havehw' : countB w.toList=r := (degree_countB w).symm.trans hw
simpa only [replace_word,FreeMonoid.ofList_toList,hw'] using shiftDeriv_word u w.toList
| zero => simp
| add p q _ _ hp hq => simp [map_add,hp,hq,Finset.sum_add_distrib]
| smul c p _ hp => simp [map_smul,hp,Finset.smul_sum]
theoremexists_below (wt : α →ℕ) (p : AR α) : ∃ n,p∈below wt n :=by
proof · 8
lines
induction p usingMonoidAlgebra.induction_on with
| of w => exact ⟨degree wt w,word_mem w (le_refl _)⟩
| add p q hp hq =>
obtain ⟨n,hn⟩ := hp
obtain ⟨m,hm⟩ := hq
exact ⟨n+m,(below wt _).add_mem (space_mono (by intro w hw; omega) hn)
(space_mono (by intro w hw; omega) hm)⟩
| smul c p hp => obtain ⟨n,hn⟩ := hp; exact ⟨n,(below wt n).smul_mem _ hn⟩
theoremdegree_countC (w : FreeMonoidBool) : degree cwt w=w.toList.count false:=by
proof · 5
lines
induction w usingFreeMonoid.inductionOn' with
| one => rfl
| of_mul b w ih =>
rw [degree_mul,degree_of,ih]
cases b <;> simp [cwt,FreeMonoid.toList_mul,Nat.add_comm]
theoremeraseLinear_replace {p : S} {m j : ℕ} (hp : p∈below cwt m) (hj : m<j) (i k : ℕ) :
eraseLinear j i (replace (C^j) k p)=if i=k then replace 1 k p else0:=by
proof · 7
lines
induction hp usingSubmodule.span_induction with
| mem p hp =>
obtain ⟨w,hw,rfl⟩ := hp
exact eraseLinear_replace_word j i k w (by rw [degree_countC] at hw; omega)
| zero => simp
| add p q _ _ hp hq => simp only [map_add,hp,hq]; split_ifs <;> simp
| smul c p _ hp => simp only [map_smul,hp]; split_ifs <;> simp
theoremreplace_missing_homogeneous {p : S} {r i : ℕ} (hp : p∈homogeneous OreShift.wt r) (hi : r ≤ i) :
replace 1 i p=0:=by
proof · 8
lines
induction hp usingSubmodule.span_induction with
| mem p hp =>
obtain ⟨w,hw,rfl⟩ := hp
rw [replace_word]
exact replaceWord_missing _ _ _ (by rw [←degree_countB,hw]; exact hi)
| zero => exact map_zero _
| add p q _ _ hp hq => simp [hp,hq]
| smul c p _ hp => simp [hp]
by_cases hi : i<r
· obtain ⟨m,hm⟩ := exists_below cwt p
let j := m+1havehj : m<j :=Nat.lt_succ_self m
have hd :=OreShift.shiftDeriv_zero (Cpow_degree (R:=R) j) hp (hinv j)
have h := congrArg (eraseLinear j i) hd
rw [shiftDeriv_eq_sum _ _ hp,map_sum,map_zero] at h
simp_rw [eraseLinear_replace hm hj i] at h
simpa [hi] using h
· exact replace_missing_homogeneous hp (by omega)
(Finsupp.linearCombination K (funw : FreeMonoidI=> word (FreeMonoid.ofList (insertList i w.toList)))).comp
(MonoidAlgebra.coeffLinearEquiv K).toLinearMap
@[simp]theoreminsert_word (i : ℕ) (w : FreeMonoidI) :
insert i (word w)=word (FreeMonoid.ofList (insertList i w.toList)) :=by
proof · 1
line
change Finsupp.linearCombination K (funmonoidWord : FreeMonoidI=> word (FreeMonoid.ofList (insertList i monoidWord.toList))) (Finsupp.single w 1) = _; simp
theoreminsert_succ_atom_mul (i : ℕ) (a : I) (p : Q) :
insert (i+1) (atom a*p)=atom a*insert i p :=by
proof · 7
lines
induction p usingMonoidAlgebra.induction_on with
| of w =>
change insert (i+1) (word (FreeMonoid.of a)*word w)=word (FreeMonoid.of a)*insert i (word w)
rw [←word_mul,insert_word,insert_word,←word_mul]
rfl
| add p q hp hq => simp only [mul_add,map_add,hp,hq]
| smul c p hp => simp only [mul_smul_comm,map_smul,hp]
theoreminsert_remove_word (i : ℕ) (w : ListI) :
insert i (removeWord i w)=if zeroAt i w then word (FreeMonoid.ofList w) else0:=by
proof · 20
lines
induction w generalizing i with
| nil => simp [removeWord,zeroAt]
| cons a w ih =>
cases i with
| zero =>
simp only [removeWord,zeroAt,decide_eq_true_eq]
split_ifs with h
· rw [insert_word]
obtain ⟨n,u⟩ := a
cases u
simp only at h
subst n
rfl
· exact map_zero _
| succ i =>
rw [removeWord,insert_succ_atom_mul,ih]
rw [zeroAt]
split_ifs
· exact (word_mul (FreeMonoid.of a) (FreeMonoid.ofList w)).symm
· exact mul_zero _
theoreminsert_remove (i : ℕ) (p : Q) :
insert i (remove i p)=project (fun w => zeroAt i w.toList=true) p :=by
proof · 6
lines
induction p usingMonoidAlgebra.induction_on with
| of w =>
change insert i (remove i (word w))=project _ (word w)
rw [remove_word,project_word,insert_remove_word,FreeMonoid.ofList_toList]
| add p q hp hq => simp only [map_add,hp,hq]
| smul c p hp => simp only [map_smul,hp]
theoremreplace_input_word (i : ℕ) (w : FreeMonoidI) :
replace 1 i (EvenIndex.input (word w))=EvenIndex.input (remove i (word w)) :=by
proof · 16
lines
rw [remove_word]
induction w usingFreeMonoid.inductionOn' generalizing i with
| one => simp [removeWord]
| of_mul a w ih =>
rw [word_mul,word_of,map_mul,replace_mul 1 i _ _ (input_degree a)]
obtain ⟨n,u⟩ := a
cases u
cases i with
| zero =>
rw [ite_eq_left (by omega),replace_input_atom_zero]
change (if n=0then1else0)*EvenIndex.input (word w)=EvenIndex.input (if n=0then word w else0)
split_ifs <;> simp
| succ i =>
rw [ite_eq_right (by omega),Nat.add_sub_cancel,ih]
change EvenIndex.input (atom (n,()))*EvenIndex.input (removeWord i w.toList)=EvenIndex.input (atom (n,())*removeWord i w.toList)
rw [map_mul]
theoremreplace_input (i : ℕ) (p : Q) :
replace 1 i (EvenIndex.input p)=EvenIndex.input (remove i p) :=by
proof · 4
lines
induction p usingMonoidAlgebra.induction_on with
| of w => exact replace_input_word i w
| add p q hp hq => simp only [map_add,hp,hq]
| smul c p hp => simp only [map_smul,hp]
theoremnoZero_of_zeroAt_false (w : ListI) (h : ∀ i,zeroAt i w=false) : noZero w :=by
proof · 9
lines
induction w with
| nil => simp [noZero]
| cons a w ih =>haveha : a.1≠0:=by simpa [zeroAt] using h 0haveht : noZero w := ih (fun i =>by simpa only [zeroAt] using h (i+1))
intro b hb
rcases List.mem_cons.mp hb with rfl | hb
· exact ha
· exact ht b hb
theoremsupport_noZero {p : Q} (h : ∀ i,remove i p=0) :
p∈space (fun w => noZero w.toList) :=by
proof · 13
lines
apply mem_space
intro w hw
apply noZero_of_zeroAt_false
intro i
havehp : project (fun w => zeroAt i w.toList=true) p=0:=by
rw [←insert_remove,h i,map_zero]
have hc := congrArg (funq : Q=> q.coeff w) hp
rw [project_coeff] at hc
cases hi : zeroAt i w.toList with
| false=> rfl
| true=>
simp only [hi,MonoidAlgebra.coeff_zero,Finsupp.zero_apply] at hc
exact False.elim (hw hc)
theoremretain_word (w : FreeMonoidI) (h : noZero w.toList) : retain (word w)=word w :=by
proof · 6
lines
induction w usingFreeMonoid.inductionOn' with
| one => simp
| of_mul a w ih =>haveha : a.1≠0:= h a (List.mem_cons_self)
haveht : noZero w.toList :=fun b hb => h b (List.mem_cons_of_mem a hb)
rw [word_mul,word_of,map_mul,retain_atom,ite_eq_right ha,ih ht]
have hp := support_noZero h
clear h
induction hp usingSubmodule.span_induction with
| mem p hp => obtain ⟨w,hw,rfl⟩ := hp; exact retain_word w hw
| zero => exact map_zero _
| add p q _ _ hp hq => simp only [map_add,hp,hq]
| smul c p _ hp => simp only [map_smul,hp]
haveho : embed (rename bitOption p)∈homogeneous (OreShift.wt ∘ bitOption.symm) r :=by
rw [rename_embed]
apply algHom_homogeneous (renameAssoc bitOption) OreShift.wt (OreShift.wt ∘ bitOption.symm) ?_ hp
intro b
rw [renameAssoc_atom]
apply word_mem
simp [degree_of]
have hz :=EliminationGraded.trace_homogeneous_zero (wt:=OreShift.wt ∘ bitOption.symm) (by simpa [bitOption,OreShift.wt] using hr) ho
have hd :=EliminationGraded.embed_decompose (rename bitOption p)
rw [hz,zero_smul,add_zero] at hd
have h := congrArg (renameAssoc bitOption.symm) hd
rw [rename_embed,assoc_retract bitOption bitOption.symm bitOption.left_inv] at h
exact h.symm
have hi := input_fiber_of_bcount hr hp
have hd :=GapSelection.all_deletions_zero hp hinv
obtain ⟨q,hq⟩ :=GeneratorDeletion.positive_generation (p:=(Elimination.expand (rename bitOption p)).left)
(by intro i; change PositionalDeletion.replace 1 i (EvenIndex.input (EvenIndex.fiber p))=0; rw [hi]; exact hd i)
refine ⟨q,?_⟩
change EvenIndex.input (EvenIndex.fiber p)=_ at hq
rw [hi] at hq
rw [←GeneratorDeletion.include_embed] at hq
exact hq.symm
theoremweight_count (w : FreeMonoidBool) : degree cbWeight w=2*degree GapSelection.cwt w+degree OreShift.wt w :=by
proof · 5
lines
induction w usingFreeMonoid.inductionOn' with
| one => rfl
| of_mul b w ih =>
simp only [degree_mul,degree_of]
cases b <;> simp only [cbWeight,GapSelection.cwt,OreShift.wt,Bool.false_eq_true,ite_false,ite_true] <;> omega
obtain ⟨w,hw⟩ : ∃ w,p.coeff w≠0:=by
by_contra h
apply hp
ext w
have:= not_exists.mp h w
simpa using this
have h1 := mem_space_iff.mp hn w hw
have h2 := mem_space_iff.mp hr w hw
exact ⟨degree GapSelection.cwt w,by rw [←h1,weight_count,h2]⟩
induction w usingFreeMonoid.inductionOn' with
| one => simp
| of_mul b w ih =>
rw [degree_mul,degree_of] at hw
havehb : b=false:=by cases b <;> simp_all [OreShift.wt]
haveht : degree OreShift.wt w=0:=by omega
intro c hc
rcases List.mem_cons.mp hc with h | h
· exact h.trans hb
· exact ih ht c h
have h :=OreShift.shiftDeriv_zero (GapSelection.Cpow_degree (R:=K) 1) (leading_bcount r p)
(leading_shift_invariant hn hψ hp hanti hr 1)
havehe : OreShift.shiftDeriv ((OreShift.C : AKBool)^1)=OreShift.D:=by
simp only [pow_one,OreShift.shiftDeriv,OreShift.D]
rw [he] at h
exact h