src/HOL/Prod.thy
author berghofe
Tue May 21 13:42:53 1996 +0200 (1996-05-21)
changeset 1755 17001ecd546e
parent 1674 33aff4d854e4
child 1765 5db6b3ea0e28
permissions -rw-r--r--
Added additional parent theory equalities because some proofs in
Prod.ML depend on rules proved in equalities.ML
     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 
    10 Prod = Fun + equalities +
    11 
    12 (** Products **)
    13 
    14 (* type definition *)
    15 
    16 constdefs
    17   Pair_Rep      :: ['a, 'b] => ['a, 'b] => bool
    18   "Pair_Rep == (%a b. %x y. x=a & y=b)"
    19 
    20 typedef (Prod)
    21   ('a, 'b) "*"          (infixr 20)
    22     = "{f. ? a b. f = Pair_Rep (a::'a) (b::'b)}"
    23 
    24 
    25 (* abstract constants and syntax *)
    26 
    27 consts
    28   fst           :: "'a * 'b => 'a"
    29   snd           :: "'a * 'b => 'b"
    30   split         :: "[['a, 'b] => 'c, 'a * 'b] => 'c"
    31   prod_fun      :: "['a => 'b, 'c => 'd, 'a * 'c] => 'b * 'd"
    32   Pair          :: "['a, 'b] => 'a * 'b"
    33   Sigma         :: "['a set, 'a => 'b set] => ('a * 'b) set"
    34 
    35 (** Patterns -- extends pre-defined type "pttrn" used in abstractions **)
    36 types pttrns
    37 
    38 syntax
    39   "@Tuple"      :: "['a, args] => 'a * 'b"            ("(1'(_,/ _'))")
    40 
    41   "@pttrn"  :: [pttrn,pttrns] => pttrn              ("'(_,/_')")
    42   ""        ::  pttrn         => pttrns             ("_")
    43   "@pttrns" :: [pttrn,pttrns] => pttrns             ("_,/_")
    44 
    45   "@Sigma"  :: "[idt,'a set,'b set] => ('a * 'b)set"
    46                ("(3SIGMA _:_./ _)" 10)
    47   "@Times"  :: "['a set, 'a => 'b set] => ('a * 'b) set"
    48                ("_ Times _" [81,80] 80)
    49 
    50 translations
    51   "(x, y, z)"   == "(x, (y, z))"
    52   "(x, y)"      == "Pair x y"
    53 
    54   "%(x,y,zs).b"   == "split(%x (y,zs).b)"
    55   "%(x,y).b"      == "split(%x y.b)"
    56 (*<<<<<<< Prod.thy*)
    57 (* The <= direction fails if split has more than one argument because
    58    ast-matching fails. Otherwise it would work fine *)
    59 
    60 (*=======*)
    61 
    62   "SIGMA x:A. B"  =>  "Sigma A (%x.B)"
    63   "A Times B"     =>  "Sigma A (_K B)"
    64 
    65 (*>>>>>>> 1.13*)
    66 defs
    67   Pair_def      "Pair a b == Abs_Prod(Pair_Rep a b)"
    68   fst_def       "fst(p) == @a. ? b. p = (a, b)"
    69   snd_def       "snd(p) == @b. ? a. p = (a, b)"
    70   split_def     "split == (%c p. c (fst p) (snd p))"
    71   prod_fun_def  "prod_fun f g == split(%x y.(f(x), g(y)))"
    72   Sigma_def     "Sigma A B == UN x:A. UN y:B(x). {(x, y)}"
    73 
    74 (** Unit **)
    75 
    76 typedef (Unit)
    77   unit = "{p. p = True}"
    78 
    79 consts
    80   "()"          :: unit                           ("'(')")
    81 
    82 defs
    83   Unity_def     "() == Abs_Unit(True)"
    84 
    85 (* start 8bit 1 *)
    86 (* end 8bit 1 *)
    87 
    88 end
    89 (*<<<<<<< Prod.thy*)
    90 (*
    91 ML
    92 
    93 local open Syntax
    94 
    95 fun pttrn(_ $ s $ t) = const"@pttrn" $ s $ t;
    96 fun pttrns s t = const"@pttrns" $ s $ t;
    97 
    98 fun split2(Abs(x,T,t)) =
    99       let val (pats,u) = split1 t
   100       in (pttrns (Free(x,T)) pats, subst_bounds([free x],u)) end
   101   | split2(Const("split",_) $ r) =
   102       let val (pats,s) = split2(r)
   103           val (pats2,t) = split1(s)
   104       in (pttrns (pttrn pats) pats2, t) end
   105 and split1(Abs(x,T,t)) =  (Free(x,T), subst_bounds([free x],t))
   106   | split1(Const("split",_)$t) = split2(t);
   107 
   108 fun split_tr'(t::args) =
   109   let val (pats,ft) = split2(t)
   110   in list_comb(const"_lambda" $ pttrn pats $ ft, args) end;
   111 
   112 in
   113 
   114 val print_translation = [("split", split_tr')];
   115 
   116 end;
   117 *)
   118 (*=======*)
   119 
   120 ML
   121 
   122 val print_translation = [("Sigma", dependent_tr' ("@Sigma", "@Times"))];
   123 
   124 (*>>>>>>> 1.13*)