diff --git a/CMakeLists.txt b/CMakeLists.txt index 388218639..28ff64568 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ endif() ################################################################################ set(Z3_VERSION_MAJOR 4) set(Z3_VERSION_MINOR 8) -set(Z3_VERSION_PATCH 1) +set(Z3_VERSION_PATCH 2) set(Z3_VERSION_TWEAK 0) set(Z3_VERSION "${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}.${Z3_VERSION_PATCH}.${Z3_VERSION_TWEAK}") set(Z3_FULL_VERSION_STR "${Z3_VERSION}") # Note this might be modified diff --git a/cmake/msvc_legacy_quirks.cmake b/cmake/msvc_legacy_quirks.cmake index 36fe82bb3..a8006e2d3 100644 --- a/cmake/msvc_legacy_quirks.cmake +++ b/cmake/msvc_legacy_quirks.cmake @@ -8,13 +8,13 @@ # FIXME: All the commented out defines should be removed once # we are confident it is correct to not set them. set(Z3_MSVC_LEGACY_DEFINES - # Don't set `_DEBUG`. The old build sytem sets this but this + # Don't set `_DEBUG`. The old build system sets this but this # is wrong. MSVC will set this depending on which runtime is being used. # See https://msdn.microsoft.com/en-us/library/b0084kay.aspx # _DEBUG # The old build system only set `UNICODE` and `_UNICODE` for x86_64 release. - # That seems completly wrong so set it for all configurations. + # That seems completely wrong so set it for all configurations. # According to https://blogs.msdn.microsoft.com/oldnewthing/20040212-00/?p=40643/ # `UNICODE` affects Windows headers and `_UNICODE` affects C runtime header files. # There is some discussion of this define at https://msdn.microsoft.com/en-us/library/dybsewaf.aspx @@ -116,7 +116,7 @@ z3_add_cxx_flag("/analyze-" REQUIRED) ################################################################################ # By default CMake enables incremental linking for Debug and RelWithDebInfo -# builds. The old build sytem disables it for all builds so try to do the same +# builds. The old build system disables it for all builds so try to do the same # by changing all configurations if necessary string(TOUPPER "${available_build_types}" _build_types_as_upper) foreach (_build_type ${_build_types_as_upper}) diff --git a/cmake/z3_add_component.cmake b/cmake/z3_add_component.cmake index d87ffbe61..8ab6e045d 100644 --- a/cmake/z3_add_component.cmake +++ b/cmake/z3_add_component.cmake @@ -7,7 +7,7 @@ function(z3_expand_dependencies output_var) if (ARGC LESS 2) message(FATAL_ERROR "Invalid number of arguments") endif() - # Remaing args should be component names + # Remaining args should be component names set(_expanded_deps ${ARGN}) set(_old_number_of_deps 0) list(LENGTH _expanded_deps _number_of_deps) @@ -33,7 +33,7 @@ function(z3_add_component_dependencies_to_target target_name) if (NOT (TARGET ${target_name})) message(FATAL_ERROR "Target \"${target_name}\" does not exist") endif() - # Remaing args should be component names + # Remaining args should be component names set(_expanded_deps ${ARGN}) foreach (dependency ${_expanded_deps}) # Ensure this component's dependencies are built before this component. @@ -219,7 +219,7 @@ macro(z3_add_component component_name) # Record this component's dependencies foreach (dependency ${Z3_MOD_COMPONENT_DEPENDENCIES}) if (NOT (TARGET ${dependency})) - message(FATAL_ERROR "Component \"${component_name}\" depends on a non existant component \"${dependency}\"") + message(FATAL_ERROR "Component \"${component_name}\" depends on a non existent component \"${dependency}\"") endif() set_property(GLOBAL APPEND PROPERTY Z3_${component_name}_DEPS "${dependency}") endforeach() diff --git a/contrib/ci/README.md b/contrib/ci/README.md index bd1c52792..d0f336f92 100644 --- a/contrib/ci/README.md +++ b/contrib/ci/README.md @@ -1,4 +1,4 @@ -# Continous integration scripts +# Continuous integration scripts ## TravisCI @@ -45,7 +45,7 @@ the future. * `Z3_VERBOSE_BUILD_OUTPUT` - Show compile commands in CMake builds (`0` or `1`) * `Z3_STATIC_BUILD` - Build Z3 binaries and libraries statically (`0` or `1`) * `Z3_SYSTEM_TEST_GIT_REVISION` - Git revision of [z3test](https://github.com/Z3Prover/z3test). If empty lastest revision will be used. -* `Z3_WARNINGS_AS_ERRORS` - Set the `WARNINGS_AS_ERRORS` CMake option pased to Z3 (`OFF`, `ON`, or `SERIOUS_ONLY`) +* `Z3_WARNINGS_AS_ERRORS` - Set the `WARNINGS_AS_ERRORS` CMake option passed to Z3 (`OFF`, `ON`, or `SERIOUS_ONLY`) ### Linux diff --git a/doc/z3api.cfg.in b/doc/z3api.cfg.in index 9c4b464c2..e58b561c9 100644 --- a/doc/z3api.cfg.in +++ b/doc/z3api.cfg.in @@ -944,7 +944,7 @@ HTML_STYLESHEET = # user-defined cascading style sheet that is included after the standard # style sheets created by doxygen. Using this option one can overrule # certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more +# since it does not replace the standard style sheet and is therefore more # robust against future updates. Doxygen will copy the style sheet file to # the output directory. @@ -1711,7 +1711,7 @@ UML_LOOK = NO # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be +# manageable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt index 0a41d6a93..52758889d 100644 --- a/examples/c++/CMakeLists.txt +++ b/examples/c++/CMakeLists.txt @@ -7,8 +7,8 @@ find_package(Z3 REQUIRED CONFIG # `NO_DEFAULT_PATH` is set so that -DZ3_DIR has to be passed to find Z3. - # This should prevent us from accidently picking up an installed - # copy of Z3. This is here to benefit Z3's build sytem when building + # This should prevent us from accidentally picking up an installed + # copy of Z3. This is here to benefit Z3's build system when building # this project. When making your own project you probably shouldn't # use this option. NO_DEFAULT_PATH diff --git a/examples/c++/example.cpp b/examples/c++/example.cpp index 6faeb3edc..3089f5e2b 100644 --- a/examples/c++/example.cpp +++ b/examples/c++/example.cpp @@ -835,6 +835,17 @@ void tst_visit() { visit(f); } +void tst_numeral() { + context c; + expr x = c.real_val("1/3"); + double d = 0; + if (!x.is_numeral(d)) { + std::cout << x << " is not recognized as a numeral\n"; + return; + } + std::cout << x << " is " << d << "\n"; +} + void incremental_example1() { std::cout << "incremental example1\n"; context c; @@ -1212,6 +1223,7 @@ int main() { tactic_example9(); std::cout << "\n"; tactic_qe(); std::cout << "\n"; tst_visit(); std::cout << "\n"; + tst_numeral(); std::cout << "\n"; incremental_example1(); std::cout << "\n"; incremental_example2(); std::cout << "\n"; incremental_example3(); std::cout << "\n"; diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index c47a4947a..e45c82d37 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -24,8 +24,8 @@ find_package(Z3 REQUIRED CONFIG # `NO_DEFAULT_PATH` is set so that -DZ3_DIR has to be passed to find Z3. - # This should prevent us from accidently picking up an installed - # copy of Z3. This is here to benefit Z3's build sytem when building + # This should prevent us from accidentally picking up an installed + # copy of Z3. This is here to benefit Z3's build system when building # this project. When making your own project you probably shouldn't # use this option. NO_DEFAULT_PATH diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs index 230aacf6f..47906add4 100644 --- a/examples/dotnet/Program.cs +++ b/examples/dotnet/Program.cs @@ -363,10 +363,10 @@ namespace test_mapi Console.WriteLine("Model = " + s.Model); - Console.WriteLine("Interpretation of MyArray:\n" + s.Model.FuncInterp(aex.FuncDecl)); + //Console.WriteLine("Interpretation of MyArray:\n" + s.Model.ConstInterp(aex.FuncDecl)); Console.WriteLine("Interpretation of x:\n" + s.Model.ConstInterp(xc)); Console.WriteLine("Interpretation of f:\n" + s.Model.FuncInterp(fd)); - Console.WriteLine("Interpretation of MyArray as Term:\n" + s.Model.FuncInterp(aex.FuncDecl)); + //Console.WriteLine("Interpretation of MyArray as Term:\n" + s.Model.ConstInterp(aex.FuncDecl)); } /// diff --git a/examples/maxsat/CMakeLists.txt b/examples/maxsat/CMakeLists.txt index 019243ecf..e59486297 100644 --- a/examples/maxsat/CMakeLists.txt +++ b/examples/maxsat/CMakeLists.txt @@ -11,8 +11,8 @@ find_package(Z3 REQUIRED CONFIG # `NO_DEFAULT_PATH` is set so that -DZ3_DIR has to be passed to find Z3. - # This should prevent us from accidently picking up an installed - # copy of Z3. This is here to benefit Z3's build sytem when building + # This should prevent us from accidentally picking up an installed + # copy of Z3. This is here to benefit Z3's build system when building # this project. When making your own project you probably shouldn't # use this option. NO_DEFAULT_PATH diff --git a/examples/msf/SolverFoundation.Plugin.Z3/Z3BaseSolver.cs b/examples/msf/SolverFoundation.Plugin.Z3/Z3BaseSolver.cs index 1c82406be..5297d3e67 100644 --- a/examples/msf/SolverFoundation.Plugin.Z3/Z3BaseSolver.cs +++ b/examples/msf/SolverFoundation.Plugin.Z3/Z3BaseSolver.cs @@ -226,7 +226,7 @@ namespace Microsoft.SolverFoundation.Plugin.Z3 } /// - /// Adds a MSF variable with the coresponding assertion to the Z3 variables. + /// Adds a MSF variable with the corresponding assertion to the Z3 variables. /// /// The MSF id of the variable internal void AddVariable(int vid) diff --git a/examples/tptp/CMakeLists.txt b/examples/tptp/CMakeLists.txt index 8e8dfb8ea..7870e5408 100644 --- a/examples/tptp/CMakeLists.txt +++ b/examples/tptp/CMakeLists.txt @@ -7,8 +7,8 @@ find_package(Z3 REQUIRED CONFIG # `NO_DEFAULT_PATH` is set so that -DZ3_DIR has to be passed to find Z3. - # This should prevent us from accidently picking up an installed - # copy of Z3. This is here to benefit Z3's build sytem when building + # This should prevent us from accidentally picking up an installed + # copy of Z3. This is here to benefit Z3's build system when building # this project. When making your own project you probably shouldn't # use this option. NO_DEFAULT_PATH diff --git a/examples/tptp/tptp5.cpp b/examples/tptp/tptp5.cpp index facbf6c0a..882c2bbe2 100644 --- a/examples/tptp/tptp5.cpp +++ b/examples/tptp/tptp5.cpp @@ -233,7 +233,7 @@ class env { void check_arity(unsigned num_args, unsigned arity) { if (num_args != arity) { - throw failure_ex("arity missmatch"); + throw failure_ex("arity mismatch"); } } diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 174b498e7..8c037f2e5 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -9,7 +9,7 @@ from mk_util import * # Z3 Project definition def init_project_def(): - set_version(4, 8, 1, 0) + set_version(4, 8, 2, 0) add_lib('util', [], includes2install = ['z3_version.h']) add_lib('polynomial', ['util'], 'math/polynomial') add_lib('sat', ['util']) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index e5173931d..5b4d31d3e 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -3494,7 +3494,7 @@ class MakeRuleCmd(object): needed commands used in Makefile rules Note that several of the method are meant for use during ``make install`` and ``make uninstall``. These methods correctly use - ``$(PREFIX)`` and ``$(DESTDIR)`` and therefore are preferrable + ``$(PREFIX)`` and ``$(DESTDIR)`` and therefore are preferable to writing commands manually which can be error prone. """ @classmethod diff --git a/src/ackermannization/lackr_model_constructor.cpp b/src/ackermannization/lackr_model_constructor.cpp index 420fbda10..df0aac15e 100644 --- a/src/ackermannization/lackr_model_constructor.cpp +++ b/src/ackermannization/lackr_model_constructor.cpp @@ -276,7 +276,7 @@ struct lackr_model_constructor::imp { SASSERT(a->get_num_args() == 0); func_decl * const fd = a->get_decl(); expr * val = m_abstr_model->get_const_interp(fd); - if (val == nullptr) { // TODO: avoid model completetion? + if (val == nullptr) { // TODO: avoid model completion? sort * s = fd->get_range(); val = m_abstr_model->get_some_value(s); } diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 4b3b85399..c236ba3e8 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -219,7 +219,7 @@ namespace api { if (m_user_ref_count) { // Corner case bug: n may be in m_last_result, and this is the only reference to n. // When, we execute reset() it is deleted - // To avoid this bug, I bump the reference counter before reseting m_last_result + // To avoid this bug, I bump the reference counter before resetting m_last_result ast_ref node(n, m()); m_last_result.reset(); m_last_result.push_back(std::move(node)); diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index c2f437391..06207cee6 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -210,7 +210,7 @@ extern "C" { if (!out) { return Z3_FALSE; } - // must start loggging here, since function uses Z3_get_sort_kind above + // must start logging here, since function uses Z3_get_sort_kind above LOG_Z3_get_finite_domain_sort_size(c, s, out); RESET_ERROR_CODE(); VERIFY(mk_c(c)->datalog_util().try_get_size(to_sort(s), *out)); diff --git a/src/api/api_numeral.cpp b/src/api/api_numeral.cpp index 2891e8cc4..11afed82e 100644 --- a/src/api/api_numeral.cpp +++ b/src/api/api_numeral.cpp @@ -227,6 +227,11 @@ extern "C" { Z3_CATCH_RETURN(""); } + double Z3_API Z3_get_numeral_double(Z3_context c, Z3_ast a) { + Z3_string s = Z3_get_numeral_decimal_string(c, a, 12); + return std::stod(std::string(s)); + } + Z3_string Z3_API Z3_get_numeral_decimal_string(Z3_context c, Z3_ast a, unsigned precision) { Z3_TRY; LOG_Z3_get_numeral_decimal_string(c, a, precision); diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 33af3ddde..07056746d 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -709,6 +709,7 @@ namespace z3 { bool is_numeral_u(unsigned& i) const { bool r = 0 != Z3_get_numeral_uint(ctx(), m_ast, &i); check_error(); return r;} bool is_numeral(std::string& s) const { if (!is_numeral()) return false; s = Z3_get_numeral_string(ctx(), m_ast); check_error(); return true; } bool is_numeral(std::string& s, unsigned precision) const { if (!is_numeral()) return false; s = Z3_get_numeral_decimal_string(ctx(), m_ast, precision); check_error(); return true; } + bool is_numeral(double& d) const { if (!is_numeral()) return false; d = Z3_get_numeral_double(ctx(), m_ast); check_error(); return true; } /** \brief Return true if this expression is an application. */ diff --git a/src/api/dotnet/AST.cs b/src/api/dotnet/AST.cs index 2460c50f0..0afff2c42 100644 --- a/src/api/dotnet/AST.cs +++ b/src/api/dotnet/AST.cs @@ -17,17 +17,16 @@ Notes: --*/ +using System.Diagnostics; using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// The abstract syntax tree (AST) class. /// - [ContractVerification(true)] public class AST : Z3Object, IComparable { /// @@ -114,8 +113,7 @@ namespace Microsoft.Z3 /// A copy of the AST which is associated with public AST Translate(Context ctx) { - Contract.Requires(ctx != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ctx != null); if (ReferenceEquals(Context, ctx)) return this; @@ -202,14 +200,13 @@ namespace Microsoft.Z3 /// public string SExpr() { - Contract.Ensures(Contract.Result() != null); return Native.Z3_ast_to_string(Context.nCtx, NativeObject); } #region Internal - internal AST(Context ctx) : base(ctx) { Contract.Requires(ctx != null); } - internal AST(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal AST(Context ctx) : base(ctx) { Debug.Assert(ctx != null); } + internal AST(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue { @@ -246,8 +243,7 @@ namespace Microsoft.Z3 internal static AST Create(Context ctx, IntPtr obj) { - Contract.Requires(ctx != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ctx != null); switch ((Z3_ast_kind)Native.Z3_get_ast_kind(ctx.nCtx, obj)) { diff --git a/src/api/dotnet/ASTMap.cs b/src/api/dotnet/ASTMap.cs index f7c1c5914..f678f71c3 100644 --- a/src/api/dotnet/ASTMap.cs +++ b/src/api/dotnet/ASTMap.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Map from AST to AST /// - [ContractVerification(true)] internal class ASTMap : Z3Object { /// @@ -35,7 +34,7 @@ namespace Microsoft.Z3 /// True if is a key in the map, false otherwise. public bool Contains(AST k) { - Contract.Requires(k != null); + Debug.Assert(k != null); return 0 != Native.Z3_ast_map_contains(Context.nCtx, NativeObject, k.NativeObject); } @@ -49,8 +48,7 @@ namespace Microsoft.Z3 /// An AST public AST Find(AST k) { - Contract.Requires(k != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(k != null); return new AST(Context, Native.Z3_ast_map_find(Context.nCtx, NativeObject, k.NativeObject)); } @@ -62,8 +60,8 @@ namespace Microsoft.Z3 /// The value AST public void Insert(AST k, AST v) { - Contract.Requires(k != null); - Contract.Requires(v != null); + Debug.Assert(k != null); + Debug.Assert(v != null); Native.Z3_ast_map_insert(Context.nCtx, NativeObject, k.NativeObject, v.NativeObject); } @@ -74,7 +72,7 @@ namespace Microsoft.Z3 /// An AST public void Erase(AST k) { - Contract.Requires(k != null); + Debug.Assert(k != null); Native.Z3_ast_map_erase(Context.nCtx, NativeObject, k.NativeObject); } @@ -119,12 +117,12 @@ namespace Microsoft.Z3 internal ASTMap(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal ASTMap(Context ctx) : base(ctx, Native.Z3_mk_ast_map(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/ASTVector.cs b/src/api/dotnet/ASTVector.cs index 8b599ca48..fcfa6bd65 100644 --- a/src/api/dotnet/ASTVector.cs +++ b/src/api/dotnet/ASTVector.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -45,13 +45,12 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new AST(Context, Native.Z3_ast_vector_get(Context.nCtx, NativeObject, i)); } set { - Contract.Requires(value != null); + Debug.Assert(value != null); Native.Z3_ast_vector_set(Context.nCtx, NativeObject, i, value.NativeObject); } @@ -73,7 +72,7 @@ namespace Microsoft.Z3 /// An AST public void Push(AST a) { - Contract.Requires(a != null); + Debug.Assert(a != null); Native.Z3_ast_vector_push(Context.nCtx, NativeObject, a.NativeObject); } @@ -85,8 +84,7 @@ namespace Microsoft.Z3 /// A new ASTVector public ASTVector Translate(Context ctx) { - Contract.Requires(ctx != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ctx != null); return new ASTVector(Context, Native.Z3_ast_vector_translate(Context.nCtx, NativeObject, ctx.nCtx)); } @@ -232,8 +230,8 @@ namespace Microsoft.Z3 } #region Internal - internal ASTVector(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } - internal ASTVector(Context ctx) : base(ctx, Native.Z3_mk_ast_vector(ctx.nCtx)) { Contract.Requires(ctx != null); } + internal ASTVector(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } + internal ASTVector(Context ctx) : base(ctx, Native.Z3_mk_ast_vector(ctx.nCtx)) { Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue { diff --git a/src/api/dotnet/AlgebraicNum.cs b/src/api/dotnet/AlgebraicNum.cs index 3687e1f83..cd1e4e922 100644 --- a/src/api/dotnet/AlgebraicNum.cs +++ b/src/api/dotnet/AlgebraicNum.cs @@ -16,8 +16,8 @@ Author: Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; #if !FRAMEWORK_LT_4 using System.Numerics; @@ -28,7 +28,6 @@ namespace Microsoft.Z3 /// /// Algebraic numbers /// - [ContractVerification(true)] public class AlgebraicNum : ArithExpr { /// @@ -40,7 +39,6 @@ namespace Microsoft.Z3 /// A numeral Expr of sort Real public RatNum ToUpper(uint precision) { - Contract.Ensures(Contract.Result() != null); return new RatNum(Context, Native.Z3_get_algebraic_number_upper(Context.nCtx, NativeObject, precision)); } @@ -54,7 +52,6 @@ namespace Microsoft.Z3 /// A numeral Expr of sort Real public RatNum ToLower(uint precision) { - Contract.Ensures(Contract.Result() != null); return new RatNum(Context, Native.Z3_get_algebraic_number_lower(Context.nCtx, NativeObject, precision)); } @@ -65,7 +62,6 @@ namespace Microsoft.Z3 /// The result has at most decimal places. public string ToDecimal(uint precision) { - Contract.Ensures(Contract.Result() != null); return Native.Z3_get_numeral_decimal_string(Context.nCtx, NativeObject, precision); } @@ -74,7 +70,7 @@ namespace Microsoft.Z3 internal AlgebraicNum(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/ApplyResult.cs b/src/api/dotnet/ApplyResult.cs index db2922460..342bf3216 100644 --- a/src/api/dotnet/ApplyResult.cs +++ b/src/api/dotnet/ApplyResult.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -26,7 +26,6 @@ namespace Microsoft.Z3 /// ApplyResult objects represent the result of an application of a /// tactic to a goal. It contains the subgoals that were produced. /// - [ContractVerification(true)] public class ApplyResult : Z3Object { /// @@ -44,8 +43,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); - Contract.Ensures(Contract.Result().Length == this.NumSubgoals); uint n = NumSubgoals; Goal[] res = new Goal[n]; @@ -67,7 +64,7 @@ namespace Microsoft.Z3 internal ApplyResult(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/ArithExpr.cs b/src/api/dotnet/ArithExpr.cs index b6beaef0c..53b9db21d 100644 --- a/src/api/dotnet/ArithExpr.cs +++ b/src/api/dotnet/ArithExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 internal ArithExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion @@ -45,7 +45,7 @@ namespace Microsoft.Z3 private static ArithExpr MkNum(ArithExpr e, double d) { return (ArithExpr)e.Context.MkNumeral(d.ToString(), e.Context.MkRealSort()); } - /// Operator overloading for arithmetical divsion operator (over reals) + /// Operator overloading for arithmetical division operator (over reals) public static ArithExpr operator /(ArithExpr a, ArithExpr b) { return a.Context.MkDiv(a, b); } /// Operator overloading for arithmetical operator diff --git a/src/api/dotnet/ArithSort.cs b/src/api/dotnet/ArithSort.cs index f19774246..985aec7a9 100644 --- a/src/api/dotnet/ArithSort.cs +++ b/src/api/dotnet/ArithSort.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -28,7 +28,7 @@ namespace Microsoft.Z3 public class ArithSort : Sort { #region Internal - internal ArithSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal ArithSort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #endregion }; } diff --git a/src/api/dotnet/ArrayExpr.cs b/src/api/dotnet/ArrayExpr.cs index 6c51bfc5b..c53763886 100644 --- a/src/api/dotnet/ArrayExpr.cs +++ b/src/api/dotnet/ArrayExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 internal ArrayExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/ArraySort.cs b/src/api/dotnet/ArraySort.cs index 47a73ae1f..c5d15938e 100644 --- a/src/api/dotnet/ArraySort.cs +++ b/src/api/dotnet/ArraySort.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Array sorts. /// - [ContractVerification(true)] public class ArraySort : Sort { /// @@ -35,7 +34,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Sort.Create(Context, Native.Z3_get_array_sort_domain(Context.nCtx, NativeObject)); } @@ -48,27 +46,26 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Sort.Create(Context, Native.Z3_get_array_sort_range(Context.nCtx, NativeObject)); } } #region Internal - internal ArraySort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal ArraySort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } internal ArraySort(Context ctx, Sort domain, Sort range) : base(ctx, Native.Z3_mk_array_sort(ctx.nCtx, domain.NativeObject, range.NativeObject)) { - Contract.Requires(ctx != null); - Contract.Requires(domain != null); - Contract.Requires(range != null); + Debug.Assert(ctx != null); + Debug.Assert(domain != null); + Debug.Assert(range != null); } internal ArraySort(Context ctx, Sort[] domain, Sort range) : base(ctx, Native.Z3_mk_array_sort_n(ctx.nCtx, (uint)domain.Length, AST.ArrayToNative(domain), range.NativeObject)) { - Contract.Requires(ctx != null); - Contract.Requires(domain != null); - Contract.Requires(range != null); + Debug.Assert(ctx != null); + Debug.Assert(domain != null); + Debug.Assert(range != null); } #endregion }; diff --git a/src/api/dotnet/BitVecExpr.cs b/src/api/dotnet/BitVecExpr.cs index b019f8845..3efa0e9bd 100644 --- a/src/api/dotnet/BitVecExpr.cs +++ b/src/api/dotnet/BitVecExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -41,7 +41,7 @@ namespace Microsoft.Z3 #region Internal /// Constructor for BitVecExpr - internal BitVecExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal BitVecExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #endregion } } diff --git a/src/api/dotnet/BitVecNum.cs b/src/api/dotnet/BitVecNum.cs index 66054761a..5ee2d2ed8 100644 --- a/src/api/dotnet/BitVecNum.cs +++ b/src/api/dotnet/BitVecNum.cs @@ -16,8 +16,8 @@ Author: Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; #if !FRAMEWORK_LT_4 using System.Numerics; @@ -28,7 +28,6 @@ namespace Microsoft.Z3 /// /// Bit-vector numerals /// - [ContractVerification(true)] public class BitVecNum : BitVecExpr { /// @@ -109,7 +108,7 @@ namespace Microsoft.Z3 } #region Internal - internal BitVecNum(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal BitVecNum(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #endregion } } diff --git a/src/api/dotnet/BitVecSort.cs b/src/api/dotnet/BitVecSort.cs index d865159f4..fb41e76fe 100644 --- a/src/api/dotnet/BitVecSort.cs +++ b/src/api/dotnet/BitVecSort.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -36,7 +36,7 @@ namespace Microsoft.Z3 } #region Internal - internal BitVecSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal BitVecSort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #endregion }; } diff --git a/src/api/dotnet/BoolExpr.cs b/src/api/dotnet/BoolExpr.cs index c52109352..906090d2a 100644 --- a/src/api/dotnet/BoolExpr.cs +++ b/src/api/dotnet/BoolExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -32,7 +32,7 @@ namespace Microsoft.Z3 { #region Internal /// Constructor for BoolExpr - internal BoolExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal BoolExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #endregion #region Operators diff --git a/src/api/dotnet/BoolSort.cs b/src/api/dotnet/BoolSort.cs index 50f44c858..7fd6706a3 100644 --- a/src/api/dotnet/BoolSort.cs +++ b/src/api/dotnet/BoolSort.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -28,8 +28,8 @@ namespace Microsoft.Z3 public class BoolSort : Sort { #region Internal - internal BoolSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } - internal BoolSort(Context ctx) : base(ctx, Native.Z3_mk_bool_sort(ctx.nCtx)) { Contract.Requires(ctx != null); } + internal BoolSort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } + internal BoolSort(Context ctx) : base(ctx, Native.Z3_mk_bool_sort(ctx.nCtx)) { Debug.Assert(ctx != null); } #endregion }; } diff --git a/src/api/dotnet/Constructor.cs b/src/api/dotnet/Constructor.cs index 527b8bc13..f635d78e4 100644 --- a/src/api/dotnet/Constructor.cs +++ b/src/api/dotnet/Constructor.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Constructors are used for datatype sorts. /// - [ContractVerification(true)] public class Constructor : Z3Object { /// @@ -46,7 +45,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); IntPtr constructor = IntPtr.Zero; IntPtr tester = IntPtr.Zero; IntPtr[] accessors = new IntPtr[n]; @@ -62,7 +60,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); IntPtr constructor = IntPtr.Zero; IntPtr tester = IntPtr.Zero; IntPtr[] accessors = new IntPtr[n]; @@ -78,7 +75,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); IntPtr constructor = IntPtr.Zero; IntPtr tester = IntPtr.Zero; IntPtr[] accessors = new IntPtr[n]; @@ -105,9 +101,9 @@ namespace Microsoft.Z3 Sort[] sorts, uint[] sortRefs) : base(ctx) { - Contract.Requires(ctx != null); - Contract.Requires(name != null); - Contract.Requires(recognizer != null); + Debug.Assert(ctx != null); + Debug.Assert(name != null); + Debug.Assert(recognizer != null); n = AST.ArrayLength(fieldNames); diff --git a/src/api/dotnet/ConstructorList.cs b/src/api/dotnet/ConstructorList.cs index d625b5ade..9b9ba8561 100644 --- a/src/api/dotnet/ConstructorList.cs +++ b/src/api/dotnet/ConstructorList.cs @@ -17,12 +17,12 @@ Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -43,14 +43,14 @@ namespace Microsoft.Z3 internal ConstructorList(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal ConstructorList(Context ctx, Constructor[] constructors) : base(ctx) { - Contract.Requires(ctx != null); - Contract.Requires(constructors != null); + Debug.Assert(ctx != null); + Debug.Assert(constructors != null); NativeObject = Native.Z3_mk_constructor_list(Context.nCtx, (uint)constructors.Length, Constructor.ArrayToNative(constructors)); } diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index c8decb59b..97541e31f 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -18,9 +18,9 @@ Notes: --*/ using System; +using System.Diagnostics; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Diagnostics.Contracts; using System.Linq; namespace Microsoft.Z3 @@ -28,7 +28,6 @@ namespace Microsoft.Z3 /// /// The main interaction with Z3 happens via the Context. /// - [ContractVerification(true)] public class Context : IDisposable { #region Constructors @@ -66,7 +65,7 @@ namespace Microsoft.Z3 public Context(Dictionary settings) : base() { - Contract.Requires(settings != null); + Debug.Assert(settings != null); lock (creation_lock) { @@ -90,7 +89,6 @@ namespace Microsoft.Z3 /// public IntSymbol MkSymbol(int i) { - Contract.Ensures(Contract.Result() != null); return new IntSymbol(this, i); } @@ -100,7 +98,6 @@ namespace Microsoft.Z3 /// public StringSymbol MkSymbol(string name) { - Contract.Ensures(Contract.Result() != null); return new StringSymbol(this, name); } @@ -110,10 +107,6 @@ namespace Microsoft.Z3 /// internal Symbol[] MkSymbols(string[] names) { - Contract.Ensures(names == null || Contract.Result() != null); - Contract.Ensures(names != null || Contract.Result() == null); - Contract.Ensures(Contract.Result() == null || Contract.Result().Length == names.Length); - Contract.Ensures(Contract.Result() == null || Contract.ForAll(Contract.Result(), s => s != null)); if (names == null) return null; Symbol[] result = new Symbol[names.Length]; @@ -135,7 +128,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); if (m_boolSort == null) m_boolSort = new BoolSort(this); return m_boolSort; } } @@ -147,7 +139,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); if (m_intSort == null) m_intSort = new IntSort(this); return m_intSort; } } @@ -160,7 +151,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); if (m_realSort == null) m_realSort = new RealSort(this); return m_realSort; } } @@ -172,7 +162,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); if (m_stringSort == null) m_stringSort = new SeqSort(this, Native.Z3_mk_string_sort(nCtx)); return m_stringSort; } @@ -184,7 +173,6 @@ namespace Microsoft.Z3 /// public BoolSort MkBoolSort() { - Contract.Ensures(Contract.Result() != null); return new BoolSort(this); } @@ -193,8 +181,7 @@ namespace Microsoft.Z3 /// public UninterpretedSort MkUninterpretedSort(Symbol s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); CheckContextMatch(s); return new UninterpretedSort(this, s); @@ -205,7 +192,6 @@ namespace Microsoft.Z3 /// public UninterpretedSort MkUninterpretedSort(string str) { - Contract.Ensures(Contract.Result() != null); return MkUninterpretedSort(MkSymbol(str)); } @@ -215,7 +201,6 @@ namespace Microsoft.Z3 /// public IntSort MkIntSort() { - Contract.Ensures(Contract.Result() != null); return new IntSort(this); } @@ -225,7 +210,6 @@ namespace Microsoft.Z3 /// public RealSort MkRealSort() { - Contract.Ensures(Contract.Result() != null); return new RealSort(this); } @@ -234,7 +218,6 @@ namespace Microsoft.Z3 /// public BitVecSort MkBitVecSort(uint size) { - Contract.Ensures(Contract.Result() != null); return new BitVecSort(this, Native.Z3_mk_bv_sort(nCtx, size)); } @@ -245,8 +228,7 @@ namespace Microsoft.Z3 /// public SeqSort MkSeqSort(Sort s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); return new SeqSort(this, Native.Z3_mk_seq_sort(nCtx, s.NativeObject)); } @@ -255,8 +237,7 @@ namespace Microsoft.Z3 /// public ReSort MkReSort(SeqSort s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); return new ReSort(this, Native.Z3_mk_re_sort(nCtx, s.NativeObject)); } @@ -265,9 +246,8 @@ namespace Microsoft.Z3 /// public ArraySort MkArraySort(Sort domain, Sort range) { - Contract.Requires(domain != null); - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(domain != null); + Debug.Assert(range != null); CheckContextMatch(domain); CheckContextMatch(range); @@ -279,9 +259,8 @@ namespace Microsoft.Z3 /// public ArraySort MkArraySort(Sort[] domain, Sort range) { - Contract.Requires(domain != null); - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(domain != null); + Debug.Assert(range != null); CheckContextMatch(domain); CheckContextMatch(range); @@ -293,11 +272,10 @@ namespace Microsoft.Z3 /// public TupleSort MkTupleSort(Symbol name, Symbol[] fieldNames, Sort[] fieldSorts) { - Contract.Requires(name != null); - Contract.Requires(fieldNames != null); - Contract.Requires(Contract.ForAll(fieldNames, fn => fn != null)); - Contract.Requires(fieldSorts == null || Contract.ForAll(fieldSorts, fs => fs != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); + Debug.Assert(fieldNames != null); + Debug.Assert(fieldNames.All(fn => fn != null)); + Debug.Assert(fieldSorts == null || fieldSorts.All(fs => fs != null)); CheckContextMatch(name); CheckContextMatch(fieldNames); @@ -310,11 +288,10 @@ namespace Microsoft.Z3 /// public EnumSort MkEnumSort(Symbol name, params Symbol[] enumNames) { - Contract.Requires(name != null); - Contract.Requires(enumNames != null); - Contract.Requires(Contract.ForAll(enumNames, f => f != null)); + Debug.Assert(name != null); + Debug.Assert(enumNames != null); + Debug.Assert(enumNames.All(f => f != null)); - Contract.Ensures(Contract.Result() != null); CheckContextMatch(name); CheckContextMatch(enumNames); @@ -326,8 +303,7 @@ namespace Microsoft.Z3 /// public EnumSort MkEnumSort(string name, params string[] enumNames) { - Contract.Requires(enumNames != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(enumNames != null); return new EnumSort(this, MkSymbol(name), MkSymbols(enumNames)); } @@ -337,9 +313,8 @@ namespace Microsoft.Z3 /// public ListSort MkListSort(Symbol name, Sort elemSort) { - Contract.Requires(name != null); - Contract.Requires(elemSort != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); + Debug.Assert(elemSort != null); CheckContextMatch(name); CheckContextMatch(elemSort); @@ -351,8 +326,7 @@ namespace Microsoft.Z3 /// public ListSort MkListSort(string name, Sort elemSort) { - Contract.Requires(elemSort != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(elemSort != null); CheckContextMatch(elemSort); return new ListSort(this, MkSymbol(name), elemSort); @@ -366,8 +340,7 @@ namespace Microsoft.Z3 /// The size of the sort public FiniteDomainSort MkFiniteDomainSort(Symbol name, ulong size) { - Contract.Requires(name != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); CheckContextMatch(name); return new FiniteDomainSort(this, name, size); @@ -383,7 +356,6 @@ namespace Microsoft.Z3 /// The size of the sort public FiniteDomainSort MkFiniteDomainSort(string name, ulong size) { - Contract.Ensures(Contract.Result() != null); return new FiniteDomainSort(this, MkSymbol(name), size); } @@ -402,9 +374,8 @@ namespace Microsoft.Z3 /// referring to one of the recursive datatypes that is declared. public Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames = null, Sort[] sorts = null, uint[] sortRefs = null) { - Contract.Requires(name != null); - Contract.Requires(recognizer != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); + Debug.Assert(recognizer != null); return new Constructor(this, name, recognizer, fieldNames, sorts, sortRefs); } @@ -420,7 +391,6 @@ namespace Microsoft.Z3 /// public Constructor MkConstructor(string name, string recognizer, string[] fieldNames = null, Sort[] sorts = null, uint[] sortRefs = null) { - Contract.Ensures(Contract.Result() != null); return new Constructor(this, MkSymbol(name), MkSymbol(recognizer), MkSymbols(fieldNames), sorts, sortRefs); } @@ -430,11 +400,10 @@ namespace Microsoft.Z3 /// public DatatypeSort MkDatatypeSort(Symbol name, Constructor[] constructors) { - Contract.Requires(name != null); - Contract.Requires(constructors != null); - Contract.Requires(Contract.ForAll(constructors, c => c != null)); + Debug.Assert(name != null); + Debug.Assert(constructors != null); + Debug.Assert(constructors.All(c => c != null)); - Contract.Ensures(Contract.Result() != null); CheckContextMatch(name); CheckContextMatch(constructors); @@ -446,9 +415,8 @@ namespace Microsoft.Z3 /// public DatatypeSort MkDatatypeSort(string name, Constructor[] constructors) { - Contract.Requires(constructors != null); - Contract.Requires(Contract.ForAll(constructors, c => c != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(constructors != null); + Debug.Assert(constructors.All(c => c != null)); CheckContextMatch(constructors); return new DatatypeSort(this, MkSymbol(name), constructors); @@ -461,12 +429,11 @@ namespace Microsoft.Z3 /// list of constructors, one list per sort. public DatatypeSort[] MkDatatypeSorts(Symbol[] names, Constructor[][] c) { - Contract.Requires(names != null); - Contract.Requires(c != null); - Contract.Requires(names.Length == c.Length); - Contract.Requires(Contract.ForAll(0, c.Length, j => c[j] != null)); - Contract.Requires(Contract.ForAll(names, name => name != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(names != null); + Debug.Assert(c != null); + Debug.Assert(names.Length == c.Length); + //Debug.Assert(Contract.ForAll(0, c.Length, j => c[j] != null)); + Debug.Assert(names.All(name => name != null)); CheckContextMatch(names); uint n = (uint)names.Length; @@ -475,7 +442,6 @@ namespace Microsoft.Z3 for (uint i = 0; i < n; i++) { Constructor[] constructor = c[i]; - Contract.Assume(Contract.ForAll(constructor, arr => arr != null), "Clousot does not support yet quantified formula on multidimensional arrays"); CheckContextMatch(constructor); cla[i] = new ConstructorList(this, constructor); n_constr[i] = cla[i].NativeObject; @@ -496,12 +462,11 @@ namespace Microsoft.Z3 /// public DatatypeSort[] MkDatatypeSorts(string[] names, Constructor[][] c) { - Contract.Requires(names != null); - Contract.Requires(c != null); - Contract.Requires(names.Length == c.Length); - Contract.Requires(Contract.ForAll(0, c.Length, j => c[j] != null)); - Contract.Requires(Contract.ForAll(names, name => name != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(names != null); + Debug.Assert(c != null); + Debug.Assert(names.Length == c.Length); + //Debug.Assert(Contract.ForAll(0, c.Length, j => c[j] != null)); + //Debug.Assert(names.All(name => name != null)); return MkDatatypeSorts(MkSymbols(names), c); } @@ -528,10 +493,9 @@ namespace Microsoft.Z3 /// public FuncDecl MkFuncDecl(Symbol name, Sort[] domain, Sort range) { - Contract.Requires(name != null); - Contract.Requires(range != null); - Contract.Requires(Contract.ForAll(domain, d => d != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); + Debug.Assert(range != null); + Debug.Assert(domain.All(d => d != null)); CheckContextMatch(name); CheckContextMatch(domain); @@ -544,10 +508,9 @@ namespace Microsoft.Z3 /// public FuncDecl MkFuncDecl(Symbol name, Sort domain, Sort range) { - Contract.Requires(name != null); - Contract.Requires(domain != null); - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); + Debug.Assert(domain != null); + Debug.Assert(range != null); CheckContextMatch(name); CheckContextMatch(domain); @@ -561,9 +524,8 @@ namespace Microsoft.Z3 /// public FuncDecl MkFuncDecl(string name, Sort[] domain, Sort range) { - Contract.Requires(range != null); - Contract.Requires(Contract.ForAll(domain, d => d != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(range != null); + Debug.Assert(domain.All(d => d != null)); CheckContextMatch(domain); CheckContextMatch(range); @@ -575,9 +537,8 @@ namespace Microsoft.Z3 /// public FuncDecl MkFuncDecl(string name, Sort domain, Sort range) { - Contract.Requires(range != null); - Contract.Requires(domain != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(range != null); + Debug.Assert(domain != null); CheckContextMatch(domain); CheckContextMatch(range); @@ -592,9 +553,8 @@ namespace Microsoft.Z3 /// public FuncDecl MkFreshFuncDecl(string prefix, Sort[] domain, Sort range) { - Contract.Requires(range != null); - Contract.Requires(Contract.ForAll(domain, d => d != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(range != null); + Debug.Assert(domain.All(d => d != null)); CheckContextMatch(domain); CheckContextMatch(range); @@ -606,9 +566,8 @@ namespace Microsoft.Z3 /// public FuncDecl MkConstDecl(Symbol name, Sort range) { - Contract.Requires(name != null); - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); + Debug.Assert(range != null); CheckContextMatch(name); CheckContextMatch(range); @@ -620,8 +579,7 @@ namespace Microsoft.Z3 /// public FuncDecl MkConstDecl(string name, Sort range) { - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(range != null); CheckContextMatch(range); return new FuncDecl(this, MkSymbol(name), null, range); @@ -634,8 +592,7 @@ namespace Microsoft.Z3 /// public FuncDecl MkFreshConstDecl(string prefix, Sort range) { - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(range != null); CheckContextMatch(range); return new FuncDecl(this, prefix, null, range); @@ -650,8 +607,7 @@ namespace Microsoft.Z3 /// The sort of the variable public Expr MkBound(uint index, Sort ty) { - Contract.Requires(ty != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ty != null); return Expr.Create(this, Native.Z3_mk_bound(nCtx, index, ty.NativeObject)); } @@ -663,14 +619,10 @@ namespace Microsoft.Z3 /// public Pattern MkPattern(params Expr[] terms) { - Contract.Requires(terms != null); + Debug.Assert(terms != null); if (terms.Length == 0) throw new Z3Exception("Cannot create a pattern from zero terms"); - Contract.Ensures(Contract.Result() != null); - - Contract.EndContractBlock(); - IntPtr[] termsNative = AST.ArrayToNative(terms); return new Pattern(this, Native.Z3_mk_pattern(nCtx, (uint)terms.Length, termsNative)); } @@ -682,9 +634,8 @@ namespace Microsoft.Z3 /// public Expr MkConst(Symbol name, Sort range) { - Contract.Requires(name != null); - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); + Debug.Assert(range != null); CheckContextMatch(name); CheckContextMatch(range); @@ -697,8 +648,7 @@ namespace Microsoft.Z3 /// public Expr MkConst(string name, Sort range) { - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(range != null); return MkConst(MkSymbol(name), range); } @@ -709,8 +659,7 @@ namespace Microsoft.Z3 /// public Expr MkFreshConst(string prefix, Sort range) { - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(range != null); CheckContextMatch(range); return Expr.Create(this, Native.Z3_mk_fresh_const(nCtx, prefix, range.NativeObject)); @@ -722,8 +671,7 @@ namespace Microsoft.Z3 /// A decl of a 0-arity function public Expr MkConst(FuncDecl f) { - Contract.Requires(f != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(f != null); return MkApp(f); } @@ -733,8 +681,7 @@ namespace Microsoft.Z3 /// public BoolExpr MkBoolConst(Symbol name) { - Contract.Requires(name != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); return (BoolExpr)MkConst(name, BoolSort); } @@ -744,7 +691,6 @@ namespace Microsoft.Z3 /// public BoolExpr MkBoolConst(string name) { - Contract.Ensures(Contract.Result() != null); return (BoolExpr)MkConst(MkSymbol(name), BoolSort); } @@ -754,8 +700,7 @@ namespace Microsoft.Z3 /// public IntExpr MkIntConst(Symbol name) { - Contract.Requires(name != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); return (IntExpr)MkConst(name, IntSort); } @@ -765,8 +710,7 @@ namespace Microsoft.Z3 /// public IntExpr MkIntConst(string name) { - Contract.Requires(name != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); return (IntExpr)MkConst(name, IntSort); } @@ -776,8 +720,7 @@ namespace Microsoft.Z3 /// public RealExpr MkRealConst(Symbol name) { - Contract.Requires(name != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); return (RealExpr)MkConst(name, RealSort); } @@ -787,7 +730,6 @@ namespace Microsoft.Z3 /// public RealExpr MkRealConst(string name) { - Contract.Ensures(Contract.Result() != null); return (RealExpr)MkConst(name, RealSort); } @@ -797,8 +739,7 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVConst(Symbol name, uint size) { - Contract.Requires(name != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); return (BitVecExpr)MkConst(name, MkBitVecSort(size)); } @@ -808,7 +749,6 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVConst(string name, uint size) { - Contract.Ensures(Contract.Result() != null); return (BitVecExpr)MkConst(name, MkBitVecSort(size)); } @@ -820,9 +760,8 @@ namespace Microsoft.Z3 /// public Expr MkApp(FuncDecl f, params Expr[] args) { - Contract.Requires(f != null); - Contract.Requires(args == null || Contract.ForAll(args, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(f != null); + Debug.Assert(args == null || args.All(a => a != null)); CheckContextMatch(f); CheckContextMatch(args); @@ -834,9 +773,8 @@ namespace Microsoft.Z3 /// public Expr MkApp(FuncDecl f, IEnumerable args) { - Contract.Requires(f != null); - Contract.Requires(args == null || Contract.ForAll(args, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(f != null); + Debug.Assert(args == null || args.All( a => a != null)); CheckContextMatch(f); CheckContextMatch(args); @@ -849,7 +787,6 @@ namespace Microsoft.Z3 /// public BoolExpr MkTrue() { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_true(nCtx)); } @@ -859,7 +796,6 @@ namespace Microsoft.Z3 /// public BoolExpr MkFalse() { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_false(nCtx)); } @@ -869,7 +805,6 @@ namespace Microsoft.Z3 /// public BoolExpr MkBool(bool value) { - Contract.Ensures(Contract.Result() != null); return value ? MkTrue() : MkFalse(); } @@ -879,9 +814,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkEq(Expr x, Expr y) { - Contract.Requires(x != null); - Contract.Requires(y != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(x != null); + Debug.Assert(y != null); CheckContextMatch(x); CheckContextMatch(y); @@ -893,10 +827,9 @@ namespace Microsoft.Z3 /// public BoolExpr MkDistinct(params Expr[] args) { - Contract.Requires(args != null); - Contract.Requires(Contract.ForAll(args, a => a != null)); + Debug.Assert(args != null); + Debug.Assert(args.All(a => a != null)); - Contract.Ensures(Contract.Result() != null); CheckContextMatch(args); return new BoolExpr(this, Native.Z3_mk_distinct(nCtx, (uint)args.Length, AST.ArrayToNative(args))); @@ -907,8 +840,7 @@ namespace Microsoft.Z3 /// public BoolExpr MkNot(BoolExpr a) { - Contract.Requires(a != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(a != null); CheckContextMatch(a); return new BoolExpr(this, Native.Z3_mk_not(nCtx, a.NativeObject)); @@ -922,10 +854,9 @@ namespace Microsoft.Z3 /// An expression with the same sort as public Expr MkITE(BoolExpr t1, Expr t2, Expr t3) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Requires(t3 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); + Debug.Assert(t3 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -938,9 +869,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkIff(BoolExpr t1, BoolExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -952,9 +882,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkImplies(BoolExpr t1, BoolExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -966,9 +895,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkXor(BoolExpr t1, BoolExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -980,9 +908,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkAnd(params BoolExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return new BoolExpr(this, Native.Z3_mk_and(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -993,9 +920,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkAnd(IEnumerable t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return new BoolExpr(this, Native.Z3_mk_and(nCtx, (uint)t.Count(), AST.EnumToNative(t))); } @@ -1005,9 +931,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkOr(params BoolExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return new BoolExpr(this, Native.Z3_mk_or(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -1019,9 +944,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkOr(IEnumerable t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return new BoolExpr(this, Native.Z3_mk_or(nCtx, (uint)t.Count(), AST.EnumToNative(t))); @@ -1035,9 +959,8 @@ namespace Microsoft.Z3 /// public ArithExpr MkAdd(params ArithExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return (ArithExpr)Expr.Create(this, Native.Z3_mk_add(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -1048,9 +971,8 @@ namespace Microsoft.Z3 /// public ArithExpr MkAdd(IEnumerable t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return (ArithExpr)Expr.Create(this, Native.Z3_mk_add(nCtx, (uint)t.Count(), AST.EnumToNative(t))); @@ -1061,9 +983,8 @@ namespace Microsoft.Z3 /// public ArithExpr MkMul(params ArithExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return (ArithExpr)Expr.Create(this, Native.Z3_mk_mul(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -1074,9 +995,8 @@ namespace Microsoft.Z3 /// public ArithExpr MkMul(IEnumerable t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return (ArithExpr)Expr.Create(this, Native.Z3_mk_mul(nCtx, (uint)t.Count(), AST.EnumToNative(t))); @@ -1087,9 +1007,8 @@ namespace Microsoft.Z3 /// public ArithExpr MkSub(params ArithExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return (ArithExpr)Expr.Create(this, Native.Z3_mk_sub(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -1100,8 +1019,7 @@ namespace Microsoft.Z3 /// public ArithExpr MkUnaryMinus(ArithExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return (ArithExpr)Expr.Create(this, Native.Z3_mk_unary_minus(nCtx, t.NativeObject)); @@ -1112,9 +1030,8 @@ namespace Microsoft.Z3 /// public ArithExpr MkDiv(ArithExpr t1, ArithExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1127,9 +1044,8 @@ namespace Microsoft.Z3 /// The arguments must have int type. public IntExpr MkMod(IntExpr t1, IntExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1142,9 +1058,8 @@ namespace Microsoft.Z3 /// The arguments must have int type. public IntExpr MkRem(IntExpr t1, IntExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1156,9 +1071,8 @@ namespace Microsoft.Z3 /// public ArithExpr MkPower(ArithExpr t1, ArithExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1170,9 +1084,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkLt(ArithExpr t1, ArithExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1184,9 +1097,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkLe(ArithExpr t1, ArithExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1198,9 +1110,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkGt(ArithExpr t1, ArithExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1212,9 +1123,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkGe(ArithExpr t1, ArithExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1233,8 +1143,7 @@ namespace Microsoft.Z3 /// public RealExpr MkInt2Real(IntExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new RealExpr(this, Native.Z3_mk_int2real(nCtx, t.NativeObject)); @@ -1249,8 +1158,7 @@ namespace Microsoft.Z3 /// public IntExpr MkReal2Int(RealExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new IntExpr(this, Native.Z3_mk_real2int(nCtx, t.NativeObject)); @@ -1261,8 +1169,7 @@ namespace Microsoft.Z3 /// public BoolExpr MkIsInteger(RealExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BoolExpr(this, Native.Z3_mk_is_int(nCtx, t.NativeObject)); @@ -1276,8 +1183,7 @@ namespace Microsoft.Z3 /// The argument must have a bit-vector sort. public BitVecExpr MkBVNot(BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_bvnot(nCtx, t.NativeObject)); @@ -1289,8 +1195,7 @@ namespace Microsoft.Z3 /// The argument must have a bit-vector sort. public BitVecExpr MkBVRedAND(BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_bvredand(nCtx, t.NativeObject)); @@ -1302,8 +1207,7 @@ namespace Microsoft.Z3 /// The argument must have a bit-vector sort. public BitVecExpr MkBVRedOR(BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_bvredor(nCtx, t.NativeObject)); @@ -1315,9 +1219,8 @@ namespace Microsoft.Z3 /// The arguments must have a bit-vector sort. public BitVecExpr MkBVAND(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1330,9 +1233,8 @@ namespace Microsoft.Z3 /// The arguments must have a bit-vector sort. public BitVecExpr MkBVOR(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1345,9 +1247,8 @@ namespace Microsoft.Z3 /// The arguments must have a bit-vector sort. public BitVecExpr MkBVXOR(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1360,9 +1261,8 @@ namespace Microsoft.Z3 /// The arguments must have a bit-vector sort. public BitVecExpr MkBVNAND(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1375,9 +1275,8 @@ namespace Microsoft.Z3 /// The arguments must have a bit-vector sort. public BitVecExpr MkBVNOR(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1390,9 +1289,8 @@ namespace Microsoft.Z3 /// The arguments must have a bit-vector sort. public BitVecExpr MkBVXNOR(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1405,8 +1303,7 @@ namespace Microsoft.Z3 /// The arguments must have a bit-vector sort. public BitVecExpr MkBVNeg(BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_bvneg(nCtx, t.NativeObject)); @@ -1418,9 +1315,8 @@ namespace Microsoft.Z3 /// The arguments must have the same bit-vector sort. public BitVecExpr MkBVAdd(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1433,9 +1329,8 @@ namespace Microsoft.Z3 /// The arguments must have the same bit-vector sort. public BitVecExpr MkBVSub(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1448,9 +1343,8 @@ namespace Microsoft.Z3 /// The arguments must have the same bit-vector sort. public BitVecExpr MkBVMul(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1468,9 +1362,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVUDiv(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1492,9 +1385,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVSDiv(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1511,9 +1403,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVURem(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1532,9 +1423,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVSRem(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1550,9 +1440,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVSMod(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1567,9 +1456,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVULT(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1584,9 +1472,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVSLT(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1601,9 +1488,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVULE(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1618,9 +1504,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVSLE(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1635,9 +1520,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVUGE(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1652,9 +1536,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVSGE(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1669,9 +1552,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVUGT(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1686,9 +1568,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVSGT(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1707,9 +1588,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkConcat(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1727,8 +1607,7 @@ namespace Microsoft.Z3 /// public BitVecExpr MkExtract(uint high, uint low, BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_extract(nCtx, high, low, t.NativeObject)); @@ -1744,8 +1623,7 @@ namespace Microsoft.Z3 /// public BitVecExpr MkSignExt(uint i, BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_sign_ext(nCtx, i, t.NativeObject)); @@ -1762,8 +1640,7 @@ namespace Microsoft.Z3 /// public BitVecExpr MkZeroExt(uint i, BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_zero_ext(nCtx, i, t.NativeObject)); @@ -1777,8 +1654,7 @@ namespace Microsoft.Z3 /// public BitVecExpr MkRepeat(uint i, BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_repeat(nCtx, i, t.NativeObject)); @@ -1798,9 +1674,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVSHL(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1821,9 +1696,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVLSHR(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1846,9 +1720,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVASHR(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1864,8 +1737,7 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVRotateLeft(uint i, BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_rotate_left(nCtx, i, t.NativeObject)); @@ -1880,8 +1752,7 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVRotateRight(uint i, BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_rotate_right(nCtx, i, t.NativeObject)); @@ -1896,9 +1767,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVRotateLeft(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1914,9 +1784,8 @@ namespace Microsoft.Z3 /// public BitVecExpr MkBVRotateRight(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1935,8 +1804,7 @@ namespace Microsoft.Z3 /// public BitVecExpr MkInt2BV(uint n, IntExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BitVecExpr(this, Native.Z3_mk_int2bv(nCtx, n, t.NativeObject)); @@ -1959,8 +1827,7 @@ namespace Microsoft.Z3 /// public IntExpr MkBV2Int(BitVecExpr t, bool signed) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new IntExpr(this, Native.Z3_mk_bv2int(nCtx, t.NativeObject, (byte)(signed ? 1 : 0))); @@ -1974,9 +1841,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVAddNoOverflow(BitVecExpr t1, BitVecExpr t2, bool isSigned) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -1991,9 +1857,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVAddNoUnderflow(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -2008,9 +1873,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVSubNoOverflow(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -2025,9 +1889,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVSubNoUnderflow(BitVecExpr t1, BitVecExpr t2, bool isSigned) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -2042,9 +1905,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVSDivNoOverflow(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -2059,8 +1921,7 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVNegNoOverflow(BitVecExpr t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new BoolExpr(this, Native.Z3_mk_bvneg_no_overflow(nCtx, t.NativeObject)); @@ -2074,9 +1935,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVMulNoOverflow(BitVecExpr t1, BitVecExpr t2, bool isSigned) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -2091,9 +1951,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkBVMulNoUnderflow(BitVecExpr t1, BitVecExpr t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -2107,10 +1966,9 @@ namespace Microsoft.Z3 /// public ArrayExpr MkArrayConst(Symbol name, Sort domain, Sort range) { - Contract.Requires(name != null); - Contract.Requires(domain != null); - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(name != null); + Debug.Assert(domain != null); + Debug.Assert(range != null); return (ArrayExpr)MkConst(name, MkArraySort(domain, range)); } @@ -2120,9 +1978,8 @@ namespace Microsoft.Z3 /// public ArrayExpr MkArrayConst(string name, Sort domain, Sort range) { - Contract.Requires(domain != null); - Contract.Requires(range != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(domain != null); + Debug.Assert(range != null); return (ArrayExpr)MkConst(MkSymbol(name), MkArraySort(domain, range)); } @@ -2143,9 +2000,8 @@ namespace Microsoft.Z3 /// public Expr MkSelect(ArrayExpr a, Expr i) { - Contract.Requires(a != null); - Contract.Requires(i != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(a != null); + Debug.Assert(i != null); CheckContextMatch(a); CheckContextMatch(i); @@ -2167,9 +2023,8 @@ namespace Microsoft.Z3 /// public Expr MkSelect(ArrayExpr a, params Expr[] args) { - Contract.Requires(a != null); - Contract.Requires(args != null && Contract.ForAll(args, n => n != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(a != null); + Debug.Assert(args != null && args.All(n => n != null)); CheckContextMatch(a); CheckContextMatch(args); @@ -2196,10 +2051,9 @@ namespace Microsoft.Z3 /// public ArrayExpr MkStore(ArrayExpr a, Expr i, Expr v) { - Contract.Requires(a != null); - Contract.Requires(i != null); - Contract.Requires(v != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(a != null); + Debug.Assert(i != null); + Debug.Assert(v != null); CheckContextMatch(a); CheckContextMatch(i); @@ -2227,10 +2081,9 @@ namespace Microsoft.Z3 /// public ArrayExpr MkStore(ArrayExpr a, Expr[] args, Expr v) { - Contract.Requires(a != null); - Contract.Requires(args != null); - Contract.Requires(v != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(a != null); + Debug.Assert(args != null); + Debug.Assert(v != null); CheckContextMatch(args); CheckContextMatch(a); @@ -2249,9 +2102,8 @@ namespace Microsoft.Z3 /// public ArrayExpr MkConstArray(Sort domain, Expr v) { - Contract.Requires(domain != null); - Contract.Requires(v != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(domain != null); + Debug.Assert(v != null); CheckContextMatch(domain); CheckContextMatch(v); @@ -2271,9 +2123,8 @@ namespace Microsoft.Z3 /// public ArrayExpr MkMap(FuncDecl f, params ArrayExpr[] args) { - Contract.Requires(f != null); - Contract.Requires(args == null || Contract.ForAll(args, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(f != null); + Debug.Assert(args == null || args.All(a => a != null)); CheckContextMatch(f); CheckContextMatch(args); @@ -2289,8 +2140,7 @@ namespace Microsoft.Z3 /// public Expr MkTermArray(ArrayExpr array) { - Contract.Requires(array != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(array != null); CheckContextMatch(array); return Expr.Create(this, Native.Z3_mk_array_default(nCtx, array.NativeObject)); @@ -2301,9 +2151,8 @@ namespace Microsoft.Z3 /// public Expr MkArrayExt(ArrayExpr arg1, ArrayExpr arg2) { - Contract.Requires(arg1 != null); - Contract.Requires(arg2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(arg1 != null); + Debug.Assert(arg2 != null); CheckContextMatch(arg1); CheckContextMatch(arg2); @@ -2318,8 +2167,7 @@ namespace Microsoft.Z3 /// public SetSort MkSetSort(Sort ty) { - Contract.Requires(ty != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ty != null); CheckContextMatch(ty); return new SetSort(this, ty); @@ -2330,8 +2178,7 @@ namespace Microsoft.Z3 /// public ArrayExpr MkEmptySet(Sort domain) { - Contract.Requires(domain != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(domain != null); CheckContextMatch(domain); return (ArrayExpr)Expr.Create(this, Native.Z3_mk_empty_set(nCtx, domain.NativeObject)); @@ -2342,8 +2189,7 @@ namespace Microsoft.Z3 /// public ArrayExpr MkFullSet(Sort domain) { - Contract.Requires(domain != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(domain != null); CheckContextMatch(domain); return (ArrayExpr)Expr.Create(this, Native.Z3_mk_full_set(nCtx, domain.NativeObject)); @@ -2354,9 +2200,8 @@ namespace Microsoft.Z3 /// public ArrayExpr MkSetAdd(ArrayExpr set, Expr element) { - Contract.Requires(set != null); - Contract.Requires(element != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(set != null); + Debug.Assert(element != null); CheckContextMatch(set); CheckContextMatch(element); @@ -2369,9 +2214,8 @@ namespace Microsoft.Z3 /// public ArrayExpr MkSetDel(ArrayExpr set, Expr element) { - Contract.Requires(set != null); - Contract.Requires(element != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(set != null); + Debug.Assert(element != null); CheckContextMatch(set); CheckContextMatch(element); @@ -2383,8 +2227,8 @@ namespace Microsoft.Z3 /// public ArrayExpr MkSetUnion(params ArrayExpr[] args) { - Contract.Requires(args != null); - Contract.Requires(Contract.ForAll(args, a => a != null)); + Debug.Assert(args != null); + Debug.Assert(args.All(a => a != null)); CheckContextMatch(args); return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_union(nCtx, (uint)args.Length, AST.ArrayToNative(args))); @@ -2395,9 +2239,8 @@ namespace Microsoft.Z3 /// public ArrayExpr MkSetIntersection(params ArrayExpr[] args) { - Contract.Requires(args != null); - Contract.Requires(Contract.ForAll(args, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(args != null); + Debug.Assert(args.All(a => a != null)); CheckContextMatch(args); return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_intersect(nCtx, (uint)args.Length, AST.ArrayToNative(args))); @@ -2408,9 +2251,8 @@ namespace Microsoft.Z3 /// public ArrayExpr MkSetDifference(ArrayExpr arg1, ArrayExpr arg2) { - Contract.Requires(arg1 != null); - Contract.Requires(arg2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(arg1 != null); + Debug.Assert(arg2 != null); CheckContextMatch(arg1); CheckContextMatch(arg2); @@ -2422,8 +2264,7 @@ namespace Microsoft.Z3 /// public ArrayExpr MkSetComplement(ArrayExpr arg) { - Contract.Requires(arg != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(arg != null); CheckContextMatch(arg); return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_complement(nCtx, arg.NativeObject)); @@ -2434,9 +2275,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkSetMembership(Expr elem, ArrayExpr set) { - Contract.Requires(elem != null); - Contract.Requires(set != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(elem != null); + Debug.Assert(set != null); CheckContextMatch(elem); CheckContextMatch(set); @@ -2448,9 +2288,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkSetSubset(ArrayExpr arg1, ArrayExpr arg2) { - Contract.Requires(arg1 != null); - Contract.Requires(arg2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(arg1 != null); + Debug.Assert(arg2 != null); CheckContextMatch(arg1); CheckContextMatch(arg2); @@ -2459,15 +2298,14 @@ namespace Microsoft.Z3 #endregion - #region Sequence, string and regular expresions + #region Sequence, string and regular expressions /// /// Create the empty sequence. /// public SeqExpr MkEmptySeq(Sort s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); return new SeqExpr(this, Native.Z3_mk_seq_empty(nCtx, s.NativeObject)); } @@ -2476,8 +2314,7 @@ namespace Microsoft.Z3 /// public SeqExpr MkUnit(Expr elem) { - Contract.Requires(elem != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(elem != null); return new SeqExpr(this, Native.Z3_mk_seq_unit(nCtx, elem.NativeObject)); } @@ -2486,8 +2323,7 @@ namespace Microsoft.Z3 /// public SeqExpr MkString(string s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); return new SeqExpr(this, Native.Z3_mk_string(nCtx, s)); } @@ -2496,9 +2332,8 @@ namespace Microsoft.Z3 /// public SeqExpr IntToString(Expr e) { - Contract.Requires(e != null); - Contract.Requires(e is ArithExpr); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(e != null); + Debug.Assert(e is ArithExpr); return new SeqExpr(this, Native.Z3_mk_int_to_str(nCtx, e.NativeObject)); } @@ -2507,9 +2342,8 @@ namespace Microsoft.Z3 /// public IntExpr StringToInt(Expr e) { - Contract.Requires(e != null); - Contract.Requires(e is SeqExpr); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(e != null); + Debug.Assert(e is SeqExpr); return new IntExpr(this, Native.Z3_mk_str_to_int(nCtx, e.NativeObject)); } @@ -2519,9 +2353,8 @@ namespace Microsoft.Z3 /// public SeqExpr MkConcat(params SeqExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return new SeqExpr(this, Native.Z3_mk_seq_concat(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -2533,8 +2366,7 @@ namespace Microsoft.Z3 /// public IntExpr MkLength(SeqExpr s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); return (IntExpr) Expr.Create(this, Native.Z3_mk_seq_length(nCtx, s.NativeObject)); } @@ -2543,9 +2375,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkPrefixOf(SeqExpr s1, SeqExpr s2) { - Contract.Requires(s1 != null); - Contract.Requires(s2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s1 != null); + Debug.Assert(s2 != null); CheckContextMatch(s1, s2); return new BoolExpr(this, Native.Z3_mk_seq_prefix(nCtx, s1.NativeObject, s2.NativeObject)); } @@ -2555,9 +2386,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkSuffixOf(SeqExpr s1, SeqExpr s2) { - Contract.Requires(s1 != null); - Contract.Requires(s2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s1 != null); + Debug.Assert(s2 != null); CheckContextMatch(s1, s2); return new BoolExpr(this, Native.Z3_mk_seq_suffix(nCtx, s1.NativeObject, s2.NativeObject)); } @@ -2567,9 +2397,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkContains(SeqExpr s1, SeqExpr s2) { - Contract.Requires(s1 != null); - Contract.Requires(s2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s1 != null); + Debug.Assert(s2 != null); CheckContextMatch(s1, s2); return new BoolExpr(this, Native.Z3_mk_seq_contains(nCtx, s1.NativeObject, s2.NativeObject)); } @@ -2579,9 +2408,8 @@ namespace Microsoft.Z3 /// public SeqExpr MkAt(SeqExpr s, IntExpr index) { - Contract.Requires(s != null); - Contract.Requires(index != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); + Debug.Assert(index != null); CheckContextMatch(s, index); return new SeqExpr(this, Native.Z3_mk_seq_at(nCtx, s.NativeObject, index.NativeObject)); } @@ -2591,10 +2419,9 @@ namespace Microsoft.Z3 /// public SeqExpr MkExtract(SeqExpr s, IntExpr offset, IntExpr length) { - Contract.Requires(s != null); - Contract.Requires(offset != null); - Contract.Requires(length != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); + Debug.Assert(offset != null); + Debug.Assert(length != null); CheckContextMatch(s, offset, length); return new SeqExpr(this, Native.Z3_mk_seq_extract(nCtx, s.NativeObject, offset.NativeObject, length.NativeObject)); } @@ -2604,10 +2431,9 @@ namespace Microsoft.Z3 /// public IntExpr MkIndexOf(SeqExpr s, SeqExpr substr, ArithExpr offset) { - Contract.Requires(s != null); - Contract.Requires(offset != null); - Contract.Requires(substr != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); + Debug.Assert(offset != null); + Debug.Assert(substr != null); CheckContextMatch(s, substr, offset); return new IntExpr(this, Native.Z3_mk_seq_index(nCtx, s.NativeObject, substr.NativeObject, offset.NativeObject)); } @@ -2617,10 +2443,9 @@ namespace Microsoft.Z3 /// public SeqExpr MkReplace(SeqExpr s, SeqExpr src, SeqExpr dst) { - Contract.Requires(s != null); - Contract.Requires(src != null); - Contract.Requires(dst != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); + Debug.Assert(src != null); + Debug.Assert(dst != null); CheckContextMatch(s, src, dst); return new SeqExpr(this, Native.Z3_mk_seq_replace(nCtx, s.NativeObject, src.NativeObject, dst.NativeObject)); } @@ -2630,8 +2455,7 @@ namespace Microsoft.Z3 /// public ReExpr MkToRe(SeqExpr s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); return new ReExpr(this, Native.Z3_mk_seq_to_re(nCtx, s.NativeObject)); } @@ -2641,9 +2465,8 @@ namespace Microsoft.Z3 /// public BoolExpr MkInRe(SeqExpr s, ReExpr re) { - Contract.Requires(s != null); - Contract.Requires(re != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); + Debug.Assert(re != null); CheckContextMatch(s, re); return new BoolExpr(this, Native.Z3_mk_seq_in_re(nCtx, s.NativeObject, re.NativeObject)); } @@ -2653,8 +2476,7 @@ namespace Microsoft.Z3 /// public ReExpr MkStar(ReExpr re) { - Contract.Requires(re != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(re != null); return new ReExpr(this, Native.Z3_mk_re_star(nCtx, re.NativeObject)); } @@ -2663,8 +2485,7 @@ namespace Microsoft.Z3 /// public ReExpr MkLoop(ReExpr re, uint lo, uint hi = 0) { - Contract.Requires(re != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(re != null); return new ReExpr(this, Native.Z3_mk_re_loop(nCtx, re.NativeObject, lo, hi)); } @@ -2673,8 +2494,7 @@ namespace Microsoft.Z3 /// public ReExpr MkPlus(ReExpr re) { - Contract.Requires(re != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(re != null); return new ReExpr(this, Native.Z3_mk_re_plus(nCtx, re.NativeObject)); } @@ -2683,8 +2503,7 @@ namespace Microsoft.Z3 /// public ReExpr MkOption(ReExpr re) { - Contract.Requires(re != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(re != null); return new ReExpr(this, Native.Z3_mk_re_option(nCtx, re.NativeObject)); } @@ -2693,8 +2512,7 @@ namespace Microsoft.Z3 /// public ReExpr MkComplement(ReExpr re) { - Contract.Requires(re != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(re != null); return new ReExpr(this, Native.Z3_mk_re_complement(nCtx, re.NativeObject)); } @@ -2703,9 +2521,8 @@ namespace Microsoft.Z3 /// public ReExpr MkConcat(params ReExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return new ReExpr(this, Native.Z3_mk_re_concat(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -2716,9 +2533,8 @@ namespace Microsoft.Z3 /// public ReExpr MkUnion(params ReExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return new ReExpr(this, Native.Z3_mk_re_union(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -2729,9 +2545,8 @@ namespace Microsoft.Z3 /// public ReExpr MkIntersect(params ReExpr[] t) { - Contract.Requires(t != null); - Contract.Requires(Contract.ForAll(t, a => a != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(t.All(a => a != null)); CheckContextMatch(t); return new ReExpr(this, Native.Z3_mk_re_intersect(nCtx, (uint)t.Length, AST.ArrayToNative(t))); @@ -2742,8 +2557,7 @@ namespace Microsoft.Z3 /// public ReExpr MkEmptyRe(Sort s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); return new ReExpr(this, Native.Z3_mk_re_empty(nCtx, s.NativeObject)); } @@ -2752,8 +2566,7 @@ namespace Microsoft.Z3 /// public ReExpr MkFullRe(Sort s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); return new ReExpr(this, Native.Z3_mk_re_full(nCtx, s.NativeObject)); } @@ -2763,9 +2576,8 @@ namespace Microsoft.Z3 /// public ReExpr MkRange(SeqExpr lo, SeqExpr hi) { - Contract.Requires(lo != null); - Contract.Requires(hi != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(lo != null); + Debug.Assert(hi != null); CheckContextMatch(lo, hi); return new ReExpr(this, Native.Z3_mk_re_range(nCtx, lo.NativeObject, hi.NativeObject)); } @@ -2779,8 +2591,7 @@ namespace Microsoft.Z3 /// public BoolExpr MkAtMost(IEnumerable args, uint k) { - Contract.Requires(args != null); - Contract.Requires(Contract.Result() != null); + Debug.Assert(args != null); CheckContextMatch(args); return new BoolExpr(this, Native.Z3_mk_atmost(nCtx, (uint) args.Count(), AST.EnumToNative(args), k)); @@ -2791,8 +2602,7 @@ namespace Microsoft.Z3 /// public BoolExpr MkAtLeast(IEnumerable args, uint k) { - Contract.Requires(args != null); - Contract.Requires(Contract.Result() != null); + Debug.Assert(args != null); CheckContextMatch(args); return new BoolExpr(this, Native.Z3_mk_atleast(nCtx, (uint) args.Count(), AST.EnumToNative(args), k)); @@ -2803,10 +2613,9 @@ namespace Microsoft.Z3 /// public BoolExpr MkPBLe(int[] coeffs, BoolExpr[] args, int k) { - Contract.Requires(args != null); - Contract.Requires(coeffs != null); - Contract.Requires(args.Length == coeffs.Length); - Contract.Requires(Contract.Result() != null); + Debug.Assert(args != null); + Debug.Assert(coeffs != null); + Debug.Assert(args.Length == coeffs.Length); CheckContextMatch(args); return new BoolExpr(this, Native.Z3_mk_pble(nCtx, (uint) args.Length, AST.ArrayToNative(args), @@ -2818,10 +2627,9 @@ namespace Microsoft.Z3 /// public BoolExpr MkPBGe(int[] coeffs, BoolExpr[] args, int k) { - Contract.Requires(args != null); - Contract.Requires(coeffs != null); - Contract.Requires(args.Length == coeffs.Length); - Contract.Requires(Contract.Result() != null); + Debug.Assert(args != null); + Debug.Assert(coeffs != null); + Debug.Assert(args.Length == coeffs.Length); CheckContextMatch(args); return new BoolExpr(this, Native.Z3_mk_pbge(nCtx, (uint) args.Length, AST.ArrayToNative(args), @@ -2832,10 +2640,9 @@ namespace Microsoft.Z3 /// public BoolExpr MkPBEq(int[] coeffs, BoolExpr[] args, int k) { - Contract.Requires(args != null); - Contract.Requires(coeffs != null); - Contract.Requires(args.Length == coeffs.Length); - Contract.Requires(Contract.Result() != null); + Debug.Assert(args != null); + Debug.Assert(coeffs != null); + Debug.Assert(args.Length == coeffs.Length); CheckContextMatch(args); return new BoolExpr(this, Native.Z3_mk_pbeq(nCtx, (uint) args.Length, AST.ArrayToNative(args), @@ -2854,8 +2661,7 @@ namespace Microsoft.Z3 /// A Term with value and sort public Expr MkNumeral(string v, Sort ty) { - Contract.Requires(ty != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ty != null); CheckContextMatch(ty); return Expr.Create(this, Native.Z3_mk_numeral(nCtx, v, ty.NativeObject)); @@ -2870,8 +2676,7 @@ namespace Microsoft.Z3 /// A Term with value and type public Expr MkNumeral(int v, Sort ty) { - Contract.Requires(ty != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ty != null); CheckContextMatch(ty); return Expr.Create(this, Native.Z3_mk_int(nCtx, v, ty.NativeObject)); @@ -2886,8 +2691,7 @@ namespace Microsoft.Z3 /// A Term with value and type public Expr MkNumeral(uint v, Sort ty) { - Contract.Requires(ty != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ty != null); CheckContextMatch(ty); return Expr.Create(this, Native.Z3_mk_unsigned_int(nCtx, v, ty.NativeObject)); @@ -2902,8 +2706,7 @@ namespace Microsoft.Z3 /// A Term with value and type public Expr MkNumeral(long v, Sort ty) { - Contract.Requires(ty != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ty != null); CheckContextMatch(ty); return Expr.Create(this, Native.Z3_mk_int64(nCtx, v, ty.NativeObject)); @@ -2918,8 +2721,7 @@ namespace Microsoft.Z3 /// A Term with value and type public Expr MkNumeral(ulong v, Sort ty) { - Contract.Requires(ty != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ty != null); CheckContextMatch(ty); return Expr.Create(this, Native.Z3_mk_unsigned_int64(nCtx, v, ty.NativeObject)); @@ -2939,9 +2741,6 @@ namespace Microsoft.Z3 if (den == 0) throw new Z3Exception("Denominator is zero"); - Contract.Ensures(Contract.Result() != null); - Contract.EndContractBlock(); - return new RatNum(this, Native.Z3_mk_real(nCtx, num, den)); } @@ -2952,7 +2751,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Real public RatNum MkReal(string v) { - Contract.Ensures(Contract.Result() != null); return new RatNum(this, Native.Z3_mk_numeral(nCtx, v, RealSort.NativeObject)); } @@ -2964,7 +2762,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Real public RatNum MkReal(int v) { - Contract.Ensures(Contract.Result() != null); return new RatNum(this, Native.Z3_mk_int(nCtx, v, RealSort.NativeObject)); } @@ -2976,7 +2773,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Real public RatNum MkReal(uint v) { - Contract.Ensures(Contract.Result() != null); return new RatNum(this, Native.Z3_mk_unsigned_int(nCtx, v, RealSort.NativeObject)); } @@ -2988,7 +2784,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Real public RatNum MkReal(long v) { - Contract.Ensures(Contract.Result() != null); return new RatNum(this, Native.Z3_mk_int64(nCtx, v, RealSort.NativeObject)); } @@ -3000,7 +2795,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Real public RatNum MkReal(ulong v) { - Contract.Ensures(Contract.Result() != null); return new RatNum(this, Native.Z3_mk_unsigned_int64(nCtx, v, RealSort.NativeObject)); } @@ -3013,7 +2807,6 @@ namespace Microsoft.Z3 /// A string representing the Term value in decimal notation. public IntNum MkInt(string v) { - Contract.Ensures(Contract.Result() != null); return new IntNum(this, Native.Z3_mk_numeral(nCtx, v, IntSort.NativeObject)); } @@ -3025,7 +2818,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Integer public IntNum MkInt(int v) { - Contract.Ensures(Contract.Result() != null); return new IntNum(this, Native.Z3_mk_int(nCtx, v, IntSort.NativeObject)); } @@ -3037,7 +2829,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Integer public IntNum MkInt(uint v) { - Contract.Ensures(Contract.Result() != null); return new IntNum(this, Native.Z3_mk_unsigned_int(nCtx, v, IntSort.NativeObject)); } @@ -3049,7 +2840,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Integer public IntNum MkInt(long v) { - Contract.Ensures(Contract.Result() != null); return new IntNum(this, Native.Z3_mk_int64(nCtx, v, IntSort.NativeObject)); } @@ -3061,7 +2851,6 @@ namespace Microsoft.Z3 /// A Term with value and sort Integer public IntNum MkInt(ulong v) { - Contract.Ensures(Contract.Result() != null); return new IntNum(this, Native.Z3_mk_unsigned_int64(nCtx, v, IntSort.NativeObject)); } @@ -3075,7 +2864,6 @@ namespace Microsoft.Z3 /// the size of the bit-vector public BitVecNum MkBV(string v, uint size) { - Contract.Ensures(Contract.Result() != null); return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); } @@ -3087,7 +2875,6 @@ namespace Microsoft.Z3 /// the size of the bit-vector public BitVecNum MkBV(int v, uint size) { - Contract.Ensures(Contract.Result() != null); return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); } @@ -3099,7 +2886,6 @@ namespace Microsoft.Z3 /// the size of the bit-vector public BitVecNum MkBV(uint v, uint size) { - Contract.Ensures(Contract.Result() != null); return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); } @@ -3111,7 +2897,6 @@ namespace Microsoft.Z3 /// the size of the bit-vector public BitVecNum MkBV(long v, uint size) { - Contract.Ensures(Contract.Result() != null); return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); } @@ -3123,7 +2908,6 @@ namespace Microsoft.Z3 /// the size of the bit-vector public BitVecNum MkBV(ulong v, uint size) { - Contract.Ensures(Contract.Result() != null); return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); } @@ -3131,10 +2915,9 @@ namespace Microsoft.Z3 /// /// Create a bit-vector numeral. /// - /// An array of bits representing the bit-vector. Least signficant bit is at position 0. + /// An array of bits representing the bit-vector. Least significant bit is at position 0. public BitVecNum MkBV(bool[] bits) { - Contract.Ensures(Contract.Result() != null); byte[] _bits = new byte[bits.Length]; for (int i = 0; i < bits.Length; ++i) _bits[i] = (byte)(bits[i] ? 1 : 0); return (BitVecNum)Expr.Create(this, Native.Z3_mk_bv_numeral(nCtx, (uint)bits.Length, _bits)); @@ -3172,16 +2955,15 @@ namespace Microsoft.Z3 /// optional symbol to track skolem constants. public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { - Contract.Requires(sorts != null); - Contract.Requires(names != null); - Contract.Requires(body != null); - Contract.Requires(sorts.Length == names.Length); - Contract.Requires(Contract.ForAll(sorts, s => s != null)); - Contract.Requires(Contract.ForAll(names, n => n != null)); - Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); - Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); + Debug.Assert(sorts != null); + Debug.Assert(names != null); + Debug.Assert(body != null); + Debug.Assert(sorts.Length == names.Length); + Debug.Assert(sorts.All(s => s != null)); + Debug.Assert(names.All(n => n != null)); + Debug.Assert(patterns == null || patterns.All(p => p != null)); + Debug.Assert(noPatterns == null || noPatterns.All(np => np != null)); - Contract.Ensures(Contract.Result() != null); return new Quantifier(this, true, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID); } @@ -3197,12 +2979,11 @@ namespace Microsoft.Z3 /// public Quantifier MkForall(Expr[] boundConstants, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { - Contract.Requires(body != null); - Contract.Requires(boundConstants == null || Contract.ForAll(boundConstants, b => b != null)); - Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); - Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); + Debug.Assert(body != null); + Debug.Assert(boundConstants == null || boundConstants.All(b => b != null)); + Debug.Assert(patterns == null || patterns.All(p => p != null)); + Debug.Assert(noPatterns == null || noPatterns.All(np => np != null)); - Contract.Ensures(Contract.Result() != null); return new Quantifier(this, true, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); } @@ -3216,15 +2997,14 @@ namespace Microsoft.Z3 /// public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { - Contract.Requires(sorts != null); - Contract.Requires(names != null); - Contract.Requires(body != null); - Contract.Requires(sorts.Length == names.Length); - Contract.Requires(Contract.ForAll(sorts, s => s != null)); - Contract.Requires(Contract.ForAll(names, n => n != null)); - Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); - Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(sorts != null); + Debug.Assert(names != null); + Debug.Assert(body != null); + Debug.Assert(sorts.Length == names.Length); + Debug.Assert(sorts.All(s => s != null)); + Debug.Assert(names.All(n => n != null)); + Debug.Assert(patterns == null || patterns.All(p => p != null)); + Debug.Assert(noPatterns == null || noPatterns.All(np => np != null)); return new Quantifier(this, false, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID); } @@ -3239,11 +3019,10 @@ namespace Microsoft.Z3 /// public Quantifier MkExists(Expr[] boundConstants, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { - Contract.Requires(body != null); - Contract.Requires(boundConstants == null || Contract.ForAll(boundConstants, n => n != null)); - Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); - Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(body != null); + Debug.Assert(boundConstants == null || boundConstants.All(n => n != null)); + Debug.Assert(patterns == null || patterns.All(p => p != null)); + Debug.Assert(noPatterns == null || noPatterns.All(np => np != null)); return new Quantifier(this, false, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); } @@ -3255,16 +3034,15 @@ namespace Microsoft.Z3 /// public Quantifier MkQuantifier(bool universal, Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { - Contract.Requires(body != null); - Contract.Requires(names != null); - Contract.Requires(sorts != null); - Contract.Requires(sorts.Length == names.Length); - Contract.Requires(Contract.ForAll(sorts, s => s != null)); - Contract.Requires(Contract.ForAll(names, n => n != null)); - Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); - Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); + Debug.Assert(body != null); + Debug.Assert(names != null); + Debug.Assert(sorts != null); + Debug.Assert(sorts.Length == names.Length); + Debug.Assert(sorts.All(s => s != null)); + Debug.Assert(names.All(n => n != null)); + Debug.Assert(patterns == null || patterns.All(p => p != null)); + Debug.Assert(noPatterns == null || noPatterns.All(np => np != null)); - Contract.Ensures(Contract.Result() != null); if (universal) return MkForall(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID); @@ -3279,12 +3057,11 @@ namespace Microsoft.Z3 /// public Quantifier MkQuantifier(bool universal, Expr[] boundConstants, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { - Contract.Requires(body != null); - Contract.Requires(boundConstants == null || Contract.ForAll(boundConstants, n => n != null)); - Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); - Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); + Debug.Assert(body != null); + Debug.Assert(boundConstants == null || boundConstants.All(n => n != null)); + Debug.Assert(patterns == null || patterns.All(p => p != null)); + Debug.Assert(noPatterns == null || noPatterns.All(np => np != null)); - Contract.Ensures(Contract.Result() != null); if (universal) return MkForall(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); @@ -3312,13 +3089,12 @@ namespace Microsoft.Z3 /// the body of the quantifier. public Lambda MkLambda(Sort[] sorts, Symbol[] names, Expr body) { - Contract.Requires(sorts != null); - Contract.Requires(names != null); - Contract.Requires(body != null); - Contract.Requires(sorts.Length == names.Length); - Contract.Requires(Contract.ForAll(sorts, s => s != null)); - Contract.Requires(Contract.ForAll(names, n => n != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(sorts != null); + Debug.Assert(names != null); + Debug.Assert(body != null); + Debug.Assert(sorts.Length == names.Length); + Debug.Assert(sorts.All(s => s != null)); + Debug.Assert(names.All(n => n != null)); return new Lambda(this, sorts, names, body); } @@ -3332,9 +3108,8 @@ namespace Microsoft.Z3 /// public Lambda MkLambda(Expr[] boundConstants, Expr body) { - Contract.Requires(body != null); - Contract.Requires(boundConstants != null && Contract.ForAll(boundConstants, b => b != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(body != null); + Debug.Assert(boundConstants != null && boundConstants.All(b => b != null)); return new Lambda(this, boundConstants, body); } @@ -3374,7 +3149,6 @@ namespace Microsoft.Z3 /// A conjunction of assertions in the scope (up to push/pop) at the end of the string. public BoolExpr[] ParseSMTLIB2String(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null) { - Contract.Ensures(Contract.Result() != null); uint csn = Symbol.ArrayLength(sortNames); uint cs = Sort.ArrayLength(sorts); @@ -3394,7 +3168,6 @@ namespace Microsoft.Z3 /// public BoolExpr[] ParseSMTLIB2File(string fileName, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null) { - Contract.Ensures(Contract.Result() != null); uint csn = Symbol.ArrayLength(sortNames); uint cs = Sort.ArrayLength(sorts); @@ -3422,7 +3195,6 @@ namespace Microsoft.Z3 /// Indicates whether proof generation should be enabled. public Goal MkGoal(bool models = true, bool unsatCores = false, bool proofs = false) { - Contract.Ensures(Contract.Result() != null); return new Goal(this, models, unsatCores, proofs); } @@ -3434,7 +3206,6 @@ namespace Microsoft.Z3 /// public Params MkParams() { - Contract.Ensures(Contract.Result() != null); return new Params(this); } @@ -3456,7 +3227,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumTactics; string[] res = new string[n]; @@ -3471,7 +3241,6 @@ namespace Microsoft.Z3 /// public string TacticDescription(string name) { - Contract.Ensures(Contract.Result() != null); return Native.Z3_tactic_get_descr(nCtx, name); } @@ -3481,7 +3250,6 @@ namespace Microsoft.Z3 /// public Tactic MkTactic(string name) { - Contract.Ensures(Contract.Result() != null); return new Tactic(this, name); } @@ -3492,10 +3260,9 @@ namespace Microsoft.Z3 /// public Tactic AndThen(Tactic t1, Tactic t2, params Tactic[] ts) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Requires(ts == null || Contract.ForAll(0, ts.Length, j => ts[j] != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); + // Debug.Assert(ts == null || Contract.ForAll(0, ts.Length, j => ts[j] != null)); CheckContextMatch(t1); @@ -3527,10 +3294,9 @@ namespace Microsoft.Z3 /// public Tactic Then(Tactic t1, Tactic t2, params Tactic[] ts) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Requires(ts == null || Contract.ForAll(0, ts.Length, j => ts[j] != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); + // Debug.Assert(ts == null || Contract.ForAll(0, ts.Length, j => ts[j] != null)); return AndThen(t1, t2, ts); } @@ -3541,9 +3307,8 @@ namespace Microsoft.Z3 /// public Tactic OrElse(Tactic t1, Tactic t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -3558,8 +3323,7 @@ namespace Microsoft.Z3 /// public Tactic TryFor(Tactic t, uint ms) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new Tactic(this, Native.Z3_tactic_try_for(nCtx, t.NativeObject, ms)); @@ -3574,9 +3338,8 @@ namespace Microsoft.Z3 /// public Tactic When(Probe p, Tactic t) { - Contract.Requires(p != null); - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p != null); + Debug.Assert(t != null); CheckContextMatch(t); CheckContextMatch(p); @@ -3589,10 +3352,9 @@ namespace Microsoft.Z3 /// public Tactic Cond(Probe p, Tactic t1, Tactic t2) { - Contract.Requires(p != null); - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(p); CheckContextMatch(t1); @@ -3606,8 +3368,7 @@ namespace Microsoft.Z3 /// public Tactic Repeat(Tactic t, uint max = uint.MaxValue) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); CheckContextMatch(t); return new Tactic(this, Native.Z3_tactic_repeat(nCtx, t.NativeObject, max)); @@ -3618,7 +3379,6 @@ namespace Microsoft.Z3 /// public Tactic Skip() { - Contract.Ensures(Contract.Result() != null); return new Tactic(this, Native.Z3_tactic_skip(nCtx)); } @@ -3628,7 +3388,6 @@ namespace Microsoft.Z3 /// public Tactic Fail() { - Contract.Ensures(Contract.Result() != null); return new Tactic(this, Native.Z3_tactic_fail(nCtx)); } @@ -3638,8 +3397,7 @@ namespace Microsoft.Z3 /// public Tactic FailIf(Probe p) { - Contract.Requires(p != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p != null); CheckContextMatch(p); return new Tactic(this, Native.Z3_tactic_fail_if(nCtx, p.NativeObject)); @@ -3651,7 +3409,6 @@ namespace Microsoft.Z3 /// public Tactic FailIfNotDecided() { - Contract.Ensures(Contract.Result() != null); return new Tactic(this, Native.Z3_tactic_fail_if_not_decided(nCtx)); } @@ -3661,9 +3418,8 @@ namespace Microsoft.Z3 /// public Tactic UsingParams(Tactic t, Params p) { - Contract.Requires(t != null); - Contract.Requires(p != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(p != null); CheckContextMatch(t); CheckContextMatch(p); @@ -3676,9 +3432,8 @@ namespace Microsoft.Z3 /// Alias for UsingParams public Tactic With(Tactic t, Params p) { - Contract.Requires(t != null); - Contract.Requires(p != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); + Debug.Assert(p != null); return UsingParams(t, p); } @@ -3688,8 +3443,7 @@ namespace Microsoft.Z3 /// public Tactic ParOr(params Tactic[] t) { - Contract.Requires(t == null || Contract.ForAll(t, tactic => tactic != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t == null || t.All(tactic => tactic != null)); CheckContextMatch(t); return new Tactic(this, Native.Z3_tactic_par_or(nCtx, Tactic.ArrayLength(t), Tactic.ArrayToNative(t))); @@ -3701,9 +3455,8 @@ namespace Microsoft.Z3 /// public Tactic ParAndThen(Tactic t1, Tactic t2) { - Contract.Requires(t1 != null); - Contract.Requires(t2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t1 != null); + Debug.Assert(t2 != null); CheckContextMatch(t1); CheckContextMatch(t2); @@ -3736,7 +3489,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumProbes; string[] res = new string[n]; @@ -3751,7 +3503,6 @@ namespace Microsoft.Z3 /// public string ProbeDescription(string name) { - Contract.Ensures(Contract.Result() != null); return Native.Z3_probe_get_descr(nCtx, name); } @@ -3761,7 +3512,6 @@ namespace Microsoft.Z3 /// public Probe MkProbe(string name) { - Contract.Ensures(Contract.Result() != null); return new Probe(this, name); } @@ -3771,7 +3521,6 @@ namespace Microsoft.Z3 /// public Probe ConstProbe(double val) { - Contract.Ensures(Contract.Result() != null); return new Probe(this, Native.Z3_probe_const(nCtx, val)); } @@ -3782,9 +3531,8 @@ namespace Microsoft.Z3 /// public Probe Lt(Probe p1, Probe p2) { - Contract.Requires(p1 != null); - Contract.Requires(p2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p1 != null); + Debug.Assert(p2 != null); CheckContextMatch(p1); CheckContextMatch(p2); @@ -3797,9 +3545,8 @@ namespace Microsoft.Z3 /// public Probe Gt(Probe p1, Probe p2) { - Contract.Requires(p1 != null); - Contract.Requires(p2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p1 != null); + Debug.Assert(p2 != null); CheckContextMatch(p1); CheckContextMatch(p2); @@ -3812,9 +3559,8 @@ namespace Microsoft.Z3 /// public Probe Le(Probe p1, Probe p2) { - Contract.Requires(p1 != null); - Contract.Requires(p2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p1 != null); + Debug.Assert(p2 != null); CheckContextMatch(p1); CheckContextMatch(p2); @@ -3827,9 +3573,8 @@ namespace Microsoft.Z3 /// public Probe Ge(Probe p1, Probe p2) { - Contract.Requires(p1 != null); - Contract.Requires(p2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p1 != null); + Debug.Assert(p2 != null); CheckContextMatch(p1); CheckContextMatch(p2); @@ -3842,9 +3587,8 @@ namespace Microsoft.Z3 /// public Probe Eq(Probe p1, Probe p2) { - Contract.Requires(p1 != null); - Contract.Requires(p2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p1 != null); + Debug.Assert(p2 != null); CheckContextMatch(p1); CheckContextMatch(p2); @@ -3857,9 +3601,8 @@ namespace Microsoft.Z3 /// public Probe And(Probe p1, Probe p2) { - Contract.Requires(p1 != null); - Contract.Requires(p2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p1 != null); + Debug.Assert(p2 != null); CheckContextMatch(p1); CheckContextMatch(p2); @@ -3872,9 +3615,8 @@ namespace Microsoft.Z3 /// public Probe Or(Probe p1, Probe p2) { - Contract.Requires(p1 != null); - Contract.Requires(p2 != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p1 != null); + Debug.Assert(p2 != null); CheckContextMatch(p1); CheckContextMatch(p2); @@ -3887,8 +3629,7 @@ namespace Microsoft.Z3 /// public Probe Not(Probe p) { - Contract.Requires(p != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(p != null); CheckContextMatch(p); return new Probe(this, Native.Z3_probe_not(nCtx, p.NativeObject)); @@ -3906,7 +3647,6 @@ namespace Microsoft.Z3 /// public Solver MkSolver(Symbol logic = null) { - Contract.Ensures(Contract.Result() != null); if (logic == null) return new Solver(this, Native.Z3_mk_solver(nCtx)); @@ -3920,7 +3660,6 @@ namespace Microsoft.Z3 /// public Solver MkSolver(string logic) { - Contract.Ensures(Contract.Result() != null); return MkSolver(MkSymbol(logic)); } @@ -3930,7 +3669,6 @@ namespace Microsoft.Z3 /// public Solver MkSimpleSolver() { - Contract.Ensures(Contract.Result() != null); return new Solver(this, Native.Z3_mk_simple_solver(nCtx)); } @@ -3944,8 +3682,7 @@ namespace Microsoft.Z3 /// public Solver MkSolver(Tactic t) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); return new Solver(this, Native.Z3_mk_solver_from_tactic(nCtx, t.NativeObject)); } @@ -3957,7 +3694,6 @@ namespace Microsoft.Z3 /// public Fixedpoint MkFixedpoint() { - Contract.Ensures(Contract.Result() != null); return new Fixedpoint(this); } @@ -3969,7 +3705,6 @@ namespace Microsoft.Z3 /// public Optimize MkOptimize() { - Contract.Ensures(Contract.Result() != null); return new Optimize(this); } @@ -3984,7 +3719,6 @@ namespace Microsoft.Z3 /// public FPRMSort MkFPRoundingModeSort() { - Contract.Ensures(Contract.Result() != null); return new FPRMSort(this); } #endregion @@ -3995,7 +3729,6 @@ namespace Microsoft.Z3 /// public FPRMExpr MkFPRoundNearestTiesToEven() { - Contract.Ensures(Contract.Result() != null); return new FPRMExpr(this, Native.Z3_mk_fpa_round_nearest_ties_to_even(nCtx)); } @@ -4004,7 +3737,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRNE() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_rne(nCtx)); } @@ -4013,7 +3745,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRoundNearestTiesToAway() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_round_nearest_ties_to_away(nCtx)); } @@ -4022,7 +3753,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRNA() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_rna(nCtx)); } @@ -4031,7 +3761,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRoundTowardPositive() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_positive(nCtx)); } @@ -4040,7 +3769,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRTP() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_rtp(nCtx)); } @@ -4049,7 +3777,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRoundTowardNegative() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_negative(nCtx)); } @@ -4058,7 +3785,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRTN() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_rtn(nCtx)); } @@ -4067,7 +3793,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRoundTowardZero() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_zero(nCtx)); } @@ -4076,7 +3801,6 @@ namespace Microsoft.Z3 /// public FPRMNum MkFPRTZ() { - Contract.Ensures(Contract.Result() != null); return new FPRMNum(this, Native.Z3_mk_fpa_rtz(nCtx)); } #endregion @@ -4090,7 +3814,6 @@ namespace Microsoft.Z3 /// significand bits in the FloatingPoint sort. public FPSort MkFPSort(uint ebits, uint sbits) { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, ebits, sbits); } @@ -4099,7 +3822,6 @@ namespace Microsoft.Z3 /// public FPSort MkFPSortHalf() { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, Native.Z3_mk_fpa_sort_half(nCtx)); } @@ -4108,7 +3830,6 @@ namespace Microsoft.Z3 /// public FPSort MkFPSort16() { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, Native.Z3_mk_fpa_sort_16(nCtx)); } @@ -4117,7 +3838,6 @@ namespace Microsoft.Z3 /// public FPSort MkFPSortSingle() { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, Native.Z3_mk_fpa_sort_single(nCtx)); } @@ -4126,7 +3846,6 @@ namespace Microsoft.Z3 /// public FPSort MkFPSort32() { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, Native.Z3_mk_fpa_sort_32(nCtx)); } @@ -4135,7 +3854,6 @@ namespace Microsoft.Z3 /// public FPSort MkFPSortDouble() { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, Native.Z3_mk_fpa_sort_double(nCtx)); } @@ -4144,7 +3862,6 @@ namespace Microsoft.Z3 /// public FPSort MkFPSort64() { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, Native.Z3_mk_fpa_sort_64(nCtx)); } @@ -4153,7 +3870,6 @@ namespace Microsoft.Z3 /// public FPSort MkFPSortQuadruple() { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, Native.Z3_mk_fpa_sort_quadruple(nCtx)); } @@ -4162,7 +3878,6 @@ namespace Microsoft.Z3 /// public FPSort MkFPSort128() { - Contract.Ensures(Contract.Result() != null); return new FPSort(this, Native.Z3_mk_fpa_sort_128(nCtx)); } #endregion @@ -4174,7 +3889,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFPNaN(FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPNum(this, Native.Z3_mk_fpa_nan(nCtx, s.NativeObject)); } @@ -4185,7 +3899,6 @@ namespace Microsoft.Z3 /// indicates whether the result should be negative. public FPNum MkFPInf(FPSort s, bool negative) { - Contract.Ensures(Contract.Result() != null); return new FPNum(this, Native.Z3_mk_fpa_inf(nCtx, s.NativeObject, (byte)(negative ? 1 : 0))); } @@ -4196,7 +3909,6 @@ namespace Microsoft.Z3 /// indicates whether the result should be negative. public FPNum MkFPZero(FPSort s, bool negative) { - Contract.Ensures(Contract.Result() != null); return new FPNum(this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, (byte)(negative ? 1 : 0))); } @@ -4207,7 +3919,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFPNumeral(float v, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPNum(this, Native.Z3_mk_fpa_numeral_float(nCtx, v, s.NativeObject)); } @@ -4218,7 +3929,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFPNumeral(double v, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPNum(this, Native.Z3_mk_fpa_numeral_double(nCtx, v, s.NativeObject)); } @@ -4229,7 +3939,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFPNumeral(int v, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPNum(this, Native.Z3_mk_fpa_numeral_int(nCtx, v, s.NativeObject)); } @@ -4242,7 +3951,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFPNumeral(bool sgn, uint sig, int exp, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPNum(this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject)); } @@ -4255,7 +3963,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFPNumeral(bool sgn, Int64 exp, UInt64 sig, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPNum(this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject)); } @@ -4266,7 +3973,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFP(float v, FPSort s) { - Contract.Ensures(Contract.Result() != null); return MkFPNumeral(v, s); } @@ -4277,7 +3983,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFP(double v, FPSort s) { - Contract.Ensures(Contract.Result() != null); return MkFPNumeral(v, s); } @@ -4288,7 +3993,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFP(int v, FPSort s) { - Contract.Ensures(Contract.Result() != null); return MkFPNumeral(v, s); } @@ -4301,7 +4005,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFP(bool sgn, int exp, uint sig, FPSort s) { - Contract.Ensures(Contract.Result() != null); return MkFPNumeral(sgn, exp, sig, s); } @@ -4314,7 +4017,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPNum MkFP(bool sgn, Int64 exp, UInt64 sig, FPSort s) { - Contract.Ensures(Contract.Result() != null); return MkFPNumeral(sgn, exp, sig, s); } @@ -4327,7 +4029,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPAbs(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_abs(this.nCtx, t.NativeObject)); } @@ -4337,7 +4038,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPNeg(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_neg(this.nCtx, t.NativeObject)); } @@ -4349,7 +4049,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPAdd(FPRMExpr rm, FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_add(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject)); } @@ -4361,7 +4060,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPSub(FPRMExpr rm, FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_sub(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject)); } @@ -4373,7 +4071,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPMul(FPRMExpr rm, FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_mul(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject)); } @@ -4385,7 +4082,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPDiv(FPRMExpr rm, FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_div(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject)); } @@ -4401,7 +4097,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPFMA(FPRMExpr rm, FPExpr t1, FPExpr t2, FPExpr t3) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_fma(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject, t3.NativeObject)); } @@ -4412,7 +4107,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPSqrt(FPRMExpr rm, FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_sqrt(this.nCtx, rm.NativeObject, t.NativeObject)); } @@ -4423,7 +4117,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPRem(FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_rem(this.nCtx, t1.NativeObject, t2.NativeObject)); } @@ -4435,7 +4128,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPRoundToIntegral(FPRMExpr rm, FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_round_to_integral(this.nCtx, rm.NativeObject, t.NativeObject)); } @@ -4446,7 +4138,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPMin(FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_min(this.nCtx, t1.NativeObject, t2.NativeObject)); } @@ -4457,7 +4148,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPMax(FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_max(this.nCtx, t1.NativeObject, t2.NativeObject)); } @@ -4468,7 +4158,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPLEq(FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_leq(this.nCtx, t1.NativeObject, t2.NativeObject)); } @@ -4479,7 +4168,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPLt(FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_lt(this.nCtx, t1.NativeObject, t2.NativeObject)); } @@ -4490,7 +4178,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPGEq(FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_geq(this.nCtx, t1.NativeObject, t2.NativeObject)); } @@ -4501,7 +4188,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPGt(FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_gt(this.nCtx, t1.NativeObject, t2.NativeObject)); } @@ -4515,7 +4201,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPEq(FPExpr t1, FPExpr t2) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_eq(this.nCtx, t1.NativeObject, t2.NativeObject)); } @@ -4525,7 +4210,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPIsNormal(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_is_normal(this.nCtx, t.NativeObject)); } @@ -4535,7 +4219,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPIsSubnormal(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_is_subnormal(this.nCtx, t.NativeObject)); } @@ -4545,7 +4228,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPIsZero(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_is_zero(this.nCtx, t.NativeObject)); } @@ -4555,7 +4237,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPIsInfinite(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_is_infinite(this.nCtx, t.NativeObject)); } @@ -4565,7 +4246,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPIsNaN(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_is_nan(this.nCtx, t.NativeObject)); } @@ -4575,7 +4255,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPIsNegative(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_is_negative(this.nCtx, t.NativeObject)); } @@ -4585,7 +4264,6 @@ namespace Microsoft.Z3 /// floating-point term public BoolExpr MkFPIsPositive(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(this, Native.Z3_mk_fpa_is_positive(this.nCtx, t.NativeObject)); } #endregion @@ -4606,7 +4284,6 @@ namespace Microsoft.Z3 /// bit-vector term representing the exponent. public FPExpr MkFP(BitVecExpr sgn, BitVecExpr sig, BitVecExpr exp) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_fp(this.nCtx, sgn.NativeObject, sig.NativeObject, exp.NativeObject)); } @@ -4623,7 +4300,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort (ebits+sbits == m) public FPExpr MkFPToFP(BitVecExpr bv, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_to_fp_bv(this.nCtx, bv.NativeObject, s.NativeObject)); } @@ -4640,7 +4316,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPExpr MkFPToFP(FPRMExpr rm, FPExpr t, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject)); } @@ -4657,7 +4332,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public FPExpr MkFPToFP(FPRMExpr rm, RealExpr t, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_to_fp_real(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject)); } @@ -4676,7 +4350,6 @@ namespace Microsoft.Z3 /// flag indicating whether t is interpreted as signed or unsigned bit-vector. public FPExpr MkFPToFP(FPRMExpr rm, BitVecExpr t, FPSort s, bool signed) { - Contract.Ensures(Contract.Result() != null); if (signed) return new FPExpr(this, Native.Z3_mk_fpa_to_fp_signed(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject)); else @@ -4695,7 +4368,6 @@ namespace Microsoft.Z3 /// floating-point term public FPExpr MkFPToFP(FPSort s, FPRMExpr rm, FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, s.NativeObject, rm.NativeObject, t.NativeObject)); } #endregion @@ -4715,7 +4387,6 @@ namespace Microsoft.Z3 /// Indicates whether the result is a signed or unsigned bit-vector. public BitVecExpr MkFPToBV(FPRMExpr rm, FPExpr t, uint sz, bool signed) { - Contract.Ensures(Contract.Result() != null); if (signed) return new BitVecExpr(this, Native.Z3_mk_fpa_to_sbv(this.nCtx, rm.NativeObject, t.NativeObject, sz)); else @@ -4733,7 +4404,6 @@ namespace Microsoft.Z3 /// FloatingPoint term public RealExpr MkFPToReal(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new RealExpr(this, Native.Z3_mk_fpa_to_real(this.nCtx, t.NativeObject)); } #endregion @@ -4751,7 +4421,6 @@ namespace Microsoft.Z3 /// FloatingPoint term. public BitVecExpr MkFPToIEEEBV(FPExpr t) { - Contract.Ensures(Contract.Result() != null); return new BitVecExpr(this, Native.Z3_mk_fpa_to_ieee_bv(this.nCtx, t.NativeObject)); } @@ -4769,7 +4438,6 @@ namespace Microsoft.Z3 /// FloatingPoint sort. public BitVecExpr MkFPToFP(FPRMExpr rm, IntExpr exp, RealExpr sig, FPSort s) { - Contract.Ensures(Contract.Result() != null); return new BitVecExpr(this, Native.Z3_mk_fpa_to_fp_int_real(this.nCtx, rm.NativeObject, exp.NativeObject, sig.NativeObject, s.NativeObject)); } #endregion @@ -4788,7 +4456,6 @@ namespace Microsoft.Z3 /// The native pointer to wrap. public AST WrapAST(IntPtr nativeObject) { - Contract.Ensures(Contract.Result() != null); return AST.Create(this, nativeObject); } @@ -4813,7 +4480,6 @@ namespace Microsoft.Z3 /// public string SimplifyHelp() { - Contract.Ensures(Contract.Result() != null); return Native.Z3_simplify_get_help(nCtx); } @@ -4879,84 +4545,78 @@ namespace Microsoft.Z3 GC.SuppressFinalize(this); } - [Pure] internal void CheckContextMatch(Z3Object other) { - Contract.Requires(other != null); + Debug.Assert(other != null); if (!ReferenceEquals(this, other.Context)) throw new Z3Exception("Context mismatch"); } - [Pure] internal void CheckContextMatch(Z3Object other1, Z3Object other2) { - Contract.Requires(other1 != null); - Contract.Requires(other2 != null); + Debug.Assert(other1 != null); + Debug.Assert(other2 != null); CheckContextMatch(other1); CheckContextMatch(other2); } - [Pure] internal void CheckContextMatch(Z3Object other1, Z3Object other2, Z3Object other3) { - Contract.Requires(other1 != null); - Contract.Requires(other2 != null); - Contract.Requires(other3 != null); + Debug.Assert(other1 != null); + Debug.Assert(other2 != null); + Debug.Assert(other3 != null); CheckContextMatch(other1); CheckContextMatch(other2); CheckContextMatch(other3); } - [Pure] internal void CheckContextMatch(Z3Object[] arr) { - Contract.Requires(arr == null || Contract.ForAll(arr, a => a != null)); + Debug.Assert(arr == null || arr.All(a => a != null)); if (arr != null) { foreach (Z3Object a in arr) { - Contract.Assert(a != null); // It was an assume, now we added the precondition, and we made it into an assert + Debug.Assert(a != null); // It was an assume, now we added the precondition, and we made it into an assert CheckContextMatch(a); } } } - [Pure] internal void CheckContextMatch(IEnumerable arr) where T : Z3Object { - Contract.Requires(arr == null || Contract.ForAll(arr, a => a != null)); + Debug.Assert(arr == null || arr.All(a => a != null)); if (arr != null) { foreach (Z3Object a in arr) { - Contract.Assert(a != null); // It was an assume, now we added the precondition, and we made it into an assert + Debug.Assert(a != null); // It was an assume, now we added the precondition, and we made it into an assert CheckContextMatch(a); } } } - [ContractInvariantMethod] private void ObjectInvariant() { - Contract.Invariant(m_AST_DRQ != null); - Contract.Invariant(m_ASTMap_DRQ != null); - Contract.Invariant(m_ASTVector_DRQ != null); - Contract.Invariant(m_ApplyResult_DRQ != null); - Contract.Invariant(m_FuncEntry_DRQ != null); - Contract.Invariant(m_FuncInterp_DRQ != null); - Contract.Invariant(m_Goal_DRQ != null); - Contract.Invariant(m_Model_DRQ != null); - Contract.Invariant(m_Params_DRQ != null); - Contract.Invariant(m_ParamDescrs_DRQ != null); - Contract.Invariant(m_Probe_DRQ != null); - Contract.Invariant(m_Solver_DRQ != null); - Contract.Invariant(m_Statistics_DRQ != null); - Contract.Invariant(m_Tactic_DRQ != null); - Contract.Invariant(m_Fixedpoint_DRQ != null); - Contract.Invariant(m_Optimize_DRQ != null); + Debug.Assert(m_AST_DRQ != null); + Debug.Assert(m_ASTMap_DRQ != null); + Debug.Assert(m_ASTVector_DRQ != null); + Debug.Assert(m_ApplyResult_DRQ != null); + Debug.Assert(m_FuncEntry_DRQ != null); + Debug.Assert(m_FuncInterp_DRQ != null); + Debug.Assert(m_Goal_DRQ != null); + Debug.Assert(m_Model_DRQ != null); + Debug.Assert(m_Params_DRQ != null); + Debug.Assert(m_ParamDescrs_DRQ != null); + Debug.Assert(m_Probe_DRQ != null); + Debug.Assert(m_Solver_DRQ != null); + Debug.Assert(m_Statistics_DRQ != null); + Debug.Assert(m_Tactic_DRQ != null); + Debug.Assert(m_Fixedpoint_DRQ != null); + Debug.Assert(m_Optimize_DRQ != null); } readonly private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue(); @@ -4979,83 +4639,82 @@ namespace Microsoft.Z3 /// /// AST DRQ /// - public IDecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_AST_DRQ; } } + public IDecRefQueue AST_DRQ { get { return m_AST_DRQ; } } /// /// ASTMap DRQ /// - public IDecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_ASTMap_DRQ; } } + public IDecRefQueue ASTMap_DRQ { get { return m_ASTMap_DRQ; } } /// /// ASTVector DRQ /// - public IDecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_ASTVector_DRQ; } } + public IDecRefQueue ASTVector_DRQ { get { return m_ASTVector_DRQ; } } /// /// ApplyResult DRQ /// - public IDecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_ApplyResult_DRQ; } } + public IDecRefQueue ApplyResult_DRQ { get { return m_ApplyResult_DRQ; } } /// /// FuncEntry DRQ /// - public IDecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_FuncEntry_DRQ; } } + public IDecRefQueue FuncEntry_DRQ { get { return m_FuncEntry_DRQ; } } /// /// FuncInterp DRQ /// - public IDecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_FuncInterp_DRQ; } } + public IDecRefQueue FuncInterp_DRQ { get { return m_FuncInterp_DRQ; } } /// /// Goal DRQ /// - public IDecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Goal_DRQ; } } + public IDecRefQueue Goal_DRQ { get { return m_Goal_DRQ; } } /// /// Model DRQ /// - public IDecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Model_DRQ; } } + public IDecRefQueue Model_DRQ { get { return m_Model_DRQ; } } /// /// Params DRQ /// - public IDecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Params_DRQ; } } + public IDecRefQueue Params_DRQ { get { return m_Params_DRQ; } } /// /// ParamDescrs DRQ /// - public IDecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_ParamDescrs_DRQ; } } + public IDecRefQueue ParamDescrs_DRQ { get { return m_ParamDescrs_DRQ; } } /// /// Probe DRQ /// - public IDecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Probe_DRQ; } } + public IDecRefQueue Probe_DRQ { get { return m_Probe_DRQ; } } /// /// Solver DRQ /// - public IDecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Solver_DRQ; } } + public IDecRefQueue Solver_DRQ { get { return m_Solver_DRQ; } } /// /// Statistics DRQ /// - public IDecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Statistics_DRQ; } } + public IDecRefQueue Statistics_DRQ { get { return m_Statistics_DRQ; } } /// /// Tactic DRQ /// - public IDecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Tactic_DRQ; } } + public IDecRefQueue Tactic_DRQ { get { return m_Tactic_DRQ; } } /// /// FixedPoint DRQ /// - public IDecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Fixedpoint_DRQ; } } + public IDecRefQueue Fixedpoint_DRQ { get { return m_Fixedpoint_DRQ; } } /// /// Optimize DRQ /// - public IDecRefQueue Optimize_DRQ { get { Contract.Ensures(Contract.Result() != null); return m_Fixedpoint_DRQ; } } - + public IDecRefQueue Optimize_DRQ { get { return m_Fixedpoint_DRQ; } } internal long refCount = 0; diff --git a/src/api/dotnet/DatatypeExpr.cs b/src/api/dotnet/DatatypeExpr.cs index ba3a9d478..03595c349 100644 --- a/src/api/dotnet/DatatypeExpr.cs +++ b/src/api/dotnet/DatatypeExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 internal DatatypeExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/DatatypeSort.cs b/src/api/dotnet/DatatypeSort.cs index e47545d68..943d3753f 100644 --- a/src/api/dotnet/DatatypeSort.cs +++ b/src/api/dotnet/DatatypeSort.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Datatype sorts. /// - [ContractVerification(true)] public class DatatypeSort : Sort { /// @@ -43,7 +42,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumConstructors; FuncDecl[] res = new FuncDecl[n]; @@ -60,7 +58,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumConstructors; FuncDecl[] res = new FuncDecl[n]; @@ -77,7 +74,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumConstructors; FuncDecl[][] res = new FuncDecl[n][]; @@ -95,14 +91,14 @@ namespace Microsoft.Z3 } #region Internal - internal DatatypeSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal DatatypeSort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } internal DatatypeSort(Context ctx, Symbol name, Constructor[] constructors) : base(ctx, Native.Z3_mk_datatype(ctx.nCtx, name.NativeObject, (uint)constructors.Length, ArrayToNative(constructors))) { - Contract.Requires(ctx != null); - Contract.Requires(name != null); - Contract.Requires(constructors != null); + Debug.Assert(ctx != null); + Debug.Assert(name != null); + Debug.Assert(constructors != null); } #endregion }; diff --git a/src/api/dotnet/Deprecated.cs b/src/api/dotnet/Deprecated.cs index feb5b1555..64255cea2 100644 --- a/src/api/dotnet/Deprecated.cs +++ b/src/api/dotnet/Deprecated.cs @@ -17,17 +17,16 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// The main interaction with Z3 happens via the Context. /// - [ContractVerification(true)] public class Deprecated { diff --git a/src/api/dotnet/EnumSort.cs b/src/api/dotnet/EnumSort.cs index 62be48a2c..08c85361e 100644 --- a/src/api/dotnet/EnumSort.cs +++ b/src/api/dotnet/EnumSort.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Enumeration sorts. /// - [ContractVerification(true)] public class EnumSort : Sort { /// @@ -35,7 +34,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = Native.Z3_get_datatype_sort_num_constructors(Context.nCtx, NativeObject); FuncDecl[] t = new FuncDecl[n]; for (uint i = 0; i < n; i++) @@ -61,7 +59,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); FuncDecl[] cds = ConstDecls; Expr[] t = new Expr[cds.Length]; for (uint i = 0; i < t.Length; i++) @@ -87,7 +84,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = Native.Z3_get_datatype_sort_num_constructors(Context.nCtx, NativeObject); FuncDecl[] t = new FuncDecl[n]; for (uint i = 0; i < n; i++) @@ -110,9 +106,9 @@ namespace Microsoft.Z3 internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames) : base(ctx, IntPtr.Zero) { - Contract.Requires(ctx != null); - Contract.Requires(name != null); - Contract.Requires(enumNames != null); + Debug.Assert(ctx != null); + Debug.Assert(name != null); + Debug.Assert(enumNames != null); int n = enumNames.Length; IntPtr[] n_constdecls = new IntPtr[n]; diff --git a/src/api/dotnet/Expr.cs b/src/api/dotnet/Expr.cs index 99baaa8e4..f735401d8 100644 --- a/src/api/dotnet/Expr.cs +++ b/src/api/dotnet/Expr.cs @@ -17,15 +17,16 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; +using System.Linq; + namespace Microsoft.Z3 { /// /// Expressions are terms. /// - [ContractVerification(true)] public class Expr : AST { /// @@ -35,7 +36,6 @@ namespace Microsoft.Z3 /// public Expr Simplify(Params p = null) { - Contract.Ensures(Contract.Result() != null); if (p == null) return Expr.Create(Context, Native.Z3_simplify(Context.nCtx, NativeObject)); @@ -50,7 +50,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new FuncDecl(Context, Native.Z3_get_app_decl(Context.nCtx, NativeObject)); } } @@ -79,7 +78,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumArgs; Expr[] res = new Expr[n]; @@ -94,7 +92,6 @@ namespace Microsoft.Z3 /// public Expr Arg(uint i) { - Contract.Ensures(Contract.Result() != null); return Expr.Create(Context, Native.Z3_get_app_arg(Context.nCtx, NativeObject, i)); } @@ -104,8 +101,8 @@ namespace Microsoft.Z3 /// public void Update(Expr[] args) { - Contract.Requires(args != null); - Contract.Requires(Contract.ForAll(args, a => a != null)); + Debug.Assert(args != null); + Debug.Assert(args.All(a => a != null)); Context.CheckContextMatch(args); if (IsApp && args.Length != NumArgs) @@ -123,11 +120,10 @@ namespace Microsoft.Z3 /// public Expr Substitute(Expr[] from, Expr[] to) { - Contract.Requires(from != null); - Contract.Requires(to != null); - Contract.Requires(Contract.ForAll(from, f => f != null)); - Contract.Requires(Contract.ForAll(to, t => t != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(from != null); + Debug.Assert(to != null); + Debug.Assert(from.All(f => f != null)); + Debug.Assert(to.All(t => t != null)); Context.CheckContextMatch(from); Context.CheckContextMatch(to); @@ -142,9 +138,8 @@ namespace Microsoft.Z3 /// public Expr Substitute(Expr from, Expr to) { - Contract.Requires(from != null); - Contract.Requires(to != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(from != null); + Debug.Assert(to != null); return Substitute(new Expr[] { from }, new Expr[] { to }); } @@ -157,9 +152,8 @@ namespace Microsoft.Z3 /// public Expr SubstituteVars(Expr[] to) { - Contract.Requires(to != null); - Contract.Requires(Contract.ForAll(to, t => t != null)); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(to != null); + Debug.Assert(to.All(t => t != null)); Context.CheckContextMatch(to); return Expr.Create(Context, Native.Z3_substitute_vars(Context.nCtx, NativeObject, (uint)to.Length, Expr.ArrayToNative(to))); @@ -207,7 +201,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Sort.Create(Context, Native.Z3_get_sort(Context.nCtx, NativeObject)); } } @@ -332,7 +325,7 @@ namespace Microsoft.Z3 /// /// Retrieve bound of at-most /// - public uint AtMostBound { get { Contract.Requires(IsAtMost); return (uint)FuncDecl.Parameters[0].Int; } } + public uint AtMostBound { get { Debug.Assert(IsAtMost); return (uint)FuncDecl.Parameters[0].Int; } } /// /// Indicates whether the term is at-least @@ -342,7 +335,7 @@ namespace Microsoft.Z3 /// /// Retrieve bound of at-least /// - public uint AtLeastBound { get { Contract.Requires(IsAtLeast); return (uint)FuncDecl.Parameters[0].Int; } } + public uint AtLeastBound { get { Debug.Assert(IsAtLeast); return (uint)FuncDecl.Parameters[0].Int; } } /// /// Indicates whether the term is pbeq @@ -842,7 +835,7 @@ namespace Microsoft.Z3 public string String { get { return Native.Z3_get_string(Context.nCtx, NativeObject); } } /// - /// Check whether expression is a concatentation. + /// Check whether expression is a concatenation. /// /// a Boolean public bool IsConcat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONCAT; } } @@ -1816,8 +1809,6 @@ namespace Microsoft.Z3 if (!IsVar) throw new Z3Exception("Term is not a bound variable."); - Contract.EndContractBlock(); - return Native.Z3_get_index_value(Context.nCtx, NativeObject); } } @@ -1827,10 +1818,9 @@ namespace Microsoft.Z3 /// /// Constructor for Expr /// - internal protected Expr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal protected Expr(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #if DEBUG - [Pure] internal override void CheckNativeObject(IntPtr obj) { if (Native.Z3_is_app(Context.nCtx, obj) == 0 && @@ -1841,12 +1831,10 @@ namespace Microsoft.Z3 } #endif - [Pure] internal static Expr Create(Context ctx, FuncDecl f, params Expr[] arguments) { - Contract.Requires(ctx != null); - Contract.Requires(f != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ctx != null); + Debug.Assert(f != null); IntPtr obj = Native.Z3_mk_app(ctx.nCtx, f.NativeObject, AST.ArrayLength(arguments), @@ -1854,11 +1842,9 @@ namespace Microsoft.Z3 return Create(ctx, obj); } - [Pure] new internal static Expr Create(Context ctx, IntPtr obj) { - Contract.Requires(ctx != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ctx != null); Z3_ast_kind k = (Z3_ast_kind)Native.Z3_get_ast_kind(ctx.nCtx, obj); if (k == Z3_ast_kind.Z3_QUANTIFIER_AST) diff --git a/src/api/dotnet/FPExpr.cs b/src/api/dotnet/FPExpr.cs index 85fdf2603..03ae0bff1 100644 --- a/src/api/dotnet/FPExpr.cs +++ b/src/api/dotnet/FPExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -45,7 +45,7 @@ namespace Microsoft.Z3 internal FPExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/FPNum.cs b/src/api/dotnet/FPNum.cs index b6d349149..e21355f72 100644 --- a/src/api/dotnet/FPNum.cs +++ b/src/api/dotnet/FPNum.cs @@ -16,15 +16,14 @@ Author: Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// FloatiungPoint Numerals /// - [ContractVerification(true)] public class FPNum : FPExpr { /// @@ -175,7 +174,7 @@ namespace Microsoft.Z3 internal FPNum(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion diff --git a/src/api/dotnet/FPRMExpr.cs b/src/api/dotnet/FPRMExpr.cs index 896c3e6b9..4c4ae602f 100644 --- a/src/api/dotnet/FPRMExpr.cs +++ b/src/api/dotnet/FPRMExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 internal FPRMExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/FPRMNum.cs b/src/api/dotnet/FPRMNum.cs index 81cff167e..af1c8b888 100644 --- a/src/api/dotnet/FPRMNum.cs +++ b/src/api/dotnet/FPRMNum.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -93,7 +93,7 @@ namespace Microsoft.Z3 internal FPRMNum(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/FPRMSort.cs b/src/api/dotnet/FPRMSort.cs index 1d8334eb5..4e04a2586 100644 --- a/src/api/dotnet/FPRMSort.cs +++ b/src/api/dotnet/FPRMSort.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -31,12 +31,12 @@ namespace Microsoft.Z3 internal FPRMSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal FPRMSort(Context ctx) : base(ctx, Native.Z3_mk_fpa_rounding_mode_sort(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/FPSort.cs b/src/api/dotnet/FPSort.cs index e1ad62d49..56a738e65 100644 --- a/src/api/dotnet/FPSort.cs +++ b/src/api/dotnet/FPSort.cs @@ -16,8 +16,8 @@ Author: Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -40,12 +40,12 @@ namespace Microsoft.Z3 internal FPSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal FPSort(Context ctx, uint ebits, uint sbits) : base(ctx, Native.Z3_mk_fpa_sort(ctx.nCtx, ebits, sbits)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/FiniteDomainExpr.cs b/src/api/dotnet/FiniteDomainExpr.cs index 59ccb9f32..1a689d59f 100644 --- a/src/api/dotnet/FiniteDomainExpr.cs +++ b/src/api/dotnet/FiniteDomainExpr.cs @@ -16,8 +16,8 @@ Author: Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -31,7 +31,7 @@ namespace Microsoft.Z3 internal FiniteDomainExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/FiniteDomainNum.cs b/src/api/dotnet/FiniteDomainNum.cs index 52c0af8bd..39d94ddbd 100644 --- a/src/api/dotnet/FiniteDomainNum.cs +++ b/src/api/dotnet/FiniteDomainNum.cs @@ -16,8 +16,8 @@ Author: Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; #if !FRAMEWORK_LT_4 using System.Numerics; @@ -28,7 +28,6 @@ namespace Microsoft.Z3 /// /// Finite-domain numerals /// - [ContractVerification(true)] public class FiniteDomainNum : FiniteDomainExpr { /// @@ -109,7 +108,7 @@ namespace Microsoft.Z3 } #region Internal - internal FiniteDomainNum(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal FiniteDomainNum(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #endregion } } diff --git a/src/api/dotnet/FiniteDomainSort.cs b/src/api/dotnet/FiniteDomainSort.cs index 93540ff87..5392aede2 100644 --- a/src/api/dotnet/FiniteDomainSort.cs +++ b/src/api/dotnet/FiniteDomainSort.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Finite domain sorts. /// - [ContractVerification(true)] public class FiniteDomainSort : Sort { /// @@ -45,13 +44,13 @@ namespace Microsoft.Z3 internal FiniteDomainSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal FiniteDomainSort(Context ctx, Symbol name, ulong size) : base(ctx, Native.Z3_mk_finite_domain_sort(ctx.nCtx, name.NativeObject, size)) { - Contract.Requires(ctx != null); - Contract.Requires(name != null); + Debug.Assert(ctx != null); + Debug.Assert(name != null); } #endregion diff --git a/src/api/dotnet/Fixedpoint.cs b/src/api/dotnet/Fixedpoint.cs index 102a96ac5..51ee79b55 100644 --- a/src/api/dotnet/Fixedpoint.cs +++ b/src/api/dotnet/Fixedpoint.cs @@ -18,14 +18,14 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; +using System.Linq; namespace Microsoft.Z3 { /// /// Object for managing fixedpoints /// - [ContractVerification(true)] public class Fixedpoint : Z3Object { @@ -36,7 +36,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Native.Z3_fixedpoint_get_help(Context.nCtx, NativeObject); } } @@ -48,7 +47,7 @@ namespace Microsoft.Z3 { set { - Contract.Requires(value != null); + Debug.Assert(value != null); Context.CheckContextMatch(value); Native.Z3_fixedpoint_set_params(Context.nCtx, NativeObject, value.NativeObject); } @@ -68,8 +67,8 @@ namespace Microsoft.Z3 /// public void Assert(params BoolExpr[] constraints) { - Contract.Requires(constraints != null); - Contract.Requires(Contract.ForAll(constraints, c => c != null)); + Debug.Assert(constraints != null); + Debug.Assert(constraints.All(c => c != null)); Context.CheckContextMatch(constraints); foreach (BoolExpr a in constraints) @@ -91,7 +90,7 @@ namespace Microsoft.Z3 /// public void RegisterRelation(FuncDecl f) { - Contract.Requires(f != null); + Debug.Assert(f != null); Context.CheckContextMatch(f); Native.Z3_fixedpoint_register_relation(Context.nCtx, NativeObject, f.NativeObject); @@ -102,7 +101,7 @@ namespace Microsoft.Z3 /// public void AddRule(BoolExpr rule, Symbol name = null) { - Contract.Requires(rule != null); + Debug.Assert(rule != null); Context.CheckContextMatch(rule); Native.Z3_fixedpoint_add_rule(Context.nCtx, NativeObject, rule.NativeObject, AST.GetNativeObject(name)); @@ -113,8 +112,8 @@ namespace Microsoft.Z3 /// public void AddFact(FuncDecl pred, params uint[] args) { - Contract.Requires(pred != null); - Contract.Requires(args != null); + Debug.Assert(pred != null); + Debug.Assert(args != null); Context.CheckContextMatch(pred); Native.Z3_fixedpoint_add_fact(Context.nCtx, NativeObject, pred.NativeObject, (uint)args.Length, args); @@ -128,7 +127,7 @@ namespace Microsoft.Z3 /// public Status Query(BoolExpr query) { - Contract.Requires(query != null); + Debug.Assert(query != null); Context.CheckContextMatch(query); Z3_lbool r = (Z3_lbool)Native.Z3_fixedpoint_query(Context.nCtx, NativeObject, query.NativeObject); @@ -148,8 +147,8 @@ namespace Microsoft.Z3 /// public Status Query(params FuncDecl[] relations) { - Contract.Requires(relations != null); - Contract.Requires(Contract.ForAll(0, relations.Length, i => relations[i] != null)); + Debug.Assert(relations != null); + Debug.Assert(relations.All(rel => rel != null)); Context.CheckContextMatch(relations); Z3_lbool r = (Z3_lbool)Native.Z3_fixedpoint_query_relations(Context.nCtx, NativeObject, @@ -187,7 +186,7 @@ namespace Microsoft.Z3 /// public void UpdateRule(BoolExpr rule, Symbol name) { - Contract.Requires(rule != null); + Debug.Assert(rule != null); Context.CheckContextMatch(rule); Native.Z3_fixedpoint_update_rule(Context.nCtx, NativeObject, rule.NativeObject, AST.GetNativeObject(name)); @@ -208,7 +207,6 @@ namespace Microsoft.Z3 /// public string GetReasonUnknown() { - Contract.Ensures(Contract.Result() != null); return Native.Z3_fixedpoint_get_reason_unknown(Context.nCtx, NativeObject); } @@ -252,7 +250,7 @@ namespace Microsoft.Z3 /// public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds) { - Contract.Requires(f != null); + Debug.Assert(f != null); Native.Z3_fixedpoint_set_predicate_representation(Context.nCtx, NativeObject, f.NativeObject, AST.ArrayLength(kinds), Symbol.ArrayToNative(kinds)); @@ -276,7 +274,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_get_rules(Context.nCtx, NativeObject)); return av.ToBoolExprArray(); @@ -290,7 +287,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_get_assertions(Context.nCtx, NativeObject)); return av.ToBoolExprArray(); @@ -304,7 +300,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new Statistics(Context, Native.Z3_fixedpoint_get_statistics(Context.nCtx, NativeObject)); } @@ -335,12 +330,12 @@ namespace Microsoft.Z3 internal Fixedpoint(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal Fixedpoint(Context ctx) : base(ctx, Native.Z3_mk_fixedpoint(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/FuncDecl.cs b/src/api/dotnet/FuncDecl.cs index 0587a2276..24ae456d8 100644 --- a/src/api/dotnet/FuncDecl.cs +++ b/src/api/dotnet/FuncDecl.cs @@ -18,14 +18,15 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; +using System.Linq; + namespace Microsoft.Z3 { /// /// Function declarations. /// - [ContractVerification(true)] public class FuncDecl : AST { /// @@ -108,7 +109,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = DomainSize; @@ -126,7 +126,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Sort.Create(Context, Native.Z3_get_range(Context.nCtx, NativeObject)); } } @@ -146,7 +145,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Symbol.Create(Context, Native.Z3_get_decl_name(Context.nCtx, NativeObject)); } } @@ -166,7 +164,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint num = NumParameters; Parameter[] res = new Parameter[num]; @@ -287,22 +284,22 @@ namespace Microsoft.Z3 internal FuncDecl(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range) : base(ctx, Native.Z3_mk_func_decl(ctx.nCtx, name.NativeObject, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject)) { - Contract.Requires(ctx != null); - Contract.Requires(name != null); - Contract.Requires(range != null); + Debug.Assert(ctx != null); + Debug.Assert(name != null); + Debug.Assert(range != null); } internal FuncDecl(Context ctx, string prefix, Sort[] domain, Sort range) : base(ctx, Native.Z3_mk_fresh_func_decl(ctx.nCtx, prefix, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject)) { - Contract.Requires(ctx != null); - Contract.Requires(range != null); + Debug.Assert(ctx != null); + Debug.Assert(range != null); } #if DEBUG @@ -335,7 +332,7 @@ namespace Microsoft.Z3 { get { - Contract.Requires(args == null || Contract.ForAll(args, a => a != null)); + Debug.Assert(args == null || args.All(a => a != null)); return Apply(args); } @@ -348,7 +345,7 @@ namespace Microsoft.Z3 /// public Expr Apply(params Expr[] args) { - Contract.Requires(args == null || Contract.ForAll(args, a => a != null)); + Debug.Assert(args == null || args.All(a => a != null)); Context.CheckContextMatch(args); return Expr.Create(Context, this, args); diff --git a/src/api/dotnet/FuncInterp.cs b/src/api/dotnet/FuncInterp.cs index 449d460f9..6924049d3 100644 --- a/src/api/dotnet/FuncInterp.cs +++ b/src/api/dotnet/FuncInterp.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -26,7 +26,6 @@ namespace Microsoft.Z3 /// A function interpretation is represented as a finite map and an 'else' value. /// Each entry in the finite map represents the value of a function given a set of arguments. /// - [ContractVerification(true)] public class FuncInterp : Z3Object { /// @@ -42,7 +41,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Expr.Create(Context, Native.Z3_func_entry_get_value(Context.nCtx, NativeObject)); } } @@ -62,8 +60,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); - Contract.Ensures(Contract.Result().Length == this.NumArgs); uint n = NumArgs; Expr[] res = new Expr[n]; @@ -87,7 +83,7 @@ namespace Microsoft.Z3 } #region Internal - internal Entry(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal Entry(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue { @@ -133,8 +129,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); - Contract.Ensures(Contract.ForAll(0, Contract.Result().Length, j => Contract.Result()[j] != null)); uint n = NumEntries; Entry[] res = new Entry[n]; @@ -151,7 +145,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Expr.Create(Context, Native.Z3_func_interp_get_else(Context.nCtx, NativeObject)); } @@ -194,7 +187,7 @@ namespace Microsoft.Z3 internal FuncInterp(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/Global.cs b/src/api/dotnet/Global.cs index 17963b33d..207498760 100644 --- a/src/api/dotnet/Global.cs +++ b/src/api/dotnet/Global.cs @@ -17,9 +17,9 @@ Notes: --*/ +using System.Diagnostics; using System; using System.Runtime.InteropServices; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { diff --git a/src/api/dotnet/Goal.cs b/src/api/dotnet/Goal.cs index ef2e9a5da..4dbc78b7e 100644 --- a/src/api/dotnet/Goal.cs +++ b/src/api/dotnet/Goal.cs @@ -18,7 +18,8 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; +using System.Linq; namespace Microsoft.Z3 { @@ -27,7 +28,6 @@ namespace Microsoft.Z3 /// of formulas, that can be solved and/or transformed using /// tactics and solvers. /// - [ContractVerification(true)] public class Goal : Z3Object { /// @@ -79,13 +79,13 @@ namespace Microsoft.Z3 /// public void Assert(params BoolExpr[] constraints) { - Contract.Requires(constraints != null); - Contract.Requires(Contract.ForAll(constraints, c => c != null)); + Debug.Assert(constraints != null); + Debug.Assert(constraints.All(c => c != null)); Context.CheckContextMatch(constraints); foreach (BoolExpr c in constraints) { - Contract.Assert(c != null); // It was an assume, now made an assert just to be sure we do not regress + Debug.Assert(c != null); // It was an assume, now made an assert just to be sure we do not regress Native.Z3_goal_assert(Context.nCtx, NativeObject, c.NativeObject); } } @@ -140,7 +140,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = Size; BoolExpr[] res = new BoolExpr[n]; @@ -181,7 +180,6 @@ namespace Microsoft.Z3 /// A model for g public Model ConvertModel(Model m) { - Contract.Ensures(Contract.Result() != null); if (m != null) return new Model(Context, Native.Z3_goal_convert_model(Context.nCtx, NativeObject, m.NativeObject)); else @@ -194,7 +192,7 @@ namespace Microsoft.Z3 /// public Goal Translate(Context ctx) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); return new Goal(ctx, Native.Z3_goal_translate(Context.nCtx, NativeObject, ctx.nCtx)); } @@ -248,12 +246,12 @@ namespace Microsoft.Z3 } #region Internal - internal Goal(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal Goal(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } internal Goal(Context ctx, bool models, bool unsatCores, bool proofs) : base(ctx, Native.Z3_mk_goal(ctx.nCtx, (byte)(models ? 1 : 0), (byte)(unsatCores ? 1 : 0), (byte)(proofs ? 1 : 0))) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/IDecRefQueue.cs b/src/api/dotnet/IDecRefQueue.cs index 43506fabf..8af0973d6 100644 --- a/src/api/dotnet/IDecRefQueue.cs +++ b/src/api/dotnet/IDecRefQueue.cs @@ -17,26 +17,24 @@ Notes: --*/ +using System.Diagnostics; using System; using System.Collections; using System.Collections.Generic; using System.Threading; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// DecRefQueue interface /// - [ContractClass(typeof(DecRefQueueContracts))] public abstract class IDecRefQueue { #region Object invariant - [ContractInvariantMethod] private void ObjectInvariant() { - Contract.Invariant(this.m_queue != null); + Debug.Assert(this.m_queue != null); } #endregion @@ -61,7 +59,7 @@ namespace Microsoft.Z3 internal void IncAndClear(Context ctx, IntPtr o) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); IncRef(ctx, o); if (m_queue.Count >= m_move_limit) Clear(ctx); @@ -79,7 +77,7 @@ namespace Microsoft.Z3 internal void Clear(Context ctx) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); lock (m_lock) { @@ -90,17 +88,16 @@ namespace Microsoft.Z3 } } - [ContractClassFor(typeof(IDecRefQueue))] abstract class DecRefQueueContracts : IDecRefQueue { internal override void IncRef(Context ctx, IntPtr obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal override void DecRef(Context ctx, IntPtr obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } } } diff --git a/src/api/dotnet/IntExpr.cs b/src/api/dotnet/IntExpr.cs index 622be7bd5..3ca5398ea 100644 --- a/src/api/dotnet/IntExpr.cs +++ b/src/api/dotnet/IntExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 internal IntExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/IntNum.cs b/src/api/dotnet/IntNum.cs index 64fd78ad2..36f209cab 100644 --- a/src/api/dotnet/IntNum.cs +++ b/src/api/dotnet/IntNum.cs @@ -16,8 +16,8 @@ Author: Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; #if !FRAMEWORK_LT_4 using System.Numerics; @@ -28,7 +28,6 @@ namespace Microsoft.Z3 /// /// Integer Numerals /// - [ContractVerification(true)] public class IntNum : IntExpr { @@ -36,7 +35,7 @@ namespace Microsoft.Z3 internal IntNum(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion diff --git a/src/api/dotnet/IntSort.cs b/src/api/dotnet/IntSort.cs index d0c25ac79..289be4bcc 100644 --- a/src/api/dotnet/IntSort.cs +++ b/src/api/dotnet/IntSort.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -31,12 +31,12 @@ namespace Microsoft.Z3 internal IntSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal IntSort(Context ctx) : base(ctx, Native.Z3_mk_int_sort(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/IntSymbol.cs b/src/api/dotnet/IntSymbol.cs index df2d9da52..1bb3b3f13 100644 --- a/src/api/dotnet/IntSymbol.cs +++ b/src/api/dotnet/IntSymbol.cs @@ -18,15 +18,14 @@ Notes: --*/ using System; +using System.Diagnostics; using System.Runtime.InteropServices; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Numbered symbols /// - [ContractVerification(true)] public class IntSymbol : Symbol { /// @@ -47,12 +46,12 @@ namespace Microsoft.Z3 internal IntSymbol(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal IntSymbol(Context ctx, int i) : base(ctx, Native.Z3_mk_int_symbol(ctx.nCtx, i)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #if DEBUG diff --git a/src/api/dotnet/Lambda.cs b/src/api/dotnet/Lambda.cs index b3dc6c01c..35497f88f 100644 --- a/src/api/dotnet/Lambda.cs +++ b/src/api/dotnet/Lambda.cs @@ -18,14 +18,14 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; +using System.Linq; namespace Microsoft.Z3 { /// /// Lambda expressions. /// - [ContractVerification(true)] public class Lambda : ArrayExpr { /// @@ -43,7 +43,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumBound; Symbol[] res = new Symbol[n]; @@ -60,7 +59,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumBound; Sort[] res = new Sort[n]; @@ -77,7 +75,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject)); } @@ -94,17 +91,16 @@ namespace Microsoft.Z3 } #region Internal - [ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug internal Lambda(Context ctx, Sort[] sorts, Symbol[] names, Expr body) : base(ctx, IntPtr.Zero) { - Contract.Requires(ctx != null); - Contract.Requires(sorts != null); - Contract.Requires(names != null); - Contract.Requires(body != null); - Contract.Requires(sorts.Length == names.Length); - Contract.Requires(Contract.ForAll(sorts, s => s != null)); - Contract.Requires(Contract.ForAll(names, n => n != null)); + Debug.Assert(ctx != null); + Debug.Assert(sorts != null); + Debug.Assert(names != null); + Debug.Assert(body != null); + Debug.Assert(sorts.Length == names.Length); + Debug.Assert(sorts.All(s => s != null)); + Debug.Assert(names.All(n => n != null)); Context.CheckContextMatch(sorts); Context.CheckContextMatch(names); Context.CheckContextMatch(body); @@ -119,14 +115,13 @@ namespace Microsoft.Z3 } - [ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug internal Lambda(Context ctx, Expr[] bound, Expr body) : base(ctx, IntPtr.Zero) { - Contract.Requires(ctx != null); - Contract.Requires(body != null); + Debug.Assert(ctx != null); + Debug.Assert(body != null); - Contract.Requires(bound != null && bound.Length > 0 && Contract.ForAll(bound, n => n != null)); + Debug.Assert(bound != null && bound.Length > 0 && bound.All(n => n != null)); Context.CheckContextMatch(bound); Context.CheckContextMatch(body); @@ -137,7 +132,7 @@ namespace Microsoft.Z3 } - internal Lambda(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal Lambda(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #if DEBUG internal override void CheckNativeObject(IntPtr obj) diff --git a/src/api/dotnet/ListSort.cs b/src/api/dotnet/ListSort.cs index e860e4d4b..575f2a9bb 100644 --- a/src/api/dotnet/ListSort.cs +++ b/src/api/dotnet/ListSort.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// List sorts. /// - [ContractVerification(true)] public class ListSort : Sort { /// @@ -35,7 +34,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, 0)); } } @@ -47,7 +45,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Context.MkApp(NilDecl); } } @@ -59,7 +56,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, 0)); } } @@ -71,7 +67,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, 1)); } } @@ -84,7 +79,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, 1)); } } @@ -96,7 +90,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor_accessor(Context.nCtx, NativeObject, 1, 0)); } } @@ -108,7 +101,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor_accessor(Context.nCtx, NativeObject, 1, 1)); } } @@ -117,9 +109,9 @@ namespace Microsoft.Z3 internal ListSort(Context ctx, Symbol name, Sort elemSort) : base(ctx, IntPtr.Zero) { - Contract.Requires(ctx != null); - Contract.Requires(name != null); - Contract.Requires(elemSort != null); + Debug.Assert(ctx != null); + Debug.Assert(name != null); + Debug.Assert(elemSort != null); IntPtr inil = IntPtr.Zero, iisnil = IntPtr.Zero, icons = IntPtr.Zero, iiscons = IntPtr.Zero, diff --git a/src/api/dotnet/Log.cs b/src/api/dotnet/Log.cs index f8b2ea88b..a94c29bc6 100644 --- a/src/api/dotnet/Log.cs +++ b/src/api/dotnet/Log.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -29,7 +29,6 @@ namespace Microsoft.Z3 /// Note that this is a global, static log and if multiple Context /// objects are created, it logs the interaction with all of them. /// - [ContractVerification(true)] public static class Log { private static bool m_is_open = false; @@ -59,7 +58,7 @@ namespace Microsoft.Z3 /// public static void Append(string s) { - Contract.Requires(isOpen()); + Debug.Assert(isOpen()); if (!m_is_open) throw new Z3Exception("Log cannot be closed."); @@ -70,7 +69,6 @@ namespace Microsoft.Z3 /// Checks whether the interaction log is opened. /// /// True if the interaction log is open, false otherwise. - [Pure] public static bool isOpen() { return m_is_open; diff --git a/src/api/dotnet/Microsoft.Z3.csproj b/src/api/dotnet/Microsoft.Z3.csproj index 9aaa70821..045c610dd 100644 --- a/src/api/dotnet/Microsoft.Z3.csproj +++ b/src/api/dotnet/Microsoft.Z3.csproj @@ -342,6 +342,7 @@ + @@ -364,6 +365,7 @@ + diff --git a/src/api/dotnet/Model.cs b/src/api/dotnet/Model.cs index 96f62c9fb..c24516c22 100644 --- a/src/api/dotnet/Model.cs +++ b/src/api/dotnet/Model.cs @@ -18,7 +18,7 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Collections.Generic; namespace Microsoft.Z3 @@ -26,7 +26,6 @@ namespace Microsoft.Z3 /// /// A Model contains interpretations (assignments) of constants and functions. /// - [ContractVerification(true)] public class Model : Z3Object { /// @@ -36,7 +35,7 @@ namespace Microsoft.Z3 /// An expression if the constant has an interpretation in the model, null otherwise. public Expr ConstInterp(Expr a) { - Contract.Requires(a != null); + Debug.Assert(a != null); Context.CheckContextMatch(a); return ConstInterp(a.FuncDecl); @@ -49,7 +48,7 @@ namespace Microsoft.Z3 /// An expression if the function has an interpretation in the model, null otherwise. public Expr ConstInterp(FuncDecl f) { - Contract.Requires(f != null); + Debug.Assert(f != null); Context.CheckContextMatch(f); if (f.Arity != 0 || @@ -70,7 +69,7 @@ namespace Microsoft.Z3 /// A FunctionInterpretation if the function has an interpretation in the model, null otherwise. public FuncInterp FuncInterp(FuncDecl f) { - Contract.Requires(f != null); + Debug.Assert(f != null); Context.CheckContextMatch(f); @@ -122,7 +121,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumConsts; FuncDecl[] res = new FuncDecl[n]; @@ -165,7 +163,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumFuncs; FuncDecl[] res = new FuncDecl[n]; @@ -182,7 +179,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint nFuncs = NumFuncs; uint nConsts = NumConsts; @@ -223,8 +219,7 @@ namespace Microsoft.Z3 /// The evaluation of in the model. public Expr Eval(Expr t, bool completion = false) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); IntPtr v = IntPtr.Zero; if (Native.Z3_model_eval(Context.nCtx, NativeObject, t.NativeObject, (byte)(completion ? 1 : 0), ref v) == (byte)0) @@ -238,8 +233,7 @@ namespace Microsoft.Z3 /// public Expr Evaluate(Expr t, bool completion = false) { - Contract.Requires(t != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(t != null); return Eval(t, completion); } @@ -263,7 +257,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumSorts; Sort[] res = new Sort[n]; @@ -281,8 +274,7 @@ namespace Microsoft.Z3 /// An array of expressions, where each is an element of the universe of public Expr[] SortUniverse(Sort s) { - Contract.Requires(s != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(s != null); ASTVector av = new ASTVector(Context, Native.Z3_model_get_sort_universe(Context.nCtx, NativeObject, s.NativeObject)); return av.ToExprArray(); @@ -301,7 +293,7 @@ namespace Microsoft.Z3 internal Model(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/Optimize.cs b/src/api/dotnet/Optimize.cs index ce3cc55f7..4713f414a 100644 --- a/src/api/dotnet/Optimize.cs +++ b/src/api/dotnet/Optimize.cs @@ -19,14 +19,14 @@ Notes: using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; +using System.Linq; namespace Microsoft.Z3 { /// /// Object for managing optimizization context /// - [ContractVerification(true)] public class Optimize : Z3Object { /// @@ -36,7 +36,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Native.Z3_optimize_get_help(Context.nCtx, NativeObject); } } @@ -48,7 +47,7 @@ namespace Microsoft.Z3 { set { - Contract.Requires(value != null); + Debug.Assert(value != null); Context.CheckContextMatch(value); Native.Z3_optimize_set_params(Context.nCtx, NativeObject, value.NativeObject); } @@ -99,8 +98,8 @@ namespace Microsoft.Z3 /// private void AddConstraints(IEnumerable constraints) { - Contract.Requires(constraints != null); - Contract.Requires(Contract.ForAll(constraints, c => c != null)); + Debug.Assert(constraints != null); + Debug.Assert(constraints.All(c => c != null)); Context.CheckContextMatch(constraints); foreach (BoolExpr a in constraints) @@ -248,7 +247,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); ASTVector core = new ASTVector(Context, Native.Z3_optimize_get_unsat_core(Context.nCtx, NativeObject)); return core.ToBoolExprArray(); @@ -319,7 +317,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Native.Z3_optimize_get_reason_unknown(Context.nCtx, NativeObject); } } @@ -357,7 +354,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); ASTVector assertions = new ASTVector(Context, Native.Z3_optimize_get_assertions(Context.nCtx, NativeObject)); return assertions.ToBoolExprArray(); @@ -371,7 +367,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); ASTVector objectives = new ASTVector(Context, Native.Z3_optimize_get_objectives(Context.nCtx, NativeObject)); return objectives.ToExprArray(); @@ -386,7 +381,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new Statistics(Context, Native.Z3_optimize_get_statistics(Context.nCtx, NativeObject)); } @@ -397,12 +391,12 @@ namespace Microsoft.Z3 internal Optimize(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal Optimize(Context ctx) : base(ctx, Native.Z3_mk_optimize(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/ParamDescrs.cs b/src/api/dotnet/ParamDescrs.cs index 1809518e1..fbfb9cd16 100644 --- a/src/api/dotnet/ParamDescrs.cs +++ b/src/api/dotnet/ParamDescrs.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// A ParamDescrs describes a set of parameters. /// - [ContractVerification(true)] public class ParamDescrs : Z3Object { /// @@ -33,7 +32,7 @@ namespace Microsoft.Z3 /// public void Validate(Params p) { - Contract.Requires(p != null); + Debug.Assert(p != null); Native.Z3_params_validate(Context.nCtx, p.NativeObject, NativeObject); } @@ -42,7 +41,7 @@ namespace Microsoft.Z3 /// public Z3_param_kind GetKind(Symbol name) { - Contract.Requires(name != null); + Debug.Assert(name != null); return (Z3_param_kind)Native.Z3_param_descrs_get_kind(Context.nCtx, NativeObject, name.NativeObject); } @@ -51,7 +50,7 @@ namespace Microsoft.Z3 /// public string GetDocumentation(Symbol name) { - Contract.Requires(name != null); + Debug.Assert(name != null); return Native.Z3_param_descrs_get_documentation(Context.nCtx, NativeObject, name.NativeObject); } @@ -91,7 +90,7 @@ namespace Microsoft.Z3 internal ParamDescrs(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/Params.cs b/src/api/dotnet/Params.cs index f0f28d8d3..e5926934a 100644 --- a/src/api/dotnet/Params.cs +++ b/src/api/dotnet/Params.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// A Params objects represents a configuration in the form of Symbol/value pairs. /// - [ContractVerification(true)] public class Params : Z3Object { /// @@ -33,7 +32,7 @@ namespace Microsoft.Z3 /// public Params Add(Symbol name, bool value) { - Contract.Requires(name != null); + Debug.Assert(name != null); Native.Z3_params_set_bool(Context.nCtx, NativeObject, name.NativeObject, (byte)(value ? 1 : 0)); return this; @@ -44,7 +43,7 @@ namespace Microsoft.Z3 /// public Params Add(Symbol name, uint value) { - Contract.Requires(name != null); + Debug.Assert(name != null); Native.Z3_params_set_uint(Context.nCtx, NativeObject, name.NativeObject, value); return this; @@ -55,7 +54,7 @@ namespace Microsoft.Z3 /// public Params Add(Symbol name, double value) { - Contract.Requires(name != null); + Debug.Assert(name != null); Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value); return this; @@ -66,7 +65,7 @@ namespace Microsoft.Z3 /// public Params Add(Symbol name, string value) { - Contract.Requires(value != null); + Debug.Assert(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, Context.MkSymbol(value).NativeObject); return this; @@ -77,8 +76,8 @@ namespace Microsoft.Z3 /// public Params Add(Symbol name, Symbol value) { - Contract.Requires(name != null); - Contract.Requires(value != null); + Debug.Assert(name != null); + Debug.Assert(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, value.NativeObject); return this; @@ -117,7 +116,7 @@ namespace Microsoft.Z3 /// public Params Add(string name, Symbol value) { - Contract.Requires(value != null); + Debug.Assert(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject); return this; @@ -128,8 +127,8 @@ namespace Microsoft.Z3 /// public Params Add(string name, string value) { - Contract.Requires(name != null); - Contract.Requires(value != null); + Debug.Assert(name != null); + Debug.Assert(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, Context.MkSymbol(value).NativeObject); return this; @@ -147,7 +146,7 @@ namespace Microsoft.Z3 internal Params(Context ctx) : base(ctx, Native.Z3_mk_params(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/Pattern.cs b/src/api/dotnet/Pattern.cs index 1ea7bdb38..c33a38a1d 100644 --- a/src/api/dotnet/Pattern.cs +++ b/src/api/dotnet/Pattern.cs @@ -17,9 +17,9 @@ Notes: --*/ +using System.Diagnostics; using System; using System.Runtime.InteropServices; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -28,7 +28,6 @@ namespace Microsoft.Z3 /// non-empty. If the list comprises of more than one term, it is /// also called a multi-pattern. /// - [ContractVerification(true)] public class Pattern : AST { /// @@ -46,7 +45,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumTerms; Expr[] res = new Expr[n]; @@ -68,7 +66,7 @@ namespace Microsoft.Z3 internal Pattern(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/Probe.cs b/src/api/dotnet/Probe.cs index 3c5e5adc9..5cdee79a2 100644 --- a/src/api/dotnet/Probe.cs +++ b/src/api/dotnet/Probe.cs @@ -17,9 +17,9 @@ Notes: --*/ +using System.Diagnostics; using System; using System.Runtime.InteropServices; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -30,7 +30,6 @@ namespace Microsoft.Z3 /// and Context.ProbeNames. /// It may also be obtained using the command (help-tactic) in the SMT 2.0 front-end. /// - [ContractVerification(true)] public class Probe : Z3Object { /// @@ -40,7 +39,7 @@ namespace Microsoft.Z3 /// "Boolean" probes return 0.0 for false, and a value different from 0.0 for true. public double Apply(Goal g) { - Contract.Requires(g != null); + Debug.Assert(g != null); Context.CheckContextMatch(g); return Native.Z3_probe_apply(Context.nCtx, NativeObject, g.NativeObject); @@ -53,7 +52,7 @@ namespace Microsoft.Z3 { get { - Contract.Requires(g != null); + Debug.Assert(g != null); return Apply(g); } @@ -63,12 +62,12 @@ namespace Microsoft.Z3 internal Probe(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal Probe(Context ctx, string name) : base(ctx, Native.Z3_mk_probe(ctx.nCtx, name)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/Quantifier.cs b/src/api/dotnet/Quantifier.cs index d13ca4003..f4a889092 100644 --- a/src/api/dotnet/Quantifier.cs +++ b/src/api/dotnet/Quantifier.cs @@ -18,14 +18,14 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; +using System.Linq; namespace Microsoft.Z3 { /// /// Quantifier expressions. /// - [ContractVerification(true)] public class Quantifier : BoolExpr { /// @@ -67,7 +67,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumPatterns; Pattern[] res = new Pattern[n]; @@ -92,7 +91,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumNoPatterns; Pattern[] res = new Pattern[n]; @@ -117,7 +115,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumBound; Symbol[] res = new Symbol[n]; @@ -134,7 +131,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumBound; Sort[] res = new Sort[n]; @@ -151,7 +147,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new BoolExpr(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject)); } @@ -168,19 +163,18 @@ namespace Microsoft.Z3 } #region Internal - [ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug internal Quantifier(Context ctx, bool isForall, Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) : base(ctx, IntPtr.Zero) { - Contract.Requires(ctx != null); - Contract.Requires(sorts != null); - Contract.Requires(names != null); - Contract.Requires(body != null); - Contract.Requires(sorts.Length == names.Length); - Contract.Requires(Contract.ForAll(sorts, s => s != null)); - Contract.Requires(Contract.ForAll(names, n => n != null)); - Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); - Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); + Debug.Assert(ctx != null); + Debug.Assert(sorts != null); + Debug.Assert(names != null); + Debug.Assert(body != null); + Debug.Assert(sorts.Length == names.Length); + Debug.Assert(sorts.All(s => s != null)); + Debug.Assert(names.All(n => n != null)); + Debug.Assert(patterns == null || patterns.All(p => p != null)); + Debug.Assert(noPatterns == null || noPatterns.All(np => np != null)); Context.CheckContextMatch(patterns); Context.CheckContextMatch(noPatterns); @@ -211,16 +205,15 @@ namespace Microsoft.Z3 } } - [ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug internal Quantifier(Context ctx, bool isForall, Expr[] bound, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) : base(ctx, IntPtr.Zero) { - Contract.Requires(ctx != null); - Contract.Requires(body != null); + Debug.Assert(ctx != null); + Debug.Assert(body != null); - Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); - Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); - Contract.Requires(bound == null || Contract.ForAll(bound, n => n != null)); + Debug.Assert(patterns == null || patterns.All(p => p != null)); + Debug.Assert(noPatterns == null || noPatterns.All(np => np != null)); + Debug.Assert(bound == null || bound.All(n => n != null)); Context.CheckContextMatch(noPatterns); Context.CheckContextMatch(patterns); @@ -246,7 +239,7 @@ namespace Microsoft.Z3 } - internal Quantifier(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal Quantifier(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #if DEBUG internal override void CheckNativeObject(IntPtr obj) diff --git a/src/api/dotnet/RatNum.cs b/src/api/dotnet/RatNum.cs index bad6b323d..1d485a347 100644 --- a/src/api/dotnet/RatNum.cs +++ b/src/api/dotnet/RatNum.cs @@ -16,8 +16,8 @@ Author: Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; #if !FRAMEWORK_LT_4 using System.Numerics; @@ -28,7 +28,6 @@ namespace Microsoft.Z3 /// /// Rational Numerals /// - [ContractVerification(true)] public class RatNum : RealExpr { /// @@ -38,7 +37,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new IntNum(Context, Native.Z3_get_numerator(Context.nCtx, NativeObject)); } @@ -51,7 +49,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new IntNum(Context, Native.Z3_get_denominator(Context.nCtx, NativeObject)); } @@ -92,6 +89,14 @@ namespace Microsoft.Z3 return Native.Z3_get_numeral_decimal_string(Context.nCtx, NativeObject, precision); } + /// + /// Returns a double representing the value. + /// + public double Double + { + get { return Native.Z3_get_numeral_double(Context.nCtx, NativeObject); } + } + /// /// Returns a string representation of the numeral. /// @@ -104,7 +109,7 @@ namespace Microsoft.Z3 internal RatNum(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/ReExpr.cs b/src/api/dotnet/ReExpr.cs index 6a10d535f..7ab9aaffc 100644 --- a/src/api/dotnet/ReExpr.cs +++ b/src/api/dotnet/ReExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 internal ReExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/ReSort.cs b/src/api/dotnet/ReSort.cs index bc420603d..98659c697 100644 --- a/src/api/dotnet/ReSort.cs +++ b/src/api/dotnet/ReSort.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -31,12 +31,12 @@ namespace Microsoft.Z3 internal ReSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal ReSort(Context ctx) : base(ctx, Native.Z3_mk_int_sort(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/RealExpr.cs b/src/api/dotnet/RealExpr.cs index 8ee8c8e76..1c3a55189 100644 --- a/src/api/dotnet/RealExpr.cs +++ b/src/api/dotnet/RealExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 internal RealExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/RealSort.cs b/src/api/dotnet/RealSort.cs index 97f1cae11..38fe469ce 100644 --- a/src/api/dotnet/RealSort.cs +++ b/src/api/dotnet/RealSort.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -31,12 +31,12 @@ namespace Microsoft.Z3 internal RealSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal RealSort(Context ctx) : base(ctx, Native.Z3_mk_real_sort(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/RelationSort.cs b/src/api/dotnet/RelationSort.cs index cfd7a592a..6bea5c6e1 100644 --- a/src/api/dotnet/RelationSort.cs +++ b/src/api/dotnet/RelationSort.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Relation sorts. /// - [ContractVerification(true)] public class RelationSort : Sort { /// @@ -43,7 +42,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); if (m_columnSorts != null) return m_columnSorts; @@ -62,7 +60,7 @@ namespace Microsoft.Z3 internal RelationSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/SeqExpr.cs b/src/api/dotnet/SeqExpr.cs index c9fdd03a8..bfab1fa36 100644 --- a/src/api/dotnet/SeqExpr.cs +++ b/src/api/dotnet/SeqExpr.cs @@ -16,12 +16,12 @@ Author: Notes: --*/ +using System.Diagnostics; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 internal SeqExpr(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/SeqSort.cs b/src/api/dotnet/SeqSort.cs index b2be11291..2902b1e9e 100644 --- a/src/api/dotnet/SeqSort.cs +++ b/src/api/dotnet/SeqSort.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -31,12 +31,12 @@ namespace Microsoft.Z3 internal SeqSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal SeqSort(Context ctx) : base(ctx, Native.Z3_mk_int_sort(ctx.nCtx)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #endregion } diff --git a/src/api/dotnet/SetSort.cs b/src/api/dotnet/SetSort.cs index bdba3899f..9f55c8edb 100644 --- a/src/api/dotnet/SetSort.cs +++ b/src/api/dotnet/SetSort.cs @@ -17,28 +17,27 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Set sorts. /// - [ContractVerification(true)] public class SetSort : Sort { #region Internal internal SetSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal SetSort(Context ctx, Sort ty) : base(ctx, Native.Z3_mk_set_sort(ctx.nCtx, ty.NativeObject)) { - Contract.Requires(ctx != null); - Contract.Requires(ty != null); + Debug.Assert(ctx != null); + Debug.Assert(ty != null); } #endregion } diff --git a/src/api/dotnet/Solver.cs b/src/api/dotnet/Solver.cs index a288990a2..ec53b14de 100644 --- a/src/api/dotnet/Solver.cs +++ b/src/api/dotnet/Solver.cs @@ -18,16 +18,15 @@ Notes: --*/ using System; +using System.Diagnostics; using System.Linq; using System.Collections.Generic; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Solvers. /// - [ContractVerification(true)] public class Solver : Z3Object { /// @@ -37,7 +36,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Native.Z3_solver_get_help(Context.nCtx, NativeObject); } @@ -50,7 +48,7 @@ namespace Microsoft.Z3 { set { - Contract.Requires(value != null); + Debug.Assert(value != null); Context.CheckContextMatch(value); Native.Z3_solver_set_params(Context.nCtx, NativeObject, value.NativeObject); @@ -152,8 +150,8 @@ namespace Microsoft.Z3 /// public void Assert(params BoolExpr[] constraints) { - Contract.Requires(constraints != null); - Contract.Requires(Contract.ForAll(constraints, c => c != null)); + Debug.Assert(constraints != null); + Debug.Assert(constraints.All(c => c != null)); Context.CheckContextMatch(constraints); foreach (BoolExpr a in constraints) @@ -191,9 +189,9 @@ namespace Microsoft.Z3 /// public void AssertAndTrack(BoolExpr[] constraints, BoolExpr[] ps) { - Contract.Requires(constraints != null); - Contract.Requires(Contract.ForAll(constraints, c => c != null)); - Contract.Requires(Contract.ForAll(ps, c => c != null)); + Debug.Assert(constraints != null); + Debug.Assert(constraints.All(c => c != null)); + Debug.Assert(ps.All(c => c != null)); Context.CheckContextMatch(constraints); Context.CheckContextMatch(ps); if (constraints.Length != ps.Length) @@ -216,8 +214,8 @@ namespace Microsoft.Z3 /// public void AssertAndTrack(BoolExpr constraint, BoolExpr p) { - Contract.Requires(constraint != null); - Contract.Requires(p != null); + Debug.Assert(constraint != null); + Debug.Assert(p != null); Context.CheckContextMatch(constraint); Context.CheckContextMatch(p); @@ -259,7 +257,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); ASTVector assertions = new ASTVector(Context, Native.Z3_solver_get_assertions(Context.nCtx, NativeObject)); return assertions.ToBoolExprArray(); @@ -273,7 +270,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); ASTVector assertions = new ASTVector(Context, Native.Z3_solver_get_units(Context.nCtx, NativeObject)); return assertions.ToBoolExprArray(); @@ -394,7 +390,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); ASTVector core = new ASTVector(Context, Native.Z3_solver_get_unsat_core(Context.nCtx, NativeObject)); return core.ToBoolExprArray(); @@ -408,7 +403,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Native.Z3_solver_get_reason_unknown(Context.nCtx, NativeObject); } @@ -455,8 +449,7 @@ namespace Microsoft.Z3 /// public Solver Translate(Context ctx) { - Contract.Requires(ctx != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ctx != null); return new Solver(ctx, Native.Z3_solver_translate(Context.nCtx, NativeObject, ctx.nCtx)); } @@ -475,7 +468,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new Statistics(Context, Native.Z3_solver_get_statistics(Context.nCtx, NativeObject)); } @@ -493,7 +485,7 @@ namespace Microsoft.Z3 internal Solver(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); this.BacktrackLevel = uint.MaxValue; } diff --git a/src/api/dotnet/Sort.cs b/src/api/dotnet/Sort.cs index e32fd1eb3..cf70bbf73 100644 --- a/src/api/dotnet/Sort.cs +++ b/src/api/dotnet/Sort.cs @@ -17,15 +17,14 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// The Sort class implements type information for ASTs. /// - [ContractVerification(true)] public class Sort : AST { /// @@ -100,7 +99,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Symbol.Create(Context, Native.Z3_get_sort_name(Context.nCtx, NativeObject)); } } @@ -127,7 +125,7 @@ namespace Microsoft.Z3 /// /// Sort constructor /// - internal Sort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } + internal Sort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); } #if DEBUG internal override void CheckNativeObject(IntPtr obj) @@ -138,11 +136,9 @@ namespace Microsoft.Z3 } #endif - [ContractVerification(true)] new internal static Sort Create(Context ctx, IntPtr obj) { - Contract.Requires(ctx != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ctx != null); switch ((Z3_sort_kind)Native.Z3_get_sort_kind(ctx.nCtx, obj)) { diff --git a/src/api/dotnet/Statistics.cs b/src/api/dotnet/Statistics.cs index c94af625c..8b664913a 100644 --- a/src/api/dotnet/Statistics.cs +++ b/src/api/dotnet/Statistics.cs @@ -18,14 +18,14 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; + namespace Microsoft.Z3 { /// /// Objects of this class track statistical information about solvers. /// - [ContractVerification(true)] public class Statistics : Z3Object { /// @@ -62,7 +62,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); if (IsUInt) return m_uint.ToString(); @@ -124,9 +123,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); - Contract.Ensures(Contract.Result().Length == this.Size); - Contract.Ensures(Contract.ForAll(0, Contract.Result().Length, j => Contract.Result()[j] != null)); uint n = Size; Entry[] res = new Entry[n]; @@ -153,7 +149,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = Size; string[] res = new string[n]; @@ -184,7 +179,7 @@ namespace Microsoft.Z3 internal Statistics(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal class DecRefQueue : IDecRefQueue diff --git a/src/api/dotnet/Status.cs b/src/api/dotnet/Status.cs index 5847f098b..d44cffd56 100644 --- a/src/api/dotnet/Status.cs +++ b/src/api/dotnet/Status.cs @@ -17,6 +17,7 @@ Notes: --*/ +using System.Diagnostics; using System; namespace Microsoft.Z3 diff --git a/src/api/dotnet/StringSymbol.cs b/src/api/dotnet/StringSymbol.cs index e311fb958..447e0be5f 100644 --- a/src/api/dotnet/StringSymbol.cs +++ b/src/api/dotnet/StringSymbol.cs @@ -18,8 +18,8 @@ Notes: --*/ using System; +using System.Diagnostics; using System.Runtime.InteropServices; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -27,7 +27,6 @@ namespace Microsoft.Z3 /// /// Named symbols /// - [ContractVerification(true)] public class StringSymbol : Symbol { /// @@ -38,7 +37,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); if (!IsStringSymbol()) throw new Z3Exception("String requested from non-String symbol"); @@ -50,13 +48,13 @@ namespace Microsoft.Z3 internal StringSymbol(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal StringSymbol(Context ctx, string s) : base(ctx, Native.Z3_mk_string_symbol(ctx.nCtx, s)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } #if DEBUG diff --git a/src/api/dotnet/Symbol.cs b/src/api/dotnet/Symbol.cs index 2a1fdf6c5..afefdf3df 100644 --- a/src/api/dotnet/Symbol.cs +++ b/src/api/dotnet/Symbol.cs @@ -18,15 +18,14 @@ Notes: --*/ using System; +using System.Diagnostics; using System.Runtime.InteropServices; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { /// /// Symbols are used to name several term and type constructors. /// - [ContractVerification(true)] public class Symbol : Z3Object { /// @@ -84,7 +83,7 @@ namespace Microsoft.Z3 /// public static bool operator !=(Symbol s1, Symbol s2) { - return !(s1.NativeObject == s2.NativeObject); + return !(s1 == s2); } /// @@ -113,13 +112,12 @@ namespace Microsoft.Z3 /// internal protected Symbol(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal static Symbol Create(Context ctx, IntPtr obj) { - Contract.Requires(ctx != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(ctx != null); switch ((Z3_symbol_kind)Native.Z3_get_symbol_kind(ctx.nCtx, obj)) { diff --git a/src/api/dotnet/Tactic.cs b/src/api/dotnet/Tactic.cs index 0a6f79494..96b6da170 100644 --- a/src/api/dotnet/Tactic.cs +++ b/src/api/dotnet/Tactic.cs @@ -18,7 +18,7 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; namespace Microsoft.Z3 { @@ -28,7 +28,6 @@ namespace Microsoft.Z3 /// and Context.TacticNames. /// It may also be obtained using the command (help-tactic) in the SMT 2.0 front-end. /// - [ContractVerification(true)] public class Tactic : Z3Object { /// @@ -38,7 +37,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Native.Z3_tactic_get_help(Context.nCtx, NativeObject); } @@ -59,8 +57,7 @@ namespace Microsoft.Z3 /// public ApplyResult Apply(Goal g, Params p = null) { - Contract.Requires(g != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(g != null); Context.CheckContextMatch(g); if (p == null) @@ -79,8 +76,7 @@ namespace Microsoft.Z3 { get { - Contract.Requires(g != null); - Contract.Ensures(Contract.Result() != null); + Debug.Assert(g != null); return Apply(g); } @@ -94,7 +90,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return Context.MkSolver(this); } @@ -104,12 +99,12 @@ namespace Microsoft.Z3 internal Tactic(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal Tactic(Context ctx, string name) : base(ctx, Native.Z3_mk_tactic(ctx.nCtx, name)) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } /// diff --git a/src/api/dotnet/TupleSort.cs b/src/api/dotnet/TupleSort.cs index ea99f3855..adbc4f904 100644 --- a/src/api/dotnet/TupleSort.cs +++ b/src/api/dotnet/TupleSort.cs @@ -18,14 +18,13 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; namespace Microsoft.Z3 { /// /// Tuple sorts. /// - [ContractVerification(true)] public class TupleSort : Sort { /// @@ -35,7 +34,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return new FuncDecl(Context, Native.Z3_get_tuple_sort_mk_decl(Context.nCtx, NativeObject)); } @@ -56,7 +54,6 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); uint n = NumFields; FuncDecl[] res = new FuncDecl[n]; @@ -70,8 +67,8 @@ namespace Microsoft.Z3 internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts) : base(ctx, IntPtr.Zero) { - Contract.Requires(ctx != null); - Contract.Requires(name != null); + Debug.Assert(ctx != null); + Debug.Assert(name != null); IntPtr t = IntPtr.Zero; IntPtr[] f = new IntPtr[numFields]; diff --git a/src/api/dotnet/UninterpretedSort.cs b/src/api/dotnet/UninterpretedSort.cs index 154818faf..9f940468d 100644 --- a/src/api/dotnet/UninterpretedSort.cs +++ b/src/api/dotnet/UninterpretedSort.cs @@ -18,7 +18,7 @@ Notes: --*/ using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; namespace Microsoft.Z3 { @@ -31,13 +31,13 @@ namespace Microsoft.Z3 internal UninterpretedSort(Context ctx, IntPtr obj) : base(ctx, obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); } internal UninterpretedSort(Context ctx, Symbol s) : base(ctx, Native.Z3_mk_uninterpreted_sort(ctx.nCtx, s.NativeObject)) { - Contract.Requires(ctx != null); - Contract.Requires(s != null); + Debug.Assert(ctx != null); + Debug.Assert(s != null); } #endregion } diff --git a/src/api/dotnet/Version.cs b/src/api/dotnet/Version.cs index 364ada781..2099959eb 100644 --- a/src/api/dotnet/Version.cs +++ b/src/api/dotnet/Version.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; namespace Microsoft.Z3 { @@ -26,7 +26,6 @@ namespace Microsoft.Z3 /// Version information. /// /// Note that this class is static. - [ContractVerification(true)] public static class Version { static Version() { } @@ -99,7 +98,6 @@ namespace Microsoft.Z3 /// new public static string ToString() { - Contract.Ensures(Contract.Result() != null); uint major = 0, minor = 0, build = 0, revision = 0; Native.Z3_get_version(ref major, ref minor, ref build, ref revision); diff --git a/src/api/dotnet/Z3Exception.cs b/src/api/dotnet/Z3Exception.cs index b0e05900c..79f6185da 100644 --- a/src/api/dotnet/Z3Exception.cs +++ b/src/api/dotnet/Z3Exception.cs @@ -17,6 +17,7 @@ Notes: --*/ +using System.Diagnostics; using System; namespace Microsoft.Z3 diff --git a/src/api/dotnet/Z3Object.cs b/src/api/dotnet/Z3Object.cs index f32ba30af..9a61a0119 100644 --- a/src/api/dotnet/Z3Object.cs +++ b/src/api/dotnet/Z3Object.cs @@ -17,8 +17,8 @@ Notes: --*/ +using System.Diagnostics; using System; -using System.Diagnostics.Contracts; using System.Threading; using System.Collections.Generic; using System.Linq; @@ -29,7 +29,6 @@ namespace Microsoft.Z3 /// Internal base class for interfacing with native Z3 objects. /// Should not be used externally. /// - [ContractVerification(true)] public class Z3Object : IDisposable { /// @@ -63,10 +62,9 @@ namespace Microsoft.Z3 #region Object Invariant - [ContractInvariantMethod] private void ObjectInvariant() { - Contract.Invariant(this.m_ctx != null); + Debug.Assert(this.m_ctx != null); } #endregion @@ -77,7 +75,7 @@ namespace Microsoft.Z3 internal Z3Object(Context ctx) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); Interlocked.Increment(ref ctx.refCount); m_ctx = ctx; @@ -85,7 +83,7 @@ namespace Microsoft.Z3 internal Z3Object(Context ctx, IntPtr obj) { - Contract.Requires(ctx != null); + Debug.Assert(ctx != null); Interlocked.Increment(ref ctx.refCount); m_ctx = ctx; @@ -119,16 +117,12 @@ namespace Microsoft.Z3 { get { - Contract.Ensures(Contract.Result() != null); return m_ctx; } } - [Pure] internal static IntPtr[] ArrayToNative(Z3Object[] a) { - Contract.Ensures(a == null || Contract.Result() != null); - Contract.Ensures(a == null || Contract.Result().Length == a.Length); if (a == null) return null; IntPtr[] an = new IntPtr[a.Length]; @@ -137,11 +131,8 @@ namespace Microsoft.Z3 return an; } - [Pure] internal static IntPtr[] EnumToNative(IEnumerable a) where T : Z3Object { - Contract.Ensures(a == null || Contract.Result() != null); - Contract.Ensures(a == null || Contract.Result().Length == a.Count()); if (a == null) return null; IntPtr[] an = new IntPtr[a.Count()]; @@ -154,7 +145,6 @@ namespace Microsoft.Z3 return an; } - [Pure] internal static uint ArrayLength(Z3Object[] a) { return (a == null)?0:(uint)a.Length; diff --git a/src/api/dotnet/core/DummyContracts.cs b/src/api/dotnet/core/DummyContracts.cs deleted file mode 100644 index 103cc1288..000000000 --- a/src/api/dotnet/core/DummyContracts.cs +++ /dev/null @@ -1,65 +0,0 @@ -/*++ -Copyright () 2016 Microsoft Corporation - -Module Name: - - Contracts.cs - -Abstract: - - Z3 Managed API: Dummy Code Contracts class for .NET - frameworks that don't support them (e.g., CoreCLR). - -Author: - - Christoph Wintersteiger (cwinter) 2016-10-06 - -Notes: - ---*/ - -namespace System.Diagnostics.Contracts -{ - public class ContractClass : Attribute - { - public ContractClass(Type t) { } - } - - public class ContractClassFor : Attribute - { - public ContractClassFor(Type t) { } - } - - public class ContractInvariantMethod : Attribute - { - public ContractInvariantMethod() { } - } - - public class ContractVerification : Attribute - { - public ContractVerification(bool b) { } - } - - public class Pure : Attribute { } - - public static class Contract - { - [Conditional("false")] - public static void Ensures(bool b) { } - [Conditional("false")] - public static void Requires(bool b) { } - [Conditional("false")] - public static void Assume(bool b, string msg) { } - [Conditional("false")] - public static void Assert(bool b) { } - public static bool ForAll(bool b) { return true; } - public static bool ForAll(Object c, Func p) { return true; } - public static bool ForAll(int from, int to, Predicate p) { return true; } - [Conditional("false")] - public static void Invariant(bool b) { } - public static T[] Result() { return new T[1]; } - [Conditional("false")] - public static void EndContractBlock() { } - public static T ValueAtReturn(out T v) { T[] t = new T[1]; v = t[0]; return v; } - } -} diff --git a/src/api/dotnet/core/README.txt b/src/api/dotnet/core/README.txt index 72331d7f9..fa274f72b 100644 --- a/src/api/dotnet/core/README.txt +++ b/src/api/dotnet/core/README.txt @@ -6,4 +6,10 @@ functions, so that the API will compile, but not perform any contract checking. To build this using .NET core, run (in this directory): dotnet restore -dotnet build project.json +dotnet build core.csproj -c Release + +If you are building with the cmake system, you should first +copy over files that are produced by the compiler into +this directory. You need to copy over Native.cs and Enumeration.cs + +-- good luck! diff --git a/src/api/dotnet/core/core.csproj b/src/api/dotnet/core/core.csproj new file mode 100644 index 000000000..5fa3275cf --- /dev/null +++ b/src/api/dotnet/core/core.csproj @@ -0,0 +1,18 @@ + + + + netcoreapp1.0 + $(DefineConstants);DOTNET_CORE + portable + Microsoft.Z3 + Library + core + $(PackageTargetFallback);dnxcore50 + 1.0.4 + + + + + + + diff --git a/src/api/python/z3/z3util.py b/src/api/python/z3/z3util.py index fe7e76b86..6e5165c9a 100644 --- a/src/api/python/z3/z3util.py +++ b/src/api/python/z3/z3util.py @@ -199,7 +199,7 @@ def prove(claim,assume=None,verbose=0): >>> r,m = prove(True,assume=And(x,Not(x)),verbose=0) Traceback (most recent call last): ... - AssertionError: Assumption is alway False! + AssertionError: Assumption is always False! >>> r,m = prove(Implies(x,x),assume=y,verbose=2); r,model_str(m,as_str=False) assume: @@ -238,7 +238,7 @@ def prove(claim,assume=None,verbose=0): is_proved,_ = prove(Not(assume)) def _f(): - emsg = "Assumption is alway False!" + emsg = "Assumption is always False!" if verbose >= 2: emsg = "{}\n{}".format(assume,emsg) return emsg diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 03bce5d5e..de446d9a8 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -3772,7 +3772,7 @@ extern "C" { ); /** - \brief Create a lambda expression. It taks an expression \c body that contains bound variables + \brief Create a lambda expression. It takes an expression \c body that contains bound variables of the same sorts as the sorts listed in the array \c sorts. The bound variables are de-Bruijn indices created using #Z3_mk_bound. The array \c decl_names contains the names that the quantified formula uses for the bound variables. Z3 applies the convention that the last element in the \c decl_names and \c sorts array @@ -4438,6 +4438,15 @@ extern "C" { */ Z3_string Z3_API Z3_get_numeral_decimal_string(Z3_context c, Z3_ast a, unsigned precision); + /** + \brief Return numeral as a double. + + \pre Z3_get_ast_kind(c, a) == Z3_NUMERAL_AST || Z3_is_algebraic_number(c, a) + + def_API('Z3_get_numeral_double', DOUBLE, (_in(CONTEXT), _in(AST))) + */ + double Z3_API Z3_get_numeral_double(Z3_context c, Z3_ast a); + /** \brief Return the numerator (as a numeral AST) of a numeral AST of sort Real. @@ -4600,7 +4609,7 @@ extern "C" { Z3_bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a); /** - \brief Determine if ast is a lambda expresion. + \brief Determine if ast is a lambda expression. \pre Z3_get_ast_kind(a) == Z3_QUANTIFIER_AST @@ -5987,7 +5996,7 @@ extern "C" { Z3_solver Z3_API Z3_solver_translate(Z3_context source, Z3_solver s, Z3_context target); /** - \brief Ad-hoc method for importing model convertion from solver. + \brief Ad-hoc method for importing model conversion from solver. def_API('Z3_solver_import_model_converter', VOID, (_in(CONTEXT), _in(SOLVER), _in(SOLVER))) */ @@ -6206,7 +6215,7 @@ extern "C" { The third argument is a vector of variables that may be used for cubing. The contents of the vector is only used in the first call. The initial list of variables is used in subsequent calls until it returns the unsatisfiable cube. - The vector is modified to contain a set of Autarky variables that occor in clauses that + The vector is modified to contain a set of Autarky variables that occur in clauses that are affected by the (last literal in the) cube. These variables could be used by a different cuber (on a different solver object) for further recursive cubing. diff --git a/src/ast/ast_util.h b/src/ast/ast_util.h index 23c2205bb..a45c65d82 100644 --- a/src/ast/ast_util.h +++ b/src/ast/ast_util.h @@ -123,7 +123,7 @@ inline expr_ref mk_or(expr_ref_vector const& args) { return expr_ref(mk_or(args. /** Return a if arg = (not a) - Retur (not arg) otherwise + Return (not arg) otherwise */ expr * mk_not(ast_manager & m, expr * arg); diff --git a/src/ast/fpa/fpa2bv_rewriter.cpp b/src/ast/fpa/fpa2bv_rewriter.cpp index b2614e27d..7195f7179 100644 --- a/src/ast/fpa/fpa2bv_rewriter.cpp +++ b/src/ast/fpa/fpa2bv_rewriter.cpp @@ -31,7 +31,7 @@ fpa2bv_rewriter_cfg::fpa2bv_rewriter_cfg(ast_manager & m, fpa2bv_converter & c, m_bindings(m) { updt_params(p); - // We need to make sure that the mananger has the BV plugin loaded. + // We need to make sure that the manager has the BV plugin loaded. symbol s_bv("bv"); if (!m_manager.has_plugin(s_bv)) m_manager.register_plugin(s_bv, alloc(bv_decl_plugin)); diff --git a/src/ast/func_decl_dependencies.h b/src/ast/func_decl_dependencies.h index b813dc31f..9bc0be22d 100644 --- a/src/ast/func_decl_dependencies.h +++ b/src/ast/func_decl_dependencies.h @@ -58,7 +58,7 @@ public: void reset(); /** - \brief Create a dependecy set. + \brief Create a dependency set. This set should be populated using #collect_func_decls. After populating the set, it must be used as an argument for the #insert method. diff --git a/src/ast/macros/quasi_macros.cpp b/src/ast/macros/quasi_macros.cpp index ee1b77545..c91f19df8 100644 --- a/src/ast/macros/quasi_macros.cpp +++ b/src/ast/macros/quasi_macros.cpp @@ -263,7 +263,7 @@ bool quasi_macros::find_macros(unsigned n, expr * const * exprs) { m_occurrences.reset(); - // Find out how many non-ground appearences for each uninterpreted function there are + // Find out how many non-ground appearances for each uninterpreted function there are for (unsigned i = 0 ; i < n ; i++) find_occurrences(exprs[i]); @@ -301,7 +301,7 @@ bool quasi_macros::find_macros(unsigned n, justified_expr const * exprs) { m_occurrences.reset(); - // Find out how many non-ground appearences for each uninterpreted function there are + // Find out how many non-ground appearances for each uninterpreted function there are for ( unsigned i = 0 ; i < n ; i++ ) find_occurrences(exprs[i].get_fml()); diff --git a/src/ast/pattern/pattern_inference.cpp b/src/ast/pattern/pattern_inference.cpp index f6c8788d0..cf3c8bc31 100644 --- a/src/ast/pattern/pattern_inference.cpp +++ b/src/ast/pattern/pattern_inference.cpp @@ -687,7 +687,7 @@ bool pattern_inference_cfg::reduce_quantifier( mk_patterns(result2->get_num_decls(), result2->get_expr(), 0, nullptr, new_patterns); if (!new_patterns.empty()) { if (m_params.m_pi_warnings) { - warning_msg("pulled nested quantifier to be able to find an useable pattern (quantifier id: %s)", q->get_qid().str().c_str()); + warning_msg("pulled nested quantifier to be able to find an usable pattern (quantifier id: %s)", q->get_qid().str().c_str()); } new_q = m.update_quantifier(result2, new_patterns.size(), (expr**) new_patterns.c_ptr(), result2->get_expr()); if (m.proofs_enabled()) { diff --git a/src/ast/rewriter/bv_rewriter.cpp b/src/ast/rewriter/bv_rewriter.cpp index c81c7385a..81226b010 100644 --- a/src/ast/rewriter/bv_rewriter.cpp +++ b/src/ast/rewriter/bv_rewriter.cpp @@ -2679,7 +2679,7 @@ br_status bv_rewriter::mk_ite_core(expr * c, expr * t, expr * e, expr_ref & resu } const unsigned sz = m_util.get_bv_size(rhs); - if (sz == 1) { // detect (lhs = N) ? C : D, where N, C, D are 1 bit numberals + if (sz == 1) { // detect (lhs = N) ? C : D, where N, C, D are 1 bit numerals numeral rhs_n, e_n, t_n; unsigned rhs_sz, e_sz, t_sz; if (is_numeral(rhs, rhs_n, rhs_sz) diff --git a/src/ast/rewriter/datatype_rewriter.cpp b/src/ast/rewriter/datatype_rewriter.cpp index 194668b9c..4d688e682 100644 --- a/src/ast/rewriter/datatype_rewriter.cpp +++ b/src/ast/rewriter/datatype_rewriter.cpp @@ -124,7 +124,7 @@ br_status datatype_rewriter::mk_eq_core(expr * lhs, expr * rhs, expr_ref & resul // (= (+ c5 a5) b5) <<< NOT SIMPLIFIED WITH RESPECT TO ARITHMETIC // (= (cons a6 nil) (cons b6 nil))) <<< NOT SIMPLIFIED WITH RESPECT TO DATATYPE theory // - // Note that asserted_formulas::reduce() applied the simplier many times. + // Note that asserted_formulas::reduce() applied the simplifier many times. // After the first simplification step we had: // (= a1 b1) // (= (cons a2 (cons a3 (cons (+ a4 1) (cons (+ a5 c5) (cons a6 nil)))))) diff --git a/src/ast/rewriter/der.h b/src/ast/rewriter/der.h index 47e57c4fb..4dcf1e537 100644 --- a/src/ast/rewriter/der.h +++ b/src/ast/rewriter/der.h @@ -108,7 +108,7 @@ Revision History: apply var_subst using m_map to this child, and store the result in a new children array Create a new OR (new body of the quantifier) using the new children Then, we create a new quantifier using this new body, and use the function elim_unused_vars to - eliminate the ununsed variables. + eliminate the unused variables. Remark: let us implement the new version inside the class der. Use #if 0 ... #endif to comment the old version. diff --git a/src/ast/rewriter/push_app_ite.h b/src/ast/rewriter/push_app_ite.h index 8f737ea4d..a04cb6fbc 100644 --- a/src/ast/rewriter/push_app_ite.h +++ b/src/ast/rewriter/push_app_ite.h @@ -41,7 +41,7 @@ struct push_app_ite_cfg : public default_rewriter_cfg { \brief Variation of push_app_ite that applies the transformation on nonground terms only. \remark This functor uses the app::is_ground method. This method is not - completly precise, for instance, any term containing a quantifier is marked as non ground. + completely precise, for instance, any term containing a quantifier is marked as non ground. */ class ng_push_app_ite_cfg : public push_app_ite_cfg { protected: diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index cf0fd5111..a89e76edb 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -85,7 +85,7 @@ ATOMIC_CMD(get_user_tactics_cmd, "get-user-tactics", "display tactics defined us void help_tactic(cmd_context & ctx) { std::ostringstream buf; buf << "combinators:\n"; - buf << "- (and-then +) executes the given tactics sequencially.\n"; + buf << "- (and-then +) executes the given tactics sequentially.\n"; buf << "- (or-else +) tries the given tactics in sequence until one of them succeeds (i.e., the first that doesn't fail).\n"; buf << "- (par-or +) executes the given tactics in parallel until one of them succeeds (i.e., the first that doesn't fail).\n"; buf << "- (par-then ) executes tactic1 and then tactic2 to every subgoal produced by tactic1. All subgoals are processed in parallel.\n"; diff --git a/src/math/euclid/euclidean_solver.cpp b/src/math/euclid/euclidean_solver.cpp index 70b424375..4b65ab6ea 100644 --- a/src/math/euclid/euclidean_solver.cpp +++ b/src/math/euclid/euclidean_solver.cpp @@ -690,7 +690,7 @@ struct euclidean_solver::imp { m().del(eq.m_as[j]); eq.m_as.shrink(new_sz); eq.m_xs.shrink(new_sz); - // ajust c + // adjust c mpz new_c; decompose(m_next_pos_a, m_next_a, eq.m_c, new_c, eq.m_c); // create auxiliary equation diff --git a/src/math/polynomial/algebraic_numbers.cpp b/src/math/polynomial/algebraic_numbers.cpp index 528c10537..17360f35b 100644 --- a/src/math/polynomial/algebraic_numbers.cpp +++ b/src/math/polynomial/algebraic_numbers.cpp @@ -948,7 +948,7 @@ namespace algebraic_numbers { // zero is a root of p, and r_i is an isolating interval containing zero, // then c is zero reset(c); - TRACE("algebraic", tout << "reseting\nresult: "; display_root(tout, c); tout << "\n";); + TRACE("algebraic", tout << "resetting\nresult: "; display_root(tout, c); tout << "\n";); return; } int zV = upm().sign_variations_at_zero(seq); @@ -1728,7 +1728,7 @@ namespace algebraic_numbers { COMPARE_INTERVAL(); // if cell_a and cell_b, contain the same polynomial, - // and the intervals are overlaping, then they are + // and the intervals are overlapping, then they are // the same root. if (compare_p(cell_a, cell_b)) { m_compare_poly_eq++; @@ -1825,7 +1825,7 @@ namespace algebraic_numbers { // Here is an unexplored option for comparing numbers. // - // The isolating intervals of a and b are still overlaping + // The isolating intervals of a and b are still overlapping // Then we compute // r(x) = Resultant(x - y1 + y2, p1(y1), p2(y2)) // where p1(y1) and p2(y2) are the polynomials defining a and b. diff --git a/src/math/polynomial/polynomial.cpp b/src/math/polynomial/polynomial.cpp index 00a4d0593..aec901f61 100644 --- a/src/math/polynomial/polynomial.cpp +++ b/src/math/polynomial/polynomial.cpp @@ -4052,7 +4052,7 @@ namespace polynomial { // select a new random value in GF(p) that is not in vals, and store it in r void peek_fresh(scoped_numeral_vector const & vals, unsigned p, scoped_numeral & r) { - SASSERT(vals.size() < p); // otherwise we cant keep the fresh value + SASSERT(vals.size() < p); // otherwise we can't keep the fresh value unsigned sz = vals.size(); while (true) { m().set(r, rand() % p); @@ -4149,7 +4149,7 @@ namespace polynomial { TRACE("mgcd_detail", tout << "counter: " << counter << "\nidx: " << idx << "\nq: " << q << "\ndeg_q: " << deg_q << "\nmin_deg_q: " << min_deg_q << "\nnext_x: x" << vars[idx+1] << "\nmax_var(q): " << q_var << "\n";); if (deg_q < min_deg_q) { - TRACE("mgcd_detail", tout << "reseting...\n";); + TRACE("mgcd_detail", tout << "resetting...\n";); counter = 0; min_deg_q = deg_q; // start from scratch diff --git a/src/math/polynomial/polynomial.h b/src/math/polynomial/polynomial.h index 374a51084..169ee8273 100644 --- a/src/math/polynomial/polynomial.h +++ b/src/math/polynomial/polynomial.h @@ -131,12 +131,12 @@ namespace polynomial { ~factors(); /** - \brief Numer of distinct factors (not counting multiplicities). + \brief Number of distinct factors (not counting multiplicities). */ unsigned distinct_factors() const { return m_factors.size(); } /** - \brief Numer of distinct factors (counting multiplicities). + \brief Number of distinct factors (counting multiplicities). */ unsigned total_factors() const { return m_total_factors; } diff --git a/src/math/polynomial/upolynomial.cpp b/src/math/polynomial/upolynomial.cpp index cc2442981..39bdb6812 100644 --- a/src/math/polynomial/upolynomial.cpp +++ b/src/math/polynomial/upolynomial.cpp @@ -362,7 +362,7 @@ namespace upolynomial { set_size(sz-1, buffer); } - // Divide coeffients of p by their GCD + // Divide coefficients of p by their GCD void core_manager::normalize(unsigned sz, numeral * p) { if (sz == 0) return; @@ -395,7 +395,7 @@ namespace upolynomial { } } - // Divide coeffients of p by their GCD + // Divide coefficients of p by their GCD void core_manager::normalize(numeral_vector & p) { normalize(p.size(), p.c_ptr()); } @@ -568,7 +568,7 @@ namespace upolynomial { SASSERT(!is_alias(p1, buffer)); SASSERT(!is_alias(p2, buffer)); unsigned d; rem(sz1, p1, sz2, p2, d, buffer); - // We don't ned to flip the sign if d is odd and leading coefficient of p2 is negative + // We don't need to flip the sign if d is odd and leading coefficient of p2 is negative if (d % 2 == 0 || (sz2 > 0 && m().is_pos(p2[sz2-1]))) neg(buffer.size(), buffer.c_ptr()); } @@ -2005,7 +2005,7 @@ namespace upolynomial { continue; bool pos_a_n_k = m().is_pos(a_n_k); if (pos_a_n_k == pos_a_n) - continue; // must have oposite signs + continue; // must have opposite signs unsigned log2_a_n_k = pos_a_n_k ? m().log2(a_n_k) : m().mlog2(a_n_k); if (log2_a_n > log2_a_n_k) continue; @@ -2103,7 +2103,7 @@ namespace upolynomial { frame_stack.pop_back(); } - // Auxiliar method for isolating the roots of p in the interval (0, 1). + // Auxiliary method for isolating the roots of p in the interval (0, 1). // The basic idea is to split the interval in: (0, 1/2) and (1/2, 1). // This is accomplished by analyzing the roots in the interval (0, 1) of the following polynomials. // p1(x) := 2^n * p(x/2) where n = sz-1 @@ -2574,10 +2574,10 @@ namespace upolynomial { We say an interval (a, b) of a polynomial p is ISOLATING if p has only one root in the interval (a, b). - We say an isolating interval (a, b) of a square free polynomial p is REFINEABLE if + We say an isolating interval (a, b) of a square free polynomial p is REFINABLE if sign(p(a)) = -sign(p(b)) - Not every isolating interval (a, b) of a square free polynomial p is refineable, because + Not every isolating interval (a, b) of a square free polynomial p is refinable, because sign(p(a)) or sign(p(b)) may be zero. Refinable intervals of square free polynomials are useful, because we can increase precision diff --git a/src/math/polynomial/upolynomial.h b/src/math/polynomial/upolynomial.h index 439b4be9f..ad6942ffb 100644 --- a/src/math/polynomial/upolynomial.h +++ b/src/math/polynomial/upolynomial.h @@ -256,12 +256,12 @@ namespace upolynomial { void derivative(numeral_vector const & p, numeral_vector & d_p) { derivative(p.size(), p.c_ptr(), d_p); } /** - \brief Divide coeffients of p by their GCD + \brief Divide coefficients of p by their GCD */ void normalize(unsigned sz, numeral * p); /** - \brief Divide coeffients of p by their GCD + \brief Divide coefficients of p by their GCD */ void normalize(numeral_vector & p); diff --git a/src/math/polynomial/upolynomial_factorization_int.h b/src/math/polynomial/upolynomial_factorization_int.h index e422c15a6..10bfb4d8b 100644 --- a/src/math/polynomial/upolynomial_factorization_int.h +++ b/src/math/polynomial/upolynomial_factorization_int.h @@ -195,7 +195,7 @@ namespace upolynomial { // the index we are currently trying to fix int current_i = m_current_size - 1; - // the value we found as plausable (-1 we didn't find anything) + // the value we found as plausible (-1 we didn't find anything) int current_value = -1; if (remove_current) { diff --git a/src/math/realclosure/mpz_matrix.h b/src/math/realclosure/mpz_matrix.h index 92716ec0d..99ff8bce4 100644 --- a/src/math/realclosure/mpz_matrix.h +++ b/src/math/realclosure/mpz_matrix.h @@ -107,7 +107,7 @@ public: this method will give preference to the row that occurs first. \remark The vector r must have at least A.n() capacity - The numer of linear independent rows is returned. + The number of linear independent rows is returned. Store the new matrix in B. */ diff --git a/src/math/realclosure/rcf_params.pyg b/src/math/realclosure/rcf_params.pyg index 36c13035b..fc15dbe93 100644 --- a/src/math/realclosure/rcf_params.pyg +++ b/src/math/realclosure/rcf_params.pyg @@ -6,5 +6,5 @@ def_module_params('rcf', ('initial_precision', UINT, 24, "a value k that is the initial interval size (as 1/2^k) when creating transcendentals and approximated division"), ('inf_precision', UINT, 24, "a value k that is the initial interval size (i.e., (0, 1/2^l)) used as an approximation for infinitesimal values"), ('max_precision', UINT, 128, "during sign determination we switch from interval arithmetic to complete methods when the interval size is less than 1/2^k, where k is the max_precision"), - ('lazy_algebraic_normalization', BOOL, True, "during sturm-seq and square-free polynomial computations, only normalize algebraic polynomial expressions when the definining polynomial is monic") + ('lazy_algebraic_normalization', BOOL, True, "during sturm-seq and square-free polynomial computations, only normalize algebraic polynomial expressions when the defining polynomial is monic") )) diff --git a/src/math/realclosure/realclosure.cpp b/src/math/realclosure/realclosure.cpp index d41937c29..77623a2df 100644 --- a/src/math/realclosure/realclosure.cpp +++ b/src/math/realclosure/realclosure.cpp @@ -4790,7 +4790,7 @@ namespace realclosure { /** \brief Determine the sign of the new rational function value. - The idea is to keep refinining the interval until interval of v does not contain 0. + The idea is to keep refining the interval until interval of v does not contain 0. After a couple of steps we switch to expensive sign determination procedure. Return false if v is actually zero. @@ -5474,7 +5474,7 @@ namespace realclosure { } else { // Let sdt be alpha->sdt(); - // In pricipal, the signs of the polynomials sdt->qs can be used + // In principal, the signs of the polynomials sdt->qs can be used // to discriminate the roots of new_p. The signs of this polynomials // depend only on alpha, and not on the polynomial used to define alpha // So, in principle, we can reuse m_qs and m_sign_conditions. diff --git a/src/math/simplex/network_flow.h b/src/math/simplex/network_flow.h index d4c7df77f..f4147b16f 100644 --- a/src/math/simplex/network_flow.h +++ b/src/math/simplex/network_flow.h @@ -148,7 +148,7 @@ namespace smt { vector m_potentials; // nodes + 1 |-> initial: +/- 1 // Duals of flows which are convenient to compute dual solutions // become solutions to Dual simplex. - vector m_flows; // edges + nodes |-> assignemnt Basic feasible flows + vector m_flows; // edges + nodes |-> assignment Basic feasible flows svector m_states; unsigned m_step; edge_id m_enter_id; diff --git a/src/math/subpaving/subpaving_t.h b/src/math/subpaving/subpaving_t.h index 02c538828..ec514df8f 100644 --- a/src/math/subpaving/subpaving_t.h +++ b/src/math/subpaving/subpaving_t.h @@ -202,7 +202,7 @@ public: public: node(context_t & s, unsigned id); node(node * parent, unsigned id); - // return unique indentifier. + // return unique identifier. unsigned id() const { return m_id; } bound_array_manager & bm() const { return m_bm; } bound_array & lowers() { return m_lowers; } diff --git a/src/math/subpaving/subpaving_t_def.h b/src/math/subpaving/subpaving_t_def.h index cf93fbfad..b13f41c54 100644 --- a/src/math/subpaving/subpaving_t_def.h +++ b/src/math/subpaving/subpaving_t_def.h @@ -248,7 +248,7 @@ public: /** - \brief Auxiliary static method used to diplay a bound specified by (x, k, lower, open). + \brief Auxiliary static method used to display a bound specified by (x, k, lower, open). */ template void context_t::display(std::ostream & out, numeral_manager & nm, display_var_proc const & proc, var x, numeral & k, bool lower, bool open) { diff --git a/src/model/model.cpp b/src/model/model.cpp index a1fdfc980..60441054c 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -312,7 +312,8 @@ void model::collect_occs(top_sort& ts, func_decl* f) { func_interp* fi = get_func_interp(f); if (fi) { e = fi->get_else(); - collect_occs(ts, e); + if (e != nullptr) + collect_occs(ts, e); } } } diff --git a/src/muz/base/dl_context.h b/src/muz/base/dl_context.h index 23926c3d1..a14ef163f 100644 --- a/src/muz/base/dl_context.h +++ b/src/muz/base/dl_context.h @@ -615,7 +615,7 @@ namespace datalog { void ensure_engine(); - // auxilary functions for SMT2 pretty-printer. + // auxiliary functions for SMT2 pretty-printer. void declare_vars(expr_ref_vector& rules, mk_fresh_name& mk_fresh, std::ostream& out); //undefined and private copy constructor and operator= diff --git a/src/muz/base/dl_rule.h b/src/muz/base/dl_rule.h index 7e85199cf..45b75c254 100644 --- a/src/muz/base/dl_rule.h +++ b/src/muz/base/dl_rule.h @@ -110,7 +110,7 @@ namespace datalog { /** \brief Manager for the \c rule class - \remark \c rule_manager objects are interchangable as long as they + \remark \c rule_manager objects are interchangeable as long as they contain the same \c ast_manager object. */ class rule_manager diff --git a/src/muz/base/dl_util.h b/src/muz/base/dl_util.h index c6e214f79..7e38b9e9f 100644 --- a/src/muz/base/dl_util.h +++ b/src/muz/base/dl_util.h @@ -97,7 +97,7 @@ namespace datalog { \brief Auxiliary function used to create a tail based on \c pred for a new rule. The variables in \c pred are re-assigned using \c next_idx and \c varidx2var. A variable is considered non-local to the rule if it is in the set \c non_local_vars. - Non-local variables are coppied to new_rule_args, and their sorts to \c new_rule_domain. + Non-local variables are copied to new_rule_args, and their sorts to \c new_rule_domain. The new predicate is stored in \c new_pred. */ void mk_new_rule_tail(ast_manager & m, app * pred, diff --git a/src/muz/base/fp_params.pyg b/src/muz/base/fp_params.pyg index 18eb85662..325ecaaa6 100644 --- a/src/muz/base/fp_params.pyg +++ b/src/muz/base/fp_params.pyg @@ -143,8 +143,8 @@ def_module_params('fp', ('spacer.native_mbp', BOOL, True, "Use native mbp of Z3"), ('spacer.eq_prop', BOOL, True, "Enable equality and bound propagation in arithmetic"), ('spacer.weak_abs', BOOL, True, "Weak abstraction"), - ('spacer.restarts', BOOL, False, "Enable reseting obligation queue"), - ('spacer.restart_initial_threshold', UINT, 10, "Intial threshold for restarts"), + ('spacer.restarts', BOOL, False, "Enable resetting obligation queue"), + ('spacer.restart_initial_threshold', UINT, 10, "Initial threshold for restarts"), ('spacer.random_seed', UINT, 0, "Random seed to be used by SMT solver"), ('spacer.mbqi', BOOL, True, 'Enable mbqi'), diff --git a/src/muz/base/hnf.h b/src/muz/base/hnf.h index 330dfab70..70f803975 100644 --- a/src/muz/base/hnf.h +++ b/src/muz/base/hnf.h @@ -11,7 +11,7 @@ Copyright (c) 2015 Microsoft Corporation Abstract: - Horn normal form convertion. + Horn normal form conversion. Author: diff --git a/src/muz/ddnf/ddnf.cpp b/src/muz/ddnf/ddnf.cpp index a4fe5f0fa..d3460738c 100644 --- a/src/muz/ddnf/ddnf.cpp +++ b/src/muz/ddnf/ddnf.cpp @@ -332,7 +332,7 @@ namespace datalog { void internalize() { - // populate maps (should be bit-sets) of decendants. + // populate maps (should be bit-sets) of descendants. if (m_internalized) { return; } diff --git a/src/muz/fp/datalog_parser.cpp b/src/muz/fp/datalog_parser.cpp index a23d654b0..1cc85e6cd 100644 --- a/src/muz/fp/datalog_parser.cpp +++ b/src/muz/fp/datalog_parser.cpp @@ -120,7 +120,7 @@ public: This operation invalidates the line previously retrieved. - This operatio can be called only if we are not at the end of file. + This operation can be called only if we are not at the end of file. User is free to modify the content of the returned array until the terminating NULL character. */ @@ -876,7 +876,7 @@ protected: /** \brief Parse predicate arguments. If \c f==0, they are arguments of a predicate declaration. - If parsing a declaration, argumens names are pushed to the \c arg_names vector. + If parsing a declaration, argument names are pushed to the \c arg_names vector. */ dtoken parse_args(dtoken tok, func_decl* f, expr_ref_vector& args, svector & arg_names) { if (tok != TK_LP) { diff --git a/src/muz/rel/dl_base.h b/src/muz/rel/dl_base.h index 4d202f2a2..decf499a2 100644 --- a/src/muz/rel/dl_base.h +++ b/src/muz/rel/dl_base.h @@ -295,7 +295,7 @@ namespace datalog { Precondition: &orig.get_plugin()==this */ virtual base_object * mk_empty(const signature & s, family_id kind) { - SASSERT(kind==get_kind()); //if plugin uses multiple kinds, this function needs to be overriden + SASSERT(kind==get_kind()); //if plugin uses multiple kinds, this function needs to be overridden return mk_empty(s); } diff --git a/src/muz/rel/dl_finite_product_relation.cpp b/src/muz/rel/dl_finite_product_relation.cpp index fb80a2105..0b1fbc840 100644 --- a/src/muz/rel/dl_finite_product_relation.cpp +++ b/src/muz/rel/dl_finite_product_relation.cpp @@ -1319,7 +1319,7 @@ namespace datalog { if(!m_table_cond_columns.empty()) { //We will keep the table variables that appear in the condition together - //with the index column and then iterate throught the tuples, evaluating + //with the index column and then iterate through the tuples, evaluating //the rest of the condition on the inner relations. unsigned_vector removed_cols; unsigned table_data_col_cnt = r.m_table_sig.size()-1; diff --git a/src/muz/rel/dl_instruction.cpp b/src/muz/rel/dl_instruction.cpp index f7d1665d2..2b76d99f7 100644 --- a/src/muz/rel/dl_instruction.cpp +++ b/src/muz/rel/dl_instruction.cpp @@ -640,7 +640,7 @@ namespace datalog { reg_idx m_src; reg_idx m_tgt; reg_idx m_delta; - bool m_widen; //if true, widening is performed intead of an union + bool m_widen; //if true, widening is performed instead of an union public: instr_union(reg_idx src, reg_idx tgt, reg_idx delta, bool widen) : m_src(src), m_tgt(tgt), m_delta(delta), m_widen(widen) {} diff --git a/src/muz/rel/dl_relation_manager.h b/src/muz/rel/dl_relation_manager.h index bd7b9ae8c..5fb468ef5 100644 --- a/src/muz/rel/dl_relation_manager.h +++ b/src/muz/rel/dl_relation_manager.h @@ -253,7 +253,7 @@ namespace datalog { \brief Return functor that transforms a table into one that lacks columns listed in \c removed_cols array. - The \c removed_cols cotains columns of table \c t in strictly ascending order. + The \c removed_cols contains columns of table \c t in strictly ascending order. */ relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, const unsigned * removed_cols); @@ -420,7 +420,7 @@ namespace datalog { \brief Return functor that transforms a table into one that lacks columns listed in \c removed_cols array. - The \c removed_cols cotains columns of table \c t in strictly ascending order. + The \c removed_cols contains columns of table \c t in strictly ascending order. If a project operation removes a non-functional column, all functional columns become non-functional (so that none of the values in functional columns are lost) diff --git a/src/muz/rel/dl_sparse_table.cpp b/src/muz/rel/dl_sparse_table.cpp index bb48211c7..a51fbf3b1 100644 --- a/src/muz/rel/dl_sparse_table.cpp +++ b/src/muz/rel/dl_sparse_table.cpp @@ -568,7 +568,7 @@ namespace datalog { } /** - In this function we modify the content of table functional columns without reseting indexes. + In this function we modify the content of table functional columns without resetting indexes. This is ok as long as we do not allow indexing on functional columns. */ void sparse_table::ensure_fact(const table_fact & f) { diff --git a/src/muz/rel/rel_context.h b/src/muz/rel/rel_context.h index 0a31c4e9f..dbcc42248 100644 --- a/src/muz/rel/rel_context.h +++ b/src/muz/rel/rel_context.h @@ -85,7 +85,7 @@ namespace datalog { /** \brief Restrict the set of used predicates to \c res. - The function deallocates unsused relations, it does not deal with rules. + The function deallocates unused relations, it does not deal with rules. */ void restrict_predicates(func_decl_set const& predicates) override; diff --git a/src/muz/spacer/spacer_farkas_learner.cpp b/src/muz/spacer/spacer_farkas_learner.cpp index 291226b55..b8d8324fb 100644 --- a/src/muz/spacer/spacer_farkas_learner.cpp +++ b/src/muz/spacer/spacer_farkas_learner.cpp @@ -7,8 +7,8 @@ Module Name: Abstract: - Proviced abstract interface and some inplementations of algorithms - for strenghtning lemmas + Provides abstract interface and some implementations of algorithms + for strenghtening lemmas Author: @@ -161,7 +161,7 @@ bool farkas_learner::is_pure_expr(func_decl_set const& symbs, expr* e, ast_manag in a clausal version. NB: the routine is not interpolating, though an interpolating variant would - be preferrable because then we can also use it for model propagation. + be preferable because then we can also use it for model propagation. We collect the unit derivable nodes from bs. These are the weakenings of bs, besides the diff --git a/src/muz/spacer/spacer_quant_generalizer.cpp b/src/muz/spacer/spacer_quant_generalizer.cpp index f3307a596..63b204736 100644 --- a/src/muz/spacer/spacer_quant_generalizer.cpp +++ b/src/muz/spacer/spacer_quant_generalizer.cpp @@ -186,7 +186,7 @@ void lemma_quantifier_generalizer::find_candidates(expr *e, std::sort(candidates.c_ptr(), candidates.c_ptr() + candidates.size(), index_lt_proc(m)); - // keep actual select indecies in the order found at the back of + // keep actual select indices in the order found at the back of // candidate list. There is no particular reason for this order candidates.append(extra); } @@ -199,24 +199,24 @@ bool lemma_quantifier_generalizer::match_sk_idx(expr *e, app_ref_vector const &z contains_app has_zk(m, zks.get(0)); if (!contains_selects(e, m)) return false; - app_ref_vector indicies(m); - get_select_indices(e, indicies); - if (indicies.size() > 2) return false; + app_ref_vector indices(m); + get_select_indices(e, indices); + if (indices.size() > 2) return false; unsigned i=0; - if (indicies.size() == 1) { - if (!has_zk(indicies.get(0))) return false; + if (indices.size() == 1) { + if (!has_zk(indices.get(0))) return false; } else { - if (has_zk(indicies.get(0)) && !has_zk(indicies.get(1))) + if (has_zk(indices.get(0)) && !has_zk(indices.get(1))) i = 0; - else if (!has_zk(indicies.get(0)) && has_zk(indicies.get(1))) + else if (!has_zk(indices.get(0)) && has_zk(indices.get(1))) i = 1; - else if (!has_zk(indicies.get(0)) && !has_zk(indicies.get(1))) + else if (!has_zk(indices.get(0)) && !has_zk(indices.get(1))) return false; } - idx = indicies.get(i); + idx = indices.get(i); sk = zks.get(0); return true; } diff --git a/src/muz/spacer/spacer_unsat_core_plugin.cpp b/src/muz/spacer/spacer_unsat_core_plugin.cpp index aeb509c2e..77e88fb32 100644 --- a/src/muz/spacer/spacer_unsat_core_plugin.cpp +++ b/src/muz/spacer/spacer_unsat_core_plugin.cpp @@ -124,7 +124,7 @@ namespace spacer { * We can rewrite (E2) to rewrite (E1) to * (BP*Fark(BP)) => (neg(A*Fark(A) + BNP*Fark(BNP) + (neg D)*Fark(D))) (E3) * and since we can derive (A*Fark(A) + BNP*Fark(BNP) + (neg D)*Fark(D)) from - * A, BNP and D, we also know that it is inconsisent. Therefore + * A, BNP and D, we also know that it is inconsistent. Therefore * neg(A*Fark(A) + BNP*Fark(BNP) + (neg D)*Fark(D)) is a solution. * * Finally we also need the following workaround: diff --git a/src/muz/tab/tab_context.cpp b/src/muz/tab/tab_context.cpp index b5be996dc..3b8fd2ee0 100644 --- a/src/muz/tab/tab_context.cpp +++ b/src/muz/tab/tab_context.cpp @@ -1097,7 +1097,7 @@ namespace tb { m_S1.apply(2, delta, expr_offset(src.get_constraint(), 1), tmp2); constraint = m.mk_and(tmp, tmp2); - // perform trival quantifier-elimination: + // perform trivial quantifier-elimination: uint_set index_set; expr_free_vars fv; fv(head); diff --git a/src/muz/transforms/dl_mk_quantifier_instantiation.cpp b/src/muz/transforms/dl_mk_quantifier_instantiation.cpp index 058d9dca8..0a183b923 100644 --- a/src/muz/transforms/dl_mk_quantifier_instantiation.cpp +++ b/src/muz/transforms/dl_mk_quantifier_instantiation.cpp @@ -280,7 +280,7 @@ namespace datalog { } } - // model convertion: identity function. + // model conversion: identity function. if (instantiated) { result->inherit_predicates(source); diff --git a/src/muz/transforms/dl_mk_subsumption_checker.cpp b/src/muz/transforms/dl_mk_subsumption_checker.cpp index da41b4ba4..c970aedeb 100644 --- a/src/muz/transforms/dl_mk_subsumption_checker.cpp +++ b/src/muz/transforms/dl_mk_subsumption_checker.cpp @@ -45,7 +45,7 @@ namespace datalog { unsigned pt_len = r->get_positive_tail_size(); if(pt_len != r->get_uninterpreted_tail_size()) { - // we dont' expect rules with negative tails to be total + // we don't expect rules with negative tails to be total return false; } @@ -97,7 +97,7 @@ namespace datalog { void mk_subsumption_checker::scan_for_total_rules(const rule_set & rules) { bool new_discovered; //we cycle through the rules until we keep discovering new total relations - //(discovering a total relation migh reveal other total relations) + //(discovering a total relation might reveal other total relations) do { new_discovered = false; rule_set::iterator rend = rules.end(); diff --git a/src/nlsat/nlsat_evaluator.cpp b/src/nlsat/nlsat_evaluator.cpp index a93c4fb3e..e04b95a40 100644 --- a/src/nlsat/nlsat_evaluator.cpp +++ b/src/nlsat/nlsat_evaluator.cpp @@ -377,7 +377,7 @@ namespace nlsat { } /** - \brief Return the sign of the polynomial in the current interpration. + \brief Return the sign of the polynomial in the current interpretation. \pre All variables of p are assigned in the current interpretation. */ @@ -469,7 +469,7 @@ namespace nlsat { } } - // Evalute the sign of p1^e1*...*pn^en (of atom a) in cell c of table t. + // Evaluate the sign of p1^e1*...*pn^en (of atom a) in cell c of table t. int sign_at(ineq_atom * a, sign_table const & t, unsigned c) const { int sign = 1; unsigned num_ps = a->size(); @@ -556,7 +556,7 @@ namespace nlsat { result = m_ism.mk(true, true, dummy, true, true, dummy, jst); } else { - // save -oo as begining of infeasible interval + // save -oo as beginning of infeasible interval prev_open = true; prev_inf = true; prev_root_id = UINT_MAX; diff --git a/src/parsers/smt2/smt2parser.cpp b/src/parsers/smt2/smt2parser.cpp index 58b16717d..0662cacb5 100644 --- a/src/parsers/smt2/smt2parser.cpp +++ b/src/parsers/smt2/smt2parser.cpp @@ -1987,7 +1987,7 @@ namespace smt2 { if (expr_stack().size() == fr->m_expr_spos) { if (!ignore_bad_patterns()) throw parser_exception("invalid empty pattern"); - // ingoring empty pattern + // ignoring empty pattern expr_stack().shrink(fr->m_expr_spos); } else { @@ -2698,7 +2698,7 @@ namespace smt2 { next(); } unsigned spos = sort_stack().size(); - parse_sorts("Invalid function name. Expecting sort list startig with '(' to disambiguate function name"); + parse_sorts("Invalid function name. Expecting sort list starting with '(' to disambiguate function name"); unsigned domain_size = sort_stack().size() - spos; parse_sort("Invalid function name"); func_decl * d = m_ctx.find_func_decl(id, indices.size(), indices.c_ptr(), domain_size, sort_stack().c_ptr() + spos, sort_stack().back()); diff --git a/src/qe/qe_arith_plugin.cpp b/src/qe/qe_arith_plugin.cpp index f8c519285..a09c4046e 100644 --- a/src/qe/qe_arith_plugin.cpp +++ b/src/qe/qe_arith_plugin.cpp @@ -316,7 +316,7 @@ namespace qe { void mk_bound_aux(rational const& a, expr* t, rational const& b, expr* s, expr_ref& result) { SASSERT(a.is_neg() == b.is_neg()); expr_ref tt(t, m), ss(s, m), e(m); - // hack to fix wierd gcc compilation error + // hack to fix weird gcc compilation error rational abs_a(a); rational abs_b(b); if (abs_a.is_neg()) abs_a.neg(); diff --git a/src/qe/qe_datatype_plugin.cpp b/src/qe/qe_datatype_plugin.cpp index 81a402ba4..25332d164 100644 --- a/src/qe/qe_datatype_plugin.cpp +++ b/src/qe/qe_datatype_plugin.cpp @@ -46,7 +46,7 @@ Copyright (c) 2015 Microsoft Corporation // -> \/_i R_C(t_i) & phi[t_i/x] \/ phi[false, true] // // Justification: -// - We will asume that each of t_i, s_j are constructor terms. +// - We will assume that each of t_i, s_j are constructor terms. // - We can assume that x \notin t_i, x \notin s_j, or otherwise use simplification. // - We can assume that x occurs only in equalities or disequalities, or the recognizer, since // otherwise, we could simplify equalities, or QE does not apply. diff --git a/src/qe/qe_lite.cpp b/src/qe/qe_lite.cpp index d900bff5d..3226f7554 100644 --- a/src/qe/qe_lite.cpp +++ b/src/qe/qe_lite.cpp @@ -1816,7 +1816,7 @@ namespace fm { } // An integer variable x may be eliminated, if - // 1- All variables in the contraints it occur are integer. + // 1- All variables in the constraints it occur are integer. // 2- The coefficient of x in all lower bounds (or all upper bounds) is unit. bool can_eliminate(var x) const { if (!is_int(x)) diff --git a/src/qe/qe_mbi.h b/src/qe/qe_mbi.h index fdc4c3c6a..1cc2be0cb 100644 --- a/src/qe/qe_mbi.h +++ b/src/qe/qe_mbi.h @@ -47,7 +47,7 @@ namespace qe { /** * \brief Utility that works modulo a background state. * - vars - * variables to preferrably project onto (other variables would require quantification to fit interpolation signature) + * variables to preferably project onto (other variables would require quantification to fit interpolation signature) * - lits * set of literals to check satisfiability with respect to. * - mdl diff --git a/src/qe/qe_term_graph.cpp b/src/qe/qe_term_graph.cpp index 97b044f5b..b5de20368 100644 --- a/src/qe/qe_term_graph.cpp +++ b/src/qe/qe_term_graph.cpp @@ -669,7 +669,7 @@ namespace qe { // Here we could also walk equivalence classes that // contain interpreted values by sort and extract - // disequalities bewteen non-unique value + // disequalities between non-unique value // representatives. these disequalities are implied // and can be mined using other means, such as theory // aware core minimization diff --git a/src/sat/ba_solver.cpp b/src/sat/ba_solver.cpp index 4f06c2e98..01d627115 100644 --- a/src/sat/ba_solver.cpp +++ b/src/sat/ba_solver.cpp @@ -2519,7 +2519,7 @@ namespace sat { * ~lit does not occur in clauses * ~lit is only in one constraint use list * lit == C - * -> ignore assignemnts to ~lit for C + * -> ignore assignments to ~lit for C * * ~lit does not occur in clauses * lit is only in one constraint use list diff --git a/src/sat/sat_local_search.h b/src/sat/sat_local_search.h index 5fd69a740..baf072419 100644 --- a/src/sat/sat_local_search.h +++ b/src/sat/sat_local_search.h @@ -118,7 +118,7 @@ namespace sat { local_search_config m_config; // objective function: maximize - svector ob_constraint; // the objective function *constraint*, sorted in decending order + svector ob_constraint; // the objective function *constraint*, sorted in descending order // information about the variable int_vector coefficient_in_ob_constraint; // var! initialized to be 0 @@ -169,8 +169,8 @@ namespace sat { // unsat constraint stack bool m_is_unsat; - unsigned_vector m_unsat_stack; // store all the unsat constraits - unsigned_vector m_index_in_unsat_stack; // which position is a contraint in the unsat_stack + unsigned_vector m_unsat_stack; // store all the unsat constraints + unsigned_vector m_index_in_unsat_stack; // which position is a constraint in the unsat_stack // configuration changed decreasing variables (score>0 and conf_change==true) bool_var_vector m_goodvar_stack; diff --git a/src/sat/sat_lookahead.cpp b/src/sat/sat_lookahead.cpp index 72792b182..389cdb19b 100644 --- a/src/sat/sat_lookahead.cpp +++ b/src/sat/sat_lookahead.cpp @@ -1220,7 +1220,7 @@ namespace sat { double operator()(literal l) override { return lh.literal_occs(l); } }; - // Ternary clause managagement: + // Ternary clause management: void lookahead::add_ternary(literal u, literal v, literal w) { SASSERT(u != w && u != v && v != w && ~u != w && ~u != v && ~w != v); @@ -1377,7 +1377,7 @@ namespace sat { } - // new n-ary clause managment + // new n-ary clause management void lookahead::add_clause(clause const& c) { SASSERT(c.size() > 3); @@ -1636,7 +1636,7 @@ namespace sat { } // Sum_{ clause C that contains ~l } 1 - // FIXME: counts occurences of ~l; misleading + // FIXME: counts occurrences of ~l; misleading double lookahead::literal_occs(literal l) { double result = m_binary[l.index()].size(); result += literal_big_occs(l); @@ -1644,7 +1644,7 @@ namespace sat { } // Sum_{ clause C that contains ~l such that |C| > 2} 1 - // FIXME: counts occurences of ~l; misleading + // FIXME: counts occurrences of ~l; misleading double lookahead::literal_big_occs(literal l) { double result = m_nary_count[(~l).index()]; result += m_ternary_count[(~l).index()]; @@ -1718,7 +1718,7 @@ namespace sat { } // VERIFY(!missed_propagation()); if (unsat) { - TRACE("sat", tout << "backtracking and settting " << ~lit << "\n";); + TRACE("sat", tout << "backtracking and setting " << ~lit << "\n";); lookahead_backtrack(); assign(~lit); propagate(); diff --git a/src/sat/sat_lookahead.h b/src/sat/sat_lookahead.h index c2282e779..046750832 100644 --- a/src/sat/sat_lookahead.h +++ b/src/sat/sat_lookahead.h @@ -471,7 +471,7 @@ namespace sat { watch_list& get_wlist(literal l) { return m_watches[l.index()]; } watch_list const& get_wlist(literal l) const { return m_watches[l.index()]; } - // new clause managment: + // new clause management: void add_ternary(literal u, literal v, literal w); void propagate_ternary(literal l); lbool propagate_ternary(literal l1, literal l2); diff --git a/src/sat/sat_parallel.cpp b/src/sat/sat_parallel.cpp index c6e29f64c..33cb02a87 100644 --- a/src/sat/sat_parallel.cpp +++ b/src/sat/sat_parallel.cpp @@ -232,7 +232,7 @@ namespace sat { } if (m_consumer_ready && (m_num_clauses == 0 || (m_num_clauses > s.m_clauses.size()))) { // time to update local search with new clauses. - // there could be multiple local search engines runing at the same time. + // there could be multiple local search engines running at the same time. IF_VERBOSE(1, verbose_stream() << "(sat-parallel refresh :from " << m_num_clauses << " :to " << s.m_clauses.size() << ")\n";); m_solver_copy = alloc(solver, s.m_params, s.rlimit()); m_solver_copy->copy(s); diff --git a/src/sat/sat_simplifier.cpp b/src/sat/sat_simplifier.cpp index d19cd14d4..21d264af5 100644 --- a/src/sat/sat_simplifier.cpp +++ b/src/sat/sat_simplifier.cpp @@ -984,7 +984,7 @@ namespace sat { queue m_queue; literal_vector m_covered_clause; // covered clause - svector m_covered_antecedent; // explainations for literals in covered clause + svector m_covered_antecedent; // explanations for literals in covered clause literal_vector m_intersection; // current resolution intersection literal_vector m_tautology; // literals that are used in blocking tautology literal_vector m_new_intersection; diff --git a/src/sat/sat_simplifier.h b/src/sat/sat_simplifier.h index 3787b5894..990b87b10 100644 --- a/src/sat/sat_simplifier.h +++ b/src/sat/sat_simplifier.h @@ -74,7 +74,7 @@ namespace sat { // config bool m_abce; // block clauses using asymmetric added literals bool m_cce; // covered clause elimination - bool m_acce; // cce with asymetric literal addition + bool m_acce; // cce with asymmetric literal addition bool m_bca; // blocked (binary) clause addition. unsigned m_bce_delay; bool m_bce; // blocked clause elimination diff --git a/src/smt/arith_eq_solver.cpp b/src/smt/arith_eq_solver.cpp index 883255b8a..4b1c6e4a6 100644 --- a/src/smt/arith_eq_solver.cpp +++ b/src/smt/arith_eq_solver.cpp @@ -492,7 +492,7 @@ bool arith_eq_solver::solve_integer_equations_omega( return false; } else if (r[index].is_zero()) { - // Row is trival + // Row is trivial rows_solved.pop_back(); continue; } diff --git a/src/smt/params/qi_params.h b/src/smt/params/qi_params.h index 0f6c03f5b..d1434103b 100644 --- a/src/smt/params/qi_params.h +++ b/src/smt/params/qi_params.h @@ -64,14 +64,14 @@ struct qi_params { Enodes in the input problem have generation 0. Some combinations of m_qi_cost and m_qi_new_gen will prevent Z3 from breaking matching loops. - For example, the "Weight 0" peformace bug was triggered by the following combination: + For example, the "Weight 0" performance bug was triggered by the following combination: - m_qi_cost: (+ weight generation) - m_qi_new_gen: cost If a quantifier has weight 0, then the cost of instantiating it with a term in the input problem has cost 0. The new enodes created during the instantiation will be tagged with generation = const = 0. So, every enode will have generation 0, and consequently every quantifier instantiation will have cost 0. - Although dangerous, this feature was requested by the Boogie team. In their case, the patterns are carefully constructred, + Although dangerous, this feature was requested by the Boogie team. In their case, the patterns are carefully constructed, and there are no matching loops. Moreover, the tag some quantifiers with weight 0 to instruct Z3 to never block their instances. An example is the select-store axiom. They need this feature to be able to analyze code that contains very long execution paths. diff --git a/src/smt/params/smt_params_helper.pyg b/src/smt/params/smt_params_helper.pyg index 76e9f03b1..b8b561e37 100644 --- a/src/smt/params/smt_params_helper.pyg +++ b/src/smt/params/smt_params_helper.pyg @@ -12,7 +12,7 @@ def_module_params(module_name='smt', ('ematching', BOOL, True, 'E-Matching based quantifier instantiation'), ('phase_selection', UINT, 3, 'phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences'), ('restart_strategy', UINT, 1, '0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic'), - ('restart_factor', DOUBLE, 1.1, 'when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold'), + ('restart_factor', DOUBLE, 1.1, 'when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the current restart threshold'), ('case_split', UINT, 1, '0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal, 6 - activity-based case split with theory-aware branching activity'), ('delay_units', BOOL, False, 'if true then z3 will not restart when a unit clause is learned'), ('delay_units_threshold', UINT, 32, 'maximum number of learned unit clauses before restarting, ignored if delay_units is false'), diff --git a/src/smt/qi_queue.cpp b/src/smt/qi_queue.cpp index 94868ef6e..d621a9f50 100644 --- a/src/smt/qi_queue.cpp +++ b/src/smt/qi_queue.cpp @@ -175,7 +175,7 @@ namespace smt { } } m_new_entries.reset(); - TRACE("new_entries_bug", tout << "[qi:instatiate]\n";); + TRACE("new_entries_bug", tout << "[qi:instantiate]\n";); } void qi_queue::display_instance_profile(fingerprint * f, quantifier * q, unsigned num_bindings, enode * const * bindings, unsigned proof_id, unsigned generation) { diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index f7bc60051..93c172bf1 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -51,7 +51,7 @@ namespace smt { } /** - \brief Mark all enodes in a 'proof' tree brach starting at n + \brief Mark all enodes in a 'proof' tree branch starting at n n -> ... -> root */ template diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index f275b0ebf..17a7ce3a3 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -518,7 +518,7 @@ namespace smt { // 2. r1 is interpreted but r2 is not. // // The second condition is used to enforce the invariant that if a class contain - // an interepreted enode then the root is also interpreted. + // an interpreted enode then the root is also interpreted. if ((r1->get_class_size() > r2->get_class_size() && !r2->is_interpreted()) || r1->is_interpreted()) { SASSERT(!r2->is_interpreted()); std::swap(n1, n2); @@ -529,7 +529,7 @@ namespace smt { " n1: #" << n1->get_owner_id() << "\n";); // It is necessary to propagate relevancy to other elements of - // the equivalence class. This is nessary to enforce the invariant + // the equivalence class. This is necessary to enforce the invariant // in the field m_parent of the enode class. if (is_relevant(r1)) { // && !m_manager.is_eq(r1->get_owner())) !is_eq HACK // NOTE for !is_eq HACK... the !is_eq HACK does not propagate relevancy when two @@ -4067,7 +4067,7 @@ namespace smt { A literal may have been marked relevant within the scope that gets popped during conflict resolution. In this case, the literal is no longer marked as relevant after the pop. This can cause quantifier instantiation to miss relevant triggers and thereby - cause incmpleteness. + cause incompleteness. */ void context::record_relevancy(unsigned n, literal const* lits) { m_relevant_conflict_literals.reset(); @@ -4281,7 +4281,7 @@ namespace smt { return true; } - // the variabe is shared if the equivalence class of n + // the variable is shared if the equivalence class of n // contains a parent application. theory_var_list * l = n->get_th_var_list(); diff --git a/src/smt/smt_enode.h b/src/smt/smt_enode.h index 61fed786b..74fcbfb45 100644 --- a/src/smt/smt_enode.h +++ b/src/smt/smt_enode.h @@ -73,7 +73,7 @@ namespace smt { class tmp_enode; /** - \brief Aditional data-structure for implementing congruence closure, + \brief Additional data-structure for implementing congruence closure, equality propagation, and the theory central bus of equalities. */ class enode { diff --git a/src/smt/smt_model_generator.h b/src/smt/smt_model_generator.h index 1f69eb324..a26113a16 100644 --- a/src/smt/smt_model_generator.h +++ b/src/smt/smt_model_generator.h @@ -96,7 +96,7 @@ namespace smt { class model_value_dependency { bool m_fresh; //!< True if the dependency is a new fresh value; union { - enode * m_enode; //!< When m_fresh == false, contains an enode depedency. + enode * m_enode; //!< When m_fresh == false, contains an enode dependency. extra_fresh_value * m_value; //!< When m_fresh == true, contains the sort of the fresh value }; public: diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index 9e38fef69..6dcc9448c 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -203,7 +203,7 @@ namespace smt { static void check_no_arithmetic(static_features const & st, char const * logic) { if (st.m_num_arith_ineqs > 0 || st.m_num_arith_terms > 0 || st.m_num_arith_eqs > 0) - throw default_exception("Benchmark constains arithmetic, but specified loging does not support it."); + throw default_exception("Benchmark constains arithmetic, but specified logic does not support it."); } void setup::setup_QF_UF() { @@ -519,7 +519,7 @@ namespace smt { m_params.m_arith_eq2ineq = true; m_params.m_eliminate_term_ite = true; // if (st.m_num_exprs < 5000 && st.m_num_ite_terms < 50) { // safeguard to avoid high memory consumption - // TODO: implement analsysis function to decide where lift ite is too expensive. + // TODO: implement analysis function to decide where lift ite is too expensive. // m_params.m_lift_ite = LI_FULL; // } } diff --git a/src/smt/smt_theory.h b/src/smt/smt_theory.h index b791d890e..f65ffe922 100644 --- a/src/smt/smt_theory.h +++ b/src/smt/smt_theory.h @@ -68,7 +68,7 @@ namespace smt { public: /** - \brief Return ture if the given enode is attached to a + \brief Return true if the given enode is attached to a variable of the theory. \remark The result is not equivalent to @@ -389,7 +389,7 @@ namespace smt { \brief When an eq atom n is created during the search, the default behavior is to make sure that the n->get_arg(0)->get_id() < n->get_arg(1)->get_id(). This may create some redundant atoms, since some theories/families use different - convetions in their simplifiers. For example, arithmetic always force a numeral + conventions in their simplifiers. For example, arithmetic always force a numeral to be in the right hand side. So, this method should be redefined if the default behavior conflicts with a convention used by the theory/family. */ diff --git a/src/smt/theory_arith_aux.h b/src/smt/theory_arith_aux.h index 89737fb42..9561aa089 100644 --- a/src/smt/theory_arith_aux.h +++ b/src/smt/theory_arith_aux.h @@ -1073,7 +1073,7 @@ namespace smt { /** \brief: Create an atom that enforces the inequality v > val The arithmetical expression encoding the inequality suffices - for the theory of aritmetic. + for the theory of arithmetic. */ template expr_ref theory_arith::mk_gt(theory_var v) { @@ -1146,7 +1146,7 @@ namespace smt { template void theory_arith::enable_record_conflict(expr* bound) { m_params.m_arith_bound_prop = BP_NONE; - SASSERT(propagation_mode() == BP_NONE); // bound propagtion rules are not (yet) handled. + SASSERT(propagation_mode() == BP_NONE); // bound propagation rules are not (yet) handled. if (bound) { context& ctx = get_context(); m_bound_watch = ctx.get_bool_var(bound); diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index bce029753..3da78e8ee 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -3128,7 +3128,7 @@ namespace smt { // // 1) Handling inequalities: (n1, k1) <= (n2, k2) // - // The only intersting case is n1 < n2 and k1 > k2. + // The only interesting case is n1 < n2 and k1 > k2. // Using the definition of infinitesimal numbers // we have: // n1 + k1 * epsilon <= n2 + k2 - epsilon @@ -3533,7 +3533,7 @@ namespace smt { } /** - \brief reset and retrieve built-in explanation hints for arithmetic lemmmas. + \brief reset and retrieve built-in explanation hints for arithmetic lemmas. */ template diff --git a/src/smt/theory_arith_nl.h b/src/smt/theory_arith_nl.h index c27d3b44a..24e1020fd 100644 --- a/src/smt/theory_arith_nl.h +++ b/src/smt/theory_arith_nl.h @@ -1337,7 +1337,7 @@ namespace smt { } /** - \brief Diplay a nested form expression + \brief Display a nested form expression */ template void theory_arith::display_nested_form(std::ostream & out, expr * p) { @@ -1682,7 +1682,7 @@ namespace smt { if (!get_manager().int_real_coercions() && is_mixed_real_integer(r)) return true; // giving up... see comment above - TRACE("cross_nested", tout << "cheking problematic row...\n";); + TRACE("cross_nested", tout << "checking problematic row...\n";); rational c = rational::one(); if (is_integer(r)) @@ -1764,7 +1764,7 @@ namespace smt { updated with the fixed variables in m. A variable is only added to dep if it is not already in already_found. - Return null if the monomial was simplied to 0. + Return null if the monomial was simplified to 0. */ template grobner::monomial * theory_arith::mk_gb_monomial(rational const & _coeff, expr * m, grobner & gb, v_dependency * & dep, var_set & already_found) { diff --git a/src/smt/theory_dense_diff_logic_def.h b/src/smt/theory_dense_diff_logic_def.h index 3dfba6b1b..369209e49 100644 --- a/src/smt/theory_dense_diff_logic_def.h +++ b/src/smt/theory_dense_diff_logic_def.h @@ -756,7 +756,7 @@ namespace smt { (n_x, k_x) <= (n_y + n_c, k_y + k_c) - The only intersting case is n_x < n_y + n_c and k_x > k_y + k_c. + The only interesting case is n_x < n_y + n_c and k_x > k_y + k_c. Using the definition of infinitesimal numbers we have: diff --git a/src/smt/theory_lra.cpp b/src/smt/theory_lra.cpp index 24309ba88..4a04fdaaf 100644 --- a/src/smt/theory_lra.cpp +++ b/src/smt/theory_lra.cpp @@ -3225,7 +3225,7 @@ public: theory_var w; if (m_solver->is_term(ti.var())) { //w = m_term_index2theory_var.get(m_solver->adjust_term_index(ti.var()), null_theory_var); - //if (w == null_theory_var) // if extracing expressions directly from nested term + //if (w == null_theory_var) // if extracting expressions directly from nested term lp::lar_term const& term1 = m_solver->get_term(ti.var()); rational coeff2 = coeff * ti.coeff(); term2coeffs(term1, coeffs, coeff2, offset); diff --git a/src/smt/theory_pb.h b/src/smt/theory_pb.h index 3a0ee723f..c20683d73 100644 --- a/src/smt/theory_pb.h +++ b/src/smt/theory_pb.h @@ -107,7 +107,7 @@ namespace smt { struct ineq { unsynch_mpz_manager& m_mpz; // mpz manager. - literal m_lit; // literal repesenting predicate + literal m_lit; // literal representing predicate bool m_is_eq; // is this an = or >=. arg_t m_args[2]; // encode args[0]*coeffs[0]+...+args[n-1]*coeffs[n-1] >= k(); // Watch the first few positions until the sum satisfies: @@ -192,7 +192,7 @@ namespace smt { // If none are available, then perform unit propagation. // class card { - literal m_lit; // literal repesenting predicate + literal m_lit; // literal representing predicate literal_vector m_args; unsigned m_bound; unsigned m_num_propagations; diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 093a47146..2fb95e676 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -1412,7 +1412,7 @@ bool theory_seq::is_complex(eq const& e) { \brief Decompose ls = rs into Xa = bYc, such that 1. - X != Y - - |b| <= |X| <= |bY| in currrent model + - |b| <= |X| <= |bY| in current model - b is non-empty. 2. X != Y - b is empty diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index ec192cd89..856ba728e 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -5074,7 +5074,7 @@ namespace smt { } } else { // ------------------------------------------------------------------------------------------------ - // subStr doesn't have an eqc contant value + // subStr doesn't have an eqc constant value // however, subStr equals to some concat(arg_1, arg_2, ..., arg_n) // if arg_j is a constant and is not a part of the strConst, it's sure that the contains is false // ** This check is needed here because the "strConst" and "strAst" may not be in a same eqc yet diff --git a/src/solver/combined_solver.cpp b/src/solver/combined_solver.cpp index 61094c29c..e8fb34815 100644 --- a/src/solver/combined_solver.cpp +++ b/src/solver/combined_solver.cpp @@ -39,7 +39,7 @@ Notes: The object switches to incremental when: - push is used - - assertions are peformed after a check_sat + - assertions are performed after a check_sat - parameter ignore_solver1==false */ class combined_solver : public solver { diff --git a/src/solver/parallel_params.pyg b/src/solver/parallel_params.pyg index 2d58cbb81..cb37138ee 100644 --- a/src/solver/parallel_params.pyg +++ b/src/solver/parallel_params.pyg @@ -9,7 +9,7 @@ def_module_params('parallel', ('conquer.restart.max', UINT, 5, 'maximal number of restarts during conquer phase'), ('conquer.delay', UINT, 10, 'delay of cubes until applying conquer'), ('conquer.backtrack_frequency', UINT, 10, 'frequency to apply core minimization during conquer'), - ('simplify.exp', DOUBLE, 1, 'restart and inprocess max is multipled by simplify.exp ^ depth'), + ('simplify.exp', DOUBLE, 1, 'restart and inprocess max is multiplied by simplify.exp ^ depth'), ('simplify.restart.max', UINT, 5000, 'maximal number of restarts during simplification phase'), ('simplify.inprocess.max', UINT, 2, 'maximal number of inprocessing steps during simplification'), )) diff --git a/src/tactic/arith/fm_tactic.cpp b/src/tactic/arith/fm_tactic.cpp index fc41f54a4..bd99e4303 100644 --- a/src/tactic/arith/fm_tactic.cpp +++ b/src/tactic/arith/fm_tactic.cpp @@ -1231,7 +1231,7 @@ class fm_tactic : public tactic { } // An integer variable x may be eliminated, if - // 1- All variables in the contraints it occur are integer. + // 1- All variables in the constraints it occur are integer. // 2- The coefficient of x in all lower bounds (or all upper bounds) is unit. bool can_eliminate(var x) const { if (!is_int(x)) diff --git a/src/tactic/bv/bvarray2uf_rewriter.cpp b/src/tactic/bv/bvarray2uf_rewriter.cpp index 3ca296eb7..97947c03a 100644 --- a/src/tactic/bv/bvarray2uf_rewriter.cpp +++ b/src/tactic/bv/bvarray2uf_rewriter.cpp @@ -40,7 +40,7 @@ bvarray2uf_rewriter_cfg::bvarray2uf_rewriter_cfg(ast_manager & m, params_ref con m_fmc(nullptr), extra_assertions(m) { updt_params(p); - // We need to make sure that the mananger has the BV and array plugins loaded. + // We need to make sure that the manager has the BV and array plugins loaded. symbol s_bv("bv"); if (!m_manager.has_plugin(s_bv)) m_manager.register_plugin(s_bv, alloc(bv_decl_plugin)); diff --git a/src/tactic/core/cofactor_elim_term_ite.cpp b/src/tactic/core/cofactor_elim_term_ite.cpp index 1b435791c..6afcdee41 100644 --- a/src/tactic/core/cofactor_elim_term_ite.cpp +++ b/src/tactic/core/cofactor_elim_term_ite.cpp @@ -197,7 +197,7 @@ struct cofactor_elim_term_ite::imp { switch (arg->get_kind()) { case AST_VAR: case AST_QUANTIFIER: - // ingore quantifiers + // ignore quantifiers break; case AST_APP: if (to_app(arg)->get_num_args() > 0) { @@ -264,7 +264,7 @@ struct cofactor_elim_term_ite::imp { switch (arg->get_kind()) { case AST_VAR: case AST_QUANTIFIER: - // ingore quantifiers + // ignore quantifiers break; case AST_APP: if (to_app(arg)->get_num_args() > 0) { diff --git a/src/tactic/core/pb_preprocess_tactic.cpp b/src/tactic/core/pb_preprocess_tactic.cpp index 7f17c8dae..50d606197 100644 --- a/src/tactic/core/pb_preprocess_tactic.cpp +++ b/src/tactic/core/pb_preprocess_tactic.cpp @@ -273,8 +273,8 @@ private: } /** - \brief decompose large sums into smaller sums by intoducing - auxilary variables. + \brief decompose large sums into smaller sums by introducing + auxiliary variables. */ void decompose(goal_ref const& g) { expr_ref fml1(m), fml2(m); diff --git a/src/tactic/model_converter.h b/src/tactic/model_converter.h index 9c5b72830..73432219f 100644 --- a/src/tactic/model_converter.h +++ b/src/tactic/model_converter.h @@ -31,7 +31,7 @@ Notes: This property holds for both eval, that decides on a fixed value for constants that have no interpretation in m and for 'peval' - (partial eval) that retuns just the constants that are unfixed. + (partial eval) that returns just the constants that are unfixed. (in the model evaluator one can control this behavior using a configuration flag) @@ -48,7 +48,7 @@ Notes: mc(G) & F_s is SAT iff G & F is SAT For a model converter that is a sequence of definitions and removals - of functions we can obtain mc(G) by adding back or expanding definitinos + of functions we can obtain mc(G) by adding back or expanding definitions that are required to interpret G fully in the context of F_s. --*/ diff --git a/src/tactic/nlsat_smt/nl_purify_tactic.cpp b/src/tactic/nlsat_smt/nl_purify_tactic.cpp index 745b0352d..a02c2d327 100644 --- a/src/tactic/nlsat_smt/nl_purify_tactic.cpp +++ b/src/tactic/nlsat_smt/nl_purify_tactic.cpp @@ -8,7 +8,7 @@ Module Name: Abstract: Tactic for purifying quantifier-free formulas that mix QF_NRA and other theories. - It is designed to allow cooprating between the nlsat solver and other theories + It is designed to allow cooperation between the nlsat solver and other theories in a decoupled way. Let goal be formula F. @@ -446,7 +446,7 @@ private: expr* pred = fresh_preds[i]; if (mdl->eval(pred, tmp)) { polarity_t pol = m_polarities.find(pred); - // if assumptinon literals are used to satisfy NL state, + // if assumption literals are used to satisfy NL state, // we have to assume them when satisfying SMT state if (pol != pol_neg && m.is_false(tmp)) { m_asms.push_back(m.mk_not(pred)); @@ -767,7 +767,7 @@ public: // then annotate subformulas by polarities, // finally extract polynomial inequalities by // creating a place-holder predicate inside the - // original goal and extracing pure nlsat clauses. + // original goal and extracting pure nlsat clauses. r.set_interface_var_mode(); rewrite_goal(r, g); if (!g->unsat_core_enabled()) { diff --git a/src/tactic/sls/sls_engine.cpp b/src/tactic/sls/sls_engine.cpp index f5b5ec1b2..1285e46cf 100644 --- a/src/tactic/sls/sls_engine.cpp +++ b/src/tactic/sls/sls_engine.cpp @@ -182,7 +182,7 @@ bool sls_engine::what_if( // Andreas: Had this idea on my last day. Maybe we could add a noise here similar to the one that worked so well for ucb assertion selection. // r += 0.0001 * m_tracker.get_random_uint(8); - // Andreas: For some reason it is important to use > here instead of >=. Probably related to prefering the LSB. + // Andreas: For some reason it is important to use > here instead of >=. Probably related to preferring the LSB. if (r > best_score) { best_score = r; best_const = fd_inx; diff --git a/src/tactic/smtlogics/qfbv_tactic.cpp b/src/tactic/smtlogics/qfbv_tactic.cpp index a8ad95319..7c410e721 100644 --- a/src/tactic/smtlogics/qfbv_tactic.cpp +++ b/src/tactic/smtlogics/qfbv_tactic.cpp @@ -36,7 +36,7 @@ Notes: static tactic * mk_qfbv_preamble(ast_manager& m, params_ref const& p) { params_ref solve_eq_p; - // conservative guassian elimination. + // conservative gaussian elimination. solve_eq_p.set_uint("solve_eqs_max_occs", 2); params_ref simp2_p = p; diff --git a/src/test/ast.cpp b/src/test/ast.cpp index 59bdfc8e4..0826306f2 100644 --- a/src/test/ast.cpp +++ b/src/test/ast.cpp @@ -44,7 +44,7 @@ static void tst1() { // ast_ref v3 (m.mk_var(1), m); // ENSURE(v1 != v2); // ENSURE(v1 == v3); -// TRACE("ast", tout << "reseting v1\n";); +// TRACE("ast", tout << "resetting v1\n";); // v1.reset(); // TRACE("ast", tout << "overwriting v3\n";); // v3 = v2; diff --git a/src/test/ddnf.cpp b/src/test/ddnf.cpp index 003e5bdb8..b1bb624a2 100644 --- a/src/test/ddnf.cpp +++ b/src/test/ddnf.cpp @@ -15,7 +15,7 @@ Copyright (c) 2015 Microsoft Corporation #include /* -TBD: count number of nodes, number of operations accross all insertions +TBD: count number of nodes, number of operations across all insertions */ void read_nums(std::istream& is, unsigned & x, unsigned& y) { diff --git a/src/test/fuzzing/expr_delta.h b/src/test/fuzzing/expr_delta.h index d69ed33f1..f59e4c4d5 100644 --- a/src/test/fuzzing/expr_delta.h +++ b/src/test/fuzzing/expr_delta.h @@ -33,7 +33,7 @@ public: // // Create the n'th delta in dfs mode. - // resturn 'true' if a delta was obtained. + // return 'true' if a delta was obtained. // bool delta_dfs(unsigned n, expr_ref_vector& result); diff --git a/src/test/lp/lp.cpp b/src/test/lp/lp.cpp index ffdbb5af8..192bd46b0 100644 --- a/src/test/lp/lp.cpp +++ b/src/test/lp/lp.cpp @@ -117,7 +117,7 @@ void test_matrix(square_sparse_matrix & a) { } void tst1() { - std::cout << "testing the minimial matrix with 1 row and 1 column" << std::endl; + std::cout << "testing the minimal matrix with 1 row and 1 column" << std::endl; square_sparse_matrix m0(1, 1); m0.set(0, 0, 1); // print_matrix(m0); @@ -192,7 +192,7 @@ void tst1() { // print_matrix(m10by9); } -vector allocate_basis_heading(unsigned count) { // the rest of initilization will be handled by lu_QR +vector allocate_basis_heading(unsigned count) { // the rest of initialization will be handled by lu_QR vector basis_heading(count, -1); return basis_heading; } @@ -850,7 +850,7 @@ void fill_uniformly(dense_matrix & m, unsigned dim) { } } -void square_sparse_matrix_with_permutaions_test() { +void square_sparse_matrix_with_permutations_test() { unsigned dim = 4; square_sparse_matrix m(dim, dim); fill_uniformly(m, dim); @@ -1023,7 +1023,7 @@ void test_dense_matrix() { -vector> vector_of_permutaions() { +vector> vector_of_permutations() { vector> ret; { permutation_matrix p0(5); @@ -1058,7 +1058,7 @@ void test_apply_reverse_from_right_to_perm(permutation_matrix & } void test_apply_reverse_from_right() { - auto vec = vector_of_permutaions(); + auto vec = vector_of_permutations(); for (unsigned i = 0; i < vec.size(); i++) { test_apply_reverse_from_right_to_perm(vec[i]); } @@ -1901,17 +1901,17 @@ void setup_args_parser(argument_parser & parser) { parser.add_option_with_after_string_with_help("--density", "the percentage of non-zeroes in the matrix below which it is not dense"); parser.add_option_with_after_string_with_help("--harris_toler", "harris tolerance"); parser.add_option_with_help_string("--test_swaps", "test row swaps with a permutation"); - parser.add_option_with_help_string("--test_perm", "test permutaions"); + parser.add_option_with_help_string("--test_perm", "test permutations"); parser.add_option_with_after_string_with_help("--checklu", "the file name for lu checking"); parser.add_option_with_after_string_with_help("--partial_pivot", "the partial pivot constant, a number somewhere between 10 and 100"); parser.add_option_with_after_string_with_help("--percent_for_enter", "which percent of columns check for entering column"); - parser.add_option_with_help_string("--totalinf", "minimizes the total infeasibility instead of diminishin infeasibility of the rows"); + parser.add_option_with_help_string("--totalinf", "minimizes the total infeasibility instead of diminishing infeasibility of the rows"); parser.add_option_with_after_string_with_help("--rep_frq", "the report frequency, in how many iterations print the cost and other info "); parser.add_option_with_help_string("--smt", "smt file format"); parser.add_option_with_after_string_with_help("--filelist", "the file containing the list of files"); parser.add_option_with_after_string_with_help("--file", "the input file name"); parser.add_option_with_after_string_with_help("--random_seed", "random seed"); - parser.add_option_with_help_string("--bp", "bound propogation"); + parser.add_option_with_help_string("--bp", "bound propagation"); parser.add_option_with_help_string("--min", "will look for the minimum for the given file if --file is used; the default is looking for the max"); parser.add_option_with_help_string("--max", "will look for the maximum for the given file if --file is used; it is the default behavior"); parser.add_option_with_after_string_with_help("--max_iters", "maximum total iterations in a core solver stage"); @@ -1932,7 +1932,7 @@ void setup_args_parser(argument_parser & parser) { parser.add_option_with_help_string("--lar", "test lar_solver"); parser.add_option_with_after_string_with_help("--maxng", "max iterations without progress"); parser.add_option_with_help_string("-tbq", "test binary queue"); - parser.add_option_with_help_string("--randomize_lar", "test randomize funclionality"); + parser.add_option_with_help_string("--randomize_lar", "test randomize functionality"); parser.add_option_with_help_string("--smap", "test stacked_map"); parser.add_option_with_help_string("--term", "simple term test"); parser.add_option_with_help_string("--eti"," run a small evidence test for total infeasibility scenario"); @@ -3722,7 +3722,7 @@ void test_lp_local(int argn, char**argv) { test_init_U(); test_replace_column(); #ifdef Z3DEBUG - square_sparse_matrix_with_permutaions_test(); + square_sparse_matrix_with_permutations_test(); test_dense_matrix(); test_swap_operations(); test_permutations(); diff --git a/src/test/sat_local_search.cpp b/src/test/sat_local_search.cpp index 1116c5420..ad982d024 100644 --- a/src/test/sat_local_search.cpp +++ b/src/test/sat_local_search.cpp @@ -7,7 +7,7 @@ static bool build_instance(char const * filename, sat::solver& s, sat::local_search& local_search) { char line[16383]; - // for temperally storage + // for temporary storage std::ifstream infile(filename); //if (infile == NULL) //linux @@ -28,7 +28,7 @@ static bool build_instance(char const * filename, sat::solver& s, sat::local_sea sat::literal_vector lits; // process objective function: - // read coefficents + // read coefficients infile >> cur_term; while (cur_term != 0) { coefficients.push_back(cur_term); @@ -43,7 +43,7 @@ static bool build_instance(char const * filename, sat::solver& s, sat::local_sea } if (lits.size() != coefficients.size()) { - std::cout << "Objective function format error. They have different lenghts.\n"; + std::cout << "Objective function format error. They have different lengths.\n"; return false; } diff --git a/src/util/bit_util.cpp b/src/util/bit_util.cpp index a38f42fdd..fdca2dc83 100644 --- a/src/util/bit_util.cpp +++ b/src/util/bit_util.cpp @@ -126,7 +126,7 @@ unsigned ntz(unsigned sz, unsigned const * data) { /** \brief dst <- src - Trucate if src_sz > dst_sz. + Truncate if src_sz > dst_sz. Fill range [src_sz, dst_sz) of dst with zeros if dst_sz > src_sz. */ void copy(unsigned src_sz, unsigned const * src, diff --git a/src/util/bit_util.h b/src/util/bit_util.h index 5729e8eed..7a0923400 100644 --- a/src/util/bit_util.h +++ b/src/util/bit_util.h @@ -48,7 +48,7 @@ unsigned ntz(unsigned sz, unsigned const * data); /** \brief dst <- src - Trucate if src_sz > dst_sz. + Truncate if src_sz > dst_sz. Fill range [src_sz, dst_sz) of dst with zeros if dst_sz > src_sz. */ void copy(unsigned src_sz, unsigned const * src, unsigned dst_sz, unsigned * dst); @@ -87,7 +87,7 @@ void shr(unsigned sz, unsigned const * src, unsigned k, unsigned * dst); \brief dst <- src >> k Store in dst the result of shifting src k bits to the right. - Trucate if src_sz > dst_sz. + Truncate if src_sz > dst_sz. Fill range [src_sz, dst_sz) of dst with zeros if dst_sz > src_sz. \pre src_sz != 0 diff --git a/src/util/list.h b/src/util/list.h index 075d5a0e1..82ca73308 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -68,7 +68,7 @@ unsigned length(list * l) { } /** - \brief Non destructive apppend operation. The new nodes are allocated + \brief Non destructive append operation. The new nodes are allocated using the given region allocator. */ template diff --git a/src/util/lp/binary_heap_priority_queue_def.h b/src/util/lp/binary_heap_priority_queue_def.h index 232959c83..d0a08c27d 100644 --- a/src/util/lp/binary_heap_priority_queue_def.h +++ b/src/util/lp/binary_heap_priority_queue_def.h @@ -76,7 +76,7 @@ template void binary_heap_priority_queue::remove(unsigned o) { put_at(o_in_heap, m_heap[m_heap_size--]); if (m_priorities[m_heap[o_in_heap]] > priority_of_o) { fix_heap_under(o_in_heap); - } else { // we need to propogate the m_heap[o_in_heap] up + } else { // we need to propagate the m_heap[o_in_heap] up unsigned i = o_in_heap; while (i > 1) { unsigned ip = i >> 1; diff --git a/src/util/lp/bound_analyzer_on_row.h b/src/util/lp/bound_analyzer_on_row.h index 549c8e5ce..a20b4850a 100644 --- a/src/util/lp/bound_analyzer_on_row.h +++ b/src/util/lp/bound_analyzer_on_row.h @@ -270,7 +270,7 @@ public : } } - // // it is the coefficent before the bounded column + // // it is the coefficient before the bounded column // void provide_evidence(bool coeff_is_pos) { // /* // auto & be = m_ibounds.back(); diff --git a/src/util/lp/lp_core_solver_base_def.h b/src/util/lp/lp_core_solver_base_def.h index c3a0a0a00..6844ab839 100644 --- a/src/util/lp/lp_core_solver_base_def.h +++ b/src/util/lp/lp_core_solver_base_def.h @@ -74,7 +74,7 @@ lp_core_solver_base(static_matrix & A, } template void lp_core_solver_base:: -allocate_basis_heading() { // the rest of initilization will be handled by the factorization class +allocate_basis_heading() { // the rest of initialization will be handled by the factorization class init_basis_heading_and_non_basic_columns_vector(); lp_assert(basis_heading_is_correct()); } diff --git a/src/util/lp/lp_dual_core_solver_def.h b/src/util/lp/lp_dual_core_solver_def.h index 86e6231fc..e7ab73928 100644 --- a/src/util/lp/lp_dual_core_solver_def.h +++ b/src/util/lp/lp_dual_core_solver_def.h @@ -276,7 +276,7 @@ template bool lp_dual_core_solver::can_be_breakpo bool grawing = m_sign_of_alpha_r * this->m_pivot_row[j] > 0; return lower_bound == grawing; } - case column_type::fixed: // is always dual feasible so we ingore it + case column_type::fixed: // is always dual feasible so we ignore it return false; case column_type::free_column: return true; diff --git a/src/util/lp/lp_primal_core_solver_def.h b/src/util/lp/lp_primal_core_solver_def.h index 872922f60..d86ebf548 100644 --- a/src/util/lp/lp_primal_core_solver_def.h +++ b/src/util/lp/lp_primal_core_solver_def.h @@ -284,7 +284,7 @@ template int lp_primal_core_solver::advance_on_so break; } else { if ((numeric_traits::precise() == false) || ( numeric_traits::is_zero(slope_at_entering) && this->m_settings.random_next() % 2 == 0)) { - // it is not cost benefitial to advance the delta more, so just break to increas the randomness + // it is not cost beneficial to advance the delta more, so just break to increase the randomness break; } } @@ -612,7 +612,7 @@ template int lp_primal_core_solver::refresh_re return 2; // abort entering } else { if (refreshed_cost > -m_epsilon_of_reduced_cost) - return 2; // abort entiring + return 2; // abort entering } return 1; // go on with this entering } else { @@ -621,7 +621,7 @@ template int lp_primal_core_solver::refresh_re return 2; // abort entering } else { if (refreshed_cost > -m_epsilon_of_reduced_cost) - return 2; // abort entiring + return 2; // abort entering } } return 0; diff --git a/src/util/lp/lp_settings.h b/src/util/lp/lp_settings.h index 1bbefd154..d0bdc284d 100644 --- a/src/util/lp/lp_settings.h +++ b/src/util/lp/lp_settings.h @@ -68,7 +68,7 @@ enum class lp_status { CANCELLED }; -// when the ratio of the vector lenth to domain size to is greater than the return value we switch to solve_By_for_T_indexed_only +// when the ratio of the vector length to domain size to is greater than the return value we switch to solve_By_for_T_indexed_only template unsigned ratio_of_index_size_to_all_size() { if (numeric_traits::precise()) @@ -145,7 +145,7 @@ public: double pivot_epsilon; // see Chatal, page 115 double positive_price_epsilon; - // a quatation "if some choice of the entering vairable leads to an eta matrix + // a quotation "if some choice of the entering variable leads to an eta matrix // whose diagonal element in the eta column is less than e2 (entering_diag_epsilon) in magnitude, the this choice is rejected ... double entering_diag_epsilon; int c_partial_pivoting; // this is the constant c from page 410 diff --git a/src/util/lp/scaler_def.h b/src/util/lp/scaler_def.h index 2710f89bf..4c9784a43 100644 --- a/src/util/lp/scaler_def.h +++ b/src/util/lp/scaler_def.h @@ -126,7 +126,7 @@ template void scaler::scale_once_for_ratio() { T max_ratio_on_rows = get_max_ratio_on_rows(); T max_ratio_on_columns = get_max_ratio_on_columns(); bool scale_rows_first = max_ratio_on_rows > max_ratio_on_columns; - // if max_ratio_on_columns is the largerst then the rows are in worser shape then columns + // if max_ratio_on_columns is the largest then the rows are in worse shape than columns if (scale_rows_first) { scale_rows_with_geometric_mean(); scale_columns_with_geometric_mean(); diff --git a/src/util/lp/square_sparse_matrix_def.h b/src/util/lp/square_sparse_matrix_def.h index 791bdb6ae..cc6625453 100644 --- a/src/util/lp/square_sparse_matrix_def.h +++ b/src/util/lp/square_sparse_matrix_def.h @@ -186,7 +186,7 @@ void square_sparse_matrix::init_row_headers() { } template -void square_sparse_matrix::init_column_headers() { // we alway have only square square_sparse_matrix +void square_sparse_matrix::init_column_headers() { // we always have only square square_sparse_matrix for (unsigned l = 0; l < m_row_permutation.size(); l++) { m_columns.push_back(col_header()); } diff --git a/src/util/mpf.cpp b/src/util/mpf.cpp index 7549a7bb3..49335467d 100644 --- a/src/util/mpf.cpp +++ b/src/util/mpf.cpp @@ -952,7 +952,7 @@ void my_mpz_sqrt(unsynch_mpz_manager & m, unsigned sbits, bool odd_exp, mpz & in scoped_mpz lower(m), upper(m); scoped_mpz mid(m), product(m), diff(m); // we have lower <= a.significand <= upper and we need 1.[52+3 bits] in the bounds. - // since we comapre upper*upper to a.significand further down, we need a.significand + // since we compare upper*upper to a.significand further down, we need a.significand // to be of twice the size. m.set(lower, 1); m.mul2k(lower, sbits+2-1); @@ -978,7 +978,7 @@ void my_mpz_sqrt(unsynch_mpz_manager & m, unsigned sbits, bool odd_exp, mpz & in } else { STRACE("mpf_dbg", tout << "choosing upper" << std::endl;); - m.set(o, upper); // chosing upper is like a sticky bit here. + m.set(o, upper); // choosing upper is like a sticky bit here. } break; } diff --git a/src/util/obj_ref_hashtable.h b/src/util/obj_ref_hashtable.h index 23a2a1867..80d198607 100644 --- a/src/util/obj_ref_hashtable.h +++ b/src/util/obj_ref_hashtable.h @@ -7,7 +7,7 @@ Module Name: Abstract: - corresponding obj_map with reference count managment. + corresponding obj_map with reference count management. Author: diff --git a/src/util/warning.cpp b/src/util/warning.cpp index 6184db880..1e9f8a484 100644 --- a/src/util/warning.cpp +++ b/src/util/warning.cpp @@ -16,8 +16,8 @@ Author: Revision History: --*/ -#include -#include +#include +#include #include "util/error_codes.h" #include "util/util.h" @@ -25,7 +25,6 @@ Revision History: #include "util/vector.h" #ifdef _WINDOWS -#define PRF sprintf_s #define VPRF vsprintf_s void STD_CALL myInvalidParameterHandler( @@ -54,7 +53,6 @@ void STD_CALL myInvalidParameterHandler( #else -#define PRF snprintf #define VPRF vsnprintf #define BEGIN_ERR_HANDLER() {} #define END_ERR_HANDLER() {} @@ -64,7 +62,6 @@ static bool g_warning_msgs = true; static bool g_use_std_stdout = false; static std::ostream* g_error_stream = nullptr; static std::ostream* g_warning_stream = nullptr; -static bool g_show_error_msg_prefix = true; void send_warnings_to_stdout(bool flag) { g_use_std_stdout = flag; @@ -82,61 +79,24 @@ void set_warning_stream(std::ostream* strm) { g_warning_stream = strm; } -void disable_error_msg_prefix() { - g_show_error_msg_prefix = false; -} - -#if 0 -// [Leo]: Do we need this? -static void string2ostream(std::ostream& out, char const* msg) { - svector buff; - buff.resize(10); - BEGIN_ERR_HANDLER(); - while (true) { - int nc = PRF(buff.c_ptr(), buff.size(), msg); - if (nc >= 0 && nc < static_cast(buff.size())) - break; // success - buff.resize(buff.size()*2 + 1); - } - END_ERR_HANDLER(); - out << buff.c_ptr(); -} -#endif - void format2ostream(std::ostream & out, char const* msg, va_list args) { svector buff; -#if !defined(_WINDOWS) && defined(_AMD64_) - // see comment below. - buff.resize(1024); -#else - buff.resize(128); -#endif BEGIN_ERR_HANDLER(); - while (true) { - int nc = VPRF(buff.c_ptr(), buff.size(), msg, args); -#if !defined(_WINDOWS) && defined(_AMD64_) - // For some strange reason, on Linux 64-bit version, va_list args is reset by vsnprintf. - // Z3 crashes when trying to use va_list args again. - // Hack: I truncate the message instead of expanding the buffer to make sure that - // va_list args is only used once. - END_ERR_HANDLER(); - if (nc < 0) { - // vsnprintf didn't work, so we just print the msg - out << msg; - return; - } - if (nc >= static_cast(buff.size())) { - // truncate the message - buff[buff.size() - 1] = 0; - } - out << buff.c_ptr(); - return; + + va_list args_copy; + va_copy(args_copy, args); +#ifdef _WINDOWS + size_t msg_len = _vscprintf(msg, args_copy); #else - if (nc >= 0 && nc < static_cast(buff.size())) - break; // success - buff.resize(buff.size()*2 + 1); + size_t msg_len = vsnprintf(NULL, 0, msg, args_copy); #endif - } + va_end(args_copy); + + // +1 is for NUL termination. + buff.resize(static_cast(msg_len + 1)); + + VPRF(buff.c_ptr(), buff.size(), msg, args); + END_ERR_HANDLER(); out << buff.c_ptr(); } diff --git a/src/util/warning.h b/src/util/warning.h index 15f1a1757..2bcc7512b 100644 --- a/src/util/warning.h +++ b/src/util/warning.h @@ -31,30 +31,7 @@ void set_warning_stream(std::ostream* strm); void warning_msg(const char * msg, ...); -void disable_error_msg_prefix(); - void format2ostream(std::ostream& out, char const* fmt, va_list args); -class warning_displayer { - const char * m_msg; - bool m_displayed; -public: - warning_displayer(const char * msg): - m_msg(msg), - m_displayed(false) { - } - - void sign() { - if (!m_displayed) { - warning_msg(m_msg); - m_displayed = true; - } - } - - void reset() { - m_displayed = false; - } -}; - #endif /* WARNING_H_ */