src/HOL/Fun.ML
author paulson
Fri, 11 Apr 1997 15:21:36 +0200
changeset 2935 998cb95fdd43
parent 2922 580647a879cf
child 3341 89fe22bf9f54
permissions -rw-r--r--
Yet more fast_tac->blast_tac, and other tidying
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)";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2922
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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
val [major] = goal Fun.thy "inj(f) ==> (@x.f(x)=f(y)) = y";
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";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2922
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)";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2922
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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
(*** Lemmas about inj ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
2922
580647a879cf Using Blast_tac
paulson
parents: 2912
diff changeset
   102
goalw Fun.thy [o_def]
580647a879cf Using Blast_tac
paulson
parents: 2912
diff changeset
   103
    "!!f g. [| inj(f);  inj_onto g (range f) |] ==> inj(g o f)";
580647a879cf Using Blast_tac
paulson
parents: 2912
diff changeset
   104
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
   105
qed "comp_inj";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
val [prem] = goal Fun.thy "inj(f) ==> inj_onto f A";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2922
diff changeset
   108
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
   109
qed "inj_imp";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   111
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
   112
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
   113
qed "f_inv_f";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
val prems = goal Fun.thy
2912
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   116
    "[| 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
   117
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
   118
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
   119
qed "inv_injective";
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   120
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2922
diff changeset
   121
goal Fun.thy "!!f. [| inj(f);  A<=range(f) |] ==> inj_onto (inv f) A";
1754
852093aeb0ab Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1672
diff changeset
   122
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
   123
                      addEs [inv_injective,injD]) 1);
3fac3e8d5d3e moved inj and surj from Set to Fun and Inv -> inv.
nipkow
parents: 2890
diff changeset
   124
qed "inj_onto_inv";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
1837
ce5dc74dec97 Now set_cs is just taken from !claset
paulson
parents: 1822
diff changeset
   127
val set_cs = !claset delrules [equalityI];