-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathEllipticDivisibilitySequence.lean
More file actions
547 lines (433 loc) · 20.6 KB
/
EllipticDivisibilitySequence.lean
File metadata and controls
547 lines (433 loc) · 20.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
/-
Copyright (c) 2024 David Kurniadi Angdinata. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Kurniadi Angdinata
-/
module
public import Mathlib.Data.Nat.EvenOddRec
public import Mathlib.Tactic.Linarith
public import Mathlib.Tactic.LinearCombination
import Mathlib.Algebra.Group.Int.Even
/-!
# Elliptic divisibility sequences
This file defines the type of an elliptic divisibility sequence (EDS) and a few examples.
## Mathematical background
Let `R` be a commutative ring. An elliptic sequence is a sequence `W : ℤ → R` satisfying
`W(m + n)W(m - n)W(r)² = W(m + r)W(m - r)W(n)² - W(n + r)W(n - r)W(m)²` for any `m, n, r ∈ ℤ`.
A divisibility sequence is a sequence `W : ℤ → R` satisfying `W(m) ∣ W(n)` for any `m, n ∈ ℤ` such
that `m ∣ n`. An elliptic divisibility sequence is simply a divisibility sequence that is elliptic.
Some examples of EDSs include
* the identity sequence,
* certain terms of Lucas sequences, and
* division polynomials of elliptic curves.
## Main definitions
* `IsEllSequence`: a sequence indexed by integers is an elliptic sequence.
* `IsDivSequence`: a sequence indexed by integers is a divisibility sequence.
* `IsEllDivSequence`: a sequence indexed by integers is an EDS.
* `preNormEDS'`: the auxiliary sequence for a normalised EDS indexed by `ℕ`.
* `preNormEDS`: the auxiliary sequence for a normalised EDS indexed by `ℤ`.
* `complEDS₂`: the 2-complement sequence for a normalised EDS indexed by `ℕ`.
* `normEDS`: the canonical example of a normalised EDS indexed by `ℤ`.
* `complEDS'`: the complement sequence for a normalised EDS indexed by `ℕ`.
* `complEDS`: the complement sequence for a normalised EDS indexed by `ℤ`.
## Main statements
* TODO: prove that `normEDS` satisfies `IsEllDivSequence`.
* TODO: prove that a normalised sequence satisfying `IsEllDivSequence` can be given by `normEDS`.
## Implementation notes
The normalised EDS `normEDS b c d n` is defined in terms of the auxiliary sequence
`preNormEDS (b ^ 4) c d n`, which are equal when `n` is odd, and which differ by a factor of `b`
when `n` is even. This coincides with the definition in the references since both agree for
`normEDS b c d 2` and for `normEDS b c d 4`, and the correct factors of `b` are removed in
`normEDS b c d (2 * (m + 2) + 1)` and in `normEDS b c d (2 * (m + 3))`.
One reason is to avoid the necessity for ring division by `b` in the inductive definition of
`normEDS b c d (2 * (m + 3))`. The idea is that it can be shown that `normEDS b c d (2 * (m + 3))`
always contains a factor of `b`, so it is possible to remove a factor of `b` *a posteriori*, but
stating this lemma requires first defining `normEDS b c d (2 * (m + 3))`, which requires having this
factor of `b` *a priori*. Another reason is to allow the definition of univariate `n`-division
polynomials of elliptic curves, omitting a factor of the bivariate `2`-division polynomial.
## References
M Ward, *Memoir on Elliptic Divisibility Sequences*
## Tags
elliptic, divisibility, sequence
-/
@[expose] public section
universe u v
variable {R : Type u} [CommRing R]
section IsEllDivSequence
variable (W : ℤ → R)
/-- The proposition that a sequence indexed by integers is an elliptic sequence. -/
def IsEllSequence : Prop :=
∀ m n r : ℤ, W (m + n) * W (m - n) * W r ^ 2 =
W (m + r) * W (m - r) * W n ^ 2 - W (n + r) * W (n - r) * W m ^ 2
/-- The proposition that a sequence indexed by integers is a divisibility sequence. -/
def IsDivSequence : Prop :=
∀ m n : ℕ, m ∣ n → W m ∣ W n
/-- The proposition that a sequence indexed by integers is an EDS. -/
def IsEllDivSequence : Prop :=
IsEllSequence W ∧ IsDivSequence W
lemma isEllSequence_id : IsEllSequence id :=
fun _ _ _ => by simp_rw [id_eq]; ring1
lemma isDivSequence_id : IsDivSequence id :=
fun _ _ => Int.ofNat_dvd.mpr
/-- The identity sequence is an EDS. -/
theorem isEllDivSequence_id : IsEllDivSequence id :=
⟨isEllSequence_id, isDivSequence_id⟩
variable {W}
lemma IsEllSequence.smul (h : IsEllSequence W) (x : R) : IsEllSequence (x • W) :=
fun m n r => by
linear_combination (norm := (simp_rw [Pi.smul_apply, smul_eq_mul]; ring1)) x ^ 4 * h m n r
lemma IsDivSequence.smul (h : IsDivSequence W) (x : R) : IsDivSequence (x • W) :=
fun m n r => mul_dvd_mul_left x <| h m n r
lemma IsEllDivSequence.smul (h : IsEllDivSequence W) (x : R) : IsEllDivSequence (x • W) :=
⟨h.left.smul x, h.right.smul x⟩
end IsEllDivSequence
variable (b c d : R)
section PreNormEDS
/-- The auxiliary sequence for a normalised EDS `W : ℕ → R`, with initial values
`W(0) = 0`, `W(1) = 1`, `W(2) = 1`, `W(3) = c`, and `W(4) = d` and extra parameter `b`. -/
def preNormEDS' : ℕ → R
| 0 => 0
| 1 => 1
| 2 => 1
| 3 => c
| 4 => d
| (n + 5) => let m := n / 2
if hn : Even n then
preNormEDS' (m + 4) * preNormEDS' (m + 2) ^ 3 * (if Even m then b else 1) -
preNormEDS' (m + 1) * preNormEDS' (m + 3) ^ 3 * (if Even m then 1 else b)
else
have : m + 5 < n + 5 := by
gcongr; exact Nat.div_lt_self (Nat.not_even_iff_odd.mp hn).pos one_lt_two
preNormEDS' (m + 2) ^ 2 * preNormEDS' (m + 3) * preNormEDS' (m + 5) -
preNormEDS' (m + 1) * preNormEDS' (m + 3) * preNormEDS' (m + 4) ^ 2
@[simp]
lemma preNormEDS'_zero : preNormEDS' b c d 0 = 0 := by
rw [preNormEDS']
@[simp]
lemma preNormEDS'_one : preNormEDS' b c d 1 = 1 := by
rw [preNormEDS']
@[simp]
lemma preNormEDS'_two : preNormEDS' b c d 2 = 1 := by
rw [preNormEDS']
@[simp]
lemma preNormEDS'_three : preNormEDS' b c d 3 = c := by
rw [preNormEDS']
@[simp]
lemma preNormEDS'_four : preNormEDS' b c d 4 = d := by
rw [preNormEDS']
lemma preNormEDS'_even (m : ℕ) : preNormEDS' b c d (2 * (m + 3)) =
preNormEDS' b c d (m + 2) ^ 2 * preNormEDS' b c d (m + 3) * preNormEDS' b c d (m + 5) -
preNormEDS' b c d (m + 1) * preNormEDS' b c d (m + 3) * preNormEDS' b c d (m + 4) ^ 2 := by
rw [show 2 * (m + 3) = 2 * m + 1 + 5 by rfl, preNormEDS', dif_neg m.not_even_two_mul_add_one]
simp [Nat.mul_add_div two_pos]
lemma preNormEDS'_odd (m : ℕ) : preNormEDS' b c d (2 * (m + 2) + 1) =
preNormEDS' b c d (m + 4) * preNormEDS' b c d (m + 2) ^ 3 * (if Even m then b else 1) -
preNormEDS' b c d (m + 1) * preNormEDS' b c d (m + 3) ^ 3 * (if Even m then 1 else b) := by
rw [show 2 * (m + 2) + 1 = 2 * m + 5 by rfl, preNormEDS', dif_pos <| even_two_mul m,
m.mul_div_cancel_left two_pos]
/-- The auxiliary sequence for a normalised EDS `W : ℤ → R`, with initial values
`W(0) = 0`, `W(1) = 1`, `W(2) = 1`, `W(3) = c`, and `W(4) = d` and extra parameter `b`.
This extends `preNormEDS'` by defining its values at negative integers. -/
def preNormEDS (n : ℤ) : R :=
n.sign * preNormEDS' b c d n.natAbs
@[simp]
lemma preNormEDS_ofNat (n : ℕ) : preNormEDS b c d n = preNormEDS' b c d n := by
by_cases hn : n = 0
· simp [hn, preNormEDS]
· simp [preNormEDS, Int.sign_natCast_of_ne_zero hn]
@[simp]
lemma preNormEDS_zero : preNormEDS b c d 0 = 0 := by
simp [preNormEDS]
@[simp]
lemma preNormEDS_one : preNormEDS b c d 1 = 1 := by
simp [preNormEDS]
@[simp]
lemma preNormEDS_two : preNormEDS b c d 2 = 1 := by
simp [preNormEDS, Int.sign_eq_one_of_pos]
@[simp]
lemma preNormEDS_three : preNormEDS b c d 3 = c := by
simp [preNormEDS, Int.sign_eq_one_of_pos]
@[simp]
lemma preNormEDS_four : preNormEDS b c d 4 = d := by
simp [preNormEDS, Int.sign_eq_one_of_pos]
@[simp]
lemma preNormEDS_neg (n : ℤ) : preNormEDS b c d (-n) = -preNormEDS b c d n := by
simp [preNormEDS]
lemma preNormEDS_even (m : ℤ) : preNormEDS b c d (2 * m) =
preNormEDS b c d (m - 1) ^ 2 * preNormEDS b c d m * preNormEDS b c d (m + 2) -
preNormEDS b c d (m - 2) * preNormEDS b c d m * preNormEDS b c d (m + 1) ^ 2 := by
induction m using Int.negInduction with
| nat m =>
rcases m with _ | _ | _ | m
iterate 3 simp
simp_rw [Nat.cast_succ, Int.add_sub_cancel, show (m : ℤ) + 1 + 1 + 1 = m + 1 + 2 by rfl,
Int.add_sub_cancel]
norm_cast
simpa only [preNormEDS_ofNat] using preNormEDS'_even ..
| neg ih m =>
simp_rw [mul_neg, ← sub_neg_eq_add, ← neg_sub', ← neg_add', preNormEDS_neg, ih]
ring1
lemma preNormEDS_odd (m : ℤ) : preNormEDS b c d (2 * m + 1) =
preNormEDS b c d (m + 2) * preNormEDS b c d m ^ 3 * (if Even m then b else 1) -
preNormEDS b c d (m - 1) * preNormEDS b c d (m + 1) ^ 3 * (if Even m then 1 else b) := by
induction m using Int.negInduction with
| nat m =>
rcases m with _ | _ | _
iterate 2 simp
simp_rw [Nat.cast_succ, Int.add_sub_cancel, Int.even_add_one, not_not, Int.even_coe_nat]
norm_cast
simpa only [preNormEDS_ofNat] using preNormEDS'_odd ..
| neg ih m =>
rcases m with _ | m
· simp
simp_rw [Nat.cast_succ, show 2 * -(m + 1 : ℤ) + 1 = -(2 * m + 1) by rfl,
show -(m + 1 : ℤ) + 2 = -(m - 1) by ring1, show -(m + 1 : ℤ) - 1 = -(m + 2) by rfl,
show -(m + 1 : ℤ) + 1 = -m by ring1, preNormEDS_neg, even_neg, Int.even_add_one, ite_not, ih]
ring1
/-- The 2-complement sequence `Wᶜ₂ : ℤ → R` for a normalised EDS `W : ℤ → R` that witnesses
`W(k) ∣ W(2 * k)`. In other words, `W(k) * Wᶜ₂(k) = W(2 * k)` for any `k ∈ ℤ`.
This is defined in terms of `preNormEDS`. -/
def complEDS₂ (k : ℤ) : R :=
(preNormEDS (b ^ 4) c d (k - 1) ^ 2 * preNormEDS (b ^ 4) c d (k + 2) -
preNormEDS (b ^ 4) c d (k - 2) * preNormEDS (b ^ 4) c d (k + 1) ^ 2) * if Even k then 1 else b
@[simp]
lemma complEDS₂_zero : complEDS₂ b c d 0 = 2 := by
simp [complEDS₂, one_add_one_eq_two]
@[simp]
lemma complEDS₂_one : complEDS₂ b c d 1 = b := by
simp [complEDS₂]
@[simp]
lemma complEDS₂_two : complEDS₂ b c d 2 = d := by
simp [complEDS₂]
@[simp]
lemma complEDS₂_three : complEDS₂ b c d 3 = preNormEDS (b ^ 4) c d 5 * b - d ^ 2 * b := by
simp [complEDS₂, if_neg (by decide : ¬Even (3 : ℤ)), sub_mul]
@[simp]
lemma complEDS₂_four : complEDS₂ b c d 4 =
c ^ 2 * preNormEDS (b ^ 4) c d 6 - preNormEDS (b ^ 4) c d 5 ^ 2 := by
simp [complEDS₂, if_pos (by decide : Even (4 : ℤ))]
@[simp]
lemma complEDS₂_neg (k : ℤ) : complEDS₂ b c d (-k) = complEDS₂ b c d k := by
simp_rw [complEDS₂, ← neg_add', ← sub_neg_eq_add, ← neg_sub', preNormEDS_neg, even_neg]
ring1
lemma preNormEDS_mul_complEDS₂ (k : ℤ) : preNormEDS (b ^ 4) c d k * complEDS₂ b c d k =
preNormEDS (b ^ 4) c d (2 * k) * if Even k then 1 else b := by
rw [complEDS₂, preNormEDS_even]
ring1
end PreNormEDS
section NormEDS
/-- The canonical example of a normalised EDS `W : ℤ → R`, with initial values
`W(0) = 0`, `W(1) = 1`, `W(2) = b`, `W(3) = c`, and `W(4) = d * b`.
This is defined in terms of `preNormEDS` whose even terms differ by a factor of `b`. -/
def normEDS (n : ℤ) : R :=
preNormEDS (b ^ 4) c d n * if Even n then b else 1
@[simp]
lemma normEDS_ofNat (n : ℕ) :
normEDS b c d n = preNormEDS' (b ^ 4) c d n * if Even n then b else 1 := by
simp [normEDS]
@[simp]
lemma normEDS_zero : normEDS b c d 0 = 0 := by
simp [normEDS]
@[simp]
lemma normEDS_one : normEDS b c d 1 = 1 := by
simp [normEDS]
@[simp]
lemma normEDS_two : normEDS b c d 2 = b := by
simp [normEDS]
@[simp]
lemma normEDS_three : normEDS b c d 3 = c := by
simp [normEDS, show ¬Even (3 : ℤ) by decide]
@[simp]
lemma normEDS_four : normEDS b c d 4 = d * b := by
simp [normEDS, show ¬Odd (4 : ℤ) by decide]
@[simp]
lemma normEDS_neg (n : ℤ) : normEDS b c d (-n) = -normEDS b c d n := by
simp_rw [normEDS, preNormEDS_neg, even_neg, neg_mul]
lemma normEDS_mul_complEDS₂ (k : ℤ) :
normEDS b c d k * complEDS₂ b c d k = normEDS b c d (2 * k) := by
simp_rw [normEDS, mul_right_comm, preNormEDS_mul_complEDS₂, mul_assoc, apply_ite₂, one_mul,
mul_one, ite_self, if_pos <| even_two_mul k]
lemma normEDS_dvd_normEDS_two_mul (k : ℤ) : normEDS b c d k ∣ normEDS b c d (2 * k) :=
⟨complEDS₂ .., (normEDS_mul_complEDS₂ ..).symm⟩
lemma complEDS₂_mul_b (k : ℤ) : complEDS₂ b c d k * b =
normEDS b c d (k - 1) ^ 2 * normEDS b c d (k + 2) -
normEDS b c d (k - 2) * normEDS b c d (k + 1) ^ 2 := by
simp_rw [complEDS₂, normEDS, Int.even_add, Int.even_sub, even_two, iff_true, Int.not_even_one,
iff_false]
split_ifs <;> ring1
lemma normEDS_even (m : ℤ) : normEDS b c d (2 * m) * b =
normEDS b c d (m - 1) ^ 2 * normEDS b c d m * normEDS b c d (m + 2) -
normEDS b c d (m - 2) * normEDS b c d m * normEDS b c d (m + 1) ^ 2 := by
rw [← normEDS_mul_complEDS₂, mul_assoc, complEDS₂_mul_b]
ring1
lemma normEDS_odd (m : ℤ) : normEDS b c d (2 * m + 1) =
normEDS b c d (m + 2) * normEDS b c d m ^ 3 -
normEDS b c d (m - 1) * normEDS b c d (m + 1) ^ 3 := by
simp_rw [normEDS, preNormEDS_odd, if_neg m.not_even_two_mul_add_one, Int.even_add, Int.even_sub,
even_two, iff_true, Int.not_even_one, iff_false]
split_ifs <;> ring1
/--
Strong recursion principle for a normalised EDS: if we have
* `P 0`, `P 1`, `P 2`, `P 3`, and `P 4`,
* for all `m : ℕ` we can prove `P (2 * (m + 3))` from `P k` for all `k < 2 * (m + 3)`, and
* for all `m : ℕ` we can prove `P (2 * (m + 2) + 1)` from `P k` for all `k < 2 * (m + 2) + 1`,
then we have `P n` for all `n : ℕ`.
-/
@[elab_as_elim]
noncomputable def normEDSRec' {P : ℕ → Sort u}
(zero : P 0) (one : P 1) (two : P 2) (three : P 3) (four : P 4)
(even : ∀ m : ℕ, (∀ k < 2 * (m + 3), P k) → P (2 * (m + 3)))
(odd : ∀ m : ℕ, (∀ k < 2 * (m + 2) + 1, P k) → P (2 * (m + 2) + 1)) (n : ℕ) : P n :=
n.evenOddStrongRec (by rintro (_ | _ | _ | _) h; exacts [zero, two, four, even _ h])
(by rintro (_ | _ | _) h; exacts [one, three, odd _ h])
/-- Recursion principle for a normalised EDS: if we have
* `P 0`, `P 1`, `P 2`, `P 3`, and `P 4`,
* for all `m : ℕ` we can prove `P (2 * (m + 3))` from `P (m + 1)`, `P (m + 2)`, `P (m + 3)`,
`P (m + 4)`, and `P (m + 5)`, and
* for all `m : ℕ` we can prove `P (2 * (m + 2) + 1)` from `P (m + 1)`, `P (m + 2)`, `P (m + 3)`,
and `P (m + 4)`,
then we have `P n` for all `n : ℕ`. -/
@[elab_as_elim]
noncomputable def normEDSRec {P : ℕ → Sort u}
(zero : P 0) (one : P 1) (two : P 2) (three : P 3) (four : P 4)
(even : ∀ m : ℕ, P (m + 1) → P (m + 2) → P (m + 3) → P (m + 4) → P (m + 5) → P (2 * (m + 3)))
(odd : ∀ m : ℕ, P (m + 1) → P (m + 2) → P (m + 3) → P (m + 4) → P (2 * (m + 2) + 1)) (n : ℕ) :
P n :=
normEDSRec' zero one two three four (fun _ ih => by apply even <;> exact ih _ <| by linarith only)
(fun _ ih => by apply odd <;> exact ih _ <| by linarith only) n
end NormEDS
section ComplEDS
variable (k : ℤ)
/-- The complement sequence `Wᶜ : ℤ × ℕ → R` for a normalised EDS `W : ℤ → R` that witnesses
`W(k) ∣ W(n * k)`. In other words, `W(k) * Wᶜ(k, n) = W(n * k)` for any `k, n ∈ ℤ`.
This is defined in terms of `normEDS` and agrees with `complEDS₂` when `n = 2`. -/
def complEDS' : ℕ → R
| 0 => 0
| 1 => 1
| (n + 2) => let m := n / 2 + 1
if hn : Even n then complEDS' m * complEDS₂ b c d (m * k) else
have : m + 1 < n + 2 :=
add_lt_add_left (Nat.div_lt_self (Nat.not_even_iff_odd.mp hn).pos one_lt_two) 2
complEDS' m ^ 2 * normEDS b c d ((m + 1) * k + 1) * normEDS b c d ((m + 1) * k - 1) -
complEDS' (m + 1) ^ 2 * normEDS b c d (m * k + 1) * normEDS b c d (m * k - 1)
@[simp]
lemma complEDS'_zero : complEDS' b c d k 0 = 0 := by
rw [complEDS']
@[simp]
lemma complEDS'_one : complEDS' b c d k 1 = 1 := by
rw [complEDS']
lemma complEDS'_even (m : ℕ) : complEDS' b c d k (2 * (m + 1)) =
complEDS' b c d k (m + 1) * complEDS₂ b c d ((m + 1) * k) := by
rw [show 2 * (m + 1) = 2 * m + 2 by rfl, complEDS', dif_pos <| even_two_mul m,
m.mul_div_cancel_left two_pos, Nat.cast_succ]
lemma complEDS'_odd (m : ℕ) : complEDS' b c d k (2 * (m + 1) + 1) =
complEDS' b c d k (m + 1) ^ 2
* normEDS b c d ((m + 2) * k + 1) * normEDS b c d ((m + 2) * k - 1) -
complEDS' b c d k (m + 2) ^ 2
* normEDS b c d ((m + 1) * k + 1) * normEDS b c d ((m + 1) * k - 1) := by
rw [show 2 * (m + 1) + 1 = 2 * m + 3 by rfl, complEDS', dif_neg m.not_even_two_mul_add_one]
simp [Nat.mul_add_div two_pos, add_assoc]
/-- The complement sequence `Wᶜ : ℤ × ℤ → R` for a normalised EDS `W : ℤ → R` that witnesses
`W(k) ∣ W(n * k)`. In other words, `W(k) * Wᶜ(k, n) = W(n * k)` for any `k, n ∈ ℤ`.
This extends `complEDS'` by defining its values at negative integers. -/
def complEDS (n : ℤ) : R :=
n.sign * complEDS' b c d k n.natAbs
@[simp]
lemma complEDS_ofNat (n : ℕ) : complEDS b c d k n = complEDS' b c d k n := by
by_cases hn : n = 0
· simp [hn, complEDS]
· simp [complEDS, Int.sign_natCast_of_ne_zero hn]
@[simp]
lemma complEDS_zero : complEDS b c d k 0 = 0 := by
simp [complEDS]
@[simp]
lemma complEDS_one : complEDS b c d k 1 = 1 := by
simp [complEDS]
@[simp]
lemma complEDS_neg (n : ℤ) : complEDS b c d k (-n) = -complEDS b c d k n := by
simp [complEDS]
lemma complEDS_even (m : ℤ) :
complEDS b c d k (2 * m) = complEDS b c d k m * complEDS₂ b c d (m * k) := by
induction m using Int.negInduction with
| nat m =>
rcases m with _ | _
· simp
norm_cast
simpa only [complEDS_ofNat] using complEDS'_even ..
| neg ih => simp_rw [mul_neg, complEDS_neg, ih, neg_mul, complEDS₂_neg]
lemma complEDS_odd (m : ℤ) : complEDS b c d k (2 * m + 1) =
complEDS b c d k m ^ 2 * normEDS b c d ((m + 1) * k + 1) * normEDS b c d ((m + 1) * k - 1) -
complEDS b c d k (m + 1) ^ 2 * normEDS b c d (m * k + 1) * normEDS b c d (m * k - 1) := by
induction m using Int.negInduction with
| nat m =>
rcases m with _ | _
· simp
norm_cast
simpa only [complEDS_ofNat] using complEDS'_odd ..
| neg ih m =>
rcases m with _ | m
· simp
simp_rw [Nat.cast_succ, show 2 * -(m + 1 : ℤ) + 1 = -(2 * m + 1) by rfl,
show (-(m + 1 : ℤ) + 1) = -m by ring1, neg_mul, ← sub_neg_eq_add, ← neg_sub', sub_neg_eq_add,
← neg_add', complEDS_neg, normEDS_neg, ih]
ring1
/-- Strong recursion principle for the complement sequence for a normalised EDS: if we have
* `P 0`, `P 1`,
* for all `m : ℕ` we can prove `P (2 * (m + 3))` from `P k` for all `k < 2 * (m + 3)`, and
* for all `m : ℕ` we can prove `P (2 * (m + 2) + 1)` from `P k` for all `k < 2 * (m + 2) + 1`,
then we have `P n` for all `n : ℕ`. -/
@[elab_as_elim]
noncomputable def complEDSRec' {P : ℕ → Sort u} (zero : P 0) (one : P 1)
(even : ∀ m : ℕ, (∀ k < 2 * (m + 1), P k) → P (2 * (m + 1)))
(odd : ∀ m : ℕ, (∀ k < 2 * (m + 1) + 1, P k) → P (2 * (m + 1) + 1)) (n : ℕ) : P n :=
n.evenOddStrongRec (by rintro (_ | _) h; exacts [zero, even _ h])
(by rintro (_ | _) h; exacts [one, odd _ h])
/-- Recursion principle for the complement sequence for a normalised EDS: if we have
* `P 0`, `P 1`,
* for all `m : ℕ` we can prove `P (2 * (m + 3))` from `P (m + 1)`, `P (m + 2)`, `P (m + 3)`,
`P (m + 4)`, and `P (m + 5)`, and
* for all `m : ℕ` we can prove `P (2 * (m + 2) + 1)` from `P (m + 1)`, `P (m + 2)`, `P (m + 3)`,
and `P (m + 4)`,
then we have `P n` for all `n : ℕ`. -/
@[elab_as_elim]
noncomputable def complEDSRec {P : ℕ → Sort u} (zero : P 0) (one : P 1)
(even : ∀ m : ℕ, P (m + 1) → P (2 * (m + 1)))
(odd : ∀ m : ℕ, P (m + 1) → P (m + 2) → P (2 * (m + 1) + 1)) (n : ℕ) : P n :=
complEDSRec' zero one (fun _ ih => even _ <| ih _ <| by linarith only)
(fun _ ih => odd _ (ih _ <| by linarith only) <| ih _ <| by linarith only) n
end ComplEDS
section Map
variable {S : Type v} [CommRing S] (f : R →+* S)
@[simp]
lemma map_preNormEDS' (n : ℕ) : f (preNormEDS' b c d n) = preNormEDS' (f b) (f c) (f d) n := by
induction n using normEDSRec' with
| zero => simp
| one => simp
| two => simp
| three => simp
| four => simp
| _ _ ih =>
simp only [preNormEDS'_even, preNormEDS'_odd, apply_ite f, map_pow, map_mul, map_sub, map_one]
repeat rw [ih _ <| by linarith only]
@[simp]
lemma map_preNormEDS (n : ℤ) : f (preNormEDS b c d n) = preNormEDS (f b) (f c) (f d) n := by
simp [preNormEDS]
@[simp]
lemma map_complEDS₂ (n : ℤ) : f (complEDS₂ b c d n) = complEDS₂ (f b) (f c) (f d) n := by
simp [complEDS₂, apply_ite f]
@[simp]
lemma map_normEDS (n : ℤ) : f (normEDS b c d n) = normEDS (f b) (f c) (f d) n := by
simp [normEDS, apply_ite f]
@[simp]
lemma map_complEDS' (k : ℤ) (n : ℕ) :
f (complEDS' b c d k n) = complEDS' (f b) (f c) (f d) k n := by
induction n using complEDSRec' with
| zero => simp
| one => simp
| _ _ ih =>
simp only [complEDS'_even, complEDS'_odd, map_normEDS, map_complEDS₂, map_pow, map_mul, map_sub]
repeat rw [ih _ <| by linarith only]
@[simp]
lemma map_complEDS (k n : ℤ) : f (complEDS b c d k n) = complEDS (f b) (f c) (f d) k n := by
simp [complEDS]
end Map