author | paulson |
Wed, 16 Jan 2002 17:53:22 +0100 | |
changeset 12777 | 70b2651af635 |
parent 9548 | 15bee2731e43 |
child 12789 | 459b5de466b2 |
permissions | -rw-r--r-- |
1478 | 1 |
(* Title: ZF/List |
516 | 2 |
ID: $Id$ |
1478 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
516 | 4 |
Copyright 1994 University of Cambridge |
5 |
||
6 |
Lists in Zermelo-Fraenkel Set Theory |
|
7 |
||
8 |
map is a binding operator -- it applies to meta-level functions, not |
|
9 |
object-level functions. This simplifies the final form of term_rec_conv, |
|
10 |
although complicating its derivation. |
|
11 |
*) |
|
12 |
||
9548 | 13 |
List = Datatype + ArithSimp + |
516 | 14 |
|
15 |
consts |
|
1478 | 16 |
list :: i=>i |
516 | 17 |
|
18 |
datatype |
|
581 | 19 |
"list(A)" = Nil | Cons ("a:A", "l: list(A)") |
516 | 20 |
|
21 |
||
2539 | 22 |
syntax |
23 |
"[]" :: i ("[]") |
|
24 |
"@List" :: is => i ("[(_)]") |
|
25 |
||
516 | 26 |
translations |
27 |
"[x, xs]" == "Cons(x, [xs])" |
|
28 |
"[x]" == "Cons(x, [])" |
|
29 |
"[]" == "Nil" |
|
30 |
||
31 |
||
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
32 |
consts |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
33 |
length :: i=>i |
1806 | 34 |
hd :: i=>i |
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
35 |
tl :: i=>i |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
36 |
|
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
37 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
38 |
"length([]) = 0" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
39 |
"length(Cons(a,l)) = succ(length(l))" |
1806 | 40 |
|
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
41 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
42 |
"hd(Cons(a,l)) = a" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
43 |
|
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
44 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
45 |
"tl([]) = []" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
46 |
"tl(Cons(a,l)) = l" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
47 |
|
6070 | 48 |
|
49 |
consts |
|
50 |
map :: [i=>i, i] => i |
|
51 |
set_of_list :: i=>i |
|
52 |
"@" :: [i,i]=>i (infixr 60) |
|
53 |
||
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
54 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
55 |
"map(f,[]) = []" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
56 |
"map(f,Cons(a,l)) = Cons(f(a), map(f,l))" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
57 |
|
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
58 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
59 |
"set_of_list([]) = 0" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
60 |
"set_of_list(Cons(a,l)) = cons(a, set_of_list(l))" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
61 |
|
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
62 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
63 |
"[] @ ys = ys" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
64 |
"(Cons(a,l)) @ ys = Cons(a, l @ ys)" |
1806 | 65 |
|
6070 | 66 |
|
67 |
consts |
|
68 |
rev :: i=>i |
|
69 |
flat :: i=>i |
|
70 |
list_add :: i=>i |
|
71 |
||
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
72 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
73 |
"rev([]) = []" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
74 |
"rev(Cons(a,l)) = rev(l) @ [a]" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
75 |
|
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
76 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
77 |
"flat([]) = []" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
78 |
"flat(Cons(l,ls)) = l @ flat(ls)" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
79 |
|
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
80 |
primrec |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
81 |
"list_add([]) = 0" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
82 |
"list_add(Cons(a,l)) = a #+ list_add(l)" |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
3840
diff
changeset
|
83 |
|
6070 | 84 |
consts |
1806 | 85 |
drop :: [i,i]=>i |
6070 | 86 |
|
87 |
primrec |
|
88 |
drop_0 "drop(0,l) = l" |
|
89 |
drop_SUCC "drop(succ(i), l) = tl (drop(i,l))" |
|
516 | 90 |
|
91 |
end |