src/HOL/Prod.ML
author nipkow
Wed, 25 Oct 1995 09:48:29 +0100
changeset 1301 42782316d510
parent 1264 3eb91524b938
child 1454 d0266c81a85e
permissions -rw-r--r--
Added various thms and tactics.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/prod
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1991  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
For prod.thy.  Ordered Pairs, the Cartesian product type, the unit type
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
open Prod;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
(*This counts as a non-emptiness result for admitting 'a * 'b as a type*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
goalw Prod.thy [Prod_def] "Pair_Rep a b : Prod";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
by (EVERY1 [rtac CollectI, rtac exI, rtac exI, rtac refl]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
qed "ProdI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
val [major] = goalw Prod.thy [Pair_Rep_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
    "Pair_Rep a b = Pair_Rep a' b' ==> a=a' & b=b'";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
by (EVERY1 [rtac (major RS fun_cong RS fun_cong RS subst), 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
	    rtac conjI, rtac refl, rtac refl]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
qed "Pair_Rep_inject";
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
goal Prod.thy "inj_onto Abs_Prod Prod";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
by (rtac inj_onto_inverseI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
by (etac Abs_Prod_inverse 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
qed "inj_onto_Abs_Prod";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
val prems = goalw Prod.thy [Pair_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    28
    "[| (a, b) = (a',b');  [| a=a';  b=b' |] ==> R |] ==> R";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
by (rtac (inj_onto_Abs_Prod RS inj_ontoD RS Pair_Rep_inject RS conjE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
by (REPEAT (ares_tac (prems@[ProdI]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
qed "Pair_inject";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    33
goal Prod.thy "((a,b) = (a',b')) = (a=a' & b=b')";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
by (fast_tac (set_cs addIs [Pair_inject]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
qed "Pair_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    37
goalw Prod.thy [fst_def] "fst((a,b)) = a";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
by (fast_tac (set_cs addIs [select_equality] addSEs [Pair_inject]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
qed "fst_conv";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    41
goalw Prod.thy [snd_def] "snd((a,b)) = b";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
by (fast_tac (set_cs addIs [select_equality] addSEs [Pair_inject]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
qed "snd_conv";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    45
goalw Prod.thy [Pair_def] "? x y. p = (x,y)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
by (rtac (rewrite_rule [Prod_def] Rep_Prod RS CollectE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
by (EVERY1[etac exE, etac exE, rtac exI, rtac exI,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
	   rtac (Rep_Prod_inverse RS sym RS trans),  etac arg_cong]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
qed "PairE_lemma";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    51
val [prem] = goal Prod.thy "[| !!x y. p = (x,y) ==> Q |] ==> Q";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
by (rtac (PairE_lemma RS exE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
by (REPEAT (eresolve_tac [prem,exE] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
qed "PairE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    56
(* replace parameters of product type by individual component parameters *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    57
local
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    58
fun is_pair (_,Type("*",_)) = true
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    59
  | is_pair _ = false;
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    60
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    61
fun find_pair_param t =
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    62
  let val params = Logic.strip_params t
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    63
  in if exists is_pair params
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    64
     then let val params = rev(rename_wrt_term t params)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    65
                           (*as they are printed*)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    66
          in apsome fst (find_first is_pair params) end
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    67
     else None
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    68
  end;
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    69
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    70
in
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    71
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    72
val split_all_tac = REPEAT o SUBGOAL (fn (t,_) =>
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    73
  case find_pair_param t of
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    74
    None => no_tac
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    75
  | Some x => EVERY[res_inst_tac[("p",x)] PairE 1,
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    76
                    REPEAT(hyp_subst_tac 1), prune_params_tac]);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    77
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    78
end;
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    79
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    80
goal Prod.thy "(!x. P x) = (!a b. P(a,b))";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    81
by(fast_tac (HOL_cs addbefore split_all_tac 1) 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    82
qed "split_paired_All";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    83
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    84
goalw Prod.thy [split_def] "split c (a,b) = c a b";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
by (sstac [fst_conv, snd_conv] 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
by (rtac refl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
qed "split";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    89
Addsimps [fst_conv, snd_conv, split_paired_All, split, Pair_eq];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
goal Prod.thy "(s=t) = (fst(s)=fst(t) & snd(s)=snd(t))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
by (res_inst_tac[("p","s")] PairE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
by (res_inst_tac[("p","t")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
    94
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
qed "Pair_fst_snd_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
(*Prevents simplification of c: much faster*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
qed_goal "split_weak_cong" Prod.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
  "p=q ==> split c p = split c q"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
  (fn [prem] => [rtac (prem RS arg_cong) 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
(* Do not add as rewrite rule: invalidates some proofs in IMP *)
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   103
goal Prod.thy "p = (fst(p),snd(p))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
by (res_inst_tac [("p","p")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   105
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
qed "surjective_pairing";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   108
goal Prod.thy "p = split (%x y.(x,y)) p";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
by (res_inst_tac [("p","p")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   110
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
qed "surjective_pairing2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
(*For use with split_tac and the simplifier*)
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   114
goal Prod.thy "R(split c p) = (! x y. p = (x,y) --> R(c x y))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
by (stac surjective_pairing 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   116
by (stac split 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
by (fast_tac (HOL_cs addSEs [Pair_inject]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
qed "expand_split";
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
(** split used as a logical connective or set former **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
(*These rules are for use with fast_tac.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   123
  Could instead call simp_tac/asm_full_simp_tac using split as rewrite.*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   124
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   125
goal Prod.thy "!!a b c. c a b ==> split c (a,b)";
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   126
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   127
qed "splitI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
val prems = goalw Prod.thy [split_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   130
    "[| split c p;  !!x y. [| p = (x,y);  c x y |] ==> Q |] ==> Q";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
qed "splitE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   134
goal Prod.thy "!!R a b. split R (a,b) ==> R a b";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
by (etac (split RS iffD1) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
qed "splitD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   138
goal Prod.thy "!!a b c. z: c a b ==> z: split c (a,b)";
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   139
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
qed "mem_splitI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   141
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
val prems = goalw Prod.thy [split_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   143
    "[| z: split c p;  !!x y. [| p = (x,y);  z: c x y |] ==> Q |] ==> Q";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
qed "mem_splitE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   147
(*** prod_fun -- action of the product functor upon functions ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   149
goalw Prod.thy [prod_fun_def] "prod_fun f g (a,b) = (f(a),g(b))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
by (rtac split 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
qed "prod_fun";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
goal Prod.thy 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
    "prod_fun (f1 o f2) (g1 o g2) = ((prod_fun f1 g1) o (prod_fun f2 g2))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   155
by (rtac ext 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   156
by (res_inst_tac [("p","x")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   157
by (asm_simp_tac (!simpset addsimps [prod_fun,o_def]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   158
qed "prod_fun_compose";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   159
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   160
goal Prod.thy "prod_fun (%x.x) (%y.y) = (%z.z)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   161
by (rtac ext 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   162
by (res_inst_tac [("p","z")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   163
by (asm_simp_tac (!simpset addsimps [prod_fun]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   164
qed "prod_fun_ident";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   165
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   166
val prems = goal Prod.thy "(a,b):r ==> (f(a),g(b)) : (prod_fun f g)``r";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   167
by (rtac image_eqI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   168
by (rtac (prod_fun RS sym) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   169
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   170
qed "prod_fun_imageI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   171
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   172
val major::prems = goal Prod.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   173
    "[| c: (prod_fun f g)``r;  !!x y. [| c=(f(x),g(y));  (x,y):r |] ==> P  \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   174
\    |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   175
by (rtac (major RS imageE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   176
by (res_inst_tac [("p","x")] PairE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   177
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   178
by (fast_tac HOL_cs 2);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   179
by (fast_tac (HOL_cs addIs [prod_fun]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   180
qed "prod_fun_imageE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
(*** Disjoint union of a family of sets - Sigma ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
qed_goalw "SigmaI" Prod.thy [Sigma_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   185
    "[| a:A;  b:B(a) |] ==> (a,b) : Sigma A B"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   186
 (fn prems=> [ (REPEAT (resolve_tac (prems@[singletonI,UN_I]) 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   187
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
(*The general elimination rule*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
qed_goalw "SigmaE" Prod.thy [Sigma_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   190
    "[| c: Sigma A B;  \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   191
\       !!x y.[| x:A;  y:B(x);  c=(x,y) |] ==> P \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   192
\    |] ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   193
 (fn major::prems=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   194
  [ (cut_facts_tac [major] 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   195
    (REPEAT (eresolve_tac [UN_E, singletonE] 1 ORELSE ares_tac prems 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   196
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   197
(** Elimination of (a,b):A*B -- introduces no eigenvariables **)
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   198
qed_goal "SigmaD1" Prod.thy "(a,b) : Sigma A B ==> a : A"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   199
 (fn [major]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   200
  [ (rtac (major RS SigmaE) 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   201
    (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   202
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   203
qed_goal "SigmaD2" Prod.thy "(a,b) : Sigma A B ==> b : B(a)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   204
 (fn [major]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   205
  [ (rtac (major RS SigmaE) 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   206
    (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   207
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   208
qed_goal "SigmaE2" Prod.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   209
    "[| (a,b) : Sigma A B;    \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   210
\       [| a:A;  b:B(a) |] ==> P   \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   211
\    |] ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   212
 (fn [major,minor]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   213
  [ (rtac minor 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   214
    (rtac (major RS SigmaD1) 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   215
    (rtac (major RS SigmaD2) 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   216
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   217
(*** Domain of a relation ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   218
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   219
val prems = goalw Prod.thy [image_def] "(a,b) : r ==> a : fst``r";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   220
by (rtac CollectI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   221
by (rtac bexI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   222
by (rtac (fst_conv RS sym) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   223
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   224
qed "fst_imageI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   225
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   226
val major::prems = goal Prod.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   227
    "[| a : fst``r;  !!y.[| (a,y) : r |] ==> P |] ==> P"; 
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   228
by (rtac (major RS imageE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   229
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   230
by (etac ssubst 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   231
by (rtac (surjective_pairing RS subst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   232
by (assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   233
qed "fst_imageE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   234
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   235
(*** Range of a relation ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   236
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   237
val prems = goalw Prod.thy [image_def] "(a,b) : r ==> b : snd``r";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   238
by (rtac CollectI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   239
by (rtac bexI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   240
by (rtac (snd_conv RS sym) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   241
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   242
qed "snd_imageI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   243
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   244
val major::prems = goal Prod.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   245
    "[| a : snd``r;  !!y.[| (y,a) : r |] ==> P |] ==> P"; 
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   246
by (rtac (major RS imageE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   247
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   248
by (etac ssubst 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   249
by (rtac (surjective_pairing RS subst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   250
by (assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   251
qed "snd_imageE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   252
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   253
(** Exhaustion rule for unit -- a degenerate form of induction **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   254
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   255
goalw Prod.thy [Unity_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   256
    "u = ()";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   257
by (stac (rewrite_rule [Unit_def] Rep_Unit RS CollectD RS sym) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   258
by (rtac (Rep_Unit_inverse RS sym) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   259
qed "unit_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   260
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   261
val prod_cs = set_cs addSIs [SigmaI, mem_splitI] 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   262
                     addIs  [fst_imageI, snd_imageI, prod_fun_imageI]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   263
                     addSEs [SigmaE2, SigmaE, mem_splitE, 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   264
			     fst_imageE, snd_imageE, prod_fun_imageE,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   265
			     Pair_inject];