src/HOL/Fun.ML
author paulson
Mon May 26 12:37:24 1997 +0200 (1997-05-26)
changeset 3341 89fe22bf9f54
parent 2935 998cb95fdd43
child 3842 b55686a7b22c
permissions -rw-r--r--
New theorem subset_inj_onto
clasohm@1465
     1
(*  Title:      HOL/Fun
clasohm@923
     2
    ID:         $Id$
clasohm@1465
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1993  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Lemmas about functions.
clasohm@923
     7
*)
clasohm@923
     8
clasohm@923
     9
goal Fun.thy "(f = g) = (!x. f(x)=g(x))";
clasohm@923
    10
by (rtac iffI 1);
clasohm@1264
    11
by (Asm_simp_tac 1);
clasohm@1264
    12
by (rtac ext 1 THEN Asm_simp_tac 1);
clasohm@923
    13
qed "expand_fun_eq";
clasohm@923
    14
clasohm@923
    15
val prems = goal Fun.thy
clasohm@923
    16
    "[| f(x)=u;  !!x. P(x) ==> g(f(x)) = x;  P(x) |] ==> x=g(u)";
clasohm@923
    17
by (rtac (arg_cong RS box_equals) 1);
clasohm@923
    18
by (REPEAT (resolve_tac (prems@[refl]) 1));
clasohm@923
    19
qed "apply_inverse";
clasohm@923
    20
clasohm@923
    21
clasohm@923
    22
(*** inj(f): f is a one-to-one function ***)
clasohm@923
    23
clasohm@923
    24
val prems = goalw Fun.thy [inj_def]
clasohm@923
    25
    "[| !! x y. f(x) = f(y) ==> x=y |] ==> inj(f)";
paulson@2935
    26
by (blast_tac (!claset addIs prems) 1);
clasohm@923
    27
qed "injI";
clasohm@923
    28
clasohm@923
    29
val [major] = goal Fun.thy "(!!x. g(f(x)) = x) ==> inj(f)";
clasohm@923
    30
by (rtac injI 1);
clasohm@923
    31
by (etac (arg_cong RS box_equals) 1);
clasohm@923
    32
by (rtac major 1);
clasohm@923
    33
by (rtac major 1);
clasohm@923
    34
qed "inj_inverseI";
clasohm@923
    35
clasohm@923
    36
val [major,minor] = goalw Fun.thy [inj_def]
clasohm@923
    37
    "[| inj(f); f(x) = f(y) |] ==> x=y";
clasohm@923
    38
by (rtac (major RS spec RS spec RS mp) 1);
clasohm@923
    39
by (rtac minor 1);
clasohm@923
    40
qed "injD";
clasohm@923
    41
clasohm@923
    42
(*Useful with the simplifier*)
clasohm@923
    43
val [major] = goal Fun.thy "inj(f) ==> (f(x) = f(y)) = (x=y)";
clasohm@923
    44
by (rtac iffI 1);
clasohm@923
    45
by (etac (major RS injD) 1);
clasohm@923
    46
by (etac arg_cong 1);
clasohm@923
    47
qed "inj_eq";
clasohm@923
    48
clasohm@923
    49
val [major] = goal Fun.thy "inj(f) ==> (@x.f(x)=f(y)) = y";
clasohm@923
    50
by (rtac (major RS injD) 1);
clasohm@923
    51
by (rtac selectI 1);
clasohm@923
    52
by (rtac refl 1);
clasohm@923
    53
qed "inj_select";
clasohm@923
    54
clasohm@923
    55
(*A one-to-one function has an inverse (given using select).*)
nipkow@2912
    56
val [major] = goalw Fun.thy [inv_def] "inj(f) ==> inv f (f x) = x";
clasohm@923
    57
by (EVERY1 [rtac (major RS inj_select)]);
nipkow@2912
    58
qed "inv_f_f";
clasohm@923
    59
clasohm@923
    60
(* Useful??? *)
clasohm@923
    61
val [oneone,minor] = goal Fun.thy
nipkow@2912
    62
    "[| inj(f); !!y. y: range(f) ==> P(inv f y) |] ==> P(x)";
nipkow@2912
    63
by (res_inst_tac [("t", "x")] (oneone RS (inv_f_f RS subst)) 1);
clasohm@923
    64
by (rtac (rangeI RS minor) 1);
clasohm@923
    65
qed "inj_transfer";
clasohm@923
    66
clasohm@923
    67
clasohm@923
    68
(*** inj_onto f A: f is one-to-one over A ***)
clasohm@923
    69
clasohm@923
    70
