src/HOL/Library/SetsAndFunctions.thy
author haftmann
Fri, 18 Apr 2008 09:44:16 +0200
changeset 26719 a259d259c797
parent 25764 878c37886eed
child 26814 b3e8d5ec721d
permissions -rwxr-xr-x
improved definition of upd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16932
0bca871f5a21 proper header;
wenzelm
parents: 16908
diff changeset
     1
(*  Title:      HOL/Library/SetsAndFunctions.thy
19736
wenzelm
parents: 19656
diff changeset
     2
    ID:         $Id$
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
     3
    Author:     Jeremy Avigad and Kevin Donnelly
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
     4
*)
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
header {* Operations on sets and functions *}
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
     7
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
     8
theory SetsAndFunctions
25691
8f8d83af100a switched from PreList to ATP_Linkup
haftmann
parents: 25594
diff changeset
     9
imports ATP_Linkup
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    10
begin
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    11
19736
wenzelm
parents: 19656
diff changeset
    12
text {*
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    13
This library lifts operations like addition and muliplication to sets and
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    14
functions of appropriate types. It was designed to support asymptotic
17161
57c69627d71a tuned some proofs;
wenzelm
parents: 16932
diff changeset
    15
calculations. See the comments at the top of theory @{text BigO}.
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    16
*}
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    17
19736
wenzelm
parents: 19656
diff changeset
    18
subsection {* Basic definitions *}
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    19
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    20
instantiation set :: (plus) plus
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    21
begin
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    22
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    23
definition
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    24
  set_plus: "A + B == {c. EX a:A. EX b:B. c = a + b}"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    25
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    26
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    27
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    28
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    29
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    30
instantiation "fun" :: (type, plus) plus
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    31
begin
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    32
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    33
definition
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    34
  func_plus: "f + g == (%x. f x + g x)"
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    35
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    36
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    37
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    38
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    39
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    40
instantiation set :: (times) times
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    41
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    42
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    43
definition
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    44
  set_times:"A * B == {c. EX a:A. EX b:B. c = a * b}"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    45
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    46
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    47
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    48
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    49
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    50
instantiation "fun" :: (type, times) times
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    51
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    52
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    53
definition
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    54
  func_times: "f * g == (%x. f x * g x)"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    55
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    56
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    57
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    58
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    59
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    60
instantiation "fun" :: (type, minus) minus
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    61
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    62
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    63
definition
19736
wenzelm
parents: 19656
diff changeset
    64
  func_diff: "f - g == %x. f x - g x"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    65
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    66
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    67
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    68
end
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    69
25764
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    70
instantiation "fun" :: (type, uminus) uminus
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    71
begin
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    72
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    73
definition
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    74
  func_minus: "- f == (%x. - f x)"
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    75
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    76
instance ..
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    77
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    78
end
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    79
878c37886eed removed some legacy instantiations
haftmann
parents: 25691
diff changeset
    80
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    81
instantiation set :: (zero) zero
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    82
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    83
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    84
definition
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    85
  set_zero: "0::('a::zero)set == {0}"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    86
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    87
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    88
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    89
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    90
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    91
instantiation "fun" :: (type, zero) zero
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    92
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    93
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    94
definition
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    95
  func_zero: "0::(('a::type) => ('b::zero)) == %x. 0"
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    96
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    97
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    98
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    99
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   100
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   101
instantiation set :: (one) one
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   102
begin
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   103
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   104
definition
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   105
  set_one: "1::('a::one)set == {1}"
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   106
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   107
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   108
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   109
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   110
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   111
instantiation "fun" :: (type, one) one
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   112
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   113
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   114
definition
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   115
  func_one: "1::(('a::type) => ('b::one)) == %x. 1"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   116
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   117
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   118
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
   119
end
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   120
19736
wenzelm
parents: 19656
diff changeset
   121
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20523
diff changeset
   122
  elt_set_plus :: "'a::plus => 'a set => 'a set"  (infixl "+o" 70) where
