@@ -27,6 +27,11 @@ omit [Finite F] in
2727private lemma op_der_eq : Monoid.toMulAction Fˣ = Units.mulAction' := by ext; rfl
2828
2929open Lean Elab in
30+ /--
31+ A variation on `rw [op_der_eq] at *`.
32+
33+ Ensures that once `Fˣ` is fixed, we use `Monoid.toMulAction Fˣ`, not `Units.mulAction'`.
34+ -/
3035private def reconcile (goal : MVarId) : MetaM (Option MVarId) := goal.withContext do
3136 let mut goal ← go goal
3237 for const in ←getLCtx do
@@ -43,46 +48,30 @@ private def reconcile (goal : MVarId) : MetaM (Option MVarId) := goal.withContex
4348 return goal'
4449
4550open Lean Elab Tactic in
46- private def reconcile_tac : TacticM Unit := liftMetaTactic1 reconcile
51+ /--
52+ Reconciles `Monoid.toMulAction Fˣ = Units.mulAction'` across the goal.
53+ -/
54+ scoped elab "reconcile" : tactic => liftMetaTactic1 reconcile
4755
4856/--
4957`reconcile`-aware `aesop` that deals with coset membership.
5058
51- - Optionally takes either side of `mem_leftCoset_iff` as a hint .
59+ Can be trivially extended to recognise more than just `mem_leftCoset_iff` .
5260-/
53- scoped syntax (name := reconcileStx) withPosition( "aesop_reconcile" (colGt ident)?) : tactic
61+ scoped syntax (name := reconcileStx) "aesop_reconcile" : tactic
5462
55- open Lean Elab Tactic in
63+ set_option hygiene false in
64+ open Lean Elab Tactic PrettyPrinter Delaborator in
5665@ [tactic reconcileStx, inherit_doc reconcileStx]
57- private def elabReconcileStx : Tactic := fun stx => do
66+ private def elabReconcileStx : Tactic := fun stx => withMainContext do
5867 match stx with
59- | `(tactic|aesop_reconcile $[$h]?) =>
60- let tac : TacticM _ :=
61- match h with
62- | .none => `(tactic|(try apply (mem_leftCoset_iff _).1
63- aesop (add safe tactic reconcile_tac)))
64- | .some h => `(tactic| (try have := (mem_leftCoset_iff _).2 $h
65- try apply (mem_leftCoset_iff _).1
66- aesop (add safe tactic reconcile_tac)))
67- evalTactic (←tac)
68+ | `(tactic|aesop_reconcile) =>
69+ evalTactic (←
70+ `(tactic|(have := fun X₁ X₂ X₃ ↦ @mem_leftCoset_iff Fˣ _ X₁ X₂ X₃
71+ reconcile
72+ aesop)))
6873 | _ => throwError "Unsupported syntax."
6974
70- /--
71- Reconciles `Monoid.toMulAction Fˣ = Units.mulAction'` across the goal.
72- -/
73- scoped elab "reconcile" : tactic => reconcile_tac
74-
75- -- open Lean Elab Tactic in
76- -- scoped elab "reconcile" h:(ident)? : tactic => do
77- -- let tac : TacticM _ :=
78- -- match h with
79- -- | .none => `(tactic|(try apply (mem_leftCoset_iff _).1
80- -- aesop (add safe tactic (reconcile_tac))))
81- -- | .some h => `(tactic| (try have := (mem_leftCoset_iff _).2 $h
82- -- try apply (mem_leftCoset_iff _).1
83- -- aesop (add safe tactic (reconcile_tac))))
84- -- evalTactic (←tac)
85-
8675namespace Domain
8776
8877/-- Constructs the subgroups of `Fˣ` which we will use to construct
@@ -194,8 +183,10 @@ def domainEmb {i : ℕ} : evalDomain D i ↪ F :=
194183
195184/- Proof the first subgroup is `D`, the cyclic group generated by `DIsCyclicC.gen : Fˣ` -/
196185omit [Finite F] in
197- lemma D_def : D = evalDomain D 0 := by
186+ @[simp]
187+ lemma D_def : evalDomain D 0 = D := by
198188 unfold evalDomain
189+ symm
199190 ext x
200191 rw [Subgroup.mem_zpowers_iff]
201192 simp only [pow_zero, pow_one]
@@ -360,8 +351,6 @@ namespace CosetDomain
360351
361352open Pointwise
362353
363-
364-
365354/- Element of `Fˣ` we will use to define our coset -/
366355variable (x : Fˣ)
367356
@@ -373,21 +362,12 @@ def evalDomain (i : ℕ) : Set Fˣ :=
373362abbrev evalDomainSigma (s : Fin (n + 1 ) → ℕ+) (i : ℕ) :=
374363 evalDomain D x (∑ j' ∈ finRangeTo i, s j')
375364
376- -- set_option pp.all true in
377365/- Enumeration of the elements of the `i`th coset. -/
378366def domain (n : ℕ) (i : ℕ) : Fin (2 ^ (n - i)) → evalDomain D x i :=
379367 fun j =>
380368 ⟨
381369 x ^ 2 ^ i * (DIsCyclicC.gen ^ (2 ^ i)) ^ j.1 ,
382- by
383- simp
384- rw [←Domain.evalDomain]
385- have h :
386- (x ^ 2 ^ i)⁻¹ * (x ^ 2 ^ i * (DIsCyclicC.gen.1 ^ 2 ^ i) ^ j.1 ) ∈
387- Domain.evalDomain D i := by
388- rw [←mul_assoc]
389- simp
390- aesop_reconcile h
370+ by aesop_reconcile
391371 ⟩
392372
393373lemma domain_injective {i : ℕ} : i ≤ n → Function.Injective (domain D x n i) := by
@@ -422,9 +402,7 @@ noncomputable def domainToFin {i : Fin (n + 1)} : evalDomain D x i → Fin (2 ^
422402 g.1 .1 = x.1 ^ (2 ^ i.1 ) * ((DIsCyclicC.gen.1 ^ (2 ^ i.1 )) ^ ind.1 ) := by
423403 have h := g.2
424404 unfold evalDomain at h
425- have h' : (x ^ 2 ^ i.1 )⁻¹ * ↑g ∈ ↑(Domain.evalDomain D ↑i) := by
426- apply (@mem_leftCoset_iff Fˣ _ (Domain.evalDomain D ↑i) g.1 (x ^ (2 ^ i.1 ))).mp
427- aesop_reconcile
405+ have h' : (x ^ 2 ^ i.1 )⁻¹ * ↑g ∈ ↑(Domain.evalDomain D ↑i) := by aesop_reconcile
428406 unfold Domain.evalDomain at h'
429407 rw [Subgroup.mem_zpowers_iff] at h'
430408 rcases h' with ⟨ind, h'⟩
@@ -480,7 +458,11 @@ def injectF {F : Type} [NonBinaryField F] {D : Subgroup Fˣ} [DIsCyclicC : IsCyc
480458/- Helper lemmas for constructing operations on/lifting between domains. -/
481459
482460omit [Finite F] in
483- lemma D_def : evalDomain D x 0 = x • D := by simp [Domain.D_def D]
461+ @[simp]
462+ lemma D_def : evalDomain D x 0 = x • D := by
463+ unfold evalDomain
464+ rw [Domain.D_def]
465+ simp
484466
485467lemma pow_2_pow_i_mem_Di_of_mem_D {F : Type } [NonBinaryField F] [Finite F] {D : Subgroup Fˣ}
486468 [DIsCyclicC : IsCyclicWithGen ↥D] {x : Fˣ} :
@@ -489,10 +471,10 @@ lemma pow_2_pow_i_mem_Di_of_mem_D {F : Type} [NonBinaryField F] [Finite F] {D :
489471 unfold evalDomain
490472 intros a i h
491473 have h : x⁻¹ * a ∈ Domain.evalDomain D 0 := by aesop_reconcile
492- rw [←Domain.D_def] at h
493474 have : (x⁻¹ * a) ^ 2 ^ i = (x ^ (2 ^ i))⁻¹ * (a ^ (2 ^ i)) := by field_simp
494- have h := this ▸ Domain.pow_2_pow_i_mem_Di_of_mem_D D (i := i) h
495- aesop_reconcile h
475+ simp only [Domain.D_def] at h
476+ have := Domain.pow_2_pow_i_mem_Di_of_mem_D D (i := i) h
477+ aesop_reconcile
496478
497479omit [Finite F] in
498480lemma sqr_mem_D_succ_i_of_mem_D_i : ∀ {a : Fˣ} {i : ℕ},
@@ -510,8 +492,8 @@ lemma sqr_mem_D_succ_i_of_mem_D_i : ∀ {a : Fˣ} {i : ℕ},
510492 congr 1
511493 grind
512494 rw [this]
513- have h := this ▸ Domain.sqr_mem_D_succ_i_of_mem_D_i D h
514- aesop_reconcile h
495+ have h := Domain.sqr_mem_D_succ_i_of_mem_D_i D h
496+ aesop_reconcile
515497
516498omit [Finite F] in
517499lemma pow_lift : ∀ {a : Fˣ} {i : ℕ} (s : ℕ),
@@ -533,17 +515,17 @@ lemma neg_mem_dom_of_mem_dom : ∀ {a : Fˣ} (i : Fin n),
533515 unfold evalDomain
534516 rintro a ⟨i, i_prop⟩ h
535517 have mem : (x ^ 2 ^ i)⁻¹ * a ∈ Domain.evalDomain D i := by
536- aesop_reconcile h
518+ aesop_reconcile
537519 have : (x ^ 2 ^ i)⁻¹ * -a ∈ ↑(Domain.evalDomain D i) := by
538520 have : (x ^ 2 ^ i)⁻¹ * -a = ((x ^ 2 ^ i)⁻¹ * a) * (- 1 ) := by field_simp
539521 rw [this]
540522 exact
541523 (
542524 Subgroup.mul_mem_cancel_right
543- (Domain.evalDomain D i)
525+ _
544526 (Domain.minus_one_in_doms D i_prop)
545527 ).mpr mem
546- aesop_reconcile this
528+ aesop_reconcile
547529
548530omit [Finite F] in
549531lemma mul_root_of_unity {x : Fˣ} :
@@ -563,11 +545,11 @@ lemma mul_root_of_unity {x : Fˣ} :
563545 apply Subgroup.mem_zpowers_iff.mpr
564546 exists (ka + (2 ^ (j - i)) * kb)
565547 rw [
566- ←@mul_assoc Fˣ _ _ a b, ←a_in, ←b_in, zpow_add,
567- Eq.symm (pow_mul_pow_sub 2 i_le_j), pow_mul, zpow_mul
548+ ←@mul_assoc _ _ _ a b, ←a_in, ←b_in, zpow_add,
549+ (pow_mul_pow_sub 2 i_le_j).symm , pow_mul, zpow_mul
568550 ]
569551 norm_cast
570- aesop_reconcile this
552+ aesop_reconcile
571553
572554omit [Finite F] in
573555lemma dom_n_eq_triv : evalDomain D x n = {x ^ (2 ^ n)} := by
@@ -577,15 +559,8 @@ lemma dom_n_eq_triv : evalDomain D x n = {x ^ (2 ^ n)} := by
577559
578560noncomputable local instance : Fintype F := Fintype.ofFinite _
579561
580- noncomputable instance : Nonempty ↑(CosetDomain.evalDomain D x 0 ) := by
581- apply Nonempty.intro
582- exact
583- ⟨x,
584- by
585- simp
586- have := (@mem_leftCoset_iff Fˣ _ (Subgroup.zpowers DIsCyclicC.gen.1 ) x x).mpr (by simp)
587- aesop
588- ⟩
562+ noncomputable instance : Nonempty ↑(CosetDomain.evalDomain D x 0 ) :=
563+ ⟨x, by aesop_reconcile⟩
589564
590565noncomputable instance : Fintype ↑(CosetDomain.evalDomain D x 0 ) := inferInstance
591566
0 commit comments