internlm/Lean-Github huggingface dataset:
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
⊢ 2 ^ Nat.size a = 2 ^ n * 2 ^ (Nat.size a - n)
Tactic:
rewrite [← pow_add]
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
⊢ 2 ^ Nat.size a = 2 ^ (n + (Nat.size a - n))
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
⊢ 2 ^ Nat.size a = 2 ^ (n + (Nat.size a - n))
Tactic:
rw [add_tsub_cancel_of_le le_size]
Proof state after:
no goals
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ (a + b) / ulp n a = 2 ^ n
Tactic:
apply Nat.eq_of_mul_eq_mul_right (ulp_pos n a)
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ (a + b) / ulp n a * ulp n a = 2 ^ n * ulp n a
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ (a + b) / ulp n a * ulp n a = 2 ^ n * ulp n a
Tactic:
apply div_mul_eq_of_dvd_of_le_of_lt
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ ulp n a ∣ 2 ^ n * ulp n a

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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ 2 ^ n * ulp n a ≤ a + b

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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ a + b < 2 ^ n * ulp n a + ulp n a
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ ulp n a ∣ 2 ^ n * ulp n a

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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ 2 ^ n * ulp n a ≤ a + b

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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ a + b < 2 ^ n * ulp n a + ulp n a
Tactic:
. exact Nat.dvd_mul_left _ _
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ 2 ^ n * ulp n a ≤ a + b

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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ a + b < 2 ^ n * ulp n a + ulp n a
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ 2 ^ n * ulp n a ≤ a + b

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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ a + b < 2 ^ n * ulp n a + ulp n a
Tactic:
. exact pow_size_eq_pow_mul_ulp.ge.trans carry
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ a + b < 2 ^ n * ulp n a + ulp n a
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ a + b < 2 ^ n * ulp n a + ulp n a
Tactic:
. apply Nat.lt_of_lt_of_le add_lt_pow_add_ulp
  rw [pow_size_eq_pow_mul_ulp]
Proof state after:
no goals
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ ulp n a ∣ 2 ^ n * ulp n a
Tactic:
exact Nat.dvd_mul_left _ _
Proof state after:
no goals
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ 2 ^ n * ulp n a ≤ a + b
Tactic:
exact pow_size_eq_pow_mul_ulp.ge.trans carry
Proof state after:
no goals
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ a + b < 2 ^ n * ulp n a + ulp n a
Tactic:
apply Nat.lt_of_lt_of_le add_lt_pow_add_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ 2 ^ Nat.size a + ulp n a ≤ 2 ^ n * ulp n a + ulp n a
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
pow_size_eq_pow_mul_ulp : 2 ^ Nat.size a = 2 ^ n * ulp n a
⊢ 2 ^ Nat.size a + ulp n a ≤ 2 ^ n * ulp n a + ulp n a
Tactic:
rw [pow_size_eq_pow_mul_ulp]
Proof state after:
no goals
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ a + b < trunc n (a + b) + ulp n (a + b) / 2
Tactic:
rewrite [eq_pow]
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ a + b < 2 ^ Nat.size a + ulp n (a + b) / 2
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ a + b < 2 ^ Nat.size a + ulp n (a + b) / 2
Tactic:
apply Nat.lt_of_lt_of_le add_lt_pow_add_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ 2 ^ Nat.size a + ulp n a ≤ 2 ^ Nat.size a + ulp n (a + b) / 2
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ 2 ^ Nat.size a + ulp n a ≤ 2 ^ Nat.size a + ulp n (a + b) / 2
Tactic:
apply Nat.add_le_add_left
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ ulp n a ≤ ulp n (a + b) / 2
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ ulp n a ≤ ulp n (a + b) / 2
Tactic:
rewrite [ulp_eq]
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ ulp n a ≤ 2 * ulp n a / 2
Theorem: round_le_of_no_uflow_of_carry_of_lt_ulp
Proof 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
hba : b ≤ a
no_uflow : 2 ^ n ≤ a + b
carry : 2 ^ Nat.size a ≤ a + b
lt_ulp : b < ulp n (a + b)
le_size : n ≤ Nat.size a
ulp_eq : ulp n (a + b) = 2 * ulp n a
add_lt_pow_add_ulp : a + b < 2 ^ Nat.size a + ulp n a
eq_pow : trunc n (a + b) = 2 ^ Nat.size a
⊢ ulp n a ≤ 2 * ulp n a / 2
Tactic:
rw [Nat.mul_div_cancel_left _ two_pos]
Proof state after:
no goals
Theorem: a₁'
Proof 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
⊢ trunc n (a + b - round (a + b)) = a + b - round (a + b) ∧ trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
Tactic:
cases Nat.lt_or_ge (a + b) (2 ^ n) with
| inl uflow => exact a₁_of_uflow npos hfaithful₀ uflow
| inr no_uflow =>
  cases Nat.lt_or_ge (a + b) (round (a + b)) with
  | inl lt_round =>
    constructor
    . exact a₁_lo_of_lt_round npos hfaithful₁ lt_round
    . cases Nat.lt_or_ge (a + b) (2 ^ Nat.size a) with
      | inl no_carry =>
        exact a₁_hi_of_no_uflow_of_no_carry_of_lt_round
          npos hfaithful₁ hcorrect₁ hfa hfb hba no_uflow no_carry lt_round
      | inr carry =>
        have ulp_le : ulp n (a + b) ≤ b := by
          rewrite [← Nat.not_lt]
          intro lt_ulp
          apply Nat.lt_le_asymm lt_round
          exact round_le_of_no_uflow_of_carry_of_lt_ulp
            npos hfaithful₀ hfaithful₁ hcorrect₁ hfa hba no_uflow carry lt_ulp
        exact a₁_hi_of_ulp_le_of_lt_round npos hfaithful₁ hfa hfb hba ulp_le lt_round
  | inr round_le =>
    constructor
    . cases Nat.lt_or_ge (a + b) (2 ^ Nat.size a) with
      | inl no_carry =>
        exact a₁_lo_of_no_carry_of_round_le
          npos hfaithful₁ hfa hfb hba no_carry round_le
      | inr carry =>
        exact a₁_lo_of_no_uflow_of_carry_of_round_le
          npos hfaithful₁ hfa hfb hba no_uflow carry round_le
    . exact a₁_hi_of_round_le npos hfaithful₁ round_le
