doc-src/TutorialI/Sets/Functions.thy
author paulson
Mon, 23 Oct 2000 16:24:52 +0200
changeset 10294 2ec9c808a8a7
child 10341 6eb91805a012
permissions -rw-r--r--
the Sets chapter and theories
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     1
theory Functions = Main:
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     2
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     3
ML "Pretty.setmargin 64"
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     4
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     5
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     6
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     7
@{thm[display] id_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     8
\rulename{id_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     9
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    10
@{thm[display] o_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    11
\rulename{o_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    12
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    13
@{thm[display] o_assoc[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    14
\rulename{o_assoc}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    15
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    16
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    17
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    18
@{thm[display] fun_upd_apply[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    19
\rulename{fun_upd_apply}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    20
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    21
@{thm[display] fun_upd_upd[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    22
\rulename{fun_upd_upd}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    23
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    24
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    25
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    26
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    27
definitions of injective, surjective, bijective
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    28
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    29
@{thm[display] inj_on_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    30
\rulename{inj_on_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    31
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    32
@{thm[display] surj_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    33
\rulename{surj_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    34
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    35
@{thm[display] bij_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    36
\rulename{bij_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    37
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    38
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    39
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    40
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    41
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    42
possibly interesting theorems about inv
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    43
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    44
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    45
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    46
@{thm[display] inv_f_f[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    47
\rulename{inv_f_f}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    48
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    49
@{thm[display] inj_imp_surj_inv[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    50
\rulename{inj_imp_surj_inv}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    51
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    52
@{thm[display] surj_imp_inj_inv[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    53
\rulename{surj_imp_inj_inv}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    54
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    55
@{thm[display] surj_f_inv_f[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    56
\rulename{surj_f_inv_f}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    57
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    58
@{thm[display] bij_imp_bij_inv[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    59
\rulename{bij_imp_bij_inv}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    60
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    61
@{thm[display] inv_inv_eq[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    62
\rulename{inv_inv_eq}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    63
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    64
@{thm[display] o_inv_distrib[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    65
\rulename{o_inv_distrib}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    66
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    67
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    68
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    69
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    70
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    71
small sample proof
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    72
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    73
@{thm[display] ext[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    74
\rulename{ext}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    75
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    76
@{thm[display] expand_fun_eq[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    77
\rulename{expand_fun_eq}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    78
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    79
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    80
lemma "inj f \<Longrightarrow> (f o g = f o h) = (g = h)";
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    81
  apply (simp add: expand_fun_eq inj_on_def o_def)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    82
  apply (auto)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    83
  done
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    84
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    85
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    86
\begin{isabelle}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    87
inj\ f\ \isasymLongrightarrow \ (f\ \isasymcirc \ g\ =\ f\ \isasymcirc \ h)\ =\ (g\ =\ h)\isanewline
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    88
\ 1.\ \isasymforall x\ y.\ f\ x\ =\ f\ y\ \isasymlongrightarrow \ x\ =\ y\ \isasymLongrightarrow \isanewline
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    89
\ \ \ \ (\isasymforall x.\ f\ (g\ x)\ =\ f\ (h\ x))\ =\ (\isasymforall x.\ g\ x\ =\ h\ x)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    90
\end{isabelle}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    91
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    92
 
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    93
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    94
text{*image, inverse image*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    95
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    96
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    97
@{thm[display] image_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    98
\rulename{image_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    99
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   100
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   101
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   102
@{thm[display] image_Un[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   103
\rulename{image_Un}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   104
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   105
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   106
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   107
@{thm[display] image_compose[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   108
\rulename{image_compose}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   109
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   110
@{thm[display] image_Int[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   111
\rulename{image_Int}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   112
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   113
@{thm[display] bij_image_Compl_eq[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   114
\rulename{bij_image_Compl_eq}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   115
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   116
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   117
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   118
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   119
illustrates Union as well as image
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   120
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   121
lemma "f``A \<union> g``A = (\<Union>x\<in>A. {f x, g x})"
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   122
  apply (blast)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   123
  done
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   124
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   125
lemma "f `` {(x,y). P x y} = {f(x,y) | x y. P x y}"
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   126
  apply (blast)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   127
  done
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   128
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   129
text{*actually a macro!*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   130
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   131
lemma "range f = f``UNIV"
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   132
  apply (blast)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   133
  done
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   134
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   135
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   136
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   137
inverse image
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   138
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   139
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   140
text{*
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   141
@{thm[display] vimage_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   142
\rulename{vimage_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   143
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   144
@{thm[display] vimage_Compl[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   145
\rulename{vimage_Compl}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   146
*}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   147
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   148
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   149
end