author | boehmes |
Wed, 15 Dec 2010 10:12:44 +0100 | |
changeset 41127 | 2ea84c8535c6 |
parent 41072 | 9f9bc1bdacef |
child 41281 | 679118e35378 |
permissions | -rw-r--r-- |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
1 |
(* Title: HOL/Tools/SMT/smt_word.ML |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
2 |
Author: Sascha Boehme, TU Muenchen |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
3 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
4 |
SMT setup for words. |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
5 |
*) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
6 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
7 |
signature SMT_WORD = |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
8 |
sig |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
9 |
val setup: theory -> theory |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
10 |
end |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
11 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
12 |
structure SMT_Word: SMT_WORD = |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
13 |
struct |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
14 |
|
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
15 |
structure B = SMT_Builtin |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
16 |
|
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
17 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
18 |
(* utilities *) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
19 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
20 |
fun dest_binT T = |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
21 |
(case T of |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
22 |
Type (@{type_name "Numeral_Type.num0"}, _) => 0 |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
23 |
| Type (@{type_name "Numeral_Type.num1"}, _) => 1 |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
24 |
| Type (@{type_name "Numeral_Type.bit0"}, [T]) => 2 * dest_binT T |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
25 |
| Type (@{type_name "Numeral_Type.bit1"}, [T]) => 1 + 2 * dest_binT T |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
26 |
| _ => raise TYPE ("dest_binT", [T], [])) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
27 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
28 |
fun is_wordT (Type (@{type_name word}, _)) = true |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
29 |
| is_wordT _ = false |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
30 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
31 |
fun dest_wordT (Type (@{type_name word}, [T])) = dest_binT T |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
32 |
| dest_wordT T = raise TYPE ("dest_wordT", [T], []) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
33 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
34 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
35 |
(* SMT-LIB logic *) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
36 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
37 |
fun smtlib_logic ts = |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
38 |
if exists (Term.exists_type (Term.exists_subtype is_wordT)) ts |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
39 |
then SOME "QF_AUFBV" |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
40 |
else NONE |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
41 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
42 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
43 |
(* SMT-LIB builtins *) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
44 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
45 |
local |
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
46 |
val smtlibC = SMTLIB_Interface.smtlibC |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
47 |
|
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
48 |
val wordT = @{typ "'a::len word"} |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
49 |
|
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
50 |
fun index1 n i = n ^ "[" ^ string_of_int i ^ "]" |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
51 |
fun index2 n i j = n ^ "[" ^ string_of_int i ^ ":" ^ string_of_int j ^ "]" |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
52 |
|
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
53 |
fun word_typ (Type (@{type_name word}, [T])) = |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
54 |
Option.map (index1 "BitVec") (try dest_binT T) |
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
55 |
| word_typ _ = NONE |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
56 |
|
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
57 |
fun word_num (Type (@{type_name word}, [T])) i = |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
58 |
Option.map (index1 ("bv" ^ string_of_int i)) (try dest_binT T) |
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
59 |
| word_num _ _ = NONE |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
60 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
61 |
fun if_fixed n T ts = |
41127
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
62 |
let val (Us, U) = Term.strip_type T |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
63 |
in |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
64 |
if forall (can dest_wordT) (U :: Us) then |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
65 |
SOME (((n, length Us), T), ts, T) |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
66 |
else NONE |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
67 |
end |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
68 |
|
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
69 |
fun if_fixed' n T ts = |
41127
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
70 |
let val Ts = Term.binder_types T |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
71 |
in |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
72 |
if forall (can dest_wordT) Ts then SOME (((n, length Ts), T), ts, T) |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
73 |
else NONE |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
74 |
end |
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
75 |
|
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
76 |
fun add_word_fun f (t, n) = |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
77 |
B.add_builtin_fun smtlibC (Term.dest_Const t, K (f n)) |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
78 |
|
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
79 |
fun add_word_fun' f (t, n) = add_word_fun f (t, n) |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
80 |
|
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
81 |
fun dest_word_funT (Type ("fun", [T, U])) = (dest_wordT T, dest_wordT U) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
82 |
| dest_word_funT T = raise TYPE ("dest_word_funT", [T], []) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
83 |
fun dest_nat (@{const nat} $ n :: ts) = (snd (HOLogic.dest_number n), ts) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
84 |
| dest_nat ts = raise TERM ("dest_nat", ts) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
85 |
fun dest_nat_word_funT (T, ts) = |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
86 |
(dest_word_funT (Term.range_type T), dest_nat ts) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
87 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
88 |
fun shift n T ts = |
41127
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
89 |
let |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
90 |
val U = Term.domain_type T |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
91 |
val T' = [U, U] ---> U |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
92 |
in |
41127
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
93 |
(case (can dest_wordT T', ts) of |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
94 |
(true, [t, u]) => |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
95 |
(case try HOLogic.dest_number u of |
41127
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
96 |
SOME (_, i) => SOME (((n, 2), T'), [t, HOLogic.mk_number T' i], T') |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
97 |
| NONE => NONE) (* FIXME: also support non-numerical shifts *) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
98 |
| _ => NONE) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
99 |
end |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
100 |
|
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
101 |
fun extract n T ts = |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
102 |
try dest_nat_word_funT (T, ts) |
41127
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
103 |
|> Option.map (fn ((_, i), (lb, ts')) => |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
104 |
let val T' = Term.range_type T |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
105 |
in (((index2 n (i + lb - 1) lb, 1), T'), ts', T') end) |
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
106 |
|
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
107 |
fun extend n T ts = |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
108 |
(case try dest_word_funT T of |
41127
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
109 |
SOME (i, j) => |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
110 |
if j-i >= 0 then SOME (((index1 n (j-i), 1), T), ts, T) |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
111 |
else NONE |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
112 |
| _ => NONE) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
113 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
114 |
fun rotate n T ts = |
41127
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
115 |
let val T' = Term.range_type T |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
116 |
in |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
117 |
try dest_nat ts |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
118 |
|> Option.map (fn (i, ts') => (((index1 n i, 1), T'), ts', T')) |
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
boehmes
parents:
41072
diff
changeset
|
119 |
end |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
120 |
in |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
121 |
|
41061
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
122 |
val setup_builtins = |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
123 |
B.add_builtin_typ smtlibC (wordT, word_typ, word_num) #> |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
124 |
fold (add_word_fun' if_fixed) [ |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
125 |
(@{term "uminus :: 'a::len word => _"}, "bvneg"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
126 |
(@{term "plus :: 'a::len word => _"}, "bvadd"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
127 |
(@{term "minus :: 'a::len word => _"}, "bvsub"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
128 |
(@{term "times :: 'a::len word => _"}, "bvmul"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
129 |
(@{term "bitNOT :: 'a::len word => _"}, "bvnot"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
130 |
(@{term "bitAND :: 'a::len word => _"}, "bvand"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
131 |
(@{term "bitOR :: 'a::len word => _"}, "bvor"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
132 |
(@{term "bitXOR :: 'a::len word => _"}, "bvxor"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
133 |
(@{term "word_cat :: 'a::len word => _"}, "concat") ] #> |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
134 |
fold (add_word_fun shift) [ |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
135 |
(@{term "shiftl :: 'a::len word => _ "}, "bvshl"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
136 |
(@{term "shiftr :: 'a::len word => _"}, "bvlshr"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
137 |
(@{term "sshiftr :: 'a::len word => _"}, "bvashr") ] #> |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
138 |
add_word_fun extract |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
139 |
(@{term "slice :: _ => 'a::len word => _"}, "extract") #> |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
140 |
fold (add_word_fun extend) [ |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
141 |
(@{term "ucast :: 'a::len word => _"}, "zero_extend"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
142 |
(@{term "scast :: 'a::len word => _"}, "sign_extend") ] #> |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
143 |
fold (add_word_fun rotate) [ |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
144 |
(@{term word_rotl}, "rotate_left"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
145 |
(@{term word_rotr}, "rotate_right") ] #> |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
146 |
fold (add_word_fun' if_fixed') [ |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
147 |
(@{term "less :: 'a::len word => _"}, "bvult"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
148 |
(@{term "less_eq :: 'a::len word => _"}, "bvule"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
149 |
(@{term word_sless}, "bvslt"), |
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
boehmes
parents:
41060
diff
changeset
|
150 |
(@{term word_sle}, "bvsle") ] |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
151 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
152 |
end |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
153 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
154 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
155 |
(* setup *) |
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
156 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
157 |
val setup = |
41072
9f9bc1bdacef
be more flexible: store SMT built-in symbols in generic contexts (not in theory contexts)
boehmes
parents:
41061
diff
changeset
|
158 |
Context.theory_map ( |
9f9bc1bdacef
be more flexible: store SMT built-in symbols in generic contexts (not in theory contexts)
boehmes
parents:
41061
diff
changeset
|
159 |
SMTLIB_Interface.add_logic (20, smtlib_logic) #> |
9f9bc1bdacef
be more flexible: store SMT built-in symbols in generic contexts (not in theory contexts)
boehmes
parents:
41061
diff
changeset
|
160 |
setup_builtins) |
41060
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
161 |
|
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
boehmes
parents:
diff
changeset
|
162 |
end |