19736
wenzelm
parents: 19656
diff changeset
   123
  "a +o B = {c. EX b:B. c = a + b}"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   124
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20523
diff changeset
   125
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20523
diff changeset
   126
  elt_set_times :: "'a::times => 'a set => 'a set"  (infixl "*o" 80) where
19736
wenzelm
parents: 19656
diff changeset
   127
  "a *o B = {c. EX b:B. c = a * b}"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   128
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19380
diff changeset
   129
abbreviation (input)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20523
diff changeset
   130
  elt_set_eq :: "'a => 'a set => bool"  (infix "=o" 50) where
19380
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 17161
diff changeset
   131
  "x =o A == x : A"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   132
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 19736
diff changeset
   133
instance "fun" :: (type,semigroup_add)semigroup_add
19380
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 17161
diff changeset
   134
  by default (auto simp add: func_plus add_assoc)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   135
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 19736
diff changeset
   136
instance "fun" :: (type,comm_monoid_add)comm_monoid_add
19380
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 17161
diff changeset
   137
  by default (auto simp add: func_zero func_plus add_ac)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   138
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 19736
diff changeset
   139
instance "fun" :: (type,ab_group_add)ab_group_add
19736
wenzelm
parents: 19656
diff changeset
   140
  apply default
wenzelm
parents: 19656
diff changeset
   141
   apply (simp add: func_minus func_plus func_zero)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   142
  apply (simp add: func_minus func_plus func_diff diff_minus)
19736
wenzelm
parents: 19656
diff changeset
   143
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   144
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 19736
diff changeset
   145
instance "fun" :: (type,semigroup_mult)semigroup_mult
19736
wenzelm
parents: 19656
diff changeset
   146
  apply default
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   147
  apply (auto simp add: func_times mult_assoc)
19736
wenzelm
parents: 19656
diff changeset
   148
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   149
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 19736
diff changeset
   150
instance "fun" :: (type,comm_monoid_mult)comm_monoid_mult
19736
wenzelm
parents: 19656
diff changeset
   151
  apply default
wenzelm
parents: 19656
diff changeset
   152
   apply (auto simp add: func_one func_times mult_ac)
wenzelm
parents: 19656
diff changeset
   153
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   154
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 19736
diff changeset
   155
instance "fun" :: (type,comm_ring_1)comm_ring_1
19736
wenzelm
parents: 19656
diff changeset
   156
  apply default
