576 lift_definition is_float_pos :: "float \<Rightarrow> bool" is "op < 0 :: real \<Rightarrow> bool" . |
576 lift_definition is_float_pos :: "float \<Rightarrow> bool" is "op < 0 :: real \<Rightarrow> bool" . |
577 |
577 |
578 qualified lemma compute_is_float_pos[code]: "is_float_pos (Float m e) \<longleftrightarrow> 0 < m" |
578 qualified lemma compute_is_float_pos[code]: "is_float_pos (Float m e) \<longleftrightarrow> 0 < m" |
579 by transfer (auto simp add: zero_less_mult_iff not_le[symmetric, of _ 0]) |
579 by transfer (auto simp add: zero_less_mult_iff not_le[symmetric, of _ 0]) |
580 |
580 |
581 qualified lemma compute_float_less[code]: "a < b \<longleftrightarrow> is_float_pos (b - a)" |
|
582 by transfer (simp add: field_simps) |
|
583 |
|
584 lift_definition is_float_nonneg :: "float \<Rightarrow> bool" is "op \<le> 0 :: real \<Rightarrow> bool" . |
581 lift_definition is_float_nonneg :: "float \<Rightarrow> bool" is "op \<le> 0 :: real \<Rightarrow> bool" . |
585 |
582 |
586 qualified lemma compute_is_float_nonneg[code]: "is_float_nonneg (Float m e) \<longleftrightarrow> 0 \<le> m" |
583 qualified lemma compute_is_float_nonneg[code]: "is_float_nonneg (Float m e) \<longleftrightarrow> 0 \<le> m" |
587 by transfer (auto simp add: zero_le_mult_iff not_less[symmetric, of _ 0]) |
584 by transfer (auto simp add: zero_le_mult_iff not_less[symmetric, of _ 0]) |
588 |
|
589 qualified lemma compute_float_le[code]: "a \<le> b \<longleftrightarrow> is_float_nonneg (b - a)" |
|
590 by transfer (simp add: field_simps) |
|
591 |
585 |
592 lift_definition is_float_zero :: "float \<Rightarrow> bool" is "op = 0 :: real \<Rightarrow> bool" . |
586 lift_definition is_float_zero :: "float \<Rightarrow> bool" is "op = 0 :: real \<Rightarrow> bool" . |
593 |
587 |
594 qualified lemma compute_is_float_zero[code]: "is_float_zero (Float m e) \<longleftrightarrow> 0 = m" |
588 qualified lemma compute_is_float_zero[code]: "is_float_zero (Float m e) \<longleftrightarrow> 0 = m" |
595 by transfer (auto simp add: is_float_zero_def) |
589 by transfer (auto simp add: is_float_zero_def) |
1903 by transfer (simp add: plus_down_def plus_up_def ac_simps) |
1897 by transfer (simp add: plus_down_def plus_up_def ac_simps) |
1904 |
1898 |
1905 lemma mantissa_zero[simp]: "mantissa 0 = 0" |
1899 lemma mantissa_zero[simp]: "mantissa 0 = 0" |
1906 by (metis mantissa_0 zero_float.abs_eq) |
1900 by (metis mantissa_0 zero_float.abs_eq) |
1907 |
1901 |
|
1902 qualified lemma compute_float_less[code]: "a < b \<longleftrightarrow> is_float_pos (float_plus_down 0 b (- a))" |
|
1903 using truncate_down[of 0 "b - a"] truncate_down_pos[of "b - a" 0] |
|
1904 by transfer (auto simp: plus_down_def) |
|
1905 |
|
1906 qualified lemma compute_float_le[code]: "a \<le> b \<longleftrightarrow> is_float_nonneg (float_plus_down 0 b (- a))" |
|
1907 using truncate_down[of 0 "b - a"] truncate_down_nonneg[of "b - a" 0] |
|
1908 by transfer (auto simp: plus_down_def) |
|
1909 |
1908 end |
1910 end |
1909 |
1911 |
1910 |
1912 |
1911 subsection \<open>Lemmas needed by Approximate\<close> |
1913 subsection \<open>Lemmas needed by Approximate\<close> |
1912 |
1914 |