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
le_round : a - b ≤ round (a - b)
⊢ round (a - b) - round (b - round (a - round (a - b))) = a - b
Tactic:
have ⟨_, hfr₂⟩ := b₁ npos hfaithful₀ hfaithful₁ hcorrect₀ hfa hfb 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
le_round : a - b ≤ round (a - b)
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 (b - round (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
le_round : a - b ≤ round (a - b)
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 (b - round (a - round (a - b))) = a - b
Tactic:
have hfe : round (a - round (a - b)) = a - round (a - b) := by
  apply round_eq_of_trunc_eq npos hfaithful₀
  exact s₂ npos hfaithful₀ hfaithful₁ hfa hfb 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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
⊢ round (a - b) - round (b - round (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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
⊢ round (a - b) - round (b - round (a - round (a - b))) = a - b
Tactic:
have hca : round (a - b) ≤ a := round_sub_le npos hfaithful₀ hfaithful₁ b hfa
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ round (a - b) - round (b - round (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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ round (a - b) - round (b - round (a - round (a - b))) = a - b
Tactic:
have h : b - (a - round (a - b)) = round (a - b) - (a - b) := by
  apply tsub_eq_of_eq_add
  rewrite [tsub_add_eq_add_tsub le_round]
  rewrite [add_tsub_cancel_of_le hca]
  exact Eq.symm $ tsub_tsub_cancel_of_le 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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
h : b - (a - round (a - b)) = round (a - b) - (a - b)
⊢ round (a - b) - round (b - round (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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
h : b - (a - round (a - b)) = round (a - b) - (a - b)
⊢ round (a - b) - round (b - round (a - round (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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
h : b - (a - round (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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
h : b - (a - round (a - b)) = round (a - b) - (a - b)
⊢ round (a - b) - round (b - (a - round (a - b))) = a - b
Tactic:
rewrite [h]
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
h : b - (a - round (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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
h : b - (a - round (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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
h : b - (a - round (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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
h : b - (a - round (a - b)) = round (a - b) - (a - b)
⊢ round (a - b) - (round (a - b) - (a - b)) = a - b
Tactic:
exact tsub_tsub_cancel_of_le le_round
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
le_round : a - b ≤ round (a - b)
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 - round (a - b)) = a - round (a - b)
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
le_round : a - b ≤ round (a - b)
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)
⊢ trunc n (a - round (a - b)) = a - round (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
le_round : a - b ≤ round (a - b)
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)
⊢ trunc n (a - round (a - b)) = a - round (a - b)
Tactic:
exact s₂ npos hfaithful₀ hfaithful₁ hfa hfb hba
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ b - (a - round (a - b)) = round (a - b) - (a - b)
Tactic:
apply tsub_eq_of_eq_add
State after:
case h
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ b = round (a - b) - (a - b) + (a - round (a - b))

State before:
case h
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ b = round (a - b) - (a - b) + (a - round (a - b))
Tactic:
rewrite [tsub_add_eq_add_tsub le_round]
State after:
case h
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ b = round (a - b) + (a - round (a - b)) - (a - b)

State before:
case h
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ b = round (a - b) + (a - round (a - b)) - (a - b)
Tactic:
rewrite [add_tsub_cancel_of_le hca]
State after:
case h
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ b = a - (a - b)

State before:
case h
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
le_round : a - b ≤ round (a - b)
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)
hfe : round (a - round (a - b)) = a - round (a - b)
hca : round (a - b) ≤ a
⊢ b = a - (a - b)
Tactic:
exact Eq.symm $ tsub_tsub_cancel_of_le hba
State after:
no goals