This journal is in preparation. Submissions are open as a pilot and the editorial board is being formed. Articles marked Demonstration show the format only.
Journal of Machine-Verified MathematicsPeer-reviewed mathematics with machine-checked proofs, for the age of AI

E424/Input/Gen.lean

All files · 63 lines · source at the verified commit

1module
2
3public import Mathlib
4
5@[expose] public section
6
7/-!
8# Input, part 1: the generated set, and affine maps that preserve it
9
10`Gen n` says that `n` is in the smallest set that contains 2, 3 and `a * b - 1` for distinct members `a`, `b`.
11`IsMap Q c` says that `x ↦ Q x - c` maps `{x ∈ A | 14 < x}` into itself.
12-/
13
14set_option linter.style.header false
15
16namespace E424.Inp
17
18/-- Inductive form of membership in the generated set. -/
19inductive Gen : ℕ → Prop
20 | two : Gen 2
21 | three : Gen 3
22 | mul_sub_one {a b : ℕ} : Gen a → Gen b → a ≠ b → Gen (a * b - 1)
23
24/-- The generated set. -/
25def genSet : Set ℕ := {n | Gen n}
26
27theorem mem_iff (n : ℕ) : n ∈ genSet ↔ Gen n := Iff.rfl
28
29theorem Gen.five : Gen 5 := .mul_sub_one .two .three (by norm_num)
30theorem Gen.nine : Gen 9 := .mul_sub_one .two .five (by norm_num)
31theorem Gen.fourteen : Gen 14 := .mul_sub_one .three .five (by norm_num)
32theorem Gen.seventeen : Gen 17 := .mul_sub_one .two .nine (by norm_num)
33
34/-- The five multipliers. -/
35def Letter (a : ℕ) : Prop := a = 2 ∨ a = 3 ∨ a = 5 ∨ a = 9 ∨ a = 14
36
37theorem Letter.gen {a : ℕ} (h : Letter a) : Gen a := by
38 rcases h with rfl | rfl | rfl | rfl | rfl
39 exacts [.two, .three, .five, .nine, .fourteen]
40
41theorem Letter.two_le {a : ℕ} (h : Letter a) : 2 ≤ a := by unfold Letter at h; omega
42theorem Letter.le {a : ℕ} (h : Letter a) : a ≤ 14 := by unfold Letter at h; omega
43
44/-- `x ↦ Q x - c` preserves the elements above 14. -/
45def IsMap (Q c : ℕ) : Prop := c < Q ∧ ∀ x, Gen x → 14 < x → Gen (Q * x - c) ∧ 14 < Q * x - c
46
47theorem IsMap.one : IsMap 1 0 := ⟨by norm_num, fun x hx h => by simpa using ⟨hx, h⟩⟩
48
49/-- Compose with `y ↦ a y - 1`. -/
50theorem IsMap.step {Q c a : ℕ} (h : IsMap Q c) (ha : Letter a) : IsMap (a * Q) (a * c + 1) := by
51 have h2 := ha.two_le
52 obtain ⟨hc, hx⟩ := h
53 have hle : a * (c + 1) ≤ a * Q := Nat.mul_le_mul_left _ hc
54 refine ⟨by nlinarith, fun x hxG h14 => ?_⟩
55 obtain ⟨hg, hb⟩ := hx x hxG h14
56 have heq : a * Q * x - (a * c + 1) = a * (Q * x - c) - 1 := by
57 rw [Nat.mul_sub, mul_assoc, Nat.sub_sub]
58 rw [heq]
59 have : 2 * (Q * x - c) ≤ a * (Q * x - c) := Nat.mul_le_mul_right _ h2
60 exact ⟨.mul_sub_one ha.gen hg (by have := ha.le; omega), by omega⟩
61
62end E424.Inp
63