src/HOL/Fun.ML
author paulson
Wed, 11 Nov 1998 15:49:15 +0100
changeset 5847 17c869f24c5f
parent 5608 a82a038a3e7a
child 5852 4d7320490be4
permissions -rw-r--r--
proved surjI
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1264
diff changeset
     1
(*  Title:      HOL/Fun
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1264
diff changeset
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
Lemmas about functions.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
4656
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
     9
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
    10
Goal "(f = g) = (!x. f(x)=g(x))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
by (rtac iffI 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 923
diff changeset
    12
by (Asm_simp_tac 1);
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 923
diff changeset
    13
by (rtac ext 1 THEN Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
qed "expand_fun_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    16
val prems = Goal
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
    "[| f(x)=u;  !!x. P(x) ==> g(f(x)) = x;  P(x) |] ==> x=g(u)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
by (rtac (arg_cong RS box_equals) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
by (REPEAT (resolve_tac (prems@[refl]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
qed "apply_inverse";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
4656
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    23
(** "Axiom" of Choice, proved using the description operator **)
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    24
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    25
Goal "!!Q. ALL x. EX y. Q x y ==> EX f. ALL x. Q x (f x)";
4656
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    26
by (fast_tac (claset() addEs [selectI]) 1);
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    27
qed "choice";
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    28
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    29
Goal "!!S. ALL x:S. EX y. Q x y ==> EX f. ALL x:S. Q x (f x)";
4656
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    30
by (fast_tac (claset() addEs [selectI]) 1);
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    31
qed "bchoice";
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    32
134d24ddaad3 Proved choice and bchoice; changed Fun.thy -> thy
paulson
parents: 4089
diff changeset
    33
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5441
diff changeset
    34
section "id";
5441
45bd13b15d80 added Id_apply
oheimb
parents: 5318
diff changeset
    35
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5441
diff changeset
    36
qed_goalw "id_apply" thy [id_def] "id x = x" (K [rtac refl 1]);
a82a038a3e7a id <-> Id
nipkow
parents: 5441
diff changeset
    37
Addsimps [id_apply];
5441
45bd13b15d80 added Id_apply
oheimb
parents: 5318
diff changeset
    38
45bd13b15d80 added Id_apply
oheimb
parents: 5318
diff changeset
    39
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    40
section "o";
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    41
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    42
qed_goalw "o_apply" thy [o_def] "(f o g) x = f (g x)"
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    43
 (K [rtac refl 1]);
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    44
Addsimps [o_apply];
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    45
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    46
qed_goalw "o_assoc" thy [o_def] "f o (g o h) = f o g o h"
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    47
  (K [rtac ext 1, rtac refl 1]);
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    48
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5441
diff changeset
    49
qed_goalw "id_o" thy [id_def] "id o g = g"
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    50
 (K [rtac ext 1, Simp_tac 1]);
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5441
diff changeset
    51
Addsimps [id_o];
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    52
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5441
diff changeset
    53
qed_goalw "o_id" thy [id_def] "f o id = f"
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    54
 (K [rtac ext 1, Simp_tac 1]);
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5441
diff changeset
    55
Addsimps [o_id];
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    56
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    57
Goalw [o_def] "(f o g)``r = f``(g``r)";
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    58
by (Blast_tac 1);
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    59
qed "image_compose";
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    60
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    61
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    62
section "inj";
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    63
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
(*** inj(f): f is a one-to-one function ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    66
val prems = Goalw [inj_def]
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
    "[| !! x y. f(x) = f(y) ==> x=y |] ==> inj(f)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    68
by (blast_tac (claset() addIs prems) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
qed "injI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    71
val [major] = Goal "(!!x. g(f(x)) = x) ==> inj(f)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
by (rtac injI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
by (etac (arg_cong RS box_equals) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
by (rtac major 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
by (rtac major 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
qed "inj_inverseI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    78
Goalw [inj_def] "[| inj(f); f(x) = f(y) |] ==> x=y";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    79
by (Blast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
qed "injD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
(*Useful with the simplifier*)
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    83
Goal "inj(f) ==> (f(x) = f(y)) = (x=y)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
by (rtac iffI 1);
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    85
by (etac arg_cong 2);
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    86
by (etac injD 1);
5318
72bf8039b53f expandshort
paulson
parents: 5316
diff changeset
    87
by (assume_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
qed "inj_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    90
Goal "inj(f) ==> (@x. f(x)=f(y)) = y";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    91
by (etac injD 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
by (rtac selectI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
by (rtac refl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
qed "inj_select";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
(*A one-to-one function has an inverse (given using select).*)
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    97
Goalw [inv_def] "inj(f) ==> inv f (f x) = x";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    98
by (etac inj_select 1);
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
    99
qed "inv_f_f";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
(* Useful??? *)
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   102
val [oneone,minor] = Goal
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   103
    "[| inj(f); !!y. y: range(f) ==> P(inv f y) |] ==> P(x)";
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   104
by (res_inst_tac [("t", "x")] (oneone RS (inv_f_f RS subst)) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
by (rtac (rangeI RS minor) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
qed "inj_transfer";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   109
(*** inj_on f A: f is one-to-one over A ***)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   111
val prems = Goalw [inj_on_def]
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   112
    "(!! x y. [| f(x) = f(y);  x:A;  y:A |] ==> x=y) ==> inj_on f A";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   113
by (blast_tac (claset() addIs prems) 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   114
qed "inj_onI";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   116
val [major] = Goal 
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   117
    "(!!x. x:A ==> g(f(x)) = x) ==> inj_on f A";
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   118
by (rtac inj_onI 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
by (etac (apply_inverse RS trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
by (REPEAT (eresolve_tac [asm_rl,major] 1));
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   121
qed "inj_on_inverseI";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   123
Goalw [inj_on_def] "[| inj_on f A;  f(x)=f(y);  x:A;  y:A |] ==> x=y";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   124
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   125
qed "inj_onD";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   127
Goal "[| inj_on f A;  x:A;  y:A |] ==> (f(x)=f(y)) = (x=y)";
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   128
by (blast_tac (claset() addSDs [inj_onD]) 1);
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   129
qed "inj_on_iff";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   131
Goalw [inj_on_def] "[| inj_on f A;  ~x=y;  x:A;  y:A |] ==> ~ f(x)=f(y)";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   132
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   133
qed "inj_on_contraD";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   135
Goalw [inj_on_def] "[| A<=B; inj_on f B |] ==> inj_on f A";
3341
89fe22bf9f54 New theorem subset_inj_onto
paulson
parents: 2935
diff changeset
   136
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   137
qed "subset_inj_on";
3341
89fe22bf9f54 New theorem subset_inj_onto
paulson
parents: 2935
diff changeset
   138
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
(*** Lemmas about inj ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   141
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   142
Goalw [o_def] "[| inj(f);  inj_on g (range f) |] ==> inj(g o f)";
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   143
by (fast_tac (claset() addIs [injI] addEs [injD, inj_onD]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
qed "comp_inj";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   146
Goal "inj(f) ==> inj_on f A";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   147
by (blast_tac (claset() addIs [injD, inj_onI]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
qed "inj_imp";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   149
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   150
Goalw [inv_def] "y : range(f) ==> f(inv f y) = y";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   151
by (fast_tac (claset() addIs [selectI]) 1);
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   152
qed "f_inv_f";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   154
Goal "[| inv f x=inv f y; x: range(f);  y: range(f) |] ==> x=y";
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   155
by (rtac (arg_cong RS box_equals) 1);
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   156
by (REPEAT (ares_tac [f_inv_f] 1));
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   157
qed "inv_injective";
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   158
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   159
Goal "[| inj(f);  A<=range(f) |] ==> inj_on (inv f) A";
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   160
by (fast_tac (claset() addIs [inj_onI] 
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   161
                      addEs [inv_injective,injD]) 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   162
qed "inj_on_inv";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   163
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   164
Goalw [inj_on_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   165
   "[| inj_on f C;  A<=C;  B<=C |] ==> f``(A Int B) = f``A Int f``B";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   166
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   167
qed "inj_on_image_Int";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   168
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   169
Goalw [inj_on_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   170
   "[| inj_on f C;  A<=C;  B<=C |] ==> f``(A-B) = f``A - f``B";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   171
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   172
qed "inj_on_image_set_diff";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   173
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   174
Goalw [inj_def] "inj f ==> f``(A Int B) = f``A Int f``B";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   175
by (Blast_tac 1);
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   176
qed "image_Int";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   177
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   178
Goalw [inj_def] "inj f ==> f``(A-B) = f``A - f``B";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   179
by (Blast_tac 1);
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   180
qed "image_set_diff";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   181
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
5847
17c869f24c5f proved surjI
paulson
parents: 5608
diff changeset
   183
17c869f24c5f proved surjI
paulson
parents: 5608
diff changeset
   184
val [major] = Goalw [surj_def] "(!! x. g(f x) = x) ==> surj g";
17c869f24c5f proved surjI
paulson
parents: 5608
diff changeset
   185
by (blast_tac (claset() addIs [major RS sym]) 1);
17c869f24c5f proved surjI
paulson
parents: 5608
diff changeset
   186
qed "surjI";
17c869f24c5f proved surjI
paulson
parents: 5608
diff changeset
   187
17c869f24c5f proved surjI
paulson
parents: 5608
diff changeset
   188
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   189
val set_cs = claset() delrules [equalityI];
5305
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   190
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   191
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   192
section "fun_upd";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   193
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   194
Goalw [fun_upd_def] "(f(x:=y) = f) = (f x = y)";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   195
by Safe_tac;
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   196
by (etac subst 1);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   197
by (rtac ext 2);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   198
by Auto_tac;
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   199
qed "fun_upd_idem_iff";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   200
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   201
(* f x = y ==> f(x:=y) = f *)
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   202
bind_thm("fun_upd_idem", fun_upd_idem_iff RS iffD2);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   203
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   204
(* f(x := f x) = f *)
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   205
AddIffs [refl RS fun_upd_idem];
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   206
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   207
Goal "(f(x:=y))z = (if z=x then y else f z)";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   208
by (simp_tac (simpset() addsimps [fun_upd_def]) 1);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   209
qed "fun_upd_apply";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   210
Addsimps [fun_upd_apply];
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   211
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   212
qed_goal "fun_upd_same" thy "(f(x:=y)) x = y" 
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   213
	(K [Simp_tac 1]);
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
   214
qed_goal "fun_upd_other" thy "!!X. z~=x ==> (f(x:=y)) z = f z"
5305
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   215
	(K [Asm_simp_tac 1]);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   216
(*Addsimps [fun_upd_same, fun_upd_other];*)
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   217
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   218
Goal "a ~= c ==> m(a:=b)(c:=d) = m(c:=d)(a:=b)";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   219
by (rtac ext 1);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   220
by (Auto_tac);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   221
qed "fun_upd_twist";