equal
deleted
inserted
replaced
4 |
4 |
5 header {* SMT-specific definitions and basic tools *} |
5 header {* SMT-specific definitions and basic tools *} |
6 |
6 |
7 theory SMT_Base |
7 theory SMT_Base |
8 imports Real "~~/src/HOL/Word/Word" |
8 imports Real "~~/src/HOL/Word/Word" |
9 "~~/src/HOL/Decision_Procs/Dense_Linear_Order" |
|
10 uses |
9 uses |
11 "~~/src/Tools/cache_io.ML" |
10 "~~/src/Tools/cache_io.ML" |
12 ("Tools/smt_normalize.ML") |
11 ("Tools/smt_normalize.ML") |
13 ("Tools/smt_monomorph.ML") |
12 ("Tools/smt_monomorph.ML") |
14 ("Tools/smt_translate.ML") |
13 ("Tools/smt_translate.ML") |
39 |
38 |
40 definition trigger :: "pattern list \<Rightarrow> bool \<Rightarrow> bool" |
39 definition trigger :: "pattern list \<Rightarrow> bool \<Rightarrow> bool" |
41 where "trigger _ P = P" |
40 where "trigger _ P = P" |
42 |
41 |
43 |
42 |
|
43 |
44 section {* Arithmetic *} |
44 section {* Arithmetic *} |
45 |
45 |
46 text {* |
46 text {* |
47 The sign of @{term "op mod :: int \<Rightarrow> int \<Rightarrow> int"} follows the sign of the |
47 The sign of @{term "op mod :: int \<Rightarrow> int \<Rightarrow> int"} follows the sign of the |
48 divisor. In contrast to that, the sign of the following operation is that of |
48 divisor. In contrast to that, the sign of the following operation is that of |
51 |
51 |
52 definition rem :: "int \<Rightarrow> int \<Rightarrow> int" (infixl "rem" 70) |
52 definition rem :: "int \<Rightarrow> int \<Rightarrow> int" (infixl "rem" 70) |
53 where "a rem b = |
53 where "a rem b = |
54 (if (a \<ge> 0 \<and> b < 0) \<or> (a < 0 \<and> b \<ge> 0) then - (a mod b) else a mod b)" |
54 (if (a \<ge> 0 \<and> b < 0) \<or> (a < 0 \<and> b \<ge> 0) then - (a mod b) else a mod b)" |
55 |
55 |
56 text {* A decision procedure for linear real arithmetic: *} |
|
57 |
|
58 setup {* |
|
59 Arith_Data.add_tactic "Ferrante-Rackoff" (K FerranteRackoff.dlo_tac) |
|
60 *} |
|
61 |
56 |
62 |
57 |
63 section {* Bitvectors *} |
58 section {* Bitvectors *} |
64 |
59 |
65 text {* |
60 text {* |
85 |
80 |
86 definition bv_ashr :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> 'a word" |
81 definition bv_ashr :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> 'a word" |
87 where "bv_ashr w1 w2 = (w1 >>> unat w2)" |
82 where "bv_ashr w1 w2 = (w1 >>> unat w2)" |
88 |
83 |
89 |
84 |
|
85 |
90 section {* Higher-Order Encoding *} |
86 section {* Higher-Order Encoding *} |
91 |
87 |
92 definition "apply" where "apply f x = f x" |
88 definition "apply" where "apply f x = f x" |
93 |
89 |
94 definition array_ext where "array_ext a b = (SOME x. a = b \<or> a x \<noteq> b x)" |
90 definition array_ext where "array_ext a b = (SOME x. a = b \<or> a x \<noteq> b x)" |
100 thus "f x = y" by simp |
96 thus "f x = y" by simp |
101 qed (auto simp add: ext) |
97 qed (auto simp add: ext) |
102 |
98 |
103 lemmas array_rules = |
99 lemmas array_rules = |
104 ext fun_upd_apply fun_upd_same fun_upd_other fun_upd_upd fun_upd_eq apply_def |
100 ext fun_upd_apply fun_upd_same fun_upd_other fun_upd_upd fun_upd_eq apply_def |
|
101 |
105 |
102 |
106 |
103 |
107 section {* First-order logic *} |
104 section {* First-order logic *} |
108 |
105 |
109 text {* |
106 text {* |
128 |
125 |
129 definition iff :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infix "iff" 50) where |
126 definition iff :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infix "iff" 50) where |
130 "(x iff y) = (x = y)" |
127 "(x iff y) = (x = y)" |
131 |
128 |
132 |
129 |
|
130 |
133 section {* Setup *} |
131 section {* Setup *} |
134 |
132 |
135 use "Tools/smt_normalize.ML" |
133 use "Tools/smt_normalize.ML" |
136 use "Tools/smt_monomorph.ML" |
134 use "Tools/smt_monomorph.ML" |
137 use "Tools/smt_translate.ML" |
135 use "Tools/smt_translate.ML" |