src/HOL/Library/Function_Algebras.thy
author haftmann
Sat, 28 Jun 2014 21:09:17 +0200
changeset 57427 91f9e4148460
parent 56828 08041569357e
child 58881 b9556a055632
permissions -rw-r--r--
proper trading of variables; more appropriate ML variable names
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/Function_Algebras.thy
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
     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
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
     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
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
     7
theory Function_Algebras
30738
0842e906300c normalized imports
haftmann
parents: 29667
diff changeset
     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
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    11
text {* Pointwise operations *}
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    12
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    13
instantiation "fun" :: (type, plus) plus
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    14
begin
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    15
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    16
definition "f + g = (\<lambda>x. f x + g x)"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    17
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    18
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    19
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    20
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    21
lemma plus_fun_apply [simp]:
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    22
  "(f + g) x = f x + g x"
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    23
  by (simp add: plus_fun_def)
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    24
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    25
instantiation "fun" :: (type, zero) zero
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    26
begin
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    27
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    28
definition "0 = (\<lambda>x. 0)"
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    29
instance ..
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    30
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    31
end
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    32
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    33
lemma zero_fun_apply [simp]:
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    34
  "0 x = 0"
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    35
  by (simp add: zero_fun_def)
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    36
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    37
instantiation "fun" :: (type, times) times
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    38
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    39
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    40
definition "f * g = (\<lambda>x. f x * g x)"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    41
instance ..
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
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    44
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    45
lemma times_fun_apply [simp]:
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    46
  "(f * g) x = f x * g x"
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    47
  by (simp add: times_fun_def)
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    48
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    49
instantiation "fun" :: (type, one) one
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    50
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    51
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    52
definition "1 = (\<lambda>x. 1)"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    53
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    54
43c718438f9f switched import from Main to PreList
haftmann
parents: 23477
diff changeset
    55
end
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    56
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    57
lemma one_fun_apply [simp]:
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    58
  "1 x = 1"
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    59
  by (simp add: one_fun_def)
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    60
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    61
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    62
text {* Additive structures *}
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    63
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    64
instance "fun" :: (type, semigroup_add) semigroup_add
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    65
  by default (simp add: fun_eq_iff add.assoc)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    66
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    67
instance "fun" :: (type, cancel_semigroup_add) cancel_semigroup_add
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    68
  by default (simp_all add: fun_eq_iff)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    69
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    70
instance "fun" :: (type, ab_semigroup_add) ab_semigroup_add
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    71
  by default (simp add: fun_eq_iff add.commute)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    72
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    73
instance "fun" :: (type, cancel_ab_semigroup_add) cancel_ab_semigroup_add
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    74
  by default simp
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    75
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    76
instance "fun" :: (type, monoid_add) monoid_add
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    77
  by default (simp_all add: fun_eq_iff)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    78
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    79
instance "fun" :: (type, comm_monoid_add) comm_monoid_add
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    80
  by default simp
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    81
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    82
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
    83
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    84
instance "fun" :: (type, group_add) group_add
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    85
  by default
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 51489
diff changeset
    86
    (simp_all add: fun_eq_iff)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    87
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    88
instance "fun" :: (type, ab_group_add) ab_group_add
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 51489
diff changeset
    89
  by default simp_all
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    90
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    91
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    92
text {* Multiplicative structures *}
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    93
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    94
instance "fun" :: (type, semigroup_mult) semigroup_mult
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    95
  by default (simp add: fun_eq_iff mult.assoc)
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
    96
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
    97
instance "fun" :: (type, ab_semigroup_mult) ab_semigroup_mult
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
    98
  by default (simp add: fun_eq_iff mult.commute)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
    99
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   100
instance "fun" :: (type, monoid_mult) monoid_mult
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   101
  by default (simp_all add: fun_eq_iff)
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   102
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   103
instance "fun" :: (type, comm_monoid_mult) comm_monoid_mult
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   104
  by default simp
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   105
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   106
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   107
text {* Misc *}
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   108
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   109
instance "fun" :: (type, "Rings.dvd") "Rings.dvd" ..
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   110
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   111
instance "fun" :: (type, mult_zero) mult_zero
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   112
  by default (simp_all add: fun_eq_iff)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   113
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   114
instance "fun" :: (type, zero_neq_one) zero_neq_one
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   115
  by default (simp add: fun_eq_iff)
