equal
deleted
inserted
replaced
1 (* Title: Subst/AList.thy |
1 (* ID: $Id$ |
2 ID: $Id$ |
|
3 Author: Martin Coen, Cambridge University Computer Laboratory |
2 Author: Martin Coen, Cambridge University Computer Laboratory |
4 Copyright 1993 University of Cambridge |
3 Copyright 1993 University of Cambridge |
5 |
4 |
6 Association lists. |
|
7 *) |
5 *) |
8 |
6 |
9 AList = Main + |
7 header{*Association Lists*} |
|
8 |
|
9 theory AList |
|
10 imports Main |
|
11 begin |
10 |
12 |
11 consts |
13 consts |
12 alist_rec :: "[('a*'b)list, 'c, ['a, 'b, ('a*'b)list, 'c]=>'c] => 'c" |
14 alist_rec :: "[('a*'b)list, 'c, ['a, 'b, ('a*'b)list, 'c]=>'c] => 'c" |
13 assoc :: "['a,'b,('a*'b) list] => 'b" |
15 assoc :: "['a,'b,('a*'b) list] => 'b" |
14 |
16 |
18 |
20 |
19 primrec |
21 primrec |
20 "assoc v d [] = d" |
22 "assoc v d [] = d" |
21 "assoc v d (p # al) = (if v = fst p then snd p else assoc v d al)" |
23 "assoc v d (p # al) = (if v = fst p then snd p else assoc v d al)" |
22 |
24 |
|
25 |
|
26 lemma alist_induct: |
|
27 "[| P([]); |
|
28 !!x y xs. P(xs) ==> P((x,y)#xs) |] ==> P(l)" |
|
29 by (induct_tac "l", auto) |
|
30 |
23 end |
31 end |