author | haftmann |
Sun, 08 Mar 2009 15:25:28 +0100 | |
changeset 30374 | 7311a1546d85 |
child 30810 | 83642621425a |
permissions | -rw-r--r-- |
haftmann@30374 | 1 |
theory Predicate_Compile |
haftmann@30374 | 2 |
imports Complex_Main Lattice_Syntax |
haftmann@30374 | 3 |
uses "predicate_compile.ML" |
haftmann@30374 | 4 |
begin |
haftmann@30374 | 5 |
|
haftmann@30374 | 6 |
setup {* Predicate_Compile.setup *} |
haftmann@30374 | 7 |
|
haftmann@30374 | 8 |
primrec "next" :: "('a Predicate.pred \<Rightarrow> ('a \<times> 'a Predicate.pred) option) |
haftmann@30374 | 9 |
\<Rightarrow> 'a Predicate.seq \<Rightarrow> ('a \<times> 'a Predicate.pred) option" where |
haftmann@30374 | 10 |
"next yield Predicate.Empty = None" |
haftmann@30374 | 11 |
| "next yield (Predicate.Insert x P) = Some (x, P)" |
haftmann@30374 | 12 |
| "next yield (Predicate.Join P xq) = (case yield P |
haftmann@30374 | 13 |
of None \<Rightarrow> next yield xq | Some (x, Q) \<Rightarrow> Some (x, Predicate.Seq (\<lambda>_. Predicate.Join Q xq)))" |
haftmann@30374 | 14 |
|
haftmann@30374 | 15 |
primrec pull :: "('a Predicate.pred \<Rightarrow> ('a \<times> 'a Predicate.pred) option) |
haftmann@30374 | 16 |
\<Rightarrow> nat \<Rightarrow> 'a Predicate.pred \<Rightarrow> 'a list \<times> 'a Predicate.pred" where |
haftmann@30374 | 17 |
"pull yield 0 P = ([], \<bottom>)" |
haftmann@30374 | 18 |
| "pull yield (Suc n) P = (case yield P |
haftmann@30374 | 19 |
of None \<Rightarrow> ([], \<bottom>) | Some (x, Q) \<Rightarrow> let (xs, R) = pull yield n Q in (x # xs, R))" |
haftmann@30374 | 20 |
|
haftmann@30374 | 21 |
end |