equal
deleted
inserted
replaced
2 imports Complex_Main Code_Index Lattice_Syntax |
2 imports Complex_Main Code_Index Lattice_Syntax |
3 uses "predicate_compile.ML" |
3 uses "predicate_compile.ML" |
4 begin |
4 begin |
5 |
5 |
6 setup {* Predicate_Compile.setup *} |
6 setup {* Predicate_Compile.setup *} |
|
7 |
|
8 ML {* |
|
9 OuterSyntax.local_theory_to_proof "code_pred" "sets up goal for cases rule from given introduction rules and compiles predicate" |
|
10 OuterKeyword.thy_goal (OuterParse.term_group >> Predicate_Compile.code_pred_cmd) |
|
11 *} |
7 |
12 |
8 primrec "next" :: "('a Predicate.pred \<Rightarrow> ('a \<times> 'a Predicate.pred) option) |
13 primrec "next" :: "('a Predicate.pred \<Rightarrow> ('a \<times> 'a Predicate.pred) option) |
9 \<Rightarrow> 'a Predicate.seq \<Rightarrow> ('a \<times> 'a Predicate.pred) option" where |
14 \<Rightarrow> 'a Predicate.seq \<Rightarrow> ('a \<times> 'a Predicate.pred) option" where |
10 "next yield Predicate.Empty = None" |
15 "next yield Predicate.Empty = None" |
11 | "next yield (Predicate.Insert x P) = Some (x, P)" |
16 | "next yield (Predicate.Insert x P) = Some (x, P)" |
32 yieldn 0 (*replace with number of elements to retrieve*) |
37 yieldn 0 (*replace with number of elements to retrieve*) |
33 @{code "\<bottom> :: 'a Predicate.pred"} (*replace bottom with sequence to evaluate*) |
38 @{code "\<bottom> :: 'a Predicate.pred"} (*replace bottom with sequence to evaluate*) |
34 end |
39 end |
35 *} |
40 *} |
36 |
41 |
|
42 section {* Example for user interface *} |
|
43 |
|
44 inductive append :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
|
45 where |
|
46 "append [] ys ys" |
|
47 | "append xs' ys zs' \<Longrightarrow> append (x#xs') ys (x#zs')" |
|
48 |
|
49 code_pred append |
|
50 using assms by (rule append.cases) |
|
51 |
|
52 thm append_cases |
|
53 |
|
54 |
37 end |
55 end |