-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathBasic.lean
More file actions
486 lines (371 loc) · 18.7 KB
/
Copy pathBasic.lean
File metadata and controls
486 lines (371 loc) · 18.7 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
/-
Copyright (c) 2024 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
module
public import Mathlib.Algebra.Group.Action.Pi
public import Mathlib.Algebra.Group.End
public import Mathlib.Algebra.Module.NatInt
public import Mathlib.Algebra.Order.Archimedean.Basic
import Mathlib.Algebra.Order.Group.Basic
/-!
# Maps (semi)conjugating a shift to a shift
Denote by $S^1$ the unit circle `UnitAddCircle`.
A common way to study a self-map $f\colon S^1\to S^1$ of degree `1`
is to lift it to a map $\tilde f\colon \mathbb R\to \mathbb R$
such that $\tilde f(x + 1) = \tilde f(x)+1$ for all `x`.
In this file we define a structure and a typeclass
for bundled maps satisfying `f (x + a) = f x + b`.
We use parameters `a` and `b` instead of `1` to accommodate for two use cases:
- maps between circles of different lengths;
- self-maps $f\colon S^1\to S^1$ of degree other than one,
including orientation-reversing maps.
-/
@[expose] public section
assert_not_exists Finset
open Function Set
/-- A bundled map `f : G → H` such that `f (x + a) = f x + b` for all `x`,
denoted as `f : G →+c[a, b] H`.
One can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/
structure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where
/-- The underlying function of an `AddConstMap`.
Use automatic coercion to function instead. -/
protected toFun : G → H
/-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/
map_add_const' (x : G) : toFun (x + a) = toFun x + b
@[inherit_doc]
scoped[AddConstMap] notation:25 G " →+c[" a ", " b "] " H => AddConstMap G H a b
/-- Typeclass for maps satisfying `f (x + a) = f x + b`.
Note that `a` and `b` are `outParam`s,
so one should not add instances like
`[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/
class AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H]
(a : outParam G) (b : outParam H) [FunLike F G H] : Prop where
/-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`:
`∀ x, f (x + a) = f x + b`. -/
map_add_const (f : F) (x : G) : f (x + a) = f x + b
namespace AddConstMapClass
/-!
### Properties of `AddConstMapClass` maps
In this section we prove properties like `f (x + n • a) = f x + n • b`.
-/
scoped[AddConstMapClass] attribute [simp] map_add_const
variable {F G H : Type*} [FunLike F G H] {a : G} {b : H}
protected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) :
Semiconj f (· + a) (· + b) :=
map_add_const f
@[scoped simp]
theorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]
(f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by
simpa using (AddConstMapClass.semiconj f).iterate_right n x
@[scoped simp]
theorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by simp [← map_add_nsmul]
theorem map_add_one [AddMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) : f (x + 1) = f x + b := map_add_const f x
@[scoped simp]
theorem map_add_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :
f (x + ofNat(n)) = f x + (ofNat(n) : ℕ) • b :=
map_add_nat' f x n
theorem map_add_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (x : G) (n : ℕ) : f (x + n) = f x + n := by simp
theorem map_add_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :
f (x + ofNat(n)) = f x + ofNat(n) := map_add_nat f x n
@[scoped simp]
theorem map_const [AddZeroClass G] [Add H] [AddConstMapClass F G H a b] (f : F) :
f a = f 0 + b := by
simpa using map_add_const f 0
theorem map_one [AddZeroClass G] [One G] [Add H] [AddConstMapClass F G H 1 b] (f : F) :
f 1 = f 0 + b :=
map_const f
@[scoped simp]
theorem map_nsmul_const [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]
(f : F) (n : ℕ) : f (n • a) = f 0 + n • b := by
simpa using map_add_nsmul f 0 n
@[scoped simp]
theorem map_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (n : ℕ) : f n = f 0 + n • b := by
simpa using map_add_nat' f 0 n
theorem map_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (n : ℕ) [n.AtLeastTwo] :
f (ofNat(n)) = f 0 + (ofNat(n) : ℕ) • b :=
map_nat' f n
theorem map_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : ℕ) : f n = f 0 + n := by simp
theorem map_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : ℕ) [n.AtLeastTwo] :
f ofNat(n) = f 0 + ofNat(n) := map_nat f n
@[scoped simp]
theorem map_const_add [AddCommMagma G] [Add H] [AddConstMapClass F G H a b]
(f : F) (x : G) : f (a + x) = f x + b := by
rw [add_comm, map_add_const]
theorem map_one_add [AddCommMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) : f (1 + x) = f x + b := map_const_add f x
@[scoped simp]
theorem map_nsmul_add [AddCommMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]
(f : F) (n : ℕ) (x : G) : f (n • a + x) = f x + n • b := by
rw [add_comm, map_add_nsmul]
@[scoped simp]
theorem map_nat_add' [AddCommMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (n : ℕ) (x : G) : f (↑n + x) = f x + n • b := by
simpa using map_nsmul_add f n x
theorem map_ofNat_add' [AddCommMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]
(f : F) (n : ℕ) [n.AtLeastTwo] (x : G) :
f (ofNat(n) + x) = f x + ofNat(n) • b :=
map_nat_add' f n x
theorem map_nat_add [AddCommMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : ℕ) (x : G) : f (↑n + x) = f x + n := by simp
theorem map_ofNat_add [AddCommMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : ℕ) [n.AtLeastTwo] (x : G) :
f (ofNat(n) + x) = f x + ofNat(n) :=
map_nat_add f n x
@[scoped simp]
theorem map_sub_nsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (x : G) (n : ℕ) : f (x - n • a) = f x - n • b := by
conv_rhs => rw [← sub_add_cancel x (n • a), map_add_nsmul, add_sub_cancel_right]
@[scoped simp]
theorem map_sub_const [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (x : G) : f (x - a) = f x - b := by
simpa using map_sub_nsmul f x 1
theorem map_sub_one [AddGroup G] [One G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) : f (x - 1) = f x - b :=
map_sub_const f x
@[scoped simp]
theorem map_sub_nat' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : ℕ) : f (x - n) = f x - n • b := by
simpa using map_sub_nsmul f x n
@[scoped simp]
theorem map_sub_ofNat' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :
f (x - ofNat(n)) = f x - ofNat(n) • b :=
map_sub_nat' f x n
@[scoped simp]
theorem map_add_zsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (x : G) : ∀ n : ℤ, f (x + n • a) = f x + n • b
| (n : ℕ) => by simp
| .negSucc n => by simp [← sub_eq_add_neg]
@[scoped simp]
theorem map_zsmul_const [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (n : ℤ) : f (n • a) = f 0 + n • b := by
simpa using map_add_zsmul f 0 n
@[scoped simp]
theorem map_add_int' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : ℤ) : f (x + n) = f x + n • b := by
rw [← map_add_zsmul f x n, zsmul_one]
theorem map_add_int [AddGroupWithOne G] [AddGroupWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (x : G) (n : ℤ) : f (x + n) = f x + n := by simp
@[scoped simp]
theorem map_sub_zsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (x : G) (n : ℤ) : f (x - n • a) = f x - n • b := by
simpa [sub_eq_add_neg] using map_add_zsmul f x (-n)
@[scoped simp]
theorem map_sub_int' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (x : G) (n : ℤ) : f (x - n) = f x - n • b := by
rw [← map_sub_zsmul, zsmul_one]
theorem map_sub_int [AddGroupWithOne G] [AddGroupWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (x : G) (n : ℤ) : f (x - n) = f x - n := by simp
@[scoped simp]
theorem map_zsmul_add [AddCommGroup G] [AddGroup H] [AddConstMapClass F G H a b]
(f : F) (n : ℤ) (x : G) : f (n • a + x) = f x + n • b := by
rw [add_comm, map_add_zsmul]
@[scoped simp]
theorem map_int_add' [AddCommGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]
(f : F) (n : ℤ) (x : G) : f (↑n + x) = f x + n • b := by
rw [← map_zsmul_add, zsmul_one]
theorem map_int_add [AddCommGroupWithOne G] [AddGroupWithOne H] [AddConstMapClass F G H 1 1]
(f : F) (n : ℤ) (x : G) : f (↑n + x) = f x + n := by simp
theorem map_fract {R : Type*} [Ring R] [LinearOrder R] [FloorRing R] [AddGroup H]
[FunLike F R H] [AddConstMapClass F R H 1 b] (f : F) (x : R) :
f (Int.fract x) = f x - ⌊x⌋ • b :=
map_sub_int' ..
open scoped Relator in
/-- Auxiliary lemmas for the "monotonicity on a fundamental interval implies monotonicity" lemmas.
We formulate it for any relation so that the proof works both for `Monotone` and `StrictMono`. -/
protected theorem rel_map_of_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G]
[Archimedean G] [AddGroup H]
[AddConstMapClass F G H a b] {f : F} {R : H → H → Prop} [IsTrans H R]
[hR : CovariantClass H H (fun x y ↦ y + x) R] (ha : 0 < a) {l : G}
(hf : ∀ x ∈ Icc l (l + a), ∀ y ∈ Icc l (l + a), x < y → R (f x) (f y)) :
((· < ·) ⇒ R) f f := fun x y hxy ↦ by
replace hR := hR.elim
have ha' : 0 ≤ a := ha.le
-- Shift both points by `m • a` so that `l ≤ x < l + a`
wlog hx : x ∈ Ico l (l + a) generalizing x y
· rcases existsUnique_sub_zsmul_mem_Ico ha x l with ⟨m, hm, -⟩
suffices R (f (x - m • a)) (f (y - m • a)) by simpa using hR (m • b) this
exact this _ _ (by simpa) hm
· -- Now find `n` such that `l + n • a < y ≤ l + (n + 1) • a`
rcases existsUnique_sub_zsmul_mem_Ioc ha y l with ⟨n, hny, -⟩
rcases lt_trichotomy n 0 with hn | rfl | hn
· -- Since `l ≤ x ≤ y`, the case `n < 0` is impossible
refine absurd ?_ hxy.not_ge
calc
y ≤ l + a + n • a := sub_le_iff_le_add.1 hny.2
_ = l + (n + 1) • a := by rw [add_comm n, add_smul, one_smul, add_assoc]
_ ≤ l + (0 : ℤ) • a := by gcongr; lia
_ ≤ x := by simpa using hx.1
· -- If `n = 0`, then `l < y ≤ l + a`, hence we can apply the assumption
exact hf x (Ico_subset_Icc_self hx) y (by simpa using Ioc_subset_Icc_self hny) hxy
· -- In the remaining case `0 < n` we use transitivity.
-- If `R = (· < ·)`, then the proof looks like
-- `f x < f (l + a) ≤ f (l + n • a) < f y`
trans f (l + (1 : ℤ) • a)
· grind
have hy : R (f (l + n • a)) (f y) := by
rw [← sub_add_cancel y (n • a), map_add_zsmul, map_add_zsmul]
refine hR _ <| hf _ ?_ _ (Ioc_subset_Icc_self hny) hny.1; simpa
rw [← Int.add_one_le_iff, zero_add] at hn
rcases hn.eq_or_lt with rfl | hn; · assumption
trans f (l + n • a)
· refine Int.rel_of_forall_rel_succ_of_lt R (f := (f <| l + · • a)) (fun k ↦ ?_) hn
simp_rw [add_comm k 1, add_zsmul, ← add_assoc, one_zsmul, map_add_zsmul]
refine hR (k • b) (hf _ ?_ _ ?_ ?_) <;> simpa
· assumption
theorem monotone_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G]
[AddCommGroup H] [PartialOrder H] [IsOrderedAddMonoid H]
[AddConstMapClass F G H a b] {f : F} (ha : 0 < a) (l : G) :
Monotone f ↔ MonotoneOn f (Icc l (l + a)) :=
⟨(Monotone.monotoneOn · _), fun hf ↦ monotone_iff_forall_lt.2 <|
AddConstMapClass.rel_map_of_Icc ha fun _x hx _y hy hxy ↦ hf hx hy hxy.le⟩
theorem antitone_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G]
[AddCommGroup H] [PartialOrder H] [IsOrderedAddMonoid H]
[AddConstMapClass F G H a b] {f : F} (ha : 0 < a) (l : G) :
Antitone f ↔ AntitoneOn f (Icc l (l + a)) :=
monotone_iff_Icc (H := Hᵒᵈ) ha l
theorem strictMono_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G]
[AddCommGroup H] [PartialOrder H] [IsOrderedAddMonoid H]
[AddConstMapClass F G H a b] {f : F} (ha : 0 < a) (l : G) :
StrictMono f ↔ StrictMonoOn f (Icc l (l + a)) :=
⟨(StrictMono.strictMonoOn · _), AddConstMapClass.rel_map_of_Icc ha⟩
theorem strictAnti_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G]
[AddCommGroup H] [PartialOrder H] [IsOrderedAddMonoid H]
[AddConstMapClass F G H a b] {f : F} (ha : 0 < a) (l : G) :
StrictAnti f ↔ StrictAntiOn f (Icc l (l + a)) :=
strictMono_iff_Icc (H := Hᵒᵈ) ha l
end AddConstMapClass
open AddConstMapClass
namespace AddConstMap
section Add
variable {G H : Type*} [Add G] [Add H] {a : G} {b : H}
/-!
### Coercion to function
-/
instance : FunLike (G →+c[a, b] H) G H where
coe := AddConstMap.toFun
coe_injective | ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
@[simp, push_cast] theorem coe_mk (f : G → H) (hf) : ⇑(mk f hf : G →+c[a, b] H) = f := rfl
@[simp] theorem mk_coe (f : G →+c[a, b] H) : mk f f.2 = f := rfl
@[simp] theorem toFun_eq_coe (f : G →+c[a, b] H) : f.toFun = f := rfl
instance : AddConstMapClass (G →+c[a, b] H) G H a b where
map_add_const f := f.map_add_const'
@[ext] protected theorem ext {f g : G →+c[a, b] H} (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext _ _ h
initialize_simps_projections AddConstMap (toFun → coe, as_prefix coe)
/-!
### Constructions about `G →+c[a, b] H`
-/
/-- The identity map as `G →+c[a, a] G`. -/
@[simps -fullyApplied]
protected def id : G →+c[a, a] G := ⟨id, fun _ ↦ rfl⟩
instance : Inhabited (G →+c[a, a] G) := ⟨.id⟩
/-- Composition of two `AddConstMap`s. -/
@[simps -fullyApplied]
def comp {K : Type*} [Add K] {c : K} (g : H →+c[b, c] K) (f : G →+c[a, b] H) :
G →+c[a, c] K :=
⟨g ∘ f, by simp⟩
@[simp] theorem comp_id (f : G →+c[a, b] H) : f.comp .id = f := rfl
@[simp] theorem id_comp (f : G →+c[a, b] H) : .comp .id f = f := rfl
/-- Change constants `a` and `b` in `(f : G →+c[a, b] H)` to improve definitional equalities. -/
@[simps -fullyApplied]
def replaceConsts (f : G →+c[a, b] H) (a' b') (ha : a = a') (hb : b = b') :
G →+c[a', b'] H where
toFun := f
map_add_const' := ha ▸ hb ▸ f.map_add_const'
/-!
### Additive action on `G →+c[a, b] H`
-/
/-- If `f` is an `AddConstMap`, then so is `(c +ᵥ f ·)`. -/
instance {K : Type*} [VAdd K H] [VAddAssocClass K H H] : VAdd K (G →+c[a, b] H) :=
⟨fun c f ↦ ⟨c +ᵥ ⇑f, fun x ↦ by simp [vadd_add_assoc]⟩⟩
@[simp, norm_cast]
theorem coe_vadd {K : Type*} [VAdd K H] [VAddAssocClass K H H] (c : K) (f : G →+c[a, b] H) :
⇑(c +ᵥ f) = c +ᵥ ⇑f :=
rfl
instance {K : Type*} [AddMonoid K] [AddAction K H] [VAddAssocClass K H H] :
AddAction K (G →+c[a, b] H) :=
DFunLike.coe_injective.addAction _ coe_vadd
/-!
### Monoid structure on endomorphisms `G →+c[a, a] G`
-/
instance : Mul (G →+c[a, a] G) := ⟨comp⟩
instance : One (G →+c[a, a] G) := ⟨.id⟩
instance : Pow (G →+c[a, a] G) ℕ+ where
pow f n := ⟨f^[n], Commute.iterate_left (AddConstMapClass.semiconj f) _⟩
instance : Pow (G →+c[a, a] G) ℕ where
pow f n := ⟨f^[n], Commute.iterate_left (AddConstMapClass.semiconj f) _⟩
instance : Monoid (G →+c[a, a] G) :=
DFunLike.coe_injective.monoid (M₂ := Function.End G) _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
fun _ _ ↦ rfl
theorem mul_def (f g : G →+c[a, a] G) : f * g = f.comp g := rfl
@[simp, push_cast] theorem coe_mul (f g : G →+c[a, a] G) : ⇑(f * g) = f ∘ g := rfl
theorem one_def : (1 : G →+c[a, a] G) = .id := rfl
@[simp, push_cast] theorem coe_one : ⇑(1 : G →+c[a, a] G) = id := rfl
@[simp, push_cast] theorem coe_pow (f : G →+c[a, a] G) (n : ℕ) : ⇑(f ^ n) = f^[n] := rfl
theorem ppow_apply (f : G →+c[a, a] G) (n : ℕ+) (x : G) : (f ^ n) x = f^[n] x := rfl
theorem pow_apply (f : G →+c[a, a] G) (n : ℕ) (x : G) : (f ^ n) x = f^[n] x := rfl
/-- Coercion to functions as a monoid homomorphism to `Function.End G`. -/
@[simps -fullyApplied]
def toEnd : (G →+c[a, a] G) →* Function.End G where
toFun := DFunLike.coe
map_mul' _ _ := rfl
map_one' := rfl
end Add
section AddZeroClass
variable {G H K : Type*} [Add G] [AddZeroClass H] {a : G} {b : H}
/-!
### Multiplicative action on `(b : H) × (G →+c[a, b] H)`
If `K` acts distributively on `H`, then for each `f : G →+c[a, b] H`
we define `(AddConstMap.smul c f : G →+c[a, c • b] H)`.
One can show that this defines a multiplicative action of `K` on `(b : H) × (G →+c[a, b] H)`
but we don't do this at the moment because we don't need this.
-/
/-- Pointwise scalar multiplication of `f : G →+c[a, b] H` as a map `G →+c[a, c • b] H`. -/
@[simps -fullyApplied]
def smul [DistribSMul K H] (c : K) (f : G →+c[a, b] H) : G →+c[a, c • b] H where
toFun := c • ⇑f
map_add_const' x := by simp [smul_add]
end AddZeroClass
section AddMonoid
variable {G : Type*} [AddMonoid G] {a : G}
/-- The map that sends `c` to a translation by `c`
as a monoid homomorphism from `Multiplicative G` to `G →+c[a, a] G`. -/
@[simps! -fullyApplied]
def addLeftHom : Multiplicative G →* (G →+c[a, a] G) where
toFun c := c.toAdd +ᵥ .id
map_one' := by ext; apply zero_add
map_mul' _ _ := by ext; apply add_assoc
end AddMonoid
section AddCommGroup
variable {G H : Type*} [AddCommGroup G] [AddCommGroup H] {a : G} {b : H}
/-- If `f : G → H` is an `AddConstMap`, then so is `fun x ↦ -f (-x)`. -/
@[simps! apply_coe]
def conjNeg : (G →+c[a, b] H) ≃ (G →+c[a, b] H) :=
Involutive.toPerm (fun f ↦ ⟨fun x ↦ - f (-x), fun _ ↦ by simp [neg_add_eq_sub]⟩) fun _ ↦
AddConstMap.ext fun _ ↦ by simp
@[simp] theorem conjNeg_symm : (conjNeg (a := a) (b := b)).symm = conjNeg := rfl
end AddCommGroup
section FloorRing
variable {R G : Type*} [Ring R] [LinearOrder R] [IsStrictOrderedRing R] [FloorRing R] [AddGroup G]
(a : G)
/-- A map `f : R →+c[1, a] G` is defined by its values on `Set.Ico 0 1`. -/
def mkFract : (Ico (0 : R) 1 → G) ≃ (R →+c[1, a] G) where
toFun f := ⟨fun x ↦ f ⟨Int.fract x, Int.fract_nonneg _, Int.fract_lt_one _⟩ + ⌊x⌋ • a, fun x ↦ by
simp [add_one_zsmul, add_assoc]⟩
invFun f x := f x
left_inv _ := by ext x; simp [Int.fract_eq_self.2 x.2, Int.floor_eq_zero_iff.2 x.2]
right_inv f := by ext x; simp [map_fract]
end FloorRing
end AddConstMap