val prems = goalw Fun.thy [inj_onto_def]
clasohm@923
    71
    "(!! x y. [| f(x) = f(y);  x:A;  y:A |] ==> x=y) ==> inj_onto f A";
paulson@2935
    72
by (blast_tac (!claset addIs prems) 1);
clasohm@923
    73
qed "inj_ontoI";
clasohm@923
    74
clasohm@923
    75
val [major] = goal Fun.thy 
clasohm@923
    76
    "(!!x. x:A ==> g(f(x)) = x) ==> inj_onto f A";
clasohm@923
    77
by (rtac inj_ontoI 1);
clasohm@923
    78
by (etac (apply_inverse RS trans) 1);
clasohm@923
    79
by (REPEAT (eresolve_tac [asm_rl,major] 1));
clasohm@923
    80
qed "inj_onto_inverseI";
clasohm@923
    81
clasohm@923
    82
val major::prems = goalw Fun.thy [inj_onto_def]
clasohm@923
    83
    "[| inj_onto f A;  f(x)=f(y);  x:A;  y:A |] ==> x=y";
clasohm@923
    84
by (rtac (major RS bspec RS bspec RS mp) 1);
clasohm@923
    85
by (REPEAT (resolve_tac prems 1));
clasohm@923
    86
qed "inj_ontoD";
clasohm@923
    87
clasohm@923
    88
goal Fun.thy "!!x y.[| inj_onto f A;  x:A;  y:A |] ==> (f(x)=f(y)) = (x=y)";
paulson@2935
    89
by (blast_tac (!claset addSDs [inj_ontoD]) 1);
clasohm@923
    90
qed "inj_onto_iff";
clasohm@923
    91
clasohm@923
    92
val major::prems = goal Fun.thy
clasohm@923
    93
    "[| inj_onto f A;  ~x=y;  x:A;  y:A |] ==> ~ f(x)=f(y)";
clasohm@923
    94
by (rtac contrapos 1);
clasohm@923
    95
by (etac (major RS inj_ontoD) 2);
clasohm@923
    96
by (REPEAT (resolve_tac prems 1));
clasohm@923
    97
qed "inj_onto_contraD";
clasohm@923
    98
paulson@3341
    99
goalw Fun.thy [inj_onto_def]
paulson@3341
   100
    "!!A B. [| A<=B; inj_onto f B |] ==> inj_onto f A";
paulson@3341
   101
by (Blast_tac 1);
paulson@3341
   102
qed "subset_inj_onto";
paulson@3341
   103
clasohm@923
   104
clasohm@923
   105
(*** Lemmas about inj ***)
clasohm@923
   106
paulson@2922
   107
goalw Fun.thy [o_def]
paulson@2922
   108
    "!!f g. [| inj(f);  inj_onto g (range f) |] ==> inj(g o f)";
paulson@2922
   109
by (fast_tac (!claset addIs [injI] addEs [injD, inj_ontoD]) 1);
clasohm@923
   110
qed "comp_inj";
clasohm@923
   111
clasohm@923
   112
val [prem] = goal Fun.thy "inj(f) ==> inj_onto f A";
paulson@2935
   113
by (blast_tac (!claset addIs [prem RS injD, inj_ontoI]) 1);
clasohm@923
   114
qed "inj_imp";
clasohm@923
   115
nipkow@2912
   116
val [prem] = goalw Fun.thy [inv_def] "y : range(f) ==> f(inv f y) = y";
clasohm@923
   117
by (EVERY1 [rtac (prem RS rangeE), rtac selectI, etac sym]);
nipkow@2912
   118
qed "f_inv_f";
clasohm@923
   119
clasohm@923
   120
val prems = goal Fun.thy
nipkow@2912
   121
    "[| inv f x=inv f y; x: range(f);  y: range(f) |] ==> x=y";
nipkow@2912
   122
by (rtac (arg_cong RS box_equals) 1);
nipkow@2912
   123
by (REPEAT (resolve_tac (prems @ [f_inv_f]) 1));
nipkow@2912
   124
qed "inv_injective";
nipkow@2912
   125
paulson@2935
   126
goal Fun.thy "!!f. [| inj(f);  A<=range(f) |] ==> inj_onto (inv f) A";
berghofe@1754
   127
by (fast_tac (!claset addIs [inj_ontoI] 
nipkow@2912
   128
                      addEs [inv_injective,injD]) 1);
nipkow@2912
   129
qed "inj_onto_inv";
clasohm@923
   130
clasohm@923
   131
paulson@1837
   132
val set_cs = !claset delrules [equalityI];