
diff -r 6a4d5ca6d2e5 -r b3e8d5ec721d src/HOL/Library/SetsAndFunctions.thy
--- a/src/HOL/Library/SetsAndFunctions.thy	Wed May 07 10:59:23 2008 +0200
+++ b/src/HOL/Library/SetsAndFunctions.thy	Wed May 07 10:59:24 2008 +0200
@@ -17,15 +17,9 @@
 
 subsection {* Basic definitions *}
 
-instantiation set :: (plus) plus
-begin
-
 definition
-  set_plus: "A + B == {c. EX a:A. EX b:B. c = a + b}"
-
-instance ..
-
-end
+  set_plus :: "('a::plus) set => 'a set => 'a set"  (infixl "\<oplus>" 65) where
+  "A \<oplus> B == {c. EX a:A. EX b:B. c = a + b}"
 
 instantiation "fun" :: (type, plus) plus
 begin
@@ -37,15 +31,9 @@
 
 end
 
-instantiation set :: (times) times
-begin
-
 definition
-  set_times:"A * B == {c. EX a:A. EX b:B. c = a * b}"
-
-instance ..
-
-end
+  set_times :: "('a::times) set => 'a set => 'a set"  (infixl "\<otimes>" 70) where
+  "A \<otimes> B == {c. EX a:A. EX b:B. c = a * b}"
 
 instantiation "fun" :: (type, times) times
 begin
@@ -57,36 +45,6 @@
 
 end
 
-instantiation "fun" :: (type, minus) minus
-begin
-
-definition
-  func_diff: "f - g == %x. f x - g x"
-
-instance ..
-
-end
-
-instantiation "fun" :: (type, uminus) uminus
-begin
-
-definition
-  func_minus: "- f == (%x. - f x)"
-
-instance ..
-
-end
-
-
-instantiation set :: (zero) zero
-begin
-
-definition
-  set_zero: "0::('a::zero)set == {0}"
-
-instance ..
-
-end
 
 instantiation "fun" :: (type, zero) zero
 begin
@@ -98,16 +56,6 @@
 
 end
 
-instantiation set :: (one) one
-begin
-
-definition
-  set_one: "1::('a::one)set == {1}"
-
-instance ..
-
-end
-
 instantiation "fun" :: (type, one) one
 begin
 
@@ -138,8 +86,8 @@
 
 instance "fun" :: (type,ab_group_add)ab_group_add
   apply default
-   apply (simp add: func_minus func_plus func_zero)
-  apply (simp add: func_minus func_plus func_diff diff_minus)
+   apply (simp add: fun_Compl_def func_plus func_zero)
+  apply (simp add: fun_Compl_def func_plus fun_diff_def diff_minus)
   done
 
 instance "fun" :: (type,semigroup_mult)semigroup_mult
@@ -154,52 +102,50 @@
 
 instance "fun" :: (type,comm_ring_1)comm_ring_1
   apply default
