src/HOL/Prod.ML
author wenzelm
Tue, 20 May 1997 19:29:50 +0200
changeset 3257 4e3724e0659f
parent 2935 998cb95fdd43
child 3429 160f18a686b5
permissions -rw-r--r--
README generation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1454
diff changeset
     1
(*  Title:      HOL/prod
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1454
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
923
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), 
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1454
diff changeset
    19
            rtac conjI, rtac refl, rtac refl]);
923
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
2856
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
    33
AddSEs [Pair_inject];
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
    34
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    35
goal Prod.thy "((a,b) = (a',b')) = (a=a' & b=b')";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
    36
by (Blast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
qed "Pair_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    39
goalw Prod.thy [fst_def] "fst((a,b)) = a";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
    40
by (blast_tac (!claset addIs [select_equality]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
qed "fst_conv";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    43
goalw Prod.thy [snd_def] "snd((a,b)) = b";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
    44
by (blast_tac (!claset addIs [select_equality]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
qed "snd_conv";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    47
goalw Prod.thy [Pair_def] "? x y. p = (x,y)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
by (rtac (rewrite_rule [Prod_def] Rep_Prod RS CollectE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
by (EVERY1[etac exE, etac exE, rtac exI, rtac exI,
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1454
diff changeset
    50
           rtac (Rep_Prod_inverse RS sym RS trans),  etac arg_cong]);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
qed "PairE_lemma";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    53
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
    54
by (rtac (PairE_lemma RS exE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
by (REPEAT (eresolve_tac [prem,exE] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
qed "PairE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    58
(* replace parameters of product type by individual component parameters *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    59
local
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    60
fun is_pair (_,Type("*",_)) = true
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    61
  | is_pair _ = false;
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    62
1727
7d0fbdc46e8e Now split_all_tac works for i>1 !
paulson
parents: 1655
diff changeset
    63
fun find_pair_param prem =
7d0fbdc46e8e Now split_all_tac works for i>1 !
paulson
parents: 1655
diff changeset
    64
  let val params = Logic.strip_params prem
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    65
  in if exists is_pair params
1727
7d0fbdc46e8e Now split_all_tac works for i>1 !
paulson
parents: 1655
diff changeset
    66
     then let val params = rev(rename_wrt_term prem params)
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    67
                           (*as they are printed*)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    68
          in apsome fst (find_first is_pair params) end
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    69
     else None
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    70
  end;
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    71
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    72
in
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    73
1727
7d0fbdc46e8e Now split_all_tac works for i>1 !
paulson
parents: 1655
diff changeset
    74
val split_all_tac = REPEAT o SUBGOAL (fn (prem,i) =>
7d0fbdc46e8e Now split_all_tac works for i>1 !
paulson
parents: 1655
diff changeset
    75
  case find_pair_param prem of
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    76
    None => no_tac
1727
7d0fbdc46e8e Now split_all_tac works for i>1 !
paulson
parents: 1655
diff changeset
    77
  | Some x => EVERY[res_inst_tac[("p",x)] PairE i,
7d0fbdc46e8e Now split_all_tac works for i>1 !
paulson
parents: 1655
diff changeset
    78
                    REPEAT(hyp_subst_tac i), prune_params_tac]);
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    79
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    80
end;
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    81
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    82
goal Prod.thy "(!x. P x) = (!a b. P(a,b))";
2637
e9b203f854ae reflecting my recent changes of the simplifier and classical reasoner
oheimb
parents: 2089
diff changeset
    83
by (fast_tac (!claset addbefore split_all_tac) 1);
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    84
qed "split_paired_All";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    85
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
    86
goalw Prod.thy [split_def] "split c (a,b) = c a b";
1485
240cc98b94a7 Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents: 1465
diff changeset
    87
by (EVERY1[stac fst_conv, stac snd_conv]);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
by (rtac refl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
qed "split";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
    91
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
    92
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
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
    94
by (res_inst_tac[("p","s")] PairE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
by (res_inst_tac[("p","t")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
    96
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
qed "Pair_fst_snd_eq";
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
(*Prevents simplification of c: much faster*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
qed_goal "split_weak_cong" Prod.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
  "p=q ==> split c p = split c q"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
  (fn [prem] => [rtac (prem RS arg_cong) 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
(* Do not add as rewrite rule: invalidates some proofs in IMP *)
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   105
goal Prod.thy "p = (fst(p),snd(p))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
by (res_inst_tac [("p","p")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   107
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
qed "surjective_pairing";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   110
goal Prod.thy "p = split (%x y.(x,y)) p";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
by (res_inst_tac [("p","p")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   112
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
qed "surjective_pairing2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
1655
5be64540f275 Added a number of lemmas
nipkow
parents: 1642
diff changeset
   115
qed_goal "split_eta" Prod.thy "(%(x,y). f(x,y)) = f"
5be64540f275 Added a number of lemmas
nipkow
parents: 1642
diff changeset
   116
  (fn _ => [rtac ext 1, split_all_tac 1, rtac split 1]);
5be64540f275 Added a number of lemmas
nipkow
parents: 1642
diff changeset
   117
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
(*For use with split_tac and the simplifier*)
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   119
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
   120
by (stac surjective_pairing 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
by (stac split 1);
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   122
by (Blast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   123
qed "expand_split";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   124
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
(** split used as a logical connective or set former **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   127
(*These rules are for use with blast_tac.
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
  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
   129
1454
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1301
diff changeset
   130
goal Prod.thy "!!p. [| !!a b. p=(a,b) ==> c a b |] ==> split c p";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
   131
by (split_all_tac 1);
1454
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1301
diff changeset
   132
by (Asm_simp_tac 1);
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1301
diff changeset
   133
qed "splitI2";
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1301
diff changeset
   134
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   135
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
   136
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
qed "splitI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
val prems = goalw Prod.thy [split_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   140
    "[| 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
   141
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
qed "splitE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   143
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   144
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
   145
by (etac (split RS iffD1) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
qed "splitD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   147
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   148
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
   149
by (Asm_simp_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
qed "mem_splitI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
1454
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1301
diff changeset
   152
goal Prod.thy "!!p. [| !!a b. p=(a,b) ==> z: c a b |] ==> z: split c p";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
   153
by (split_all_tac 1);
1454
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1301
diff changeset
   154
by (Asm_simp_tac 1);
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1301
diff changeset
   155
qed "mem_splitI2";
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1301
diff changeset
   156
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   157
val prems = goalw Prod.thy [split_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   158
    "[| 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
   159
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   160
qed "mem_splitE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   161
2856
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   162
AddSIs [splitI, splitI2, mem_splitI, mem_splitI2];
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   163
AddSEs [splitE, mem_splitE];
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   164
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   165
(*** prod_fun -- action of the product functor upon functions ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   166
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   167
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
   168
by (rtac split 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   169
qed "prod_fun";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   170
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   171
goal Prod.thy 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   172
    "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
   173
by (rtac ext 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   174
by (res_inst_tac [("p","x")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   175
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
   176
qed "prod_fun_compose";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   177
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   178
goal Prod.thy "prod_fun (%x.x) (%y.y) = (%z.z)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   179
by (rtac ext 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   180
by (res_inst_tac [("p","z")] PairE 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 972
diff changeset
   181
by (asm_simp_tac (!simpset addsimps [prod_fun]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
qed "prod_fun_ident";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   184
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
   185
by (rtac image_eqI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   186
by (rtac (prod_fun RS sym) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   187
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
qed "prod_fun_imageI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   190
val major::prems = goal Prod.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   191
    "[| 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
   192
\    |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   193
by (rtac (major RS imageE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   194
by (res_inst_tac [("p","x")] PairE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   195
by (resolve_tac prems 1);
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   196
by (Blast_tac 2);
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   197
by (blast_tac (!claset addIs [prod_fun]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   198
qed "prod_fun_imageE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   199
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   200
(*** Disjoint union of a family of sets - Sigma ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   201
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   202
qed_goalw "SigmaI" Prod.thy [Sigma_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   203
    "[| a:A;  b:B(a) |] ==> (a,b) : Sigma A B"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   204
 (fn prems=> [ (REPEAT (resolve_tac (prems@[singletonI,UN_I]) 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   205
2856
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   206
AddSIs [SigmaI];
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   207
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   208
(*The general elimination rule*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   209
qed_goalw "SigmaE" Prod.thy [Sigma_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   210
    "[| c: Sigma A B;  \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   211
\       !!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
   212
\    |] ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   213
 (fn major::prems=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   214
  [ (cut_facts_tac [major] 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   215
    (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
   216
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   217
(** Elimination of (a,b):A*B -- introduces no eigenvariables **)
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   218
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
   219
 (fn [major]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   220
  [ (rtac (major RS SigmaE) 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   221
    (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   222
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   223
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
   224
 (fn [major]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   225
  [ (rtac (major RS SigmaE) 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   226
    (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   227
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   228
qed_goal "SigmaE2" Prod.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   229
    "[| (a,b) : Sigma A B;    \
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   230
\       [| a:A;  b:B(a) |] ==> P   \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   231
\    |] ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   232
 (fn [major,minor]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   233
  [ (rtac minor 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   234
    (rtac (major RS SigmaD1) 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   235
    (rtac (major RS SigmaD2) 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   236
2856
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   237
AddSEs [SigmaE2, SigmaE];
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   238
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1485
diff changeset
   239
val prems = goal Prod.thy
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1618
diff changeset
   240
    "[| A<=C;  !!x. x:A ==> B x <= D x |] ==> Sigma A B <= Sigma C D";
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1485
diff changeset
   241
by (cut_facts_tac prems 1);
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   242
by (blast_tac (!claset addIs (prems RL [subsetD])) 1);
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1485
diff changeset
   243
qed "Sigma_mono";
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1485
diff changeset
   244
1618
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   245
qed_goal "Sigma_empty1" Prod.thy "Sigma {} B = {}"
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   246
 (fn _ => [ (Blast_tac 1) ]);
1618
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   247
1642
21db0cf9a1a4 Using new "Times" infix
paulson
parents: 1618
diff changeset
   248
qed_goal "Sigma_empty2" Prod.thy "A Times {} = {}"
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   249
 (fn _ => [ (Blast_tac 1) ]);
1618
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   250
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   251
Addsimps [Sigma_empty1,Sigma_empty2]; 
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   252
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   253
goal Prod.thy "((a,b): Sigma A B) = (a:A & b:B(a))";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   254
by (Blast_tac 1);
1618
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   255
qed "mem_Sigma_iff";
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   256
Addsimps [mem_Sigma_iff]; 
372880456b5b Library changes for mutilated checkerboard
paulson
parents: 1552
diff changeset
   257
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1485
diff changeset
   258
2856
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   259
(*Suggested by Pierre Chartier*)
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   260
goal Prod.thy
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   261
     "(UN (a,b):(A Times B). E a Times F b) = (UNION A E) Times (UNION B F)";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2886
diff changeset
   262
by (Blast_tac 1);
2856
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   263
qed "UNION_Times_distrib";
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   264
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   265
(*** Domain of a relation ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   266
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   267
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
   268
by (rtac CollectI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   269
by (rtac bexI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   270
by (rtac (fst_conv RS sym) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   271
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   272
qed "fst_imageI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   273
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   274
val major::prems = goal Prod.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   275
    "[| a : fst``r;  !!y.[| (a,y) : r |] ==> P |] ==> P"; 
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   276
by (rtac (major RS imageE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   277
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   278
by (etac ssubst 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   279
by (rtac (surjective_pairing RS subst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   280
by (assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   281
qed "fst_imageE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   282
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   283
(*** Range of a relation ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   284
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   285
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
   286
by (rtac CollectI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   287
by (rtac bexI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   288
by (rtac (snd_conv RS sym) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   289
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   290
qed "snd_imageI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   291
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   292
val major::prems = goal Prod.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   293
    "[| a : snd``r;  !!y.[| (y,a) : r |] ==> P |] ==> P"; 
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   294
by (rtac (major RS imageE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   295
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   296
by (etac ssubst 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   297
by (rtac (surjective_pairing RS subst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   298
by (assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   299
qed "snd_imageE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   300
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   301
(** Exhaustion rule for unit -- a degenerate form of induction **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   302
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   303
goalw Prod.thy [Unity_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 923
diff changeset
   304
    "u = ()";
2886
fd5645efa43d Now: unit = {True}
nipkow
parents: 2880
diff changeset
   305
by (stac (rewrite_rule [unit_def] Rep_unit RS singletonD RS sym) 1);
2880
a0fde30aa126 Removed (Unit) in Prod.
nipkow
parents: 2856
diff changeset
   306
by (rtac (Rep_unit_inverse RS sym) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   307
qed "unit_eq";
1754
852093aeb0ab Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   308
 
852093aeb0ab Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1746
diff changeset
   309
AddIs  [fst_imageI, snd_imageI, prod_fun_imageI];
2856
cdb908486a96 Reorganization of how classical rules are installed
paulson
parents: 2637
diff changeset
   310
AddSEs [fst_imageE, snd_imageE, prod_fun_imageE];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   311
1746
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   312
structure Prod_Syntax =
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   313
struct
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   314
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   315
val unitT = Type("unit",[]);
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   316
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   317
fun mk_prod (T1,T2) = Type("*", [T1,T2]);
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   318
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   319
(*Maps the type T1*...*Tn to [T1,...,Tn], however nested*)
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   320
fun factors (Type("*", [T1,T2])) = factors T1 @ factors T2
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   321
  | factors T                    = [T];
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   322
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   323
(*Make a correctly typed ordered pair*)
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   324
fun mk_Pair (t1,t2) = 
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   325
  let val T1 = fastype_of t1
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   326
      and T2 = fastype_of t2
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   327
  in  Const("Pair", [T1, T2] ---> mk_prod(T1,T2)) $ t1 $ t2  end;
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   328
   
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   329
fun split_const(Ta,Tb,Tc) = 
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   330
    Const("split", [[Ta,Tb]--->Tc, mk_prod(Ta,Tb)] ---> Tc);
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   331
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   332
(*In ap_split S T u, term u expects separate arguments for the factors of S,
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   333
  with result type T.  The call creates a new term expecting one argument
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   334
  of type S.*)
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   335
fun ap_split (Type("*", [T1,T2])) T3 u = 
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   336
      split_const(T1,T2,T3) $ 
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   337
      Abs("v", T1, 
2031
03a843f0f447 Ran expandshort
paulson
parents: 1754
diff changeset
   338
          ap_split T2 T3
03a843f0f447 Ran expandshort
paulson
parents: 1754
diff changeset
   339
             ((ap_split T1 (factors T2 ---> T3) (incr_boundvars 1 u)) $ 
03a843f0f447 Ran expandshort
paulson
parents: 1754
diff changeset
   340
              Bound 0))
1746
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   341
  | ap_split T T3 u = u;
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   342
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   343
(*Makes a nested tuple from a list, following the product type structure*)
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   344
fun mk_tuple (Type("*", [T1,T2])) tms = 
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   345
        mk_Pair (mk_tuple T1 tms, 
2031
03a843f0f447 Ran expandshort
paulson
parents: 1754
diff changeset
   346
                 mk_tuple T2 (drop (length (factors T1), tms)))
1746
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   347
  | mk_tuple T (t::_) = t;
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   348
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   349
(*Attempts to remove occurrences of split, and pair-valued parameters*)
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   350
val remove_split = rewrite_rule [split RS eq_reflection]  o  
2031
03a843f0f447 Ran expandshort
paulson
parents: 1754
diff changeset
   351
                   rule_by_tactic (ALLGOALS split_all_tac);
1746
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   352
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   353
(*Uncurries any Var of function type in the rule*)
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   354
fun split_rule_var (t as Var(v, Type("fun",[T1,T2])), rl) =
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   355
      let val T' = factors T1 ---> T2
2031
03a843f0f447 Ran expandshort
paulson
parents: 1754
diff changeset
   356
          val newt = ap_split T1 T2 (Var(v,T'))
03a843f0f447 Ran expandshort
paulson
parents: 1754
diff changeset
   357
          val cterm = Thm.cterm_of (#sign(rep_thm rl))
1746
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   358
      in
2031
03a843f0f447 Ran expandshort
paulson
parents: 1754
diff changeset
   359
          remove_split (instantiate ([], [(cterm t, cterm newt)]) rl)
1746
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   360
      end
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   361
  | split_rule_var (t,rl) = rl;
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   362
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   363
(*Uncurries ALL function variables occurring in a rule's conclusion*)
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   364
fun split_rule rl = foldr split_rule_var (term_vars (concl_of rl), rl)
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   365
                    |> standard;
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   366
f0c6aabc6c02 Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents: 1727
diff changeset
   367
end;