author | blanchet |
Tue, 20 Mar 2012 13:53:09 +0100 | |
changeset 47049 | 72bd3311ecba |
parent 46575 | f1e387195a56 |
child 48173 | c6a5a4336edf |
permissions | -rw-r--r-- |
38622 | 1 |
(* Title: HOL/Library/Function_Algebras.thy |
2 |
Author: Jeremy Avigad and Kevin Donnelly; Florian Haftmann, TUM |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
3 |
*) |
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
4 |
|
38622 | 5 |
header {* Pointwise instantiation of functions to algebra type classes *} |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
6 |
|
38622 | 7 |
theory Function_Algebras |
30738 | 8 |
imports Main |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
9 |
begin |
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
10 |
|
38622 | 11 |
text {* Pointwise operations *} |
25594 | 12 |
|
13 |
instantiation "fun" :: (type, plus) plus |
|
14 |
begin |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
15 |
|
46575 | 16 |
definition "f + g = (\<lambda>x. f x + g x)" |
25594 | 17 |
instance .. |
18 |
||
19 |
end |
|
20 |
||
38622 | 21 |
instantiation "fun" :: (type, zero) zero |
22 |
begin |
|
23 |
||
46575 | 24 |
definition "0 = (\<lambda>x. 0)" |
38622 | 25 |
instance .. |
26 |
||
27 |
end |
|
25594 | 28 |
|
29 |
instantiation "fun" :: (type, times) times |
|
30 |
begin |
|
31 |
||
46575 | 32 |
definition "f * g = (\<lambda>x. f x * g x)" |
25594 | 33 |
instance .. |
34 |
||
35 |
end |
|
36 |
||
37 |
instantiation "fun" :: (type, one) one |
|
38 |
begin |
|
39 |
||
46575 | 40 |
definition "1 = (\<lambda>x. 1)" |
25594 | 41 |
instance .. |
42 |
||
43 |
end |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
44 |
|
38622 | 45 |
|
46 |
text {* Additive structures *} |
|
47 |
||
46575 | 48 |
instance "fun" :: (type, semigroup_add) semigroup_add |
49 |
by default (simp add: plus_fun_def add.assoc) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
50 |
|
46575 | 51 |
instance "fun" :: (type, cancel_semigroup_add) cancel_semigroup_add |
52 |
by default (simp_all add: plus_fun_def fun_eq_iff) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
53 |
|
46575 | 54 |
instance "fun" :: (type, ab_semigroup_add) ab_semigroup_add |
55 |
by default (simp add: plus_fun_def add.commute) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
56 |
|
46575 | 57 |
instance "fun" :: (type, cancel_ab_semigroup_add) cancel_ab_semigroup_add |
58 |
by default simp |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
59 |
|
46575 | 60 |
instance "fun" :: (type, monoid_add) monoid_add |
61 |
by default (simp_all add: plus_fun_def zero_fun_def) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
62 |
|
46575 | 63 |
instance "fun" :: (type, comm_monoid_add) comm_monoid_add |
64 |
by default simp |
|
38622 | 65 |
|
66 |
instance "fun" :: (type, cancel_comm_monoid_add) cancel_comm_monoid_add .. |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
67 |
|
46575 | 68 |
instance "fun" :: (type, group_add) group_add |
69 |
by default |
|
70 |
(simp_all add: plus_fun_def zero_fun_def fun_Compl_def fun_diff_def diff_minus) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
71 |
|
46575 | 72 |
instance "fun" :: (type, ab_group_add) ab_group_add |
73 |
by default (simp_all add: diff_minus) |
|
38622 | 74 |
|
75 |
||
76 |
text {* Multiplicative structures *} |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
77 |
|
46575 | 78 |
instance "fun" :: (type, semigroup_mult) semigroup_mult |
79 |
by default (simp add: times_fun_def mult.assoc) |
|
38622 | 80 |
|
46575 | 81 |
instance "fun" :: (type, ab_semigroup_mult) ab_semigroup_mult |
82 |
by default (simp add: times_fun_def mult.commute) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
83 |
|
46575 | 84 |
instance "fun" :: (type, ab_semigroup_idem_mult) ab_semigroup_idem_mult |
85 |
by default (simp add: times_fun_def) |
|
38622 | 86 |
|
46575 | 87 |
instance "fun" :: (type, monoid_mult) monoid_mult |
88 |
by default (simp_all add: times_fun_def one_fun_def) |
|
38622 | 89 |
|
46575 | 90 |
instance "fun" :: (type, comm_monoid_mult) comm_monoid_mult |
91 |
by default simp |
|
38622 | 92 |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
93 |
|
38622 | 94 |
text {* Misc *} |
95 |
||
96 |
instance "fun" :: (type, "Rings.dvd") "Rings.dvd" .. |
|
97 |
||
46575 | 98 |
instance "fun" :: (type, mult_zero) mult_zero |
99 |
by default (simp_all add: zero_fun_def times_fun_def) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
100 |
|
46575 | 101 |
instance "fun" :: (type, zero_neq_one) zero_neq_one |
102 |
by default (simp add: zero_fun_def one_fun_def fun_eq_iff) |
|
19736 | 103 |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
104 |
|
38622 | 105 |
text {* Ring structures *} |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
106 |
|
46575 | 107 |
instance "fun" :: (type, semiring) semiring |
108 |
by default (simp_all add: plus_fun_def times_fun_def algebra_simps) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
109 |
|
46575 | 110 |
instance "fun" :: (type, comm_semiring) comm_semiring |
111 |
by default (simp add: plus_fun_def times_fun_def algebra_simps) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
112 |
|
38622 | 113 |
instance "fun" :: (type, semiring_0) semiring_0 .. |
114 |
||
115 |
instance "fun" :: (type, comm_semiring_0) comm_semiring_0 .. |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
116 |
|
38622 | 117 |
instance "fun" :: (type, semiring_0_cancel) semiring_0_cancel .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
118 |
|
38622 | 119 |
instance "fun" :: (type, comm_semiring_0_cancel) comm_semiring_0_cancel .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
120 |
|
38622 | 121 |
instance "fun" :: (type, semiring_1) semiring_1 .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
122 |
|
46575 | 123 |
lemma of_nat_fun: "of_nat n = (\<lambda>x::'a. of_nat n)" |
38622 | 124 |
proof - |
125 |
have comp: "comp = (\<lambda>f g x. f (g x))" |
|
126 |
by (rule ext)+ simp |
|
127 |
have plus_fun: "plus = (\<lambda>f g x. f x + g x)" |
|
128 |
by (rule ext, rule ext) (fact plus_fun_def) |
|
129 |
have "of_nat n = (comp (plus (1::'b)) ^^ n) (\<lambda>x::'a. 0)" |
|
130 |
by (simp add: of_nat_def plus_fun zero_fun_def one_fun_def comp) |
|
131 |
also have "... = comp ((plus 1) ^^ n) (\<lambda>x::'a. 0)" |
|
132 |
by (simp only: comp_funpow) |
|
133 |
finally show ?thesis by (simp add: of_nat_def comp) |
|
134 |
qed |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
135 |
|
38622 | 136 |
instance "fun" :: (type, comm_semiring_1) comm_semiring_1 .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
137 |
|
38622 | 138 |
instance "fun" :: (type, semiring_1_cancel) semiring_1_cancel .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
139 |
|
38622 | 140 |
instance "fun" :: (type, comm_semiring_1_cancel) comm_semiring_1_cancel .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
141 |
|
46575 | 142 |
instance "fun" :: (type, semiring_char_0) semiring_char_0 |
143 |
proof |
|
38622 | 144 |
from inj_of_nat have "inj (\<lambda>n (x::'a). of_nat n :: 'b)" |
145 |
by (rule inj_fun) |
|
146 |
then have "inj (\<lambda>n. of_nat n :: 'a \<Rightarrow> 'b)" |
|
147 |
by (simp add: of_nat_fun) |
|
148 |
then show "inj (of_nat :: nat \<Rightarrow> 'a \<Rightarrow> 'b)" . |
|
149 |
qed |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
150 |
|
38622 | 151 |
instance "fun" :: (type, ring) ring .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
152 |
|
38622 | 153 |
instance "fun" :: (type, comm_ring) comm_ring .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
154 |
|
38622 | 155 |
instance "fun" :: (type, ring_1) ring_1 .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
156 |
|
38622 | 157 |
instance "fun" :: (type, comm_ring_1) comm_ring_1 .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
158 |
|
38622 | 159 |
instance "fun" :: (type, ring_char_0) ring_char_0 .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
160 |
|
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
161 |
|
38622 | 162 |
text {* Ordereded structures *} |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
163 |
|
46575 | 164 |
instance "fun" :: (type, ordered_ab_semigroup_add) ordered_ab_semigroup_add |
165 |
by default (auto simp add: plus_fun_def le_fun_def intro: add_left_mono) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
166 |
|
38622 | 167 |
instance "fun" :: (type, ordered_cancel_ab_semigroup_add) ordered_cancel_ab_semigroup_add .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
168 |
|
46575 | 169 |
instance "fun" :: (type, ordered_ab_semigroup_add_imp_le) ordered_ab_semigroup_add_imp_le |
170 |
by default (simp add: plus_fun_def le_fun_def) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
171 |
|
38622 | 172 |
instance "fun" :: (type, ordered_comm_monoid_add) ordered_comm_monoid_add .. |
173 |
||
174 |
instance "fun" :: (type, ordered_ab_group_add) ordered_ab_group_add .. |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
175 |
|
46575 | 176 |
instance "fun" :: (type, ordered_semiring) ordered_semiring |
177 |
by default |
|
178 |
(auto simp add: zero_fun_def times_fun_def le_fun_def intro: mult_left_mono mult_right_mono) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
179 |
|
46575 | 180 |
instance "fun" :: (type, ordered_comm_semiring) ordered_comm_semiring |
181 |
by default (fact mult_left_mono) |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
182 |
|
38622 | 183 |
instance "fun" :: (type, ordered_cancel_semiring) ordered_cancel_semiring .. |
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
184 |
|
38622 | 185 |
instance "fun" :: (type, ordered_cancel_comm_semiring) ordered_cancel_comm_semiring .. |
186 |
||
187 |
instance "fun" :: (type, ordered_ring) ordered_ring .. |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
188 |
|
38622 | 189 |
instance "fun" :: (type, ordered_comm_ring) ordered_comm_ring .. |
190 |
||
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
191 |
|
38622 | 192 |
lemmas func_plus = plus_fun_def |
193 |
lemmas func_zero = zero_fun_def |
|
194 |
lemmas func_times = times_fun_def |
|
195 |
lemmas func_one = one_fun_def |
|
19736 | 196 |
|
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset
|
197 |
end |