Theory HMM_Example
section ‹Example›
theory HMM_Example
imports
HMM_Implementation
"HOL-Library.AList_Mapping"
begin
text ‹
We would like to implement mappings as red-black trees
but they require the key type to be linearly ordered.
Unfortunately, ‹HOL-Analysis› fixes the product order to the element-wise order
and thus we cannot restore a linear order,
and the red-black tree implementation (from ‹HOL-Library›) cannot be used.
›
text ‹The ice cream example from Jurafsky and Martin \<^cite>‹"Jurafsky"›.›
definition
"states = [''start'', ''hot'', ''cold'', ''end'']"
definition observations :: "int list" where
"observations = [0, 1, 2, 3]"
definition
"kernel =
[
(''start'', [(''hot'',0.8 :: real), (''cold'',0.2)]),
(''hot'', [(''hot'',0.6 :: real), (''cold'',0.3), (''end'', 0.1)]),
(''cold'', [(''hot'',0.4 :: real), (''cold'',0.5), (''end'', 0.1)]),
(''end'', [(''end'', 1)])
]"
definition
"emissions =
[
(''hot'', [(1, 0.2), (2, 0.4), (3, 0.4)]),
(''cold'', [(1, 0.5), (2, 0.4), (3, 0.1)]),
(''end'', [(0, 1)])
]
"