src/ZF/List.thy
author clasohm
Tue Feb 06 12:27:17 1996 +0100 (1996-02-06)
changeset 1478 2b8c2a7547ab
parent 1401 0c439768f45c
child 1806 12708740f58d
permissions -rw-r--r--
expanded tabs
clasohm@1478
     1
(*  Title:      ZF/List
lcp@516
     2
    ID:         $Id$
clasohm@1478
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
lcp@516
     4
    Copyright   1994  University of Cambridge
lcp@516
     5
lcp@516
     6
Lists in Zermelo-Fraenkel Set Theory 
lcp@516
     7
lcp@516
     8
map is a binding operator -- it applies to meta-level functions, not 
lcp@516
     9
object-level functions.  This simplifies the final form of term_rec_conv,
lcp@516
    10
although complicating its derivation.
lcp@516
    11
*)
lcp@516
    12
lcp@810
    13
List = Datatype + 
lcp@516
    14
lcp@516
    15
consts
clasohm@1478
    16
  "@"        :: [i,i]=>i                        (infixr 60)
clasohm@1401
    17
  list_rec   :: [i, i, [i,i,i]=>i] => i
clasohm@1478
    18
  map        :: [i=>i, i] => i
clasohm@1401
    19
  length,rev :: i=>i
clasohm@1401
    20
  flat       :: i=>i
clasohm@1401
    21
  list_add   :: i=>i
clasohm@1401
    22
  hd,tl      :: i=>i
clasohm@1478
    23
  drop       :: [i,i]=>i
lcp@516
    24
lcp@516
    25
 (* List Enumeration *)
clasohm@1478
    26
 "[]"        :: i                                       ("[]")
clasohm@1478
    27
 "@List"     :: is => i                                 ("[(_)]")
clasohm@124
    28
clasohm@1478
    29
  list       :: i=>i
lcp@516
    30
lcp@516
    31
  
lcp@516
    32
datatype
lcp@581
    33
  "list(A)" = Nil | Cons ("a:A", "l: list(A)")
lcp@516
    34
lcp@516
    35
lcp@516
    36
translations
lcp@516
    37
  "[x, xs]"     == "Cons(x, [xs])"
lcp@516
    38
  "[x]"         == "Cons(x, [])"
lcp@516
    39
  "[]"          == "Nil"
lcp@516
    40
lcp@516
    41
lcp@753
    42
defs
lcp@516
    43
clasohm@1478
    44
  hd_def        "hd(l)       == list_case(0, %x xs.x, l)"
clasohm@1478
    45
  tl_def        "tl(l)       == list_case(Nil, %x xs.xs, l)"
clasohm@1478
    46
  drop_def      "drop(i,l)   == rec(i, l, %j r. tl(r))"
lcp@516
    47
lcp@516
    48
  list_rec_def
lcp@516
    49
      "list_rec(l,c,h) == Vrec(l, %l g.list_case(c, %x xs. h(x, xs, g`xs), l))"
lcp@516
    50
lcp@516
    51
  map_def       "map(f,l)    == list_rec(l,  Nil,  %x xs r. Cons(f(x), r))"
lcp@516
    52
  length_def    "length(l)   == list_rec(l,  0,  %x xs r. succ(r))"
lcp@516
    53
  app_def       "xs@ys       == list_rec(xs, ys, %x xs r. Cons(x,r))"
lcp@516
    54
  rev_def       "rev(l)      == list_rec(l,  Nil,  %x xs r. r @ [x])"
lcp@516
    55
  flat_def      "flat(ls)    == list_rec(ls, Nil,  %l ls r. l @ r)"
lcp@516
    56
  list_add_def  "list_add(l) == list_rec(l, 0,  %x xs r. x#+r)"
lcp@516
    57
end