author | nipkow |
Mon, 31 Oct 2005 01:43:22 +0100 | |
changeset 18049 | 156bba334c12 |
parent 17956 | 369e2af8ee45 |
child 18336 | 1a2e30b37ed3 |
permissions | -rw-r--r-- |
13462 | 1 |
(* Title: HOL/List.thy |
2 |
ID: $Id$ |
|
3 |
Author: Tobias Nipkow |
|
923 | 4 |
*) |
5 |
||
13114 | 6 |
header {* The datatype of finite lists *} |
13122 | 7 |
|
15131 | 8 |
theory List |
15140 | 9 |
imports PreList |
15131 | 10 |
begin |
923 | 11 |
|
13142 | 12 |
datatype 'a list = |
13366 | 13 |
Nil ("[]") |
14 |
| Cons 'a "'a list" (infixr "#" 65) |
|
923 | 15 |
|
15392 | 16 |
subsection{*Basic list processing functions*} |
15302 | 17 |
|
923 | 18 |
consts |
13366 | 19 |
"@" :: "'a list => 'a list => 'a list" (infixr 65) |
20 |
filter:: "('a => bool) => 'a list => 'a list" |
|
21 |
concat:: "'a list list => 'a list" |
|
22 |
foldl :: "('b => 'a => 'b) => 'b => 'a list => 'b" |
|
23 |
foldr :: "('a => 'b => 'b) => 'a list => 'b => 'b" |
|
24 |
hd:: "'a list => 'a" |
|
25 |
tl:: "'a list => 'a list" |
|
26 |
last:: "'a list => 'a" |
|
27 |
butlast :: "'a list => 'a list" |
|
28 |
set :: "'a list => 'a set" |
|
29 |
list_all2 :: "('a => 'b => bool) => 'a list => 'b list => bool" |
|
30 |
map :: "('a=>'b) => ('a list => 'b list)" |
|
31 |
nth :: "'a list => nat => 'a" (infixl "!" 100) |
|
32 |
list_update :: "'a list => nat => 'a => 'a list" |
|
33 |
take:: "nat => 'a list => 'a list" |
|
34 |
drop:: "nat => 'a list => 'a list" |
|
35 |
takeWhile :: "('a => bool) => 'a list => 'a list" |
|
36 |
dropWhile :: "('a => bool) => 'a list => 'a list" |
|
37 |
rev :: "'a list => 'a list" |
|
38 |
zip :: "'a list => 'b list => ('a * 'b) list" |
|
15425 | 39 |
upt :: "nat => nat => nat list" ("(1[_..</_'])") |
13366 | 40 |
remdups :: "'a list => 'a list" |
15110
78b5636eabc7
Added a number of new thms and the new function remove1
nipkow
parents:
15072
diff
changeset
|
41 |
remove1 :: "'a => 'a list => 'a list" |
13366 | 42 |
null:: "'a list => bool" |
43 |
"distinct":: "'a list => bool" |
|
44 |
replicate :: "nat => 'a => 'a list" |
|
15302 | 45 |
rotate1 :: "'a list \<Rightarrow> 'a list" |
46 |
rotate :: "nat \<Rightarrow> 'a list \<Rightarrow> 'a list" |
|
47 |
sublist :: "'a list => nat set => 'a list" |
|
17086 | 48 |
(* For efficiency *) |
49 |
mem :: "'a => 'a list => bool" (infixl 55) |
|
50 |
list_inter :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
|
51 |
list_ex :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool" |
|
52 |
list_all:: "('a => bool) => ('a list => bool)" |
|
53 |
itrev :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
|
54 |
filtermap :: "('a \<Rightarrow> 'b option) \<Rightarrow> 'a list \<Rightarrow> 'b list" |
|
55 |
map_filter :: "('a => 'b) => ('a => bool) => 'a list => 'b list" |
|
15302 | 56 |
|
923 | 57 |
|
13146 | 58 |
nonterminals lupdbinds lupdbind |
5077
71043526295f
* HOL/List: new function list_update written xs[i:=v] that updates the i-th
nipkow
parents:
4643
diff
changeset
|
59 |
|
923 | 60 |
syntax |
13366 | 61 |
-- {* list Enumeration *} |
62 |
"@list" :: "args => 'a list" ("[(_)]") |
|
923 | 63 |
|
13366 | 64 |
-- {* Special syntax for filter *} |
65 |
"@filter" :: "[pttrn, 'a list, bool] => 'a list" ("(1[_:_./ _])") |
|
923 | 66 |
|
13366 | 67 |
-- {* list update *} |
68 |
"_lupdbind":: "['a, 'a] => lupdbind" ("(2_ :=/ _)") |
|
69 |
"" :: "lupdbind => lupdbinds" ("_") |
|
70 |
"_lupdbinds" :: "[lupdbind, lupdbinds] => lupdbinds" ("_,/ _") |
|
71 |
"_LUpdate" :: "['a, lupdbinds] => 'a" ("_/[(_)]" [900,0] 900) |
|
5077
71043526295f
* HOL/List: new function list_update written xs[i:=v] that updates the i-th
nipkow
parents:
4643
diff
changeset
|
72 |
|
13366 | 73 |
upto:: "nat => nat => nat list" ("(1[_../_])") |
5427 | 74 |
|
923 | 75 |
translations |
13366 | 76 |
"[x, xs]" == "x#[xs]" |
77 |
"[x]" == "x#[]" |
|
78 |
"[x:xs . P]"== "filter (%x. P) xs" |
|