src/HOL/Subst/AList.thy
author krauss
Sun, 21 Aug 2011 22:13:04 +0200
changeset 44367 74c08021ab2e
parent 38140 05691ad74079
permissions -rw-r--r--
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.

(*  Title:      HOL/Subst/AList.thy
    Author:     Martin Coen, Cambridge University Computer Laboratory
    Copyright   1993  University of Cambridge
*)

header {* Association Lists *}

theory AList
imports Main
begin

primrec alist_rec :: "[('a*'b)list, 'c, ['a, 'b, ('a*'b)list, 'c]=>'c] => 'c"
where
  "alist_rec [] c d = c"
| "alist_rec (p # al) c d = d (fst p) (snd p) al (alist_rec al c d)"

primrec assoc :: "['a,'b,('a*'b) list] => 'b"
where
  "assoc v d [] = d"
| "assoc v d (p # al) = (if v = fst p then snd p else assoc v d al)"

lemma alist_induct:
    "P [] \<Longrightarrow> (!!x y xs. P xs \<Longrightarrow> P ((x,y) # xs)) \<Longrightarrow> P l"
  by (induct l) auto



end