Theorem: Nat.Ico_filter_modEq_cast
File: Mathlib/Data/Int/CardIntervalMod.lean

tactic: ext x
state_before: a b r : ℕ
hr : 0 < r
v : ℕ
⊢ map castEmbedding (filter (fun x => x ≡ v [MOD r]) (Ico a b)) = filter (fun x => x ≡ ↑v [ZMOD ↑r]) (Ico ↑a ↑b)
state_after: case a
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ x ∈ map castEmbedding (filter (fun x => x ≡ v [MOD r]) (Ico a b)) ↔ x ∈ filter (fun x => x ≡ ↑v [ZMOD ↑r]) (Ico ↑a ↑b)

tactic: simp only [mem_map, mem_filter, mem_Ico, castEmbedding_apply]
state_before: case a
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ x ∈ map castEmbedding (filter (fun x => x ≡ v [MOD r]) (Ico a b)) ↔ x ∈ filter (fun x => x ≡ ↑v [ZMOD ↑r]) (Ico ↑a ↑b)
state_after: case a
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ (∃ a_1, ((a ≤ a_1 ∧ a_1 < b) ∧ a_1 ≡ v [MOD r]) ∧ ↑a_1 = x) ↔ (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]

tactic: constructor
state_before: case a
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ (∃ a_1, ((a ≤ a_1 ∧ a_1 < b) ∧ a_1 ≡ v [MOD r]) ∧ ↑a_1 = x) ↔ (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]
state_after: case a.mp
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ (∃ a_1, ((a ≤ a_1 ∧ a_1 < b) ∧ a_1 ≡ v [MOD r]) ∧ ↑a_1 = x) → (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]

case a.mpr
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r] → ∃ a_2, ((a ≤ a_2 ∧ a_2 < b) ∧ a_2 ≡ v [MOD r]) ∧ ↑a_2 = x

tactic: simp_rw [forall_exists_index, ← natCast_modEq_iff]
state_before: case a.mp
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ (∃ a_1, ((a ≤ a_1 ∧ a_1 < b) ∧ a_1 ≡ v [MOD r]) ∧ ↑a_1 = x) → (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]
state_after: case a.mp
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ ∀ (x_1 : ℕ), ((a ≤ x_1 ∧ x_1 < b) ∧ ↑x_1 ≡ ↑v [ZMOD ↑r]) ∧ ↑x_1 = x → (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]

tactic: intro y ⟨h, c⟩
state_before: case a.mp
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ ∀ (x_1 : ℕ), ((a ≤ x_1 ∧ x_1 < b) ∧ ↑x_1 ≡ ↑v [ZMOD ↑r]) ∧ ↑x_1 = x → (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]
state_after: case a.mp
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
y : ℕ
h : (a ≤ y ∧ y < b) ∧ ↑y ≡ ↑v [ZMOD ↑r]
c : ↑y = x
⊢ (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]

tactic: subst c
state_before: case a.mp
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
y : ℕ
h : (a ≤ y ∧ y < b) ∧ ↑y ≡ ↑v [ZMOD ↑r]
c : ↑y = x
⊢ (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]
state_after: case a.mp
a b r : ℕ
hr : 0 < r
v y : ℕ
h : (a ≤ y ∧ y < b) ∧ ↑y ≡ ↑v [ZMOD ↑r]
⊢ (↑a ≤ ↑y ∧ ↑y < ↑b) ∧ ↑y ≡ ↑v [ZMOD ↑r]

tactic: exact_mod_cast h
state_before: case a.mp
a b r : ℕ
hr : 0 < r
v y : ℕ
h : (a ≤ y ∧ y < b) ∧ ↑y ≡ ↑v [ZMOD ↑r]
⊢ (↑a ≤ ↑y ∧ ↑y < ↑b) ∧ ↑y ≡ ↑v [ZMOD ↑r]
state_after: no goals

tactic: intro h
state_before: case a.mpr
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
⊢ (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r] → ∃ a_2, ((a ≤ a_2 ∧ a_2 < b) ∧ a_2 ≡ v [MOD r]) ∧ ↑a_2 = x
state_after: case a.mpr
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
h : (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]
⊢ ∃ a_1, ((a ≤ a_1 ∧ a_1 < b) ∧ a_1 ≡ v [MOD r]) ∧ ↑a_1 = x

tactic: lift x to ℕ using (by linarith)
state_before: case a.mpr
a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
h : (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]
⊢ ∃ a_1, ((a ≤ a_1 ∧ a_1 < b) ∧ a_1 ≡ v [MOD r]) ∧ ↑a_1 = x
state_after: case a.mpr.intro
a b r : ℕ
hr : 0 < r
v x : ℕ
h : (↑a ≤ ↑x ∧ ↑x < ↑b) ∧ ↑x ≡ ↑v [ZMOD ↑r]
⊢ ∃ a_1, ((a ≤ a_1 ∧ a_1 < b) ∧ a_1 ≡ v [MOD r]) ∧ ↑a_1 = ↑x

tactic: exact ⟨x, by simp_all [natCast_modEq_iff]⟩
state_before: case a.mpr.intro
a b r : ℕ
hr : 0 < r
v x : ℕ
h : (↑a ≤ ↑x ∧ ↑x < ↑b) ∧ ↑x ≡ ↑v [ZMOD ↑r]
⊢ ∃ a_1, ((a ≤ a_1 ∧ a_1 < b) ∧ a_1 ≡ v [MOD r]) ∧ ↑a_1 = ↑x
state_after: no goals

tactic: linarith
state_before: a b r : ℕ
hr : 0 < r
v : ℕ
x : ℤ
h : (↑a ≤ x ∧ x < ↑b) ∧ x ≡ ↑v [ZMOD ↑r]
⊢ 0 ≤ x
state_after: no goals

tactic: simp_all [natCast_modEq_iff]
state_before: a b r : ℕ
hr : 0 < r
v x : ℕ
h : (↑a ≤ ↑x ∧ ↑x < ↑b) ∧ ↑x ≡ ↑v [ZMOD ↑r]
⊢ ((a ≤ x ∧ x < b) ∧ x ≡ v [MOD r]) ∧ ↑x = ↑x
state_after: no goals