src/HOL/Fun.ML
author oheimb
Wed, 12 Nov 1997 12:34:43 +0100
changeset 4206 688050e83d89
parent 4089 96fba19bcbe2
child 4656 134d24ddaad3
permissions -rw-r--r--
restored last version
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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
goal Fun.thy "(f = g) = (!x. f(x)=g(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
by (rtac iffI 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 923
diff changeset
    11
by (Asm_simp_tac 1);
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 923
diff changeset
    12
by (rtac ext 1 THEN Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
qed "expand_fun_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
val prems = goal Fun.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
    "[| 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
    17
by (rtac (arg_cong RS box_equals) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
by (REPEAT (resolve_tac (prems@[refl]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
qed "apply_inverse";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
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
(*** inj(f): f is a one-to-one function ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
val prems = goalw Fun.thy [inj_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
    "[| !! x y. f(x) = f(y) ==> x=y |] ==> inj(f)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    26
by (blast_tac (claset() addIs prems) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
qed "injI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
val [major] = goal Fun.thy "(!!x. g(f(x)) = x) ==> inj(f)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
by (rtac injI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
by (etac (arg_cong RS box_equals) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
by (rtac major 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
by (rtac major 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
qed "inj_inverseI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
val [major,minor] = goalw Fun.thy [inj_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
    "[| inj(f); f(x) = f(y) |] ==> x=y";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
by (rtac (major RS spec RS spec RS mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
by (rtac minor 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
qed "injD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
(*Useful with the simplifier*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
val [major] = goal Fun.thy "inj(f) ==> (f(x) = f(y)) = (x=y)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
by (rtac iffI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
by (etac (major RS injD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
by (etac arg_cong 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
qed "inj_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
3842
b55686a7b22c fixed dots;
wenzelm
parents: 3341
diff changeset
    49
val [major] = goal Fun.thy "inj(f) ==> (@x. f(x)=f(y)) = y";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
by (rtac (major RS injD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
by (rtac selectI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
by (rtac refl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
qed "inj_select";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
(*A one-to-one function has an inverse (given using select).*)
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
    56
val [major] = goalw Fun.thy [inv_def] "inj(f) ==> inv f (f x) = x";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
by (EVERY1 [rtac (major RS inj_select)]);
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
    58
qed "inv_f_f";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
(* Useful??? *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
val [oneone,minor] = goal Fun.thy
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
    62
    "[| 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
    63
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
    64
by (rtac (rangeI RS minor) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
qed "inj_transfer";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
(*** inj_onto f A: f is one-to-one over A ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
val prems = goalw Fun.thy [inj_onto_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
    "(!! x y. [| f(x) = f(y);  x:A;  y:A |] ==> x=y) ==> inj_onto f A";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    72
by (blast_tac (claset() addIs prems) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
qed "inj_ontoI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
val [major] = goal Fun.thy 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
    "(!!x. x:A ==> g(f(x)) = x) ==> inj_onto f A";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
by (rtac inj_ontoI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
by (etac (apply_inverse RS trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
by (REPEAT (eresolve_tac [asm_rl,major] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
qed "inj_onto_inverseI";
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
val major::prems = goalw Fun.thy [inj_onto_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
    "[| inj_onto f A;  f(x)=f(y);  x:A;  y:A |] ==> x=y";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
by (rtac (major RS bspec RS bspec RS mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
by (REPEAT (resolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
qed "inj_ontoD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
goal Fun.thy "!!x y.[| inj_onto f A;  x:A;  y:A |] ==> (f(x)=f(y)) = (x=y)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
    89
by (blast_tac (claset() addSDs [inj_ontoD]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
qed "inj_onto_iff";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
val major::prems = goal Fun.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
    "[| inj_onto f A;  ~x=y;  x:A;  y:A |] ==> ~ f(x)=f(y)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
by (rtac contrapos 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
by (etac (major RS inj_ontoD) 2);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
by (REPEAT (resolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
qed "inj_onto_contraD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
3341
89fe22bf9f54 New theorem subset_inj_onto
paulson
parents: 2935
diff changeset
    99
goalw Fun.thy [inj_onto_def]
89fe22bf9f54 New theorem subset_inj_onto
paulson
parents: 2935
diff changeset
   100
    "!!A B. [| A<=B; inj_onto f B |] ==> inj_onto f A";
89fe22bf9f54 New theorem subset_inj_onto
paulson
parents: 2935
diff changeset
   101
by (Blast_tac 1);
89fe22bf9f54 New theorem subset_inj_onto
paulson
parents: 2935
diff changeset
   102
qed "subset_inj_onto";
89fe22bf9f54 New theorem subset_inj_onto
paulson
parents: 2935
diff changeset
   103
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
(*** Lemmas about inj ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
2922
580647a879cf Using Blast_tac
paulson
parents: 2912
diff changeset
   107
goalw Fun.thy [o_def]
580647a879cf Using Blast_tac
paulson
parents: 2912
diff changeset
   108
    "!!f g. [| inj(f);  inj_onto g (range f) |] ==> inj(g o f)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   109
by (fast_tac (claset() addIs [injI] addEs [injD, inj_ontoD]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
qed "comp_inj";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
val [prem] = goal Fun.thy "inj(f) ==> inj_onto f A";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   113
by (blast_tac (claset() addIs [prem RS injD, inj_ontoI]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
qed "inj_imp";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   116
val [prem] = goalw Fun.thy [inv_def] "y : range(f) ==> f(inv f y) = y";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
by (EVERY1 [rtac (prem RS rangeE), rtac selectI, etac sym]);
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   118
qed "f_inv_f";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
val prems = goal Fun.thy
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   121
    "[| inv f x=inv f y; x: range(f);  y: range(f) |] ==> x=y";
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   122
by (rtac (arg_cong RS box_equals) 1);
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   123
by (REPEAT (resolve_tac (prems @ [f_inv_f]) 1));
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   124
qed "inv_injective";
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   125
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2922
diff changeset
   126
goal Fun.thy "!!f. [| inj(f);  A<=range(f) |] ==> inj_onto (inv f) A";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   127
by (fast_tac (claset() addIs [inj_ontoI] 
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   128
                      addEs [inv_injective,injD]) 1);
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   129
qed "inj_onto_inv";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
4059
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   131
goalw thy [inj_onto_def]
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   132
   "!!f. [| inj_onto f C;  A<=C;  B<=C |] ==> f``(A Int B) = f``A Int f``B";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   133
by (Blast_tac 1);
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   134
qed "inj_onto_image_Int";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   135
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   136
goalw thy [inj_onto_def]
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   137
   "!!f. [| inj_onto f C;  A<=C;  B<=C |] ==> f``(A-B) = f``A - f``B";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   138
by (Blast_tac 1);
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   139
qed "inj_onto_image_set_diff";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   140
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   141
goalw thy [inj_def] "!!f. inj f ==> f``(A Int B) = f``A Int f``B";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   142
by (Blast_tac 1);
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   143
qed "image_Int";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   144
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   145
goalw thy [inj_def] "!!f. inj f ==> f``(A-B) = f``A - f``B";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   146
by (Blast_tac 1);
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   147
qed "image_set_diff";
59c1422c9da5 New Blast_tac (and minor tidying...)
paulson
parents: 3842
diff changeset
   148
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   149
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4059
diff changeset
   150
val set_cs = claset() delrules [equalityI];