wenzelm
parents: 19656
diff changeset
   157
   apply (auto simp add: func_plus func_times func_minus func_diff ext
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 21404
diff changeset
   158
     func_one func_zero ring_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   159
  apply (drule fun_cong)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   160
  apply simp
19736
wenzelm
parents: 19656
diff changeset
   161
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   162
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   163
instance set :: (semigroup_add)semigroup_add
19736
wenzelm
parents: 19656
diff changeset
   164
  apply default
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   165
  apply (unfold set_plus)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   166
  apply (force simp add: add_assoc)
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
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   169
instance set :: (semigroup_mult)semigroup_mult
19736
wenzelm
parents: 19656
diff changeset
   170
  apply default
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   171
  apply (unfold set_times)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   172
  apply (force simp add: mult_assoc)
19736
wenzelm
parents: 19656
diff changeset
   173
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   174
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   175
instance set :: (comm_monoid_add)comm_monoid_add
19736
wenzelm
parents: 19656
diff changeset
   176
  apply default
wenzelm
parents: 19656
diff changeset
   177
   apply (unfold set_plus)
wenzelm
parents: 19656
diff changeset
   178
   apply (force simp add: add_ac)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   179
  apply (unfold set_zero)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   180
  apply force
19736
wenzelm
parents: 19656
diff changeset
   181
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   182
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   183
instance set :: (comm_monoid_mult)comm_monoid_mult
19736
wenzelm
parents: 19656
diff changeset
   184
  apply default
wenzelm
parents: 19656
diff changeset
   185
   apply (unfold set_times)
wenzelm
parents: 19656
diff changeset
   186
   apply (force simp add: mult_ac)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   187
  apply (unfold set_one)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   188
  apply force
19736
wenzelm
parents: 19656
diff changeset
   189
  done
wenzelm
parents: 19656
diff changeset
   190
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   191
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   192
subsection {* Basic properties *}
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   193
19736
wenzelm
parents: 19656
diff changeset
   194
lemma set_plus_intro [intro]: "a : C ==> b : D ==> a + b : C + D"
wenzelm
parents: 19656
diff changeset
   195
  by (auto simp add: set_plus)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   196
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   197
lemma set_plus_intro2 [intro]: "b : C ==> a + b : a +o C"
19736
wenzelm
parents: 19656
diff changeset
   198
  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
   199
19736
wenzelm
parents: 19656
diff changeset
   200
lemma set_plus_rearrange: "((a::'a::comm_monoid_add) +o C) +
wenzelm
parents: 19656
diff changeset
   201
    (b +o D) = (a + b) +o (C + D)"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   202
  apply (auto simp add: elt_set_plus_def set_plus add_ac)
19736
wenzelm
parents: 19656
diff changeset
   203
   apply (rule_tac x = "ba + bb" in exI)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   204
  apply (auto simp add: add_ac)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   205
  apply (rule_tac x = "aa + a" in exI)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   206
  apply (auto simp add: add_ac)
19736
wenzelm
parents: 19656
diff changeset
   207
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   208
19736
wenzelm
parents: 19656
diff changeset
   209
lemma set_plus_rearrange2: "(a::'a::semigroup_add) +o (b +o C) =
wenzelm
parents: 19656
diff changeset
   210
    (a + b) +o C"
wenzelm
parents: 19656
diff changeset
   211
  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
   212
19736
wenzelm
parents: 19656
diff changeset
   213
lemma set_plus_rearrange3: "((a::'a::semigroup_add) +o B) + C =
wenzelm
parents: 19656
diff changeset
   214
    a +o (B + C)"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   215
  apply (auto simp add: elt_set_plus_def set_plus)
19736
wenzelm
parents: 19656
diff changeset
   216
   apply (blast intro: add_ac)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   217
  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
   218
  apply (rule conjI)
19736
wenzelm
parents: 19656
diff changeset
   219
   apply (rule_tac x = "aa" in bexI)
wenzelm
parents: 19656
diff changeset
   220
    apply auto
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   221
  apply (rule_tac x = "ba" in bexI)
19736
wenzelm
parents: 19656
diff changeset
   222
   apply (auto simp add: add_ac)
wenzelm
parents: 19656
diff changeset
   223
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   224
19736
wenzelm
parents: 19656
diff changeset
   225
theorem set_plus_rearrange4: "C + ((a::'a::comm_monoid_add) +o D) =
wenzelm
parents: 19656
diff changeset
   226
    a +o (C + D)"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   227
  apply (auto intro!: subsetI simp add: elt_set_plus_def set_plus add_ac)
19736
wenzelm
parents: 19656
diff changeset
   228
   apply (rule_tac x = "aa + ba" in exI)
wenzelm
parents: 19656
diff changeset
   229
   apply (auto simp add: add_ac)
wenzelm
parents: 19656
diff changeset
   230
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   231
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   232
theorems set_plus_rearranges = set_plus_rearrange set_plus_rearrange2
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   233
  set_plus_rearrange3 set_plus_rearrange4
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   234
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   235
lemma set_plus_mono [intro!]: "C <= D ==> a +o C <= a +o D"
19736
wenzelm
parents: 19656
diff changeset
   236
  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
   237
19736
wenzelm
parents: 19656
diff changeset
   238
lemma set_plus_mono2 [intro]: "(C::('a::plus) set) <= D ==> E <= F ==>
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   239
    C + E <= D + F"
19736
wenzelm
parents: 19656
diff changeset
   240
  by (auto simp add: set_plus)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   241
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   242
lemma set_plus_mono3 [intro]: "a : C ==> a +o D <= C + D"
19736
wenzelm
parents: 19656
diff changeset
   243
  by (auto simp add: elt_set_plus_def set_plus)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   244
19736
wenzelm
parents: 19656
diff changeset
   245
lemma set_plus_mono4 [intro]: "(a::'a::comm_monoid_add) : C ==>
wenzelm
parents: 19656
diff changeset
   246
    a +o D <= D + C"
wenzelm
parents: 19656
diff changeset
   247
  by (auto simp add: elt_set_plus_def set_plus add_ac)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   248
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   249
lemma set_plus_mono5: "a:C ==> B <= D ==> a +o B <= C + D"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   250
  apply (subgoal_tac "a +o B <= a +o D")
19736
wenzelm
parents: 19656
diff changeset
   251
   apply (erule order_trans)
wenzelm
parents: 19656
diff changeset
   252
   apply (erule set_plus_mono3)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   253
  apply (erule set_plus_mono)
19736
wenzelm
parents: 19656
diff changeset
   254
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   255
19736
wenzelm
parents: 19656
diff changeset
   256
lemma set_plus_mono_b: "C <= D ==> x : a +o C
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   257
    ==> x : a +o D"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   258
  apply (frule set_plus_mono)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   259
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   260
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   261
19736
wenzelm
parents: 19656
diff changeset
   262
lemma set_plus_mono2_b: "C <= D ==> E <= F ==> x : C + E ==>
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   263
    x : D + F"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   264
  apply (frule set_plus_mono2)
19736
wenzelm
parents: 19656
diff changeset
   265
   prefer 2
wenzelm
parents: 19656
diff changeset
   266
   apply force
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   267
  apply assumption
19736
wenzelm
parents: 19656
diff changeset
   268
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   269
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   270
lemma set_plus_mono3_b: "a : C ==> x : a +o D ==> x : C + D"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   271
  apply (frule set_plus_mono3)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   272
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   273
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   274
19736
wenzelm
parents: 19656
diff changeset
   275
lemma set_plus_mono4_b: "(a::'a::comm_monoid_add) : C ==>
wenzelm
parents: 19656
diff changeset
   276
    x : a +o D ==> x : D + C"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   277
  apply (frule set_plus_mono4)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   278
  apply auto
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
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   281
lemma set_zero_plus [simp]: "(0::'a::comm_monoid_add) +o C = C"
19736
wenzelm
parents: 19656
diff changeset
   282
  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
   283
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   284
lemma set_zero_plus2: "(0::'a::comm_monoid_add) : A ==> B <= A + B"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   285
  apply (auto intro!: subsetI simp add: set_plus)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   286
  apply (rule_tac x = 0 in bexI)
19736
wenzelm
parents: 19656
diff changeset
   287
   apply (rule_tac x = x in bexI)
wenzelm
parents: 19656
diff changeset
   288
    apply (auto simp add: add_ac)
wenzelm
parents: 19656
diff changeset
   289
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   290
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   291
lemma set_plus_imp_minus: "(a::'a::ab_group_add) : b +o C ==> (a - b) : C"
19736
wenzelm
parents: 19656
diff changeset
   292
  by (auto simp add: elt_set_plus_def add_ac diff_minus)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   293
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   294
lemma set_minus_imp_plus: "(a::'a::ab_group_add) - b : C ==> a : b +o C"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   295
  apply (auto simp add: elt_set_plus_def add_ac diff_minus)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   296
  apply (subgoal_tac "a = (a + - b) + b")
19736
wenzelm
parents: 19656
diff changeset
   297
   apply (rule bexI, assumption, assumption)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   298
  apply (auto simp add: add_ac)
19736
wenzelm
parents: 19656
diff changeset
   299
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   300
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   301
lemma set_minus_plus: "((a::'a::ab_group_add) - b : C) = (a : b +o C)"
19736
wenzelm
parents: 19656
diff changeset
   302
  by (rule iffI, rule set_minus_imp_plus, assumption, rule set_plus_imp_minus,
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   303
    assumption)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   304
19736
wenzelm
parents: 19656
diff changeset
   305
lemma set_times_intro [intro]: "a : C ==> b : D ==> a * b : C * D"
wenzelm
parents: 19656
diff changeset
   306
  by (auto simp add: set_times)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   307
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   308
lemma set_times_intro2 [intro!]: "b : C ==> a * b : a *o C"
19736
wenzelm
parents: 19656
diff changeset
   309
  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
   310
19736
wenzelm
parents: 19656
diff changeset
   311
lemma set_times_rearrange: "((a::'a::comm_monoid_mult) *o C) *
wenzelm
parents: 19656
diff changeset
   312
    (b *o D) = (a * b) *o (C * D)"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   313
  apply (auto simp add: elt_set_times_def set_times)
19736
wenzelm
parents: 19656
diff changeset
   314
   apply (rule_tac x = "ba * bb" in exI)
wenzelm
parents: 19656
diff changeset
   315
   apply (auto simp add: mult_ac)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   316
  apply (rule_tac x = "aa * a" in exI)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   317
  apply (auto simp add: mult_ac)
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
19736
wenzelm
parents: 19656
diff changeset
   320
lemma set_times_rearrange2: "(a::'a::semigroup_mult) *o (b *o C) =
wenzelm
parents: 19656
diff changeset
   321
    (a * b) *o C"
wenzelm
parents: 19656
diff changeset
   322
  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
   323
19736
wenzelm
parents: 19656
diff changeset
   324
lemma set_times_rearrange3: "((a::'a::semigroup_mult) *o B) * C =
wenzelm
parents: 19656
diff changeset
   325
    a *o (B * C)"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   326
  apply (auto simp add: elt_set_times_def set_times)
19736
wenzelm
parents: 19656
diff changeset
   327
   apply (blast intro: mult_ac)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   328
  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
   329
  apply (rule conjI)
19736
wenzelm
parents: 19656
diff changeset
   330
   apply (rule_tac x = "aa" in bexI)
wenzelm
parents: 19656
diff changeset
   331
    apply auto
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   332
  apply (rule_tac x = "ba" in bexI)
19736
wenzelm
parents: 19656
diff changeset
   333
   apply (auto simp add: mult_ac)
wenzelm
parents: 19656
diff changeset
   334
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   335
19736
wenzelm
parents: 19656
diff changeset
   336
theorem set_times_rearrange4: "C * ((a::'a::comm_monoid_mult) *o D) =
wenzelm
parents: 19656
diff changeset
   337
    a *o (C * D)"
wenzelm
parents: 19656
diff changeset
   338
  apply (auto intro!: subsetI simp add: elt_set_times_def set_times
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   339
    mult_ac)
19736
wenzelm
parents: 19656
diff changeset
   340
   apply (rule_tac x = "aa * ba" in exI)
wenzelm
parents: 19656
diff changeset
   341
   apply (auto simp add: mult_ac)
wenzelm
parents: 19656
diff changeset
   342
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   343
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   344
theorems set_times_rearranges = set_times_rearrange set_times_rearrange2
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   345
  set_times_rearrange3 set_times_rearrange4
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   346
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   347
lemma set_times_mono [intro]: "C <= D ==> a *o C <= a *o D"
19736
wenzelm
parents: 19656
diff changeset
   348
  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
   349
19736
wenzelm
parents: 19656
diff changeset
   350
lemma set_times_mono2 [intro]: "(C::('a::times) set) <= D ==> E <= F ==>
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   351
    C * E <= D * F"
19736
wenzelm
parents: 19656
diff changeset
   352
  by (auto simp add: set_times)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   353
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   354
lemma set_times_mono3 [intro]: "a : C ==> a *o D <= C * D"
19736
wenzelm
parents: 19656
diff changeset
   355
  by (auto simp add: elt_set_times_def set_times)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   356
19736
wenzelm
parents: 19656
diff changeset
   357
lemma set_times_mono4 [intro]: "(a::'a::comm_monoid_mult) : C ==>
wenzelm
parents: 19656
diff changeset
   358
    a *o D <= D * C"
wenzelm
parents: 19656
diff changeset
   359
  by (auto simp add: elt_set_times_def set_times mult_ac)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   360
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   361
lemma set_times_mono5: "a:C ==> B <= D ==> a *o B <= C * D"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   362
  apply (subgoal_tac "a *o B <= a *o D")
19736
wenzelm
parents: 19656
diff changeset
   363
   apply (erule order_trans)
wenzelm
parents: 19656
diff changeset
   364
   apply (erule set_times_mono3)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   365
  apply (erule set_times_mono)
19736
wenzelm
parents: 19656
diff changeset
   366
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   367
19736
wenzelm
parents: 19656
diff changeset
   368
lemma set_times_mono_b: "C <= D ==> x : a *o C
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   369
    ==> x : a *o D"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   370
  apply (frule set_times_mono)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   371
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   372
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   373
19736
wenzelm
parents: 19656
diff changeset
   374
lemma set_times_mono2_b: "C <= D ==> E <= F ==> x : C * E ==>
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   375
    x : D * F"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   376
  apply (frule set_times_mono2)
19736
wenzelm
parents: 19656
diff changeset
   377
   prefer 2
wenzelm
parents: 19656
diff changeset
   378
   apply force
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   379
  apply assumption
19736
wenzelm
parents: 19656
diff changeset
   380
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   381
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   382
lemma set_times_mono3_b: "a : C ==> x : a *o D ==> x : C * D"
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   383
  apply (frule set_times_mono3)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   384
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   385
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   386
19736
wenzelm
parents: 19656
diff changeset
   387
lemma set_times_mono4_b: "(a::'a::comm_monoid_mult) : C ==>
wenzelm
parents: 19656
diff changeset
   388
    x : a *o D ==> x : D * C"
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   389
  apply (frule set_times_mono4)
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   390
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   391
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   392
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   393
lemma set_one_times [simp]: "(1::'a::comm_monoid_mult) *o C = C"
19736
wenzelm
parents: 19656
diff changeset
   394
  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
   395
19736
wenzelm
parents: 19656
diff changeset
   396
lemma set_times_plus_distrib: "(a::'a::semiring) *o (b +o C)=
wenzelm
parents: 19656
diff changeset
   397
    (a * b) +o (a *o C)"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 21404
diff changeset
   398
  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
   399
19736
wenzelm
parents: 19656
diff changeset
   400
lemma set_times_plus_distrib2: "(a::'a::semiring) *o (B + C) =
wenzelm
parents: 19656
diff changeset
   401
    (a *o B) + (a *o C)"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 21404
diff changeset
   402
  apply (auto simp add: set_plus elt_set_times_def ring_distribs)
19736
wenzelm
parents: 19656
diff changeset
   403
   apply blast
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   404
  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
   405
  apply (auto simp add: ring_distribs)
19736
wenzelm
parents: 19656
diff changeset
   406
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   407
19736
wenzelm
parents: 19656
diff changeset
   408
lemma set_times_plus_distrib3: "((a::'a::semiring) +o C) * D <=
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   409
    a *o D + C * D"
19736
wenzelm
parents: 19656
diff changeset
   410
  apply (auto intro!: subsetI simp add:
wenzelm
parents: 19656
diff changeset
   411
    elt_set_plus_def elt_set_times_def set_times
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 21404
diff changeset
   412
    set_plus ring_distribs)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   413
  apply auto
19736
wenzelm
parents: 19656
diff changeset
   414
  done
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   415
19380
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 17161
diff changeset
   416
theorems set_times_plus_distribs =
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 17161
diff changeset
   417
  set_times_plus_distrib
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   418
  set_times_plus_distrib2
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   419
19736
wenzelm
parents: 19656
diff changeset
   420
lemma set_neg_intro: "(a::'a::ring_1) : (- 1) *o C ==>
wenzelm
parents: 19656
diff changeset
   421
    - a : C"
wenzelm
parents: 19656
diff changeset
   422
  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
   423
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   424
lemma set_neg_intro2: "(a::'a::ring_1) : C ==>
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   425
    - a : (- 1) *o C"
19736
wenzelm
parents: 19656
diff changeset
   426
  by (auto simp add: elt_set_times_def)
wenzelm
parents: 19656
diff changeset
   427
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   428
end