Theorem: AddCircle.addOrderOf_eq_pos_iff
File: Mathlib/Topology/Instances/AddCircle.lean

tactic: refine' ⟨QuotientAddGroup.induction_on' u fun k hk => _, _⟩
state_before: 𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
⊢ addOrderOf u = n ↔ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = u

tactic: have h0 := addOrderOf_nsmul_eq_zero (k : AddCircle p)
state_before: case refine'_2
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k

tactic: rw [hk, ← coe_nsmul, coe_eq_zero_iff] at h0
state_before: case refine'_2
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
h0 : addOrderOf ↑k • ↑k = 0
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k

tactic: obtain ⟨a, ha⟩ := h0
state_before: case refine'_2
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
h0 : ∃ n_1, n_1 • p = n • k
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k

tactic: have h0 : (_ : 𝕜) ≠ 0 := Nat.cast_ne_zero.2 h.ne'
state_before: case refine'_2.intro
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : a • p = n • k
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k

tactic: rw [nsmul_eq_mul, mul_comm, ← div_eq_iff h0, ← a.ediv_add_emod' n, add_smul, add_div,
  zsmul_eq_mul, Int.cast_mul, Int.cast_ofNat, mul_assoc, ← mul_div, mul_comm _ p,
  mul_div_cancel p h0] at ha
state_before: case refine'_2.intro
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : a • p = n • k
h0 : ↑n ≠ 0
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k

tactic: have han : _ = a % n := Int.toNat_of_nonneg (Int.emod_nonneg _ <| by exact_mod_cast h.ne')
state_before: case refine'_2.intro
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k

tactic: have he : (↑(↑((a % n).toNat) / ↑n * p) : AddCircle p) = k
state_before: case refine'_2.intro
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k

tactic: refine' ⟨(a % n).toNat, _, _, he⟩
state_before: case refine'_2.intro
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
⊢ ∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = ↑k

tactic: rintro ⟨m, _, h₁, rfl⟩
state_before: case refine'_1
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
⊢ (∃ m, m < n ∧ Nat.gcd m n = 1 ∧ ↑(↑m / ↑n * p) = u) → addOrderOf u = n

tactic: exact addOrderOf_div_of_gcd_eq_one h h₁
state_before: case refine'_1.intro.intro.intro
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
n : ℕ
h : 0 < n
m : ℕ
left✝ : m < n
h₁ : Nat.gcd m n = 1
⊢ addOrderOf ↑(↑m / ↑n * p) = n

tactic: exact_mod_cast h.ne'
state_before: 𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
⊢ ↑n ≠ 0

tactic: convert congr_arg (QuotientAddGroup.mk : 𝕜 → (AddCircle p)) ha using 1
state_before: case he
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
⊢ ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k

tactic: rw [coe_add, ← Int.cast_ofNat, han, zsmul_eq_mul, mul_div_right_comm, eq_comm, add_left_eq_self,
  ←zsmul_eq_mul, coe_zsmul, coe_period, smul_zero]
state_before: case h.e'_2
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
⊢ ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑(↑(a / ↑n) * p + (a % ↑n) • p / ↑n)

tactic: rw [← Int.ofNat_lt, han]
state_before: case refine'_2.intro.refine'_1
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
⊢ Int.toNat (a % ↑n) < n

tactic: exact Int.emod_lt_of_pos _ (Int.ofNat_lt.2 h)
state_before: case refine'_2.intro.refine'_1
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
⊢ a % ↑n < ↑n

tactic: have := (gcd_mul_addOrderOf_div_eq p (Int.toNat (a % ↑n)) h).trans
  ((congr_arg addOrderOf he).trans hk).symm
state_before: case refine'_2.intro.refine'_2
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
⊢ Nat.gcd (Int.toNat (a % ↑n)) n = 1

tactic: rw [he, Nat.mul_left_eq_self_iff] at this
state_before: case refine'_2.intro.refine'_2
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
this :
  Nat.gcd (Int.toNat (a % ↑n)) n * addOrderOf ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) =
    addOrderOf ↑(↑(Int.toNat (a % ↑n)) / ↑n * p)
⊢ Nat.gcd (Int.toNat (a % ↑n)) n = 1

tactic: exact this
state_before: case refine'_2.intro.refine'_2
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
this : Nat.gcd (Int.toNat (a % ↑n)) n = 1
⊢ Nat.gcd (Int.toNat (a % ↑n)) n = 1

tactic: rwa [hk]
state_before: case refine'_2.intro.refine'_2
𝕜 : Type u_1
B : Type ?u.220024
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p q : 𝕜
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
h : 0 < n
k : 𝕜
hk : addOrderOf ↑k = n
a : ℤ
ha : ↑(a / ↑n) * p + (a % ↑n) • p / ↑n = k
h0 : ↑n ≠ 0
han : ↑(Int.toNat (a % ↑n)) = a % ↑n
he : ↑(↑(Int.toNat (a % ↑n)) / ↑n * p) = ↑k
this : Nat.gcd (Int.toNat (a % ↑n)) n * addOrderOf ↑k = addOrderOf ↑k
⊢ 0 < addOrderOf ↑k