11 val hosmtlibC: SMT_Util.class |
11 val hosmtlibC: SMT_Util.class |
12 val bvsmlibC: SMT_Util.class |
12 val bvsmlibC: SMT_Util.class |
13 val add_logic: int * (string -> term list -> string option) -> Context.generic -> Context.generic |
13 val add_logic: int * (string -> term list -> string option) -> Context.generic -> Context.generic |
14 val del_logic: int * (string -> term list -> string option) -> Context.generic -> Context.generic |
14 val del_logic: int * (string -> term list -> string option) -> Context.generic -> Context.generic |
15 val translate_config: SMT_Util.order -> Proof.context -> SMT_Translate.config |
15 val translate_config: SMT_Util.order -> Proof.context -> SMT_Translate.config |
16 val assert_name_of_index: int -> string |
16 val assert_name_of_role_and_index: SMT_Util.role -> int -> string |
17 val assert_index_of_name: string -> int |
17 val role_and_index_of_assert_name: string -> SMT_Util.role * int |
18 val assert_prefix : string |
|
19 end; |
18 end; |
20 |
19 |
21 structure SMTLIB_Interface: SMTLIB_INTERFACE = |
20 structure SMTLIB_Interface: SMTLIB_INTERFACE = |
22 struct |
21 struct |
23 |
22 |
135 |
134 |
136 fun string_of_fun (f, (ss, s)) = f ^ " (" ^ space_implode " " ss ^ ") " ^ s |
135 fun string_of_fun (f, (ss, s)) = f ^ " (" ^ space_implode " " ss ^ ") " ^ s |
137 |
136 |
138 fun named_sterm s t = SMTLIB.S [SMTLIB.Sym "!", t, SMTLIB.Key "named", SMTLIB.Sym s] |
137 fun named_sterm s t = SMTLIB.S [SMTLIB.Sym "!", t, SMTLIB.Key "named", SMTLIB.Sym s] |
139 |
138 |
140 val assert_prefix = "a" |
139 val conjecture_prefix = "conjecture" (* FUDGE *) |
|
140 val hypothesis_prefix = "hypothesis" (* FUDGE *) |
|
141 val axiom_prefix = "axiom" (* FUDGE *) |
141 |
142 |
142 fun assert_name_of_index i = assert_prefix ^ string_of_int i |
143 fun assert_prefix_of_role SMT_Util.Conjecture = conjecture_prefix |
143 fun assert_index_of_name s = the_default ~1 (Int.fromString (unprefix assert_prefix s)) |
144 | assert_prefix_of_role SMT_Util.Hypothesis = hypothesis_prefix |
|
145 | assert_prefix_of_role SMT_Util.Axiom = axiom_prefix |
|
146 |
|
147 fun assert_name_of_role_and_index role i = assert_prefix_of_role role ^ string_of_int i |
|
148 |
|
149 fun unprefix_axiom s = |
|
150 try (pair SMT_Util.Conjecture o unprefix conjecture_prefix) s |
|
151 |> curry merge_options (try (pair SMT_Util.Conjecture o unprefix hypothesis_prefix) s) |
|
152 |> curry merge_options (try (pair SMT_Util.Conjecture o unprefix axiom_prefix) s) |
|
153 |> the |
|
154 |
|
155 fun role_and_index_of_assert_name s = |
|
156 apsnd (the_default ~1 o Int.fromString) (unprefix_axiom s) |
144 |
157 |
145 fun sdtyp (fp, dtyps) = |
158 fun sdtyp (fp, dtyps) = |
146 Buffer.add (enclose ("(declare-" ^ BNF_FP_Util.co_prefix fp ^ "datatypes () (") "))\n" |
159 Buffer.add (enclose ("(declare-" ^ BNF_FP_Util.co_prefix fp ^ "datatypes () (") "))\n" |
147 (space_implode "\n " (map sdatatype dtyps))) |
160 (space_implode "\n " (map sdatatype dtyps))) |
148 |
161 |
156 |> Buffer.add logic |
169 |> Buffer.add logic |
157 |> fold (Buffer.add o enclose "(declare-sort " " 0)\n") (sort fast_string_ord sorts) |
170 |> fold (Buffer.add o enclose "(declare-sort " " 0)\n") (sort fast_string_ord sorts) |
158 |> fold sdtyp (AList.coalesce (op =) dtyps) |
171 |> fold sdtyp (AList.coalesce (op =) dtyps) |
159 |> fold (Buffer.add o enclose "(declare-fun " ")\n" o string_of_fun) |
172 |> fold (Buffer.add o enclose "(declare-fun " ")\n" o string_of_fun) |
160 (sort (fast_string_ord o apply2 fst) funcs) |
173 (sort (fast_string_ord o apply2 fst) funcs) |
161 |> fold (fn (i, t) => Buffer.add (enclose "(assert " ")\n" |
174 |> fold (fn (i, (role, t)) => Buffer.add (enclose "(assert " ")\n" |
162 (SMTLIB.str_of (named_sterm (assert_name_of_index i) (tree_of_sterm 0 t))))) (map_index I ts) |
175 (SMTLIB.str_of (named_sterm (assert_name_of_role_and_index role i) (tree_of_sterm 0 t))))) |
|
176 (map_index I ts) |
163 |> Buffer.add "(check-sat)\n" |
177 |> Buffer.add "(check-sat)\n" |
164 |> Buffer.add (if unsat_core then "(get-unsat-core)\n" else "(get-proof)\n") |
178 |> Buffer.add (if unsat_core then "(get-unsat-core)\n" else "(get-proof)\n") |
165 |> Buffer.content |
179 |> Buffer.content |
166 end |
180 end |
167 |
181 |