author | haftmann |
Wed, 01 Dec 2010 18:00:40 +0100 | |
changeset 40858 | 69ab03d29c92 |
parent 40691 | a68f64f99832 |
child 41059 | d2b1fc1b8e19 |
permissions | -rw-r--r-- |
40277 | 1 |
(* Title: HOL/Tools/SMT/smt_builtin.ML |
2 |
Author: Sascha Boehme, TU Muenchen |
|
3 |
||
4 |
Crafted collection of SMT built-in symbols. |
|
5 |
||
6 |
FIXME: This list is currently not automatically kept synchronized with the |
|
7 |
remaining implementation. |
|
8 |
*) |
|
9 |
||
10 |
signature SMT_BUILTIN = |
|
11 |
sig |
|
40686
4725ed462387
swap names for built-in tester functions (to better reflect the intuition of what they do);
boehmes
parents:
40681
diff
changeset
|
12 |
val is_builtin: Proof.context -> string * typ -> bool |
40277 | 13 |
val is_partially_builtin: Proof.context -> string * typ -> bool |
14 |
end |
|
15 |
||
16 |
structure SMT_Builtin: SMT_BUILTIN = |
|
17 |
struct |
|
18 |
||
40677
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
19 |
fun is_arithT T = |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
20 |
(case T of |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
21 |
@{typ int} => true |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
22 |
| @{typ nat} => true |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
23 |
| Type ("RealDef.real", []) => true |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
24 |
| _ => false) |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
25 |
|
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
26 |
fun is_arithT_dom (Type (@{type_name fun}, [T, _])) = is_arithT T |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
27 |
| is_arithT_dom _ = false |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
28 |
fun is_arithT_ran (Type (@{type_name fun}, [_, T])) = is_arithT T |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
29 |
| is_arithT_ran _ = false |
40277 | 30 |
|
31 |
val builtins = Symtab.make [ |
|
32 |
||
33 |
(* Pure constants *) |
|
34 |
(@{const_name all}, K true), |
|
35 |
(@{const_name "=="}, K true), |
|
36 |
(@{const_name "==>"}, K true), |
|
37 |
(@{const_name Trueprop}, K true), |
|
38 |
||
39 |
(* logical constants *) |
|
40 |
(@{const_name All}, K true), |
|
41 |
(@{const_name Ex}, K true), |
|
42 |
(@{const_name Ball}, K true), |
|
43 |
(@{const_name Bex}, K true), |
|
44 |
(@{const_name Ex1}, K true), |
|
45 |
(@{const_name True}, K true), |
|
46 |
(@{const_name False}, K true), |
|
47 |
(@{const_name Not}, K true), |
|
48 |
(@{const_name HOL.conj}, K true), |
|
49 |
(@{const_name HOL.disj}, K true), |
|
50 |
(@{const_name HOL.implies}, K true), |
|
51 |
||
52 |
(* term abbreviations *) |
|
53 |
(@{const_name If}, K true), |
|
54 |
(@{const_name bool.bool_case}, K true), |
|
55 |
(@{const_name Let}, K true), |
|
40681
872b08416fb4
be more precise: only treat constant 'distinct' applied to an explicit list as built-in
boehmes
parents:
40677
diff
changeset
|
56 |
(* (@{const_name distinct}, K true), -- not a real builtin, only when |
872b08416fb4
be more precise: only treat constant 'distinct' applied to an explicit list as built-in
boehmes
parents:
40677
diff
changeset
|
57 |
applied to an explicit list *) |
40277 | 58 |
|
59 |
(* technicalities *) |
|
60 |
(@{const_name SMT.pat}, K true), |
|
61 |
(@{const_name SMT.nopat}, K true), |
|
62 |
(@{const_name SMT.trigger}, K true), |
|
40664 | 63 |
(@{const_name SMT.weight}, K true), |
40277 | 64 |
(@{const_name SMT.fun_app}, K true), |
65 |
(@{const_name SMT.z3div}, K true), |
|
66 |
(@{const_name SMT.z3mod}, K true), |
|
67 |
||
68 |
(* equality *) |
|
69 |
(@{const_name HOL.eq}, K true), |
|
70 |
||
71 |
(* numerals *) |
|
40691
a68f64f99832
fix check for builtinness of 0 and 1 -- these aren't functions
blanchet
parents:
40686
diff
changeset
|
72 |
(@{const_name zero_class.zero}, is_arithT), |
a68f64f99832
fix check for builtinness of 0 and 1 -- these aren't functions
blanchet
parents:
40686
diff
changeset
|
73 |
(@{const_name one_class.one}, is_arithT), |
40277 | 74 |
(@{const_name Int.Pls}, K true), |
75 |
(@{const_name Int.Min}, K true), |
|
76 |
(@{const_name Int.Bit0}, K true), |
|
77 |
(@{const_name Int.Bit1}, K true), |
|
40677
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
78 |
(@{const_name number_of}, is_arithT_ran), |
40277 | 79 |
|
80 |
(* arithmetic *) |
|
81 |
(@{const_name nat}, K true), |
|
82 |
(@{const_name of_nat}, K true), |
|
83 |
(@{const_name Suc}, K true), |
|
40677
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
84 |
(@{const_name plus}, is_arithT_dom), |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
85 |
(@{const_name uminus}, is_arithT_dom), |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
86 |
(@{const_name minus}, is_arithT_dom), |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
87 |
(@{const_name abs}, is_arithT_dom), |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
88 |
(@{const_name min}, is_arithT_dom), |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
89 |
(@{const_name max}, is_arithT_dom), |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
90 |
(@{const_name less}, is_arithT_dom), |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
91 |
(@{const_name less_eq}, is_arithT_dom), |
40277 | 92 |
|
93 |
(* pairs *) |
|
94 |
(@{const_name fst}, K true), |
|
95 |
(@{const_name snd}, K true), |
|
96 |
(@{const_name Pair}, K true) |
|
97 |
||
98 |
] |
|
99 |
||
100 |
val all_builtins = |
|
101 |
builtins |
|
40677
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
102 |
|> Symtab.update (@{const_name times}, is_arithT_dom) |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
103 |
|> Symtab.update (@{const_name div_class.div}, is_arithT_dom) |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
104 |
|> Symtab.update (@{const_name div_class.mod}, is_arithT_dom) |
f5caf58e9cdb
more precise characterization of built-in constants "number_of", "0", and "1"
blanchet
parents:
40664
diff
changeset
|
105 |
|> Symtab.update ("Rings.inverse_class.divide", is_arithT_dom) |
40277 | 106 |
|
107 |
fun lookup_builtin bs (name, T) = |
|
108 |
(case Symtab.lookup bs name of |
|
109 |
SOME proper_type => proper_type T |
|
110 |
| NONE => false) |
|
111 |
||
40686
4725ed462387
swap names for built-in tester functions (to better reflect the intuition of what they do);
boehmes
parents:
40681
diff
changeset
|
112 |
fun is_builtin _ = lookup_builtin builtins |
40277 | 113 |
|
40686
4725ed462387
swap names for built-in tester functions (to better reflect the intuition of what they do);
boehmes
parents:
40681
diff
changeset
|
114 |
fun is_partially_builtin _ = lookup_builtin all_builtins |
40277 | 115 |
|
116 |
end |