equal
deleted
inserted
replaced
621 subsection \<open>The Set of Integers\<close> |
621 subsection \<open>The Set of Integers\<close> |
622 |
622 |
623 context ring_1 |
623 context ring_1 |
624 begin |
624 begin |
625 |
625 |
626 definition Ints :: "'a set" where |
626 definition Ints :: "'a set" ("\<int>") |
627 "Ints = range of_int" |
627 where "\<int> = range of_int" |
628 |
|
629 notation (xsymbols) |
|
630 Ints ("\<int>") |
|
631 |
628 |
632 lemma Ints_of_int [simp]: "of_int z \<in> \<int>" |
629 lemma Ints_of_int [simp]: "of_int z \<in> \<int>" |
633 by (simp add: Ints_def) |
630 by (simp add: Ints_def) |
634 |
631 |
635 lemma Ints_of_nat [simp]: "of_nat n \<in> \<int>" |
632 lemma Ints_of_nat [simp]: "of_nat n \<in> \<int>" |
685 end |
682 end |
686 |
683 |
687 text \<open>The premise involving @{term Ints} prevents @{term "a = 1/2"}.\<close> |
684 text \<open>The premise involving @{term Ints} prevents @{term "a = 1/2"}.\<close> |
688 |
685 |
689 lemma Ints_double_eq_0_iff: |
686 lemma Ints_double_eq_0_iff: |
690 assumes in_Ints: "a \<in> Ints" |
687 assumes in_Ints: "a \<in> \<int>" |
691 shows "(a + a = 0) = (a = (0::'a::ring_char_0))" |
688 shows "(a + a = 0) = (a = (0::'a::ring_char_0))" |
692 proof - |
689 proof - |
693 from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] . |
690 from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] . |
694 then obtain z where a: "a = of_int z" .. |
691 then obtain z where a: "a = of_int z" .. |
695 show ?thesis |
692 show ?thesis |
704 thus "a = 0" by (simp add: a) |
701 thus "a = 0" by (simp add: a) |
705 qed |
702 qed |
706 qed |
703 qed |
707 |
704 |
708 lemma Ints_odd_nonzero: |
705 lemma Ints_odd_nonzero: |
709 assumes in_Ints: "a \<in> Ints" |
706 assumes in_Ints: "a \<in> \<int>" |
710 shows "1 + a + a \<noteq> (0::'a::ring_char_0)" |
707 shows "1 + a + a \<noteq> (0::'a::ring_char_0)" |
711 proof - |
708 proof - |
712 from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] . |
709 from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] . |
713 then obtain z where a: "a = of_int z" .. |
710 then obtain z where a: "a = of_int z" .. |
714 show ?thesis |
711 show ?thesis |
718 hence "1 + z + z = 0" by (simp only: of_int_eq_iff) |
715 hence "1 + z + z = 0" by (simp only: of_int_eq_iff) |
719 with odd_nonzero show False by blast |
716 with odd_nonzero show False by blast |
720 qed |
717 qed |
721 qed |
718 qed |
722 |
719 |
723 lemma Nats_numeral [simp]: "numeral w \<in> Nats" |
720 lemma Nats_numeral [simp]: "numeral w \<in> \<nat>" |
724 using of_nat_in_Nats [of "numeral w"] by simp |
721 using of_nat_in_Nats [of "numeral w"] by simp |
725 |
722 |
726 lemma Ints_odd_less_0: |
723 lemma Ints_odd_less_0: |
727 assumes in_Ints: "a \<in> Ints" |
724 assumes in_Ints: "a \<in> \<int>" |
728 shows "(1 + a + a < 0) = (a < (0::'a::linordered_idom))" |
725 shows "(1 + a + a < 0) = (a < (0::'a::linordered_idom))" |
729 proof - |
726 proof - |
730 from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] . |
727 from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] . |
731 then obtain z where a: "a = of_int z" .. |
728 then obtain z where a: "a = of_int z" .. |
732 hence "((1::'a) + a + a < 0) = (of_int (1 + z + z) < (of_int 0 :: 'a))" |
729 hence "((1::'a) + a + a < 0) = (of_int (1 + z + z) < (of_int 0 :: 'a))" |