Proof state after:
no goals
Theorem: a₁'
Proof state before:
case inl
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
uflow : a + b < 2 ^ n
⊢ trunc n (a + b - round (a + b)) = a + b - round (a + b) ∧ trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
Tactic:
exact a₁_of_uflow npos hfaithful₀ uflow
Proof state after:
no goals
Theorem: a₁'
Proof state before:
case inr
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
no_uflow : a + b ≥ 2 ^ n
⊢ trunc n (a + b - round (a + b)) = a + b - round (a + b) ∧ trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
Tactic:
cases Nat.lt_or_ge (a + b) (round (a + b)) with
| inl lt_round =>
  constructor
  . exact a₁_lo_of_lt_round npos hfaithful₁ lt_round
  . cases Nat.lt_or_ge (a + b) (2 ^ Nat.size a) with
    | inl no_carry =>
      exact a₁_hi_of_no_uflow_of_no_carry_of_lt_round
        npos hfaithful₁ hcorrect₁ hfa hfb hba no_uflow no_carry lt_round
    | inr carry =>
      have ulp_le : ulp n (a + b) ≤ b := by
        rewrite [← Nat.not_lt]
        intro lt_ulp
        apply Nat.lt_le_asymm lt_round
        exact round_le_of_no_uflow_of_carry_of_lt_ulp
          npos hfaithful₀ hfaithful₁ hcorrect₁ hfa hba no_uflow carry lt_ulp
      exact a₁_hi_of_ulp_le_of_lt_round npos hfaithful₁ hfa hfb hba ulp_le lt_round
| inr round_le =>
  constructor
  . cases Nat.lt_or_ge (a + b) (2 ^ Nat.size a) with
    | inl no_carry =>
      exact a₁_lo_of_no_carry_of_round_le
        npos hfaithful₁ hfa hfb hba no_carry round_le
    | inr carry =>
      exact a₁_lo_of_no_uflow_of_carry_of_round_le
        npos hfaithful₁ hfa hfb hba no_uflow carry round_le
  . exact a₁_hi_of_round_le npos hfaithful₁ round_le
Proof state after:
no goals
Theorem: a₁'
Proof state before:
case inr.inl
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
no_uflow : a + b ≥ 2 ^ n
lt_round : a + b < round (a + b)
⊢ trunc n (a + b - round (a + b)) = a + b - round (a + b) ∧ trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
Tactic:
constructor
Proof state after:
case inr.inl.left
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
no_uflow : a + b ≥ 2 ^ n
lt_round : a + b < round (a + b)
⊢ trunc n (a + b - round (a + b)) = a + b - round (a + b)

case inr.inl.right
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
no_uflow : a + b ≥ 2 ^ n
lt_round : a + b < round (a + b)
⊢ trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
Theorem: a₁'
Proof state before:
case inr.inl.left
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
no_uflow : a + b ≥ 2 ^ n
lt_round : a + b < round (a + b)
⊢ trunc n (a + b - round (a + b)) = a + b - round (a + b)

case inr.inl.right
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
no_uflow : a + b ≥ 2 ^ n
lt_round : a + b < round (a + b)
⊢ trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
Tactic:
. exact a₁_lo_of_lt_round npos hfaithful₁ lt_round
Proof state after:
case inr.inl.right
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
no_uflow : a + b ≥ 2 ^ n
lt_round : a + b < round (a + b)
⊢ trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
Theorem: a₁'
Proof state before:
case inr.inl.right
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
no_uflow : a + b ≥ 2 ^ n
lt_round : a + b < round (a + b)
⊢ trunc n (round (a + b) - (a + b)) = round (a + b) - (a + b)
Tactic:
. cases Nat.lt_or_ge (a + b) (2 ^ Nat.size a) with
  | inl no_carry =>
    exact a₁_hi_of_no_uflow_of_no_carry_of_lt_round
      npos hfaithful₁ hcorrect₁ hfa hfb hba no_uflow no_carry lt_round
  | inr carry =>
    have ulp_le : ulp n (a + b) ≤ b := by
      rewrite [← Nat.not_lt]
      intro lt_ulp
      apply Nat.lt_le_asymm lt_round
      exact round_le_of_no_uflow_of_carry_of_lt_ulp
        npos hfaithful₀ hfaithful₁ hcorrect₁ hfa hba no_uflow carry lt_ulp
    exact a₁_hi_of_ulp_le_of_lt_round npos hfaithful₁ hfa hfb hba ulp_le lt_round
Proof state after:
no goals
Theorem: a₁'
Proof state before:
case inr.inl.left
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
no_uflow : a + b ≥ 2 ^ n
lt_round : a + b < round (a + b)
⊢ trunc n (a + b - round (a + b)) = a + b - round (a + b)
Tactic:
exact a₁_lo_of_lt_round npos hfaithful₁ lt_round
Proof state after:
no goals