equal
deleted
inserted
replaced
664 lemma [code]: |
664 lemma [code]: |
665 "of_rat (Rational (k, l)) = (if l \<noteq> 0 then of_int k / of_int l else 0)" |
665 "of_rat (Rational (k, l)) = (if l \<noteq> 0 then of_int k / of_int l else 0)" |
666 by (cases "l = 0") |
666 by (cases "l = 0") |
667 (auto simp add: Rational_simp of_rat_rat [simplified Fract_of_int_quotient [of k l], symmetric]) |
667 (auto simp add: Rational_simp of_rat_rat [simplified Fract_of_int_quotient [of k l], symmetric]) |
668 |
668 |
669 instance rat :: eq .. |
669 instantiation rat :: eq |
670 |
670 begin |
671 lemma rat_eq_code [code]: "Rational x = Rational y \<longleftrightarrow> normNum x = normNum y" |
671 |
672 unfolding Rational_def INum_normNum_iff .. |
672 definition [code func del]: "eq (r\<Colon>rat) s \<longleftrightarrow> r = s" |
|
673 |
|
674 instance by default (simp add: eq_rat_def) |
|
675 |
|
676 lemma rat_eq_code [code]: "eq (Rational x) (Rational y) \<longleftrightarrow> eq (normNum x) (normNum y)" |
|
677 unfolding Rational_def INum_normNum_iff eq .. |
|
678 |
|
679 end |
673 |
680 |
674 lemma rat_less_eq_code [code]: "Rational x \<le> Rational y \<longleftrightarrow> normNum x \<le>\<^sub>N normNum y" |
681 lemma rat_less_eq_code [code]: "Rational x \<le> Rational y \<longleftrightarrow> normNum x \<le>\<^sub>N normNum y" |
675 proof - |
682 proof - |
676 have "normNum x \<le>\<^sub>N normNum y \<longleftrightarrow> Rational (normNum x) \<le> Rational (normNum y)" |
683 have "normNum x \<le>\<^sub>N normNum y \<longleftrightarrow> Rational (normNum x) \<le> Rational (normNum y)" |
677 by (simp add: Rational_def del: normNum) |
684 by (simp add: Rational_def del: normNum) |