Theorem: sum_and_error₁_lo (Fl.lean)

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b
Tactic:
have hac : a ≤ round (a + b) := calc
  a = trunc n a       := hfa.symm
  _ ≤ trunc n (a + b) := trunc_le_trunc npos (Nat.le_add_right _ _)
  _ ≤ round (a + b)   := trunc_le_round _ _ hfaithful₁
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b
Tactic:
have hca : round (a + b) ≤ 2 * a := round_add_le npos hfaithful₀ hfaithful₁ hfa hba
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b
Tactic:
have hfc : trunc n (round (a + b)) = round (a + b) := trunc_round npos hfaithful₁ _
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b
Tactic:
have hfe : round (round (a + b) - a) = round (a + b) - a := by
  apply round_eq_of_trunc_eq npos hfaithful₀
  exact sterbenz hfc hfa hac hca
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b
Tactic:
have ⟨hfr₁, _⟩ := a₁ npos hfaithful₀ hfaithful₁ hcorrect₁ hfa hfb
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + round (b - round (round (a + b) - a)) = a + b
Tactic:
rewrite [hfe]
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + round (b - (round (a + b) - a)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + round (b - (round (a + b) - a)) = a + b
Tactic:
rewrite [← add_tsub_assoc' lo hac]
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + round (b + a - round (a + b)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + round (b + a - round (a + b)) = a + b
Tactic:
rewrite [Nat.add_comm b a]
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + round (a + b - round (a + b)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + round (a + b - round (a + b)) = a + b
Tactic:
rewrite [round_eq_of_trunc_eq npos hfaithful₀ hfr₁]
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + (a + b - round (a + b)) = a + b

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
hfe : round (round (a + b) - a) = round (a + b) - a
hfr₁ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
right✝ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) + (a + b - round (a + b)) = a + b
Tactic:
exact add_tsub_cancel_of_le lo
State after:
no goals

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
⊢ round (round (a + b) - a) = round (a + b) - a
Tactic:
apply round_eq_of_trunc_eq npos hfaithful₀
State after:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
⊢ trunc n (round (a + b) - a) = round (a + b) - a

State before:
round : ℕ → ℕ
n a b : ℕ
npos : 0 < n
hfaithful₀ : faithful₀ n round
hfaithful₁ : faithful₁ n round
hcorrect₁ : correct₁ n round
hfa : trunc n a = a
hfb : trunc n b = b
hba : b ≤ a
lo : round (a + b) ≤ a + b
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
hfc : trunc n (round (a + b)) = round (a + b)
⊢ trunc n (round (a + b) - a) = round (a + b) - a
Tactic:
exact sterbenz hfc hfa hac hca
State after:
no goals