public SMTLibExprLineariser(TextWriter wr, UniqueNamer namer, SMTLibProverOptions opts) { Contract.Requires(wr != null); Contract.Requires(namer != null); this.wr = wr; this.Namer = namer; this.ProverOptions = opts; }
public TypeDeclCollector(SMTLibProverOptions opts, UniqueNamer namer) { Contract.Requires(namer != null); this.Namer = namer; this.Options = opts; InitializeKnownDecls(); }
public SMTLibProcess(ProcessStartInfo psi, SMTLibProverOptions options) { this.options = options; this.smtProcessId = smtProcessIdSeq++; if (options.Inspector != null) { this.inspector = new Inspector(options); } foreach (var arg in options.SolverArguments) psi.Arguments += " " + arg; if (cancelEvent == null && CommandLineOptions.Clo.RunningBoogieFromCommandLine) { cancelEvent = new ConsoleCancelEventHandler(ControlCHandler); Console.CancelKeyPress += cancelEvent; } if (options.Verbosity >= 1) { Console.WriteLine("[SMT-{0}] Starting {1} {2}", smtProcessId, psi.FileName, psi.Arguments); } try { prover = new Process(); prover.StartInfo = psi; prover.ErrorDataReceived += prover_ErrorDataReceived; prover.OutputDataReceived += prover_OutputDataReceived; prover.Start(); toProver = prover.StandardInput; prover.BeginErrorReadLine(); prover.BeginOutputReadLine(); } catch (System.ComponentModel.Win32Exception e) { throw new ProverException(string.Format("Unable to start the process {0}: {1}", psi.FileName, e.Message)); } }
public SMTLibExprLineariser(TextWriter wr, UniqueNamer namer, SMTLibProverOptions opts, ISet <VCExprVar> namedAssumes = null, IList <string> optReqs = null) { Contract.Requires(wr != null); Contract.Requires(namer != null); this.wr = wr; this.Namer = namer; this.ProverOptions = opts; this.OptimizationRequests = optReqs; this.NamedAssumes = namedAssumes; }
public static void SetupOptions(SMTLibProverOptions options) { FindExecutable(); //options.AddWeakSmtOption("produce-unsat-cores", "true"); //options.AddWeakSmtOption("smt-lib-version", "2.0"); //options.AddWeakSmtOption("produce-models", "true"); options.AddWeakSmtOption("produce-proofs", "true"); }
public static void SetDefaultOptions(SMTLibProverOptions options) { options.AddWeakSmtOption("smt.mbqi", "false"); // default: true // {:captureState} does not work with compressed models options.AddWeakSmtOption("model.compact", "false"); // default: false options.AddWeakSmtOption("model.v2", "true"); // default: false // Make sure we get something that is parsable as a bitvector options.AddWeakSmtOption("pp.bv_literals", "false"); // default: true }
public static string ToString(VCExpr e, UniqueNamer namer, SMTLibProverOptions opts, ISet <VCExprVar> namedAssumes = null, IList <string> optReqs = null, ISet <VCExprVar> tryAssumes = null) { Contract.Requires(e != null); Contract.Requires(namer != null); Contract.Ensures(Contract.Result <string>() != null); StringWriter sw = new StringWriter(); SMTLibExprLineariser lin = new SMTLibExprLineariser(sw, namer, opts, namedAssumes, optReqs); Contract.Assert(lin != null); lin.Linearise(e, LineariserOptions.Default); return(cce.NonNull(sw.ToString())); }
public SMTLibProcess(SMTLibProverOptions options) { this.options = options; this.smtProcessId = smtProcessIdSeq++; var psi = new ProcessStartInfo(options.ExecutablePath(), options.SolverArguments.Concat(" ")) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }; if (options.Inspector != null) { this.inspector = new Inspector(options); } if (cancelEvent == null && CommandLineOptions.Clo.RunningBoogieFromCommandLine) { cancelEvent = new ConsoleCancelEventHandler(ControlCHandler); Console.CancelKeyPress += cancelEvent; } if (options.Verbosity >= 1) { Console.WriteLine("[SMT-{0}] Starting {1} {2}", smtProcessId, psi.FileName, psi.Arguments); } try { prover = new Process(); prover.StartInfo = psi; prover.ErrorDataReceived += prover_ErrorDataReceived; prover.OutputDataReceived += prover_OutputDataReceived; prover.Start(); toProver = prover.StandardInput; prover.BeginErrorReadLine(); prover.BeginOutputReadLine(); } catch (System.ComponentModel.Win32Exception e) { throw new ProverException(string.Format("Unable to start the process {0}: {1}", psi.FileName, e.Message)); } }
public SMTLibProcess(ProcessStartInfo psi, SMTLibProverOptions options) { this.options = options; this.smtProcessId = smtProcessIdSeq++; if (options.Inspector != null) { this.inspector = new Inspector(options); } foreach (var arg in options.SolverArguments) { psi.Arguments += " " + arg; } if (cancelEvent == null && CommandLineOptions.Clo.RunningBoogieFromCommandLine) { cancelEvent = new ConsoleCancelEventHandler(ControlCHandler); Console.CancelKeyPress += cancelEvent; } if (options.Verbosity >= 1) { Console.WriteLine("[SMT-{0}] Starting {1} {2}", smtProcessId, psi.FileName, psi.Arguments); } try { prover = new Process(); prover.StartInfo = psi; prover.ErrorDataReceived += prover_ErrorDataReceived; prover.OutputDataReceived += prover_OutputDataReceived; prover.Start(); toProver = prover.StandardInput; prover.BeginErrorReadLine(); prover.BeginOutputReadLine(); } catch (System.ComponentModel.Win32Exception e) { throw new ProverException(string.Format("Unable to start the process {0}: {1}", psi.FileName, e.Message)); } }
public SMTLibProcessTheoremProver(ProverOptions options, VCExpressionGenerator gen, SMTLibProverContext ctx) { Contract.Requires(options != null); Contract.Requires(gen != null); Contract.Requires(ctx != null); InitializeGlobalInformation(); this.options = (SMTLibProverOptions)options; this.ctx = ctx; this.gen = gen; this.usingUnsatCore = false; SetupAxiomBuilder(gen); Namer = new SMTLibNamer(); ctx.parent = this; this.DeclCollector = new TypeDeclCollector((SMTLibProverOptions)options, Namer); if (CommandLineOptions.Clo.PrintFixedPoint != null || CommandLineOptions.Clo.PrintConjectures != null) { declHandler = new MyDeclHandler(); DeclCollector.SetDeclHandler(declHandler); } SetupProcess(); if (CommandLineOptions.Clo.StratifiedInlining > 0 || CommandLineOptions.Clo.ContractInfer || CommandLineOptions.Clo.SecureVcGen != null) { // Prepare for ApiChecker usage if (options.LogFilename != null && currentLogFile == null) { currentLogFile = OpenOutputFile(""); } PrepareCommon(); } }
public Inspector(SMTLibProverOptions opts) { Contract.Requires(opts != null); ProcessStartInfo psi = new ProcessStartInfo(opts.Inspector); Contract.Assert(psi != null); psi.CreateNoWindow = true; psi.UseShellExecute = false; psi.RedirectStandardInput = true; psi.RedirectStandardOutput = true; psi.RedirectStandardError = false; try { Process inspector = Process.Start(psi); this.inspector = inspector; fromInspector = inspector.StandardOutput; toInspector = inspector.StandardInput; } catch (System.ComponentModel.Win32Exception e) { throw new Exception(string.Format("Unable to start the inspector process {0}: {1}", opts.Inspector, e.Message)); } }
public static void SetupOptions(SMTLibProverOptions options) { FindExecutable(); int major, minor; GetVersion(out major, out minor); if (major > 4 || major == 4 && minor >= 3) { bool fp = false; // CommandLineOptions.Clo.FixedPointEngine != null; // don't bother with auto-config - it would disable explicit settings for eager threshold and so on if (!fp) { options.AddWeakSmtOption("AUTO_CONFIG", "false"); } //options.AddWeakSmtOption("MODEL_PARTIAL", "true"); //options.WeakAddSmtOption("MODEL_VALUE_COMPLETION", "false"); // options.AddWeakSmtOption("MODEL_HIDE_UNUSED_PARTITIONS", "false"); TODO: what does this do? // Make sure we get something that is parsable as a bitvector options.AddWeakSmtOption("pp.bv_literals", "false"); if (!CommandLineOptions.Clo.UseSmtOutputFormat) { options.AddWeakSmtOption("MODEL.V2", "true"); } //options.AddWeakSmtOption("ASYNC_COMMANDS", "false"); TODO: is this needed? if (!options.OptimizeForBv) { // Phase selection means to always try the negative literal polarity first, seems to be good for Boogie. // The restart parameters change the restart behavior to match Z3 v1, which also seems to be good. options.AddWeakSmtOption("smt.PHASE_SELECTION", "0"); options.AddWeakSmtOption("smt.RESTART_STRATEGY", "0"); options.AddWeakSmtOption("smt.RESTART_FACTOR", "|1.5|"); // Make the integer model more diverse by default, speeds up some benchmarks a lot. options.AddWeakSmtOption("smt.ARITH.RANDOM_INITIAL_VALUE", "true"); // The left-to-right structural case-splitting strategy. //options.AddWeakSmtOption("SORT_AND_OR", "false"); // always false now if (!fp) { options.AddWeakSmtOption("smt.CASE_SPLIT", "3"); } // In addition delay adding unit conflicts. options.AddWeakSmtOption("smt.DELAY_UNITS", "true"); //options.AddWeakSmtOption("DELAY_UNITS_THRESHOLD", "16"); TODO: what? } // This is used by VCC, but could be also useful for others, if sk_hack(foo(x)) is included as trigger, // the foo(x0) will be activated for e-matching when x is skolemized to x0. options.AddWeakSmtOption("NNF.SK_HACK", "true"); // don't use model-based quantifier instantiation; it never finishes on non-trivial Boogie problems options.AddWeakSmtOption("smt.MBQI", "false"); // More or less like MAM=0. options.AddWeakSmtOption("smt.QI.EAGER_THRESHOLD", "100"); // Complex proof attempts in VCC (and likely elsewhere) require matching depth of 20 or more. // the following will make the :weight option more usable // KLM: this QI cost function is the default // if (!fp) options.AddWeakSmtOption("smt.QI.COST", "|(+ weight generation)|"); // TODO: this doesn't seem to work //if (options.Inspector != null) // options.WeakAddSmtOption("PROGRESS_SAMPLING_FREQ", "100"); options.AddWeakSmtOption("TYPE_CHECK", "true"); options.AddWeakSmtOption("smt.BV.REFLECT", "true"); if (options.TimeLimit > 0) { options.AddWeakSmtOption("TIMEOUT", options.TimeLimit.ToString()); options.AddWeakSmtOption("fixedpoint.TIMEOUT", options.TimeLimit.ToString()); // This kills the Z3 *instance* after the specified time, not a particular query, so we cannot use it. // options.AddSolverArgument("/T:" + (options.TimeLimit + 1000) / 1000); } if (options.Inspector != null) { options.AddWeakSmtOption("PROGRESS_SAMPLING_FREQ", "200"); } if (CommandLineOptions.Clo.WeakArrayTheory) { options.AddWeakSmtOption("smt.array.weak", "true"); options.AddWeakSmtOption("smt.array.extensional", "false"); } if (CommandLineOptions.Clo.PrintConjectures != null) { options.AddWeakSmtOption("fixedpoint.conjecture_file", CommandLineOptions.Clo.PrintConjectures + ".tmp"); } } else { // don't bother with auto-config - it would disable explicit settings for eager threshold and so on options.AddWeakSmtOption("AUTO_CONFIG", "false"); //options.AddWeakSmtOption("MODEL_PARTIAL", "true"); //options.WeakAddSmtOption("MODEL_VALUE_COMPLETION", "false"); options.AddWeakSmtOption("MODEL_HIDE_UNUSED_PARTITIONS", "false"); options.AddWeakSmtOption("ASYNC_COMMANDS", "false"); if (CommandLineOptions.Clo.UseSmtOutputFormat) { options.AddWeakSmtOption("pp-bv-literals", "false");; } else { options.AddWeakSmtOption("MODEL_V2", "true"); } if (!options.OptimizeForBv) { // Phase selection means to always try the negative literal polarity first, seems to be good for Boogie. // The restart parameters change the restart behavior to match Z3 v1, which also seems to be good. options.AddWeakSmtOption("PHASE_SELECTION", "0"); options.AddWeakSmtOption("RESTART_STRATEGY", "0"); options.AddWeakSmtOption("RESTART_FACTOR", "|1.5|"); // Make the integer model more diverse by default, speeds up some benchmarks a lot. options.AddWeakSmtOption("ARITH_RANDOM_INITIAL_VALUE", "true"); // The left-to-right structural case-splitting strategy. //options.AddWeakSmtOption("SORT_AND_OR", "false"); // always false now options.AddWeakSmtOption("CASE_SPLIT", "3"); // In addition delay adding unit conflicts. options.AddWeakSmtOption("DELAY_UNITS", "true"); options.AddWeakSmtOption("DELAY_UNITS_THRESHOLD", "16"); } // This is used by VCC, but could be also useful for others, if sk_hack(foo(x)) is included as trigger, // the foo(x0) will be activated for e-matching when x is skolemized to x0. options.AddWeakSmtOption("NNF_SK_HACK", "true"); // don't use model-based quantifier instantiation; it never finishes on non-trivial Boogie problems options.AddWeakSmtOption("MBQI", "false"); // More or less like MAM=0. options.AddWeakSmtOption("QI_EAGER_THRESHOLD", "100"); // Complex proof attempts in VCC (and likely elsewhere) require matching depth of 20 or more. // the following will make the :weight option more usable options.AddWeakSmtOption("QI_COST", "|\"(+ weight generation)\"|"); //if (options.Inspector != null) // options.WeakAddSmtOption("PROGRESS_SAMPLING_FREQ", "100"); options.AddWeakSmtOption("TYPE_CHECK", "true"); options.AddWeakSmtOption("BV_REFLECT", "true"); if (options.TimeLimit > 0) { options.AddWeakSmtOption("SOFT_TIMEOUT", options.TimeLimit.ToString()); // This kills the Z3 *instance* after the specified time, not a particular query, so we cannot use it. // options.AddSolverArgument("/T:" + (options.TimeLimit + 1000) / 1000); } if (options.Inspector != null) { options.AddWeakSmtOption("PROGRESS_SAMPLING_FREQ", "200"); } if (CommandLineOptions.Clo.WeakArrayTheory) { options.AddWeakSmtOption("ARRAY_WEAK", "true"); options.AddWeakSmtOption("ARRAY_EXTENSIONAL", "false"); } options.AddWeakSmtOption("MODEL_ON_TIMEOUT", "true"); } // KLM: don't add Z3 options here. The options are different in different Z3 versions. // Add options in the above condition for the appropriate version. // legacy option handling if (!CommandLineOptions.Clo.z3AtFlag) { options.MultiTraces = true; } foreach (string opt in CommandLineOptions.Clo.Z3Options) { Contract.Assert(opt != null); int eq = opt.IndexOf("="); if (eq > 0 && 'A' <= opt[0] && opt[0] <= 'Z' && !commandLineOnly.Contains(opt.Substring(0, eq))) { options.AddSmtOption(opt.Substring(0, eq), opt.Substring(eq + 1)); } else { options.AddSolverArgument(opt); } } }
public static void SetupOptions(SMTLibProverOptions options) { FindExecutable(); int major, minor; GetVersion(out major, out minor); if (major > 4 || major == 4 && minor >= 3) { // don't bother with auto-config - it would disable explicit settings for eager threshold and so on options.AddWeakSmtOption("AUTO_CONFIG", "false"); //options.AddWeakSmtOption("MODEL_PARTIAL", "true"); //options.WeakAddSmtOption("MODEL_VALUE_COMPLETION", "false"); // options.AddWeakSmtOption("MODEL_HIDE_UNUSED_PARTITIONS", "false"); TODO: what does this do? options.AddWeakSmtOption("MODEL.V2", "true"); //options.AddWeakSmtOption("ASYNC_COMMANDS", "false"); TODO: is this needed? if (!options.OptimizeForBv) { // Phase selection means to always try the negative literal polarity first, seems to be good for Boogie. // The restart parameters change the restart behavior to match Z3 v1, which also seems to be good. options.AddWeakSmtOption("smt.PHASE_SELECTION", "0"); options.AddWeakSmtOption("smt.RESTART_STRATEGY", "0"); options.AddWeakSmtOption("smt.RESTART_FACTOR", "|1.5|"); // Make the integer model more diverse by default, speeds up some benchmarks a lot. options.AddWeakSmtOption("smt.ARITH.RANDOM_INITIAL_VALUE", "true"); // The left-to-right structural case-splitting strategy. //options.AddWeakSmtOption("SORT_AND_OR", "false"); // always false now options.AddWeakSmtOption("smt.CASE_SPLIT", "3"); // In addition delay adding unit conflicts. options.AddWeakSmtOption("smt.DELAY_UNITS", "true"); //options.AddWeakSmtOption("DELAY_UNITS_THRESHOLD", "16"); TODO: what? } // This is used by VCC, but could be also useful for others, if sk_hack(foo(x)) is included as trigger, // the foo(x0) will be activated for e-matching when x is skolemized to x0. options.AddWeakSmtOption("NNF.SK_HACK", "true"); // don't use model-based quantifier instantiation; it never finishes on non-trivial Boogie problems options.AddWeakSmtOption("smt.MBQI", "false"); // More or less like MAM=0. options.AddWeakSmtOption("smt.QI.EAGER_THRESHOLD", "100"); // Complex proof attempts in VCC (and likely elsewhere) require matching depth of 20 or more. // the following will make the :weight option more usable options.AddWeakSmtOption("smt.QI.COST", "|\"(+ weight generation)\"|"); // TODO: this doesn't seem to work //if (options.Inspector != null) // options.WeakAddSmtOption("PROGRESS_SAMPLING_FREQ", "100"); options.AddWeakSmtOption("TYPE_CHECK", "true"); options.AddWeakSmtOption("smt.BV.REFLECT", "true"); if (options.TimeLimit > 0) { options.AddWeakSmtOption("TIMEOUT", options.TimeLimit.ToString()); options.AddWeakSmtOption("fixedpoint.TIMEOUT", options.TimeLimit.ToString()); // This kills the Z3 *instance* after the specified time, not a particular query, so we cannot use it. // options.AddSolverArgument("/T:" + (options.TimeLimit + 1000) / 1000); } if (options.Inspector != null) options.AddWeakSmtOption("PROGRESS_SAMPLING_FREQ", "200"); if (CommandLineOptions.Clo.WeakArrayTheory) { options.AddWeakSmtOption("smt.array.weak", "true"); options.AddWeakSmtOption("smt.array.extensional", "false"); } } else { // don't bother with auto-config - it would disable explicit settings for eager threshold and so on options.AddWeakSmtOption("AUTO_CONFIG", "false"); //options.AddWeakSmtOption("MODEL_PARTIAL", "true"); //options.WeakAddSmtOption("MODEL_VALUE_COMPLETION", "false"); options.AddWeakSmtOption("MODEL_HIDE_UNUSED_PARTITIONS", "false"); options.AddWeakSmtOption("ASYNC_COMMANDS", "false"); if (CommandLineOptions.Clo.UseSmtOutputFormat) { options.AddWeakSmtOption("pp-bv-literals", "false"); ; } else { options.AddWeakSmtOption("MODEL_V2", "true"); } if (!options.OptimizeForBv) { // Phase selection means to always try the negative literal polarity first, seems to be good for Boogie. // The restart parameters change the restart behavior to match Z3 v1, which also seems to be good. options.AddWeakSmtOption("PHASE_SELECTION", "0"); options.AddWeakSmtOption("RESTART_STRATEGY", "0"); options.AddWeakSmtOption("RESTART_FACTOR", "|1.5|"); // Make the integer model more diverse by default, speeds up some benchmarks a lot. options.AddWeakSmtOption("ARITH_RANDOM_INITIAL_VALUE", "true"); // The left-to-right structural case-splitting strategy. //options.AddWeakSmtOption("SORT_AND_OR", "false"); // always false now options.AddWeakSmtOption("CASE_SPLIT", "3"); // In addition delay adding unit conflicts. options.AddWeakSmtOption("DELAY_UNITS", "true"); options.AddWeakSmtOption("DELAY_UNITS_THRESHOLD", "16"); } // This is used by VCC, but could be also useful for others, if sk_hack(foo(x)) is included as trigger, // the foo(x0) will be activated for e-matching when x is skolemized to x0. options.AddWeakSmtOption("NNF_SK_HACK", "true"); // don't use model-based quantifier instantiation; it never finishes on non-trivial Boogie problems options.AddWeakSmtOption("MBQI", "false"); // More or less like MAM=0. options.AddWeakSmtOption("QI_EAGER_THRESHOLD", "100"); // Complex proof attempts in VCC (and likely elsewhere) require matching depth of 20 or more. // the following will make the :weight option more usable options.AddWeakSmtOption("QI_COST", "|\"(+ weight generation)\"|"); //if (options.Inspector != null) // options.WeakAddSmtOption("PROGRESS_SAMPLING_FREQ", "100"); options.AddWeakSmtOption("TYPE_CHECK", "true"); options.AddWeakSmtOption("BV_REFLECT", "true"); if (options.TimeLimit > 0) { options.AddWeakSmtOption("SOFT_TIMEOUT", options.TimeLimit.ToString()); // This kills the Z3 *instance* after the specified time, not a particular query, so we cannot use it. // options.AddSolverArgument("/T:" + (options.TimeLimit + 1000) / 1000); } if (options.Inspector != null) options.AddWeakSmtOption("PROGRESS_SAMPLING_FREQ", "200"); if (CommandLineOptions.Clo.WeakArrayTheory) { options.AddWeakSmtOption("ARRAY_WEAK", "true"); options.AddWeakSmtOption("ARRAY_EXTENSIONAL", "false"); } options.AddWeakSmtOption("MODEL_ON_TIMEOUT", "true"); } // KLM: don't add Z3 options here. The options are different in different Z3 versions. // Add options in the above condition for the appropriate version. // legacy option handling if (!CommandLineOptions.Clo.z3AtFlag) options.MultiTraces = true; foreach (string opt in CommandLineOptions.Clo.Z3Options) { Contract.Assert(opt != null); int eq = opt.IndexOf("="); if (eq > 0 && 'A' <= opt[0] && opt[0] <= 'Z' && !commandLineOnly.Contains(opt.Substring(0, eq))) { options.AddSmtOption(opt.Substring(0, eq), opt.Substring(eq + 1)); } else { options.AddSolverArgument(opt); } } }
public static void SetupOptions(SMTLibProverOptions options) { }
public SMTLibProcessTheoremProver(ProverOptions options, VCExpressionGenerator gen, SMTLibProverContext ctx) { Contract.Requires(options != null); Contract.Requires(gen != null); Contract.Requires(ctx != null); InitializeGlobalInformation(); this.options = (SMTLibProverOptions)options; this.ctx = ctx; this.gen = gen; this.usingUnsatCore = false; SetupAxiomBuilder(gen); Namer = new SMTLibNamer(); ctx.parent = this; this.DeclCollector = new TypeDeclCollector((SMTLibProverOptions)options, Namer); SetupProcess(); if (CommandLineOptions.Clo.StratifiedInlining > 0 || CommandLineOptions.Clo.ContractInfer) { // Prepare for ApiChecker usage if (options.LogFilename != null && currentLogFile == null) { currentLogFile = OpenOutputFile(""); } if (CommandLineOptions.Clo.ContractInfer) { SendThisVC("(set-option :produce-unsat-cores true)"); this.usingUnsatCore = true; } PrepareCommon(); } }