src/HOL/Fun.ML
author wenzelm
Thu, 01 Jul 1999 21:19:45 +0200
changeset 6874 747f656e04ec
parent 6829 50459a995aa3
child 7014 11ee650edcd2
permissions -rw-r--r--
renamed with/APP to of/OF;
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
5852
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
    61
Goalw [o_def] "UNION A (g o f) = UNION (f``A) g";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
    62
by (Blast_tac 1);
6829
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
    63
qed "UN_o";
5852
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
    64
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    65
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    66
section "inj";
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
    67
(**NB: inj now just translates to inj_on**)
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
    68
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
(*** inj(f): f is a one-to-one function ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
    71
(*for Tools/datatype_rep_proofs*)
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
    72
val [prem] = Goalw [inj_on_def]
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
    73
    "(!! x. ALL y. f(x) = f(y) --> x=y) ==> inj(f)";
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
    74
by (blast_tac (claset() addIs [prem RS spec RS mp]) 1);
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
    75
qed "datatype_injI";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
    77
Goalw [inj_on_def] "[| inj(f); f(x) = f(y) |] ==> x=y";
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    78
by (Blast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
qed "injD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
(*Useful with the simplifier*)
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    82
Goal "inj(f) ==> (f(x) = f(y)) = (x=y)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
by (rtac iffI 1);
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    84
by (etac arg_cong 2);
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    85
by (etac injD 1);
5318
72bf8039b53f expandshort
paulson
parents: 5316
diff changeset
    86
by (assume_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
qed "inj_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    89
Goal "inj(f) ==> (@x. f(x)=f(y)) = y";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    90
by (etac injD 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
by (rtac selectI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
by (rtac refl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
qed "inj_select";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
(*A one-to-one function has an inverse (given using select).*)
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    96
Goalw [inv_def] "inj(f) ==> inv f (f x) = x";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
    97
by (etac inj_select 1);
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
    98
qed "inv_f_f";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   100
Addsimps [inv_f_f];
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   101
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
(* Useful??? *)
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   103
val [oneone,minor] = Goal
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   104
    "[| 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
   105
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
   106
by (rtac (rangeI RS minor) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
qed "inj_transfer";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   110
(*** 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
   111
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   112
val prems = Goalw [inj_on_def]
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   113
    "(!! 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
   114
by (blast_tac (claset() addIs prems) 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   115
qed "inj_onI";
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   116
val injI = inj_onI;                  (*for compatibility*)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   118
val [major] = Goal 
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   119
    "(!!x. x:A ==> g(f(x)) = x) ==> inj_on f A";
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   120
by (rtac inj_onI 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
by (etac (apply_inverse RS trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
by (REPEAT (eresolve_tac [asm_rl,major] 1));
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   123
qed "inj_on_inverseI";
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   124
val inj_inverseI = inj_on_inverseI;   (*for compatibility*)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   126
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
   127
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   128
qed "inj_onD";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   130
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
   131
by (blast_tac (claset() addSDs [inj_onD]) 1);
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   132
qed "inj_on_iff";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   134
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
   135
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   136
qed "inj_on_contraD";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   138
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
   139
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   140
qed "subset_inj_on";
3341
89fe22bf9f54 New theorem subset_inj_onto
paulson
parents: 2935
diff changeset
   141
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   143
(** surj **)
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   144
6267
a3098667b9b6 new lemma surjD
paulson
parents: 6235
diff changeset
   145
val [prem] = Goalw [surj_def] "(!! x. g(f x) = x) ==> surj g";
a3098667b9b6 new lemma surjD
paulson
parents: 6235
diff changeset
   146
by (blast_tac (claset() addIs [prem RS sym]) 1);
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   147
qed "surjI";
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   148
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   149
Goalw [surj_def] "surj f ==> range f = UNIV";
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   150
by Auto_tac;
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   151
qed "surj_range";
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   152
6267
a3098667b9b6 new lemma surjD
paulson
parents: 6235
diff changeset
   153
Goalw [surj_def] "surj f ==> EX x. y = f x";
a3098667b9b6 new lemma surjD
paulson
parents: 6235
diff changeset
   154
by (Blast_tac 1);
a3098667b9b6 new lemma surjD
paulson
parents: 6235
diff changeset
   155
qed "surjD";
a3098667b9b6 new lemma surjD
paulson
parents: 6235
diff changeset
   156
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   157
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   158
(*** Lemmas about injective functions and inv ***)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   159
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   160
Goalw [o_def] "[| inj_on f A;  inj_on g (range f) |] ==> inj_on (g o f) A";
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   161
by (fast_tac (claset() addIs [inj_onI] addEs [inj_onD]) 1);
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   162
qed "comp_inj_on";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   163
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   164
Goalw [inv_def] "y : range(f) ==> f(inv f y) = y";
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   165
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
   166
qed "f_inv_f";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   167
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   168
Goal "surj f ==> f(inv f y) = y";
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   169
by (asm_simp_tac (simpset() addsimps [f_inv_f, surj_range]) 1);
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   170
qed "surj_f_inv_f";
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   171
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   172
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
   173
by (rtac (arg_cong RS box_equals) 1);
5316
7a8975451a89 even more tidying of Goal commands
paulson
parents: 5306
diff changeset
   174
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
   175
qed "inv_injective";
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   176
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   177
Goal "A <= range(f) ==> inj_on (inv f) A";
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   178
by (fast_tac (claset() addIs [inj_onI] 
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   179
                       addEs [inv_injective, injD]) 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   180
qed "inj_on_inv";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   182
Goal "surj f ==> inj (inv f)";
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   183
by (asm_simp_tac (simpset() addsimps [inj_on_inv, surj_range]) 1);
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   184
qed "surj_imp_inj_inv";
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   185
6290
31483ca40e91 new image laws
paulson
parents: 6267
diff changeset
   186
Goal "f``(A Int B) <= f``A Int f``B";
31483ca40e91 new image laws
paulson
parents: 6267
diff changeset
   187
by (Blast_tac 1);
31483ca40e91 new image laws
paulson
parents: 6267
diff changeset
   188
qed "image_Int_subset";
31483ca40e91 new image laws
paulson
parents: 6267
diff changeset
   189
31483ca40e91 new image laws
paulson
parents: 6267
diff changeset
   190
Goal "f``A - f``B <= f``(A - B)";
31483ca40e91 new image laws
paulson
parents: 6267
diff changeset
   191
by (Blast_tac 1);
31483ca40e91 new image laws
paulson
parents: 6267
diff changeset
   192
qed "image_diff_subset";
31483ca40e91 new image laws
paulson
parents: 6267
diff changeset
   193
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   194
Goalw [inj_on_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   195
   "[| 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
   196
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   197
qed "inj_on_image_Int";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   198
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   199
Goalw [inj_on_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
   200
   "[| 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
   201
by (Blast_tac 1);
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4656
diff changeset
   202
qed "inj_on_image_set_diff";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   203
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   204
Goalw [inj_on_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
   205
by (Blast_tac 1);
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   206
qed "image_Int";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   207
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 5865
diff changeset
   208
Goalw [inj_on_def] "inj f ==> f``(A-B) = f``A - f``B";
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   209
by (Blast_tac 1);
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   210
qed "image_set_diff";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   211
6235
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   212
Goalw [image_def] "inj(f) ==> inv(f)``(f``X) = X";
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   213
by Auto_tac;
c8a69ecafb99 new surj rules
paulson
parents: 6171
diff changeset
   214
qed "inv_image_comp";
5847
17c869f24c5f proved surjI
paulson
parents: 5608
diff changeset
   215
6301
08245f5a436d expandshort
paulson
parents: 6290
diff changeset
   216
Goal "inj f ==> (f a : f``A) = (a : A)";
08245f5a436d expandshort
paulson
parents: 6290
diff changeset
   217
by (blast_tac (claset() addDs [injD]) 1);
08245f5a436d expandshort
paulson
parents: 6290
diff changeset
   218
qed "inj_image_mem_iff";
08245f5a436d expandshort
paulson
parents: 6290
diff changeset
   219
08245f5a436d expandshort
paulson
parents: 6290
diff changeset
   220
Goal "inj f ==> (f``A = f``B) = (A = B)";
08245f5a436d expandshort
paulson
parents: 6290
diff changeset
   221
by (blast_tac (claset() addSEs [equalityE] addDs [injD]) 1);
08245f5a436d expandshort
paulson
parents: 6290
diff changeset
   222
qed "inj_image_eq_iff";
08245f5a436d expandshort
paulson
parents: 6290
diff changeset
   223
6829
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   224
Goal  "(f `` (UNION A B)) = (UN x:A.(f `` (B x)))";
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   225
by (Blast_tac 1);
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   226
qed "image_UN";
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   227
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   228
(*injectivity's required.  Left-to-right inclusion holds even if A is empty*)
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   229
Goalw [inj_on_def]
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   230
   "[| inj_on f C;  ALL x:A. B x <= C;  j:A |] \
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   231
\   ==> f `` (INTER A B) = (INT x:A. f `` B x)";
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   232
by (Blast_tac 1);
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   233
qed "image_INT";
50459a995aa3 renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents: 6301
diff changeset
   234
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   235
val set_cs = claset() delrules [equalityI];
5305
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   236
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   237
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   238
section "fun_upd";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   239
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   240
Goalw [fun_upd_def] "(f(x:=y) = f) = (f x = y)";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   241
by Safe_tac;
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   242
by (etac subst 1);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   243
by (rtac ext 2);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   244
by Auto_tac;
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   245
qed "fun_upd_idem_iff";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   246
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   247
(* f x = y ==> f(x:=y) = f *)
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   248
bind_thm("fun_upd_idem", fun_upd_idem_iff RS iffD2);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   249
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   250
(* f(x := f x) = f *)
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   251
AddIffs [refl RS fun_upd_idem];
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   252
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   253
Goal "(f(x:=y))z = (if z=x then y else f z)";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   254
by (simp_tac (simpset() addsimps [fun_upd_def]) 1);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   255
qed "fun_upd_apply";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   256
Addsimps [fun_upd_apply];
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   257
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   258
qed_goal "fun_upd_same" thy "(f(x:=y)) x = y" 
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   259
	(K [Simp_tac 1]);
5306
3d1368a3a2a2 added theorems Id_o, o_Id
oheimb
parents: 5305
diff changeset
   260
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
   261
	(K [Asm_simp_tac 1]);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   262
(*Addsimps [fun_upd_same, fun_upd_other];*)
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   263
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   264
Goal "a ~= c ==> m(a:=b)(c:=d) = m(c:=d)(a:=b)";
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   265
by (rtac ext 1);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   266
by (Auto_tac);
513925de8962 cleanup for Fun.thy:
oheimb
parents: 5148
diff changeset
   267
qed "fun_upd_twist";
5852
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   268
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   269
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   270
(*** -> and Pi, by Florian Kammueller and LCP ***)
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   271
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   272
val prems = Goalw [Pi_def]
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   273
"[| !!x. x: A ==> f x: B x; !!x. x ~: A  ==> f(x) = (@ y. True)|] \
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   274
\    ==> f: Pi A B";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   275
by (auto_tac (claset(), simpset() addsimps prems));
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   276
qed "Pi_I";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   277
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   278
val prems = Goal 
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   279
"[| !!x. x: A ==> f x: B; !!x. x ~: A  ==> f(x) = (@ y. True)|] ==> f: A funcset B";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   280
by (blast_tac (claset() addIs Pi_I::prems) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   281
qed "funcsetI";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   282
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   283
Goalw [Pi_def] "[|f: Pi A B; x: A|] ==> f x: B x";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   284
by Auto_tac;
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   285
qed "Pi_mem";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   286
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   287
Goalw [Pi_def] "[|f: A funcset B; x: A|] ==> f x: B";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   288
by Auto_tac;
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   289
qed "funcset_mem";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   290
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   291
Goalw [Pi_def] "[|f: Pi A B; x~: A|] ==> f x = (@ y. True)";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   292
by Auto_tac;
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   293
qed "apply_arb";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   294
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   295
Goalw [Pi_def] "[| f: Pi A B; g: Pi A B; ! x: A. f x = g x |] ==> f = g";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   296
by (rtac ext 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   297
by Auto_tac;
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   298
val Pi_extensionality = ballI RSN (3, result());
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   299
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   300
(*** compose ***)
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   301
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   302
Goalw [Pi_def, compose_def, restrict_def]
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   303
     "[| f: A funcset B; g: B funcset C |]==> compose A g f: A funcset C";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   304
by Auto_tac;
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   305
qed "funcset_compose";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   306
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   307
Goal "[| f: A funcset B; g: B funcset C; h: C funcset D |]\
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   308
\     ==> compose A h (compose A g f) = compose A (compose B h g) f";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   309
by (res_inst_tac [("A","A")] Pi_extensionality 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   310
by (blast_tac (claset() addIs [funcset_compose]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   311
by (blast_tac (claset() addIs [funcset_compose]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   312
by (rewrite_goals_tac [Pi_def, compose_def, restrict_def]);  
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   313
by Auto_tac;
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   314
qed "compose_assoc";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   315
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   316
Goal "[| f: A funcset B; g: B funcset C; x: A |]==> compose A g f x = g(f(x))";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   317
by (asm_full_simp_tac (simpset() addsimps [compose_def, restrict_def]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   318
qed "compose_eq";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   319
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   320
Goal "[| f : A funcset B; f `` A = B; g: B funcset C; g `` B = C |]\
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   321
\     ==> compose A g f `` A = C";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   322
by (auto_tac (claset(),
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   323
	      simpset() addsimps [image_def, compose_eq]));
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   324
qed "surj_compose";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   325
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   326
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   327
Goal "[| f : A funcset B; g: B funcset C; f `` A = B; inj_on f A; inj_on g B |]\
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   328
\     ==> inj_on (compose A g f) A";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   329
by (auto_tac (claset(),
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   330
	      simpset() addsimps [inj_on_def, compose_eq]));
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   331
qed "inj_on_compose";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   332
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   333
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   334
(*** restrict / lam ***)
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   335
Goal "[| f `` A <= B |] ==> (lam x: A. f x) : A funcset B";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   336
by (auto_tac (claset(),
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   337
	      simpset() addsimps [restrict_def, Pi_def]));
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   338
qed "restrict_in_funcset";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   339
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   340
val prems = Goalw [restrict_def, Pi_def]
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   341
     "(!!x. x: A ==> f x: B x) ==> (lam x: A. f x) : Pi A B";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   342
by (asm_simp_tac (simpset() addsimps prems) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   343
qed "restrictI";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   344
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   345
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   346
Goal "x: A ==> (lam y: A. f y) x = f x";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   347
by (asm_simp_tac (simpset() addsimps [restrict_def]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   348
qed "restrict_apply1";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   349
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   350
Goal "[| x: A; f : A funcset B |] ==> (lam y: A. f y) x : B";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   351
by (asm_full_simp_tac (simpset() addsimps [restrict_apply1,Pi_def]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   352
qed "restrict_apply1_mem";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   353
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   354
Goal "x ~: A ==> (lam y: A. f y) x =  (@ y. True)";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   355
by (asm_simp_tac (simpset() addsimps [restrict_def]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   356
qed "restrict_apply2";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   357
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   358
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   359
val prems = Goal
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   360
    "(!!x. x: A ==> f x = g x) ==> (lam x: A. f x) = (lam x: A. g x)";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   361
by (rtac ext 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   362
by (auto_tac (claset(),
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   363
	      simpset() addsimps prems@[restrict_def, Pi_def]));
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   364
qed "restrict_ext";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   365
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   366
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   367
(*** Inverse ***)
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   368
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   369
Goal "[|f `` A = B;  x: B |] ==> ? y: A. f y = x";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   370
by (Blast_tac 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   371
qed "surj_image";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   372
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   373
Goalw [Inv_def] "[| f `` A = B; f : A funcset B |] \
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   374
\                ==> (lam x: B. (Inv A f) x) : B funcset A";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   375
by (fast_tac (claset() addIs [restrict_in_funcset, selectI2]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   376
qed "Inv_funcset";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   377
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   378
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   379
Goal "[| f: A funcset B;  inj_on f A;  f `` A = B;  x: A |] \
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   380
\     ==> (lam y: B. (Inv A f) y) (f x) = x";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   381
by (asm_simp_tac (simpset() addsimps [restrict_apply1, funcset_mem]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   382
by (asm_full_simp_tac (simpset() addsimps [Inv_def, inj_on_def]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   383
by (rtac selectI2 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   384
by Auto_tac;
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   385
qed "Inv_f_f";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   386
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   387
Goal "[| f: A funcset B;  f `` A = B;  x: B |] \
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   388
\     ==> f ((lam y: B. (Inv A f y)) x) = x";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   389
by (asm_simp_tac (simpset() addsimps [Inv_def, restrict_apply1]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   390
by (fast_tac (claset() addIs [selectI2]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   391
qed "f_Inv_f";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   392
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   393
Goal "[| f: A funcset B;  inj_on f A;  f `` A = B |]\
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   394
\     ==> compose A (lam y:B. (Inv A f) y) f = (lam x: A. x)";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   395
by (rtac Pi_extensionality 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   396
by (blast_tac (claset() addIs [funcset_compose, Inv_funcset]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   397
by (blast_tac (claset() addIs [restrict_in_funcset]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   398
by (asm_simp_tac
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   399
    (simpset() addsimps [restrict_apply1, compose_def, Inv_f_f]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   400
qed "compose_Inv_id";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   401
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   402
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   403
(*** Pi and Applyall ***)
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   404
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   405
Goalw [Pi_def] "[| B(x) = {};  x: A |] ==> (PI x: A. B x) = {}";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   406
by Auto_tac;
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   407
qed "Pi_eq_empty";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   408
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   409
Goal "[| (PI x: A. B x) ~= {};  x: A |] ==> B(x) ~= {}";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   410
by (blast_tac (HOL_cs addIs [Pi_eq_empty]) 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   411
qed "Pi_total1";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   412
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   413
Goal "[| a : A; Pi A B ~= {} |] ==> Applyall (Pi A B) a = B a";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   414
by (auto_tac (claset(), simpset() addsimps [Applyall_def, Pi_def]));
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   415
by (rename_tac "g z" 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   416
by (res_inst_tac [("x","%y. if  (y = a) then z else g y")] exI 1);
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   417
by (auto_tac (claset(), simpset() addsimps [split_if_mem1, split_if_eq1]));
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   418
qed "Applyall_beta";
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   419
5865
2303f5a3036d moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents: 5852
diff changeset
   420
Goal "Pi {} B = { (%x. @ y. True) }";
2303f5a3036d moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents: 5852
diff changeset
   421
by (auto_tac (claset() addIs [ext], simpset() addsimps [Pi_def]));
2303f5a3036d moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents: 5852
diff changeset
   422
qed "Pi_empty";
5852
4d7320490be4 the function space operator
paulson
parents: 5847
diff changeset
   423
5865
2303f5a3036d moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents: 5852
diff changeset
   424
val [major] = Goalw [Pi_def] "(!!x. x: A ==> B x <= C x) ==> Pi A B <= Pi A C";
2303f5a3036d moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents: 5852
diff changeset
   425
by (auto_tac (claset(),
2303f5a3036d moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents: 5852
diff changeset
   426
	      simpset() addsimps [impOfSubs major]));
2303f5a3036d moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents: 5852
diff changeset
   427
qed "Pi_mono";