mirror of
https://github.com/Z3Prover/z3
synced 2025-06-19 20:33:38 +00:00
address divergence in the case of shared theory symbols. Codeplex issue 147, thanks to George Karpenkov
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
08cb8b8de8
74 changed files with 1280 additions and 896 deletions
|
@ -273,6 +273,9 @@ extern "C" {
|
|||
0 // ignore params for now
|
||||
);
|
||||
|
||||
for (unsigned i = 0; i < cnsts.size(); i++)
|
||||
_m.dec_ref(cnsts[i]);
|
||||
|
||||
Z3_lbool status = of_lbool(_status);
|
||||
|
||||
Z3_ast_vector_ref *v = 0;
|
||||
|
@ -617,7 +620,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
for (unsigned j = 0; j < num - 1; j++)
|
||||
if (read_parents[j] == SHRT_MIN){
|
||||
if (read_parents[j] == SHRT_MAX){
|
||||
read_error << "formula " << j + 1 << ": unreferenced";
|
||||
goto fail;
|
||||
}
|
||||
|
@ -717,4 +720,4 @@ Z3_lbool Z3_API Z3_interpolate(__in Z3_context ctx,
|
|||
__in unsigned incremental,
|
||||
__in unsigned num_theory,
|
||||
__in_ecount(num_theory) Z3_ast *theory);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1314,6 +1314,26 @@ namespace z3 {
|
|||
expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
|
||||
expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
|
||||
friend std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
|
||||
|
||||
std::string to_smt2(char const* status = "unknown") {
|
||||
array<Z3_ast> es(assertions());
|
||||
Z3_ast const* fmls = es.ptr();
|
||||
Z3_ast fml = 0;
|
||||
unsigned sz = es.size();
|
||||
if (sz > 0) {
|
||||
--sz;
|
||||
fml = fmls[sz];
|
||||
}
|
||||
else {
|
||||
fml = ctx().bool_val(true);
|
||||
}
|
||||
return std::string(Z3_benchmark_to_smtlib_string(
|
||||
ctx(),
|
||||
"", "", status, "",
|
||||
sz,
|
||||
fmls,
|
||||
fml));
|
||||
}
|
||||
};
|
||||
|
||||
class goal : public object {
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
|
||||
<OutputPath>..\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<DocumentationFile>..\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
|
@ -254,7 +254,7 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
|
||||
<OutputPath>..\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
|
@ -266,7 +266,7 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<DocumentationFile>..\x86\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
|
|
|
@ -12,7 +12,7 @@ using System.Security.Permissions;
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft Corporation")]
|
||||
[assembly: AssemblyProduct("Z3")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2006")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2006-2014 Microsoft Corporation")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
|
|
@ -24,28 +24,12 @@ import com.microsoft.z3.enumerations.Z3_ast_kind;
|
|||
**/
|
||||
public class AST extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Comparison operator. <param name="a">An AST</param> <param name="b">An
|
||||
* AST</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
|
||||
* the same context and represent the same sort; false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator. <param name="a">An AST</param> <param name="b">An
|
||||
* AST</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
|
||||
* from the same context or represent different sorts; false
|
||||
* otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Object comparison.
|
||||
**/
|
||||
* <param name="o">another AST</param>
|
||||
**/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
AST casted = null;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class Expr extends AST
|
|||
/**
|
||||
* Returns a simplified version of the expression
|
||||
* A set of
|
||||
* parameters <param name="p" /> to configure the simplifier
|
||||
* parameters <param name="p">a Params object</param> to configure the simplifier
|
||||
* <seealso cref="Context.SimplifyHelp"/>
|
||||
**/
|
||||
public Expr simplify(Params p) throws Z3Exception
|
||||
|
|
|
@ -50,8 +50,7 @@ public final class Global
|
|||
/**
|
||||
* Get a global (or module) parameter.
|
||||
* <remarks>
|
||||
* Returns null if the parameter <param name="id"/> does not exist.
|
||||
* The caller must invoke #Z3_global_param_del_value to delete the value returned at \c param_value.
|
||||
* Returns null if the parameter <param name="id">parameter id</param> does not exist.
|
||||
* This function cannot be invoked simultaneously from different threads without synchronization.
|
||||
* The result string stored in param_value is stored in a shared location.
|
||||
* </remarks>
|
||||
|
@ -70,7 +69,7 @@ public final class Global
|
|||
* <remarks>
|
||||
* This command will not affect already created objects (such as tactics and solvers)
|
||||
* </remarks>
|
||||
* @seealso SetParameter
|
||||
* <seealso cref="SetParameter"/>
|
||||
**/
|
||||
public static void resetParameters()
|
||||
{
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
Java bindings
|
||||
-------------
|
||||
|
||||
The Java bindings will be included in the Z3 build if it is configured with
|
||||
the option --java to python scripts/mk_make.py. This will produce the
|
||||
com.microsoft.z3.jar package in the build directory.
|
||||
|
|
|
@ -25,27 +25,10 @@ import com.microsoft.z3.enumerations.Z3_sort_kind;
|
|||
**/
|
||||
public class Sort extends AST
|
||||
{
|
||||
/**
|
||||
* Comparison operator. <param name="a">A Sort</param> <param name="b">A
|
||||
* Sort</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
|
||||
* the same context and represent the same sort; false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator. <param name="a">A Sort</param> <param name="b">A
|
||||
* Sort</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
|
||||
* from the same context or represent different sorts; false
|
||||
* otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Equality operator for objects of type Sort. <param name="o"></param>
|
||||
* Equality operator for objects of type Sort. <param name="o"/>
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Manifest-Version: 1.0
|
||||
Created-By: 4.3.0 (Microsoft Research LTD.)
|
||||
Created-By: 4.3.2 (Microsoft Research LTD.)
|
||||
|
|
|
@ -1,463 +0,0 @@
|
|||
######################################################
|
||||
# Copyright (c) 2012 Microsoft Corporation
|
||||
#
|
||||
# Auxiliary scripts for generating Java bindings
|
||||
# from the managed API.
|
||||
#
|
||||
# Author: Christoph M. Wintersteiger (cwinter)
|
||||
######################################################
|
||||
|
||||
|
||||
###
|
||||
# DO NOT USE THIS SCRIPT!
|
||||
# This script creates a rough draft of a Java API from
|
||||
# the managed API, but does not automated the process.
|
||||
###
|
||||
|
||||
CS="../dotnet/"
|
||||
EXT=".cs"
|
||||
EXCLUDE=["Enumerations.cs", "Native.cs", "AssemblyInfo.cs"]
|
||||
OUTDIR="com/Microsoft/Z3/"
|
||||
ENUMS_FILE = "Enumerations.cs"
|
||||
|
||||
import os
|
||||
import fileinput
|
||||
import string
|
||||
import re
|
||||
|
||||
EXCLUDE_METHODS = [ [ "Context.cs", "public Expr MkNumeral(ulong" ],
|
||||
[ "Context.cs", "public Expr MkNumeral(uint" ],
|
||||
[ "Context.cs", "public RatNum MkReal(ulong" ],
|
||||
[ "Context.cs", "public RatNum MkReal(uint" ],
|
||||
[ "Context.cs", "public IntNum MkInt(ulong" ],
|
||||
[ "Context.cs", "public IntNum MkInt(uint" ],
|
||||
[ "Context.cs", "public BitVecNum MkBV(ulong" ],
|
||||
[ "Context.cs", "public BitVecNum MkBV(uint" ],
|
||||
]
|
||||
|
||||
ENUMS = []
|
||||
|
||||
def mk_java_bindings():
|
||||
print "Generating Java bindings (from C# bindings in " + CS + ")..."
|
||||
print "Finding enumerations in " + ENUMS_FILE + "..."
|
||||
find_enums(ENUMS_FILE)
|
||||
for root, dirs, files in os.walk(CS):
|
||||
for fn in files:
|
||||
if not fn in EXCLUDE and fn.endswith(EXT):
|
||||
translate(fn)
|
||||
|
||||
def subst_getters(s, getters):
|
||||
for g in getters:
|
||||
s = s.replace(g, g + "()")
|
||||
|
||||
def type_replace(s):
|
||||
s = s.replace(" bool", " boolean")
|
||||
s = s.replace("(bool", "(boolean")
|
||||
s = s.replace("uint", "int")
|
||||
s = s.replace("ulong", "long")
|
||||
s = s.replace("string", "String")
|
||||
s = s.replace("IntPtr", "long")
|
||||
s = s.replace("Dictionary<", "Map<")
|
||||
s = s.replace("UInt64", "long")
|
||||
s = s.replace("Int64", "long")
|
||||
s = s.replace("List<long>", "LinkedList<Long>")
|
||||
s = s.replace("System.Exception", "Exception")
|
||||
return s
|
||||
|
||||
def rename_native(s):
|
||||
while s.find("Native.Z3") != -1:
|
||||
i0 = s.find("Native.Z3")
|
||||
i1 = s.find("(", i0)
|
||||
c0 = s[:i0]
|
||||
c1 = s[i0:i1]
|
||||
c1 = c1.replace("Native.Z3_", "Native.")
|
||||
c2 = s[i1:]
|
||||
lc_callback = lambda pat: pat.group("id").upper()
|
||||
c1 = re.sub("_(?P<id>\w)", lc_callback, c1)
|
||||
s = c0 + c1 + c2
|
||||
return s
|
||||
|
||||
def find_enums(fn):
|
||||
for line in fileinput.input(os.path.join(CS, fn)):
|
||||
s = string.rstrip(string.lstrip(line))
|
||||
if s.startswith("public enum"):
|
||||
ENUMS.append(s.split(" ")[2])
|
||||
|
||||
|
||||
def enum_replace(line):
|
||||
for e in ENUMS:
|
||||
if line.find("case") != -1:
|
||||
line = line.replace(e + ".", "")
|
||||
elif line.find("== (int)") != -1 or line.find("!= (int)") != -1:
|
||||
line = re.sub("\(int\)" + e + "\.(?P<id>[A-Z0-9_]*)", e + ".\g<id>.toInt()", line)
|
||||
elif line.find("==") != -1 or line.find("!=") != -1:
|
||||
line = re.sub(e + "\.(?P<id>[A-Z0-9_]*)", e + ".\g<id>", line)
|
||||
else:
|
||||
# line = re.sub("\(\(" + e + "\)(?P<rest>.*\(.*)\)", "(" + e + ".values()[\g<rest>])", line)
|
||||
line = re.sub("\(" + e + "\)(?P<rest>.*\(.*\))", e + ".fromInt(\g<rest>)", line)
|
||||
return line
|
||||
|
||||
def replace_generals(a):
|
||||
a = re.sub(" NativeObject", " NativeObject()", a)
|
||||
a = re.sub("\.NativeObject", ".NativeObject()", a)
|
||||
a = re.sub("(?P<h>[\.\(])Id", "\g<h>Id()", a)
|
||||
a = a.replace("(Context ==", "(Context() ==")
|
||||
a = a.replace("(Context,", "(Context(),")
|
||||
a = a.replace("Context.", "Context().")
|
||||
a = a.replace(".nCtx", ".nCtx()")
|
||||
a = a.replace("(nCtx", "(nCtx()")
|
||||
a = re.sub("Context\(\).(?P<id>[^_]*)_DRQ", "Context().\g<id>_DRQ()", a)
|
||||
a = re.sub("ASTKind", "ASTKind()", a)
|
||||
a = re.sub("IsExpr(?P<f>[ ;])", "IsExpr()\g<f>", a)
|
||||
a = re.sub("IsNumeral(?P<f>[ ;])", "IsNumeral()\g<f>", a)
|
||||
a = re.sub("IsInt(?P<f>[ ;])", "IsInt()\g<f>", a)
|
||||
a = re.sub("IsReal(?P<f>[ ;])", "IsReal()\g<f>", a)
|
||||
a = re.sub("IsVar(?P<f>[ ;\)])", "IsVar()\g<f>", a)
|
||||
a = re.sub("FuncDecl.DeclKind", "FuncDecl().DeclKind()", a)
|
||||
a = re.sub("FuncDecl.DomainSize", "FuncDecl().DomainSize()", a)
|
||||
a = re.sub("(?P<h>[=&]) Num(?P<id>[a-zA-Z]*)", "\g<h> Num\g<id>()", a)
|
||||
a = re.sub("= Denominator", "= Denominator()", a)
|
||||
a = re.sub(", BoolSort(?P<f>[\)\.])", ", BoolSort()\g<f>", a)
|
||||
a = re.sub(", RealSort(?P<f>[\)\.])", ", RealSort()\g<f>", a)
|
||||
a = re.sub(", IntSort(?P<f>[\)\.])", ", IntSort()\g<f>", a)
|
||||
a = a.replace("? 1 : 0", "? true : false")
|
||||
if a.find("Native.") != -1 and a.find("!= 0") != -1:
|
||||
a = a.replace("!= 0", "")
|
||||
if a.find("Native.") != -1 and a.find("== 0") != -1:
|
||||
a = a.replace("== 0", "^ true")
|
||||
return a
|
||||
|
||||
def translate(filename):
|
||||
tgtfn = OUTDIR + filename.replace(EXT, ".java")
|
||||
print "Translating " + filename + " to " + tgtfn
|
||||
tgt = open(tgtfn, "w")
|
||||
in_header = 0
|
||||
in_class = 0
|
||||
in_static_class = 0
|
||||
in_javadoc = 0
|
||||
lastindent = 0
|
||||
skip_brace = 0
|
||||
in_getter = ""
|
||||
in_getter_type = ""
|
||||
in_unsupported = 0
|
||||
getters = []
|
||||
in_bracket_op = 0
|
||||
in_getter_get = 0
|
||||
in_getter_set = 0
|
||||
had_ulong_res = 0
|
||||
in_enum = 0
|
||||
missing_foreach_brace = 0
|
||||
foreach_opened_brace = 0
|
||||
for line in fileinput.input(os.path.join(CS, filename)):
|
||||
s = string.rstrip(string.lstrip(line))
|
||||
if in_javadoc:
|
||||
if s.startswith("///"):
|
||||
lastindent = line.find(s);
|
||||
if s.startswith("/// </summary>"):
|
||||
pass
|
||||
else:
|
||||
a = line
|
||||
a = a.replace("<c>", "<code>")
|
||||
a = a.replace("</c>", "</code>")
|
||||
a = a.replace("///"," *")
|
||||
a = a.replace("<returns>","@return ")
|
||||
a = a.replace("</returns>","")
|
||||
tgt.write(a)
|
||||
else:
|
||||
t = ""
|
||||
for i in range(0, lastindent):
|
||||
t += " "
|
||||
tgt.write(t + " **/\n")
|
||||
in_javadoc = 0
|
||||
|
||||
# for i in range(0, len(EXCLUDE_METHODS)):
|
||||
# if filename == EXCLUDE_METHODS[i][0] and s.startswith(EXCLUDE_METHODS[i][1]):
|
||||
# tgt.write(t + "/* Not translated because it would translate to a function with clashing types. */\n")
|
||||
# in_unsupported = 1
|
||||
# break
|
||||
|
||||
|
||||
if in_unsupported:
|
||||
if s == "}":
|
||||
in_unsupported = 0
|
||||
elif not in_javadoc:
|
||||
if not in_header and s.find("/*++") != -1:
|
||||
in_header = 1
|
||||
tgt.write("/**\n")
|
||||
elif in_header and s.startswith("--*/"):
|
||||
in_header = 0
|
||||
tgt.write(" * This file was automatically generated from " + filename + " \n")
|
||||
tgt.write(" **/\n")
|
||||
tgt.write("\npackage com.Microsoft.Z3;\n\n")
|
||||
tgt.write("import java.math.BigInteger;\n")
|
||||
tgt.write("import java.util.*;\n")
|
||||
tgt.write("import java.lang.Exception;\n")
|
||||
tgt.write("import com.Microsoft.Z3.Enumerations.*;\n")
|
||||
elif in_header == 1:
|
||||
# tgt.write(" * " + line.replace(filename, tgtfn))
|
||||
pass
|
||||
elif s.startswith("using"):
|
||||
if s.find("System.Diagnostics.Contracts") == -1:
|
||||
tgt.write("/* " + s + " */\n")
|
||||
elif s.startswith("namespace"):
|
||||
pass
|
||||
elif s.startswith("public") and s.find("operator") != -1 and (s.find("==") != -1 or s.find("!=") != -1):
|
||||
t = ""
|
||||
for i in range(0, line.find(s)+1):
|
||||
t += " "
|
||||
tgt.write(t + "/* Overloaded operators are not translated. */\n")
|
||||
in_unsupported = 1
|
||||
elif s.startswith("public enum"):
|
||||
tgt.write(line.replace("enum", "class"))
|
||||
in_enum = 1
|
||||
elif in_enum == 1:
|
||||
if s == "}":
|
||||
tgt.write(line)
|
||||
in_enum = 0
|
||||
else:
|
||||
line = re.sub("(?P<id>.*)\W*=\W*(?P<val>[^\n,])", "public static final int \g<id> = \g<val>;", line)
|
||||
tgt.write(line.replace(",",""))
|
||||
elif s.startswith("public class") or s.startswith("internal class") or s.startswith("internal abstract class"):
|
||||
a = line.replace(":", "extends").replace("internal ", "")
|
||||
a = a.replace(", IComparable", "")
|
||||
a = type_replace(a)
|
||||
tgt.write(a)
|
||||
in_class = 1
|
||||
in_static_class = 0
|
||||
elif s.startswith("public static class") or s.startswith("abstract class"):
|
||||
tgt.write(line.replace(":", "extends").replace("static", "final"))
|
||||
in_class = 1
|
||||
in_static_class = 1
|
||||
elif s.startswith("/// <summary>"):
|
||||
tgt.write(line.replace("/// <summary>", "/**"))
|
||||
in_javadoc = 1
|
||||
elif skip_brace and s == "{":
|
||||
skip_brace = 0
|
||||
elif ((s.find("public") != -1 or s.find("protected") != -1) and s.find("class") == -1 and s.find("event") == -1 and s.find("(") == -1) or s.startswith("internal virtual IntPtr NativeObject") or s.startswith("internal Context Context"):
|
||||
if (s.startswith("new")):
|
||||
s = s[3:]
|
||||
s = s.replace("internal virtual", "")
|
||||
s = s.replace("internal", "")
|
||||
tokens = s.split(" ")
|
||||
# print "TOKENS: " + str(len(tokens))
|
||||
if len(tokens) == 3:
|
||||
in_getter = tokens[2]
|
||||
in_getter_type = type_replace((tokens[0] + " " + tokens[1]))
|
||||
if in_static_class:
|
||||
in_getter_type = in_getter_type.replace("static", "")
|
||||
lastindent = line.find(s)
|
||||
skip_brace = 1
|
||||
getters.append(in_getter)
|
||||
elif len(tokens) == 4:
|
||||
if tokens[2].startswith("this["):
|
||||
in_bracket_op = 1
|
||||
in_getter = type_replace(tokens[2]).replace("this[", "get(")
|
||||
in_getter += " " + tokens[3].replace("]", ")")
|
||||
in_getter_type = type_replace(tokens[0] + " " + tokens[1])
|
||||
else:
|
||||
in_getter = tokens[3]
|
||||
in_getter_type = type_replace(tokens[0] + " " + tokens[1] + " " + tokens[2])
|
||||
if in_static_class:
|
||||
in_getter_type = in_getter_type.replace("static", "")
|
||||
lastindent = line.find(s)
|
||||
skip_brace = 1
|
||||
getters.append(in_getter)
|
||||
else:
|
||||
in_getter = tokens[2]
|
||||
in_getter_type = type_replace(tokens[0] + " " + tokens[1])
|
||||
if tokens[2].startswith("this["):
|
||||
lastindent = line.find(s)
|
||||
t = ""
|
||||
for i in range(0, lastindent): t += " "
|
||||
tgt.write(t + "/* operator this[] not translated */\n ")
|
||||
in_unsupported = 1
|
||||
else:
|
||||
if in_static_class:
|
||||
in_getter_type = in_getter_type.replace("static", "")
|
||||
rest = s[s.find("get ") + 4:-1]
|
||||
subst_getters(rest, getters)
|
||||
rest = type_replace(rest)
|
||||
rest = rename_native(rest)
|
||||
rest = replace_generals(rest)
|
||||
rest = enum_replace(rest)
|
||||
t = ""
|
||||
for i in range(0, lastindent):
|
||||
t += " "
|
||||
tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n")
|
||||
if rest.find("}") == -1:
|
||||
in_getter_get = 1
|
||||
else:
|
||||
getters.append(in_getter)
|
||||
in_getter = ""
|
||||
in_getter_type = ""
|
||||
print "ACC: " + s + " --> " + in_getter
|
||||
elif s.find("{ get {") != -1:
|
||||
line = type_replace(line)
|
||||
line = line.replace("internal ", "")
|
||||
d = line[0:line.find("{ get")]
|
||||
rest = line[line.find("{ get")+5:]
|
||||
rest = rest.replace("} }", "}")
|
||||
rest = re.sub("Contract.\w+\([\s\S]*\);", "", rest)
|
||||
subst_getters(rest, getters)
|
||||
rest = rename_native(rest)
|
||||
rest = replace_generals(rest)
|
||||
rest = enum_replace(rest)
|
||||
if in_bracket_op:
|
||||
tgt.write(d + rest)
|
||||
else:
|
||||
tgt.write(d + "()" + rest)
|
||||
print "ACC: " + s + " --> " + in_getter
|
||||
elif in_getter != "" and s.startswith("get"):
|
||||
t = ""
|
||||
for i in range(0, lastindent):
|
||||
t += " "
|
||||
if len(s) > 3: rest = s[3:]
|
||||
else: rest = ""
|
||||
subst_getters(rest, getters)
|
||||
rest = type_replace(rest)
|
||||
rest = rename_native(rest)
|
||||
rest = replace_generals(rest)
|
||||
rest = enum_replace(rest)
|
||||
if in_bracket_op:
|
||||
tgt.write(t + in_getter_type + " " + in_getter + " " + rest + "\n")
|
||||
else:
|
||||
tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n")
|
||||
if rest.find("}") == -1:
|
||||
in_getter_get = 1
|
||||
elif in_getter != "" and s.startswith("set"):
|
||||
t = ""
|
||||
for i in range(0, lastindent):
|
||||
t += " "
|
||||
if len(s) > 3: rest = type_replace(s[3:])
|
||||
else: rest = ""
|
||||
subst_getters(rest, getters)
|
||||
rest = rest.replace("(Integer)value", "Integer(value)")
|
||||
rest = type_replace(rest)
|
||||
rest = rename_native(rest)
|
||||
rest = replace_generals(rest)
|
||||
rest = enum_replace(rest)
|
||||
ac_acc = in_getter_type[:in_getter_type.find(' ')]
|
||||
ac_type = in_getter_type[in_getter_type.find(' ')+1:]
|
||||
if in_bracket_op:
|
||||
in_getter = in_getter.replace("get", "set").replace(")", "")
|
||||
tgt.write(t + ac_acc + " void " + in_getter + ", " + ac_type + " value) " + rest + "\n")
|
||||
else:
|
||||
tgt.write(t + ac_acc + " void set" + in_getter + "(" + ac_type + " value) " + rest + "\n")
|
||||
if rest.find("}") == -1:
|
||||
in_getter_set = 1
|
||||
elif in_getter != "" and in_getter_get == 1 and s == "}":
|
||||
tgt.write(line)
|
||||
in_getter_get = 0
|
||||
elif in_getter != "" and in_getter_set == 1 and s == "}":
|
||||
tgt.write(line)
|
||||
in_getter_set = 0
|
||||
elif in_getter != "" and in_getter_get == 0 and in_getter_set == 0 and s == "}":
|
||||
in_getter = ""
|
||||
in_getter_type == ""
|
||||
in_bracket_op = 0
|
||||
skip_brace = 0
|
||||
elif s.startswith("uint ") and s.find("=") == -1:
|
||||
line = line.replace("uint", "Integer", line)
|
||||
line = re.sub("(?P<n>\w+)(?P<c>[,;])", "\g<n>\g<c>", line)
|
||||
tgt.write(line);
|
||||
elif (not in_class and (s.startswith("{") or s.startswith("}"))) or s.startswith("[") or s.startswith("#"):
|
||||
# tgt.write("// Skipping: " + s)
|
||||
pass
|
||||
elif line == "}\n":
|
||||
pass
|
||||
else:
|
||||
# indent = line.find(s)
|
||||
# tgt.write("// LINE: " + line)
|
||||
if line.find(": base") != -1:
|
||||
line = re.sub(": base\((?P<p>[^\{]*)\)", "{ super(\g<p>);", line)
|
||||
line = line[4:]
|
||||
obraces = line.count("{")
|
||||
cbraces = line.count("}")
|
||||
mbraces = obraces - cbraces
|
||||
# tgt.write("// obraces = " + str(obraces) + "\n")
|
||||
if obraces == 1:
|
||||
skip_brace = 1
|
||||
else:
|
||||
for i in range(0, mbraces):
|
||||
line = line.replace("\n", "}\n")
|
||||
if (s.find("public") != -1 or s.find("protected") != -1 or s.find("internal") != -1) and s.find("(") != -1:
|
||||
line = re.sub(" = [\w.]+(?P<d>[,;\)])", "\g<d>", line)
|
||||
a = type_replace(line)
|
||||
a = enum_replace(a)
|
||||
a = re.sub("(?P<d>[\(, ])params ", "\g<d>", a)
|
||||
a = a.replace("base.", "super.")
|
||||
a = re.sub("Contract.\w+\([\s\S]*\);", "", a)
|
||||
a = rename_native(a)
|
||||
a = re.sub("~\w+\(\)", "protected void finalize()", a)
|
||||
|
||||
if missing_foreach_brace == 1:
|
||||
# a = a.replace("\n", " // checked " + str(foreach_opened_brace) + "\n")
|
||||
if foreach_opened_brace == 0 and a.find("{") != -1:
|
||||
foreach_opened_brace = 1
|
||||
elif foreach_opened_brace == 0 and a.find("}") == -1:
|
||||
a = a.replace("\n", "}}\n")
|
||||
foreach_opened_brace = 0
|
||||
missing_foreach_brace = 0
|
||||
elif foreach_opened_brace == 1 and a.find("}") != -1:
|
||||
a = a.replace("\n", "}}\n")
|
||||
foreach_opened_brace = 0
|
||||
missing_foreach_brace = 0
|
||||
|
||||
# if a.find("foreach") != -1:
|
||||
# missing_foreach_brace = 1
|
||||
# a = re.sub("foreach\s*\((?P<t>[\w <>,]+)\s+(?P<i>\w+)\s+in\s+(?P<w>\w+)\)",
|
||||
# "{ Iterator fe_i = \g<w>.iterator(); while (fe_i.hasNext()) { \g<t> \g<i> = (long)fe_i.next(); ",
|
||||
# a)
|
||||
a = re.sub("foreach\s*\((?P<t>[\w <>,]+)\s+(?P<i>\w+)\s+in\s+(?P<w>\w+)\)",
|
||||
"for (\g<t> \g<i>: \g<w>)",
|
||||
a)
|
||||
if a.find("long o: m_queue") != -1:
|
||||
a = a.replace("long", "Long")
|
||||
a = a.replace("readonly ", "")
|
||||
a = a.replace("const ", "final ")
|
||||
a = a.replace("String ToString", "String toString")
|
||||
a = a.replace(".ToString", ".toString")
|
||||
a = a.replace("internal ", "")
|
||||
a = a.replace("new static", "static")
|
||||
a = a.replace("new public", "public")
|
||||
a = a.replace("override ", "")
|
||||
a = a.replace("virtual ", "")
|
||||
a = a.replace("o as AST", "(AST) o")
|
||||
a = a.replace("o as Sort", "(Sort) o")
|
||||
a = a.replace("other as AST", "(AST) other")
|
||||
a = a.replace("o as FuncDecl", "(FuncDecl) o")
|
||||
a = a.replace("IntPtr obj", "long obj")
|
||||
a = a.replace("IntPtr o", "long o")
|
||||
a = a.replace("new long()", "0")
|
||||
a = a.replace("long.Zero", "0")
|
||||
a = a.replace("object o", "Object o")
|
||||
a = a.replace("object other", "Object other")
|
||||
a = a.replace("IntPtr res = IntPtr.Zero;", "Native.IntPtr res = new Native.IntPtr();")
|
||||
a = a.replace("out res", "res")
|
||||
a = a.replace("GC.ReRegisterForFinalize(m_ctx);", "")
|
||||
a = a.replace("GC.SuppressFinalize(this);", "")
|
||||
a = a.replace(".Length", ".length")
|
||||
a = a.replace("m_queue.Count", "m_queue.size()")
|
||||
a = a.replace("m_queue.Add", "m_queue.add")
|
||||
a = a.replace("m_queue.Clear", "m_queue.clear")
|
||||
a = a.replace("for (long ", "for (int ")
|
||||
a = a.replace("ReferenceEquals(Context, ctx)", "Context() == ctx")
|
||||
a = a.replace("BigInteger.Parse", "new BigInteger")
|
||||
if had_ulong_res == 0 and a.find("ulong res = 0") != -1:
|
||||
a = a.replace("ulong res = 0;", "LongPtr res = new LongPtr();")
|
||||
elif had_ulong_res == 1:
|
||||
a = a.replace("ref res)", "res)")
|
||||
if a.find("return res;") != -1:
|
||||
a = a.replace("return res;", "return res.value;")
|
||||
had_ulong_res = 0
|
||||
a = a.replace("lock (", "synchronized (")
|
||||
if in_static_class:
|
||||
a = a.replace("static", "")
|
||||
a = re.sub("ref (?P<id>\w+)", "\g<id>", a)
|
||||
subst_getters(a, getters)
|
||||
a = re.sub("NativeObject = (?P<rest>.*);", "setNativeObject(\g<rest>);", a)
|
||||
a = replace_generals(a)
|
||||
tgt.write(a)
|
||||
tgt.close()
|
||||
|
||||
mk_java_bindings()
|
|
@ -1,5 +1,5 @@
|
|||
/*++
|
||||
Copyright (c) 2010 Microsoft Corporation
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ Z3 exceptions:
|
|||
... n = x + y
|
||||
... except Z3Exception as ex:
|
||||
... print("failed: %s" % ex)
|
||||
failed: 'sort mismatch'
|
||||
failed: sort mismatch
|
||||
"""
|
||||
from z3core import *
|
||||
from z3types import *
|
||||
|
@ -1396,7 +1396,7 @@ def BoolVector(prefix, sz, ctx=None):
|
|||
return [ Bool('%s__%s' % (prefix, i)) for i in range(sz) ]
|
||||
|
||||
def FreshBool(prefix='b', ctx=None):
|
||||
"""Return a fresh Bolean constant in the given context using the given prefix.
|
||||
"""Return a fresh Boolean constant in the given context using the given prefix.
|
||||
|
||||
If `ctx=None`, then the global context is used.
|
||||
|
||||
|
@ -6162,7 +6162,7 @@ class Fixedpoint(Z3PPObject):
|
|||
Z3_fixedpoint_add_rule(self.ctx.ref(), self.fixedpoint, head.as_ast(), name)
|
||||
else:
|
||||
body = _get_args(body)
|
||||
f = self.abstract(Implies(And(body),head))
|
||||
f = self.abstract(Implies(And(body,self.ctx),head))
|
||||
Z3_fixedpoint_add_rule(self.ctx.ref(), self.fixedpoint, f.as_ast(), name)
|
||||
|
||||
def rule(self, head, body = None, name = None):
|
||||
|
@ -6190,7 +6190,7 @@ class Fixedpoint(Z3PPObject):
|
|||
if sz == 1:
|
||||
query = query[0]
|
||||
else:
|
||||
query = And(query)
|
||||
query = And(query, self.ctx)
|
||||
query = self.abstract(query, False)
|
||||
r = Z3_fixedpoint_query(self.ctx.ref(), self.fixedpoint, query.as_ast())
|
||||
return CheckSatResult(r)
|
||||
|
@ -6209,7 +6209,7 @@ class Fixedpoint(Z3PPObject):
|
|||
name = ""
|
||||
name = to_symbol(name, self.ctx)
|
||||
body = _get_args(body)
|
||||
f = self.abstract(Implies(And(body),head))
|
||||
f = self.abstract(Implies(And(body, self.ctx),head))
|
||||
Z3_fixedpoint_update_rule(self.ctx.ref(), self.fixedpoint, f.as_ast(), name)
|
||||
|
||||
def get_answer(self):
|
||||
|
|
|
@ -23,7 +23,19 @@ Notes:
|
|||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
\defgroup capi C API
|
||||
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
@name Algebraic Numbers API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if \c can be used as value in the Z3 real algebraic
|
||||
|
@ -218,6 +230,8 @@ extern "C" {
|
|||
*/
|
||||
int Z3_API Z3_algebraic_eval(__in Z3_context c, __in Z3_ast p, __in unsigned n, __in Z3_ast a[]);
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
|
|
@ -773,7 +773,6 @@ typedef enum
|
|||
|
||||
The premises of the rules is a sequence of clauses.
|
||||
The first clause argument is the main clause of the rule.
|
||||
One literal from the second, third, .. clause is resolved
|
||||
with a literal from the first (main) clause.
|
||||
|
||||
Premises of the rules are of the form
|
||||
|
@ -1159,8 +1158,8 @@ typedef enum {
|
|||
- Z3_FILE_ACCESS_ERRROR: A file could not be accessed.
|
||||
- Z3_INVALID_USAGE: API call is invalid in the current state.
|
||||
- Z3_INTERNAL_FATAL: An error internal to Z3 occurred.
|
||||
- Z3_DEC_REF_ERROR: Trying to decrement the reference counter of an AST that was deleted or the reference counter was not initialized\mlonly.\endmlonly\conly with #Z3_inc_ref.
|
||||
- Z3_EXCEPTION: Internal Z3 exception. Additional details can be retrieved using \mlonly #Z3_get_error_msg. \endmlonly \conly #Z3_get_error_msg_ex.
|
||||
- Z3_DEC_REF_ERROR: Trying to decrement the reference counter of an AST that was deleted or the reference counter was not initialized \mlonly.\endmlonly \conly with #Z3_inc_ref.
|
||||
- Z3_EXCEPTION: Internal Z3 exception. Additional details can be retrieved using #Z3_get_error_msg.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
@ -1304,8 +1303,6 @@ extern "C" {
|
|||
|
||||
\sa Z3_global_param_set
|
||||
|
||||
The caller must invoke #Z3_global_param_del_value to delete the value returned at \c param_value.
|
||||
|
||||
\remark This function cannot be invoked simultaneously from different threads without synchronization.
|
||||
The result string stored in param_value is stored in shared location.
|
||||
|
||||
|
|
|
@ -24,7 +24,14 @@ extern "C" {
|
|||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
@name Interpolation
|
||||
\defgroup capi C API
|
||||
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
@name Interpolation API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
|
@ -184,6 +191,8 @@ extern "C" {
|
|||
\param cnsts Returns sequence of formulas (do not free)
|
||||
\param parents Returns the parents vector (or NULL for sequence)
|
||||
\param error Returns an error message in case of failure (do not free the string)
|
||||
\param num_theory Number of theory terms
|
||||
\param theory Theory terms
|
||||
|
||||
Returns true on success.
|
||||
|
||||
|
@ -232,6 +241,8 @@ extern "C" {
|
|||
\param parents The parents vector (or NULL for sequence)
|
||||
\param interps The interpolant to check
|
||||
\param error Returns an error message if interpolant incorrect (do not free the string)
|
||||
\param num_theory Number of theory terms
|
||||
\param theory Theory terms
|
||||
|
||||
Return value is Z3_L_TRUE if interpolant is verified, Z3_L_FALSE if
|
||||
incorrect, and Z3_L_UNDEF if unknown.
|
||||
|
@ -258,6 +269,8 @@ extern "C" {
|
|||
\param cnsts Array of constraints
|
||||
\param parents The parents vector (or NULL for sequence)
|
||||
\param filename The file name to write
|
||||
\param num_theory Number of theory terms
|
||||
\param theory Theory terms
|
||||
|
||||
def_API('Z3_write_interpolation_problem', VOID, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(STRING), _in(UINT), _in_array(5, AST)))
|
||||
*/
|
||||
|
@ -270,6 +283,9 @@ extern "C" {
|
|||
__in unsigned num_theory,
|
||||
__in_ecount(num_theory) Z3_ast theory[]);
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // __cplusplus
|
||||
|
|
|
@ -24,6 +24,19 @@ Notes:
|
|||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
\defgroup capi C API
|
||||
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
|
||||
/**
|
||||
@name Polynomials API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
\brief Return the nonzero subresultants of \c p and \c q with respect to the "variable" \c x.
|
||||
|
||||
|
@ -38,6 +51,9 @@ extern "C" {
|
|||
Z3_ast_vector Z3_API Z3_polynomial_subresultants(__in Z3_context c, __in Z3_ast p, __in Z3_ast q, __in Z3_ast x);
|
||||
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // __cplusplus
|
||||
|
|
|
@ -25,6 +25,18 @@ Notes:
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
\defgroup capi C API
|
||||
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
@name Real Closed Fields API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
\brief Delete a RCF numeral created using the RCF API.
|
||||
|
@ -192,6 +204,9 @@ extern "C" {
|
|||
*/
|
||||
void Z3_API Z3_rcf_get_numerator_denominator(__in Z3_context c, __in Z3_rcf_num a, __out Z3_rcf_num * n, __out Z3_rcf_num * d);
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // __cplusplus
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue