more default simp rules for sgn
authorhaftmann
Mon Feb 16 19:11:55 2009 +0100 (2009-02-16)
changeset 2994083b373f61d41
parent 29939 2138ff0ec94a
child 29946 cfec0c2982b2
more default simp rules for sgn
src/HOL/Rational.thy
src/HOL/Ring_and_Field.thy
     1.1 --- a/src/HOL/Rational.thy	Mon Feb 16 19:11:35 2009 +0100
     1.2 +++ b/src/HOL/Rational.thy	Mon Feb 16 19:11:55 2009 +0100
     1.3 @@ -886,14 +886,13 @@
     1.4    finally show ?thesis using assms by simp
     1.5  qed
     1.6  
     1.7 -lemma rat_less_eq_code [code]:
     1.8 -  "Fract a b \<le> Fract c d \<longleftrightarrow> (if b = 0
     1.9 -       then sgn c * sgn d \<ge> 0
    1.10 -     else if d = 0
    1.11 -       then sgn a * sgn b \<le> 0
    1.12 -     else a * \<bar>d\<bar> * sgn b \<le> c * \<bar>b\<bar> * sgn d)"
    1.13 -by (auto simp add: sgn_times mult_le_0_iff zero_le_mult_iff le_rat' eq_rat simp del: le_rat)
    1.14 -  (auto simp add: sgn_times sgn_0_0 le_less sgn_1_pos [symmetric] sgn_1_neg [symmetric])
    1.15 +lemma (in ordered_idom) sgn_greater [simp]:
    1.16 +  "0 < sgn a \<longleftrightarrow> 0 < a"
    1.17 +  unfolding sgn_if by auto
    1.18 +
    1.19 +lemma (in ordered_idom) sgn_less [simp]:
    1.20 +  "sgn a < 0 \<longleftrightarrow> a < 0"
    1.21 +  unfolding sgn_if by auto
    1.22  
    1.23  lemma rat_le_eq_code [code]:
    1.24    "Fract a b < Fract c d \<longleftrightarrow> (if b = 0
    1.25 @@ -901,9 +900,17 @@
    1.26       else if d = 0
    1.27         then sgn a * sgn b < 0
    1.28       else a * \<bar>d\<bar> * sgn b < c * \<bar>b\<bar> * sgn d)"
    1.29 -by (auto simp add: sgn_times mult_less_0_iff zero_less_mult_iff less_rat' eq_rat simp del: less_rat)
    1.30 -   (auto simp add: sgn_times sgn_0_0 sgn_1_pos [symmetric] sgn_1_neg [symmetric],
    1.31 -     auto simp add: sgn_1_pos)
    1.32 +  by (auto simp add: sgn_times mult_less_0_iff zero_less_mult_iff less_rat' eq_rat simp del: less_rat)
    1.33 +
    1.34 +lemma rat_less_eq_code [code]:
    1.35 +  "Fract a b \<le> Fract c d \<longleftrightarrow> (if b = 0
    1.36 +       then sgn c * sgn d \<ge> 0
    1.37 +     else if d = 0
    1.38 +       then sgn a * sgn b \<le> 0
    1.39 +     else a * \<bar>d\<bar> * sgn b \<le> c * \<bar>b\<bar> * sgn d)"
    1.40 +  by (auto simp add: sgn_times mult_le_0_iff zero_le_mult_iff le_rat' eq_rat simp del: le_rat)
    1.41 +    (auto simp add: le_less not_less sgn_0_0)
    1.42 +
    1.43  
    1.44  lemma rat_plus_code [code]:
    1.45    "Fract a b + Fract c d = (if b = 0
     2.1 --- a/src/HOL/Ring_and_Field.thy	Mon Feb 16 19:11:35 2009 +0100
     2.2 +++ b/src/HOL/Ring_and_Field.thy	Mon Feb 16 19:11:55 2009 +0100
     2.3 @@ -1,5 +1,4 @@
     2.4  (*  Title:   HOL/Ring_and_Field.thy
     2.5 -    ID:      $Id$
     2.6      Author:  Gertrud Bauer, Steven Obua, Tobias Nipkow, Lawrence C Paulson, and Markus Wenzel,
     2.7               with contributions by Jeremy Avigad
     2.8  *)
     2.9 @@ -1078,6 +1077,14 @@
    2.10    "sgn a = - 1 \<longleftrightarrow> a < 0"
    2.11  unfolding sgn_if by (auto simp add: equal_neg_zero)
    2.12  
    2.13 +lemma sgn_pos [simp]:
    2.14 +  "0 < a \<Longrightarrow> sgn a = 1"
    2.15 +unfolding sgn_1_pos .
    2.16 +
    2.17 +lemma sgn_neg [simp]:
    2.18 +  "a < 0 \<Longrightarrow> sgn a = - 1"
    2.19 +unfolding sgn_1_neg .
    2.20 +
    2.21  lemma sgn_times:
    2.22    "sgn (a * b) = sgn a * sgn b"
    2.23  by (auto simp add: sgn_if zero_less_mult_iff)
    2.24 @@ -1085,6 +1092,14 @@
    2.25  lemma abs_sgn: "abs k = k * sgn k"
    2.26  unfolding sgn_if abs_if by auto
    2.27  
    2.28 +lemma sgn_greater [simp]:
    2.29 +  "0 < sgn a \<longleftrightarrow> 0 < a"
    2.30 +  unfolding sgn_if by auto
    2.31 +
    2.32 +lemma sgn_less [simp]:
    2.33 +  "sgn a < 0 \<longleftrightarrow> a < 0"
    2.34 +  unfolding sgn_if by auto
    2.35 +
    2.36  (* The int instances are proved, these generic ones are tedious to prove here.
    2.37  And not very useful, as int seems to be the only instance.
    2.38  If needed, they should be proved later, when metis is available.