Z3 C#FiniteDomain排序异常/用法?

时间:2014-05-30 06:52:30

标签: z3

我正在尝试在我的上下文中使用“FiniteDomainSort”,但是当我将它提供给解算器时,它会抛出一些异常。

说明:
*我按建议使用MkNumeral here
*使用z3-4.3.0 x64(win)和z3-4.3.2 x64(ubuntu)测试 *在同一个例子中使用IntSort时运行正常

示例:

using System;
using System.Collections.Generic;
using Microsoft.Z3;
namespace NS { class CL { public static void Main() {
    Context ctx = new Context (new Dictionary<string, string> () { { "MODEL", "true" } });
    Sort BOOL = ctx.BoolSort;

    Sort INT = ctx.IntSort;
    FuncDecl f1 = ctx.MkFuncDecl("f1", new Sort[] {INT}, BOOL);
    Expr c1 = ctx.MkNumeral ( 1, INT);
    BoolExpr app1 = (BoolExpr) ctx.MkApp (f1,c1);
    Solver solver1 = ctx.MkSolver();
    solver1.Assert(app1);
    Console.WriteLine ("[Solver 1]");
    Console.WriteLine ("Check: " + solver1.Check ());
    Console.WriteLine ("Model\n" + solver1.Model);

    Sort TEST = ctx.MkFiniteDomainSort ("MySort", 2); // size "2" just for demonstration
    FuncDecl f2 = ctx.MkFuncDecl("g", new Sort[] {TEST}, BOOL);
    Expr c2 = ctx.MkNumeral ( 1, TEST);
    BoolExpr app2 = (BoolExpr) ctx.MkApp (f2,c2);
    Solver solver2 = ctx.MkSolver();
    solver2.Assert(app2);
    Console.WriteLine ("[Solver 2]");
    Console.WriteLine ("Check: " + solver2.Check ());
    Console.WriteLine ("Model\n" + solver2.Model);
} } }

输出:

./Problem.exe 
[Solver 1]
Check: SATISFIABLE
Model
(define-fun f1 ((x!1 Int)) Bool
  (ite (= x!1 1) true
    true))
[Solver 2]
Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) Microsoft.Z3.Native/LIB.Z3_solver_check (intptr,intptr) <0xffffffff>
  at Microsoft.Z3.Native.Z3_solver_check (intptr,intptr) <0x00023>
  at Microsoft.Z3.Solver.Check (Microsoft.Z3.Expr[]) <0x00093>
  at NS.CL.Main () <0x0049b>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

    /usr/bin/cli() [0x4b8e48]
    /usr/bin/cli() [0x51211b]
    /usr/bin/cli() [0x424152]
    /lib/x86_64-linux-gnu/libpthread.so.0(+0xfbb0) [0x7f5aee780bb0]
    /some/path/libz3.so(_ZN3smt15model_generator16top_sort_sourcesERK10ptr_vectorINS_5enodeEERK7obj_mapIS2_PNS_16model_value_procEER7svectorINS_22model_value_dependencyEjE+0x3d2) [0x7f5aeac9ffc2]
    /some/path/libz3.so(_ZN3smt15model_generator9mk_valuesEv+0x17c) [0x7f5aeaca10ac]
    /some/path/libz3.so(_ZN3smt15model_generator8mk_modelEv+0x21) [0x7f5aeaca2161]
    /some/path/libz3.so(_ZN3smt7context14mk_proto_modelE5lbool+0x43) [0x7f5aeace17d3]
    /some/path/libz3.so(_ZN3smt7context6searchEv+0x21d) [0x7f5aeace854d]
    /some/path/libz3.so(_ZN3smt7context15setup_and_checkEb+0x88) [0x7f5aeace8948]
    /some/path/libz3.so(_ZN10smt_tacticclERK3refI4goalER11sref_bufferIS1_Lj16EERS0_I15model_converterERS0_I15proof_converterER7obj_refIN18dependency_managerIN11ast_manager22expr_dependency_configEE10dependencyESG_E+0x12ee) [0x7f5aeac395ce]
    /some/path/libz3.so(_ZN17and_then_tacticalclERK3refI4goalER11sref_bufferIS1_Lj16EERS0_I15model_converterERS0_I15proof_converterER7obj_refIN18dependency_managerIN11ast_manager22expr_dependency_configEE10dependencyESG_E+0xf82) [0x7f5aeb0d1282]
    /some/path/libz3.so(_Z4execR6tacticRK3refI4goalER11sref_bufferIS2_Lj16EERS1_I15model_converterERS1_I15proof_converterER7obj_refIN18dependency_managerIN11ast_manager22expr_dependency_configEE10dependencyESH_E+0x40) [0x7f5aeb0c8240]
    /some/path/libz3.so(_Z9check_satR6tacticR3refI4goalERS1_I5modelER7obj_refI3app11ast_managerERS8_IN18dependency_managerINSA_22expr_dependency_configEE10dependencyESA_ERSs+0x121) [0x7f5aeb0c86a1]
    /some/path/libz3.so(_ZN13tactic2solver14check_sat_coreEjPKP4expr+0x1c6) [0x7f5aeaf92476]
    /some/path/libz3.so(_ZN12solver_na2as9check_satEjPKP4expr+0x115) [0x7f5aeaf94445]
    /some/path/libz3.so(_ZN15combined_solver9check_satEjPKP4expr+0x16f) [0x7f5aeaf93a9f]
    /some/path/libz3.so(Z3_solver_check+0xdb) [0x7f5aea95304b]
    [0x40142191]

Debug info from gdb:

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No threads.

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Aborted

1 个答案:

答案 0 :(得分:1)

看起来这是一个错误,将在不稳定中修复。 见http://z3.codeplex.com/workitem/115