Theorem: sum_and_error₁_hi (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
hi : a + b ≤ round (a + b)
⊢ round (a + b) - round (round (round (a + b) - a) - b) = a + b
Tactic:
have hac : a ≤ round (a + b) := Nat.le_trans (Nat.le_add_right _ _) hi
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
hi : a + b ≤ round (a + b)
hac : a ≤ round (a + b)
⊢ round (a + b) - round (round (round (a + b) - 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
hi : a + b ≤ round (a + b)
hac : a ≤ round (a + b)
⊢ round (a + b) - round (round (round (a + b) - a) - b) = 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
hi : a + b ≤ round (a + b)
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
⊢ round (a + b) - round (round (round (a + b) - 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
hi : a + b ≤ round (a + b)
hac : a ≤ round (a + b)
hca : round (a + b) ≤ 2 * a
⊢ round (a + b) - round (round (round (a + b) - a) - b) = 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
hi : a + b ≤ round (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 (round (round (a + b) - 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
hi : a + b ≤ round (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 (round (round (a + b) - a) - b) = 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
hi : a + b ≤ round (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 (round (round (a + b) - 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
hi : a + b ≤ round (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 (round (round (a + b) - a) - b) = 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
hi : a + b ≤ round (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
left✝ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
hfr₂ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) - round (round (round (a + b) - 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
hi : a + b ≤ round (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
left✝ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
hfr₂ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) - round (round (round (a + b) - a) - b) = 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
hi : a + b ≤ round (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
left✝ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
hfr₂ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) - round (round (a + b) - 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
hi : a + b ≤ round (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
left✝ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
hfr₂ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) - round (round (a + b) - a - b) = a + b
Tactic:
rewrite [tsub_tsub]
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
hi : a + b ≤ round (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
left✝ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
hfr₂ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) - round (round (a + b) - (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
hi : a + b ≤ round (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
left✝ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
hfr₂ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) - round (round (a + b) - (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
hi : a + b ≤ round (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
left✝ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
hfr₂ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) - (round (a + b) - (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
hi : a + b ≤ round (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
left✝ : trunc n (a + b - round (a + b)) = a + b - round (a + b)
hfr₂ : trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
⊢ round (a + b) - (round (a + b) - (a + b)) = a + b
Tactic:
exact tsub_tsub_cancel_of_le hi
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
hi : a + b ≤ round (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
hi : a + b ≤ round (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
hi : a + b ≤ round (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