604 zero_neq_numeral |
604 zero_neq_numeral |
605 |
605 |
606 end |
606 end |
607 |
607 |
608 |
608 |
609 subsubsection \<open>Comparisons: class \<open>linordered_semidom\<close>\<close> |
609 subsubsection \<open>Comparisons: class \<open>linordered_nonzero_semiring\<close>\<close> |
610 |
610 |
611 text \<open>Could be perhaps more general than here.\<close> |
611 context linordered_nonzero_semiring |
612 |
|
613 context linordered_semidom |
|
614 begin |
612 begin |
615 |
613 |
616 lemma numeral_le_iff: "numeral m \<le> numeral n \<longleftrightarrow> m \<le> n" |
614 lemma numeral_le_iff: "numeral m \<le> numeral n \<longleftrightarrow> m \<le> n" |
617 proof - |
615 proof - |
618 have "of_nat (numeral m) \<le> of_nat (numeral n) \<longleftrightarrow> m \<le> n" |
616 have "of_nat (numeral m) \<le> of_nat (numeral n) \<longleftrightarrow> m \<le> n" |
619 by (simp only: less_eq_num_def nat_of_num_numeral of_nat_le_iff) |
617 by (simp only: less_eq_num_def nat_of_num_numeral of_nat_le_iff) |
620 then show ?thesis by simp |
618 then show ?thesis by simp |
621 qed |
619 qed |
622 |
620 |
623 lemma one_le_numeral: "1 \<le> numeral n" |
621 lemma one_le_numeral: "1 \<le> numeral n" |
624 using numeral_le_iff [of One n] by (simp add: numeral_One) |
622 using numeral_le_iff [of num.One n] by (simp add: numeral_One) |
625 |
623 |
626 lemma numeral_le_one_iff: "numeral n \<le> 1 \<longleftrightarrow> n \<le> One" |
624 lemma numeral_le_one_iff: "numeral n \<le> 1 \<longleftrightarrow> n \<le> num.One" |
627 using numeral_le_iff [of n One] by (simp add: numeral_One) |
625 using numeral_le_iff [of n num.One] by (simp add: numeral_One) |
628 |
626 |
629 lemma numeral_less_iff: "numeral m < numeral n \<longleftrightarrow> m < n" |
627 lemma numeral_less_iff: "numeral m < numeral n \<longleftrightarrow> m < n" |
630 proof - |
628 proof - |
631 have "of_nat (numeral m) < of_nat (numeral n) \<longleftrightarrow> m < n" |
629 have "of_nat (numeral m) < of_nat (numeral n) \<longleftrightarrow> m < n" |
632 unfolding less_num_def nat_of_num_numeral of_nat_less_iff .. |
630 unfolding less_num_def nat_of_num_numeral of_nat_less_iff .. |
633 then show ?thesis by simp |
631 then show ?thesis by simp |
634 qed |
632 qed |
635 |
633 |
636 lemma not_numeral_less_one: "\<not> numeral n < 1" |
634 lemma not_numeral_less_one: "\<not> numeral n < 1" |
637 using numeral_less_iff [of n One] by (simp add: numeral_One) |
635 using numeral_less_iff [of n num.One] by (simp add: numeral_One) |
638 |
636 |
639 lemma one_less_numeral_iff: "1 < numeral n \<longleftrightarrow> One < n" |
637 lemma one_less_numeral_iff: "1 < numeral n \<longleftrightarrow> num.One < n" |
640 using numeral_less_iff [of One n] by (simp add: numeral_One) |
638 using numeral_less_iff [of num.One n] by (simp add: numeral_One) |
641 |
639 |
642 lemma zero_le_numeral: "0 \<le> numeral n" |
640 lemma zero_le_numeral: "0 \<le> numeral n" |
643 by (induct n) (simp_all add: numeral.simps) |
641 using dual_order.trans one_le_numeral zero_le_one by blast |
644 |
642 |
645 lemma zero_less_numeral: "0 < numeral n" |
643 lemma zero_less_numeral: "0 < numeral n" |
646 by (induct n) (simp_all add: numeral.simps add_pos_pos) |
644 using less_linear not_numeral_less_one order.strict_trans zero_less_one by blast |
647 |
645 |
648 lemma not_numeral_le_zero: "\<not> numeral n \<le> 0" |
646 lemma not_numeral_le_zero: "\<not> numeral n \<le> 0" |
649 by (simp add: not_le zero_less_numeral) |
647 by (simp add: not_le zero_less_numeral) |
650 |
648 |
651 lemma not_numeral_less_zero: "\<not> numeral n < 0" |
649 lemma not_numeral_less_zero: "\<not> numeral n < 0" |