src/HOL/Groups.thy
changeset 48556 62a3fbf9d35b
parent 45548 3e2722d66169
child 48891 c0eafbd55de3
equal deleted inserted replaced
48555:be4bf5f6b2ef 48556:62a3fbf9d35b
     4 
     4 
     5 header {* Groups, also combined with orderings *}
     5 header {* Groups, also combined with orderings *}
     6 
     6 
     7 theory Groups
     7 theory Groups
     8 imports Orderings
     8 imports Orderings
     9 uses ("Tools/abel_cancel.ML")
     9 uses ("Tools/group_cancel.ML")
    10 begin
    10 begin
    11 
    11 
    12 subsection {* Fact collections *}
    12 subsection {* Fact collections *}
    13 
    13 
    14 ML {*
    14 ML {*
   469 
   469 
   470 (* FIXME: duplicates right_minus_eq from class group_add *)
   470 (* FIXME: duplicates right_minus_eq from class group_add *)
   471 (* but only this one is declared as a simp rule. *)
   471 (* but only this one is declared as a simp rule. *)
   472 lemma diff_eq_0_iff_eq [simp, no_atp]: "a - b = 0 \<longleftrightarrow> a = b"
   472 lemma diff_eq_0_iff_eq [simp, no_atp]: "a - b = 0 \<longleftrightarrow> a = b"
   473   by (rule right_minus_eq)
   473   by (rule right_minus_eq)
       
   474 
       
   475 lemma add_diff_cancel_left: "(c + a) - (c + b) = a - b"
       
   476   by (simp add: diff_minus add_ac)
   474 
   477 
   475 end
   478 end
   476 
   479 
   477 
   480 
   478 subsection {* (Partially) Ordered Groups *} 
   481 subsection {* (Partially) Ordered Groups *} 
   825   "a - b = c - d \<Longrightarrow> a \<le> b \<longleftrightarrow> c \<le> d"
   828   "a - b = c - d \<Longrightarrow> a \<le> b \<longleftrightarrow> c \<le> d"
   826   by (auto simp only: le_iff_diff_le_0 [of a b] le_iff_diff_le_0 [of c d])
   829   by (auto simp only: le_iff_diff_le_0 [of a b] le_iff_diff_le_0 [of c d])
   827 
   830 
   828 end
   831 end
   829 
   832 
   830 use "Tools/abel_cancel.ML"
   833 use "Tools/group_cancel.ML"
   831 
   834 
   832 simproc_setup abel_cancel_sum
   835 simproc_setup group_cancel_add ("a + b::'a::ab_group_add") =
   833   ("a + b::'a::ab_group_add" | "a - b::'a::ab_group_add") =
   836   {* fn phi => fn ss => try Group_Cancel.cancel_add_conv *}
   834   {* fn phi => Abel_Cancel.sum_proc *}
   837 
   835 
   838 simproc_setup group_cancel_diff ("a - b::'a::ab_group_add") =
   836 simproc_setup abel_cancel_relation
   839   {* fn phi => fn ss => try Group_Cancel.cancel_diff_conv *}
   837   ("a < (b::'a::ordered_ab_group_add)" | "a \<le> (b::'a::ordered_ab_group_add)" | "c = (d::'b::ab_group_add)") =
   840 
   838   {* fn phi => Abel_Cancel.rel_proc *}
   841 simproc_setup group_cancel_eq ("a = (b::'a::ab_group_add)") =
       
   842   {* fn phi => fn ss => try Group_Cancel.cancel_eq_conv *}
       
   843 
       
   844 simproc_setup group_cancel_le ("a \<le> (b::'a::ordered_ab_group_add)") =
       
   845   {* fn phi => fn ss => try Group_Cancel.cancel_le_conv *}
       
   846 
       
   847 simproc_setup group_cancel_less ("a < (b::'a::ordered_ab_group_add)") =
       
   848   {* fn phi => fn ss => try Group_Cancel.cancel_less_conv *}
   839 
   849 
   840 class linordered_ab_semigroup_add =
   850 class linordered_ab_semigroup_add =
   841   linorder + ordered_ab_semigroup_add
   851   linorder + ordered_ab_semigroup_add
   842 
   852 
   843 class linordered_cancel_ab_semigroup_add =
   853 class linordered_cancel_ab_semigroup_add =