File size: 5,546 Bytes
7f5fab8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import Mathlib.Data.Nat.Factorial.Basic
import Mathlib.Data.Rat.Lemmas
import Mathlib.Analysis.Real.Sqrt
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.NormNum

namespace OAI

/-!
# Factorial dilation and square arithmetic reductions
-/

section

/-! Arithmetic in the permutation-product step of Lemma `lem:universal`.
The input `s` is the natural sum of arbitrary multiplicity entries. No
geometric existence or incidence statement is encoded in these lemmas. -/
namespace Nagata.Workers.W14

/-- A violating multiplicity sum is positive when the degree and point count are positive. -/
theorem multiplicity_sum_pos {r d s : ℕ} (hr : 0 < r) (hd : 0 < d)
    (h : (d : ℝ) * Real.sqrt r ≤ s) : 0 < s := by
  have hr' : (0 : ℝ) < r := by exact_mod_cast hr
  have hd' : (0 : ℝ) < d := by exact_mod_cast hd
  have hs' : (0 : ℝ) < s :=
    lt_of_lt_of_le (mul_pos hd' (Real.sqrt_pos.2 hr')) h
  exact_mod_cast hs'

/-- The scalar ratio estimate underlying symmetrization. -/
theorem symmetrized_ratio_le {r d s : ℕ} (hs : 0 < s)
    (h : (d : ℝ) * Real.sqrt r ≤ s) :
    (r : ℝ) * d / s ≤ Real.sqrt r := by
  have hs' : (0 : ℝ) < s := by exact_mod_cast hs
  apply (div_le_iff₀ hs').2
  calc
    (r : ℝ) * d = Real.sqrt r * ((d : ℝ) * Real.sqrt r) := by
      calc
        (r : ℝ) * d = (d : ℝ) * (Real.sqrt r * Real.sqrt r) := by
          rw [Real.mul_self_sqrt (Nat.cast_nonneg r)]
          exact mul_comm _ _
        _ = _ := by ac_rfl
    _ ≤ Real.sqrt r * s := mul_le_mul_of_nonneg_left h (Real.sqrt_nonneg _)

/-- Cancel the factorial that occurs in every point's multiplicity. -/
theorem factorial_ratio_eq {r d s : ℕ} (hr : 0 < r) (hs : 0 < s) :
    ((r.factorial * d : ℕ) : ℝ) / (((r - 1).factorial * s : ℕ) : ℝ) =
      (r : ℝ) * d / s := by
  have hf : ((r - 1).factorial : ℝ) ≠ 0 := by
    exact_mod_cast (Nat.factorial_ne_zero (r - 1))
  have hs' : (s : ℝ) ≠ 0 := by exact_mod_cast hs.ne'
  rw [← Nat.mul_factorial_pred hr.ne']
  push_cast
  apply (div_eq_div_iff (mul_ne_zero hf hs') hs').2
  simp only [mul_assoc, mul_comm, mul_left_comm]

/-- Exact positive degree and common multiplicity produced by the permutation product. -/
theorem factorial_symmetrization {r d s : ℕ} (hr : 0 < r) (hd : 0 < d)
    (h : (d : ℝ) * Real.sqrt r ≤ s) :
    0 < r.factorial * d ∧ 0 < (r - 1).factorial * s ∧
      ((r.factorial * d : ℕ) : ℝ) / (((r - 1).factorial * s : ℕ) : ℝ) ≤
        Real.sqrt r := by
  have hs := multiplicity_sum_pos hr hd h
  refine ⟨Nat.mul_pos (Nat.factorial_pos _) hd,
    Nat.mul_pos (Nat.factorial_pos _) hs, ?_⟩
  rw [factorial_ratio_eq hr hs]
  exact symmetrized_ratio_le hs h

/-- Taking common positive powers preserves the degree to multiplicity ratio. -/
theorem common_power_ratio (d m N : ℕ) (hN : 0 < N) :
    ((N * d : ℕ) : ℝ) / ((N * m : ℕ) : ℝ) = (d : ℝ) / m := by
  have hN' : (N : ℝ) ≠ 0 := by exact_mod_cast hN.ne'
  push_cast
  exact mul_div_mul_left _ _ hN'

end Nagata.Workers.W14

end

section

namespace Nagata.Workers.W14

/-- For nonsquare point counts a rational homogeneous slope cannot equal the boundary. -/
theorem ratio_ne_sqrt_of_nonsquare (r d m : ℕ) (hr : ¬ IsSquare r) :
    (d : ℝ) / m ≠ Real.sqrt r := by
  intro heq
  apply hr
  apply Rat.isSquare_natCast_iff.mp
  refine ⟨(d : ℚ) / m, ?_⟩
  apply Rat.cast_injective (α := ℝ)
  push_cast
  rw [heq]
  exact (Real.mul_self_sqrt (Nat.cast_nonneg r)).symm

/-- Consequently a weak homogeneous bound is strict for nonsquare `r`. -/
theorem ratio_lt_sqrt_of_nonsquare {r d m : ℕ} (hr : ¬ IsSquare r)
    (h : (d : ℝ) / m ≤ Real.sqrt r) : (d : ℝ) / m < Real.sqrt r :=
  lt_of_le_of_ne h (ratio_ne_sqrt_of_nonsquare r d m hr)

/-- The two numerical exclusions put the homogeneous slope in the elliptic range. -/
theorem elliptic_ratio_range {r d m : ℕ} (hr : ¬ IsSquare r) (hm : 0 < m)
    (hlow : 3 * m < d) (hhigh : (d : ℝ) / m ≤ Real.sqrt r) :
    3 < (d : ℝ) / m ∧ (d : ℝ) / m < Real.sqrt r := by
  have hm' : (0 : ℝ) < m := by exact_mod_cast hm
  refine ⟨(lt_div_iff₀ hm').2 ?_, ratio_lt_sqrt_of_nonsquare hr hhigh⟩
  exact_mod_cast hlow

end Nagata.Workers.W14

end

section

/-! Arithmetic of the square branch, with the equality case retained. -/
namespace Nagata.Workers.W14

/-- The positive square root of a natural square is its natural root. -/
theorem sqrt_nat_square (k : ℕ) : Real.sqrt ((k * k : ℕ) : ℝ) = k := by
  rw [Nat.cast_mul, Real.sqrt_mul_self (Nat.cast_nonneg k)]

/-- An equality with a natural square root is equivalent to equality of squares. -/
theorem sqrt_nat_eq_iff (r k : ℕ) : Real.sqrt (r : ℝ) = k ↔ r = k * k := by
  constructor
  · intro h
    have hs := Real.mul_self_sqrt (Nat.cast_nonneg r)
    rw [h] at hs
    exact_mod_cast hs.symm
  · rintro rfl
    exact sqrt_nat_square k

/-- A square point count at least ten has root at least four. -/
theorem square_root_ge_four {r k : ℕ} (hr : 10 ≤ r) (hk : r = k * k) : 4 ≤ k := by
  by_contra h
  have hk3 : k ≤ 3 := Nat.le_of_lt_succ (Nat.lt_of_not_ge h)
  have hs : k * k ≤ 9 := by nlinarith
  omega

/-- For a positive denominator the weak square bound is exactly the integral bound. -/
theorem square_ratio_le_iff {r k d m : ℕ} (hk : r = k * k) (hm : 0 < m) :
    (d : ℝ) / m ≤ Real.sqrt r ↔ d ≤ k * m := by
  rw [(sqrt_nat_eq_iff r k).2 hk]
  have hmR : (0 : ℝ) < m := by exact_mod_cast hm
  rw [div_le_iff₀ hmR]
  norm_cast

end Nagata.Workers.W14

end

end OAI