考慮使用Z3模塊與Z3解算器接口的以下OCaml代碼片段。代碼試圖定義Z3新TPair
數據類型與接受兩個整數參數一個構造函數T
:Z3的OCaml庫引發了分段錯誤
open Z3
open Z3.SMT
open Z3.Expr
open Z3.Symbol
open Z3.Datatype
open Z3.FuncDecl
open Z3.Arithmetic
open Z3.Arithmetic.Integer
open Z3.Quantifier
let _ =
let cfg = [("model", "true"); ("proof", "false")] in
let ctx = (mk_context cfg) in
let sym = Symbol.mk_string ctx in
let s_Int = mk_sort ctx in
(* (declare-datatypes() ((TPair (T Int Int))))*)
let s_T = mk_constructor_s ctx "T" (sym "isT")
[sym "left"; sym "right"]
[Some s_Int; Some s_Int] [0; 0] in
let s_TPair = mk_sort_s ctx "TPair" [s_T] in
let _::s_content::_ = Constructor.get_accessor_decls s_T in
let s_isT = Constructor.get_tester_decl s_T in
let solver = Solver.mk_solver ctx None in
begin
Printf.printf "***** CONTEXT ******\n";
print_string @@ Solver.to_string solver;
Printf.printf "\n*********************\n"
end
到get_tester_decl
和get_accessor_decls
都扔分割故障的電話。可能是什麼原因?
報告給圖書館的作者。 – camlspotter
這裏給出的示例源代碼編譯(帶有警告)並且對我運行良好。 OCaml有一點點缺陷。您能否告訴我們您正在使用哪個版本以及從哪裏獲得?此外,請確保您使用的是最新的Z3源代碼,並從源代碼編譯,因爲自上次二進制發行版以來,已有多個修復程序。 –