src/HOL/Library/Set_Algebras.thy
author wenzelm
Wed, 13 Jul 2016 14:28:15 +0200
changeset 63473 151bb79536a7
parent 61585 a9599d3d7610
child 63485 ea8dfb0ed10e
permissions -rw-r--r--
misc tuning and modernization;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
     1
(*  Title:      HOL/Library/Set_Algebras.thy
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
     2
    Author:     Jeremy Avigad
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
     3
    Author:     Kevin Donnelly
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
     4
    Author:     Florian Haftmann, TUM
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
     5
*)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
     6
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
     7
section \<open>Algebraic operations on sets\<close>
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
     8
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
     9
theory Set_Algebras
30738
0842e906300c normalized imports
haftmann
parents: 29667
diff changeset
    10
imports Main
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    11
begin
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    12
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
    13
text \<open>
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
    14
  This library lifts operations like addition and multiplication to
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    15
  sets.  It was designed to support asymptotic calculations. See the
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    16
  comments at the top of @{file "BigO.thy"}.
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
    17
\<close>
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    18
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    19
instantiation set :: (plus) plus
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    20
begin
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    21
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    22
definition plus_set :: "'a::plus set \<Rightarrow> 'a set \<Rightarrow> 'a set"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    23
  where set_plus_def: "A + B = {c. \<exists>a\<in>A. \<exists>b\<in>B. c = a + b}"
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    24
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    25
instance ..
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    26
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    27
end
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    28
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    29
instantiation set :: (times) times
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    30
begin
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    31
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    32
definition times_set :: "'a::times set \<Rightarrow> 'a set \<Rightarrow> 'a set"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    33
  where set_times_def: "A * B = {c. \<exists>a\<in>A. \<exists>b\<in>B. c = a * b}"
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    34
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    35
instance ..
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    36
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    37
end
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    38
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    39
instantiation set :: (zero) zero
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    40
begin
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    41
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    42
definition set_zero[simp]: "(0::'a::zero set) = {0}"
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    43
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    44
instance ..
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    45
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    46
end
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
    47
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    48
instantiation set :: (one) one
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    49
begin
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    50
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    51
definition set_one[simp]: "(1::'a::one set) = {1}"
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    52
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    53
instance ..
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    54
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    55
end
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    56
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    57
definition elt_set_plus :: "'a::plus \<Rightarrow> 'a set \<Rightarrow> 'a set"  (infixl "+o" 70)
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    58
  where "a +o B = {c. \<exists>b\<in>B. c = a + b}"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    59
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    60
definition elt_set_times :: "'a::times \<Rightarrow> 'a set \<Rightarrow> 'a set"  (infixl "*o" 80)
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    61
  where "a *o B = {c. \<exists>b\<in>B. c = a * b}"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    62
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    63
abbreviation (input) elt_set_eq :: "'a \<Rightarrow> 'a set \<Rightarrow> bool"  (infix "=o" 50)
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
    64
  where "x =o A \<equiv> x \<in> A"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    65
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    66
instance set :: (semigroup_add) semigroup_add
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60500
diff changeset
    67
  by standard (force simp add: set_plus_def add.assoc)
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    68
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    69
instance set :: (ab_semigroup_add) ab_semigroup_add
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60500
diff changeset
    70
  by standard (force simp add: set_plus_def add.commute)
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    71
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    72
instance set :: (monoid_add) monoid_add
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60500
diff changeset
    73
  by standard (simp_all add: set_plus_def)
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    74
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    75
instance set :: (comm_monoid_add) comm_monoid_add
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60500
diff changeset
    76
  by standard (simp_all add: set_plus_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    77
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    78
instance set :: (semigroup_mult) semigroup_mult
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60500
diff changeset
    79
  by standard (force simp add: set_times_def mult.assoc)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    80
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    81
instance set :: (ab_semigroup_mult) ab_semigroup_mult
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60500
diff changeset
    82
  by standard (force simp add: set_times_def mult.commute)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    83
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    84
instance set :: (monoid_mult) monoid_mult
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60500
diff changeset
    85
  by standard (simp_all add: set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    86
47443
aeff49a3369b backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents: 44890
diff changeset
    87
instance set :: (comm_monoid_mult) comm_monoid_mult
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60500
diff changeset
    88
  by standard (simp_all add: set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    89
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
    90
lemma set_plus_intro [intro]: "a \<in> C \<Longrightarrow> b \<in> D \<Longrightarrow> a + b \<in> C + D"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
    91
  by (auto simp add: set_plus_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    92
53596
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
    93
lemma set_plus_elim:
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
    94
  assumes "x \<in> A + B"
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
    95
  obtains a b where "x = a + b" and "a \<in> A" and "b \<in> B"
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
    96
  using assms unfolding set_plus_def by fast
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
    97
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
    98
lemma set_plus_intro2 [intro]: "b \<in> C \<Longrightarrow> a + b \<in> a +o C"
19736
wenzelm
parents: 19656
diff changeset
    99
  by (auto simp add: elt_set_plus_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   100
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   101
lemma set_plus_rearrange: "(a +o C) + (b +o D) = (a + b) +o (C + D)"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   102
  for a b :: "'a::comm_monoid_add"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   103
  apply (auto simp add: elt_set_plus_def set_plus_def ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   104
   apply (rule_tac x = "ba + bb" in exI)
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   105
   apply (auto simp add: ac_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   106
  apply (rule_tac x = "aa + a" in exI)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   107
  apply (auto simp add: ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   108
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   109
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   110
lemma set_plus_rearrange2: "a +o (b +o C) = (a + b) +o C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   111
  for a b :: "'a::semigroup_add"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56899
diff changeset
   112
  by (auto simp add: elt_set_plus_def add.assoc)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   113
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   114
lemma set_plus_rearrange3: "(a +o B) + C = a +o (B + C)"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   115
  for a :: "'a::semigroup_add"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   116
  apply (auto simp add: elt_set_plus_def set_plus_def)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   117
   apply (blast intro: ac_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   118
  apply (rule_tac x = "a + aa" in exI)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   119
  apply (rule conjI)
19736
wenzelm
parents: 19656
diff changeset
   120
   apply (rule_tac x = "aa" in bexI)
wenzelm
parents: 19656
diff changeset
   121
    apply auto
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   122
  apply (rule_tac x = "ba" in bexI)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   123
   apply (auto simp add: ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   124
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   125
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   126
theorem set_plus_rearrange4: "C + (a +o D) = a +o (C + D)"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   127
  for a :: "'a::comm_monoid_add"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   128
  apply (auto simp add: elt_set_plus_def set_plus_def ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   129
   apply (rule_tac x = "aa + ba" in exI)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   130
   apply (auto simp add: ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   131
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   132
61337
4645502c3c64 fewer aliases for toplevel theorem statements;
wenzelm
parents: 60679
diff changeset
   133
lemmas set_plus_rearranges = set_plus_rearrange set_plus_rearrange2
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   134
  set_plus_rearrange3 set_plus_rearrange4
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   135
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   136
lemma set_plus_mono [intro!]: "C \<subseteq> D \<Longrightarrow> a +o C \<subseteq> a +o D"
19736
wenzelm
parents: 19656
diff changeset
   137
  by (auto simp add: elt_set_plus_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   138
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   139
lemma set_plus_mono2 [intro]: "C \<subseteq> D \<Longrightarrow> E \<subseteq> F \<Longrightarrow> C + E \<subseteq> D + F"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   140
  for C D E F :: "'a::plus set"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   141
  by (auto simp add: set_plus_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   142
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   143
lemma set_plus_mono3 [intro]: "a \<in> C \<Longrightarrow> a +o D \<subseteq> C + D"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   144
  by (auto simp add: elt_set_plus_def set_plus_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   145
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   146
lemma set_plus_mono4 [intro]: "a \<in> C \<Longrightarrow> a +o D \<subseteq> D + C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   147
  for a :: "'a::comm_monoid_add"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   148
  by (auto simp add: elt_set_plus_def set_plus_def ac_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   149
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   150
lemma set_plus_mono5: "a \<in> C \<Longrightarrow> B \<subseteq> D \<Longrightarrow> a +o B \<subseteq> C + D"
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   151
  apply (subgoal_tac "a +o B \<subseteq> a +o D")
19736
wenzelm
parents: 19656
diff changeset
   152
   apply (erule order_trans)
wenzelm
parents: 19656
diff changeset
   153
   apply (erule set_plus_mono3)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   154
  apply (erule set_plus_mono)
19736
wenzelm
parents: 19656
diff changeset
   155
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   156
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   157
lemma set_plus_mono_b: "C \<subseteq> D \<Longrightarrow> x \<in> a +o C \<Longrightarrow> x \<in> a +o D"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   158
  apply (frule set_plus_mono)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   159
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   160
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   161
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   162
lemma set_plus_mono2_b: "C \<subseteq> D \<Longrightarrow> E \<subseteq> F \<Longrightarrow> x \<in> C + E \<Longrightarrow> x \<in> D + F"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   163
  apply (frule set_plus_mono2)
19736
wenzelm
parents: 19656
diff changeset
   164
   prefer 2
wenzelm
parents: 19656
diff changeset
   165
   apply force
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   166
  apply assumption
19736
wenzelm
parents: 19656
diff changeset
   167
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   168
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   169
lemma set_plus_mono3_b: "a \<in> C \<Longrightarrow> x \<in> a +o D \<Longrightarrow> x \<in> C + D"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   170
  apply (frule set_plus_mono3)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   171
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   172
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   173
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   174
lemma set_plus_mono4_b: "a \<in> C \<Longrightarrow> x \<in> a +o D \<Longrightarrow> x \<in> D + C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   175
  for a x :: "'a::comm_monoid_add"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   176
  apply (frule set_plus_mono4)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   177
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   178
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   179
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   180
lemma set_zero_plus [simp]: "0 +o C = C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   181
  for C :: "'a::comm_monoid_add set"
19736
wenzelm
parents: 19656
diff changeset
   182
  by (auto simp add: elt_set_plus_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   183
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   184
lemma set_zero_plus2: "0 \<in> A \<Longrightarrow> B \<subseteq> A + B"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   185
  for A B :: "'a::comm_monoid_add set"
44142
8e27e0177518 avoid warnings about duplicate rules
huffman
parents: 40887
diff changeset
   186
  apply (auto simp add: set_plus_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   187
  apply (rule_tac x = 0 in bexI)
19736
wenzelm
parents: 19656
diff changeset
   188
   apply (rule_tac x = x in bexI)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   189
    apply (auto simp add: ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   190
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   191
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   192
lemma set_plus_imp_minus: "a \<in> b +o C \<Longrightarrow> a - b \<in> C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   193
  for a b :: "'a::ab_group_add"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   194
  by (auto simp add: elt_set_plus_def ac_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   195
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   196
lemma set_minus_imp_plus: "a - b \<in> C \<Longrightarrow> a \<in> b +o C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   197
  for a b :: "'a::ab_group_add"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   198
  apply (auto simp add: elt_set_plus_def ac_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   199
  apply (subgoal_tac "a = (a + - b) + b")
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   200
   apply (rule bexI)
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   201
    apply assumption
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   202
   apply (auto simp add: ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   203
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   204
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   205
lemma set_minus_plus: "a - b \<in> C \<longleftrightarrow> a \<in> b +o C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   206
  for a b :: "'a::ab_group_add"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   207
  apply (rule iffI)
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   208
   apply (rule set_minus_imp_plus)
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   209
   apply assumption
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   210
  apply (rule set_plus_imp_minus)
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   211
  apply assumption
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   212
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   213
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   214
lemma set_times_intro [intro]: "a \<in> C \<Longrightarrow> b \<in> D \<Longrightarrow> a * b \<in> C * D"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   215
  by (auto simp add: set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   216
53596
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   217
lemma set_times_elim:
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   218
  assumes "x \<in> A * B"
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   219
  obtains a b where "x = a * b" and "a \<in> A" and "b \<in> B"
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   220
  using assms unfolding set_times_def by fast
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   221
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   222
lemma set_times_intro2 [intro!]: "b \<in> C \<Longrightarrow> a * b \<in> a *o C"
19736
wenzelm
parents: 19656
diff changeset
   223
  by (auto simp add: elt_set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   224
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   225
lemma set_times_rearrange: "(a *o C) * (b *o D) = (a * b) *o (C * D)"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   226
  for a b :: "'a::comm_monoid_mult"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   227
  apply (auto simp add: elt_set_times_def set_times_def)
19736
wenzelm
parents: 19656
diff changeset
   228
   apply (rule_tac x = "ba * bb" in exI)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   229
   apply (auto simp add: ac_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   230
  apply (rule_tac x = "aa * a" in exI)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   231
  apply (auto simp add: ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   232
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   233
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   234
lemma set_times_rearrange2: "a *o (b *o C) = (a * b) *o C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   235
  for a b :: "'a::semigroup_mult"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56899
diff changeset
   236
  by (auto simp add: elt_set_times_def mult.assoc)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   237
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   238
lemma set_times_rearrange3: "(a *o B) * C = a *o (B * C)"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   239
  for a :: "'a::semigroup_mult"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   240
  apply (auto simp add: elt_set_times_def set_times_def)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   241
   apply (blast intro: ac_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   242
  apply (rule_tac x = "a * aa" in exI)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   243
  apply (rule conjI)
19736
wenzelm
parents: 19656
diff changeset
   244
   apply (rule_tac x = "aa" in bexI)
wenzelm
parents: 19656
diff changeset
   245
    apply auto
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   246
  apply (rule_tac x = "ba" in bexI)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   247
   apply (auto simp add: ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   248
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   249
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   250
theorem set_times_rearrange4: "C * (a *o D) = a *o (C * D)"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   251
  for a :: "'a::comm_monoid_mult"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   252
  apply (auto simp add: elt_set_times_def set_times_def ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   253
   apply (rule_tac x = "aa * ba" in exI)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   254
   apply (auto simp add: ac_simps)
19736
wenzelm
parents: 19656
diff changeset
   255
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   256
61337
4645502c3c64 fewer aliases for toplevel theorem statements;
wenzelm
parents: 60679
diff changeset
   257
lemmas set_times_rearranges = set_times_rearrange set_times_rearrange2
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   258
  set_times_rearrange3 set_times_rearrange4
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   259
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   260
lemma set_times_mono [intro]: "C \<subseteq> D \<Longrightarrow> a *o C \<subseteq> a *o D"
19736
wenzelm
parents: 19656
diff changeset
   261
  by (auto simp add: elt_set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   262
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   263
lemma set_times_mono2 [intro]: "C \<subseteq> D \<Longrightarrow> E \<subseteq> F \<Longrightarrow> C * E \<subseteq> D * F"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   264
  for C D E F :: "'a::times set"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   265
  by (auto simp add: set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   266
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   267
lemma set_times_mono3 [intro]: "a \<in> C \<Longrightarrow> a *o D \<subseteq> C * D"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   268
  by (auto simp add: elt_set_times_def set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   269
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   270
lemma set_times_mono4 [intro]: "a \<in> C \<Longrightarrow> a *o D \<subseteq> D * C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   271
  for a :: "'a::comm_monoid_mult"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   272
  by (auto simp add: elt_set_times_def set_times_def ac_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   273
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   274
lemma set_times_mono5: "a \<in> C \<Longrightarrow> B \<subseteq> D \<Longrightarrow> a *o B \<subseteq> C * D"
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   275
  apply (subgoal_tac "a *o B \<subseteq> a *o D")
19736
wenzelm
parents: 19656
diff changeset
   276
   apply (erule order_trans)
wenzelm
parents: 19656
diff changeset
   277
   apply (erule set_times_mono3)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   278
  apply (erule set_times_mono)
19736
wenzelm
parents: 19656
diff changeset
   279
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   280
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   281
lemma set_times_mono_b: "C \<subseteq> D \<Longrightarrow> x \<in> a *o C \<Longrightarrow> x \<in> a *o D"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   282
  apply (frule set_times_mono)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   283
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   284
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   285
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   286
lemma set_times_mono2_b: "C \<subseteq> D \<Longrightarrow> E \<subseteq> F \<Longrightarrow> x \<in> C * E \<Longrightarrow> x \<in> D * F"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   287
  apply (frule set_times_mono2)
19736
wenzelm
parents: 19656
diff changeset
   288
   prefer 2
wenzelm
parents: 19656
diff changeset
   289
   apply force
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   290
  apply assumption
19736
wenzelm
parents: 19656
diff changeset
   291
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   292
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   293
lemma set_times_mono3_b: "a \<in> C \<Longrightarrow> x \<in> a *o D \<Longrightarrow> x \<in> C * D"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   294
  apply (frule set_times_mono3)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   295
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   296
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   297
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   298
lemma set_times_mono4_b: "a \<in> C \<Longrightarrow> x \<in> a *o D \<Longrightarrow> x \<in> D * C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   299
  for a x :: "'a::comm_monoid_mult"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   300
  apply (frule set_times_mono4)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   301
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   302
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   303
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   304
lemma set_one_times [simp]: "1 *o C = C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   305
  for C :: "'a::comm_monoid_mult set"
19736
wenzelm
parents: 19656
diff changeset
   306
  by (auto simp add: elt_set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   307
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   308
lemma set_times_plus_distrib: "a *o (b +o C) = (a * b) +o (a *o C)"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   309
  for a b :: "'a::semiring"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 21404
diff changeset
   310
  by (auto simp add: elt_set_plus_def elt_set_times_def ring_distribs)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   311
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   312
lemma set_times_plus_distrib2: "a *o (B + C) = (a *o B) + (a *o C)"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   313
  for a :: "'a::semiring"
26814
b3e8d5ec721d Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents: 25764
diff changeset
   314
  apply (auto simp add: set_plus_def elt_set_times_def ring_distribs)
19736
wenzelm
parents: 19656
diff changeset
   315
   apply blast
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   316
  apply (rule_tac x = "b + bb" in exI)
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 21404
diff changeset
   317
  apply (auto simp add: ring_distribs)
19736
wenzelm
parents: 19656
diff changeset
   318
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   319
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   320
lemma set_times_plus_distrib3: "(a +o C) * D \<subseteq> a *o D + C * D"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   321
  for a :: "'a::semiring"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   322
  apply (auto simp: elt_set_plus_def elt_set_times_def set_times_def set_plus_def ring_distribs)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   323
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   324
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   325
61337
4645502c3c64 fewer aliases for toplevel theorem statements;
wenzelm
parents: 60679
diff changeset
   326
lemmas set_times_plus_distribs =
19380
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 17161
diff changeset
   327
  set_times_plus_distrib
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   328
  set_times_plus_distrib2
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   329
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   330
lemma set_neg_intro: "a \<in> (- 1) *o C \<Longrightarrow> - a \<in> C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   331
  for a :: "'a::ring_1"
19736
wenzelm
parents: 19656
diff changeset
   332
  by (auto simp add: elt_set_times_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   333
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   334
lemma set_neg_intro2: "a \<in> C \<Longrightarrow> - a \<in> (- 1) *o C"
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   335
  for a :: "'a::ring_1"
19736
wenzelm
parents: 19656
diff changeset
   336
  by (auto simp add: elt_set_times_def)
wenzelm
parents: 19656
diff changeset
   337
53596
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   338
lemma set_plus_image: "S + T = (\<lambda>(x, y). x + y) ` (S \<times> T)"
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   339
  by (fastforce simp: set_plus_def image_iff)
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   340
53596
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   341
lemma set_times_image: "S * T = (\<lambda>(x, y). x * y) ` (S \<times> T)"
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   342
  by (fastforce simp: set_times_def image_iff)
53596
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   343
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   344
lemma finite_set_plus: "finite s \<Longrightarrow> finite t \<Longrightarrow> finite (s + t)"
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   345
  by (simp add: set_plus_image)
53596
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   346
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   347
lemma finite_set_times: "finite s \<Longrightarrow> finite t \<Longrightarrow> finite (s * t)"
63473
151bb79536a7 misc tuning and modernization;
wenzelm
parents: 61585
diff changeset
   348
  by (simp add: set_times_image)
53596
d29d63460d84 new lemmas
huffman
parents: 47446
diff changeset
   349
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   350
lemma set_setsum_alt:
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   351
  assumes fin: "finite I"
47444
d21c95af2df7 removed "setsum_set", now subsumed by generic setsum
krauss
parents: 47443
diff changeset
   352
  shows "setsum S I = {setsum s I |s. \<forall>i\<in>I. s i \<in> S i}"
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   353
    (is "_ = ?setsum I")
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   354
  using fin
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   355
proof induct
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   356
  case empty
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   357
  then show ?case by simp
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   358
next
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   359
  case (insert x F)
47445
69e96e5500df Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
krauss
parents: 47444
diff changeset
   360
  have "setsum S (insert x F) = S x + ?setsum F"
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   361
    using insert.hyps by auto
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   362
  also have "\<dots> = {s x + setsum s F |s. \<forall> i\<in>insert x F. s i \<in> S i}"
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   363
    unfolding set_plus_def
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   364
  proof safe
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   365
    fix y s
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   366
    assume "y \<in> S x" "\<forall>i\<in>F. s i \<in> S i"
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   367
    then show "\<exists>s'. y + setsum s F = s' x + setsum s' F \<and> (\<forall>i\<in>insert x F. s' i \<in> S i)"
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   368
      using insert.hyps
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   369
      by (intro exI[of _ "\<lambda>i. if i \<in> F then s i else y"]) (auto simp add: set_plus_def)
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   370
  qed auto
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   371
  finally show ?case
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   372
    using insert.hyps by auto
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   373
qed
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   374
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   375
lemma setsum_set_cond_linear:
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   376
  fixes f :: "'a::comm_monoid_add set \<Rightarrow> 'b::comm_monoid_add set"
47445
69e96e5500df Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
krauss
parents: 47444
diff changeset
   377
  assumes [intro!]: "\<And>A B. P A  \<Longrightarrow> P B  \<Longrightarrow> P (A + B)" "P {0}"
69e96e5500df Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
krauss
parents: 47444
diff changeset
   378
    and f: "\<And>A B. P A  \<Longrightarrow> P B \<Longrightarrow> f (A + B) = f A + f B" "f {0} = {0}"
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   379
  assumes all: "\<And>i. i \<in> I \<Longrightarrow> P (S i)"
47444
d21c95af2df7 removed "setsum_set", now subsumed by generic setsum
krauss
parents: 47443
diff changeset
   380
  shows "f (setsum S I) = setsum (f \<circ> S) I"
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   381
proof (cases "finite I")
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   382
  case True
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   383
  from this all show ?thesis
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   384
  proof induct
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   385
    case empty
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   386
    then show ?case by (auto intro!: f)
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   387
  next
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   388
    case (insert x F)
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   389
    from \<open>finite F\<close> \<open>\<And>i. i \<in> insert x F \<Longrightarrow> P (S i)\<close> have "P (setsum S F)"
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   390
      by induct auto
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   391
    with insert show ?case
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   392
      by (simp, subst f) auto
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   393
  qed
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   394
next
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   395
  case False
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   396
  then show ?thesis by (auto intro!: f)
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   397
qed
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   398
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   399
lemma setsum_set_linear:
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   400
  fixes f :: "'a::comm_monoid_add set \<Rightarrow> 'b::comm_monoid_add set"
47445
69e96e5500df Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
krauss
parents: 47444
diff changeset
   401
  assumes "\<And>A B. f(A) + f(B) = f(A + B)" "f {0} = {0}"
47444
d21c95af2df7 removed "setsum_set", now subsumed by generic setsum
krauss
parents: 47443
diff changeset
   402
  shows "f (setsum S I) = setsum (f \<circ> S) I"
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   403
  using setsum_set_cond_linear[of "\<lambda>x. True" f I S] assms by auto
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 39302
diff changeset
   404
47446
ed0795caec95 distributivity of * over Un and UNION
krauss
parents: 47445
diff changeset
   405
lemma set_times_Un_distrib:
ed0795caec95 distributivity of * over Un and UNION
krauss
parents: 47445
diff changeset
   406
  "A * (B \<union> C) = A * B \<union> A * C"
ed0795caec95 distributivity of * over Un and UNION
krauss
parents: 47445
diff changeset
   407
  "(A \<union> B) * C = A * C \<union> B * C"
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   408
  by (auto simp: set_times_def)
47446
ed0795caec95 distributivity of * over Un and UNION
krauss
parents: 47445
diff changeset
   409
ed0795caec95 distributivity of * over Un and UNION
krauss
parents: 47445
diff changeset
   410
lemma set_times_UNION_distrib:
56899
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   411
  "A * UNION I M = (\<Union>i\<in>I. A * M i)"
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   412
  "UNION I M * A = (\<Union>i\<in>I. M i * A)"
9b9f4abaaa7e more symbols;
wenzelm
parents: 54230
diff changeset
   413
  by (auto simp: set_times_def)
47446
ed0795caec95 distributivity of * over Un and UNION
krauss
parents: 47445
diff changeset
   414
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   415
end