equal
deleted
inserted
replaced
1 (* Title: HOL/Predicate_Compile.thy |
1 (* Title: HOL/Predicate_Compile.thy |
2 Author: Stefan Berghofer, Lukas Bulwahn, Florian Haftmann, TU Muenchen |
2 Author: Stefan Berghofer, Lukas Bulwahn, Florian Haftmann, TU Muenchen |
3 *) |
3 *) |
4 |
4 |
5 section {* A compiler for predicates defined by introduction rules *} |
5 section \<open>A compiler for predicates defined by introduction rules\<close> |
6 |
6 |
7 theory Predicate_Compile |
7 theory Predicate_Compile |
8 imports Random_Sequence Quickcheck_Exhaustive |
8 imports Random_Sequence Quickcheck_Exhaustive |
9 keywords "code_pred" :: thy_goal and "values" :: diag |
9 keywords "code_pred" :: thy_goal and "values" :: diag |
10 begin |
10 begin |
20 ML_file "Tools/Predicate_Compile/predicate_compile_pred.ML" |
20 ML_file "Tools/Predicate_Compile/predicate_compile_pred.ML" |
21 ML_file "Tools/Predicate_Compile/predicate_compile_specialisation.ML" |
21 ML_file "Tools/Predicate_Compile/predicate_compile_specialisation.ML" |
22 ML_file "Tools/Predicate_Compile/predicate_compile.ML" |
22 ML_file "Tools/Predicate_Compile/predicate_compile.ML" |
23 |
23 |
24 |
24 |
25 subsection {* Set membership as a generator predicate *} |
25 subsection \<open>Set membership as a generator predicate\<close> |
26 |
26 |
27 text {* |
27 text \<open> |
28 Introduce a new constant for membership to allow |
28 Introduce a new constant for membership to allow |
29 fine-grained control in code equations. |
29 fine-grained control in code equations. |
30 *} |
30 \<close> |
31 |
31 |
32 definition contains :: "'a set => 'a => bool" |
32 definition contains :: "'a set => 'a => bool" |
33 where "contains A x \<longleftrightarrow> x : A" |
33 where "contains A x \<longleftrightarrow> x : A" |
34 |
34 |
35 definition contains_pred :: "'a set => 'a => unit Predicate.pred" |
35 definition contains_pred :: "'a set => 'a => unit Predicate.pred" |
66 |
66 |
67 lemma contains_pred_notI: |
67 lemma contains_pred_notI: |
68 "\<not> contains A x ==> Predicate.eval (Predicate.not_pred (contains_pred A x)) ()" |
68 "\<not> contains A x ==> Predicate.eval (Predicate.not_pred (contains_pred A x)) ()" |
69 by(simp add: contains_pred_def contains_def not_pred_eq) |
69 by(simp add: contains_pred_def contains_def not_pred_eq) |
70 |
70 |
71 setup {* |
71 setup \<open> |
72 let |
72 let |
73 val Fun = Predicate_Compile_Aux.Fun |
73 val Fun = Predicate_Compile_Aux.Fun |
74 val Input = Predicate_Compile_Aux.Input |
74 val Input = Predicate_Compile_Aux.Input |
75 val Output = Predicate_Compile_Aux.Output |
75 val Output = Predicate_Compile_Aux.Output |
76 val Bool = Predicate_Compile_Aux.Bool |
76 val Bool = Predicate_Compile_Aux.Bool |
95 elim = @{thm contains_predE}, intro = @{thm contains_predI}, |
95 elim = @{thm contains_predE}, intro = @{thm contains_predI}, |
96 neg_intro = SOME @{thm contains_pred_notI}, definition = @{thm contains_pred_eq} |
96 neg_intro = SOME @{thm contains_pred_notI}, definition = @{thm contains_pred_eq} |
97 })], |
97 })], |
98 needs_random = []})) |
98 needs_random = []})) |
99 end |
99 end |
100 *} |
100 \<close> |
101 |
101 |
102 hide_const (open) contains contains_pred |
102 hide_const (open) contains contains_pred |
103 hide_fact (open) pred_of_setE pred_of_setI pred_of_set_eq |
103 hide_fact (open) pred_of_setE pred_of_setI pred_of_set_eq |
104 containsI containsE contains_predI contains_predE contains_pred_eq contains_pred_notI |
104 containsI containsE contains_predI contains_predE contains_pred_eq contains_pred_notI |
105 |
105 |