src/Doc/Tutorial/Sets/Functions.thy
author wenzelm
Wed, 29 May 2024 16:06:07 +0200
changeset 80211 2ec1b11f1f93
parent 67406 23307fd33906
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 10983
diff changeset
     1
theory Functions imports Main begin
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     2
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     3
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
     4
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     5
@{thm[display] id_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     6
\rulename{id_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     7
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     8
@{thm[display] o_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     9
\rulename{o_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    10
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    11
@{thm[display] o_assoc[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    12
\rulename{o_assoc}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    13
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    14
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    15
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    16
@{thm[display] fun_upd_apply[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    17
\rulename{fun_upd_apply}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    18
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    19
@{thm[display] fun_upd_upd[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    20
\rulename{fun_upd_upd}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    21
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    22
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    23
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    24
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    25
definitions of injective, surjective, bijective
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    26
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    27
@{thm[display] inj_on_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    28
\rulename{inj_on_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    29
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    30
@{thm[display] surj_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    31
\rulename{surj_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    32
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    33
@{thm[display] bij_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    34
\rulename{bij_def}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    35
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    36
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    37
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    38
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    39
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    40
possibly interesting theorems about inv
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    41
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    42
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    43
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    44
@{thm[display] inv_f_f[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    45
\rulename{inv_f_f}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    46
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    47
@{thm[display] inj_imp_surj_inv[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    48
\rulename{inj_imp_surj_inv}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    49
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    50
@{thm[display] surj_imp_inj_inv[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    51
\rulename{surj_imp_inj_inv}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    52
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    53
@{thm[display] surj_f_inv_f[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    54
\rulename{surj_f_inv_f}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    55
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    56
@{thm[display] bij_imp_bij_inv[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    57
\rulename{bij_imp_bij_inv}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    58
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    59
@{thm[display] inv_inv_eq[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    60
\rulename{inv_inv_eq}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    61
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    62
@{thm[display] o_inv_distrib[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    63
\rulename{o_inv_distrib}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    64
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    65
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    66
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    67
small sample proof
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    68
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    69
@{thm[display] ext[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    70
\rulename{ext}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    71
39795
9e59b4c11039 updated files to recent changes
haftmann
parents: 36745
diff changeset
    72
@{thm[display] fun_eq_iff[no_vars]}
9e59b4c11039 updated files to recent changes
haftmann
parents: 36745
diff changeset
    73
\rulename{fun_eq_iff}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    74
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    75
58860
fee7cfa69c50 eliminated spurious semicolons;
wenzelm
parents: 56154
diff changeset
    76
lemma "inj f \<Longrightarrow> (f o g = f o h) = (g = h)"
39795
9e59b4c11039 updated files to recent changes
haftmann
parents: 36745
diff changeset
    77
  apply (simp add: fun_eq_iff inj_on_def)
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    78
  apply (auto)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    79
  done
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    80
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    81
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    82
\begin{isabelle}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    83
inj\ f\ \isasymLongrightarrow \ (f\ \isasymcirc \ g\ =\ f\ \isasymcirc \ h)\ =\ (g\ =\ h)\isanewline
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    84
\ 1.\ \isasymforall x\ y.\ f\ x\ =\ f\ y\ \isasymlongrightarrow \ x\ =\ y\ \isasymLongrightarrow \isanewline
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    85
\ \ \ \ (\isasymforall x.\ f\ (g\ x)\ =\ f\ (h\ x))\ =\ (\isasymforall x.\ g\ x\ =\ h\ x)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    86
\end{isabelle}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    87
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    88
 
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    89
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    90
text\<open>image, inverse image\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    91
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    92
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    93
@{thm[display] image_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    94
\rulename{image_def}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    95
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    96
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    97
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    98
@{thm[display] image_Un[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    99
\rulename{image_Un}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   100
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   101
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   102
text\<open>
56154
f0a927235162 more complete set of lemmas wrt. image and composition
haftmann
parents: 48985
diff changeset
   103
@{thm[display] image_comp[no_vars]}
f0a927235162 more complete set of lemmas wrt. image and composition
haftmann
parents: 48985
diff changeset
   104
\rulename{image_comp}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   105
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   106
@{thm[display] image_Int[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   107
\rulename{image_Int}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   108
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   109
@{thm[display] bij_image_Compl_eq[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   110
\rulename{bij_image_Compl_eq}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   111
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   112
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   113
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   114
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   115
illustrates Union as well as image
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   116
\<close>
10849
de981d0037ed now using "by" for one-line proofs
paulson
parents: 10839
diff changeset
   117
10839
1f93f5a27de6 *** empty log message ***
nipkow
parents: 10341
diff changeset
   118
lemma "f`A \<union> g`A = (\<Union>x\<in>A. {f x, g x})"
10849
de981d0037ed now using "by" for one-line proofs
paulson
parents: 10839
diff changeset
   119
by blast
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   120
10839
1f93f5a27de6 *** empty log message ***
nipkow
parents: 10341
diff changeset
   121
lemma "f ` {(x,y). P x y} = {f(x,y) | x y. P x y}"
10849
de981d0037ed now using "by" for one-line proofs
paulson
parents: 10839
diff changeset
   122
by blast
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   123
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   124
text\<open>actually a macro!\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   125
10839
1f93f5a27de6 *** empty log message ***
nipkow
parents: 10341
diff changeset
   126
lemma "range f = f`UNIV"
10849
de981d0037ed now using "by" for one-line proofs
paulson
parents: 10839
diff changeset
   127
by blast
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   128
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   129
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   130
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   131
inverse image
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   132
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   133
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   134
text\<open>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   135
@{thm[display] vimage_def[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   136
\rulename{vimage_def}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   137
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   138
@{thm[display] vimage_Compl[no_vars]}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   139
\rulename{vimage_Compl}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   140
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   141
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   142
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   143
end