-   apply (auto simp add: func_plus func_times func_minus func_diff ext
+   apply (auto simp add: func_plus func_times fun_Compl_def fun_diff_def ext
      func_one func_zero ring_simps)
   apply (drule fun_cong)
   apply simp
   done
 
-instance set :: (semigroup_add)semigroup_add
+interpretation set_semigroup_add: semigroup_add ["op \<oplus> :: ('a::semigroup_add) set => 'a set => 'a set"]
   apply default
-  apply (unfold set_plus)
+  apply (unfold set_plus_def)
   apply (force simp add: add_assoc)
   done
 
-instance set :: (semigroup_mult)semigroup_mult
+interpretation set_semigroup_mult: semigroup_mult ["op \<otimes> :: ('a::semigroup_mult) set => 'a set => 'a set"]
   apply default
-  apply (unfold set_times)
+  apply (unfold set_times_def)
   apply (force simp add: mult_assoc)
   done
 
-instance set :: (comm_monoid_add)comm_monoid_add
+interpretation set_comm_monoid_add: comm_monoid_add ["{0}" "op \<oplus> :: ('a::comm_monoid_add) set => 'a set => 'a set"]
   apply default
-   apply (unfold set_plus)
+   apply (unfold set_plus_def)
    apply (force simp add: add_ac)
-  apply (unfold set_zero)
   apply force
   done
 
-instance set :: (comm_monoid_mult)comm_monoid_mult
+interpretation set_comm_monoid_mult: comm_monoid_mult ["{1}" "op \<otimes> :: ('a::comm_monoid_mult) set => 'a set => 'a set"]
   apply default
-   apply (unfold set_times)
+   apply (unfold set_times_def)
    apply (force simp add: mult_ac)
-  apply (unfold set_one)
   apply force
   done
 
 
 subsection {* Basic properties *}
 
-lemma set_plus_intro [intro]: "a : C ==> b : D ==> a + b : C + D"
-  by (auto simp add: set_plus)
+lemma set_plus_intro [intro]: "a : C ==> b : D ==> a + b : C \<oplus> D"
+  by (auto simp add: set_plus_def)
 
 lemma set_plus_intro2 [intro]: "b : C ==> a + b : a +o C"
   by (auto simp add: elt_set_plus_def)
 
-lemma set_plus_rearrange: "((a::'a::comm_monoid_add) +o C) +
-    (b +o D) = (a + b) +o (C + D)"
-  apply (auto simp add: elt_set_plus_def set_plus add_ac)
+lemma set_plus_rearrange: "((a::'a::comm_monoid_add) +o C) \<oplus>
+    (b +o D) = (a + b) +o (C \<oplus> D)"
+  apply (auto simp add: elt_set_plus_def set_plus_def add_ac)
    apply (rule_tac x = "ba + bb" in exI)
   apply (auto simp add: add_ac)
   apply (rule_tac x = "aa + a" in exI)
@@ -210,9 +156,9 @@
     (a + b) +o C"
   by (auto simp add: elt_set_plus_def add_assoc)
 
-lemma set_plus_rearrange3: "((a::'a::semigroup_add) +o B) + C =
-    a +o (B + C)"
-  apply (auto simp add: elt_set_plus_def set_plus)
+lemma set_plus_rearrange3: "((a::'a::semigroup_add) +o B) \<oplus> C =
+    a +o (B \<oplus> C)"
+  apply (auto simp add: elt_set_plus_def set_plus_def)
    apply (blast intro: add_ac)
   apply (rule_tac x = "a + aa" in exI)
   apply (rule conjI)
@@ -222,9 +168,9 @@
    apply (auto simp add: add_ac)
   done
 
-theorem set_plus_rearrange4: "C + ((a::'a::comm_monoid_add) +o D) =
-    a +o (C + D)"
-  apply (auto intro!: subsetI simp add: elt_set_plus_def set_plus add_ac)
+theorem set_plus_rearrange4: "C \<oplus> ((a::'a::comm_monoid_add) +o D) =
+    a +o (C \<oplus> D)"
+  apply (auto intro!: subsetI simp add: elt_set_plus_def set_plus_def add_ac)
    apply (rule_tac x = "aa + ba" in exI)
    apply (auto simp add: add_ac)
   done
@@ -236,17 +182,17 @@
   by (auto simp add: elt_set_plus_def)
 
 lemma set_plus_mono2 [intro]: "(C::('a::plus) set) <= D ==> E <= F ==>
-    C + E <= D + F"
-  by (auto simp add: set_plus)
+    C \<oplus> E <= D \<oplus> F"
+  by (auto simp add: set_plus_def)
 
-lemma set_plus_mono3 [intro]: "a : C ==> a +o D <= C + D"
-  by (auto simp add: elt_set_plus_def set_plus)
+lemma set_plus_mono3 [intro]: "a : C ==> a +o D <= C \<oplus> D"
+  by (auto simp add: elt_set_plus_def set_plus_def)
 
 lemma set_plus_mono4 [intro]: "(a::'a::comm_monoid_add) : C ==>
-    a +o D <= D + C"
-  by (auto simp add: elt_set_plus_def set_plus add_ac)
+    a +o D <= D \<oplus> C"
+  by (auto simp add: elt_set_plus_def set_plus_def add_ac)
 
-lemma set_plus_mono5: "a:C ==> B <= D ==> a +o B <= C + D"
+lemma set_plus_mono5: "a:C ==> B <= D ==> a +o B <= C \<oplus> D"
   apply (subgoal_tac "a +o B <= a +o D")
    apply (erule order_trans)
    apply (erule set_plus_mono3)
@@ -259,21 +205,21 @@
   apply auto
   done
 
-lemma set_plus_mono2_b: "C <= D ==> E <= F ==> x : C + E ==>
-    x : D + F"
+lemma set_plus_mono2_b: "C <= D ==> E <= F ==> x : C \<oplus> E ==>
+    x : D \<oplus> F"
   apply (frule set_plus_mono2)
    prefer 2
    apply force
   apply assumption
   done
 
-lemma set_plus_mono3_b: "a : C ==> x : a +o D ==> x : C + D"
+lemma set_plus_mono3_b: "a : C ==> x : a +o D ==> x : C \<oplus> D"
   apply (frule set_plus_mono3)
   apply auto
   done
 
 lemma set_plus_mono4_b: "(a::'a::comm_monoid_add) : C ==>
-    x : a +o D ==> x : D + C"
+    x : a +o D ==> x : D \<oplus> C"
   apply (frule set_plus_mono4)
   apply auto
   done
@@ -281,8 +227,8 @@
 lemma set_zero_plus [simp]: "(0::'a::comm_monoid_add) +o C = C"
   by (auto simp add: elt_set_plus_def)
 
-lemma set_zero_plus2: "(0::'a::comm_monoid_add) : A ==> B <= A + B"
-  apply (auto intro!: subsetI simp add: set_plus)
+lemma set_zero_plus2: "(0::'a::comm_monoid_add) : A ==> B <= A \<oplus> B"
+  apply (auto intro!: subsetI simp add: set_plus_def)
   apply (rule_tac x = 0 in bexI)
    apply (rule_tac x = x in bexI)
     apply (auto simp add: add_ac)
@@ -302,15 +248,15 @@
   by (rule iffI, rule set_minus_imp_plus, assumption, rule set_plus_imp_minus,
     assumption)
 
-lemma set_times_intro [intro]: "a : C ==> b : D ==> a * b : C * D"
-  by (auto simp add: set_times)
+lemma set_times_intro [intro]: "a : C ==> b : D ==> a * b : C \<otimes> D"
+  by (auto simp add: set_times_def)
 
 lemma set_times_intro2 [intro!]: "b : C ==> a * b : a *o C"
   by (auto simp add: elt_set_times_def)
 
-lemma set_times_rearrange: "((a::'a::comm_monoid_mult) *o C) *
-    (b *o D) = (a * b) *o (C * D)"
-  apply (auto simp add: elt_set_times_def set_times)
+lemma set_times_rearrange: "((a::'a::comm_monoid_mult) *o C) \<otimes>
+    (b *o D) = (a * b) *o (C \<otimes> D)"
+  apply (auto simp add: elt_set_times_def set_times_def)
    apply (rule_tac x = "ba * bb" in exI)
    apply (auto simp add: mult_ac)
   apply (rule_tac x = "aa * a" in exI)
@@ -321,9 +267,9 @@
     (a * b) *o C"
   by (auto simp add: elt_set_times_def mult_assoc)
 
-lemma set_times_rearrange3: "((a::'a::semigroup_mult) *o B) * C =
-    a *o (B * C)"
-  apply (auto simp add: elt_set_times_def set_times)
+lemma set_times_rearrange3: "((a::'a::semigroup_mult) *o B) \<otimes> C =
+    a *o (B \<otimes> C)"
+  apply (auto simp add: elt_set_times_def set_times_def)
    apply (blast intro: mult_ac)
   apply (rule_tac x = "a * aa" in exI)
   apply (rule conjI)
@@ -333,9 +279,9 @@
    apply (auto simp add: mult_ac)
   done
 
-theorem set_times_rearrange4: "C * ((a::'a::comm_monoid_mult) *o D) =
-    a *o (C * D)"
-  apply (auto intro!: subsetI simp add: elt_set_times_def set_times
+theorem set_times_rearrange4: "C \<otimes> ((a::'a::comm_monoid_mult) *o D) =
+    a *o (C \<otimes> D)"
+  apply (auto intro!: subsetI simp add: elt_set_times_def set_times_def
     mult_ac)
    apply (rule_tac x = "aa * ba" in exI)
    apply (auto simp add: mult_ac)
@@ -348,17 +294,17 @@
   by (auto simp add: elt_set_times_def)
 
 lemma set_times_mono2 [intro]: "(C::('a::times) set) <= D ==> E <= F ==>
-    C * E <= D * F"
-  by (auto simp add: set_times)
+    C \<otimes> E <= D \<otimes> F"
+  by (auto simp add: set_times_def)
 
-lemma set_times_mono3 [intro]: "a : C ==> a *o D <= C * D"
-  by (auto simp add: elt_set_times_def set_times)
+lemma set_times_mono3 [intro]: "a : C ==> a *o D <= C \<otimes> D"
+  by (auto simp add: elt_set_times_def set_times_def)
 
 lemma set_times_mono4 [intro]: "(a::'a::comm_monoid_mult) : C ==>
-    a *o D <= D * C"
-  by (auto simp add: elt_set_times_def set_times mult_ac)
+    a *o D <= D \<otimes> C"
+  by (auto simp add: elt_set_times_def set_times_def mult_ac)
 
-lemma set_times_mono5: "a:C ==> B <= D ==> a *o B <= C * D"
+lemma set_times_mono5: "a:C ==> B <= D ==> a *o B <= C \<otimes> D"
   apply (subgoal_tac "a *o B <= a *o D")
    apply (erule order_trans)
    apply (erule set_times_mono3)
@@ -371,21 +317,21 @@
   apply auto
   done
 
-lemma set_times_mono2_b: "C <= D ==> E <= F ==> x : C * E ==>
-    x : D * F"
+lemma set_times_mono2_b: "C <= D ==> E <= F ==> x : C \<otimes> E ==>
+    x : D \<otimes> F"
   apply (frule set_times_mono2)
    prefer 2
    apply force
   apply assumption
   done
 
-lemma set_times_mono3_b: "a : C ==> x : a *o D ==> x : C * D"
+lemma set_times_mono3_b: "a : C ==> x : a *o D ==> x : C \<otimes> D"
   apply (frule set_times_mono3)
   apply auto
   done
 
 lemma set_times_mono4_b: "(a::'a::comm_monoid_mult) : C ==>
-    x : a *o D ==> x : D * C"
+    x : a *o D ==> x : D \<otimes> C"
   apply (frule set_times_mono4)
   apply auto
   done
@@ -397,19 +343,19 @@
     (a * b) +o (a *o C)"
   by (auto simp add: elt_set_plus_def elt_set_times_def ring_distribs)
 
-lemma set_times_plus_distrib2: "(a::'a::semiring) *o (B + C) =
-    (a *o B) + (a *o C)"
-  apply (auto simp add: set_plus elt_set_times_def ring_distribs)
+lemma set_times_plus_distrib2: "(a::'a::semiring) *o (B \<oplus> C) =
+    (a *o B) \<oplus> (a *o C)"
+  apply (auto simp add: set_plus_def elt_set_times_def ring_distribs)
    apply blast
   apply (rule_tac x = "b + bb" in exI)
   apply (auto simp add: ring_distribs)
   done
 
-lemma set_times_plus_distrib3: "((a::'a::semiring) +o C) * D <=
-    a *o D + C * D"
+lemma set_times_plus_distrib3: "((a::'a::semiring) +o C) \<otimes> D <=
+    a *o D \<oplus> C \<otimes> D"
   apply (auto intro!: subsetI simp add:
-    elt_set_plus_def elt_set_times_def set_times
-    set_plus ring_distribs)
+    elt_set_plus_def elt_set_times_def set_times_def
+    set_plus_def ring_distribs)
   apply auto
   done
 




