| author | wenzelm | 
| Fri, 12 Dec 1997 17:14:58 +0100 | |
| changeset 4397 | 7f760385a3a5 | 
| parent 3947 | eb707467f8c5 | 
| child 4570 | c04027ccc86e | 
| permissions | -rw-r--r-- | 
| 923 | 1 | (* Title: HOL/Prod.thy | 
| 2 | ID: Prod.thy,v 1.5 1994/08/19 09:04:27 lcp Exp | |
| 3 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | |
| 4 | Copyright 1992 University of Cambridge | |
| 5 | ||
| 6 | Ordered Pairs and the Cartesian product type. | |
| 7 | The unit type. | |
| 8 | *) | |
| 9 | ||
| 1755 
17001ecd546e
Added additional parent theory equalities because some proofs in
 berghofe parents: 
1674diff
changeset | 10 | Prod = Fun + equalities + | 
| 923 | 11 | |
| 2260 | 12 | |
| 13 | (** products **) | |
| 923 | 14 | |
| 15 | (* type definition *) | |
| 16 | ||
| 1558 | 17 | constdefs | 
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 18 | Pair_Rep :: ['a, 'b] => ['a, 'b] => bool | 
| 1558 | 19 | "Pair_Rep == (%a b. %x y. x=a & y=b)" | 
| 923 | 20 | |
| 3947 | 21 | global | 
| 22 | ||
| 1475 | 23 | typedef (Prod) | 
| 923 | 24 |   ('a, 'b) "*"          (infixr 20)
 | 
| 25 |     = "{f. ? a b. f = Pair_Rep (a::'a) (b::'b)}"
 | |
| 26 | ||
| 2260 | 27 | syntax (symbols) | 
| 28 |   "*"           :: [type, type] => type         ("(_ \\<times>/ _)" [21, 20] 20)
 | |
| 29 | ||
| 923 | 30 | |
| 31 | (* abstract constants and syntax *) | |
| 32 | ||
| 33 | consts | |
| 34 | fst :: "'a * 'b => 'a" | |
| 35 | snd :: "'a * 'b => 'b" | |
| 36 | split :: "[['a, 'b] => 'c, 'a * 'b] => 'c" | |
| 37 | prod_fun :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd" | |
| 38 | Pair :: "['a, 'b] => 'a * 'b" | |
| 39 |   Sigma         :: "['a set, 'a => 'b set] => ('a * 'b) set"
 | |
| 40 | ||
| 2260 | 41 | |
| 42 | (* patterns -- extends pre-defined type "pttrn" used in abstractions *) | |
| 43 | ||
| 3692 | 44 | types patterns | 
| 1068 | 45 | |
| 923 | 46 | syntax | 
| 3692 | 47 |   "@Tuple"      :: "['a, args] => 'a * 'b"       ("(1'(_,/ _'))")
 | 
| 923 | 48 | |
| 3692 | 49 |   "_pattern"    :: [pttrn, patterns] => pttrn    ("'(_,/_')")
 | 
| 50 |   ""            :: pttrn => patterns             ("_")
 | |
| 51 |   "_patterns"   :: [pttrn, patterns] => patterns ("_,/_")
 | |
| 2973 
184c7cd8043d
Added ability to have case expressions involving tuples. (via translation)
 nipkow parents: 
2886diff
changeset | 52 | |
| 3692 | 53 |   "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3SIGMA _:_./ _)" 10)
 | 
| 2260 | 54 |   "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ Times _" [81, 80] 80)
 | 
| 1636 | 55 | |
| 923 | 56 | translations | 
| 3842 | 57 | "(x, y, z)" == "(x, (y, z))" | 
| 58 | "(x, y)" == "Pair x y" | |
| 923 | 59 | |
| 3842 | 60 | "%(x,y,zs).b" == "split(%x (y,zs).b)" | 
| 61 | "%(x,y).b" == "split(%x y. b)" | |
| 2973 
184c7cd8043d
Added ability to have case expressions involving tuples. (via translation)
 nipkow parents: 
2886diff
changeset | 62 | "_abs (Pair x y) t" => "%(x,y).t" | 
| 
184c7cd8043d
Added ability to have case expressions involving tuples. (via translation)
 nipkow parents: 
2886diff
changeset | 63 | (* The last rule accommodates tuples in `case C ... (x,y) ... => ...' | 
| 
184c7cd8043d
Added ability to have case expressions involving tuples. (via translation)
 nipkow parents: 
2886diff
changeset | 64 | The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *) | 
| 2260 | 65 | |
| 3842 | 66 | "SIGMA x:A. B" => "Sigma A (%x. B)" | 
| 67 | "A Times B" => "Sigma A (_K B)" | |
| 1068 | 68 | |
| 2260 | 69 | syntax (symbols) | 
| 3692 | 70 |   "@Sigma"      :: "[pttrn, 'a set, 'b set] => ('a * 'b) set"   ("(3\\<Sigma> _\\<in>_./ _)" 10)
 | 
| 2260 | 71 |   "@Times"      :: "['a set, 'a => 'b set] => ('a * 'b) set"    ("_ \\<times> _" [81, 80] 80)
 | 
| 72 | ||
| 73 | ||
| 74 | (* definitions *) | |
| 1636 | 75 | |
| 3947 | 76 | local | 
| 77 | ||
| 923 | 78 | defs | 
| 79 | Pair_def "Pair a b == Abs_Prod(Pair_Rep a b)" | |
| 2393 | 80 | fst_def "fst p == @a. ? b. p = (a, b)" | 
| 81 | snd_def "snd p == @b. ? a. p = (a, b)" | |
| 1655 | 82 | split_def "split == (%c p. c (fst p) (snd p))" | 
| 972 
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
 clasohm parents: 
967diff
changeset | 83 | prod_fun_def "prod_fun f g == split(%x y.(f(x), g(y)))" | 
| 
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
 clasohm parents: 
967diff
changeset | 84 |   Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
 | 
| 923 | 85 | |
| 2260 | 86 | |
| 87 | ||
| 88 | (** unit **) | |
| 923 | 89 | |
| 3947 | 90 | global | 
| 91 | ||
| 2886 | 92 | typedef  unit = "{True}"
 | 
| 923 | 93 | |
| 94 | consts | |
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 95 |   "()"          :: unit                           ("'(')")
 | 
| 923 | 96 | |
| 3947 | 97 | local | 
| 98 | ||
| 923 | 99 | defs | 
| 2880 | 100 | Unity_def "() == Abs_unit True" | 
| 1273 | 101 | |
| 923 | 102 | end | 
| 1636 | 103 | |
| 104 | ML | |
| 105 | ||
| 106 | val print_translation = [("Sigma", dependent_tr' ("@Sigma", "@Times"))];
 |