src/HOL/Fields.thy
changeset 60352 d46de31a50c4
parent 59867 58043346ca64
child 60353 838025c6e278
equal deleted inserted replaced
60351:5cdf3903a302 60352:d46de31a50c4
    17 
    17 
    18 text {*
    18 text {*
    19   A division ring is like a field, but without the commutativity requirement.
    19   A division ring is like a field, but without the commutativity requirement.
    20 *}
    20 *}
    21 
    21 
    22 class inverse =
    22 class inverse = divide +
    23   fixes inverse :: "'a \<Rightarrow> 'a"
    23   fixes inverse :: "'a \<Rightarrow> 'a"
    24     and divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "'/" 70)
       
    25 
       
    26 setup {* Sign.add_const_constraint (@{const_name "divide"}, SOME @{typ "'a \<Rightarrow> 'a \<Rightarrow> 'a"}) *}
       
    27 
       
    28 
       
    29 context semiring
       
    30 begin
    24 begin
    31 
    25   
    32 lemma [field_simps]:
    26 abbreviation inverse_divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "'/" 70)
    33   shows distrib_left_NO_MATCH: "NO_MATCH (x / y) a \<Longrightarrow> a * (b + c) = a * b + a * c"
    27 where
    34     and distrib_right_NO_MATCH: "NO_MATCH (x / y) c \<Longrightarrow> (a + b) * c = a * c + b * c"
    28   "inverse_divide \<equiv> divide"
    35   by (rule distrib_left distrib_right)+
       
    36 
    29 
    37 end
    30 end
    38 
       
    39 context ring
       
    40 begin
       
    41 
       
    42 lemma [field_simps]:
       
    43   shows left_diff_distrib_NO_MATCH: "NO_MATCH (x / y) c \<Longrightarrow> (a - b) * c = a * c - b * c"
       
    44     and right_diff_distrib_NO_MATCH: "NO_MATCH (x / y) a \<Longrightarrow> a * (b - c) = a * b - a * c"
       
    45   by (rule left_diff_distrib right_diff_distrib)+
       
    46 
       
    47 end
       
    48 
       
    49 setup {* Sign.add_const_constraint (@{const_name "divide"}, SOME @{typ "'a::inverse \<Rightarrow> 'a \<Rightarrow> 'a"}) *}
       
    50 
    31 
    51 text{* Lemmas @{text divide_simps} move division to the outside and eliminates them on (in)equalities. *}
    32 text{* Lemmas @{text divide_simps} move division to the outside and eliminates them on (in)equalities. *}
    52 
    33 
    53 named_theorems divide_simps "rewrite rules to eliminate divisions"
    34 named_theorems divide_simps "rewrite rules to eliminate divisions"
    54 
    35 
   383   "\<lbrakk>b \<noteq> 0; c \<noteq> 0\<rbrakk> \<Longrightarrow> (a * c) / (c * b) = a / b"
   364   "\<lbrakk>b \<noteq> 0; c \<noteq> 0\<rbrakk> \<Longrightarrow> (a * c) / (c * b) = a / b"
   384 using nonzero_mult_divide_mult_cancel_right [of b c a] by (simp add: ac_simps)
   365 using nonzero_mult_divide_mult_cancel_right [of b c a] by (simp add: ac_simps)
   385 
   366 
   386 lemma diff_frac_eq:
   367 lemma diff_frac_eq:
   387   "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> x / y - w / z = (x * z - w * y) / (y * z)"
   368   "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> x / y - w / z = (x * z - w * y) / (y * z)"
       
   369   thm field_simps
   388   by (simp add: field_simps)
   370   by (simp add: field_simps)
   389 
   371 
   390 lemma frac_eq_eq:
   372 lemma frac_eq_eq:
   391   "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> (x / y = w / z) = (x * z = w * y)"
   373   "y \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> (x / y = w / z) = (x * z = w * y)"
   392   by (simp add: field_simps)
   374   by (simp add: field_simps)