src/ZF/func.ML
author wenzelm
Fri, 07 Mar 1997 11:48:46 +0100
changeset 2754 59bd96046ad6
parent 2493 bdeb5024353a
child 2835 c07d6bc56cc2
permissions -rw-r--r--
moved settings comment to build;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
     1
(*  Title:      ZF/func
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Functions in Zermelo-Fraenkel Set Theory
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
(*** The Pi operator -- dependent function space ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    11
goalw thy [Pi_def]
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    12
    "f: Pi(A,B) <-> function(f) & f<=Sigma(A,B) & A<=domain(f)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    13
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    14
qed "Pi_iff";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    15
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    16
(*For upward compatibility with the former definition*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    17
goalw thy [Pi_def, function_def]
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    18
    "f: Pi(A,B) <-> f<=Sigma(A,B) & (ALL x:A. EX! y. <x,y>: f)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    19
by (safe_tac (!claset));
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    20
by (Best_tac 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    21
by (Best_tac 1);
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    22
by (set_mp_tac 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    23
by (Deepen_tac 3 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    24
qed "Pi_iff_old";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    25
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    26
goal thy "!!f. f: Pi(A,B) ==> function(f)";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    27
by (asm_full_simp_tac (FOL_ss addsimps [Pi_iff]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    28
qed "fun_is_function";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
(**Two "destruct" rules for Pi **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    32
val [major] = goalw thy [Pi_def] "f: Pi(A,B) ==> f <= Sigma(A,B)";  
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    33
by (rtac (major RS CollectD1 RS PowD) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    34
qed "fun_is_rel";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    36
goal thy "!!f. [| f: Pi(A,B);  a:A |] ==> EX! y. <a,y>: f";  
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    37
by (fast_tac ((!claset) addSDs [Pi_iff_old RS iffD1]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    38
qed "fun_unique_Pair";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    40
val prems = goalw thy [Pi_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
    "[| A=A';  !!x. x:A' ==> B(x)=B'(x) |] ==> Pi(A,B) = Pi(A',B')";
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
    42
by (simp_tac (FOL_ss addsimps prems addcongs [Sigma_cong]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    43
qed "Pi_cong";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    45
(*Sigma_cong, Pi_cong NOT given to Addcongs: they cause
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    46
  flex-flex pairs and the "Check your prover" error.  Most
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    47
  Sigmas and Pis are abbreviated as * or -> *)
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    48
485
5e00a676a211 Axiom of choice, cardinality results, etc.
lcp
parents: 437
diff changeset
    49
(*Weakening one function type to another; see also Pi_type*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    50
goalw thy [Pi_def] "!!f. [| f: A->B;  B<=D |] ==> f: A->D";
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    51
by (Best_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    52
qed "fun_weaken_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
(*Empty function spaces*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    55
goalw thy [Pi_def, function_def] "Pi(0,A) = {0}";
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
    56
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    57
qed "Pi_empty1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    59
goalw thy [Pi_def] "!!A a. a:A ==> A->0 = 0";
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
    60
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    61
qed "Pi_empty2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
519
98b88551e102 ZF/func/empty_fun: renamed from fun_empty
lcp
parents: 517
diff changeset
    63
(*The empty function*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    64
goalw thy [Pi_def, function_def] "0: Pi(0,B)";
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    65
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    66
qed "empty_fun";
519
98b88551e102 ZF/func/empty_fun: renamed from fun_empty
lcp
parents: 517
diff changeset
    67
98b88551e102 ZF/func/empty_fun: renamed from fun_empty
lcp
parents: 517
diff changeset
    68
(*The singleton function*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    69
goalw thy [Pi_def, function_def] "{<a,b>} : {a} -> {b}";
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
    70
by (Fast_tac 1);
857
f5314a7c93f2 Renamed single_fun to singleton_fun.
lcp
parents: 824
diff changeset
    71
qed "singleton_fun";
519
98b88551e102 ZF/func/empty_fun: renamed from fun_empty
lcp
parents: 517
diff changeset
    72
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    73
Addsimps [empty_fun, singleton_fun];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    74
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
(*** Function Application ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    77
goalw thy [Pi_def, function_def]
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    78
     "!!a b f. [| <a,b>: f;  <a,c>: f;  f: Pi(A,B) |] ==> b=c";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    79
by (Deepen_tac 3 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    80
qed "apply_equality2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    82
goalw thy [apply_def] "!!a b f. [| <a,b>: f;  f: Pi(A,B) |] ==> f`a = b";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
by (rtac the_equality 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
by (rtac apply_equality2 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
by (REPEAT (assume_tac 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    86
qed "apply_equality";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
517
a9f93400f307 for infinite datatypes with arbitrary index sets
lcp
parents: 485
diff changeset
    88
(*Applying a function outside its domain yields 0*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    89
goalw thy [apply_def]
517
a9f93400f307 for infinite datatypes with arbitrary index sets
lcp
parents: 485
diff changeset
    90
    "!!a b f. [| a ~: domain(f);  f: Pi(A,B) |] ==> f`a = 0";
a9f93400f307 for infinite datatypes with arbitrary index sets
lcp
parents: 485
diff changeset
    91
by (rtac the_0 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    92
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    93
qed "apply_0";
517
a9f93400f307 for infinite datatypes with arbitrary index sets
lcp
parents: 485
diff changeset
    94
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    95
goal thy "!!f. [| f: Pi(A,B);  c: f |] ==> EX x:A.  c = <x,f`x>";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    96
by (forward_tac [fun_is_rel] 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
    97
by (fast_tac ((!claset) addDs [apply_equality]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
    98
qed "Pi_memberD";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
    99
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   100
goal thy "!!f. [| f: Pi(A,B);  a:A |] ==> <a,f`a>: f";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   101
by (rtac (fun_unique_Pair RS ex1E) 1);
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   102
by (resolve_tac [apply_equality RS ssubst] 3);
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   103
by (REPEAT (assume_tac 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   104
qed "apply_Pair";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   106
(*Conclusion is flexible -- use res_inst_tac or else apply_funtype below!*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   107
goal thy "!!f. [| f: Pi(A,B);  a:A |] ==> f`a : B(a)"; 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
by (rtac (fun_is_rel RS subsetD RS SigmaE2) 1);
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   109
by (REPEAT (ares_tac [apply_Pair] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   110
qed "apply_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   112
(*This version is acceptable to the simplifier*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   113
goal thy "!!f. [| f: A->B;  a:A |] ==> f`a : B"; 
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   114
by (REPEAT (ares_tac [apply_type] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   115
qed "apply_funtype";
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   116
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   117
val [major] = goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
    "f: Pi(A,B) ==> <a,b>: f <-> a:A & f`a = b";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   119
by (cut_facts_tac [major RS fun_is_rel] 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   120
by (fast_tac ((!claset) addSIs [major RS apply_Pair, 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
   121
                            major RSN (2,apply_equality)]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   122
qed "apply_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
(*Refining one Pi type to another*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   125
val pi_prem::prems = goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
    "[| f: Pi(A,C);  !!x. x:A ==> f`x : B(x) |] ==> f : Pi(A,B)";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   127
by (cut_facts_tac [pi_prem] 1);
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   128
by (asm_full_simp_tac (FOL_ss addsimps [Pi_iff]) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   129
by (fast_tac ((!claset) addIs prems addSDs [pi_prem RS Pi_memberD]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   130
qed "Pi_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
(** Elimination of membership in a function **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   135
goal thy "!!a A. [| <a,b> : f;  f: Pi(A,B) |] ==> a : A";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
by (REPEAT (ares_tac [fun_is_rel RS subsetD RS SigmaD1] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   137
qed "domain_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   139
goal thy "!!b B a. [| <a,b> : f;  f: Pi(A,B) |] ==> b : B(a)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
by (etac (fun_is_rel RS subsetD RS SigmaD2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
by (assume_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   142
qed "range_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   143
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   144
val prems = goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
    "[| <a,b>: f;  f: Pi(A,B);       \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
\       [| a:A;  b:B(a);  f`a = b |] ==> P  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
\    |] ==> P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
by (cut_facts_tac prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
by (resolve_tac prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
by (REPEAT (eresolve_tac [asm_rl,domain_type,range_type,apply_equality] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   151
qed "Pair_mem_PiE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
(*** Lambda Abstraction ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   155
goalw thy [lam_def] "!!A b. a:A ==> <a,b(a)> : (lam x:A. b(x))";  
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
by (etac RepFunI 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   157
qed "lamI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   159
val major::prems = goalw thy [lam_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
    "[| p: (lam x:A. b(x));  !!x.[| x:A; p=<x,b(x)> |] ==> P  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   161
\    |] ==>  P";  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
by (rtac (major RS RepFunE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
by (REPEAT (ares_tac prems 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   164
qed "lamE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   166
goal thy "!!a b c. [| <a,c>: (lam x:A. b(x)) |] ==> c = b(a)";  
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
by (REPEAT (eresolve_tac [asm_rl,lamE,Pair_inject,ssubst] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   168
qed "lamD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   170
val prems = goalw thy [lam_def, Pi_def, function_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   171
    "[| !!x. x:A ==> b(x): B(x) |] ==> (lam x:A.b(x)) : Pi(A,B)";  
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   172
by (fast_tac ((!claset) addIs prems) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   173
qed "lam_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   174
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   175
goal thy "(lam x:A.b(x)) : A -> {b(x). x:A}";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
by (REPEAT (ares_tac [refl,lam_type,RepFunI] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   177
qed "lam_funtype";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   179
goal thy "!!a A. a : A ==> (lam x:A.b(x)) ` a = b(a)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   180
by (REPEAT (ares_tac [apply_equality,lam_funtype,lamI] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   181
qed "beta";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   183
goalw thy [lam_def] "(lam x:0. b(x)) = 0";
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   184
by (Simp_tac 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   185
qed "lam_empty";
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   186
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   187
Addsimps [beta, lam_empty];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   188
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   189
(*congruence rule for lambda abstraction*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   190
val prems = goalw thy [lam_def] 
6
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   191
    "[| A=A';  !!x. x:A' ==> b(x)=b'(x) |] ==> Lambda(A,b) = Lambda(A',b')";
8ce8c4d13d4d Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents: 0
diff changeset
   192
by (simp_tac (FOL_ss addsimps prems addcongs [RepFun_cong]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   193
qed "lam_cong";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   195
Addcongs [lam_cong];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   196
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   197
val [major] = goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
    "(!!x. x:A ==> EX! y. Q(x,y)) ==> EX f. ALL x:A. Q(x, f`x)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   199
by (res_inst_tac [("x", "lam x: A. THE y. Q(x,y)")] exI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
by (rtac ballI 1);
2033
639de962ded4 Ran expandshort; used stac instead of ssubst
paulson
parents: 1461
diff changeset
   201
by (stac beta 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
by (assume_tac 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
by (etac (major RS theI) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   204
qed "lam_theI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
(** Extensionality **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   208
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
(*Semi-extensionality!*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   210
val prems = goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
    "[| f : Pi(A,B);  g: Pi(C,D);  A<=C; \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
\       !!x. x:A ==> f`x = g`x       |] ==> f<=g";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
by (rtac subsetI 1);
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   214
by (eresolve_tac (prems RL [Pi_memberD RS bexE]) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
by (etac ssubst 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
by (resolve_tac (prems RL [ssubst]) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
by (REPEAT (ares_tac (prems@[apply_Pair,subsetD]) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   218
qed "fun_subset";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   220
val prems = goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   221
    "[| f : Pi(A,B);  g: Pi(A,D);  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
\       !!x. x:A ==> f`x = g`x       |] ==> f=g";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
by (REPEAT (ares_tac (prems @ (prems RL [sym]) @
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
   224
                      [subset_refl,equalityI,fun_subset]) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   225
qed "fun_extension";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   227
goal thy "!!f A B. f : Pi(A,B) ==> (lam x:A. f`x) = f";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
by (rtac fun_extension 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   229
by (REPEAT (ares_tac [lam_type,apply_type,beta] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   230
qed "eta";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   232
Addsimps [eta];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   233
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   234
(*Every element of Pi(A,B) may be expressed as a lambda abstraction!*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   235
val prems = goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
    "[| f: Pi(A,B);        \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   237
\       !!b. [| ALL x:A. b(x):B(x);  f = (lam x:A.b(x)) |] ==> P   \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   238
\    |] ==> P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
by (resolve_tac prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   240
by (rtac (eta RS sym) 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   241
by (REPEAT (ares_tac (prems@[ballI,apply_type]) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   242
qed "Pi_lamE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   243
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 129
diff changeset
   245
(** Images of functions **)
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 129
diff changeset
   246
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   247
goalw thy [lam_def] "!!C A. C <= A ==> (lam x:A.b(x)) `` C = {b(x). x:C}";
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
   248
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   249
qed "image_lam";
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 129
diff changeset
   250
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   251
goal thy "!!C A. [| f : Pi(A,B);  C <= A |] ==> f``C = {f`x. x:C}";
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents: 435
diff changeset
   252
by (etac (eta RS subst) 1);
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 129
diff changeset
   253
by (asm_full_simp_tac (FOL_ss addsimps [beta, image_lam, subset_iff]
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 129
diff changeset
   254
                              addcongs [RepFun_cong]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   255
qed "image_fun";
435
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 129
diff changeset
   256
ca5356bd315a Addition of cardinals and order types, various tidying
lcp
parents: 129
diff changeset
   257
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
(*** properties of "restrict" ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   260
goalw thy [restrict_def,lam_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
    "!!f A. [| f: Pi(C,B);  A<=C |] ==> restrict(f,A) <= f";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   262
by (fast_tac ((!claset) addIs [apply_Pair]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   263
qed "restrict_subset";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   265
val prems = goalw thy [restrict_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
    "[| !!x. x:A ==> f`x: B(x) |] ==> restrict(f,A) : Pi(A,B)";  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
by (rtac lam_type 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   268
by (eresolve_tac prems 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   269
qed "restrict_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   270
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   271
val [pi,subs] = goal thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   272
    "[| f: Pi(C,B);  A<=C |] ==> restrict(f,A) : Pi(A,B)";  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   273
by (rtac (pi RS apply_type RS restrict_type) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
by (etac (subs RS subsetD) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   275
qed "restrict_type2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   277
goalw thy [restrict_def] "!!a A. a : A ==> restrict(f,A) ` a = f`a";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   278
by (etac beta 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   279
qed "restrict";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   280
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   281
goalw thy [restrict_def] "restrict(f,0) = 0";
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   282
by (Simp_tac 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   283
qed "restrict_empty";
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   284
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   285
Addsimps [restrict, restrict_empty];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   286
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   287
(*NOT SAFE as a congruence rule for the simplifier!  Can cause it to fail!*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   288
val prems = goalw thy [restrict_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   289
    "[| A=B;  !!x. x:B ==> f`x=g`x |] ==> restrict(f,A) = restrict(g,B)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
by (REPEAT (ares_tac (prems@[lam_cong]) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   291
qed "restrict_eqI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   293
goalw thy [restrict_def, lam_def] "domain(restrict(f,C)) = C";
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
   294
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   295
qed "domain_restrict";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   296
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   297
val [prem] = goalw thy [restrict_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
    "A<=C ==> restrict(lam x:C. b(x), A) = (lam x:A. b(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   299
by (rtac (refl RS lam_cong) 1);
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
   300
by (etac (prem RS subsetD RS beta) 1);  (*easier than calling simp_tac*)
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   301
qed "restrict_lam_eq";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   302
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   304
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   305
(*** Unions of functions ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   306
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
(** The Union of a set of COMPATIBLE functions is a function **)
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   308
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   309
goalw thy [function_def]
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   310
    "!!S. [| ALL x:S. function(x); \
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   311
\            ALL x:S. ALL y:S. x<=y | y<=x  |] ==>  \
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   312
\         function(Union(S))";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   313
by (fast_tac ((!claset) addSDs [bspec RS bspec]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   314
qed "function_Union";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   315
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   316
goalw thy [Pi_def]
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   317
    "!!S. [| ALL f:S. EX C D. f:C->D; \
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   318
\            ALL f:S. ALL y:S. f<=y | y<=f  |] ==>  \
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   319
\         Union(S) : domain(Union(S)) -> range(Union(S))";
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   320
by (fast_tac (subset_cs addSIs [rel_Union, function_Union]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   321
qed "fun_Union";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   322
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   323
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   324
(** The Union of 2 disjoint functions is a function **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   325
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   326
val Un_rls = [Un_subset_iff, domain_Un_eq, SUM_Un_distrib1, prod_Un_distrib2, 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
   327
              Un_upper1 RSN (2, subset_trans), 
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
   328
              Un_upper2 RSN (2, subset_trans)];
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   329
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   330
goal thy
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   331
    "!!f. [| f: A->B;  g: C->D;  A Int C = 0  |] ==>  \
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   332
\         (f Un g) : (A Un C) -> (B Un D)";
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   333
(*Solve the product and domain subgoals using distributive laws*)
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   334
by (asm_full_simp_tac (FOL_ss addsimps [Pi_iff,extension]@Un_rls) 1);
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   335
by (asm_simp_tac (FOL_ss addsimps [function_def]) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   336
by (safe_tac (!claset));
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   337
(*Solve the two cases that contradict A Int C = 0*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   338
by (Deepen_tac 2 2);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   339
by (Deepen_tac 2 2);
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
   340
by (rewtac function_def);
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   341
by (REPEAT_FIRST (dtac (spec RS spec)));
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   342
by (Deepen_tac 1 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   343
by (Deepen_tac 1 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   344
qed "fun_disjoint_Un";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   345
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   346
goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   347
    "!!f g a. [| a:A;  f: A->B;  g: C->D;  A Int C = 0 |] ==>  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   348
\             (f Un g)`a = f`a";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   349
by (rtac (apply_Pair RS UnI1 RS apply_equality) 1);
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   350
by (REPEAT (ares_tac [fun_disjoint_Un] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   351
qed "fun_disjoint_apply1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   352
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   353
goal thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   354
    "!!f g c. [| c:C;  f: A->B;  g: C->D;  A Int C = 0 |] ==>  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   355
\             (f Un g)`c = g`c";
691
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   356
by (rtac (apply_Pair RS UnI2 RS apply_equality) 1);
b9fc536792bb ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents: 538
diff changeset
   357
by (REPEAT (ares_tac [fun_disjoint_Un] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   358
qed "fun_disjoint_apply2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   359
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   360
(** Domain and range of a function/relation **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   361
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   362
goalw thy [Pi_def] "!!f. f : Pi(A,B) ==> domain(f)=A";
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
   363
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   364
qed "domain_of_fun";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   365
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   366
goal thy "!!f. [| f : Pi(A,B);  a: A |] ==> f`a : range(f)";
517
a9f93400f307 for infinite datatypes with arbitrary index sets
lcp
parents: 485
diff changeset
   367
by (etac (apply_Pair RS rangeI) 1);
a9f93400f307 for infinite datatypes with arbitrary index sets
lcp
parents: 485
diff changeset
   368
by (assume_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   369
qed "apply_rangeI";
517
a9f93400f307 for infinite datatypes with arbitrary index sets
lcp
parents: 485
diff changeset
   370
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   371
val [major] = goal thy "f : Pi(A,B) ==> f : A->range(f)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   372
by (rtac (major RS Pi_type) 1);
517
a9f93400f307 for infinite datatypes with arbitrary index sets
lcp
parents: 485
diff changeset
   373
by (etac (major RS apply_rangeI) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   374
qed "range_of_fun";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   375
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   376
(*** Extensions of functions ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   377
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   378
goal thy
37
cebe01deba80 added ~: for "not in"
lcp
parents: 14
diff changeset
   379
    "!!f A B. [| f: A->B;  c~:A |] ==> cons(<c,b>,f) : cons(c,A) -> cons(b,B)";
857
f5314a7c93f2 Renamed single_fun to singleton_fun.
lcp
parents: 824
diff changeset
   380
by (forward_tac [singleton_fun RS fun_disjoint_Un] 1);
519
98b88551e102 ZF/func/empty_fun: renamed from fun_empty
lcp
parents: 517
diff changeset
   381
by (asm_full_simp_tac (FOL_ss addsimps [cons_eq]) 2);
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
   382
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   383
qed "fun_extend";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   384
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   385
goal thy
538
b4fe3da03449 ZF/func/fun_extend3: new
lcp
parents: 519
diff changeset
   386
    "!!f A B. [| f: A->B;  c~:A;  b: B |] ==> cons(<c,b>,f) : cons(c,A) -> B";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   387
by (fast_tac ((!claset) addEs [fun_extend RS fun_weaken_type]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   388
qed "fun_extend3";
538
b4fe3da03449 ZF/func/fun_extend3: new
lcp
parents: 519
diff changeset
   389
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   390
goal thy "!!f A B. [| f: A->B;  a:A;  c~:A |] ==> cons(<c,b>,f)`a = f`a";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   391
by (rtac (apply_Pair RS consI2 RS apply_equality) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   392
by (rtac fun_extend 3);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   393
by (REPEAT (assume_tac 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   394
qed "fun_extend_apply1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   395
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   396
goal thy "!!f A B. [| f: A->B;  c~:A |] ==> cons(<c,b>,f)`c = b";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   397
by (rtac (consI1 RS apply_equality) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   398
by (rtac fun_extend 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   399
by (REPEAT (assume_tac 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   400
qed "fun_extend_apply2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   401
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   402
bind_thm ("singleton_apply", [singletonI, singleton_fun] MRS apply_equality);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   403
Addsimps [singleton_apply];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   404
538
b4fe3da03449 ZF/func/fun_extend3: new
lcp
parents: 519
diff changeset
   405
(*For Finite.ML.  Inclusion of right into left is easy*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   406
goal thy
485
5e00a676a211 Axiom of choice, cardinality results, etc.
lcp
parents: 437
diff changeset
   407
    "!!c. c ~: A ==> cons(c,A) -> B = (UN f: A->B. UN b:B. {cons(<c,b>, f)})";
737
436019ca97d7 cons_fun_eq: modified strange uses of classical reasoner
lcp
parents: 691
diff changeset
   408
by (rtac equalityI 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   409
by (safe_tac ((!claset) addSEs [fun_extend3]));
485
5e00a676a211 Axiom of choice, cardinality results, etc.
lcp
parents: 437
diff changeset
   410
(*Inclusion of left into right*)
5e00a676a211 Axiom of choice, cardinality results, etc.
lcp
parents: 437
diff changeset
   411
by (subgoal_tac "restrict(x, A) : A -> B" 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   412
by (fast_tac ((!claset) addEs [restrict_type2]) 2);
485
5e00a676a211 Axiom of choice, cardinality results, etc.
lcp
parents: 437
diff changeset
   413
by (rtac UN_I 1 THEN assume_tac 1);
737
436019ca97d7 cons_fun_eq: modified strange uses of classical reasoner
lcp
parents: 691
diff changeset
   414
by (rtac (apply_funtype RS UN_I) 1 THEN REPEAT (ares_tac [consI1] 1));
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   415
by (Simp_tac 1);
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 857
diff changeset
   416
by (rtac fun_extension 1 THEN REPEAT (ares_tac [fun_extend] 1));
485
5e00a676a211 Axiom of choice, cardinality results, etc.
lcp
parents: 437
diff changeset
   417
by (etac consE 1);
5e00a676a211 Axiom of choice, cardinality results, etc.
lcp
parents: 437
diff changeset
   418
by (ALLGOALS 
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 2033
diff changeset
   419
    (asm_simp_tac (!simpset addsimps [restrict, fun_extend_apply1, 
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
   420
                                      fun_extend_apply2])));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 737
diff changeset
   421
qed "cons_fun_eq";
485
5e00a676a211 Axiom of choice, cardinality results, etc.
lcp
parents: 437
diff changeset
   422