author | haftmann |
Tue, 17 Aug 2010 14:19:11 +0200 | |
changeset 38458 | 2c46f628e6b7 |
parent 38140 | 05691ad74079 |
child 44367 | 74c08021ab2e |
permissions | -rw-r--r-- |
38140 | 1 |
(* Title: HOL/Subst/AList.thy |
1476 | 2 |
Author: Martin Coen, Cambridge University Computer Laboratory |
968 | 3 |
Copyright 1993 University of Cambridge |
4 |
*) |
|
5 |
||
38140 | 6 |
header {* Association Lists *} |
15635 | 7 |
|
8 |
theory AList |
|
9 |
imports Main |
|
10 |
begin |
|
968 | 11 |
|
38140 | 12 |
primrec alist_rec :: "[('a*'b)list, 'c, ['a, 'b, ('a*'b)list, 'c]=>'c] => 'c" |
13 |
where |
|
8874
3242637f668c
alist_rec and assoc are now defined using primrec and thus no longer
berghofe
parents:
3842
diff
changeset
|
14 |
"alist_rec [] c d = c" |
38140 | 15 |
| "alist_rec (p # al) c d = d (fst p) (snd p) al (alist_rec al c d)" |
968 | 16 |
|
38140 | 17 |
primrec assoc :: "['a,'b,('a*'b) list] => 'b" |
18 |
where |
|
8874
3242637f668c
alist_rec and assoc are now defined using primrec and thus no longer
berghofe
parents:
3842
diff
changeset
|
19 |
"assoc v d [] = d" |
38140 | 20 |
| "assoc v d (p # al) = (if v = fst p then snd p else assoc v d al)" |
968 | 21 |
|
15635 | 22 |
lemma alist_induct: |
38140 | 23 |
"P [] \<Longrightarrow> (!!x y xs. P xs \<Longrightarrow> P ((x,y) # xs)) \<Longrightarrow> P l" |
24823 | 24 |
by (induct l) auto |
15635 | 25 |
|
968 | 26 |
end |