doc-src/Exercises/2001/a3/Trie3.thy
author nipkow
Sun, 25 Jan 2004 00:42:22 +0100
changeset 14360 e654599b114e
parent 13739 f5d0a66c8124
permissions -rw-r--r--
Added an exception handler and error msg.

(*<*)
theory Trie3 = Main:
(*>*)

text {* Instead of association lists we can also use partial functions
that map letters to subtrees. Partiality can be modelled with the help
of type @{typ "'a option"}: if @{term f} is a function of type
\mbox{@{typ "'a \<Rightarrow> 'b option"}}, set @{term "f a = Some b"}
if @{term a} should be mapped to some @{term b} and set @{term "f a =
None"} otherwise.  *}

datatype ('a, 'v) trie = Trie  "'v option" "'a \<Rightarrow> ('a,'v) trie option";

text{* Modify the definitions of @{term lookup} and @{term modify}
accordingly and show the same correctness theorem as above. *}

(*<*)
end;
(*>*)