19736
wenzelm
parents: 19656
diff changeset
   116
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   117
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   118
text {* Ring structures *}
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   119
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   120
instance "fun" :: (type, semiring) semiring
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   121
  by default (simp_all add: fun_eq_iff algebra_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   122
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   123
instance "fun" :: (type, comm_semiring) comm_semiring
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   124
  by default (simp add: fun_eq_iff  algebra_simps)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   125
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   126
instance "fun" :: (type, semiring_0) semiring_0 ..
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   127
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   128
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
   129
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   130
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
   131
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   132
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
   133
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   134
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
   135
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   136
lemma of_nat_fun: "of_nat n = (\<lambda>x::'a. of_nat n)"
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   137
proof -
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   138
  have comp: "comp = (\<lambda>f g x. f (g x))"
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   139
    by (rule ext)+ simp
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   140
  have plus_fun: "plus = (\<lambda>f g x. f x + g x)"
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   141
    by (rule ext, rule ext) (fact plus_fun_def)
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   142
  have "of_nat n = (comp (plus (1::'b)) ^^ n) (\<lambda>x::'a. 0)"
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   143
    by (simp add: of_nat_def plus_fun zero_fun_def one_fun_def comp)
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   144
  also have "... = comp ((plus 1) ^^ n) (\<lambda>x::'a. 0)"
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   145
    by (simp only: comp_funpow)
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   146
  finally show ?thesis by (simp add: of_nat_def comp)
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   147
qed
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   148
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   149
lemma of_nat_fun_apply [simp]:
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   150
  "of_nat n x = of_nat n"
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   151
  by (simp add: of_nat_fun)
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   152
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   153
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
   154
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   155
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
   156
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   157
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
   158
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   159
instance "fun" :: (type, semiring_char_0) semiring_char_0
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   160
proof
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   161
  from inj_of_nat have "inj (\<lambda>n (x::'a). of_nat n :: 'b)"
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   162
    by (rule inj_fun)
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   163
  then have "inj (\<lambda>n. of_nat n :: 'a \<Rightarrow> 'b)"
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   164
    by (simp add: of_nat_fun)
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   165
  then show "inj (of_nat :: nat \<Rightarrow> 'a \<Rightarrow> 'b)" .
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   166
qed
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   167
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   168
instance "fun" :: (type, ring) ring ..
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   169
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   170
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
   171
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   172
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
   173
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   174
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
   175
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   176
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
   177
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   178
56828
08041569357e tuned spelling;
wenzelm
parents: 54230
diff changeset
   179
text {* Ordered structures *}
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   180
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   181
instance "fun" :: (type, ordered_ab_semigroup_add) ordered_ab_semigroup_add
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   182
  by default (auto simp add: 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
   183
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   184
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
   185
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   186
instance "fun" :: (type, ordered_ab_semigroup_add_imp_le) ordered_ab_semigroup_add_imp_le
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   187
  by default (simp add: le_fun_def)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   188
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   189
instance "fun" :: (type, ordered_comm_monoid_add) ordered_comm_monoid_add ..
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   190
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   191
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
   192
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   193
instance "fun" :: (type, ordered_semiring) ordered_semiring
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   194
  by default
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   195
    (auto simp add: 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
   196
46575
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   197
instance "fun" :: (type, ordered_comm_semiring) ordered_comm_semiring
f1e387195a56 misc tuning;
wenzelm
parents: 39302
diff changeset
   198
  by default (fact mult_left_mono)
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   199
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   200
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
   201
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   202
instance "fun" :: (type, ordered_cancel_comm_semiring) ordered_cancel_comm_semiring ..
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   203
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   204
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
   205
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   206
instance "fun" :: (type, ordered_comm_ring) ordered_comm_ring ..
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   207
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   208
38622
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   209
lemmas func_plus = plus_fun_def
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   210
lemmas func_zero = zero_fun_def
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   211
lemmas func_times = times_fun_def
86fc906dcd86 split and enriched theory SetsAndFunctions
haftmann
parents: 35267
diff changeset
   212
lemmas func_one = one_fun_def
19736
wenzelm
parents: 19656
diff changeset
   213
16908
d374530bfaaa Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff changeset
   214
end
48173
c6a5a4336edf eta-expanded occurences of algebraic functionals are simplified by default
haftmann
parents: 46575
diff changeset
   215