1theory ToyList
2imports Main
3begin
4
5no_notation Nil ("[]") and Cons (infixr "#" 65) and append (infixr "@" 65)
6hide_type list
7hide_const rev
8
9datatype 'a list = Nil                          ("[]")
10                 | Cons 'a "'a list"            (infixr "#" 65)
11
12(* This is the append function: *)
13primrec app :: "'a list => 'a list => 'a list"  (infixr "@" 65)
14where
15"[] @ ys       = ys" |
16"(x # xs) @ ys = x # (xs @ ys)"
17
18primrec rev :: "'a list => 'a list" where
19"rev []        = []" |
20"rev (x # xs)  = (rev xs) @ (x # [])"
21