mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 13:28:47 +00:00
Merge branch 'master' of https://github.com/z3prover/z3
This commit is contained in:
commit
8b506375e4
|
@ -15,16 +15,16 @@ Copyright (c) 2015 Microsoft Corporation
|
||||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||||
DWORD ul_reason_for_call,
|
DWORD ul_reason_for_call,
|
||||||
LPVOID lpReserved
|
LPVOID lpReserved
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
switch (ul_reason_for_call)
|
switch (ul_reason_for_call)
|
||||||
{
|
{
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_THREAD_DETACH:
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,78 +43,78 @@ add_custom_command(OUTPUT "${Z3_DOTNET_CONST_FILE}"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(Z3_DOTNET_ASSEMBLY_SOURCES_IN_SRC_TREE
|
set(Z3_DOTNET_ASSEMBLY_SOURCES_IN_SRC_TREE
|
||||||
AlgebraicNum.cs
|
AlgebraicNum.cs
|
||||||
ApplyResult.cs
|
ApplyResult.cs
|
||||||
ArithExpr.cs
|
ArithExpr.cs
|
||||||
ArithSort.cs
|
ArithSort.cs
|
||||||
ArrayExpr.cs
|
ArrayExpr.cs
|
||||||
ArraySort.cs
|
ArraySort.cs
|
||||||
AST.cs
|
AST.cs
|
||||||
ASTMap.cs
|
ASTMap.cs
|
||||||
ASTVector.cs
|
ASTVector.cs
|
||||||
BitVecExpr.cs
|
BitVecExpr.cs
|
||||||
BitVecNum.cs
|
BitVecNum.cs
|
||||||
BitVecSort.cs
|
BitVecSort.cs
|
||||||
BoolExpr.cs
|
BoolExpr.cs
|
||||||
BoolSort.cs
|
BoolSort.cs
|
||||||
Constructor.cs
|
Constructor.cs
|
||||||
ConstructorList.cs
|
ConstructorList.cs
|
||||||
Context.cs
|
Context.cs
|
||||||
DatatypeExpr.cs
|
DatatypeExpr.cs
|
||||||
DatatypeSort.cs
|
DatatypeSort.cs
|
||||||
Deprecated.cs
|
Deprecated.cs
|
||||||
EnumSort.cs
|
EnumSort.cs
|
||||||
Expr.cs
|
Expr.cs
|
||||||
FiniteDomainExpr.cs
|
FiniteDomainExpr.cs
|
||||||
FiniteDomainNum.cs
|
FiniteDomainNum.cs
|
||||||
FiniteDomainSort.cs
|
FiniteDomainSort.cs
|
||||||
Fixedpoint.cs
|
Fixedpoint.cs
|
||||||
FPExpr.cs
|
FPExpr.cs
|
||||||
FPNum.cs
|
FPNum.cs
|
||||||
FPRMExpr.cs
|
FPRMExpr.cs
|
||||||
FPRMNum.cs
|
FPRMNum.cs
|
||||||
FPRMSort.cs
|
FPRMSort.cs
|
||||||
FPSort.cs
|
FPSort.cs
|
||||||
FuncDecl.cs
|
FuncDecl.cs
|
||||||
FuncInterp.cs
|
FuncInterp.cs
|
||||||
Global.cs
|
Global.cs
|
||||||
Goal.cs
|
Goal.cs
|
||||||
IDecRefQueue.cs
|
IDecRefQueue.cs
|
||||||
InterpolationContext.cs
|
InterpolationContext.cs
|
||||||
IntExpr.cs
|
IntExpr.cs
|
||||||
IntNum.cs
|
IntNum.cs
|
||||||
IntSort.cs
|
IntSort.cs
|
||||||
IntSymbol.cs
|
IntSymbol.cs
|
||||||
ListSort.cs
|
ListSort.cs
|
||||||
Log.cs
|
Log.cs
|
||||||
Model.cs
|
Model.cs
|
||||||
Optimize.cs
|
Optimize.cs
|
||||||
ParamDescrs.cs
|
ParamDescrs.cs
|
||||||
Params.cs
|
Params.cs
|
||||||
Pattern.cs
|
Pattern.cs
|
||||||
Probe.cs
|
Probe.cs
|
||||||
Quantifier.cs
|
Quantifier.cs
|
||||||
RatNum.cs
|
RatNum.cs
|
||||||
RealExpr.cs
|
RealExpr.cs
|
||||||
RealSort.cs
|
RealSort.cs
|
||||||
ReExpr.cs
|
ReExpr.cs
|
||||||
RelationSort.cs
|
RelationSort.cs
|
||||||
ReSort.cs
|
ReSort.cs
|
||||||
SeqExpr.cs
|
SeqExpr.cs
|
||||||
SeqSort.cs
|
SeqSort.cs
|
||||||
SetSort.cs
|
SetSort.cs
|
||||||
Solver.cs
|
Solver.cs
|
||||||
Sort.cs
|
Sort.cs
|
||||||
Statistics.cs
|
Statistics.cs
|
||||||
Status.cs
|
Status.cs
|
||||||
StringSymbol.cs
|
StringSymbol.cs
|
||||||
Symbol.cs
|
Symbol.cs
|
||||||
Tactic.cs
|
Tactic.cs
|
||||||
TupleSort.cs
|
TupleSort.cs
|
||||||
UninterpretedSort.cs
|
UninterpretedSort.cs
|
||||||
Version.cs
|
Version.cs
|
||||||
Z3Exception.cs
|
Z3Exception.cs
|
||||||
Z3Object.cs
|
Z3Object.cs
|
||||||
)
|
)
|
||||||
|
|
||||||
set(Z3_DOTNET_ASSEMBLY_SOURCES "")
|
set(Z3_DOTNET_ASSEMBLY_SOURCES "")
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace Microsoft.Z3
|
||||||
private BoolSort m_boolSort = null;
|
private BoolSort m_boolSort = null;
|
||||||
private IntSort m_intSort = null;
|
private IntSort m_intSort = null;
|
||||||
private RealSort m_realSort = null;
|
private RealSort m_realSort = null;
|
||||||
private SeqSort m_stringSort = null;
|
private SeqSort m_stringSort = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the Boolean sort of the context.
|
/// Retrieves the Boolean sort of the context.
|
||||||
|
@ -2426,7 +2426,7 @@ namespace Microsoft.Z3
|
||||||
public SeqExpr IntToString(Expr e)
|
public SeqExpr IntToString(Expr e)
|
||||||
{
|
{
|
||||||
Contract.Requires(e != null);
|
Contract.Requires(e != null);
|
||||||
Contract.Requires(e is ArithExpr);
|
Contract.Requires(e is ArithExpr);
|
||||||
Contract.Ensures(Contract.Result<SeqExpr>() != null);
|
Contract.Ensures(Contract.Result<SeqExpr>() != null);
|
||||||
return new SeqExpr(this, Native.Z3_mk_int_to_str(nCtx, e.NativeObject));
|
return new SeqExpr(this, Native.Z3_mk_int_to_str(nCtx, e.NativeObject));
|
||||||
}
|
}
|
||||||
|
@ -2690,7 +2690,7 @@ namespace Microsoft.Z3
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a range expression.
|
/// Create a range expression.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReExpr MkRange(SeqExpr lo, SeqExpr hi)
|
public ReExpr MkRange(SeqExpr lo, SeqExpr hi)
|
||||||
{
|
{
|
||||||
Contract.Requires(lo != null);
|
Contract.Requires(lo != null);
|
||||||
Contract.Requires(hi != null);
|
Contract.Requires(hi != null);
|
||||||
|
|
|
@ -809,55 +809,55 @@ namespace Microsoft.Z3
|
||||||
/// Check whether expression is a concatentation.
|
/// Check whether expression is a concatentation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsConcat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONCAT; } }
|
public bool IsConcat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONCAT; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether expression is a prefix.
|
/// Check whether expression is a prefix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsPrefix { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_PREFIX; } }
|
public bool IsPrefix { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_PREFIX; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether expression is a suffix.
|
/// Check whether expression is a suffix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsSuffix { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_SUFFIX; } }
|
public bool IsSuffix { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_SUFFIX; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether expression is a contains.
|
/// Check whether expression is a contains.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsContains { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONTAINS; } }
|
public bool IsContains { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONTAINS; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether expression is an extract.
|
/// Check whether expression is an extract.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsExtract { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_EXTRACT; } }
|
public bool IsExtract { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_EXTRACT; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether expression is a replace.
|
/// Check whether expression is a replace.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsReplace { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_REPLACE; } }
|
public bool IsReplace { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_REPLACE; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether expression is an at.
|
/// Check whether expression is an at.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsAt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_AT; } }
|
public bool IsAt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_AT; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether expression is a sequence length.
|
/// Check whether expression is a sequence length.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsLength { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_LENGTH; } }
|
public bool IsLength { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_LENGTH; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether expression is a sequence index.
|
/// Check whether expression is a sequence index.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Boolean</returns>
|
/// <returns>a Boolean</returns>
|
||||||
public bool IsIndex { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_INDEX; } }
|
public bool IsIndex { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_INDEX; } }
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve a lower bound for the objective handle.
|
/// Retrieve a lower bound for the objective handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ArithExpr Lower
|
public ArithExpr Lower
|
||||||
{
|
{
|
||||||
get { return opt.GetLower(handle); }
|
get { return opt.GetLower(handle); }
|
||||||
|
@ -131,7 +131,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve an upper bound for the objective handle.
|
/// Retrieve an upper bound for the objective handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ArithExpr Upper
|
public ArithExpr Upper
|
||||||
{
|
{
|
||||||
get { return opt.GetUpper(handle); }
|
get { return opt.GetUpper(handle); }
|
||||||
|
@ -139,7 +139,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve the value of an objective.
|
/// Retrieve the value of an objective.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ArithExpr Value
|
public ArithExpr Value
|
||||||
{
|
{
|
||||||
get { return Lower; }
|
get { return Lower; }
|
||||||
|
@ -147,7 +147,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve a lower bound for the objective handle.
|
/// Retrieve a lower bound for the objective handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ArithExpr[] LowerAsVector
|
public ArithExpr[] LowerAsVector
|
||||||
{
|
{
|
||||||
get { return opt.GetLowerAsVector(handle); }
|
get { return opt.GetLowerAsVector(handle); }
|
||||||
|
@ -155,7 +155,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve an upper bound for the objective handle.
|
/// Retrieve an upper bound for the objective handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ArithExpr[] UpperAsVector
|
public ArithExpr[] UpperAsVector
|
||||||
{
|
{
|
||||||
get { return opt.GetUpperAsVector(handle); }
|
get { return opt.GetUpperAsVector(handle); }
|
||||||
|
@ -240,7 +240,7 @@ namespace Microsoft.Z3
|
||||||
/// Declare an arithmetical maximization objective.
|
/// Declare an arithmetical maximization objective.
|
||||||
/// Return a handle to the objective. The handle is used as
|
/// Return a handle to the objective. The handle is used as
|
||||||
/// to retrieve the values of objectives after calling Check.
|
/// to retrieve the values of objectives after calling Check.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Handle MkMaximize(ArithExpr e)
|
public Handle MkMaximize(ArithExpr e)
|
||||||
{
|
{
|
||||||
return new Handle(this, Native.Z3_optimize_maximize(Context.nCtx, NativeObject, e.NativeObject));
|
return new Handle(this, Native.Z3_optimize_maximize(Context.nCtx, NativeObject, e.NativeObject));
|
||||||
|
@ -249,7 +249,7 @@ namespace Microsoft.Z3
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Declare an arithmetical minimization objective.
|
/// Declare an arithmetical minimization objective.
|
||||||
/// Similar to MkMaximize.
|
/// Similar to MkMaximize.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Handle MkMinimize(ArithExpr e)
|
public Handle MkMinimize(ArithExpr e)
|
||||||
{
|
{
|
||||||
return new Handle(this, Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject));
|
return new Handle(this, Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject));
|
||||||
|
@ -257,7 +257,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve a lower bound for the objective handle.
|
/// Retrieve a lower bound for the objective handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ArithExpr GetLower(uint index)
|
private ArithExpr GetLower(uint index)
|
||||||
{
|
{
|
||||||
return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
|
return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
|
||||||
|
@ -266,7 +266,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve an upper bound for the objective handle.
|
/// Retrieve an upper bound for the objective handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ArithExpr GetUpper(uint index)
|
private ArithExpr GetUpper(uint index)
|
||||||
{
|
{
|
||||||
return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index));
|
return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index));
|
||||||
|
@ -274,7 +274,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve a lower bound for the objective handle.
|
/// Retrieve a lower bound for the objective handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ArithExpr[] GetLowerAsVector(uint index)
|
private ArithExpr[] GetLowerAsVector(uint index)
|
||||||
{
|
{
|
||||||
ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_lower_as_vector(Context.nCtx, NativeObject, index));
|
ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_lower_as_vector(Context.nCtx, NativeObject, index));
|
||||||
|
@ -284,29 +284,29 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve an upper bound for the objective handle.
|
/// Retrieve an upper bound for the objective handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ArithExpr[] GetUpperAsVector(uint index)
|
private ArithExpr[] GetUpperAsVector(uint index)
|
||||||
{
|
{
|
||||||
ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_upper_as_vector(Context.nCtx, NativeObject, index));
|
ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_upper_as_vector(Context.nCtx, NativeObject, index));
|
||||||
return v.ToArithExprArray();
|
return v.ToArithExprArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return a string the describes why the last to check returned unknown
|
/// Return a string the describes why the last to check returned unknown
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public String ReasonUnknown
|
public String ReasonUnknown
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Contract.Ensures(Contract.Result<string>() != null);
|
Contract.Ensures(Contract.Result<string>() != null);
|
||||||
return Native.Z3_optimize_get_reason_unknown(Context.nCtx, NativeObject);
|
return Native.Z3_optimize_get_reason_unknown(Context.nCtx, NativeObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Print the context to a string (SMT-LIB parseable benchmark).
|
/// Print the context to a string (SMT-LIB parseable benchmark).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Native.Z3_optimize_to_string(Context.nCtx, NativeObject);
|
return Native.Z3_optimize_to_string(Context.nCtx, NativeObject);
|
||||||
|
|
|
@ -8,41 +8,41 @@ EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
Release|x86 = Release|x86
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.Build.0 = Debug|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.Build.0 = Debug|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.ActiveCfg = Release|x64
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.ActiveCfg = Release|x64
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.Build.0 = Release|x64
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.Build.0 = Release|x64
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.ActiveCfg = Release|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.Build.0 = Release|Any CPU
|
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.ActiveCfg = Debug|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.Build.0 = Debug|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.Build.0 = Debug|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.ActiveCfg = Release|x64
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.ActiveCfg = Release|x64
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.Build.0 = Release|x64
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.Build.0 = Release|x64
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.ActiveCfg = Release|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.Build.0 = Release|Any CPU
|
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class ASTVector extends Z3Object {
|
||||||
Expr[] res = new Expr[n];
|
Expr[] res = new Expr[n];
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
res[i] = Expr.create(getContext(), get(i).getNativeObject());
|
res[i] = Expr.create(getContext(), get(i).getNativeObject());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,57 +22,57 @@ package com.microsoft.z3;
|
||||||
**/
|
**/
|
||||||
public class AlgebraicNum extends ArithExpr
|
public class AlgebraicNum extends ArithExpr
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return a upper bound for a given real algebraic number. The interval
|
* Return a upper bound for a given real algebraic number. The interval
|
||||||
* isolating the number is smaller than 1/10^{@code precision}.
|
* isolating the number is smaller than 1/10^{@code precision}.
|
||||||
*
|
*
|
||||||
* @see Expr#isAlgebraicNumber
|
* @see Expr#isAlgebraicNumber
|
||||||
* @param precision the precision of the result
|
* @param precision the precision of the result
|
||||||
*
|
*
|
||||||
* @return A numeral Expr of sort Real
|
* @return A numeral Expr of sort Real
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
**/
|
**/
|
||||||
public RatNum toUpper(int precision)
|
public RatNum toUpper(int precision)
|
||||||
{
|
{
|
||||||
|
|
||||||
return new RatNum(getContext(), Native.getAlgebraicNumberUpper(getContext()
|
return new RatNum(getContext(), Native.getAlgebraicNumberUpper(getContext()
|
||||||
.nCtx(), getNativeObject(), precision));
|
.nCtx(), getNativeObject(), precision));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a lower bound for the given real algebraic number. The interval
|
* Return a lower bound for the given real algebraic number. The interval
|
||||||
* isolating the number is smaller than 1/10^{@code precision}.
|
* isolating the number is smaller than 1/10^{@code precision}.
|
||||||
*
|
*
|
||||||
* @see Expr#isAlgebraicNumber
|
* @see Expr#isAlgebraicNumber
|
||||||
* @param precision precision
|
* @param precision precision
|
||||||
*
|
*
|
||||||
* @return A numeral Expr of sort Real
|
* @return A numeral Expr of sort Real
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
**/
|
**/
|
||||||
public RatNum toLower(int precision)
|
public RatNum toLower(int precision)
|
||||||
{
|
{
|
||||||
|
|
||||||
return new RatNum(getContext(), Native.getAlgebraicNumberLower(getContext()
|
return new RatNum(getContext(), Native.getAlgebraicNumberLower(getContext()
|
||||||
.nCtx(), getNativeObject(), precision));
|
.nCtx(), getNativeObject(), precision));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation in decimal notation.
|
* Returns a string representation in decimal notation.
|
||||||
* Remarks: The result has at most {@code precision} decimal places.
|
* Remarks: The result has at most {@code precision} decimal places.
|
||||||
* @param precision precision
|
* @param precision precision
|
||||||
* @return String
|
* @return String
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
**/
|
**/
|
||||||
public String toDecimal(int precision)
|
public String toDecimal(int precision)
|
||||||
{
|
{
|
||||||
|
|
||||||
return Native.getNumeralDecimalString(getContext().nCtx(), getNativeObject(),
|
return Native.getNumeralDecimalString(getContext().nCtx(), getNativeObject(),
|
||||||
precision);
|
precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
AlgebraicNum(Context ctx, long obj)
|
AlgebraicNum(Context ctx, long obj)
|
||||||
{
|
{
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1898,8 +1898,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public SeqExpr mkEmptySeq(Sort s)
|
public SeqExpr mkEmptySeq(Sort s)
|
||||||
{
|
{
|
||||||
checkContextMatch(s);
|
checkContextMatch(s);
|
||||||
return (SeqExpr) Expr.create(this, Native.mkSeqEmpty(nCtx(), s.getNativeObject()));
|
return (SeqExpr) Expr.create(this, Native.mkSeqEmpty(nCtx(), s.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1907,8 +1907,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public SeqExpr mkUnit(Expr elem)
|
public SeqExpr mkUnit(Expr elem)
|
||||||
{
|
{
|
||||||
checkContextMatch(elem);
|
checkContextMatch(elem);
|
||||||
return (SeqExpr) Expr.create(this, Native.mkSeqUnit(nCtx(), elem.getNativeObject()));
|
return (SeqExpr) Expr.create(this, Native.mkSeqUnit(nCtx(), elem.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1916,7 +1916,7 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public SeqExpr mkString(String s)
|
public SeqExpr mkString(String s)
|
||||||
{
|
{
|
||||||
return (SeqExpr) Expr.create(this, Native.mkString(nCtx(), s));
|
return (SeqExpr) Expr.create(this, Native.mkString(nCtx(), s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1924,8 +1924,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public SeqExpr mkConcat(SeqExpr... t)
|
public SeqExpr mkConcat(SeqExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return (SeqExpr) Expr.create(this, Native.mkSeqConcat(nCtx(), t.length, AST.arrayToNative(t)));
|
return (SeqExpr) Expr.create(this, Native.mkSeqConcat(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1934,8 +1934,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public IntExpr mkLength(SeqExpr s)
|
public IntExpr mkLength(SeqExpr s)
|
||||||
{
|
{
|
||||||
checkContextMatch(s);
|
checkContextMatch(s);
|
||||||
return (IntExpr) Expr.create(this, Native.mkSeqLength(nCtx(), s.getNativeObject()));
|
return (IntExpr) Expr.create(this, Native.mkSeqLength(nCtx(), s.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1943,8 +1943,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkPrefixOf(SeqExpr s1, SeqExpr s2)
|
public BoolExpr mkPrefixOf(SeqExpr s1, SeqExpr s2)
|
||||||
{
|
{
|
||||||
checkContextMatch(s1, s2);
|
checkContextMatch(s1, s2);
|
||||||
return (BoolExpr) Expr.create(this, Native.mkSeqPrefix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
return (BoolExpr) Expr.create(this, Native.mkSeqPrefix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1952,8 +1952,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkSuffixOf(SeqExpr s1, SeqExpr s2)
|
public BoolExpr mkSuffixOf(SeqExpr s1, SeqExpr s2)
|
||||||
{
|
{
|
||||||
checkContextMatch(s1, s2);
|
checkContextMatch(s1, s2);
|
||||||
return (BoolExpr)Expr.create(this, Native.mkSeqSuffix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
return (BoolExpr)Expr.create(this, Native.mkSeqSuffix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1961,8 +1961,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkContains(SeqExpr s1, SeqExpr s2)
|
public BoolExpr mkContains(SeqExpr s1, SeqExpr s2)
|
||||||
{
|
{
|
||||||
checkContextMatch(s1, s2);
|
checkContextMatch(s1, s2);
|
||||||
return (BoolExpr) Expr.create(this, Native.mkSeqContains(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
return (BoolExpr) Expr.create(this, Native.mkSeqContains(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1970,8 +1970,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public SeqExpr mkAt(SeqExpr s, IntExpr index)
|
public SeqExpr mkAt(SeqExpr s, IntExpr index)
|
||||||
{
|
{
|
||||||
checkContextMatch(s, index);
|
checkContextMatch(s, index);
|
||||||
return (SeqExpr) Expr.create(this, Native.mkSeqAt(nCtx(), s.getNativeObject(), index.getNativeObject()));
|
return (SeqExpr) Expr.create(this, Native.mkSeqAt(nCtx(), s.getNativeObject(), index.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1979,8 +1979,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public SeqExpr mkExtract(SeqExpr s, IntExpr offset, IntExpr length)
|
public SeqExpr mkExtract(SeqExpr s, IntExpr offset, IntExpr length)
|
||||||
{
|
{
|
||||||
checkContextMatch(s, offset, length);
|
checkContextMatch(s, offset, length);
|
||||||
return (SeqExpr) Expr.create(this, Native.mkSeqExtract(nCtx(), s.getNativeObject(), offset.getNativeObject(), length.getNativeObject()));
|
return (SeqExpr) Expr.create(this, Native.mkSeqExtract(nCtx(), s.getNativeObject(), offset.getNativeObject(), length.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1988,8 +1988,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public IntExpr mkIndexOf(SeqExpr s, SeqExpr substr, ArithExpr offset)
|
public IntExpr mkIndexOf(SeqExpr s, SeqExpr substr, ArithExpr offset)
|
||||||
{
|
{
|
||||||
checkContextMatch(s, substr, offset);
|
checkContextMatch(s, substr, offset);
|
||||||
return (IntExpr)Expr.create(this, Native.mkSeqIndex(nCtx(), s.getNativeObject(), substr.getNativeObject(), offset.getNativeObject()));
|
return (IntExpr)Expr.create(this, Native.mkSeqIndex(nCtx(), s.getNativeObject(), substr.getNativeObject(), offset.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1997,8 +1997,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public SeqExpr mkReplace(SeqExpr s, SeqExpr src, SeqExpr dst)
|
public SeqExpr mkReplace(SeqExpr s, SeqExpr src, SeqExpr dst)
|
||||||
{
|
{
|
||||||
checkContextMatch(s, src, dst);
|
checkContextMatch(s, src, dst);
|
||||||
return (SeqExpr) Expr.create(this, Native.mkSeqReplace(nCtx(), s.getNativeObject(), src.getNativeObject(), dst.getNativeObject()));
|
return (SeqExpr) Expr.create(this, Native.mkSeqReplace(nCtx(), s.getNativeObject(), src.getNativeObject(), dst.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2006,8 +2006,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkToRe(SeqExpr s)
|
public ReExpr mkToRe(SeqExpr s)
|
||||||
{
|
{
|
||||||
checkContextMatch(s);
|
checkContextMatch(s);
|
||||||
return (ReExpr) Expr.create(this, Native.mkSeqToRe(nCtx(), s.getNativeObject()));
|
return (ReExpr) Expr.create(this, Native.mkSeqToRe(nCtx(), s.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2016,8 +2016,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkInRe(SeqExpr s, ReExpr re)
|
public BoolExpr mkInRe(SeqExpr s, ReExpr re)
|
||||||
{
|
{
|
||||||
checkContextMatch(s, re);
|
checkContextMatch(s, re);
|
||||||
return (BoolExpr) Expr.create(this, Native.mkSeqInRe(nCtx(), s.getNativeObject(), re.getNativeObject()));
|
return (BoolExpr) Expr.create(this, Native.mkSeqInRe(nCtx(), s.getNativeObject(), re.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2025,8 +2025,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkStar(ReExpr re)
|
public ReExpr mkStar(ReExpr re)
|
||||||
{
|
{
|
||||||
checkContextMatch(re);
|
checkContextMatch(re);
|
||||||
return (ReExpr) Expr.create(this, Native.mkReStar(nCtx(), re.getNativeObject()));
|
return (ReExpr) Expr.create(this, Native.mkReStar(nCtx(), re.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2034,7 +2034,7 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkLoop(ReExpr re, int lo, int hi)
|
public ReExpr mkLoop(ReExpr re, int lo, int hi)
|
||||||
{
|
{
|
||||||
return (ReExpr) Expr.create(this, Native.mkReLoop(nCtx(), re.getNativeObject(), lo, hi));
|
return (ReExpr) Expr.create(this, Native.mkReLoop(nCtx(), re.getNativeObject(), lo, hi));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2042,7 +2042,7 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkLoop(ReExpr re, int lo)
|
public ReExpr mkLoop(ReExpr re, int lo)
|
||||||
{
|
{
|
||||||
return (ReExpr) Expr.create(this, Native.mkReLoop(nCtx(), re.getNativeObject(), lo, 0));
|
return (ReExpr) Expr.create(this, Native.mkReLoop(nCtx(), re.getNativeObject(), lo, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2051,8 +2051,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkPlus(ReExpr re)
|
public ReExpr mkPlus(ReExpr re)
|
||||||
{
|
{
|
||||||
checkContextMatch(re);
|
checkContextMatch(re);
|
||||||
return (ReExpr) Expr.create(this, Native.mkRePlus(nCtx(), re.getNativeObject()));
|
return (ReExpr) Expr.create(this, Native.mkRePlus(nCtx(), re.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2060,8 +2060,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkOption(ReExpr re)
|
public ReExpr mkOption(ReExpr re)
|
||||||
{
|
{
|
||||||
checkContextMatch(re);
|
checkContextMatch(re);
|
||||||
return (ReExpr) Expr.create(this, Native.mkReOption(nCtx(), re.getNativeObject()));
|
return (ReExpr) Expr.create(this, Native.mkReOption(nCtx(), re.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2070,8 +2070,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkComplement(ReExpr re)
|
public ReExpr mkComplement(ReExpr re)
|
||||||
{
|
{
|
||||||
checkContextMatch(re);
|
checkContextMatch(re);
|
||||||
return (ReExpr) Expr.create(this, Native.mkReComplement(nCtx(), re.getNativeObject()));
|
return (ReExpr) Expr.create(this, Native.mkReComplement(nCtx(), re.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2079,8 +2079,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkConcat(ReExpr... t)
|
public ReExpr mkConcat(ReExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return (ReExpr) Expr.create(this, Native.mkReConcat(nCtx(), t.length, AST.arrayToNative(t)));
|
return (ReExpr) Expr.create(this, Native.mkReConcat(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2088,8 +2088,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkUnion(ReExpr... t)
|
public ReExpr mkUnion(ReExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return (ReExpr) Expr.create(this, Native.mkReUnion(nCtx(), t.length, AST.arrayToNative(t)));
|
return (ReExpr) Expr.create(this, Native.mkReUnion(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2097,8 +2097,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr mkIntersect(ReExpr... t)
|
public ReExpr mkIntersect(ReExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return (ReExpr) Expr.create(this, Native.mkReIntersect(nCtx(), t.length, AST.arrayToNative(t)));
|
return (ReExpr) Expr.create(this, Native.mkReIntersect(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2106,8 +2106,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public ReExpr MkRange(SeqExpr lo, SeqExpr hi)
|
public ReExpr MkRange(SeqExpr lo, SeqExpr hi)
|
||||||
{
|
{
|
||||||
checkContextMatch(lo, hi);
|
checkContextMatch(lo, hi);
|
||||||
return (ReExpr) Expr.create(this, Native.mkReRange(nCtx(), lo.getNativeObject(), hi.getNativeObject()));
|
return (ReExpr) Expr.create(this, Native.mkReRange(nCtx(), lo.getNativeObject(), hi.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2116,8 +2116,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkAtMost(BoolExpr[] args, int k)
|
public BoolExpr mkAtMost(BoolExpr[] args, int k)
|
||||||
{
|
{
|
||||||
checkContextMatch(args);
|
checkContextMatch(args);
|
||||||
return (BoolExpr) Expr.create(this, Native.mkAtmost(nCtx(), args.length, AST.arrayToNative(args), k));
|
return (BoolExpr) Expr.create(this, Native.mkAtmost(nCtx(), args.length, AST.arrayToNative(args), k));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2125,8 +2125,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkAtLeast(BoolExpr[] args, int k)
|
public BoolExpr mkAtLeast(BoolExpr[] args, int k)
|
||||||
{
|
{
|
||||||
checkContextMatch(args);
|
checkContextMatch(args);
|
||||||
return (BoolExpr) Expr.create(this, Native.mkAtleast(nCtx(), args.length, AST.arrayToNative(args), k));
|
return (BoolExpr) Expr.create(this, Native.mkAtleast(nCtx(), args.length, AST.arrayToNative(args), k));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2134,8 +2134,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkPBLe(int[] coeffs, BoolExpr[] args, int k)
|
public BoolExpr mkPBLe(int[] coeffs, BoolExpr[] args, int k)
|
||||||
{
|
{
|
||||||
checkContextMatch(args);
|
checkContextMatch(args);
|
||||||
return (BoolExpr) Expr.create(this, Native.mkPble(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
|
return (BoolExpr) Expr.create(this, Native.mkPble(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2143,8 +2143,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkPBGe(int[] coeffs, BoolExpr[] args, int k)
|
public BoolExpr mkPBGe(int[] coeffs, BoolExpr[] args, int k)
|
||||||
{
|
{
|
||||||
checkContextMatch(args);
|
checkContextMatch(args);
|
||||||
return (BoolExpr) Expr.create(this, Native.mkPbge(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
|
return (BoolExpr) Expr.create(this, Native.mkPbge(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2152,8 +2152,8 @@ public class Context implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public BoolExpr mkPBEq(int[] coeffs, BoolExpr[] args, int k)
|
public BoolExpr mkPBEq(int[] coeffs, BoolExpr[] args, int k)
|
||||||
{
|
{
|
||||||
checkContextMatch(args);
|
checkContextMatch(args);
|
||||||
return (BoolExpr) Expr.create(this, Native.mkPbeq(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
|
return (BoolExpr) Expr.create(this, Native.mkPbeq(nCtx(), args.length, AST.arrayToNative(args), coeffs, k));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3988,15 +3988,15 @@ public class Context implements AutoCloseable {
|
||||||
|
|
||||||
void checkContextMatch(Z3Object other1, Z3Object other2)
|
void checkContextMatch(Z3Object other1, Z3Object other2)
|
||||||
{
|
{
|
||||||
checkContextMatch(other1);
|
checkContextMatch(other1);
|
||||||
checkContextMatch(other2);
|
checkContextMatch(other2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkContextMatch(Z3Object other1, Z3Object other2, Z3Object other3)
|
void checkContextMatch(Z3Object other1, Z3Object other2, Z3Object other3)
|
||||||
{
|
{
|
||||||
checkContextMatch(other1);
|
checkContextMatch(other1);
|
||||||
checkContextMatch(other2);
|
checkContextMatch(other2);
|
||||||
checkContextMatch(other3);
|
checkContextMatch(other3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkContextMatch(Z3Object[] arr)
|
void checkContextMatch(Z3Object[] arr)
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class EnumSort extends Sort
|
||||||
**/
|
**/
|
||||||
public Expr getConst(int inx)
|
public Expr getConst(int inx)
|
||||||
{
|
{
|
||||||
return getContext().mkApp(getConstDecl(inx));
|
return getContext().mkApp(getConstDecl(inx));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1287,7 +1287,7 @@ public class Expr extends AST
|
||||||
*/
|
*/
|
||||||
public String getString()
|
public String getString()
|
||||||
{
|
{
|
||||||
return Native.getString(getContext().nCtx(), getNativeObject());
|
return Native.getString(getContext().nCtx(), getNativeObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -200,7 +200,7 @@ public class Model extends Z3Object {
|
||||||
* Remarks: This function may fail if {@code t} contains
|
* Remarks: This function may fail if {@code t} contains
|
||||||
* quantifiers, is partial (MODEL_PARTIAL enabled), or if {@code t} is not well-sorted. In this case a
|
* quantifiers, is partial (MODEL_PARTIAL enabled), or if {@code t} is not well-sorted. In this case a
|
||||||
* {@code ModelEvaluationFailedException} is thrown.
|
* {@code ModelEvaluationFailedException} is thrown.
|
||||||
* @param t the expression to evaluate
|
* @param t the expression to evaluate
|
||||||
* @param completion An expression {@code completion} When this flag
|
* @param completion An expression {@code completion} When this flag
|
||||||
* is enabled, a model value will be assigned to any constant or function
|
* is enabled, a model value will be assigned to any constant or function
|
||||||
* that does not have an interpretation in the model.
|
* that does not have an interpretation in the model.
|
||||||
|
|
|
@ -213,7 +213,7 @@ public class Optimize extends Z3Object {
|
||||||
* Declare an arithmetical maximization objective.
|
* Declare an arithmetical maximization objective.
|
||||||
* Return a handle to the objective. The handle is used as
|
* Return a handle to the objective. The handle is used as
|
||||||
* to retrieve the values of objectives after calling Check.
|
* to retrieve the values of objectives after calling Check.
|
||||||
**/
|
**/
|
||||||
public Handle MkMaximize(ArithExpr e)
|
public Handle MkMaximize(ArithExpr e)
|
||||||
{
|
{
|
||||||
return new Handle(this, Native.optimizeMaximize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
|
return new Handle(this, Native.optimizeMaximize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
|
||||||
|
@ -285,8 +285,7 @@ public class Optimize extends Z3Object {
|
||||||
**/
|
**/
|
||||||
public String getReasonUnknown()
|
public String getReasonUnknown()
|
||||||
{
|
{
|
||||||
return Native.optimizeGetReasonUnknown(getContext().nCtx(),
|
return Native.optimizeGetReasonUnknown(getContext().nCtx(), getNativeObject());
|
||||||
getNativeObject());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -304,7 +303,7 @@ public class Optimize extends Z3Object {
|
||||||
*/
|
*/
|
||||||
public void fromFile(String file)
|
public void fromFile(String file)
|
||||||
{
|
{
|
||||||
Native.optimizeFromFile(getContext().nCtx(), getNativeObject(), file);
|
Native.optimizeFromFile(getContext().nCtx(), getNativeObject(), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,7 +311,7 @@ public class Optimize extends Z3Object {
|
||||||
*/
|
*/
|
||||||
public void fromString(String s)
|
public void fromString(String s)
|
||||||
{
|
{
|
||||||
Native.optimizeFromString(getContext().nCtx(), getNativeObject(), s);
|
Native.optimizeFromString(getContext().nCtx(), getNativeObject(), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ParamDescrs extends Z3Object {
|
||||||
|
|
||||||
public String getDocumentation(Symbol name)
|
public String getDocumentation(Symbol name)
|
||||||
{
|
{
|
||||||
return Native.paramDescrsGetDocumentation(getContext().nCtx(), getNativeObject(), name.getNativeObject());
|
return Native.paramDescrsGetDocumentation(getContext().nCtx(), getNativeObject(), name.getNativeObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -302,7 +302,7 @@ public class Solver extends Z3Object {
|
||||||
*/
|
*/
|
||||||
public Solver translate(Context ctx)
|
public Solver translate(Context ctx)
|
||||||
{
|
{
|
||||||
return new Solver(ctx, Native.solverTranslate(getContext().nCtx(), getNativeObject(), ctx.nCtx()));
|
return new Solver(ctx, Native.solverTranslate(getContext().nCtx(), getNativeObject(), ctx.nCtx()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,12 +35,8 @@ public class Sort extends AST
|
||||||
if (!(o instanceof Sort)) return false;
|
if (!(o instanceof Sort)) return false;
|
||||||
Sort other = (Sort) o;
|
Sort other = (Sort) o;
|
||||||
|
|
||||||
return (getContext().nCtx() == other.getContext().nCtx()) &&
|
return (getContext().nCtx() == other.getContext().nCtx()) &&
|
||||||
(Native.isEqSort(
|
(Native.isEqSort(getContext().nCtx(), getNativeObject(), other.getNativeObject()));
|
||||||
getContext().nCtx(),
|
|
||||||
getNativeObject(),
|
|
||||||
other.getNativeObject()
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,34 +25,34 @@ extern "C" {
|
||||||
#include <z3native_stubs.h>
|
#include <z3native_stubs.h>
|
||||||
|
|
||||||
#define CAMLlocal6(X1,X2,X3,X4,X5,X6) \
|
#define CAMLlocal6(X1,X2,X3,X4,X5,X6) \
|
||||||
CAMLlocal5(X1,X2,X3,X4,X5); \
|
CAMLlocal5(X1,X2,X3,X4,X5); \
|
||||||
CAMLlocal1(X6)
|
CAMLlocal1(X6)
|
||||||
#define CAMLlocal7(X1,X2,X3,X4,X5,X6,X7) \
|
#define CAMLlocal7(X1,X2,X3,X4,X5,X6,X7) \
|
||||||
CAMLlocal5(X1,X2,X3,X4,X5); \
|
CAMLlocal5(X1,X2,X3,X4,X5); \
|
||||||
CAMLlocal2(X6,X7)
|
CAMLlocal2(X6,X7)
|
||||||
#define CAMLlocal8(X1,X2,X3,X4,X5,X6,X7,X8) \
|
#define CAMLlocal8(X1,X2,X3,X4,X5,X6,X7,X8) \
|
||||||
CAMLlocal5(X1,X2,X3,X4,X5); \
|
CAMLlocal5(X1,X2,X3,X4,X5); \
|
||||||
CAMLlocal3(X6,X7,X8)
|
CAMLlocal3(X6,X7,X8)
|
||||||
|
|
||||||
#define CAMLparam6(X1,X2,X3,X4,X5,X6) \
|
#define CAMLparam6(X1,X2,X3,X4,X5,X6) \
|
||||||
CAMLparam5(X1,X2,X3,X4,X5); \
|
CAMLparam5(X1,X2,X3,X4,X5); \
|
||||||
CAMLxparam1(X6)
|
CAMLxparam1(X6)
|
||||||
#define CAMLparam7(X1,X2,X3,X4,X5,X6,X7) \
|
#define CAMLparam7(X1,X2,X3,X4,X5,X6,X7) \
|
||||||
CAMLparam5(X1,X2,X3,X4,X5); \
|
CAMLparam5(X1,X2,X3,X4,X5); \
|
||||||
CAMLxparam2(X6,X7)
|
CAMLxparam2(X6,X7)
|
||||||
#define CAMLparam8(X1,X2,X3,X4,X5,X6,X7,X8) \
|
#define CAMLparam8(X1,X2,X3,X4,X5,X6,X7,X8) \
|
||||||
CAMLparam5(X1,X2,X3,X4,X5); \
|
CAMLparam5(X1,X2,X3,X4,X5); \
|
||||||
CAMLxparam3(X6,X7,X8)
|
CAMLxparam3(X6,X7,X8)
|
||||||
#define CAMLparam9(X1,X2,X3,X4,X5,X6,X7,X8,X9) \
|
#define CAMLparam9(X1,X2,X3,X4,X5,X6,X7,X8,X9) \
|
||||||
CAMLparam5(X1,X2,X3,X4,X5); \
|
CAMLparam5(X1,X2,X3,X4,X5); \
|
||||||
CAMLxparam4(X6,X7,X8,X9)
|
CAMLxparam4(X6,X7,X8,X9)
|
||||||
#define CAMLparam12(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12) \
|
#define CAMLparam12(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12) \
|
||||||
CAMLparam5(X1,X2,X3,X4,X5); \
|
CAMLparam5(X1,X2,X3,X4,X5); \
|
||||||
CAMLxparam5(X6,X7,X8,X9,X10); \
|
CAMLxparam5(X6,X7,X8,X9,X10); \
|
||||||
CAMLxparam2(X11,X12)
|
CAMLxparam2(X11,X12)
|
||||||
#define CAMLparam13(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13) \
|
#define CAMLparam13(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13) \
|
||||||
CAMLparam5(X1,X2,X3,X4,X5); \
|
CAMLparam5(X1,X2,X3,X4,X5); \
|
||||||
CAMLxparam5(X6,X7,X8,X9,X10); \
|
CAMLxparam5(X6,X7,X8,X9,X10); \
|
||||||
CAMLxparam3(X11,X12,X13)
|
CAMLxparam3(X11,X12,X13)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,5 +36,5 @@ Notes:
|
||||||
#define DLL_LOCAL
|
#define DLL_LOCAL
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3240,10 +3240,7 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args
|
||||||
|
|
||||||
// NaN, Inf, or negative (except -0) -> unspecified
|
// NaN, Inf, or negative (except -0) -> unspecified
|
||||||
expr_ref c1(m), v1(m), unspec_v(m);
|
expr_ref c1(m), v1(m), unspec_v(m);
|
||||||
if (!is_signed)
|
c1 = m.mk_or(x_is_nan, x_is_inf);
|
||||||
c1 = m.mk_or(x_is_nan, x_is_inf, m.mk_and(x_is_neg, m.mk_not(x_is_nzero)));
|
|
||||||
else
|
|
||||||
c1 = m.mk_or(x_is_nan, x_is_inf);
|
|
||||||
mk_to_bv_unspecified(f, num, args, unspec_v);
|
mk_to_bv_unspecified(f, num, args, unspec_v);
|
||||||
v1 = unspec_v;
|
v1 = unspec_v;
|
||||||
dbg_decouple("fpa2bv_to_bv_c1", c1);
|
dbg_decouple("fpa2bv_to_bv_c1", c1);
|
||||||
|
@ -3335,18 +3332,18 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args
|
||||||
dbg_decouple("fpa2bv_to_bv_inc", inc);
|
dbg_decouple("fpa2bv_to_bv_inc", inc);
|
||||||
dbg_decouple("fpa2bv_to_bv_pre_rounded", pre_rounded);
|
dbg_decouple("fpa2bv_to_bv_pre_rounded", pre_rounded);
|
||||||
|
|
||||||
expr_ref in_range(m);
|
pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded);
|
||||||
|
|
||||||
|
expr_ref ll(m), ul(m), in_range(m);
|
||||||
if (!is_signed) {
|
if (!is_signed) {
|
||||||
expr_ref ul(m);
|
ll = m_bv_util.mk_numeral(0, bv_sz+3);
|
||||||
ul = m_bv_util.mk_zero_extend(3, m_bv_util.mk_numeral(-1, bv_sz));
|
ul = m_bv_util.mk_zero_extend(3, m_bv_util.mk_numeral(-1, bv_sz));
|
||||||
in_range = m_bv_util.mk_ule(pre_rounded, ul);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
expr_ref ll(m), ul(m);
|
|
||||||
ll = m_bv_util.mk_sign_extend(3, m_bv_util.mk_concat(bv1, m_bv_util.mk_numeral(0, bv_sz-1)));
|
ll = m_bv_util.mk_sign_extend(3, m_bv_util.mk_concat(bv1, m_bv_util.mk_numeral(0, bv_sz-1)));
|
||||||
ul = m_bv_util.mk_zero_extend(4, m_bv_util.mk_numeral(-1, bv_sz-1));
|
ul = m_bv_util.mk_zero_extend(4, m_bv_util.mk_numeral(-1, bv_sz-1));
|
||||||
in_range = m.mk_and(m_bv_util.mk_sle(ll, pre_rounded), m_bv_util.mk_sle(pre_rounded, ul));
|
|
||||||
}
|
}
|
||||||
|
in_range = m.mk_and(m_bv_util.mk_sle(ll, pre_rounded), m_bv_util.mk_sle(pre_rounded, ul));
|
||||||
dbg_decouple("fpa2bv_to_bv_in_range", in_range);
|
dbg_decouple("fpa2bv_to_bv_in_range", in_range);
|
||||||
|
|
||||||
expr_ref rounded(m);
|
expr_ref rounded(m);
|
||||||
|
|
|
@ -2,5 +2,5 @@ def_module_params(module_name='rewriter',
|
||||||
class_name='array_rewriter_params',
|
class_name='array_rewriter_params',
|
||||||
export=True,
|
export=True,
|
||||||
params=(("expand_select_store", BOOL, False, "replace a (select (store ...) ...) term by an if-then-else term"),
|
params=(("expand_select_store", BOOL, False, "replace a (select (store ...) ...) term by an if-then-else term"),
|
||||||
("expand_store_eq", BOOL, False, "reduce (store ...) = (store ...) with a common base into selects"),
|
("expand_store_eq", BOOL, False, "reduce (store ...) = (store ...) with a common base into selects"),
|
||||||
("sort_store", BOOL, False, "sort nested stores when the indices are known to be different")))
|
("sort_store", BOOL, False, "sort nested stores when the indices are known to be different")))
|
||||||
|
|
|
@ -75,7 +75,7 @@ protected:
|
||||||
bool mk_mul(expr* a, expr* b, expr_ref& result);
|
bool mk_mul(expr* a, expr* b, expr_ref& result);
|
||||||
bool mk_comp(eq_type ty, expr* e1, expr* e2, expr_ref& result);
|
bool mk_comp(eq_type ty, expr* e1, expr* e2, expr_ref& result);
|
||||||
bool mk_add(expr* e1, expr* e2, expr_ref& result);
|
bool mk_add(expr* e1, expr* e2, expr_ref& result);
|
||||||
|
|
||||||
expr * get_cached(expr * n) const;
|
expr * get_cached(expr * n) const;
|
||||||
bool is_cached(expr * n) const { return get_cached(n) != 0; }
|
bool is_cached(expr * n) const { return get_cached(n) != 0; }
|
||||||
void cache_result(expr * n, expr * r);
|
void cache_result(expr * n, expr * r);
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
bv_bounds(ast_manager& m) : m_m(m), m_bv_util(m), m_okay(true) {};
|
bv_bounds(ast_manager& m) : m_m(m), m_bv_util(m), m_okay(true) {};
|
||||||
~bv_bounds();
|
~bv_bounds();
|
||||||
public: // bounds addition methods
|
public: // bounds addition methods
|
||||||
br_status rewrite(unsigned limit, func_decl * f, unsigned num, expr * const * args, expr_ref& result);
|
br_status rewrite(unsigned limit, func_decl * f, unsigned num, expr * const * args, expr_ref& result);
|
||||||
|
|
||||||
/** \brief Add a constraint to the system.
|
/** \brief Add a constraint to the system.
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ protected:
|
||||||
bv_util m_bv_util;
|
bv_util m_bv_util;
|
||||||
bool m_okay;
|
bool m_okay;
|
||||||
bool is_sat(app * v);
|
bool is_sat(app * v);
|
||||||
bool is_sat_core(app * v);
|
bool is_sat_core(app * v);
|
||||||
inline bool in_range(app *v, numeral l);
|
inline bool in_range(app *v, numeral l);
|
||||||
inline bool is_constant_add(unsigned bv_sz, expr * e, app*& v, numeral& val);
|
inline bool is_constant_add(unsigned bv_sz, expr * e, app*& v, numeral& val);
|
||||||
void record_singleton(app * v, numeral& singleton_value);
|
void record_singleton(app * v, numeral& singleton_value);
|
||||||
|
@ -94,7 +94,7 @@ protected:
|
||||||
inline bool bv_bounds::is_okay() { return m_okay; }
|
inline bool bv_bounds::is_okay() { return m_okay; }
|
||||||
|
|
||||||
inline bool bv_bounds::to_bound(const expr * e) const {
|
inline bool bv_bounds::to_bound(const expr * e) const {
|
||||||
return is_app(e) && m_bv_util.is_bv(e)
|
return is_app(e) && m_bv_util.is_bv(e)
|
||||||
&& !m_bv_util.is_bv_add(e)
|
&& !m_bv_util.is_bv_add(e)
|
||||||
&& !m_bv_util.is_numeral(e);
|
&& !m_bv_util.is_numeral(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -772,7 +772,6 @@ br_status fpa_rewriter::mk_to_bv(func_decl * f, expr * arg1, expr * arg2, bool i
|
||||||
|
|
||||||
if (m_util.is_rm_numeral(arg1, rmv) &&
|
if (m_util.is_rm_numeral(arg1, rmv) &&
|
||||||
m_util.is_numeral(arg2, v)) {
|
m_util.is_numeral(arg2, v)) {
|
||||||
const mpf & x = v.get();
|
|
||||||
|
|
||||||
if (m_fm.is_nan(v) || m_fm.is_inf(v))
|
if (m_fm.is_nan(v) || m_fm.is_inf(v))
|
||||||
return mk_to_bv_unspecified(f, result);
|
return mk_to_bv_unspecified(f, result);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
def_module_params(module_name='rewriter',
|
def_module_params(module_name='rewriter',
|
||||||
class_name='fpa_rewriter_params',
|
class_name='fpa_rewriter_params',
|
||||||
export=True,
|
export=True,
|
||||||
params=(("hi_fp_unspecified", BOOL, False, "use the 'hardware interpretation' for unspecified values in fp.to_ubv, fp.to_sbv, fp.to_real, and fp.to_ieee_bv"),
|
params=(("hi_fp_unspecified", BOOL, False, "use the 'hardware interpretation' for unspecified values in fp.to_ubv, fp.to_sbv, fp.to_real, and fp.to_ieee_bv"),
|
||||||
))
|
))
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "duality/duality_wrapper.h"
|
#include "duality/duality_wrapper.h"
|
||||||
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -41,9 +42,9 @@ namespace Duality {
|
||||||
typedef expr Term;
|
typedef expr Term;
|
||||||
|
|
||||||
Z3User(context &_ctx) : ctx(_ctx){}
|
Z3User(context &_ctx) : ctx(_ctx){}
|
||||||
|
|
||||||
const char *string_of_int(int n);
|
const char *string_of_int(int n);
|
||||||
|
|
||||||
Term conjoin(const std::vector<Term> &args);
|
Term conjoin(const std::vector<Term> &args);
|
||||||
|
|
||||||
Term sum(const std::vector<Term> &args);
|
Term sum(const std::vector<Term> &args);
|
||||||
|
@ -130,58 +131,58 @@ namespace Duality {
|
||||||
|
|
||||||
/** This class represents a relation post-fixed point (RPFP) problem as
|
/** This class represents a relation post-fixed point (RPFP) problem as
|
||||||
* a "problem graph". The graph consists of Nodes and hyper-edges.
|
* a "problem graph". The graph consists of Nodes and hyper-edges.
|
||||||
*
|
*
|
||||||
* A node consists of
|
* A node consists of
|
||||||
* - Annotation, a symbolic relation
|
* - Annotation, a symbolic relation
|
||||||
* - Bound, a symbolic relation giving an upper bound on Annotation
|
* - Bound, a symbolic relation giving an upper bound on Annotation
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* A hyper-edge consists of:
|
* A hyper-edge consists of:
|
||||||
* - Children, a sequence of children Nodes,
|
* - Children, a sequence of children Nodes,
|
||||||
* - F, a symbolic relational transformer,
|
* - F, a symbolic relational transformer,
|
||||||
* - Parent, a single parent Node.
|
* - Parent, a single parent Node.
|
||||||
*
|
*
|
||||||
* The graph is "solved" when:
|
* The graph is "solved" when:
|
||||||
* - For every Node n, n.Annotation subseteq n.Bound
|
* - For every Node n, n.Annotation subseteq n.Bound
|
||||||
* - For every hyperedge e, e.F(e.Children.Annotation) subseteq e.Parent.Annotation
|
* - For every hyperedge e, e.F(e.Children.Annotation) subseteq e.Parent.Annotation
|
||||||
*
|
*
|
||||||
* where, if x is a sequence of Nodes, x.Annotation is the sequences
|
* where, if x is a sequence of Nodes, x.Annotation is the sequences
|
||||||
* of Annotations of the nodes in the sequence.
|
* of Annotations of the nodes in the sequence.
|
||||||
*
|
*
|
||||||
* A symbolic Transformer consists of
|
* A symbolic Transformer consists of
|
||||||
* - RelParams, a sequence of relational symbols
|
* - RelParams, a sequence of relational symbols
|
||||||
* - IndParams, a sequence of individual symbols
|
* - IndParams, a sequence of individual symbols
|
||||||
* - Formula, a formula over RelParams and IndParams
|
* - Formula, a formula over RelParams and IndParams
|
||||||
*
|
*
|
||||||
* A Transformer t represents a function that takes sequence R of relations
|
* A Transformer t represents a function that takes sequence R of relations
|
||||||
* and yields the relation lambda (t.Indparams). Formula(R/RelParams).
|
* and yields the relation lambda (t.Indparams). Formula(R/RelParams).
|
||||||
*
|
*
|
||||||
* As a special case, a nullary Transformer (where RelParams is the empty sequence)
|
* As a special case, a nullary Transformer (where RelParams is the empty sequence)
|
||||||
* represents a fixed relation.
|
* represents a fixed relation.
|
||||||
*
|
*
|
||||||
* An RPFP consists of
|
* An RPFP consists of
|
||||||
* - Nodes, a set of Nodes
|
* - Nodes, a set of Nodes
|
||||||
* - Edges, a set of hyper-edges
|
* - Edges, a set of hyper-edges
|
||||||
* - Context, a prover context that contains formula AST's
|
* - Context, a prover context that contains formula AST's
|
||||||
*
|
*
|
||||||
* Multiple RPFP's can use the same Context, but you should be careful
|
* Multiple RPFP's can use the same Context, but you should be careful
|
||||||
* that only one RPFP asserts constraints in the context at any time.
|
* that only one RPFP asserts constraints in the context at any time.
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
class RPFP : public Z3User
|
class RPFP : public Z3User
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class Edge;
|
class Edge;
|
||||||
class Node;
|
class Node;
|
||||||
bool HornClauses;
|
bool HornClauses;
|
||||||
|
|
||||||
|
|
||||||
/** Interface class for interpolating solver. */
|
/** Interface class for interpolating solver. */
|
||||||
|
|
||||||
class LogicSolver {
|
class LogicSolver {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
context *ctx; /** Z3 context for formulas */
|
context *ctx; /** Z3 context for formulas */
|
||||||
solver *slvr; /** Z3 solver */
|
solver *slvr; /** Z3 solver */
|
||||||
bool need_goals; /** Can the solver use the goal tree to optimize interpolants? */
|
bool need_goals; /** Can the solver use the goal tree to optimize interpolants? */
|
||||||
|
@ -191,7 +192,7 @@ namespace Duality {
|
||||||
"assumptions" are currently asserted in the solver. The return
|
"assumptions" are currently asserted in the solver. The return
|
||||||
value indicates whether the assertions are satisfiable. In the
|
value indicates whether the assertions are satisfiable. In the
|
||||||
UNSAT case, a tree interpolant is returned in "interpolants".
|
UNSAT case, a tree interpolant is returned in "interpolants".
|
||||||
In the SAT case, a model is returned.
|
In the SAT case, a model is returned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
|
@ -201,7 +202,7 @@ namespace Duality {
|
||||||
TermTree *goals = 0,
|
TermTree *goals = 0,
|
||||||
bool weak = false
|
bool weak = false
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
/** Declare a constant in the background theory. */
|
/** Declare a constant in the background theory. */
|
||||||
virtual void declare_constant(const func_decl &f) = 0;
|
virtual void declare_constant(const func_decl &f) = 0;
|
||||||
|
|
||||||
|
@ -319,7 +320,7 @@ namespace Duality {
|
||||||
virtual void declare_constant(const func_decl &f){
|
virtual void declare_constant(const func_decl &f){
|
||||||
bckg.insert(f);
|
bckg.insert(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Is this a background constant? */
|
/** Is this a background constant? */
|
||||||
virtual bool is_constant(const func_decl &f){
|
virtual bool is_constant(const func_decl &f){
|
||||||
return bckg.find(f) != bckg.end();
|
return bckg.find(f) != bckg.end();
|
||||||
|
@ -344,9 +345,9 @@ namespace Duality {
|
||||||
static iZ3LogicSolver *CreateLogicSolver(config &_config){
|
static iZ3LogicSolver *CreateLogicSolver(config &_config){
|
||||||
return new iZ3LogicSolver(_config);
|
return new iZ3LogicSolver(_config);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Create a logic solver from a low-level Z3 context.
|
/** Create a logic solver from a low-level Z3 context.
|
||||||
Only use this if you know what you're doing. */
|
Only use this if you know what you're doing. */
|
||||||
static iZ3LogicSolver *CreateLogicSolver(context c){
|
static iZ3LogicSolver *CreateLogicSolver(context c){
|
||||||
return new iZ3LogicSolver(c);
|
return new iZ3LogicSolver(c);
|
||||||
|
@ -357,7 +358,7 @@ namespace Duality {
|
||||||
protected:
|
protected:
|
||||||
int nodeCount;
|
int nodeCount;
|
||||||
int edgeCount;
|
int edgeCount;
|
||||||
|
|
||||||
class stack_entry
|
class stack_entry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -365,8 +366,8 @@ namespace Duality {
|
||||||
std::list<Node *> nodes;
|
std::list<Node *> nodes;
|
||||||
std::list<std::pair<Edge *,Term> > constraints;
|
std::list<std::pair<Edge *,Term> > constraints;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
model dualModel;
|
model dualModel;
|
||||||
protected:
|
protected:
|
||||||
|
@ -375,14 +376,14 @@ namespace Duality {
|
||||||
std::vector<Term> axioms; // only saved here for printing purposes
|
std::vector<Term> axioms; // only saved here for printing purposes
|
||||||
solver &aux_solver;
|
solver &aux_solver;
|
||||||
hash_set<ast> *proof_core;
|
hash_set<ast> *proof_core;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Construct an RPFP graph with a given interpolating prover context. It is allowed to
|
/** Construct an RPFP graph with a given interpolating prover context. It is allowed to
|
||||||
have multiple RPFP's use the same context, but you should never have teo RPFP's
|
have multiple RPFP's use the same context, but you should never have teo RPFP's
|
||||||
with the same conext asserting nodes or edges at the same time. Note, if you create
|
with the same conext asserting nodes or edges at the same time. Note, if you create
|
||||||
axioms in one RPFP, them create a second RPFP with the same context, the second will
|
axioms in one RPFP, them create a second RPFP with the same context, the second will
|
||||||
inherit the axioms.
|
inherit the axioms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RPFP(LogicSolver *_ls) : Z3User(*(_ls->ctx)), dualModel(*(_ls->ctx)), aux_solver(_ls->aux_solver)
|
RPFP(LogicSolver *_ls) : Z3User(*(_ls->ctx)), dualModel(*(_ls->ctx)), aux_solver(_ls->aux_solver)
|
||||||
|
@ -396,7 +397,7 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~RPFP();
|
virtual ~RPFP();
|
||||||
|
|
||||||
/** Symbolic representation of a relational transformer */
|
/** Symbolic representation of a relational transformer */
|
||||||
class Transformer
|
class Transformer
|
||||||
{
|
{
|
||||||
|
@ -406,12 +407,12 @@ namespace Duality {
|
||||||
Term Formula;
|
Term Formula;
|
||||||
RPFP *owner;
|
RPFP *owner;
|
||||||
hash_map<std::string,Term> labels;
|
hash_map<std::string,Term> labels;
|
||||||
|
|
||||||
Transformer *Clone()
|
Transformer *Clone()
|
||||||
{
|
{
|
||||||
return new Transformer(*this);
|
return new Transformer(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetEmpty(){
|
void SetEmpty(){
|
||||||
Formula = owner->ctx.bool_val(false);
|
Formula = owner->ctx.bool_val(false);
|
||||||
}
|
}
|
||||||
|
@ -451,7 +452,7 @@ namespace Duality {
|
||||||
void Complement(){
|
void Complement(){
|
||||||
Formula = !Formula;
|
Formula = !Formula;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simplify(){
|
void Simplify(){
|
||||||
Formula = Formula.simplify();
|
Formula = Formula.simplify();
|
||||||
}
|
}
|
||||||
|
@ -459,7 +460,7 @@ namespace Duality {
|
||||||
Transformer(const std::vector<FuncDecl> &_RelParams, const std::vector<Term> &_IndParams, const Term &_Formula, RPFP *_owner)
|
Transformer(const std::vector<FuncDecl> &_RelParams, const std::vector<Term> &_IndParams, const Term &_Formula, RPFP *_owner)
|
||||||
: RelParams(_RelParams), IndParams(_IndParams), Formula(_Formula) {owner = _owner;}
|
: RelParams(_RelParams), IndParams(_IndParams), Formula(_Formula) {owner = _owner;}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Create a symbolic transformer. */
|
/** Create a symbolic transformer. */
|
||||||
Transformer CreateTransformer(const std::vector<FuncDecl> &_RelParams, const std::vector<Term> &_IndParams, const Term &_Formula)
|
Transformer CreateTransformer(const std::vector<FuncDecl> &_RelParams, const std::vector<Term> &_IndParams, const Term &_Formula)
|
||||||
{
|
{
|
||||||
|
@ -469,13 +470,13 @@ namespace Duality {
|
||||||
// t.labels = foo.Item2;
|
// t.labels = foo.Item2;
|
||||||
return Transformer(_RelParams,_IndParams,_Formula,this);
|
return Transformer(_RelParams,_IndParams,_Formula,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a relation (nullary relational transformer) */
|
/** Create a relation (nullary relational transformer) */
|
||||||
Transformer CreateRelation(const std::vector<Term> &_IndParams, const Term &_Formula)
|
Transformer CreateRelation(const std::vector<Term> &_IndParams, const Term &_Formula)
|
||||||
{
|
{
|
||||||
return CreateTransformer(std::vector<FuncDecl>(), _IndParams, _Formula);
|
return CreateTransformer(std::vector<FuncDecl>(), _IndParams, _Formula);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A node in the RPFP graph */
|
/** A node in the RPFP graph */
|
||||||
class Node
|
class Node
|
||||||
{
|
{
|
||||||
|
@ -491,17 +492,17 @@ namespace Duality {
|
||||||
Term dual;
|
Term dual;
|
||||||
Node *map;
|
Node *map;
|
||||||
unsigned recursion_bound;
|
unsigned recursion_bound;
|
||||||
|
|
||||||
Node(const FuncDecl &_Name, const Transformer &_Annotation, const Transformer &_Bound, const Transformer &_Underapprox, const Term &_dual, RPFP *_owner, int _number)
|
Node(const FuncDecl &_Name, const Transformer &_Annotation, const Transformer &_Bound, const Transformer &_Underapprox, const Term &_dual, RPFP *_owner, int _number)
|
||||||
: Name(_Name), Annotation(_Annotation), Bound(_Bound), Underapprox(_Underapprox), dual(_dual) {owner = _owner; number = _number; Outgoing = 0; recursion_bound = UINT_MAX;}
|
: Name(_Name), Annotation(_Annotation), Bound(_Bound), Underapprox(_Underapprox), dual(_dual) {owner = _owner; number = _number; Outgoing = 0; recursion_bound = UINT_MAX;}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Create a node in the graph. The input is a term R(v_1...v_n)
|
/** Create a node in the graph. The input is a term R(v_1...v_n)
|
||||||
* where R is an arbitrary relational symbol and v_1...v_n are
|
* where R is an arbitrary relational symbol and v_1...v_n are
|
||||||
* arbitary distinct variables. The names are only of mnemonic value,
|
* arbitary distinct variables. The names are only of mnemonic value,
|
||||||
* however, the number and type of arguments determine the type
|
* however, the number and type of arguments determine the type
|
||||||
* of the relation at this node. */
|
* of the relation at this node. */
|
||||||
|
|
||||||
Node *CreateNode(const Term &t)
|
Node *CreateNode(const Term &t)
|
||||||
{
|
{
|
||||||
std::vector<Term> _IndParams;
|
std::vector<Term> _IndParams;
|
||||||
|
@ -517,9 +518,9 @@ namespace Duality {
|
||||||
nodes.push_back(n);
|
nodes.push_back(n);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clone a node (can be from another graph). */
|
/** Clone a node (can be from another graph). */
|
||||||
|
|
||||||
Node *CloneNode(Node *old)
|
Node *CloneNode(Node *old)
|
||||||
{
|
{
|
||||||
Node *n = new Node(old->Name,
|
Node *n = new Node(old->Name,
|
||||||
|
@ -534,7 +535,7 @@ namespace Duality {
|
||||||
n->map = old;
|
n->map = old;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete a node. You can only do this if not connected to any edges.*/
|
/** Delete a node. You can only do this if not connected to any edges.*/
|
||||||
void DeleteNode(Node *node){
|
void DeleteNode(Node *node){
|
||||||
if(node->Outgoing || !node->Incoming.empty())
|
if(node->Outgoing || !node->Incoming.empty())
|
||||||
|
@ -549,7 +550,7 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This class represents a hyper-edge in the RPFP graph */
|
/** This class represents a hyper-edge in the RPFP graph */
|
||||||
|
|
||||||
class Edge
|
class Edge
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -565,15 +566,15 @@ namespace Duality {
|
||||||
Edge *map;
|
Edge *map;
|
||||||
Term labeled;
|
Term labeled;
|
||||||
std::vector<Term> constraints;
|
std::vector<Term> constraints;
|
||||||
|
|
||||||
Edge(Node *_Parent, const Transformer &_F, const std::vector<Node *> &_Children, RPFP *_owner, int _number)
|
Edge(Node *_Parent, const Transformer &_F, const std::vector<Node *> &_Children, RPFP *_owner, int _number)
|
||||||
: F(_F), Parent(_Parent), Children(_Children), dual(expr(_owner->ctx)) {
|
: F(_F), Parent(_Parent), Children(_Children), dual(expr(_owner->ctx)) {
|
||||||
owner = _owner;
|
owner = _owner;
|
||||||
number = _number;
|
number = _number;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Create a hyper-edge. */
|
/** Create a hyper-edge. */
|
||||||
Edge *CreateEdge(Node *_Parent, const Transformer &_F, const std::vector<Node *> &_Children)
|
Edge *CreateEdge(Node *_Parent, const Transformer &_F, const std::vector<Node *> &_Children)
|
||||||
{
|
{
|
||||||
|
@ -584,8 +585,8 @@ namespace Duality {
|
||||||
edges.push_back(e);
|
edges.push_back(e);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Delete a hyper-edge and unlink it from any nodes. */
|
/** Delete a hyper-edge and unlink it from any nodes. */
|
||||||
void DeleteEdge(Edge *edge){
|
void DeleteEdge(Edge *edge){
|
||||||
if(edge->Parent)
|
if(edge->Parent)
|
||||||
|
@ -607,19 +608,19 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
delete edge;
|
delete edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create an edge that lower-bounds its parent. */
|
/** Create an edge that lower-bounds its parent. */
|
||||||
Edge *CreateLowerBoundEdge(Node *_Parent)
|
Edge *CreateLowerBoundEdge(Node *_Parent)
|
||||||
{
|
{
|
||||||
return CreateEdge(_Parent, _Parent->Annotation, std::vector<Node *>());
|
return CreateEdge(_Parent, _Parent->Annotation, std::vector<Node *>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** For incremental solving, asserts the constraint associated
|
/** For incremental solving, asserts the constraint associated
|
||||||
* with this edge in the SMT context. If this edge is removed,
|
* with this edge in the SMT context. If this edge is removed,
|
||||||
* you must pop the context accordingly. The second argument is
|
* you must pop the context accordingly. The second argument is
|
||||||
* the number of pushes we are inside. */
|
* the number of pushes we are inside. */
|
||||||
|
|
||||||
virtual void AssertEdge(Edge *e, int persist = 0, bool with_children = false, bool underapprox = false);
|
virtual void AssertEdge(Edge *e, int persist = 0, bool with_children = false, bool underapprox = false);
|
||||||
|
|
||||||
/* Constrain an edge by the annotation of one of its children. */
|
/* Constrain an edge by the annotation of one of its children. */
|
||||||
|
@ -629,19 +630,19 @@ namespace Duality {
|
||||||
/** For incremental solving, asserts the negation of the upper bound associated
|
/** For incremental solving, asserts the negation of the upper bound associated
|
||||||
* with a node.
|
* with a node.
|
||||||
* */
|
* */
|
||||||
|
|
||||||
void AssertNode(Node *n);
|
void AssertNode(Node *n);
|
||||||
|
|
||||||
/** Assert a constraint on an edge in the SMT context.
|
/** Assert a constraint on an edge in the SMT context.
|
||||||
*/
|
*/
|
||||||
void ConstrainEdge(Edge *e, const Term &t);
|
void ConstrainEdge(Edge *e, const Term &t);
|
||||||
|
|
||||||
/** Fix the truth values of atomic propositions in the given
|
/** Fix the truth values of atomic propositions in the given
|
||||||
edge to their values in the current assignment. */
|
edge to their values in the current assignment. */
|
||||||
void FixCurrentState(Edge *root);
|
void FixCurrentState(Edge *root);
|
||||||
|
|
||||||
void FixCurrentStateFull(Edge *edge, const expr &extra);
|
void FixCurrentStateFull(Edge *edge, const expr &extra);
|
||||||
|
|
||||||
void FixCurrentStateFull(Edge *edge, const std::vector<expr> &assumps, const hash_map<ast,expr> &renaming);
|
void FixCurrentStateFull(Edge *edge, const std::vector<expr> &assumps, const hash_map<ast,expr> &renaming);
|
||||||
|
|
||||||
/** Declare a constant in the background theory. */
|
/** Declare a constant in the background theory. */
|
||||||
|
@ -660,78 +661,78 @@ namespace Duality {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/** Do not call this. */
|
/** Do not call this. */
|
||||||
|
|
||||||
void RemoveAxiom(const Term &t);
|
void RemoveAxiom(const Term &t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Solve an RPFP graph. This means either strengthen the annotation
|
/** Solve an RPFP graph. This means either strengthen the annotation
|
||||||
* so that the bound at the given root node is satisfied, or
|
* so that the bound at the given root node is satisfied, or
|
||||||
* show that this cannot be done by giving a dual solution
|
* show that this cannot be done by giving a dual solution
|
||||||
* (i.e., a counterexample).
|
* (i.e., a counterexample).
|
||||||
*
|
*
|
||||||
* In the current implementation, this only works for graphs that
|
* In the current implementation, this only works for graphs that
|
||||||
* are:
|
* are:
|
||||||
* - tree-like
|
* - tree-like
|
||||||
*
|
*
|
||||||
* - closed.
|
* - closed.
|
||||||
*
|
*
|
||||||
* In a tree-like graph, every nod has out most one incoming and one out-going edge,
|
* In a tree-like graph, every nod has out most one incoming and one out-going edge,
|
||||||
* and there are no cycles. In a closed graph, every node has exactly one out-going
|
* and there are no cycles. In a closed graph, every node has exactly one out-going
|
||||||
* edge. This means that the leaves of the tree are all hyper-edges with no
|
* edge. This means that the leaves of the tree are all hyper-edges with no
|
||||||
* children. Such an edge represents a relation (nullary transformer) and thus
|
* children. Such an edge represents a relation (nullary transformer) and thus
|
||||||
* a lower bound on its parent. The parameter root must be the root of this tree.
|
* a lower bound on its parent. The parameter root must be the root of this tree.
|
||||||
*
|
*
|
||||||
* If Solve returns LBool.False, this indicates success. The annotation of the tree
|
* If Solve returns LBool.False, this indicates success. The annotation of the tree
|
||||||
* has been updated to satisfy the upper bound at the root.
|
* has been updated to satisfy the upper bound at the root.
|
||||||
*
|
*
|
||||||
* If Solve returns LBool.True, this indicates a counterexample. For each edge,
|
* If Solve returns LBool.True, this indicates a counterexample. For each edge,
|
||||||
* you can then call Eval to determine the values of symbols in the transformer formula.
|
* you can then call Eval to determine the values of symbols in the transformer formula.
|
||||||
* You can also call Empty on a node to determine if its value in the counterexample
|
* You can also call Empty on a node to determine if its value in the counterexample
|
||||||
* is the empty relation.
|
* is the empty relation.
|
||||||
*
|
*
|
||||||
* \param root The root of the tree
|
* \param root The root of the tree
|
||||||
* \param persist Number of context pops through which result should persist
|
* \param persist Number of context pops through which result should persist
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lbool Solve(Node *root, int persist);
|
lbool Solve(Node *root, int persist);
|
||||||
|
|
||||||
/** Same as Solve, but annotates only a single node. */
|
/** Same as Solve, but annotates only a single node. */
|
||||||
|
|
||||||
lbool SolveSingleNode(Node *root, Node *node);
|
lbool SolveSingleNode(Node *root, Node *node);
|
||||||
|
|
||||||
/** Get the constraint tree (but don't solve it) */
|
/** Get the constraint tree (but don't solve it) */
|
||||||
|
|
||||||
TermTree *GetConstraintTree(Node *root, Node *skip_descendant = 0);
|
TermTree *GetConstraintTree(Node *root, Node *skip_descendant = 0);
|
||||||
|
|
||||||
/** Dispose of the dual model (counterexample) if there is one. */
|
/** Dispose of the dual model (counterexample) if there is one. */
|
||||||
|
|
||||||
void DisposeDualModel();
|
void DisposeDualModel();
|
||||||
|
|
||||||
/** Check satisfiability of asserted edges and nodes. Same functionality as
|
/** Check satisfiability of asserted edges and nodes. Same functionality as
|
||||||
* Solve, except no primal solution (interpolant) is generated in the unsat case. */
|
* Solve, except no primal solution (interpolant) is generated in the unsat case. */
|
||||||
|
|
||||||
check_result Check(Node *root, std::vector<Node *> underapproxes = std::vector<Node *>(),
|
check_result Check(Node *root, std::vector<Node *> underapproxes = std::vector<Node *>(),
|
||||||
std::vector<Node *> *underapprox_core = 0);
|
std::vector<Node *> *underapprox_core = 0);
|
||||||
|
|
||||||
/** Update the model, attempting to make the propositional literals in assumps true. If possible,
|
/** Update the model, attempting to make the propositional literals in assumps true. If possible,
|
||||||
return sat, else return unsat and keep the old model. */
|
return sat, else return unsat and keep the old model. */
|
||||||
|
|
||||||
check_result CheckUpdateModel(Node *root, std::vector<expr> assumps);
|
check_result CheckUpdateModel(Node *root, std::vector<expr> assumps);
|
||||||
|
|
||||||
/** Determines the value in the counterexample of a symbol occuring in the transformer formula of
|
/** Determines the value in the counterexample of a symbol occuring in the transformer formula of
|
||||||
* a given edge. */
|
* a given edge. */
|
||||||
|
|
||||||
Term Eval(Edge *e, Term t);
|
Term Eval(Edge *e, Term t);
|
||||||
|
|
||||||
/** Return the fact derived at node p in a counterexample. */
|
/** Return the fact derived at node p in a counterexample. */
|
||||||
|
|
||||||
Term EvalNode(Node *p);
|
Term EvalNode(Node *p);
|
||||||
|
|
||||||
/** Returns true if the given node is empty in the primal solution. For proecudure summaries,
|
/** Returns true if the given node is empty in the primal solution. For proecudure summaries,
|
||||||
this means that the procedure is not called in the current counter-model. */
|
this means that the procedure is not called in the current counter-model. */
|
||||||
|
|
||||||
bool Empty(Node *p);
|
bool Empty(Node *p);
|
||||||
|
|
||||||
/** Compute an underapproximation of every node in a tree rooted at "root",
|
/** Compute an underapproximation of every node in a tree rooted at "root",
|
||||||
|
@ -747,11 +748,11 @@ namespace Duality {
|
||||||
void InterpolateByCases(Node *root, Node *node);
|
void InterpolateByCases(Node *root, Node *node);
|
||||||
|
|
||||||
/** Push a scope. Assertions made after Push can be undone by Pop. */
|
/** Push a scope. Assertions made after Push can be undone by Pop. */
|
||||||
|
|
||||||
void Push();
|
void Push();
|
||||||
|
|
||||||
/** Exception thrown when bad clause is encountered */
|
/** Exception thrown when bad clause is encountered */
|
||||||
|
|
||||||
struct bad_clause {
|
struct bad_clause {
|
||||||
std::string msg;
|
std::string msg;
|
||||||
int i;
|
int i;
|
||||||
|
@ -777,7 +778,7 @@ namespace Duality {
|
||||||
// thrown on internal error
|
// thrown on internal error
|
||||||
struct Bad {
|
struct Bad {
|
||||||
};
|
};
|
||||||
|
|
||||||
// thrown on more serious internal error
|
// thrown on more serious internal error
|
||||||
struct ReallyBad {
|
struct ReallyBad {
|
||||||
};
|
};
|
||||||
|
@ -786,56 +787,56 @@ namespace Duality {
|
||||||
struct greedy_reduce_failed {};
|
struct greedy_reduce_failed {};
|
||||||
|
|
||||||
/** Pop a scope (see Push). Note, you cannot pop axioms. */
|
/** Pop a scope (see Push). Note, you cannot pop axioms. */
|
||||||
|
|
||||||
void Pop(int num_scopes);
|
void Pop(int num_scopes);
|
||||||
|
|
||||||
/** Erase the proof by performing a Pop, Push and re-assertion of
|
/** Erase the proof by performing a Pop, Push and re-assertion of
|
||||||
all the popped constraints */
|
all the popped constraints */
|
||||||
void PopPush();
|
void PopPush();
|
||||||
|
|
||||||
/** Return true if the given edge is used in the proof of unsat.
|
/** Return true if the given edge is used in the proof of unsat.
|
||||||
Can be called only after Solve or Check returns an unsat result. */
|
Can be called only after Solve or Check returns an unsat result. */
|
||||||
|
|
||||||
bool EdgeUsedInProof(Edge *edge);
|
bool EdgeUsedInProof(Edge *edge);
|
||||||
|
|
||||||
|
|
||||||
/** Convert a collection of clauses to Nodes and Edges in the RPFP.
|
/** Convert a collection of clauses to Nodes and Edges in the RPFP.
|
||||||
|
|
||||||
Predicate unknowns are uninterpreted predicates not
|
Predicate unknowns are uninterpreted predicates not
|
||||||
occurring in the background theory.
|
occurring in the background theory.
|
||||||
|
|
||||||
Clauses are of the form
|
Clauses are of the form
|
||||||
|
|
||||||
B => P(t_1,...,t_k)
|
B => P(t_1,...,t_k)
|
||||||
|
|
||||||
where P is a predicate unknown and predicate unknowns
|
where P is a predicate unknown and predicate unknowns
|
||||||
occur only positivey in H and only under existential
|
occur only positivey in H and only under existential
|
||||||
quantifiers in prenex form.
|
quantifiers in prenex form.
|
||||||
|
|
||||||
Each predicate unknown maps to a node. Each clause maps to
|
Each predicate unknown maps to a node. Each clause maps to
|
||||||
an edge. Let C be a clause B => P(t_1,...,t_k) where the
|
an edge. Let C be a clause B => P(t_1,...,t_k) where the
|
||||||
sequence of predicate unknowns occurring in B (in order
|
sequence of predicate unknowns occurring in B (in order
|
||||||
of occurrence) is P_1..P_n. The clause maps to a transformer
|
of occurrence) is P_1..P_n. The clause maps to a transformer
|
||||||
T where:
|
T where:
|
||||||
|
|
||||||
T.Relparams = P_1..P_n
|
T.Relparams = P_1..P_n
|
||||||
T.Indparams = x_1...x+k
|
T.Indparams = x_1...x+k
|
||||||
T.Formula = B /\ t_1 = x_1 /\ ... /\ t_k = x_k
|
T.Formula = B /\ t_1 = x_1 /\ ... /\ t_k = x_k
|
||||||
|
|
||||||
Throws exception bad_clause(msg,i) if a clause i is
|
Throws exception bad_clause(msg,i) if a clause i is
|
||||||
in the wrong form.
|
in the wrong form.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct label_struct {
|
struct label_struct {
|
||||||
symbol name;
|
symbol name;
|
||||||
expr value;
|
expr value;
|
||||||
bool pos;
|
bool pos;
|
||||||
label_struct(const symbol &s, const expr &e, bool b)
|
label_struct(const symbol &s, const expr &e, bool b)
|
||||||
: name(s), value(e), pos(b) {}
|
: name(s), value(e), pos(b) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
__declspec(dllexport)
|
__declspec(dllexport)
|
||||||
#endif
|
#endif
|
||||||
|
@ -847,7 +848,7 @@ namespace Duality {
|
||||||
|
|
||||||
void WriteCounterexample(std::ostream &s, Node *node);
|
void WriteCounterexample(std::ostream &s, Node *node);
|
||||||
|
|
||||||
enum FileFormat {DualityFormat, SMT2Format, HornFormat};
|
enum FileFormat {DualityFormat, SMT2Format, HornFormat};
|
||||||
|
|
||||||
/** Write the RPFP to a file (currently in SMTLIB 1.2 format) */
|
/** Write the RPFP to a file (currently in SMTLIB 1.2 format) */
|
||||||
void WriteProblemToFile(std::string filename, FileFormat format = DualityFormat);
|
void WriteProblemToFile(std::string filename, FileFormat format = DualityFormat);
|
||||||
|
@ -870,9 +871,9 @@ namespace Duality {
|
||||||
/** Fuse a vector of transformers. If the total number of inputs of the transformers
|
/** Fuse a vector of transformers. If the total number of inputs of the transformers
|
||||||
is N, then the result is an N-ary transfomer whose output is the union of
|
is N, then the result is an N-ary transfomer whose output is the union of
|
||||||
the outputs of the given transformers. The is, suppose we have a vetor of transfoermers
|
the outputs of the given transformers. The is, suppose we have a vetor of transfoermers
|
||||||
{T_i(r_i1,...,r_iN(i) : i=1..M}. The the result is a transformer
|
{T_i(r_i1,...,r_iN(i) : i=1..M}. The the result is a transformer
|
||||||
|
|
||||||
F(r_11,...,r_iN(1),...,r_M1,...,r_MN(M)) =
|
F(r_11,...,r_iN(1),...,r_M1,...,r_MN(M)) =
|
||||||
T_1(r_11,...,r_iN(1)) U ... U T_M(r_M1,...,r_MN(M))
|
T_1(r_11,...,r_iN(1)) U ... U T_M(r_M1,...,r_MN(M))
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -921,7 +922,7 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void ClearProofCore(){
|
void ClearProofCore(){
|
||||||
if(proof_core)
|
if(proof_core)
|
||||||
delete proof_core;
|
delete proof_core;
|
||||||
|
@ -929,7 +930,7 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
|
|
||||||
Term SuffixVariable(const Term &t, int n);
|
Term SuffixVariable(const Term &t, int n);
|
||||||
|
|
||||||
Term HideVariable(const Term &t, int n);
|
Term HideVariable(const Term &t, int n);
|
||||||
|
|
||||||
void RedVars(Node *node, Term &b, std::vector<Term> &v);
|
void RedVars(Node *node, Term &b, std::vector<Term> &v);
|
||||||
|
@ -958,16 +959,16 @@ namespace Duality {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void WriteInterps(System.IO.StreamWriter f, TermTree t);
|
void WriteInterps(System.IO.StreamWriter f, TermTree t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void WriteEdgeVars(Edge *e, hash_map<ast,int> &memo, const Term &t, std::ostream &s);
|
void WriteEdgeVars(Edge *e, hash_map<ast,int> &memo, const Term &t, std::ostream &s);
|
||||||
|
|
||||||
void WriteEdgeAssignment(std::ostream &s, Edge *e);
|
void WriteEdgeAssignment(std::ostream &s, Edge *e);
|
||||||
|
|
||||||
|
|
||||||
// Scan the clause body for occurrences of the predicate unknowns
|
// Scan the clause body for occurrences of the predicate unknowns
|
||||||
|
|
||||||
Term ScanBody(hash_map<ast,Term> &memo,
|
Term ScanBody(hash_map<ast,Term> &memo,
|
||||||
const Term &t,
|
const Term &t,
|
||||||
hash_map<func_decl,Node *> &pmap,
|
hash_map<func_decl,Node *> &pmap,
|
||||||
std::vector<func_decl> &res,
|
std::vector<func_decl> &res,
|
||||||
|
@ -1035,7 +1036,7 @@ namespace Duality {
|
||||||
void ConstrainEdgeLocalized(Edge *e, const Term &t);
|
void ConstrainEdgeLocalized(Edge *e, const Term &t);
|
||||||
|
|
||||||
void GreedyReduce(solver &s, std::vector<expr> &conjuncts);
|
void GreedyReduce(solver &s, std::vector<expr> &conjuncts);
|
||||||
|
|
||||||
void NegateLits(std::vector<expr> &lits);
|
void NegateLits(std::vector<expr> &lits);
|
||||||
|
|
||||||
expr SimplifyOr(std::vector<expr> &lits);
|
expr SimplifyOr(std::vector<expr> &lits);
|
||||||
|
@ -1053,7 +1054,7 @@ namespace Duality {
|
||||||
void GetGroundLitsUnderQuants(hash_set<ast> *memo, const Term &f, std::vector<Term> &res, int under);
|
void GetGroundLitsUnderQuants(hash_set<ast> *memo, const Term &f, std::vector<Term> &res, int under);
|
||||||
|
|
||||||
Term StrengthenFormulaByCaseSplitting(const Term &f, std::vector<expr> &case_lits);
|
Term StrengthenFormulaByCaseSplitting(const Term &f, std::vector<expr> &case_lits);
|
||||||
|
|
||||||
expr NegateLit(const expr &f);
|
expr NegateLit(const expr &f);
|
||||||
|
|
||||||
expr GetEdgeFormula(Edge *e, int persist, bool with_children, bool underapprox);
|
expr GetEdgeFormula(Edge *e, int persist, bool with_children, bool underapprox);
|
||||||
|
@ -1065,7 +1066,7 @@ namespace Duality {
|
||||||
expr UnhoistPullRec(hash_map<ast,expr> & memo, const expr &w, hash_map<ast,expr> & init_defs, hash_map<ast,expr> & const_params, hash_map<ast,expr> &const_params_inv, std::vector<expr> &new_params);
|
expr UnhoistPullRec(hash_map<ast,expr> & memo, const expr &w, hash_map<ast,expr> & init_defs, hash_map<ast,expr> & const_params, hash_map<ast,expr> &const_params_inv, std::vector<expr> &new_params);
|
||||||
|
|
||||||
void AddParamsToTransformer(Transformer &trans, const std::vector<expr> ¶ms);
|
void AddParamsToTransformer(Transformer &trans, const std::vector<expr> ¶ms);
|
||||||
|
|
||||||
expr AddParamsToApp(const expr &app, const func_decl &new_decl, const std::vector<expr> ¶ms);
|
expr AddParamsToApp(const expr &app, const func_decl &new_decl, const std::vector<expr> ¶ms);
|
||||||
|
|
||||||
expr GetRelRec(hash_set<ast> &memo, const expr &t, const func_decl &rel);
|
expr GetRelRec(hash_set<ast> &memo, const expr &t, const func_decl &rel);
|
||||||
|
@ -1081,7 +1082,7 @@ namespace Duality {
|
||||||
void UnhoistLoop(Edge *loop_edge, Edge *init_edge);
|
void UnhoistLoop(Edge *loop_edge, Edge *init_edge);
|
||||||
|
|
||||||
void Unhoist();
|
void Unhoist();
|
||||||
|
|
||||||
Term ElimIteRec(hash_map<ast,expr> &memo, const Term &t, std::vector<expr> &cnsts);
|
Term ElimIteRec(hash_map<ast,expr> &memo, const Term &t, std::vector<expr> &cnsts);
|
||||||
|
|
||||||
Term ElimIte(const Term &t);
|
Term ElimIte(const Term &t);
|
||||||
|
@ -1089,11 +1090,11 @@ namespace Duality {
|
||||||
void MarkLiveNodes(hash_map<Node *,std::vector<Edge *> > &outgoing, hash_set<Node *> &live_nodes, Node *node);
|
void MarkLiveNodes(hash_map<Node *,std::vector<Edge *> > &outgoing, hash_set<Node *> &live_nodes, Node *node);
|
||||||
|
|
||||||
virtual void slvr_add(const expr &e);
|
virtual void slvr_add(const expr &e);
|
||||||
|
|
||||||
virtual void slvr_pop(int i);
|
virtual void slvr_pop(int i);
|
||||||
|
|
||||||
virtual void slvr_push();
|
virtual void slvr_push();
|
||||||
|
|
||||||
virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0);
|
virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0);
|
||||||
|
|
||||||
virtual lbool ls_interpolate_tree(TermTree *assumptions,
|
virtual lbool ls_interpolate_tree(TermTree *assumptions,
|
||||||
|
@ -1105,14 +1106,14 @@ namespace Duality {
|
||||||
virtual bool proof_core_contains(const expr &e);
|
virtual bool proof_core_contains(const expr &e);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** RPFP solver base class. */
|
/** RPFP solver base class. */
|
||||||
|
|
||||||
class Solver {
|
class Solver {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class Counterexample {
|
class Counterexample {
|
||||||
private:
|
private:
|
||||||
RPFP *tree;
|
RPFP *tree;
|
||||||
|
@ -1148,18 +1149,18 @@ namespace Duality {
|
||||||
Counterexample &operator=(const Counterexample &);
|
Counterexample &operator=(const Counterexample &);
|
||||||
Counterexample(const Counterexample &);
|
Counterexample(const Counterexample &);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Solve the problem. You can optionally give an old
|
/** Solve the problem. You can optionally give an old
|
||||||
counterexample to use as a guide. This is chiefly useful for
|
counterexample to use as a guide. This is chiefly useful for
|
||||||
abstraction refinement metholdologies, and is only used as a
|
abstraction refinement metholdologies, and is only used as a
|
||||||
heuristic. */
|
heuristic. */
|
||||||
|
|
||||||
virtual bool Solve() = 0;
|
virtual bool Solve() = 0;
|
||||||
|
|
||||||
virtual Counterexample &GetCounterexample() = 0;
|
virtual Counterexample &GetCounterexample() = 0;
|
||||||
|
|
||||||
virtual bool SetOption(const std::string &option, const std::string &value) = 0;
|
virtual bool SetOption(const std::string &option, const std::string &value) = 0;
|
||||||
|
|
||||||
/** Learn heuristic information from another solver. This
|
/** Learn heuristic information from another solver. This
|
||||||
is chiefly useful for abstraction refinement, when we want to
|
is chiefly useful for abstraction refinement, when we want to
|
||||||
solve a series of similar problems. */
|
solve a series of similar problems. */
|
||||||
|
@ -1184,7 +1185,7 @@ namespace Duality {
|
||||||
|
|
||||||
/** Object thrown on cancellation */
|
/** Object thrown on cancellation */
|
||||||
struct Canceled {};
|
struct Canceled {};
|
||||||
|
|
||||||
/** Object thrown on incompleteness */
|
/** Object thrown on incompleteness */
|
||||||
struct Incompleteness {};
|
struct Incompleteness {};
|
||||||
};
|
};
|
||||||
|
@ -1235,16 +1236,16 @@ namespace Duality {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** appends assumption literals for edge to lits. if with_children is true,
|
/** appends assumption literals for edge to lits. if with_children is true,
|
||||||
includes that annotation of the edge's children.
|
includes that annotation of the edge's children.
|
||||||
*/
|
*/
|
||||||
void AssertEdgeCache(Edge *e, std::vector<Term> &lits, bool with_children = false);
|
void AssertEdgeCache(Edge *e, std::vector<Term> &lits, bool with_children = false);
|
||||||
|
|
||||||
/** appends assumption literals for node to lits */
|
/** appends assumption literals for node to lits */
|
||||||
void AssertNodeCache(Node *, std::vector<Term> lits);
|
void AssertNodeCache(Node *, std::vector<Term> lits);
|
||||||
|
|
||||||
/** check assumption lits, and return core */
|
/** check assumption lits, and return core */
|
||||||
check_result CheckCore(const std::vector<Term> &assumps, std::vector<Term> &core);
|
check_result CheckCore(const std::vector<Term> &assumps, std::vector<Term> &core);
|
||||||
|
|
||||||
/** Clone another RPFP into this one, keeping a map */
|
/** Clone another RPFP into this one, keeping a map */
|
||||||
void Clone(RPFP *other);
|
void Clone(RPFP *other);
|
||||||
|
|
||||||
|
@ -1287,7 +1288,7 @@ namespace Duality {
|
||||||
uptr<solver> slvr;
|
uptr<solver> slvr;
|
||||||
};
|
};
|
||||||
hash_map<Edge *, edge_solver > edge_solvers;
|
hash_map<Edge *, edge_solver > edge_solvers;
|
||||||
|
|
||||||
#ifdef LIMIT_STACK_WEIGHT
|
#ifdef LIMIT_STACK_WEIGHT
|
||||||
struct weight_counter {
|
struct weight_counter {
|
||||||
int val;
|
int val;
|
||||||
|
@ -1296,7 +1297,7 @@ namespace Duality {
|
||||||
std::swap(val,other.val);
|
std::swap(val,other.val);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct big_stack_entry {
|
struct big_stack_entry {
|
||||||
weight_counter weight_added;
|
weight_counter weight_added;
|
||||||
std::vector<expr> new_alits;
|
std::vector<expr> new_alits;
|
||||||
|
@ -1319,11 +1320,11 @@ namespace Duality {
|
||||||
void ConstrainEdgeLocalizedCache(Edge *e, const Term &tl, std::vector<expr> &lits);
|
void ConstrainEdgeLocalizedCache(Edge *e, const Term &tl, std::vector<expr> &lits);
|
||||||
|
|
||||||
virtual void slvr_add(const expr &e);
|
virtual void slvr_add(const expr &e);
|
||||||
|
|
||||||
virtual void slvr_pop(int i);
|
virtual void slvr_pop(int i);
|
||||||
|
|
||||||
virtual void slvr_push();
|
virtual void slvr_push();
|
||||||
|
|
||||||
virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0);
|
virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0);
|
||||||
|
|
||||||
virtual lbool ls_interpolate_tree(TermTree *assumptions,
|
virtual lbool ls_interpolate_tree(TermTree *assumptions,
|
||||||
|
@ -1348,7 +1349,7 @@ namespace Duality {
|
||||||
scoped_solver_for_edge(RPFP_caching *_rpfp, Edge *edge, bool models = false, bool axioms = false){
|
scoped_solver_for_edge(RPFP_caching *_rpfp, Edge *edge, bool models = false, bool axioms = false){
|
||||||
rpfp = _rpfp;
|
rpfp = _rpfp;
|
||||||
orig_slvr = rpfp->ls->slvr;
|
orig_slvr = rpfp->ls->slvr;
|
||||||
es = &(rpfp->SolverForEdge(edge,models,axioms));
|
es = &(rpfp->SolverForEdge(edge,models,axioms));
|
||||||
rpfp->ls->slvr = es->slvr.get();
|
rpfp->ls->slvr = es->slvr.get();
|
||||||
rpfp->AssumptionLits.swap(es->AssumptionLits);
|
rpfp->AssumptionLits.swap(es->AssumptionLits);
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ namespace Duality {
|
||||||
m_datalog_fid = m().mk_family_id("datalog_relation");
|
m_datalog_fid = m().mk_family_id("datalog_relation");
|
||||||
}
|
}
|
||||||
~context() { }
|
~context() { }
|
||||||
|
|
||||||
ast_manager &m() const {return *(ast_manager *)&mgr;}
|
ast_manager &m() const {return *(ast_manager *)&mgr;}
|
||||||
|
|
||||||
void set(char const * param, char const * value) { m_config.set(param,value); }
|
void set(char const * param, char const * value) { m_config.set(param,value); }
|
||||||
|
@ -186,13 +186,13 @@ namespace Duality {
|
||||||
|
|
||||||
symbol str_symbol(char const * s);
|
symbol str_symbol(char const * s);
|
||||||
symbol int_symbol(int n);
|
symbol int_symbol(int n);
|
||||||
|
|
||||||
sort bool_sort();
|
sort bool_sort();
|
||||||
sort int_sort();
|
sort int_sort();
|
||||||
sort real_sort();
|
sort real_sort();
|
||||||
sort bv_sort(unsigned sz);
|
sort bv_sort(unsigned sz);
|
||||||
sort array_sort(sort d, sort r);
|
sort array_sort(sort d, sort r);
|
||||||
|
|
||||||
func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);
|
func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);
|
||||||
func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);
|
func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);
|
||||||
func_decl function(char const * name, sort const & domain, sort const & range);
|
func_decl function(char const * name, sort const & domain, sort const & range);
|
||||||
|
@ -210,22 +210,22 @@ namespace Duality {
|
||||||
expr int_const(char const * name);
|
expr int_const(char const * name);
|
||||||
expr real_const(char const * name);
|
expr real_const(char const * name);
|
||||||
expr bv_const(char const * name, unsigned sz);
|
expr bv_const(char const * name, unsigned sz);
|
||||||
|
|
||||||
expr bool_val(bool b);
|
expr bool_val(bool b);
|
||||||
|
|
||||||
expr int_val(int n);
|
expr int_val(int n);
|
||||||
expr int_val(unsigned n);
|
expr int_val(unsigned n);
|
||||||
expr int_val(char const * n);
|
expr int_val(char const * n);
|
||||||
|
|
||||||
expr real_val(int n, int d);
|
expr real_val(int n, int d);
|
||||||
expr real_val(int n);
|
expr real_val(int n);
|
||||||
expr real_val(unsigned n);
|
expr real_val(unsigned n);
|
||||||
expr real_val(char const * n);
|
expr real_val(char const * n);
|
||||||
|
|
||||||
expr bv_val(int n, unsigned sz);
|
expr bv_val(int n, unsigned sz);
|
||||||
expr bv_val(unsigned n, unsigned sz);
|
expr bv_val(unsigned n, unsigned sz);
|
||||||
expr bv_val(char const * n, unsigned sz);
|
expr bv_val(char const * n, unsigned sz);
|
||||||
|
|
||||||
expr num_val(int n, sort const & s);
|
expr num_val(int n, sort const & s);
|
||||||
|
|
||||||
expr mki(family_id fid, ::decl_kind dk, int n, ::expr **args);
|
expr mki(family_id fid, ::decl_kind dk, int n, ::expr **args);
|
||||||
|
@ -281,17 +281,17 @@ namespace Duality {
|
||||||
object(object const & s):m_ctx(s.m_ctx) {}
|
object(object const & s):m_ctx(s.m_ctx) {}
|
||||||
context & ctx() const { return *m_ctx; }
|
context & ctx() const { return *m_ctx; }
|
||||||
friend void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
|
friend void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
|
||||||
ast_manager &m() const {return m_ctx->m();}
|
ast_manager &m() const {return m_ctx->m();}
|
||||||
};
|
};
|
||||||
|
|
||||||
class symbol : public object {
|
class symbol : public object {
|
||||||
::symbol m_sym;
|
::symbol m_sym;
|
||||||
public:
|
public:
|
||||||
symbol(context & c, ::symbol s):object(c), m_sym(s) {}
|
symbol(context & c, ::symbol s):object(c), m_sym(s) {}
|
||||||
symbol(symbol const & s):object(s), m_sym(s.m_sym) {}
|
symbol(symbol const & s):object(s), m_sym(s.m_sym) {}
|
||||||
symbol & operator=(symbol const & s) { m_ctx = s.m_ctx; m_sym = s.m_sym; return *this; }
|
symbol & operator=(symbol const & s) { m_ctx = s.m_ctx; m_sym = s.m_sym; return *this; }
|
||||||
operator ::symbol() const {return m_sym;}
|
operator ::symbol() const {return m_sym;}
|
||||||
std::string str() const {
|
std::string str() const {
|
||||||
if (m_sym.is_numerical()) {
|
if (m_sym.is_numerical()) {
|
||||||
std::ostringstream buffer;
|
std::ostringstream buffer;
|
||||||
buffer << m_sym.get_num();
|
buffer << m_sym.get_num();
|
||||||
|
@ -300,13 +300,13 @@ namespace Duality {
|
||||||
else {
|
else {
|
||||||
return m_sym.bare_str();
|
return m_sym.bare_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
friend std::ostream & operator<<(std::ostream & out, symbol const & s){
|
friend std::ostream & operator<<(std::ostream & out, symbol const & s) {
|
||||||
return out << s.str();
|
return out << s.str();
|
||||||
}
|
}
|
||||||
friend bool operator==(const symbol &x, const symbol &y){
|
friend bool operator==(const symbol &x, const symbol &y) {
|
||||||
return x.m_sym == y.m_sym;
|
return x.m_sym == y.m_sym;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class params : public config {};
|
class params : public config {};
|
||||||
|
@ -318,7 +318,7 @@ namespace Duality {
|
||||||
public:
|
public:
|
||||||
::ast * const &raw() const {return _ast;}
|
::ast * const &raw() const {return _ast;}
|
||||||
ast_i(context & c, ::ast *a = 0) : object(c) {_ast = a;}
|
ast_i(context & c, ::ast *a = 0) : object(c) {_ast = a;}
|
||||||
|
|
||||||
ast_i(){_ast = 0;}
|
ast_i(){_ast = 0;}
|
||||||
bool eq(const ast_i &other) const {
|
bool eq(const ast_i &other) const {
|
||||||
return _ast == other._ast;
|
return _ast == other._ast;
|
||||||
|
@ -345,19 +345,19 @@ namespace Duality {
|
||||||
operator ::ast*() const { return raw(); }
|
operator ::ast*() const { return raw(); }
|
||||||
friend bool eq(ast const & a, ast const & b) { return a.raw() == b.raw(); }
|
friend bool eq(ast const & a, ast const & b) { return a.raw() == b.raw(); }
|
||||||
|
|
||||||
|
|
||||||
ast(context &c, ::ast *a = 0) : ast_i(c,a) {
|
ast(context &c, ::ast *a = 0) : ast_i(c,a) {
|
||||||
if(_ast)
|
if(_ast)
|
||||||
m().inc_ref(a);
|
m().inc_ref(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast() {}
|
ast() {}
|
||||||
|
|
||||||
ast(const ast &other) : ast_i(other) {
|
ast(const ast &other) : ast_i(other) {
|
||||||
if(_ast)
|
if(_ast)
|
||||||
m().inc_ref(_ast);
|
m().inc_ref(_ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast &operator=(const ast &other) {
|
ast &operator=(const ast &other) {
|
||||||
if(_ast)
|
if(_ast)
|
||||||
m().dec_ref(_ast);
|
m().dec_ref(_ast);
|
||||||
|
@ -367,7 +367,7 @@ namespace Duality {
|
||||||
m().inc_ref(_ast);
|
m().inc_ref(_ast);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ast(){
|
~ast(){
|
||||||
if(_ast)
|
if(_ast)
|
||||||
m().dec_ref(_ast);
|
m().dec_ref(_ast);
|
||||||
|
@ -386,15 +386,15 @@ namespace Duality {
|
||||||
sort & operator=(sort const & s) { return static_cast<sort&>(ast::operator=(s)); }
|
sort & operator=(sort const & s) { return static_cast<sort&>(ast::operator=(s)); }
|
||||||
|
|
||||||
bool is_bool() const { return m().is_bool(*this); }
|
bool is_bool() const { return m().is_bool(*this); }
|
||||||
bool is_int() const { return ctx().get_sort_kind(*this) == IntSort; }
|
bool is_int() const { return ctx().get_sort_kind(*this) == IntSort; }
|
||||||
bool is_real() const { return ctx().get_sort_kind(*this) == RealSort; }
|
bool is_real() const { return ctx().get_sort_kind(*this) == RealSort; }
|
||||||
bool is_arith() const;
|
bool is_arith() const;
|
||||||
bool is_array() const { return ctx().get_sort_kind(*this) == ArraySort; }
|
bool is_array() const { return ctx().get_sort_kind(*this) == ArraySort; }
|
||||||
bool is_datatype() const;
|
bool is_datatype() const;
|
||||||
bool is_relation() const;
|
bool is_relation() const;
|
||||||
bool is_finite_domain() const;
|
bool is_finite_domain() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sort array_domain() const;
|
sort array_domain() const;
|
||||||
sort array_range() const;
|
sort array_range() const;
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class func_decl : public ast {
|
class func_decl : public ast {
|
||||||
public:
|
public:
|
||||||
func_decl() : ast() {}
|
func_decl() : ast() {}
|
||||||
|
@ -413,7 +413,7 @@ namespace Duality {
|
||||||
func_decl(func_decl const & s):ast(s) {}
|
func_decl(func_decl const & s):ast(s) {}
|
||||||
operator ::func_decl*() const { return to_func_decl(*this); }
|
operator ::func_decl*() const { return to_func_decl(*this); }
|
||||||
func_decl & operator=(func_decl const & s) { return static_cast<func_decl&>(ast::operator=(s)); }
|
func_decl & operator=(func_decl const & s) { return static_cast<func_decl&>(ast::operator=(s)); }
|
||||||
|
|
||||||
unsigned arity() const;
|
unsigned arity() const;
|
||||||
sort domain(unsigned i) const;
|
sort domain(unsigned i) const;
|
||||||
sort range() const;
|
sort range() const;
|
||||||
|
@ -434,9 +434,9 @@ namespace Duality {
|
||||||
expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const;
|
expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const;
|
||||||
expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const;
|
expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const;
|
||||||
|
|
||||||
func_decl get_func_decl_parameter(unsigned idx){
|
func_decl get_func_decl_parameter(unsigned idx){
|
||||||
return func_decl(ctx(),to_func_decl(to_func_decl(raw())->get_parameters()[idx].get_ast()));
|
return func_decl(ctx(),to_func_decl(to_func_decl(raw())->get_parameters()[idx].get_ast()));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -447,8 +447,8 @@ namespace Duality {
|
||||||
expr(context & c, ::ast *n):ast(c, n) {}
|
expr(context & c, ::ast *n):ast(c, n) {}
|
||||||
expr(expr const & n):ast(n) {}
|
expr(expr const & n):ast(n) {}
|
||||||
expr & operator=(expr const & n) { return static_cast<expr&>(ast::operator=(n)); }
|
expr & operator=(expr const & n) { return static_cast<expr&>(ast::operator=(n)); }
|
||||||
operator ::expr*() const { return to_expr(raw()); }
|
operator ::expr*() const { return to_expr(raw()); }
|
||||||
unsigned get_id() const {return to_expr(raw())->get_id();}
|
unsigned get_id() const {return to_expr(raw())->get_id();}
|
||||||
|
|
||||||
sort get_sort() const { return sort(ctx(),m().get_sort(to_expr(raw()))); }
|
sort get_sort() const { return sort(ctx(),m().get_sort(to_expr(raw()))); }
|
||||||
|
|
||||||
|
@ -460,27 +460,27 @@ namespace Duality {
|
||||||
bool is_datatype() const { return get_sort().is_datatype(); }
|
bool is_datatype() const { return get_sort().is_datatype(); }
|
||||||
bool is_relation() const { return get_sort().is_relation(); }
|
bool is_relation() const { return get_sort().is_relation(); }
|
||||||
bool is_finite_domain() const { return get_sort().is_finite_domain(); }
|
bool is_finite_domain() const { return get_sort().is_finite_domain(); }
|
||||||
bool is_true() const {return is_app() && decl().get_decl_kind() == True; }
|
bool is_true() const {return is_app() && decl().get_decl_kind() == True; }
|
||||||
|
|
||||||
bool is_numeral() const {
|
bool is_numeral() const {
|
||||||
return is_app() && decl().get_decl_kind() == OtherArith && m().is_unique_value(to_expr(raw()));
|
return is_app() && decl().get_decl_kind() == OtherArith && m().is_unique_value(to_expr(raw()));
|
||||||
}
|
}
|
||||||
bool is_app() const {return raw()->get_kind() == AST_APP;}
|
bool is_app() const {return raw()->get_kind() == AST_APP;}
|
||||||
bool is_quantifier() const {return raw()->get_kind() == AST_QUANTIFIER;}
|
bool is_quantifier() const {return raw()->get_kind() == AST_QUANTIFIER;}
|
||||||
bool is_var() const {return raw()->get_kind() == AST_VAR;}
|
bool is_var() const {return raw()->get_kind() == AST_VAR;}
|
||||||
bool is_label (bool &pos,std::vector<symbol> &names) const ;
|
bool is_label (bool &pos,std::vector<symbol> &names) const ;
|
||||||
bool is_ground() const {return to_app(raw())->is_ground();}
|
bool is_ground() const {return to_app(raw())->is_ground();}
|
||||||
bool has_quantifiers() const {return to_app(raw())->has_quantifiers();}
|
bool has_quantifiers() const {return to_app(raw())->has_quantifiers();}
|
||||||
bool has_free(int idx) const {
|
bool has_free(int idx) const {
|
||||||
used_vars proc;
|
used_vars proc;
|
||||||
proc.process(to_expr(raw()));
|
proc.process(to_expr(raw()));
|
||||||
return proc.contains(idx);
|
return proc.contains(idx);
|
||||||
}
|
}
|
||||||
unsigned get_max_var_idx_plus_1() const {
|
unsigned get_max_var_idx_plus_1() const {
|
||||||
used_vars proc;
|
used_vars proc;
|
||||||
proc.process(to_expr(raw()));
|
proc.process(to_expr(raw()));
|
||||||
return proc.get_max_found_var_idx_plus_1();
|
return proc.get_max_found_var_idx_plus_1();
|
||||||
}
|
}
|
||||||
|
|
||||||
// operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); }
|
// operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); }
|
||||||
func_decl decl() const {return func_decl(ctx(),to_app(raw())->get_decl());}
|
func_decl decl() const {return func_decl(ctx(),to_app(raw())->get_decl());}
|
||||||
|
@ -493,11 +493,11 @@ namespace Duality {
|
||||||
return 1;
|
return 1;
|
||||||
case AST_VAR:
|
case AST_VAR:
|
||||||
return 0;
|
return 0;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
SASSERT(0);
|
SASSERT(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
expr arg(unsigned i) const {
|
expr arg(unsigned i) const {
|
||||||
ast_kind dk = raw()->get_kind();
|
ast_kind dk = raw()->get_kind();
|
||||||
switch(dk){
|
switch(dk){
|
||||||
|
@ -509,25 +509,25 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
assert(0);
|
assert(0);
|
||||||
return expr();
|
return expr();
|
||||||
}
|
}
|
||||||
|
|
||||||
expr body() const {
|
expr body() const {
|
||||||
return ctx().cook(to_quantifier(raw())->get_expr());
|
return ctx().cook(to_quantifier(raw())->get_expr());
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr operator!(expr const & a) {
|
friend expr operator!(expr const & a) {
|
||||||
// ::expr *e = a;
|
// ::expr *e = a;
|
||||||
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_NOT,a));
|
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_NOT,a));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr operator&&(expr const & a, expr const & b) {
|
friend expr operator&&(expr const & a, expr const & b) {
|
||||||
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_AND,a,b));
|
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_AND,a,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr operator||(expr const & a, expr const & b) {
|
friend expr operator||(expr const & a, expr const & b) {
|
||||||
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_OR,a,b));
|
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_OR,a,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr implies(expr const & a, expr const & b) {
|
friend expr implies(expr const & a, expr const & b) {
|
||||||
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_IMPLIES,a,b));
|
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_IMPLIES,a,b));
|
||||||
}
|
}
|
||||||
|
@ -546,12 +546,12 @@ namespace Duality {
|
||||||
|
|
||||||
friend expr operator*(expr const & a, expr const & b) {
|
friend expr operator*(expr const & a, expr const & b) {
|
||||||
return a.ctx().make(Times,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_MUL,a,b));
|
return a.ctx().make(Times,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_MUL,a,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr operator/(expr const & a, expr const & b) {
|
friend expr operator/(expr const & a, expr const & b) {
|
||||||
return a.ctx().make(Div,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_DIV,a,b));
|
return a.ctx().make(Div,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_DIV,a,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr operator-(expr const & a) {
|
friend expr operator-(expr const & a) {
|
||||||
return a.ctx().make(Uminus,a); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_UMINUS,a));
|
return a.ctx().make(Uminus,a); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_UMINUS,a));
|
||||||
}
|
}
|
||||||
|
@ -562,71 +562,71 @@ namespace Duality {
|
||||||
|
|
||||||
friend expr operator<=(expr const & a, expr const & b) {
|
friend expr operator<=(expr const & a, expr const & b) {
|
||||||
return a.ctx().make(Leq,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_LE,a,b));
|
return a.ctx().make(Leq,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_LE,a,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr operator>=(expr const & a, expr const & b) {
|
friend expr operator>=(expr const & a, expr const & b) {
|
||||||
return a.ctx().make(Geq,a,b); //expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GE,a,b));
|
return a.ctx().make(Geq,a,b); //expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GE,a,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr operator<(expr const & a, expr const & b) {
|
friend expr operator<(expr const & a, expr const & b) {
|
||||||
return a.ctx().make(Lt,a,b); expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_LT,a,b));
|
return a.ctx().make(Lt,a,b); expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_LT,a,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr operator>(expr const & a, expr const & b) {
|
friend expr operator>(expr const & a, expr const & b) {
|
||||||
return a.ctx().make(Gt,a,b); expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GT,a,b));
|
return a.ctx().make(Gt,a,b); expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GT,a,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
expr simplify() const;
|
expr simplify() const;
|
||||||
|
|
||||||
expr simplify(params const & p) const;
|
expr simplify(params const & p) const;
|
||||||
|
|
||||||
expr qe_lite() const;
|
expr qe_lite() const;
|
||||||
|
|
||||||
expr qe_lite(const std::set<int> &idxs, bool index_of_bound) const;
|
expr qe_lite(const std::set<int> &idxs, bool index_of_bound) const;
|
||||||
|
|
||||||
friend expr clone_quantifier(const expr &, const expr &);
|
friend expr clone_quantifier(const expr &, const expr &);
|
||||||
|
|
||||||
friend expr clone_quantifier(const expr &q, const expr &b, const std::vector<expr> &patterns);
|
friend expr clone_quantifier(const expr &q, const expr &b, const std::vector<expr> &patterns);
|
||||||
|
|
||||||
friend expr clone_quantifier(decl_kind, const expr &, const expr &);
|
friend expr clone_quantifier(decl_kind, const expr &, const expr &);
|
||||||
|
|
||||||
friend std::ostream & operator<<(std::ostream & out, expr const & m){
|
friend std::ostream & operator<<(std::ostream & out, expr const & m){
|
||||||
m.ctx().print_expr(out,m);
|
m.ctx().print_expr(out,m);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_patterns(std::vector<expr> &pats) const ;
|
void get_patterns(std::vector<expr> &pats) const ;
|
||||||
|
|
||||||
unsigned get_quantifier_num_bound() const {
|
unsigned get_quantifier_num_bound() const {
|
||||||
return to_quantifier(raw())->get_num_decls();
|
return to_quantifier(raw())->get_num_decls();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned get_index_value() const {
|
unsigned get_index_value() const {
|
||||||
var* va = to_var(raw());
|
var* va = to_var(raw());
|
||||||
return va->get_idx();
|
return va->get_idx();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_quantifier_forall() const {
|
bool is_quantifier_forall() const {
|
||||||
return to_quantifier(raw())->is_forall();
|
return to_quantifier(raw())->is_forall();
|
||||||
}
|
}
|
||||||
|
|
||||||
sort get_quantifier_bound_sort(unsigned n) const {
|
sort get_quantifier_bound_sort(unsigned n) const {
|
||||||
return sort(ctx(),to_quantifier(raw())->get_decl_sort(n));
|
return sort(ctx(),to_quantifier(raw())->get_decl_sort(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol get_quantifier_bound_name(unsigned n) const {
|
symbol get_quantifier_bound_name(unsigned n) const {
|
||||||
return symbol(ctx(),to_quantifier(raw())->get_decl_names()[n]);
|
return symbol(ctx(),to_quantifier(raw())->get_decl_names()[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend expr forall(const std::vector<expr> &quants, const expr &body);
|
friend expr forall(const std::vector<expr> &quants, const expr &body);
|
||||||
|
|
||||||
friend expr exists(const std::vector<expr> &quants, const expr &body);
|
friend expr exists(const std::vector<expr> &quants, const expr &body);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef ::decl_kind pfrule;
|
typedef ::decl_kind pfrule;
|
||||||
|
|
||||||
class proof : public ast {
|
class proof : public ast {
|
||||||
public:
|
public:
|
||||||
proof(context & c):ast(c) {}
|
proof(context & c):ast(c) {}
|
||||||
|
@ -643,15 +643,15 @@ namespace Duality {
|
||||||
unsigned num_prems() const {
|
unsigned num_prems() const {
|
||||||
return to_app(raw())->get_num_args() - 1;
|
return to_app(raw())->get_num_args() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
expr conc() const {
|
expr conc() const {
|
||||||
return ctx().cook(to_app(raw())->get_arg(num_prems()));
|
return ctx().cook(to_app(raw())->get_arg(num_prems()));
|
||||||
}
|
}
|
||||||
|
|
||||||
proof prem(unsigned i) const {
|
proof prem(unsigned i) const {
|
||||||
return proof(ctx(),to_app(to_app(raw())->get_arg(i)));
|
return proof(ctx(),to_app(to_app(raw())->get_arg(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_assumptions(std::vector<expr> &assumps);
|
void get_assumptions(std::vector<expr> &assumps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -675,12 +675,12 @@ namespace Duality {
|
||||||
T back() const { return operator[](size() - 1); }
|
T back() const { return operator[](size() - 1); }
|
||||||
void pop_back() { assert(size() > 0); resize(size() - 1); }
|
void pop_back() { assert(size() > 0); resize(size() - 1); }
|
||||||
bool empty() const { return size() == 0; }
|
bool empty() const { return size() == 0; }
|
||||||
ast_vector_tpl & operator=(ast_vector_tpl const & s) {
|
ast_vector_tpl & operator=(ast_vector_tpl const & s) {
|
||||||
Z3_ast_vector_inc_ref(s.ctx(), s.m_vector);
|
Z3_ast_vector_inc_ref(s.ctx(), s.m_vector);
|
||||||
// Z3_ast_vector_dec_ref(ctx(), m_vector);
|
// Z3_ast_vector_dec_ref(ctx(), m_vector);
|
||||||
m_ctx = s.m_ctx;
|
m_ctx = s.m_ctx;
|
||||||
m_vector = s.m_vector;
|
m_vector = s.m_vector;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
friend std::ostream & operator<<(std::ostream & out, ast_vector_tpl const & v) { out << Z3_ast_vector_to_string(v.ctx(), v); return out; }
|
friend std::ostream & operator<<(std::ostream & out, ast_vector_tpl const & v) { out << Z3_ast_vector_to_string(v.ctx(), v); return out; }
|
||||||
};
|
};
|
||||||
|
@ -705,9 +705,9 @@ namespace Duality {
|
||||||
~func_interp() { }
|
~func_interp() { }
|
||||||
operator ::func_interp *() const { return m_interp; }
|
operator ::func_interp *() const { return m_interp; }
|
||||||
func_interp & operator=(func_interp const & s) {
|
func_interp & operator=(func_interp const & s) {
|
||||||
m_ctx = s.m_ctx;
|
m_ctx = s.m_ctx;
|
||||||
m_interp = s.m_interp;
|
m_interp = s.m_interp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
unsigned num_entries() const { return m_interp->num_entries(); }
|
unsigned num_entries() const { return m_interp->num_entries(); }
|
||||||
expr get_arg(unsigned ent, unsigned arg) const {
|
expr get_arg(unsigned ent, unsigned arg) const {
|
||||||
|
@ -729,32 +729,32 @@ namespace Duality {
|
||||||
m_model = m;
|
m_model = m;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
model(context & c, ::model * m = 0):object(c), m_model(m) { }
|
model(context & c, ::model * m = 0):object(c), m_model(m) { }
|
||||||
model(model const & s):object(s), m_model(s.m_model) { }
|
model(model const & s):object(s), m_model(s.m_model) { }
|
||||||
~model() { }
|
~model() { }
|
||||||
operator ::model *() const { return m_model.get(); }
|
operator ::model *() const { return m_model.get(); }
|
||||||
model & operator=(model const & s) {
|
model & operator=(model const & s) {
|
||||||
// ::model *_inc_ref(s.ctx(), s.m_model);
|
// ::model *_inc_ref(s.ctx(), s.m_model);
|
||||||
// ::model *_dec_ref(ctx(), m_model);
|
// ::model *_dec_ref(ctx(), m_model);
|
||||||
m_ctx = s.m_ctx;
|
m_ctx = s.m_ctx;
|
||||||
m_model = s.m_model.get();
|
m_model = s.m_model.get();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
model & operator=(::model *s) {
|
model & operator=(::model *s) {
|
||||||
m_model = s;
|
m_model = s;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
bool null() const {return !m_model;}
|
bool null() const {return !m_model;}
|
||||||
|
|
||||||
expr eval(expr const & n, bool model_completion=true) const {
|
expr eval(expr const & n, bool model_completion=true) const {
|
||||||
::model * _m = m_model.get();
|
::model * _m = m_model.get();
|
||||||
expr_ref result(ctx().m());
|
expr_ref result(ctx().m());
|
||||||
_m->eval(n, result, model_completion);
|
_m->eval(n, result, model_completion);
|
||||||
return expr(ctx(), result);
|
return expr(ctx(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show() const;
|
void show() const;
|
||||||
void show_hash() const;
|
void show_hash() const;
|
||||||
|
|
||||||
unsigned num_consts() const {return m_model.get()->get_num_constants();}
|
unsigned num_consts() const {return m_model.get()->get_num_constants();}
|
||||||
unsigned num_funcs() const {return m_model.get()->get_num_functions();}
|
unsigned num_funcs() const {return m_model.get()->get_num_functions();}
|
||||||
|
@ -765,11 +765,11 @@ namespace Duality {
|
||||||
|
|
||||||
expr get_const_interp(func_decl f) const {
|
expr get_const_interp(func_decl f) const {
|
||||||
return ctx().cook(m_model->get_const_interp(to_func_decl(f.raw())));
|
return ctx().cook(m_model->get_const_interp(to_func_decl(f.raw())));
|
||||||
}
|
}
|
||||||
|
|
||||||
func_interp get_func_interp(func_decl f) const {
|
func_interp get_func_interp(func_decl f) const {
|
||||||
return func_interp(ctx(),m_model->get_func_interp(to_func_decl(f.raw())));
|
return func_interp(ctx(),m_model->get_func_interp(to_func_decl(f.raw())));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
friend std::ostream & operator<<(std::ostream & out, model const & m) { out << Z3_model_to_string(m.ctx(), m); return out; }
|
friend std::ostream & operator<<(std::ostream & out, model const & m) { out << Z3_model_to_string(m.ctx(), m); return out; }
|
||||||
|
@ -792,9 +792,9 @@ namespace Duality {
|
||||||
stats & operator=(stats const & s) {
|
stats & operator=(stats const & s) {
|
||||||
Z3_stats_inc_ref(s.ctx(), s.m_stats);
|
Z3_stats_inc_ref(s.ctx(), s.m_stats);
|
||||||
if (m_stats) Z3_stats_dec_ref(ctx(), m_stats);
|
if (m_stats) Z3_stats_dec_ref(ctx(), m_stats);
|
||||||
m_ctx = s.m_ctx;
|
m_ctx = s.m_ctx;
|
||||||
m_stats = s.m_stats;
|
m_stats = s.m_stats;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
unsigned size() const { return Z3_stats_size(ctx(), m_stats); }
|
unsigned size() const { return Z3_stats_size(ctx(), m_stats); }
|
||||||
std::string key(unsigned i) const { Z3_string s = Z3_stats_get_key(ctx(), m_stats, i); check_error(); return s; }
|
std::string key(unsigned i) const { Z3_string s = Z3_stats_get_key(ctx(), m_stats, i); check_error(); return s; }
|
||||||
|
@ -820,7 +820,7 @@ namespace Duality {
|
||||||
void assert_cnst(const expr &cnst);
|
void assert_cnst(const expr &cnst);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream & operator<<(std::ostream & out, check_result r) {
|
inline std::ostream & operator<<(std::ostream & out, check_result r) {
|
||||||
if (r == unsat) out << "unsat";
|
if (r == unsat) out << "unsat";
|
||||||
else if (r == sat) out << "sat";
|
else if (r == sat) out << "sat";
|
||||||
else out << "unknown";
|
else out << "unknown";
|
||||||
|
@ -837,54 +837,54 @@ namespace Duality {
|
||||||
protected:
|
protected:
|
||||||
::solver *m_solver;
|
::solver *m_solver;
|
||||||
model the_model;
|
model the_model;
|
||||||
bool canceled;
|
bool canceled;
|
||||||
proof_gen_mode m_mode;
|
proof_gen_mode m_mode;
|
||||||
bool extensional;
|
bool extensional;
|
||||||
public:
|
public:
|
||||||
solver(context & c, bool extensional = false, bool models = true);
|
solver(context & c, bool extensional = false, bool models = true);
|
||||||
solver(context & c, ::solver *s):object(c),the_model(c) { m_solver = s; canceled = false;}
|
solver(context & c, ::solver *s):object(c),the_model(c) { m_solver = s; canceled = false;}
|
||||||
solver(solver const & s):object(s), the_model(s.the_model) { m_solver = s.m_solver; canceled = false;}
|
solver(solver const & s):object(s), the_model(s.the_model) { m_solver = s.m_solver; canceled = false;}
|
||||||
~solver() {
|
~solver() {
|
||||||
if(m_solver)
|
if(m_solver)
|
||||||
dealloc(m_solver);
|
dealloc(m_solver);
|
||||||
}
|
|
||||||
operator ::solver*() const { return m_solver; }
|
|
||||||
solver & operator=(solver const & s) {
|
|
||||||
m_ctx = s.m_ctx;
|
|
||||||
m_solver = s.m_solver;
|
|
||||||
the_model = s.the_model;
|
|
||||||
m_mode = s.m_mode;
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
struct cancel_exception {};
|
operator ::solver*() const { return m_solver; }
|
||||||
void checkpoint(){
|
solver & operator=(solver const & s) {
|
||||||
|
m_ctx = s.m_ctx;
|
||||||
|
m_solver = s.m_solver;
|
||||||
|
the_model = s.the_model;
|
||||||
|
m_mode = s.m_mode;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
struct cancel_exception {};
|
||||||
|
void checkpoint(){
|
||||||
if(canceled)
|
if(canceled)
|
||||||
throw(cancel_exception());
|
throw(cancel_exception());
|
||||||
}
|
}
|
||||||
// void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }
|
// void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }
|
||||||
void push() { scoped_proof_mode spm(m(),m_mode); m_solver->push(); }
|
void push() { scoped_proof_mode spm(m(),m_mode); m_solver->push(); }
|
||||||
void pop(unsigned n = 1) { scoped_proof_mode spm(m(),m_mode); m_solver->pop(n); }
|
void pop(unsigned n = 1) { scoped_proof_mode spm(m(),m_mode); m_solver->pop(n); }
|
||||||
// void reset() { Z3_solver_reset(ctx(), m_solver); check_error(); }
|
// void reset() { Z3_solver_reset(ctx(), m_solver); check_error(); }
|
||||||
void add(expr const & e) { scoped_proof_mode spm(m(),m_mode); m_solver->assert_expr(e); }
|
void add(expr const & e) { scoped_proof_mode spm(m(),m_mode); m_solver->assert_expr(e); }
|
||||||
check_result check() {
|
check_result check() {
|
||||||
scoped_proof_mode spm(m(),m_mode);
|
scoped_proof_mode spm(m(),m_mode);
|
||||||
checkpoint();
|
checkpoint();
|
||||||
lbool r = m_solver->check_sat(0,0);
|
lbool r = m_solver->check_sat(0,0);
|
||||||
model_ref m;
|
model_ref m;
|
||||||
m_solver->get_model(m);
|
m_solver->get_model(m);
|
||||||
the_model = m.get();
|
the_model = m.get();
|
||||||
return to_check_result(r);
|
return to_check_result(r);
|
||||||
}
|
}
|
||||||
check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
|
check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
|
||||||
scoped_proof_mode spm(m(),m_mode);
|
scoped_proof_mode spm(m(),m_mode);
|
||||||
model old_model(the_model);
|
model old_model(the_model);
|
||||||
check_result res = check(n,assumptions,core_size,core);
|
check_result res = check(n,assumptions,core_size,core);
|
||||||
if(the_model == 0)
|
if(the_model == 0)
|
||||||
the_model = old_model;
|
the_model = old_model;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
check_result check(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
|
check_result check(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
|
||||||
scoped_proof_mode spm(m(),m_mode);
|
scoped_proof_mode spm(m(),m_mode);
|
||||||
checkpoint();
|
checkpoint();
|
||||||
std::vector< ::expr *> _assumptions(n);
|
std::vector< ::expr *> _assumptions(n);
|
||||||
for (unsigned i = 0; i < n; i++) {
|
for (unsigned i = 0; i < n; i++) {
|
||||||
|
@ -892,7 +892,7 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
the_model = 0;
|
the_model = 0;
|
||||||
lbool r = m_solver->check_sat(n, VEC2PTR(_assumptions));
|
lbool r = m_solver->check_sat(n, VEC2PTR(_assumptions));
|
||||||
|
|
||||||
if(core_size && core){
|
if(core_size && core){
|
||||||
ptr_vector< ::expr> _core;
|
ptr_vector< ::expr> _core;
|
||||||
m_solver->get_unsat_core(_core);
|
m_solver->get_unsat_core(_core);
|
||||||
|
@ -905,20 +905,20 @@ namespace Duality {
|
||||||
m_solver->get_model(m);
|
m_solver->get_model(m);
|
||||||
the_model = m.get();
|
the_model = m.get();
|
||||||
|
|
||||||
return to_check_result(r);
|
return to_check_result(r);
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
check_result check(expr_vector assumptions) {
|
check_result check(expr_vector assumptions) {
|
||||||
scoped_proof_mode spm(m(),m_mode);
|
scoped_proof_mode spm(m(),m_mode);
|
||||||
unsigned n = assumptions.size();
|
unsigned n = assumptions.size();
|
||||||
z3array<Z3_ast> _assumptions(n);
|
z3array<Z3_ast> _assumptions(n);
|
||||||
for (unsigned i = 0; i < n; i++) {
|
for (unsigned i = 0; i < n; i++) {
|
||||||
check_context(*this, assumptions[i]);
|
check_context(*this, assumptions[i]);
|
||||||
_assumptions[i] = assumptions[i];
|
_assumptions[i] = assumptions[i];
|
||||||
}
|
}
|
||||||
Z3_lbool r = Z3_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
|
Z3_lbool r = Z3_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
|
||||||
check_error();
|
check_error();
|
||||||
return to_check_result(r);
|
return to_check_result(r);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
model get_model() const { return model(ctx(), the_model); }
|
model get_model() const { return model(ctx(), the_model); }
|
||||||
|
@ -930,27 +930,26 @@ namespace Duality {
|
||||||
#endif
|
#endif
|
||||||
// expr proof() const { Z3_ast r = Z3_solver_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
|
// expr proof() const { Z3_ast r = Z3_solver_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; }
|
// friend std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
|
||||||
|
int get_num_decisions();
|
||||||
int get_num_decisions();
|
|
||||||
|
|
||||||
void cancel(){
|
void cancel(){
|
||||||
scoped_proof_mode spm(m(),m_mode);
|
scoped_proof_mode spm(m(),m_mode);
|
||||||
canceled = true;
|
canceled = true;
|
||||||
m().limit().cancel();
|
m().limit().cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned get_scope_level(){ scoped_proof_mode spm(m(),m_mode); return m_solver->get_scope_level();}
|
unsigned get_scope_level(){ scoped_proof_mode spm(m(),m_mode); return m_solver->get_scope_level();}
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
void print(const char *filename);
|
void print(const char *filename);
|
||||||
void show_assertion_ids();
|
void show_assertion_ids();
|
||||||
|
|
||||||
proof get_proof(){
|
proof get_proof(){
|
||||||
scoped_proof_mode spm(m(),m_mode);
|
scoped_proof_mode spm(m(),m_mode);
|
||||||
return proof(ctx(),m_solver->get_proof());
|
return proof(ctx(),m_solver->get_proof());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool extensional_array_theory() {return extensional;}
|
bool extensional_array_theory() {return extensional;}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -969,20 +968,20 @@ namespace Duality {
|
||||||
goal & operator=(goal const & s) {
|
goal & operator=(goal const & s) {
|
||||||
Z3_goal_inc_ref(s.ctx(), s.m_goal);
|
Z3_goal_inc_ref(s.ctx(), s.m_goal);
|
||||||
Z3_goal_dec_ref(ctx(), m_goal);
|
Z3_goal_dec_ref(ctx(), m_goal);
|
||||||
m_ctx = s.m_ctx;
|
m_ctx = s.m_ctx;
|
||||||
m_goal = s.m_goal;
|
m_goal = s.m_goal;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
void add(expr const & f) { check_context(*this, f); Z3_goal_assert(ctx(), m_goal, f); check_error(); }
|
void add(expr const & f) { check_context(*this, f); Z3_goal_assert(ctx(), m_goal, f); check_error(); }
|
||||||
unsigned size() const { return Z3_goal_size(ctx(), m_goal); }
|
unsigned size() const { return Z3_goal_size(ctx(), m_goal); }
|
||||||
expr operator[](unsigned i) const { Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); }
|
expr operator[](unsigned i) const { Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); }
|
||||||
Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); }
|
Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); }
|
||||||
bool inconsistent() const { return Z3_goal_inconsistent(ctx(), m_goal) != 0; }
|
bool inconsistent() const { return Z3_goal_inconsistent(ctx(), m_goal) != 0; }
|
||||||
unsigned depth() const { return Z3_goal_depth(ctx(), m_goal); }
|
unsigned depth() const { return Z3_goal_depth(ctx(), m_goal); }
|
||||||
void reset() { Z3_goal_reset(ctx(), m_goal); }
|
void reset() { Z3_goal_reset(ctx(), m_goal); }
|
||||||
unsigned num_exprs() const { Z3_goal_num_exprs(ctx(), m_goal); }
|
unsigned num_exprs() const { Z3_goal_num_exprs(ctx(), m_goal); }
|
||||||
bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal) != 0; }
|
bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal) != 0; }
|
||||||
bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal) != 0; }
|
bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal) != 0; }
|
||||||
friend std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }
|
friend std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1000,15 +999,15 @@ namespace Duality {
|
||||||
apply_result & operator=(apply_result const & s) {
|
apply_result & operator=(apply_result const & s) {
|
||||||
Z3_apply_result_inc_ref(s.ctx(), s.m_apply_result);
|
Z3_apply_result_inc_ref(s.ctx(), s.m_apply_result);
|
||||||
Z3_apply_result_dec_ref(ctx(), m_apply_result);
|
Z3_apply_result_dec_ref(ctx(), m_apply_result);
|
||||||
m_ctx = s.m_ctx;
|
m_ctx = s.m_ctx;
|
||||||
m_apply_result = s.m_apply_result;
|
m_apply_result = s.m_apply_result;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
unsigned size() const { return Z3_apply_result_get_num_subgoals(ctx(), m_apply_result); }
|
unsigned size() const { return Z3_apply_result_get_num_subgoals(ctx(), m_apply_result); }
|
||||||
goal operator[](unsigned i) const { Z3_goal r = Z3_apply_result_get_subgoal(ctx(), m_apply_result, i); check_error(); return goal(ctx(), r); }
|
goal operator[](unsigned i) const { Z3_goal r = Z3_apply_result_get_subgoal(ctx(), m_apply_result, i); check_error(); return goal(ctx(), r); }
|
||||||
goal operator[](int i) const { assert(i >= 0); return this->operator[](static_cast<unsigned>(i)); }
|
goal operator[](int i) const { assert(i >= 0); return this->operator[](static_cast<unsigned>(i)); }
|
||||||
model convert_model(model const & m, unsigned i = 0) const {
|
model convert_model(model const & m, unsigned i = 0) const {
|
||||||
check_context(*this, m);
|
check_context(*this, m);
|
||||||
Z3_model new_m = Z3_apply_result_convert_model(ctx(), m_apply_result, i, m);
|
Z3_model new_m = Z3_apply_result_convert_model(ctx(), m_apply_result, i, m);
|
||||||
check_error();
|
check_error();
|
||||||
return model(ctx(), new_m);
|
return model(ctx(), new_m);
|
||||||
|
@ -1031,16 +1030,16 @@ namespace Duality {
|
||||||
tactic & operator=(tactic const & s) {
|
tactic & operator=(tactic const & s) {
|
||||||
Z3_tactic_inc_ref(s.ctx(), s.m_tactic);
|
Z3_tactic_inc_ref(s.ctx(), s.m_tactic);
|
||||||
Z3_tactic_dec_ref(ctx(), m_tactic);
|
Z3_tactic_dec_ref(ctx(), m_tactic);
|
||||||
m_ctx = s.m_ctx;
|
m_ctx = s.m_ctx;
|
||||||
m_tactic = s.m_tactic;
|
m_tactic = s.m_tactic;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
solver mk_solver() const { Z3_solver r = Z3_mk_solver_from_tactic(ctx(), m_tactic); check_error(); return solver(ctx(), r); }
|
solver mk_solver() const { Z3_solver r = Z3_mk_solver_from_tactic(ctx(), m_tactic); check_error(); return solver(ctx(), r); }
|
||||||
apply_result apply(goal const & g) const {
|
apply_result apply(goal const & g) const {
|
||||||
check_context(*this, g);
|
check_context(*this, g);
|
||||||
Z3_apply_result r = Z3_tactic_apply(ctx(), m_tactic, g);
|
Z3_apply_result r = Z3_tactic_apply(ctx(), m_tactic, g);
|
||||||
check_error();
|
check_error();
|
||||||
return apply_result(ctx(), r);
|
return apply_result(ctx(), r);
|
||||||
}
|
}
|
||||||
apply_result operator()(goal const & g) const {
|
apply_result operator()(goal const & g) const {
|
||||||
return apply(g);
|
return apply(g);
|
||||||
|
@ -1091,45 +1090,45 @@ namespace Duality {
|
||||||
probe & operator=(probe const & s) {
|
probe & operator=(probe const & s) {
|
||||||
Z3_probe_inc_ref(s.ctx(), s.m_probe);
|
Z3_probe_inc_ref(s.ctx(), s.m_probe);
|
||||||
Z3_probe_dec_ref(ctx(), m_probe);
|
Z3_probe_dec_ref(ctx(), m_probe);
|
||||||
m_ctx = s.m_ctx;
|
m_ctx = s.m_ctx;
|
||||||
m_probe = s.m_probe;
|
m_probe = s.m_probe;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
double apply(goal const & g) const { double r = Z3_probe_apply(ctx(), m_probe, g); check_error(); return r; }
|
double apply(goal const & g) const { double r = Z3_probe_apply(ctx(), m_probe, g); check_error(); return r; }
|
||||||
double operator()(goal const & g) const { return apply(g); }
|
double operator()(goal const & g) const { return apply(g); }
|
||||||
friend probe operator<=(probe const & p1, probe const & p2) {
|
friend probe operator<=(probe const & p1, probe const & p2) {
|
||||||
check_context(p1, p2); Z3_probe r = Z3_probe_le(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
check_context(p1, p2); Z3_probe r = Z3_probe_le(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
||||||
}
|
}
|
||||||
friend probe operator<=(probe const & p1, double p2) { return p1 <= probe(p1.ctx(), p2); }
|
friend probe operator<=(probe const & p1, double p2) { return p1 <= probe(p1.ctx(), p2); }
|
||||||
friend probe operator<=(double p1, probe const & p2) { return probe(p2.ctx(), p1) <= p2; }
|
friend probe operator<=(double p1, probe const & p2) { return probe(p2.ctx(), p1) <= p2; }
|
||||||
friend probe operator>=(probe const & p1, probe const & p2) {
|
friend probe operator>=(probe const & p1, probe const & p2) {
|
||||||
check_context(p1, p2); Z3_probe r = Z3_probe_ge(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
check_context(p1, p2); Z3_probe r = Z3_probe_ge(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
||||||
}
|
}
|
||||||
friend probe operator>=(probe const & p1, double p2) { return p1 >= probe(p1.ctx(), p2); }
|
friend probe operator>=(probe const & p1, double p2) { return p1 >= probe(p1.ctx(), p2); }
|
||||||
friend probe operator>=(double p1, probe const & p2) { return probe(p2.ctx(), p1) >= p2; }
|
friend probe operator>=(double p1, probe const & p2) { return probe(p2.ctx(), p1) >= p2; }
|
||||||
friend probe operator<(probe const & p1, probe const & p2) {
|
friend probe operator<(probe const & p1, probe const & p2) {
|
||||||
check_context(p1, p2); Z3_probe r = Z3_probe_lt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
check_context(p1, p2); Z3_probe r = Z3_probe_lt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
||||||
}
|
}
|
||||||
friend probe operator<(probe const & p1, double p2) { return p1 < probe(p1.ctx(), p2); }
|
friend probe operator<(probe const & p1, double p2) { return p1 < probe(p1.ctx(), p2); }
|
||||||
friend probe operator<(double p1, probe const & p2) { return probe(p2.ctx(), p1) < p2; }
|
friend probe operator<(double p1, probe const & p2) { return probe(p2.ctx(), p1) < p2; }
|
||||||
friend probe operator>(probe const & p1, probe const & p2) {
|
friend probe operator>(probe const & p1, probe const & p2) {
|
||||||
check_context(p1, p2); Z3_probe r = Z3_probe_gt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
check_context(p1, p2); Z3_probe r = Z3_probe_gt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
||||||
}
|
}
|
||||||
friend probe operator>(probe const & p1, double p2) { return p1 > probe(p1.ctx(), p2); }
|
friend probe operator>(probe const & p1, double p2) { return p1 > probe(p1.ctx(), p2); }
|
||||||
friend probe operator>(double p1, probe const & p2) { return probe(p2.ctx(), p1) > p2; }
|
friend probe operator>(double p1, probe const & p2) { return probe(p2.ctx(), p1) > p2; }
|
||||||
friend probe operator==(probe const & p1, probe const & p2) {
|
friend probe operator==(probe const & p1, probe const & p2) {
|
||||||
check_context(p1, p2); Z3_probe r = Z3_probe_eq(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
check_context(p1, p2); Z3_probe r = Z3_probe_eq(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
||||||
}
|
}
|
||||||
friend probe operator==(probe const & p1, double p2) { return p1 == probe(p1.ctx(), p2); }
|
friend probe operator==(probe const & p1, double p2) { return p1 == probe(p1.ctx(), p2); }
|
||||||
friend probe operator==(double p1, probe const & p2) { return probe(p2.ctx(), p1) == p2; }
|
friend probe operator==(double p1, probe const & p2) { return probe(p2.ctx(), p1) == p2; }
|
||||||
friend probe operator&&(probe const & p1, probe const & p2) {
|
friend probe operator&&(probe const & p1, probe const & p2) {
|
||||||
check_context(p1, p2); Z3_probe r = Z3_probe_and(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
check_context(p1, p2); Z3_probe r = Z3_probe_and(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
||||||
}
|
}
|
||||||
friend probe operator||(probe const & p1, probe const & p2) {
|
friend probe operator||(probe const & p1, probe const & p2) {
|
||||||
check_context(p1, p2); Z3_probe r = Z3_probe_or(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
check_context(p1, p2); Z3_probe r = Z3_probe_or(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
|
||||||
}
|
}
|
||||||
friend probe operator!(probe const & p) {
|
friend probe operator!(probe const & p) {
|
||||||
Z3_probe r = Z3_probe_not(p.ctx(), p); p.check_error(); return probe(p.ctx(), r);
|
Z3_probe r = Z3_probe_not(p.ctx(), p); p.check_error(); return probe(p.ctx(), r);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1159,15 +1158,15 @@ namespace Duality {
|
||||||
inline symbol context::int_symbol(int n) { ::symbol r = ::symbol(n); return symbol(*this, r); }
|
inline symbol context::int_symbol(int n) { ::symbol r = ::symbol(n); return symbol(*this, r); }
|
||||||
|
|
||||||
inline sort context::bool_sort() {
|
inline sort context::bool_sort() {
|
||||||
::sort *s = m().mk_sort(m_basic_fid, BOOL_SORT);
|
::sort *s = m().mk_sort(m_basic_fid, BOOL_SORT);
|
||||||
return sort(*this, s);
|
return sort(*this, s);
|
||||||
}
|
}
|
||||||
inline sort context::int_sort() {
|
inline sort context::int_sort() {
|
||||||
::sort *s = m().mk_sort(m_arith_fid, INT_SORT);
|
::sort *s = m().mk_sort(m_arith_fid, INT_SORT);
|
||||||
return sort(*this, s);
|
return sort(*this, s);
|
||||||
}
|
}
|
||||||
inline sort context::real_sort() {
|
inline sort context::real_sort() {
|
||||||
::sort *s = m().mk_sort(m_arith_fid, REAL_SORT);
|
::sort *s = m().mk_sort(m_arith_fid, REAL_SORT);
|
||||||
return sort(*this, s);
|
return sort(*this, s);
|
||||||
}
|
}
|
||||||
inline sort context::array_sort(sort d, sort r) {
|
inline sort context::array_sort(sort d, sort r) {
|
||||||
|
@ -1188,7 +1187,7 @@ namespace Duality {
|
||||||
inline func_decl context::function(char const * name, unsigned arity, sort const * domain, sort const & range) {
|
inline func_decl context::function(char const * name, unsigned arity, sort const * domain, sort const & range) {
|
||||||
return function(str_symbol(name), arity, domain, range);
|
return function(str_symbol(name), arity, domain, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline func_decl context::function(char const * name, sort const & domain, sort const & range) {
|
inline func_decl context::function(char const * name, sort const & domain, sort const & range) {
|
||||||
sort args[1] = { domain };
|
sort args[1] = { domain };
|
||||||
return function(name, 1, args, range);
|
return function(name, 1, args, range);
|
||||||
|
@ -1196,7 +1195,7 @@ namespace Duality {
|
||||||
|
|
||||||
inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & range) {
|
inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & range) {
|
||||||
sort args[2] = { d1, d2 };
|
sort args[2] = { d1, d2 };
|
||||||
return function(name, 2, args, range);
|
return function(name, 2, args, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {
|
inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {
|
||||||
|
@ -1208,7 +1207,7 @@ namespace Duality {
|
||||||
sort args[4] = { d1, d2, d3, d4 };
|
sort args[4] = { d1, d2, d3, d4 };
|
||||||
return function(name, 4, args, range);
|
return function(name, 4, args, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & d5, sort const & range) {
|
inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & d5, sort const & range) {
|
||||||
sort args[5] = { d1, d2, d3, d4, d5 };
|
sort args[5] = { d1, d2, d3, d4, d5 };
|
||||||
return function(name, 5, args, range);
|
return function(name, 5, args, range);
|
||||||
|
@ -1217,7 +1216,7 @@ namespace Duality {
|
||||||
|
|
||||||
inline expr context::constant(symbol const & name, sort const & s) {
|
inline expr context::constant(symbol const & name, sort const & s) {
|
||||||
::expr *r = m().mk_const(m().mk_const_decl(name, s));
|
::expr *r = m().mk_const(m().mk_const_decl(name, s));
|
||||||
return expr(*this, r);
|
return expr(*this, r);
|
||||||
}
|
}
|
||||||
inline expr context::constant(char const * name, sort const & s) { return constant(str_symbol(name), s); }
|
inline expr context::constant(char const * name, sort const & s) { return constant(str_symbol(name), s); }
|
||||||
inline expr context::bool_const(char const * name) { return constant(name, bool_sort()); }
|
inline expr context::bool_const(char const * name) { return constant(name, bool_sort()); }
|
||||||
|
@ -1250,11 +1249,11 @@ namespace Duality {
|
||||||
expr args[5] = {a1,a2,a3,a4,a5};
|
expr args[5] = {a1,a2,a3,a4,a5};
|
||||||
return operator()(5,args);
|
return operator()(5,args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline expr select(expr const & a, expr const & i) { return a.ctx().make(Select,a,i); }
|
inline expr select(expr const & a, expr const & i) { return a.ctx().make(Select,a,i); }
|
||||||
inline expr store(expr const & a, expr const & i, expr const & v) { return a.ctx().make(Store,a,i,v); }
|
inline expr store(expr const & a, expr const & i, expr const & v) { return a.ctx().make(Store,a,i,v); }
|
||||||
|
|
||||||
inline expr forall(const std::vector<expr> &quants, const expr &body){
|
inline expr forall(const std::vector<expr> &quants, const expr &body){
|
||||||
return body.ctx().make_quant(Forall,quants,body);
|
return body.ctx().make_quant(Forall,quants,body);
|
||||||
}
|
}
|
||||||
|
@ -1304,7 +1303,7 @@ namespace Duality {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setTerm(expr t){term = t;}
|
inline void setTerm(expr t){term = t;}
|
||||||
|
|
||||||
inline void addTerm(expr t){terms.push_back(t);}
|
inline void addTerm(expr t){terms.push_back(t);}
|
||||||
|
|
||||||
inline void setChildren(const std::vector<TermTree *> & _children){
|
inline void setChildren(const std::vector<TermTree *> & _children){
|
||||||
|
@ -1326,7 +1325,7 @@ namespace Duality {
|
||||||
std::vector<TermTree *> children;
|
std::vector<TermTree *> children;
|
||||||
int num;
|
int num;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef context interpolating_context;
|
typedef context interpolating_context;
|
||||||
|
|
||||||
class interpolating_solver : public solver {
|
class interpolating_solver : public solver {
|
||||||
|
@ -1336,7 +1335,7 @@ namespace Duality {
|
||||||
{
|
{
|
||||||
weak_mode = false;
|
weak_mode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
lbool interpolate(const std::vector<expr> &assumptions,
|
lbool interpolate(const std::vector<expr> &assumptions,
|
||||||
std::vector<expr> &interpolants,
|
std::vector<expr> &interpolants,
|
||||||
|
@ -1344,41 +1343,41 @@ namespace Duality {
|
||||||
literals &lits,
|
literals &lits,
|
||||||
bool incremental
|
bool incremental
|
||||||
);
|
);
|
||||||
|
|
||||||
lbool interpolate_tree(TermTree *assumptions,
|
lbool interpolate_tree(TermTree *assumptions,
|
||||||
TermTree *&interpolants,
|
TermTree *&interpolants,
|
||||||
model &_model,
|
model &_model,
|
||||||
literals &lits,
|
literals &lits,
|
||||||
bool incremental
|
bool incremental
|
||||||
);
|
);
|
||||||
|
|
||||||
bool read_interpolation_problem(const std::string &file_name,
|
bool read_interpolation_problem(const std::string &file_name,
|
||||||
std::vector<expr> &assumptions,
|
std::vector<expr> &assumptions,
|
||||||
std::vector<expr> &theory,
|
std::vector<expr> &theory,
|
||||||
std::string &error_message
|
std::string &error_message
|
||||||
);
|
);
|
||||||
|
|
||||||
void write_interpolation_problem(const std::string &file_name,
|
void write_interpolation_problem(const std::string &file_name,
|
||||||
const std::vector<expr> &assumptions,
|
const std::vector<expr> &assumptions,
|
||||||
const std::vector<expr> &theory
|
const std::vector<expr> &theory
|
||||||
);
|
);
|
||||||
|
|
||||||
void AssertInterpolationAxiom(const expr &expr);
|
void AssertInterpolationAxiom(const expr &expr);
|
||||||
void RemoveInterpolationAxiom(const expr &expr);
|
void RemoveInterpolationAxiom(const expr &expr);
|
||||||
|
|
||||||
void SetWeakInterpolants(bool weak);
|
void SetWeakInterpolants(bool weak);
|
||||||
void SetPrintToFile(const std::string &file_name);
|
void SetPrintToFile(const std::string &file_name);
|
||||||
|
|
||||||
const std::vector<expr> &GetInterpolationAxioms() {return theory;}
|
const std::vector<expr> &GetInterpolationAxioms() {return theory;}
|
||||||
const char *profile();
|
const char *profile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool weak_mode;
|
bool weak_mode;
|
||||||
std::string print_filename;
|
std::string print_filename;
|
||||||
std::vector<expr> theory;
|
std::vector<expr> theory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline expr context::cook(::expr *a) {return expr(*this,a);}
|
inline expr context::cook(::expr *a) {return expr(*this,a);}
|
||||||
|
|
||||||
inline std::vector<expr> context::cook(ptr_vector< ::expr> v) {
|
inline std::vector<expr> context::cook(ptr_vector< ::expr> v) {
|
||||||
|
|
|
@ -66,35 +66,35 @@ class iz3base : public iz3mgr, public scopes {
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
|
|
||||||
iz3base(ast_manager &_m_manager,
|
iz3base(ast_manager &_m_manager,
|
||||||
const std::vector<ast> &_cnsts,
|
const std::vector<ast> &_cnsts,
|
||||||
const std::vector<int> &_parents,
|
const std::vector<int> &_parents,
|
||||||
const std::vector<ast> &_theory)
|
const std::vector<ast> &_theory)
|
||||||
: iz3mgr(_m_manager), scopes(_parents) {
|
: iz3mgr(_m_manager), scopes(_parents) {
|
||||||
initialize(_cnsts,_parents,_theory);
|
initialize(_cnsts,_parents,_theory);
|
||||||
weak = false;
|
weak = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
iz3base(const iz3mgr& other,
|
iz3base(const iz3mgr& other,
|
||||||
const std::vector<ast> &_cnsts,
|
const std::vector<ast> &_cnsts,
|
||||||
const std::vector<int> &_parents,
|
const std::vector<int> &_parents,
|
||||||
const std::vector<ast> &_theory)
|
const std::vector<ast> &_theory)
|
||||||
: iz3mgr(other), scopes(_parents) {
|
: iz3mgr(other), scopes(_parents) {
|
||||||
initialize(_cnsts,_parents,_theory);
|
initialize(_cnsts,_parents,_theory);
|
||||||
weak = false;
|
weak = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
iz3base(const iz3mgr& other,
|
iz3base(const iz3mgr& other,
|
||||||
const std::vector<std::vector<ast> > &_cnsts,
|
const std::vector<std::vector<ast> > &_cnsts,
|
||||||
const std::vector<int> &_parents,
|
const std::vector<int> &_parents,
|
||||||
const std::vector<ast> &_theory)
|
const std::vector<ast> &_theory)
|
||||||
: iz3mgr(other), scopes(_parents) {
|
: iz3mgr(other), scopes(_parents) {
|
||||||
initialize(_cnsts,_parents,_theory);
|
initialize(_cnsts,_parents,_theory);
|
||||||
weak = false;
|
weak = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
iz3base(const iz3mgr& other)
|
iz3base(const iz3mgr& other)
|
||||||
: iz3mgr(other), scopes() {
|
: iz3mgr(other), scopes() {
|
||||||
weak = false;
|
weak = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,26 +24,26 @@
|
||||||
#include "solver/solver.h"
|
#include "solver/solver.h"
|
||||||
|
|
||||||
bool iz3check(ast_manager &_m_manager,
|
bool iz3check(ast_manager &_m_manager,
|
||||||
solver *s,
|
solver *s,
|
||||||
std::ostream &err,
|
std::ostream &err,
|
||||||
const ptr_vector<ast> &cnsts,
|
const ptr_vector<ast> &cnsts,
|
||||||
const ::vector<int> &parents,
|
const ::vector<int> &parents,
|
||||||
const ptr_vector<ast> &interps,
|
const ptr_vector<ast> &interps,
|
||||||
const ptr_vector<ast> &theory);
|
const ptr_vector<ast> &theory);
|
||||||
|
|
||||||
bool iz3check(ast_manager &_m_manager,
|
bool iz3check(ast_manager &_m_manager,
|
||||||
solver *s,
|
solver *s,
|
||||||
std::ostream &err,
|
std::ostream &err,
|
||||||
const ptr_vector<ast> &cnsts,
|
const ptr_vector<ast> &cnsts,
|
||||||
ast *tree,
|
ast *tree,
|
||||||
const ptr_vector<ast> &interps);
|
const ptr_vector<ast> &interps);
|
||||||
|
|
||||||
bool iz3check(iz3mgr &mgr,
|
bool iz3check(iz3mgr &mgr,
|
||||||
solver *s,
|
solver *s,
|
||||||
std::ostream &err,
|
std::ostream &err,
|
||||||
const std::vector<iz3mgr::ast> &cnsts,
|
const std::vector<iz3mgr::ast> &cnsts,
|
||||||
const std::vector<int> &parents,
|
const std::vector<int> &parents,
|
||||||
const std::vector<iz3mgr::ast> &interps,
|
const std::vector<iz3mgr::ast> &interps,
|
||||||
const ptr_vector<iz3mgr::ast> &theory);
|
const ptr_vector<iz3mgr::ast> &theory);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -468,10 +468,10 @@ namespace hash_space {
|
||||||
: hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>(7) {}
|
: hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>(7) {}
|
||||||
|
|
||||||
Value &operator[](const Key& key) {
|
Value &operator[](const Key& key) {
|
||||||
std::pair<Key,Value> kvp(key,Value());
|
std::pair<Key,Value> kvp(key,Value());
|
||||||
return
|
return
|
||||||
hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>::
|
hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>::
|
||||||
lookup(kvp,true)->val.second;
|
lookup(kvp,true)->val.second;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,22 +73,22 @@ typedef interpolation_options_struct *interpolation_options;
|
||||||
representation, for compatibility with the old API. */
|
representation, for compatibility with the old API. */
|
||||||
|
|
||||||
void iz3interpolate(ast_manager &_m_manager,
|
void iz3interpolate(ast_manager &_m_manager,
|
||||||
ast *proof,
|
ast *proof,
|
||||||
const ptr_vector<ast> &cnsts,
|
const ptr_vector<ast> &cnsts,
|
||||||
const ::vector<int> &parents,
|
const ::vector<int> &parents,
|
||||||
ptr_vector<ast> &interps,
|
ptr_vector<ast> &interps,
|
||||||
const ptr_vector<ast> &theory,
|
const ptr_vector<ast> &theory,
|
||||||
interpolation_options_struct * options = 0);
|
interpolation_options_struct * options = 0);
|
||||||
|
|
||||||
/* Same as above, but each constraint is a vector of formulas. */
|
/* Same as above, but each constraint is a vector of formulas. */
|
||||||
|
|
||||||
void iz3interpolate(ast_manager &_m_manager,
|
void iz3interpolate(ast_manager &_m_manager,
|
||||||
ast *proof,
|
ast *proof,
|
||||||
const vector<ptr_vector<ast> > &cnsts,
|
const vector<ptr_vector<ast> > &cnsts,
|
||||||
const ::vector<int> &parents,
|
const ::vector<int> &parents,
|
||||||
ptr_vector<ast> &interps,
|
ptr_vector<ast> &interps,
|
||||||
const ptr_vector<ast> &theory,
|
const ptr_vector<ast> &theory,
|
||||||
interpolation_options_struct * options = 0);
|
interpolation_options_struct * options = 0);
|
||||||
|
|
||||||
/* Compute an interpolant from a proof. This version uses the ast
|
/* Compute an interpolant from a proof. This version uses the ast
|
||||||
representation, for compatibility with the new API. Here, cnsts is
|
representation, for compatibility with the new API. Here, cnsts is
|
||||||
|
@ -98,11 +98,11 @@ void iz3interpolate(ast_manager &_m_manager,
|
||||||
proof, so it can be considered a hint. */
|
proof, so it can be considered a hint. */
|
||||||
|
|
||||||
void iz3interpolate(ast_manager &_m_manager,
|
void iz3interpolate(ast_manager &_m_manager,
|
||||||
ast *proof,
|
ast *proof,
|
||||||
const ptr_vector<ast> &cnsts,
|
const ptr_vector<ast> &cnsts,
|
||||||
ast *tree,
|
ast *tree,
|
||||||
ptr_vector<ast> &interps,
|
ptr_vector<ast> &interps,
|
||||||
interpolation_options_struct * options);
|
interpolation_options_struct * options);
|
||||||
|
|
||||||
|
|
||||||
/* Compute an interpolant from an ast representing an interpolation
|
/* Compute an interpolant from an ast representing an interpolation
|
||||||
|
@ -112,12 +112,12 @@ void iz3interpolate(ast_manager &_m_manager,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lbool iz3interpolate(ast_manager &_m_manager,
|
lbool iz3interpolate(ast_manager &_m_manager,
|
||||||
solver &s,
|
solver &s,
|
||||||
ast *tree,
|
ast *tree,
|
||||||
ptr_vector<ast> &cnsts,
|
ptr_vector<ast> &cnsts,
|
||||||
ptr_vector<ast> &interps,
|
ptr_vector<ast> &interps,
|
||||||
model_ref &m,
|
model_ref &m,
|
||||||
interpolation_options_struct * options);
|
interpolation_options_struct * options);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct iz3pp_bad_tree: public iz3_exception {
|
||||||
};
|
};
|
||||||
|
|
||||||
void iz3pp(ast_manager &m,
|
void iz3pp(ast_manager &m,
|
||||||
const ptr_vector<expr> &cnsts_vec,
|
const ptr_vector<expr> &cnsts_vec,
|
||||||
expr *tree,
|
expr *tree,
|
||||||
std::ostream& out);
|
std::ostream& out);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -105,7 +105,7 @@ class scopes {
|
||||||
|
|
||||||
void range_add(int i, range &n){
|
void range_add(int i, range &n){
|
||||||
#if 0
|
#if 0
|
||||||
if(i < n.lo) n.lo = i;
|
if(i < n.lo) n.lo = i;
|
||||||
if(i > n.hi) n.hi = i;
|
if(i > n.hi) n.hi = i;
|
||||||
#else
|
#else
|
||||||
range rng; rng.lo = i; rng.hi = i;
|
range rng; rng.lo = i; rng.hi = i;
|
||||||
|
@ -119,7 +119,7 @@ class scopes {
|
||||||
int thing = tree_lca(rng1.lo,rng2.hi);
|
int thing = tree_lca(rng1.lo,rng2.hi);
|
||||||
if(thing == rng1.lo) frame = rng1.lo;
|
if(thing == rng1.lo) frame = rng1.lo;
|
||||||
else frame = tree_gcd(thing,rng1.hi);
|
else frame = tree_gcd(thing,rng1.hi);
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@ class iz3translation : public iz3base {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
iz3translation(iz3mgr &mgr,
|
iz3translation(iz3mgr &mgr,
|
||||||
const std::vector<std::vector<ast> > &_cnsts,
|
const std::vector<std::vector<ast> > &_cnsts,
|
||||||
const std::vector<int> &_parents,
|
const std::vector<int> &_parents,
|
||||||
const std::vector<ast> &_theory)
|
const std::vector<ast> &_theory)
|
||||||
: iz3base(mgr,_cnsts,_parents,_theory) {}
|
: iz3base(mgr,_cnsts,_parents,_theory) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -478,7 +478,7 @@ public:
|
||||||
unsigned out_degree(unsigned state) const { return m_delta[state].size(); }
|
unsigned out_degree(unsigned state) const { return m_delta[state].size(); }
|
||||||
move const& get_move_from(unsigned state) const { SASSERT(m_delta[state].size() == 1); return m_delta[state][0]; }
|
move const& get_move_from(unsigned state) const { SASSERT(m_delta[state].size() == 1); return m_delta[state][0]; }
|
||||||
move const& get_move_to(unsigned state) const { SASSERT(m_delta_inv[state].size() == 1); return m_delta_inv[state][0]; }
|
move const& get_move_to(unsigned state) const { SASSERT(m_delta_inv[state].size() == 1); return m_delta_inv[state][0]; }
|
||||||
moves const& get_moves_from(unsigned state) const { return m_delta[state]; }
|
moves const& get_moves_from(unsigned state) const { return m_delta[state]; }
|
||||||
moves const& get_moves_to(unsigned state) const { return m_delta_inv[state]; }
|
moves const& get_moves_to(unsigned state) const { return m_delta_inv[state]; }
|
||||||
bool initial_state_is_source() const { return m_delta_inv[m_init].empty(); }
|
bool initial_state_is_source() const { return m_delta_inv[m_init].empty(); }
|
||||||
bool is_final_state(unsigned s) const { return m_final_set.contains(s); }
|
bool is_final_state(unsigned s) const { return m_final_set.contains(s); }
|
||||||
|
|
|
@ -40,9 +40,7 @@ template<class T>
|
||||||
class boolean_algebra : public positive_boolean_algebra<T> {
|
class boolean_algebra : public positive_boolean_algebra<T> {
|
||||||
public:
|
public:
|
||||||
virtual ~boolean_algebra() {}
|
virtual ~boolean_algebra() {}
|
||||||
virtual T mk_not(T x) = 0;
|
virtual T mk_not(T x) = 0;
|
||||||
//virtual lbool are_equivalent(T x, T y) = 0;
|
|
||||||
//virtual T simplify(T x) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,8 +63,8 @@ namespace polynomial {
|
||||||
public:
|
public:
|
||||||
void set_degree(var x, unsigned d) { m_var2degree.setx(x, d, 0); }
|
void set_degree(var x, unsigned d) { m_var2degree.setx(x, d, 0); }
|
||||||
unsigned degree(var x) const { return m_var2degree.get(x, 0); }
|
unsigned degree(var x) const { return m_var2degree.get(x, 0); }
|
||||||
void display(std::ostream & out) const;
|
void display(std::ostream & out) const;
|
||||||
friend std::ostream & operator<<(std::ostream & out, var2degree const & ideal) { ideal.display(out); return out; }
|
friend std::ostream & operator<<(std::ostream & out, var2degree const & ideal) { ideal.display(out); return out; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ValManager, typename Value = typename ValManager::numeral>
|
template<typename ValManager, typename Value = typename ValManager::numeral>
|
||||||
|
|
|
@ -434,11 +434,11 @@ namespace upolynomial {
|
||||||
m().reset(r[i]);
|
m().reset(r[i]);
|
||||||
}
|
}
|
||||||
for (unsigned i = 0; i < sz; i++) {
|
for (unsigned i = 0; i < sz; i++) {
|
||||||
typename polynomial::monomial * mon = pm.get_monomial(p, i);
|
typename polynomial::monomial * mon = pm.get_monomial(p, i);
|
||||||
if (pm.size(mon) == 0) {
|
if (pm.size(mon) == 0) {
|
||||||
m().set(r[0], pm.coeff(p, i));
|
m().set(r[0], pm.coeff(p, i));
|
||||||
} else if (pm.size(mon) == 1 && pm.get_var(mon, 0) == x) {
|
} else if (pm.size(mon) == 1 && pm.get_var(mon, 0) == x) {
|
||||||
unsigned m_deg_x = pm.degree(mon, 0);
|
unsigned m_deg_x = pm.degree(mon, 0);
|
||||||
m().set(r[m_deg_x], pm.coeff(p, i));
|
m().set(r[m_deg_x], pm.coeff(p, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,13 +86,13 @@ void model_core::register_decl(func_decl * d, func_interp * fi) {
|
||||||
void model_core::unregister_decl(func_decl * d) {
|
void model_core::unregister_decl(func_decl * d) {
|
||||||
decl2expr::obj_map_entry * ec = m_interp.find_core(d);
|
decl2expr::obj_map_entry * ec = m_interp.find_core(d);
|
||||||
if (ec && ec->get_data().m_value != 0) {
|
if (ec && ec->get_data().m_value != 0) {
|
||||||
m_manager.dec_ref(ec->get_data().m_key);
|
m_manager.dec_ref(ec->get_data().m_key);
|
||||||
m_manager.dec_ref(ec->get_data().m_value);
|
m_manager.dec_ref(ec->get_data().m_value);
|
||||||
m_interp.remove(d);
|
m_interp.remove(d);
|
||||||
m_const_decls.erase(d);
|
m_const_decls.erase(d);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
decl2finterp::obj_map_entry * ef = m_finterp.find_core(d);
|
decl2finterp::obj_map_entry * ef = m_finterp.find_core(d);
|
||||||
if (ef && ef->get_data().m_value != 0) {
|
if (ef && ef->get_data().m_value != 0) {
|
||||||
m_manager.dec_ref(ef->get_data().m_key);
|
m_manager.dec_ref(ef->get_data().m_key);
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace datalog {
|
||||||
MEMOUT,
|
MEMOUT,
|
||||||
INPUT_ERROR,
|
INPUT_ERROR,
|
||||||
APPROX,
|
APPROX,
|
||||||
BOUNDED,
|
BOUNDED,
|
||||||
CANCELED
|
CANCELED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ namespace datalog {
|
||||||
\brief Retrieve predicates
|
\brief Retrieve predicates
|
||||||
*/
|
*/
|
||||||
func_decl_set const& get_predicates() const { return m_preds; }
|
func_decl_set const& get_predicates() const { return m_preds; }
|
||||||
ast_ref_vector const &get_pinned() const {return m_pinned; }
|
ast_ref_vector const &get_pinned() const {return m_pinned; }
|
||||||
|
|
||||||
bool is_predicate(func_decl* pred) const { return m_preds.contains(pred); }
|
bool is_predicate(func_decl* pred) const { return m_preds.contains(pred); }
|
||||||
bool is_predicate(expr * e) const { return is_app(e) && is_predicate(to_app(e)->get_decl()); }
|
bool is_predicate(expr * e) const { return is_app(e) && is_predicate(to_app(e)->get_decl()); }
|
||||||
|
@ -534,7 +534,7 @@ namespace datalog {
|
||||||
\brief retrieve proof from derivation of the query.
|
\brief retrieve proof from derivation of the query.
|
||||||
|
|
||||||
\pre engine == 'pdr' || engine == 'duality'- this option is only supported
|
\pre engine == 'pdr' || engine == 'duality'- this option is only supported
|
||||||
for PDR mode and Duality mode.
|
for PDR mode and Duality mode.
|
||||||
*/
|
*/
|
||||||
proof_ref get_proof();
|
proof_ref get_proof();
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace datalog {
|
||||||
QBMC_ENGINE,
|
QBMC_ENGINE,
|
||||||
TAB_ENGINE,
|
TAB_ENGINE,
|
||||||
CLP_ENGINE,
|
CLP_ENGINE,
|
||||||
DUALITY_ENGINE,
|
DUALITY_ENGINE,
|
||||||
DDNF_ENGINE,
|
DDNF_ENGINE,
|
||||||
LAST_ENGINE
|
LAST_ENGINE
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ def_module_params('fixedpoint',
|
||||||
params=(('timeout', UINT, UINT_MAX, 'set timeout'),
|
params=(('timeout', UINT, UINT_MAX, 'set timeout'),
|
||||||
('engine', SYMBOL, 'auto-config',
|
('engine', SYMBOL, 'auto-config',
|
||||||
'Select: auto-config, datalog, duality, pdr, bmc, spacer'),
|
'Select: auto-config, datalog, duality, pdr, bmc, spacer'),
|
||||||
('datalog.default_table', SYMBOL, 'sparse',
|
('datalog.default_table', SYMBOL, 'sparse',
|
||||||
'default table implementation: sparse, hashtable, bitvector, interval'),
|
'default table implementation: sparse, hashtable, bitvector, interval'),
|
||||||
('datalog.default_relation', SYMBOL, 'pentagon',
|
('datalog.default_relation', SYMBOL, 'pentagon',
|
||||||
'default relation implementation: external_relation, pentagon'),
|
'default relation implementation: external_relation, pentagon'),
|
||||||
|
@ -56,18 +56,18 @@ def_module_params('fixedpoint',
|
||||||
"table columns, if it would have been empty otherwise"),
|
"table columns, if it would have been empty otherwise"),
|
||||||
('datalog.subsumption', BOOL, True,
|
('datalog.subsumption', BOOL, True,
|
||||||
"if true, removes/filters predicates with total transitions"),
|
"if true, removes/filters predicates with total transitions"),
|
||||||
('duality.full_expand', BOOL, False, 'Fully expand derivation trees'),
|
('duality.full_expand', BOOL, False, 'Fully expand derivation trees'),
|
||||||
('duality.no_conj', BOOL, False, 'No forced covering (conjectures)'),
|
('duality.no_conj', BOOL, False, 'No forced covering (conjectures)'),
|
||||||
('duality.feasible_edges', BOOL, True,
|
('duality.feasible_edges', BOOL, True,
|
||||||
'Don\'t expand definitley infeasible edges'),
|
'Don\'t expand definitley infeasible edges'),
|
||||||
('duality.use_underapprox', BOOL, False, 'Use underapproximations'),
|
('duality.use_underapprox', BOOL, False, 'Use underapproximations'),
|
||||||
('duality.stratified_inlining', BOOL, False, 'Use stratified inlining'),
|
('duality.stratified_inlining', BOOL, False, 'Use stratified inlining'),
|
||||||
('duality.recursion_bound', UINT, UINT_MAX,
|
('duality.recursion_bound', UINT, UINT_MAX,
|
||||||
'Recursion bound for stratified inlining'),
|
'Recursion bound for stratified inlining'),
|
||||||
('duality.profile', BOOL, False, 'profile run time'),
|
('duality.profile', BOOL, False, 'profile run time'),
|
||||||
('duality.mbqi', BOOL, True, 'use model-based quantifier instantiation'),
|
('duality.mbqi', BOOL, True, 'use model-based quantifier instantiation'),
|
||||||
('duality.batch_expand', BOOL, False, 'use batch expansion'),
|
('duality.batch_expand', BOOL, False, 'use batch expansion'),
|
||||||
('duality.conjecture_file', STRING, '', 'save conjectures to file'),
|
('duality.conjecture_file', STRING, '', 'save conjectures to file'),
|
||||||
('pdr.bfs_model_search', BOOL, True,
|
('pdr.bfs_model_search', BOOL, True,
|
||||||
"use BFS strategy for expanding model search"),
|
"use BFS strategy for expanding model search"),
|
||||||
('pdr.farkas', BOOL, True,
|
('pdr.farkas', BOOL, True,
|
||||||
|
@ -92,9 +92,9 @@ def_module_params('fixedpoint',
|
||||||
"generalize lemmas using induction strengthening"),
|
"generalize lemmas using induction strengthening"),
|
||||||
('pdr.use_arith_inductive_generalizer', BOOL, False,
|
('pdr.use_arith_inductive_generalizer', BOOL, False,
|
||||||
"generalize lemmas using arithmetic heuristics for induction strengthening"),
|
"generalize lemmas using arithmetic heuristics for induction strengthening"),
|
||||||
('pdr.use_convex_closure_generalizer', BOOL, False,
|
('pdr.use_convex_closure_generalizer', BOOL, False,
|
||||||
"generalize using convex closures of lemmas"),
|
"generalize using convex closures of lemmas"),
|
||||||
('pdr.use_convex_interior_generalizer', BOOL, False,
|
('pdr.use_convex_interior_generalizer', BOOL, False,
|
||||||
"generalize using convex interiors of lemmas"),
|
"generalize using convex interiors of lemmas"),
|
||||||
('pdr.cache_mode', UINT, 0, "use no (0), symbolic (1) or explicit " +
|
('pdr.cache_mode', UINT, 0, "use no (0), symbolic (1) or explicit " +
|
||||||
"cache (2) for model search"),
|
"cache (2) for model search"),
|
||||||
|
@ -104,7 +104,7 @@ def_module_params('fixedpoint',
|
||||||
('pdr.max_num_contexts', UINT, 500, "maximal number of contexts to create"),
|
('pdr.max_num_contexts', UINT, 500, "maximal number of contexts to create"),
|
||||||
('pdr.try_minimize_core', BOOL, False,
|
('pdr.try_minimize_core', BOOL, False,
|
||||||
"try to reduce core size (before inductive minimization)"),
|
"try to reduce core size (before inductive minimization)"),
|
||||||
('pdr.utvpi', BOOL, True, 'Enable UTVPI strategy'),
|
('pdr.utvpi', BOOL, True, 'Enable UTVPI strategy'),
|
||||||
('print_fixedpoint_extensions', BOOL, True,
|
('print_fixedpoint_extensions', BOOL, True,
|
||||||
"use SMT-LIB2 fixedpoint extensions, instead of pure SMT2, " +
|
"use SMT-LIB2 fixedpoint extensions, instead of pure SMT2, " +
|
||||||
"when printing rules"),
|
"when printing rules"),
|
||||||
|
@ -123,7 +123,7 @@ def_module_params('fixedpoint',
|
||||||
('print_statistics', BOOL, False, 'print statistics'),
|
('print_statistics', BOOL, False, 'print statistics'),
|
||||||
('print_aig', SYMBOL, '',
|
('print_aig', SYMBOL, '',
|
||||||
'Dump clauses in AIG text format (AAG) to the given file name'),
|
'Dump clauses in AIG text format (AAG) to the given file name'),
|
||||||
('tab.selection', SYMBOL, 'weight',
|
('tab.selection', SYMBOL, 'weight',
|
||||||
'selection method for tabular strategy: weight (default), first, var-use'),
|
'selection method for tabular strategy: weight (default), first, var-use'),
|
||||||
('xform.bit_blast', BOOL, False,
|
('xform.bit_blast', BOOL, False,
|
||||||
'bit-blast bit-vectors'),
|
'bit-blast bit-vectors'),
|
||||||
|
@ -140,7 +140,7 @@ def_module_params('fixedpoint',
|
||||||
('xform.unfold_rules', UINT, 0,
|
('xform.unfold_rules', UINT, 0,
|
||||||
"unfold rules statically using iterative squarring"),
|
"unfold rules statically using iterative squarring"),
|
||||||
('xform.slice', BOOL, True, "simplify clause set using slicing"),
|
('xform.slice', BOOL, True, "simplify clause set using slicing"),
|
||||||
('xform.karr', BOOL, False,
|
('xform.karr', BOOL, False,
|
||||||
"Add linear invariants to clauses using Karr's method"),
|
"Add linear invariants to clauses using Karr's method"),
|
||||||
('spacer.use_eqclass', BOOL, False, "Generalizes equalities to equivalence classes"),
|
('spacer.use_eqclass', BOOL, False, "Generalizes equalities to equivalence classes"),
|
||||||
('xform.transform_arrays', BOOL, False,
|
('xform.transform_arrays', BOOL, False,
|
||||||
|
@ -153,24 +153,24 @@ def_module_params('fixedpoint',
|
||||||
"Gives the number of quantifiers per array"),
|
"Gives the number of quantifiers per array"),
|
||||||
('xform.instantiate_arrays.slice_technique', SYMBOL, "no-slicing",
|
('xform.instantiate_arrays.slice_technique', SYMBOL, "no-slicing",
|
||||||
"<no-slicing>=> GetId(i) = i, <smash> => GetId(i) = true"),
|
"<no-slicing>=> GetId(i) = i, <smash> => GetId(i) = true"),
|
||||||
('xform.quantify_arrays', BOOL, False,
|
('xform.quantify_arrays', BOOL, False,
|
||||||
"create quantified Horn clauses from clauses with arrays"),
|
"create quantified Horn clauses from clauses with arrays"),
|
||||||
('xform.instantiate_quantifiers', BOOL, False,
|
('xform.instantiate_quantifiers', BOOL, False,
|
||||||
"instantiate quantified Horn clauses using E-matching heuristic"),
|
"instantiate quantified Horn clauses using E-matching heuristic"),
|
||||||
('xform.coalesce_rules', BOOL, False, "coalesce rules"),
|
('xform.coalesce_rules', BOOL, False, "coalesce rules"),
|
||||||
('xform.tail_simplifier_pve', BOOL, True, "propagate_variable_equivalences"),
|
('xform.tail_simplifier_pve', BOOL, True, "propagate_variable_equivalences"),
|
||||||
('xform.subsumption_checker', BOOL, True, "Enable subsumption checker (no support for model conversion)"),
|
('xform.subsumption_checker', BOOL, True, "Enable subsumption checker (no support for model conversion)"),
|
||||||
('xform.coi', BOOL, True, "use cone of influence simplificaiton"),
|
('xform.coi', BOOL, True, "use cone of influence simplification"),
|
||||||
('duality.enable_restarts', BOOL, False, 'DUALITY: enable restarts'),
|
('duality.enable_restarts', BOOL, False, 'DUALITY: enable restarts'),
|
||||||
('spacer.order_children', UINT, 0, 'SPACER: order of enqueuing children in non-linear rules : 0 (original), 1 (reverse)'),
|
('spacer.order_children', UINT, 0, 'SPACER: order of enqueuing children in non-linear rules : 0 (original), 1 (reverse)'),
|
||||||
('spacer.eager_reach_check', BOOL, True, 'SPACER: eagerly check if a query is reachable using reachability facts of predecessors'),
|
('spacer.eager_reach_check', BOOL, True, 'SPACER: eagerly check if a query is reachable using reachability facts of predecessors'),
|
||||||
('spacer.use_lemma_as_cti', BOOL, False, 'SPACER: use a lemma instead of a CTI in flexible_trace'),
|
('spacer.use_lemma_as_cti', BOOL, False, 'SPACER: use a lemma instead of a CTI in flexible_trace'),
|
||||||
('spacer.reset_obligation_queue', BOOL, True, 'SPACER: reset obligation queue when entering a new level'),
|
('spacer.reset_obligation_queue', BOOL, True, 'SPACER: reset obligation queue when entering a new level'),
|
||||||
('spacer.init_reach_facts', BOOL, True, 'SPACER: initialize reachability facts with false'),
|
('spacer.init_reach_facts', BOOL, True, 'SPACER: initialize reachability facts with false'),
|
||||||
('spacer.use_array_eq_generalizer', BOOL, True, 'SPACER: attempt to generalize lemmas with array equalities'),
|
('spacer.use_array_eq_generalizer', BOOL, True, 'SPACER: attempt to generalize lemmas with array equalities'),
|
||||||
('spacer.use_derivations', BOOL, True, 'SPACER: using derivation mechanism to cache intermediate results for non-linear rules'),
|
('spacer.use_derivations', BOOL, True, 'SPACER: using derivation mechanism to cache intermediate results for non-linear rules'),
|
||||||
('xform.array_blast', BOOL, False, "try to eliminate local array terms using Ackermannization -- some array terms may remain"),
|
('xform.array_blast', BOOL, False, "try to eliminate local array terms using Ackermannization -- some array terms may remain"),
|
||||||
('xform.array_blast_full', BOOL, False, "eliminate all local array variables by QE"),
|
('xform.array_blast_full', BOOL, False, "eliminate all local array variables by QE"),
|
||||||
('spacer.skip_propagate', BOOL, False, "Skip propagate/pushing phase. Turns PDR into a BMC that returns either reachable or unknown"),
|
('spacer.skip_propagate', BOOL, False, "Skip propagate/pushing phase. Turns PDR into a BMC that returns either reachable or unknown"),
|
||||||
('spacer.max_level', UINT, UINT_MAX, "Maximum level to explore"),
|
('spacer.max_level', UINT, UINT_MAX, "Maximum level to explore"),
|
||||||
('spacer.elim_aux', BOOL, True, "Eliminate auxiliary variables in reachability facts"),
|
('spacer.elim_aux', BOOL, True, "Eliminate auxiliary variables in reachability facts"),
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Duality {
|
||||||
|
|
||||||
class dl_interface : public datalog::engine_base {
|
class dl_interface : public datalog::engine_base {
|
||||||
duality_data *_d;
|
duality_data *_d;
|
||||||
datalog::context &m_ctx;
|
datalog::context &m_ctx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dl_interface(datalog::context& ctx);
|
dl_interface(datalog::context& ctx);
|
||||||
|
@ -69,7 +69,7 @@ namespace Duality {
|
||||||
|
|
||||||
proof_ref get_proof();
|
proof_ref get_proof();
|
||||||
|
|
||||||
duality_data *dd(){return _d;}
|
duality_data *dd(){return _d;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void display_certificate_non_const(std::ostream& out);
|
void display_certificate_non_const(std::ostream& out);
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace pdr {
|
||||||
virtual ~core_convex_hull_generalizer() {}
|
virtual ~core_convex_hull_generalizer() {}
|
||||||
virtual void operator()(model_node& n, expr_ref_vector const& core, bool uses_level, cores& new_cores);
|
virtual void operator()(model_node& n, expr_ref_vector const& core, bool uses_level, cores& new_cores);
|
||||||
virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level);
|
virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level);
|
||||||
};
|
};
|
||||||
|
|
||||||
class core_multi_generalizer : public core_generalizer {
|
class core_multi_generalizer : public core_generalizer {
|
||||||
core_bool_inductive_generalizer m_gen;
|
core_bool_inductive_generalizer m_gen;
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace datalog {
|
||||||
*/
|
*/
|
||||||
class mk_similarity_compressor : public rule_transformer::plugin {
|
class mk_similarity_compressor : public rule_transformer::plugin {
|
||||||
|
|
||||||
context & m_context;
|
context & m_context;
|
||||||
ast_manager & m_manager;
|
ast_manager & m_manager;
|
||||||
/** number of similar rules necessary for a group to be introduced */
|
/** number of similar rules necessary for a group to be introduced */
|
||||||
unsigned m_threshold_count;
|
unsigned m_threshold_count;
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace datalog {
|
||||||
We say that a rule containing C_i's is a rule with a "big tail".
|
We say that a rule containing C_i's is a rule with a "big tail".
|
||||||
*/
|
*/
|
||||||
class mk_simple_joins : public rule_transformer::plugin {
|
class mk_simple_joins : public rule_transformer::plugin {
|
||||||
context & m_context;
|
context & m_context;
|
||||||
rule_manager & rm;
|
rule_manager & rm;
|
||||||
public:
|
public:
|
||||||
mk_simple_joins(context & ctx);
|
mk_simple_joins(context & ctx);
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ namespace qe {
|
||||||
|
|
||||||
void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml) {
|
void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml) {
|
||||||
expr_map map (m);
|
expr_map map (m);
|
||||||
operator()(mdl, vars, fml, map);
|
operator()(mdl, vars, fml, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml, expr_map& map) {
|
void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml, expr_map& map) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace datalog {
|
||||||
typedef obj_map<func_decl, adornment> pred_adornment_map;
|
typedef obj_map<func_decl, adornment> pred_adornment_map;
|
||||||
typedef obj_map<func_decl, func_decl *> pred2pred;
|
typedef obj_map<func_decl, func_decl *> pred2pred;
|
||||||
|
|
||||||
context & m_context;
|
context & m_context;
|
||||||
ast_manager & m;
|
ast_manager & m;
|
||||||
rule_manager& rm;
|
rule_manager& rm;
|
||||||
ast_ref_vector m_pinned;
|
ast_ref_vector m_pinned;
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace datalog {
|
||||||
typedef hashtable<c_info, c_info_hash, default_eq<c_info> > in_progress_table;
|
typedef hashtable<c_info, c_info_hash, default_eq<c_info> > in_progress_table;
|
||||||
typedef svector<c_info> todo_stack;
|
typedef svector<c_info> todo_stack;
|
||||||
|
|
||||||
context & m_context;
|
context & m_context;
|
||||||
ast_manager & m;
|
ast_manager & m;
|
||||||
rule_manager & rm;
|
rule_manager & rm;
|
||||||
rule_ref_vector m_rules;
|
rule_ref_vector m_rules;
|
||||||
|
|
|
@ -2,7 +2,7 @@ def_module_params('opt',
|
||||||
description='optimization parameters',
|
description='optimization parameters',
|
||||||
export=True,
|
export=True,
|
||||||
params=(('optsmt_engine', SYMBOL, 'basic', "select optimization engine: 'basic', 'farkas', 'symba'"),
|
params=(('optsmt_engine', SYMBOL, 'basic', "select optimization engine: 'basic', 'farkas', 'symba'"),
|
||||||
('maxsat_engine', SYMBOL, 'maxres', "select engine for maxsat: 'core_maxsat', 'wmax', 'maxres', 'pd-maxres'"),
|
('maxsat_engine', SYMBOL, 'maxres', "select engine for maxsat: 'core_maxsat', 'wmax', 'maxres', 'pd-maxres'"),
|
||||||
('priority', SYMBOL, 'lex', "select how to priortize objectives: 'lex' (lexicographic), 'pareto', or 'box'"),
|
('priority', SYMBOL, 'lex', "select how to priortize objectives: 'lex' (lexicographic), 'pareto', or 'box'"),
|
||||||
('dump_benchmarks', BOOL, False, 'dump benchmarks for profiling'),
|
('dump_benchmarks', BOOL, False, 'dump benchmarks for profiling'),
|
||||||
('timeout', UINT, UINT_MAX, 'timeout (in milliseconds) (UINT_MAX and 0 mean no timeout)'),
|
('timeout', UINT, UINT_MAX, 'timeout (in milliseconds) (UINT_MAX and 0 mean no timeout)'),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*++
|
/*++
|
||||||
Copyright (c) 2016 Microsoft Corporation
|
Copyright (c) 2016 Microsoft Corporation
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
Lev Nachmanson 2016-10-27
|
Lev Nachmanson 2016-10-27
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ Author:
|
||||||
#include "util/gparams.h"
|
#include "util/gparams.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
static lean::lp_solver<double, double>* g_solver = 0;
|
static lp::lp_solver<double, double>* g_solver = 0;
|
||||||
|
|
||||||
static void display_statistics() {
|
static void display_statistics() {
|
||||||
if (g_solver && g_solver->settings().print_statistics) {
|
if (g_solver && g_solver->settings().print_statistics) {
|
||||||
|
@ -42,7 +42,7 @@ static void on_timeout() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct front_end_resource_limit : public lean::lp_resource_limit {
|
struct front_end_resource_limit : public lp::lp_resource_limit {
|
||||||
reslimit& m_reslim;
|
reslimit& m_reslim;
|
||||||
|
|
||||||
front_end_resource_limit(reslimit& lim):
|
front_end_resource_limit(reslimit& lim):
|
||||||
|
@ -54,7 +54,7 @@ struct front_end_resource_limit : public lean::lp_resource_limit {
|
||||||
|
|
||||||
void run_solver(lp_params & params, char const * mps_file_name) {
|
void run_solver(lp_params & params, char const * mps_file_name) {
|
||||||
|
|
||||||
reslimit rlim;
|
reslimit rlim;
|
||||||
unsigned timeout = gparams::get().get_uint("timeout", 0);
|
unsigned timeout = gparams::get().get_uint("timeout", 0);
|
||||||
unsigned rlimit = gparams::get().get_uint("rlimit", 0);
|
unsigned rlimit = gparams::get().get_uint("rlimit", 0);
|
||||||
front_end_resource_limit lp_limit(rlim);
|
front_end_resource_limit lp_limit(rlim);
|
||||||
|
@ -64,14 +64,14 @@ void run_solver(lp_params & params, char const * mps_file_name) {
|
||||||
scoped_timer timer(timeout, &eh);
|
scoped_timer timer(timeout, &eh);
|
||||||
|
|
||||||
std::string fn(mps_file_name);
|
std::string fn(mps_file_name);
|
||||||
lean::mps_reader<double, double> reader(fn);
|
lp::mps_reader<double, double> reader(fn);
|
||||||
reader.set_message_stream(&std::cout); // can be redirected
|
reader.set_message_stream(&std::cout); // can be redirected
|
||||||
reader.read();
|
reader.read();
|
||||||
if (!reader.is_ok()) {
|
if (!reader.is_ok()) {
|
||||||
std::cerr << "cannot process " << mps_file_name << std::endl;
|
std::cerr << "cannot process " << mps_file_name << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lean::lp_solver<double, double> * solver = reader.create_solver(false); // false - to create the primal solver
|
lp::lp_solver<double, double> * solver = reader.create_solver(false); // false - to create the primal solver
|
||||||
solver->settings().set_resource_limit(lp_limit);
|
solver->settings().set_resource_limit(lp_limit);
|
||||||
g_solver = solver;
|
g_solver = solver;
|
||||||
if (params.min()) {
|
if (params.min()) {
|
||||||
|
@ -80,20 +80,20 @@ void run_solver(lp_params & params, char const * mps_file_name) {
|
||||||
solver->settings().set_message_ostream(&std::cout);
|
solver->settings().set_message_ostream(&std::cout);
|
||||||
solver->settings().report_frequency = params.rep_freq();
|
solver->settings().report_frequency = params.rep_freq();
|
||||||
solver->settings().print_statistics = params.print_stats();
|
solver->settings().print_statistics = params.print_stats();
|
||||||
solver->settings().simplex_strategy() = lean:: simplex_strategy_enum::lu;
|
solver->settings().simplex_strategy() = lp:: simplex_strategy_enum::lu;
|
||||||
|
|
||||||
solver->find_maximal_solution();
|
solver->find_maximal_solution();
|
||||||
|
|
||||||
*(solver->settings().get_message_ostream()) << "status is " << lp_status_to_string(solver->get_status()) << std::endl;
|
*(solver->settings().get_message_ostream()) << "status is " << lp_status_to_string(solver->get_status()) << std::endl;
|
||||||
if (solver->get_status() == lean::OPTIMAL) {
|
if (solver->get_status() == lp::OPTIMAL) {
|
||||||
if (params.min()) {
|
if (params.min()) {
|
||||||
solver->flip_costs();
|
solver->flip_costs();
|
||||||
}
|
}
|
||||||
solver->print_model(std::cout);
|
solver->print_model(std::cout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #pragma omp critical (g_display_stats)
|
// #pragma omp critical (g_display_stats)
|
||||||
{
|
{
|
||||||
display_statistics();
|
display_statistics();
|
||||||
register_on_timeout_proc(0);
|
register_on_timeout_proc(0);
|
||||||
g_solver = 0;
|
g_solver = 0;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
:formula (forall (a Int) (i Int) (e Int)
|
:formula (forall (a Int) (i Int) (e Int)
|
||||||
(= (?select (?store a i e) i) e)
|
(= (?select (?store a i e) i) e)
|
||||||
:pats { (?store a i e) }
|
:pats { (?store a i e) }
|
||||||
:weight { 0 })
|
:weight { 0 })
|
||||||
|
|
||||||
:formula (forall (a Int) (i Int) (j Int) (e Int)
|
:formula (forall (a Int) (i Int) (j Int) (e Int)
|
||||||
(or (= i j) (= (?select (?store a i e) j) (?select a j)))
|
(or (= i j) (= (?select (?store a i e) j) (?select a j)))
|
||||||
|
|
|
@ -956,8 +956,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_neighbours_undirected(dl_var current, svector<dl_var> & neighbours) {
|
void get_neighbours_undirected(dl_var current, svector<dl_var> & neighbours) {
|
||||||
neighbours.reset();
|
neighbours.reset();
|
||||||
edge_id_vector & out_edges = m_out_edges[current];
|
edge_id_vector & out_edges = m_out_edges[current];
|
||||||
typename edge_id_vector::iterator it = out_edges.begin(), end = out_edges.end();
|
typename edge_id_vector::iterator it = out_edges.begin(), end = out_edges.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
edge_id e_id = *it;
|
edge_id e_id = *it;
|
||||||
|
@ -968,7 +968,7 @@ public:
|
||||||
}
|
}
|
||||||
edge_id_vector & in_edges = m_in_edges[current];
|
edge_id_vector & in_edges = m_in_edges[current];
|
||||||
typename edge_id_vector::iterator it2 = in_edges.begin(), end2 = in_edges.end();
|
typename edge_id_vector::iterator it2 = in_edges.begin(), end2 = in_edges.end();
|
||||||
for (; it2 != end2; ++it2) {
|
for (; it2 != end2; ++it2) {
|
||||||
edge_id e_id = *it2;
|
edge_id e_id = *it2;
|
||||||
edge & e = m_edges[e_id];
|
edge & e = m_edges[e_id];
|
||||||
SASSERT(e.get_target() == current);
|
SASSERT(e.get_target() == current);
|
||||||
|
@ -980,19 +980,19 @@ public:
|
||||||
void dfs_undirected(dl_var start, svector<dl_var> & threads) {
|
void dfs_undirected(dl_var start, svector<dl_var> & threads) {
|
||||||
threads.reset();
|
threads.reset();
|
||||||
threads.resize(get_num_nodes());
|
threads.resize(get_num_nodes());
|
||||||
uint_set discovered, explored;
|
uint_set discovered, explored;
|
||||||
svector<dl_var> nodes;
|
svector<dl_var> nodes;
|
||||||
discovered.insert(start);
|
discovered.insert(start);
|
||||||
nodes.push_back(start);
|
nodes.push_back(start);
|
||||||
dl_var prev = start;
|
dl_var prev = start;
|
||||||
while(!nodes.empty()) {
|
while(!nodes.empty()) {
|
||||||
dl_var current = nodes.back();
|
dl_var current = nodes.back();
|
||||||
SASSERT(discovered.contains(current) && !explored.contains(current));
|
SASSERT(discovered.contains(current) && !explored.contains(current));
|
||||||
svector<dl_var> neighbours;
|
svector<dl_var> neighbours;
|
||||||
get_neighbours_undirected(current, neighbours);
|
get_neighbours_undirected(current, neighbours);
|
||||||
SASSERT(!neighbours.empty());
|
SASSERT(!neighbours.empty());
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (unsigned i = 0; i < neighbours.size(); ++i) {
|
for (unsigned i = 0; i < neighbours.size(); ++i) {
|
||||||
dl_var next = neighbours[i];
|
dl_var next = neighbours[i];
|
||||||
DEBUG_CODE(
|
DEBUG_CODE(
|
||||||
edge_id id;
|
edge_id id;
|
||||||
|
@ -1002,18 +1002,18 @@ public:
|
||||||
threads[prev] = next;
|
threads[prev] = next;
|
||||||
prev = next;
|
prev = next;
|
||||||
discovered.insert(next);
|
discovered.insert(next);
|
||||||
nodes.push_back(next);
|
nodes.push_back(next);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SASSERT(!nodes.empty());
|
SASSERT(!nodes.empty());
|
||||||
if (!found) {
|
if (!found) {
|
||||||
explored.insert(current);
|
explored.insert(current);
|
||||||
nodes.pop_back();
|
nodes.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
threads[prev] = start;
|
threads[prev] = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bfs_undirected(dl_var start, svector<dl_var> & parents, svector<dl_var> & depths) {
|
void bfs_undirected(dl_var start, svector<dl_var> & parents, svector<dl_var> & depths) {
|
||||||
|
@ -1022,31 +1022,31 @@ public:
|
||||||
parents[start] = -1;
|
parents[start] = -1;
|
||||||
depths.reset();
|
depths.reset();
|
||||||
depths.resize(get_num_nodes());
|
depths.resize(get_num_nodes());
|
||||||
uint_set visited;
|
uint_set visited;
|
||||||
std::deque<dl_var> nodes;
|
std::deque<dl_var> nodes;
|
||||||
visited.insert(start);
|
visited.insert(start);
|
||||||
nodes.push_front(start);
|
nodes.push_front(start);
|
||||||
while(!nodes.empty()) {
|
while(!nodes.empty()) {
|
||||||
dl_var current = nodes.back();
|
dl_var current = nodes.back();
|
||||||
nodes.pop_back();
|
nodes.pop_back();
|
||||||
SASSERT(visited.contains(current));
|
SASSERT(visited.contains(current));
|
||||||
svector<dl_var> neighbours;
|
svector<dl_var> neighbours;
|
||||||
get_neighbours_undirected(current, neighbours);
|
get_neighbours_undirected(current, neighbours);
|
||||||
SASSERT(!neighbours.empty());
|
SASSERT(!neighbours.empty());
|
||||||
for (unsigned i = 0; i < neighbours.size(); ++i) {
|
for (unsigned i = 0; i < neighbours.size(); ++i) {
|
||||||
dl_var next = neighbours[i];
|
dl_var next = neighbours[i];
|
||||||
DEBUG_CODE(
|
DEBUG_CODE(
|
||||||
edge_id id;
|
edge_id id;
|
||||||
SASSERT(get_edge_id(current, next, id) || get_edge_id(next, current, id)););
|
SASSERT(get_edge_id(current, next, id) || get_edge_id(next, current, id)););
|
||||||
if (!visited.contains(next)) {
|
if (!visited.contains(next)) {
|
||||||
TRACE("diff_logic", tout << "parents[" << next << "] --> " << current << std::endl;);
|
TRACE("diff_logic", tout << "parents[" << next << "] --> " << current << std::endl;);
|
||||||
parents[next] = current;
|
parents[next] = current;
|
||||||
depths[next] = depths[current] + 1;
|
depths[next] = depths[current] + 1;
|
||||||
visited.insert(next);
|
visited.insert(next);
|
||||||
nodes.push_front(next);
|
nodes.push_front(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
|
|
|
@ -40,10 +40,10 @@ namespace smt {
|
||||||
|
|
||||||
/** \ brief Use sparse maps in SMT solver.
|
/** \ brief Use sparse maps in SMT solver.
|
||||||
|
|
||||||
Define this to use hash maps rather than vectors over ast
|
Define this to use hash maps rather than vectors over ast
|
||||||
nodes. This is useful in the case there are many solvers, each
|
nodes. This is useful in the case there are many solvers, each
|
||||||
referencing few nodes from a large ast manager. There is some
|
referencing few nodes from a large ast manager. There is some
|
||||||
unknown performance penalty for this. */
|
unknown performance penalty for this. */
|
||||||
|
|
||||||
// #define SPARSE_MAP
|
// #define SPARSE_MAP
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace smt {
|
||||||
/**
|
/**
|
||||||
\brief Is "model based" instantiate allowed to instantiate this quantifier?
|
\brief Is "model based" instantiate allowed to instantiate this quantifier?
|
||||||
*/
|
*/
|
||||||
virtual bool mbqi_enabled(quantifier *q) const {return true;}
|
virtual bool mbqi_enabled(quantifier *q) const {return true;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Give a change to the plugin to adjust the interpretation of unintepreted functions.
|
\brief Give a change to the plugin to adjust the interpretation of unintepreted functions.
|
||||||
|
|
|
@ -192,7 +192,7 @@ namespace smt {
|
||||||
virtual lbool validate_unsat_core(expr_ref_vector & unsat_core) {
|
virtual lbool validate_unsat_core(expr_ref_vector & unsat_core) {
|
||||||
return l_false;
|
return l_false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief This method is invoked before the search starts.
|
\brief This method is invoked before the search starts.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,7 +38,7 @@ Revision History:
|
||||||
#include "util/nat_set.h"
|
#include "util/nat_set.h"
|
||||||
#include "tactic/filter_model_converter.h"
|
#include "tactic/filter_model_converter.h"
|
||||||
|
|
||||||
namespace lp {
|
namespace lra_lp {
|
||||||
enum bound_kind { lower_t, upper_t };
|
enum bound_kind { lower_t, upper_t };
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, bound_kind const& k) {
|
std::ostream& operator<<(std::ostream& out, bound_kind const& k) {
|
||||||
|
@ -50,7 +50,7 @@ namespace lp {
|
||||||
}
|
}
|
||||||
|
|
||||||
class bound {
|
class bound {
|
||||||
smt::bool_var m_bv;
|
smt::bool_var m_bv;
|
||||||
smt::theory_var m_var;
|
smt::theory_var m_var;
|
||||||
rational m_value;
|
rational m_value;
|
||||||
bound_kind m_bound_kind;
|
bound_kind m_bound_kind;
|
||||||
|
@ -111,7 +111,7 @@ namespace lp {
|
||||||
|
|
||||||
namespace smt {
|
namespace smt {
|
||||||
|
|
||||||
typedef ptr_vector<lp::bound> lp_bounds;
|
typedef ptr_vector<lra_lp::bound> lp_bounds;
|
||||||
|
|
||||||
class theory_lra::imp {
|
class theory_lra::imp {
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ namespace smt {
|
||||||
delayed_atom(unsigned b, bool t): m_bv(b), m_is_true(t) {}
|
delayed_atom(unsigned b, bool t): m_bv(b), m_is_true(t) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class resource_limit : public lean::lp_resource_limit {
|
class resource_limit : public lp::lp_resource_limit {
|
||||||
imp& m_imp;
|
imp& m_imp;
|
||||||
public:
|
public:
|
||||||
resource_limit(imp& i): m_imp(i) { }
|
resource_limit(imp& i): m_imp(i) { }
|
||||||
|
@ -198,7 +198,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<std::pair<rational, lean::var_index>> var_coeffs;
|
typedef vector<std::pair<rational, lp::var_index>> var_coeffs;
|
||||||
struct delayed_def {
|
struct delayed_def {
|
||||||
vector<rational> m_coeffs;
|
vector<rational> m_coeffs;
|
||||||
svector<theory_var> m_vars;
|
svector<theory_var> m_vars;
|
||||||
|
@ -208,11 +208,11 @@ namespace smt {
|
||||||
m_coeffs(coeffs), m_vars(vars), m_coeff(r), m_var(v) {}
|
m_coeffs(coeffs), m_vars(vars), m_coeff(r), m_var(v) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
svector<lean::var_index> m_theory_var2var_index; // translate from theory variables to lar vars
|
svector<lp::var_index> m_theory_var2var_index; // translate from theory variables to lar vars
|
||||||
svector<theory_var> m_var_index2theory_var; // reverse map from lp_solver variables to theory variables
|
svector<theory_var> m_var_index2theory_var; // reverse map from lp_solver variables to theory variables
|
||||||
svector<theory_var> m_term_index2theory_var; // reverse map from lp_solver variables to theory variables
|
svector<theory_var> m_term_index2theory_var; // reverse map from lp_solver variables to theory variables
|
||||||
var_coeffs m_left_side; // constraint left side
|
var_coeffs m_left_side; // constraint left side
|
||||||
mutable std::unordered_map<lean::var_index, rational> m_variable_values; // current model
|
mutable std::unordered_map<lp::var_index, rational> m_variable_values; // current model
|
||||||
|
|
||||||
enum constraint_source {
|
enum constraint_source {
|
||||||
inequality_source,
|
inequality_source,
|
||||||
|
@ -233,10 +233,10 @@ namespace smt {
|
||||||
expr* m_not_handled;
|
expr* m_not_handled;
|
||||||
ptr_vector<app> m_underspecified;
|
ptr_vector<app> m_underspecified;
|
||||||
unsigned_vector m_var_trail;
|
unsigned_vector m_var_trail;
|
||||||
vector<ptr_vector<lp::bound> > m_use_list; // bounds where variables are used.
|
vector<ptr_vector<lra_lp::bound> > m_use_list; // bounds where variables are used.
|
||||||
|
|
||||||
// attributes for incremental version:
|
// attributes for incremental version:
|
||||||
u_map<lp::bound*> m_bool_var2bound;
|
u_map<lra_lp::bound*> m_bool_var2bound;
|
||||||
vector<lp_bounds> m_bounds;
|
vector<lp_bounds> m_bounds;
|
||||||
unsigned_vector m_unassigned_bounds;
|
unsigned_vector m_unassigned_bounds;
|
||||||
unsigned_vector m_bounds_trail;
|
unsigned_vector m_bounds_trail;
|
||||||
|
@ -258,15 +258,15 @@ namespace smt {
|
||||||
struct var_value_hash {
|
struct var_value_hash {
|
||||||
imp & m_th;
|
imp & m_th;
|
||||||
var_value_hash(imp & th):m_th(th) {}
|
var_value_hash(imp & th):m_th(th) {}
|
||||||
unsigned operator()(theory_var v) const { return (unsigned)std::hash<lean::impq>()(m_th.get_ivalue(v)); }
|
unsigned operator()(theory_var v) const { return (unsigned)std::hash<lp::impq>()(m_th.get_ivalue(v)); }
|
||||||
};
|
};
|
||||||
int_hashtable<var_value_hash, var_value_eq> m_model_eqs;
|
int_hashtable<var_value_hash, var_value_eq> m_model_eqs;
|
||||||
|
|
||||||
|
|
||||||
svector<scope> m_scopes;
|
svector<scope> m_scopes;
|
||||||
lp::stats m_stats;
|
lra_lp::stats m_stats;
|
||||||
arith_factory* m_factory;
|
arith_factory* m_factory;
|
||||||
scoped_ptr<lean::lar_solver> m_solver;
|
scoped_ptr<lp::lar_solver> m_solver;
|
||||||
resource_limit m_resource_limit;
|
resource_limit m_resource_limit;
|
||||||
lp_bounds m_new_bounds;
|
lp_bounds m_new_bounds;
|
||||||
|
|
||||||
|
@ -282,10 +282,10 @@ namespace smt {
|
||||||
void init_solver() {
|
void init_solver() {
|
||||||
if (m_solver) return;
|
if (m_solver) return;
|
||||||
lp_params lp(ctx().get_params());
|
lp_params lp(ctx().get_params());
|
||||||
m_solver = alloc(lean::lar_solver);
|
m_solver = alloc(lp::lar_solver);
|
||||||
m_theory_var2var_index.reset();
|
m_theory_var2var_index.reset();
|
||||||
m_solver->settings().set_resource_limit(m_resource_limit);
|
m_solver->settings().set_resource_limit(m_resource_limit);
|
||||||
m_solver->settings().simplex_strategy() = static_cast<lean::simplex_strategy_enum>(lp.simplex_strategy());
|
m_solver->settings().simplex_strategy() = static_cast<lp::simplex_strategy_enum>(lp.simplex_strategy());
|
||||||
reset_variable_values();
|
reset_variable_values();
|
||||||
m_solver->settings().bound_propagation() = BP_NONE != propagation_mode();
|
m_solver->settings().bound_propagation() = BP_NONE != propagation_mode();
|
||||||
m_solver->set_propagate_bounds_on_pivoted_rows_mode(lp.bprop_on_pivoted_rows());
|
m_solver->set_propagate_bounds_on_pivoted_rows_mode(lp.bprop_on_pivoted_rows());
|
||||||
|
@ -487,8 +487,8 @@ namespace smt {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
lean::var_index get_var_index(theory_var v) {
|
lp::var_index get_var_index(theory_var v) {
|
||||||
lean::var_index result = UINT_MAX;
|
lp::var_index result = UINT_MAX;
|
||||||
if (m_theory_var2var_index.size() > static_cast<unsigned>(v)) {
|
if (m_theory_var2var_index.size() > static_cast<unsigned>(v)) {
|
||||||
result = m_theory_var2var_index[v];
|
result = m_theory_var2var_index[v];
|
||||||
}
|
}
|
||||||
|
@ -537,20 +537,20 @@ namespace smt {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_eq_constraint(lean::constraint_index index, enode* n1, enode* n2) {
|
void add_eq_constraint(lp::constraint_index index, enode* n1, enode* n2) {
|
||||||
m_constraint_sources.setx(index, equality_source, null_source);
|
m_constraint_sources.setx(index, equality_source, null_source);
|
||||||
m_equalities.setx(index, enode_pair(n1, n2), enode_pair(0, 0));
|
m_equalities.setx(index, enode_pair(n1, n2), enode_pair(0, 0));
|
||||||
++m_stats.m_add_rows;
|
++m_stats.m_add_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_ineq_constraint(lean::constraint_index index, literal lit) {
|
void add_ineq_constraint(lp::constraint_index index, literal lit) {
|
||||||
m_constraint_sources.setx(index, inequality_source, null_source);
|
m_constraint_sources.setx(index, inequality_source, null_source);
|
||||||
m_inequalities.setx(index, lit, null_literal);
|
m_inequalities.setx(index, lit, null_literal);
|
||||||
++m_stats.m_add_rows;
|
++m_stats.m_add_rows;
|
||||||
TRACE("arith", m_solver->print_constraint(index, tout); tout << "\n";);
|
TRACE("arith", m_solver->print_constraint(index, tout); tout << "\n";);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_def_constraint(lean::constraint_index index, theory_var v) {
|
void add_def_constraint(lp::constraint_index index, theory_var v) {
|
||||||
m_constraint_sources.setx(index, definition_source, null_source);
|
m_constraint_sources.setx(index, definition_source, null_source);
|
||||||
m_definitions.setx(index, v, null_theory_var);
|
m_definitions.setx(index, v, null_theory_var);
|
||||||
++m_stats.m_add_rows;
|
++m_stats.m_add_rows;
|
||||||
|
@ -561,7 +561,7 @@ namespace smt {
|
||||||
st.vars().append(d.m_vars);
|
st.vars().append(d.m_vars);
|
||||||
st.coeffs().append(d.m_coeffs);
|
st.coeffs().append(d.m_coeffs);
|
||||||
init_left_side(st);
|
init_left_side(st);
|
||||||
add_def_constraint(m_solver->add_constraint(m_left_side, lean::EQ, -d.m_coeff), d.m_var);
|
add_def_constraint(m_solver->add_constraint(m_left_side, lp::EQ, -d.m_coeff), d.m_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
void internalize_eq(theory_var v1, theory_var v2) {
|
void internalize_eq(theory_var v1, theory_var v2) {
|
||||||
|
@ -573,7 +573,7 @@ namespace smt {
|
||||||
st.coeffs().push_back(rational::one());
|
st.coeffs().push_back(rational::one());
|
||||||
st.coeffs().push_back(rational::minus_one());
|
st.coeffs().push_back(rational::minus_one());
|
||||||
init_left_side(st);
|
init_left_side(st);
|
||||||
add_eq_constraint(m_solver->add_constraint(m_left_side, lean::EQ, rational::zero()), n1, n2);
|
add_eq_constraint(m_solver->add_constraint(m_left_side, lp::EQ, rational::zero()), n1, n2);
|
||||||
TRACE("arith",
|
TRACE("arith",
|
||||||
tout << "v" << v1 << " = " << "v" << v2 << ": "
|
tout << "v" << v1 << " = " << "v" << v2 << ": "
|
||||||
<< mk_pp(n1->get_owner(), m) << " = " << mk_pp(n2->get_owner(), m) << "\n";);
|
<< mk_pp(n1->get_owner(), m) << " = " << mk_pp(n2->get_owner(), m) << "\n";);
|
||||||
|
@ -583,7 +583,7 @@ namespace smt {
|
||||||
for (unsigned i = m_bounds_trail.size(); i > old_size; ) {
|
for (unsigned i = m_bounds_trail.size(); i > old_size; ) {
|
||||||
--i;
|
--i;
|
||||||
unsigned v = m_bounds_trail[i];
|
unsigned v = m_bounds_trail[i];
|
||||||
lp::bound* b = m_bounds[v].back();
|
lra_lp::bound* b = m_bounds[v].back();
|
||||||
// del_use_lists(b);
|
// del_use_lists(b);
|
||||||
dealloc(b);
|
dealloc(b);
|
||||||
m_bounds[v].pop_back();
|
m_bounds[v].pop_back();
|
||||||
|
@ -626,7 +626,7 @@ namespace smt {
|
||||||
else {
|
else {
|
||||||
init_left_side(st);
|
init_left_side(st);
|
||||||
theory_var v = mk_var(term);
|
theory_var v = mk_var(term);
|
||||||
lean::var_index vi = m_theory_var2var_index.get(v, UINT_MAX);
|
lp::var_index vi = m_theory_var2var_index.get(v, UINT_MAX);
|
||||||
if (vi == UINT_MAX) {
|
if (vi == UINT_MAX) {
|
||||||
vi = m_solver->add_term(m_left_side, st.coeff());
|
vi = m_solver->add_term(m_left_side, st.coeff());
|
||||||
m_theory_var2var_index.setx(v, vi, UINT_MAX);
|
m_theory_var2var_index.setx(v, vi, UINT_MAX);
|
||||||
|
@ -691,22 +691,22 @@ namespace smt {
|
||||||
ctx().set_var_theory(bv, get_id());
|
ctx().set_var_theory(bv, get_id());
|
||||||
expr* n1, *n2;
|
expr* n1, *n2;
|
||||||
rational r;
|
rational r;
|
||||||
lp::bound_kind k;
|
lra_lp::bound_kind k;
|
||||||
theory_var v = null_theory_var;
|
theory_var v = null_theory_var;
|
||||||
if (a.is_le(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
|
if (a.is_le(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
|
||||||
v = internalize_def(to_app(n1));
|
v = internalize_def(to_app(n1));
|
||||||
k = lp::upper_t;
|
k = lra_lp::upper_t;
|
||||||
}
|
}
|
||||||
else if (a.is_ge(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
|
else if (a.is_ge(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
|
||||||
v = internalize_def(to_app(n1));
|
v = internalize_def(to_app(n1));
|
||||||
k = lp::lower_t;
|
k = lra_lp::lower_t;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TRACE("arith", tout << "Could not internalize " << mk_pp(atom, m) << "\n";);
|
TRACE("arith", tout << "Could not internalize " << mk_pp(atom, m) << "\n";);
|
||||||
found_not_handled(atom);
|
found_not_handled(atom);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
lp::bound* b = alloc(lp::bound, bv, v, r, k);
|
lra_lp::bound* b = alloc(lra_lp::bound, bv, v, r, k);
|
||||||
m_bounds[v].push_back(b);
|
m_bounds[v].push_back(b);
|
||||||
updt_unassigned_bounds(v, +1);
|
updt_unassigned_bounds(v, +1);
|
||||||
m_bounds_trail.push_back(v);
|
m_bounds_trail.push_back(v);
|
||||||
|
@ -723,23 +723,23 @@ namespace smt {
|
||||||
ctx().set_var_theory(bv, get_id());
|
ctx().set_var_theory(bv, get_id());
|
||||||
expr* n1, *n2;
|
expr* n1, *n2;
|
||||||
rational r;
|
rational r;
|
||||||
lp::bound_kind k;
|
lra_lp::bound_kind k;
|
||||||
theory_var v = null_theory_var;
|
theory_var v = null_theory_var;
|
||||||
scoped_internalize_state st(*this);
|
scoped_internalize_state st(*this);
|
||||||
if (a.is_le(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
|
if (a.is_le(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
|
||||||
v = internalize_def(to_app(n1), st);
|
v = internalize_def(to_app(n1), st);
|
||||||
k = lp::upper_t;
|
k = lra_lp::upper_t;
|
||||||
}
|
}
|
||||||
else if (a.is_ge(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
|
else if (a.is_ge(atom, n1, n2) && is_numeral(n2, r) && is_app(n1)) {
|
||||||
v = internalize_def(to_app(n1), st);
|
v = internalize_def(to_app(n1), st);
|
||||||
k = lp::lower_t;
|
k = lra_lp::lower_t;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TRACE("arith", tout << "Could not internalize " << mk_pp(atom, m) << "\n";);
|
TRACE("arith", tout << "Could not internalize " << mk_pp(atom, m) << "\n";);
|
||||||
found_not_handled(atom);
|
found_not_handled(atom);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
lp::bound* b = alloc(lp::bound, bv, v, r, k);
|
lra_lp::bound* b = alloc(lra_lp::bound, bv, v, r, k);
|
||||||
m_bounds[v].push_back(b);
|
m_bounds[v].push_back(b);
|
||||||
updt_unassigned_bounds(v, +1);
|
updt_unassigned_bounds(v, +1);
|
||||||
m_bounds_trail.push_back(v);
|
m_bounds_trail.push_back(v);
|
||||||
|
@ -830,7 +830,7 @@ namespace smt {
|
||||||
unsigned old_size = m_scopes.size() - num_scopes;
|
unsigned old_size = m_scopes.size() - num_scopes;
|
||||||
del_bounds(m_scopes[old_size].m_bounds_lim);
|
del_bounds(m_scopes[old_size].m_bounds_lim);
|
||||||
for (unsigned i = m_scopes[old_size].m_var_trail_lim; i < m_var_trail.size(); ++i) {
|
for (unsigned i = m_scopes[old_size].m_var_trail_lim; i < m_var_trail.size(); ++i) {
|
||||||
lean::var_index vi = m_theory_var2var_index[m_var_trail[i]];
|
lp::var_index vi = m_theory_var2var_index[m_var_trail[i]];
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
unsigned ti = m_solver->adjust_term_index(vi);
|
unsigned ti = m_solver->adjust_term_index(vi);
|
||||||
m_term_index2theory_var[ti] = UINT_MAX;
|
m_term_index2theory_var[ti] = UINT_MAX;
|
||||||
|
@ -1023,14 +1023,14 @@ namespace smt {
|
||||||
return m_solver->var_is_registered(m_theory_var2var_index[v]);
|
return m_solver->var_is_registered(m_theory_var2var_index[v]);
|
||||||
}
|
}
|
||||||
|
|
||||||
lean::impq get_ivalue(theory_var v) const {
|
lp::impq get_ivalue(theory_var v) const {
|
||||||
lean_assert(can_get_ivalue(v));
|
SASSERT(can_get_ivalue(v));
|
||||||
lean::var_index vi = m_theory_var2var_index[v];
|
lp::var_index vi = m_theory_var2var_index[v];
|
||||||
if (!m_solver->is_term(vi))
|
if (!m_solver->is_term(vi))
|
||||||
return m_solver->get_value(vi);
|
return m_solver->get_value(vi);
|
||||||
|
|
||||||
const lean::lar_term& term = m_solver->get_term(vi);
|
const lp::lar_term& term = m_solver->get_term(vi);
|
||||||
lean::impq result(term.m_v);
|
lp::impq result(term.m_v);
|
||||||
for (const auto & i: term.m_coeffs) {
|
for (const auto & i: term.m_coeffs) {
|
||||||
result += m_solver->get_value(i.first) * i.second;
|
result += m_solver->get_value(i.first) * i.second;
|
||||||
}
|
}
|
||||||
|
@ -1040,12 +1040,12 @@ namespace smt {
|
||||||
|
|
||||||
rational get_value(theory_var v) const {
|
rational get_value(theory_var v) const {
|
||||||
if (!can_get_value(v)) return rational::zero();
|
if (!can_get_value(v)) return rational::zero();
|
||||||
lean::var_index vi = m_theory_var2var_index[v];
|
lp::var_index vi = m_theory_var2var_index[v];
|
||||||
if (m_variable_values.count(vi) > 0) {
|
if (m_variable_values.count(vi) > 0) {
|
||||||
return m_variable_values[vi];
|
return m_variable_values[vi];
|
||||||
}
|
}
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
const lean::lar_term& term = m_solver->get_term(vi);
|
const lp::lar_term& term = m_solver->get_term(vi);
|
||||||
rational result = term.m_v;
|
rational result = term.m_v;
|
||||||
for (auto i = term.m_coeffs.begin(); i != term.m_coeffs.end(); ++i) {
|
for (auto i = term.m_coeffs.begin(); i != term.m_coeffs.end(); ++i) {
|
||||||
result += m_variable_values[i->first] * i->second;
|
result += m_variable_values[i->first] * i->second;
|
||||||
|
@ -1068,7 +1068,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool assume_eqs() {
|
bool assume_eqs() {
|
||||||
svector<lean::var_index> vars;
|
svector<lp::var_index> vars;
|
||||||
theory_var sz = static_cast<theory_var>(th.get_num_vars());
|
theory_var sz = static_cast<theory_var>(th.get_num_vars());
|
||||||
for (theory_var v = 0; v < sz; ++v) {
|
for (theory_var v = 0; v < sz; ++v) {
|
||||||
if (th.is_relevant_and_shared(get_enode(v))) {
|
if (th.is_relevant_and_shared(get_enode(v))) {
|
||||||
|
@ -1169,7 +1169,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
is_sat = make_feasible();
|
is_sat = make_feasible();
|
||||||
}
|
}
|
||||||
else if (m_solver->get_status() != lean::lp_status::OPTIMAL) {
|
else if (m_solver->get_status() != lp::lp_status::OPTIMAL) {
|
||||||
is_sat = make_feasible();
|
is_sat = make_feasible();
|
||||||
}
|
}
|
||||||
switch (is_sat) {
|
switch (is_sat) {
|
||||||
|
@ -1266,7 +1266,7 @@ namespace smt {
|
||||||
propagate_bound(bv, is_true, b);
|
propagate_bound(bv, is_true, b);
|
||||||
#endif
|
#endif
|
||||||
if (!m_delay_constraints) {
|
if (!m_delay_constraints) {
|
||||||
lp::bound& b = *m_bool_var2bound.find(bv);
|
lra_lp::bound& b = *m_bool_var2bound.find(bv);
|
||||||
assert_bound(bv, is_true, b);
|
assert_bound(bv, is_true, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,7 +1279,7 @@ namespace smt {
|
||||||
/*for (; qhead < m_asserted_atoms.size() && !ctx().inconsistent(); ++qhead) {
|
/*for (; qhead < m_asserted_atoms.size() && !ctx().inconsistent(); ++qhead) {
|
||||||
bool_var bv = m_asserted_atoms[qhead].m_bv;
|
bool_var bv = m_asserted_atoms[qhead].m_bv;
|
||||||
bool is_true = m_asserted_atoms[qhead].m_is_true;
|
bool is_true = m_asserted_atoms[qhead].m_is_true;
|
||||||
lp::bound& b = *m_bool_var2bound.find(bv);
|
lra_lp::bound& b = *m_bool_var2bound.find(bv);
|
||||||
propagate_bound_compound(bv, is_true, b);
|
propagate_bound_compound(bv, is_true, b);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
@ -1314,7 +1314,7 @@ namespace smt {
|
||||||
int new_num_of_p = m_solver->settings().st().m_num_of_implied_bounds;
|
int new_num_of_p = m_solver->settings().st().m_num_of_implied_bounds;
|
||||||
(void)new_num_of_p;
|
(void)new_num_of_p;
|
||||||
CTRACE("arith", new_num_of_p > num_of_p, tout << "found " << new_num_of_p << " implied bounds\n";);
|
CTRACE("arith", new_num_of_p > num_of_p, tout << "found " << new_num_of_p << " implied bounds\n";);
|
||||||
if (m_solver->get_status() == lean::lp_status::INFEASIBLE) {
|
if (m_solver->get_status() == lp::lp_status::INFEASIBLE) {
|
||||||
set_conflict();
|
set_conflict();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1324,7 +1324,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bound_is_interesting(unsigned vi, lean::lconstraint_kind kind, const rational & bval) const {
|
bool bound_is_interesting(unsigned vi, lp::lconstraint_kind kind, const rational & bval) const {
|
||||||
theory_var v;
|
theory_var v;
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
v = m_term_index2theory_var.get(m_solver->adjust_term_index(vi), null_theory_var);
|
v = m_term_index2theory_var.get(m_solver->adjust_term_index(vi), null_theory_var);
|
||||||
|
@ -1341,7 +1341,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
lp_bounds const& bounds = m_bounds[v];
|
lp_bounds const& bounds = m_bounds[v];
|
||||||
for (unsigned i = 0; i < bounds.size(); ++i) {
|
for (unsigned i = 0; i < bounds.size(); ++i) {
|
||||||
lp::bound* b = bounds[i];
|
lra_lp::bound* b = bounds[i];
|
||||||
if (ctx().get_assignment(b->get_bv()) != l_undef) {
|
if (ctx().get_assignment(b->get_bv()) != l_undef) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1354,11 +1354,11 @@ namespace smt {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct local_bound_propagator: public lean::lp_bound_propagator {
|
struct local_bound_propagator: public lp::lp_bound_propagator {
|
||||||
imp & m_imp;
|
imp & m_imp;
|
||||||
local_bound_propagator(imp& i) : lp_bound_propagator(*i.m_solver), m_imp(i) {}
|
local_bound_propagator(imp& i) : lp_bound_propagator(*i.m_solver), m_imp(i) {}
|
||||||
|
|
||||||
bool bound_is_interesting(unsigned j, lean::lconstraint_kind kind, const rational & v) {
|
bool bound_is_interesting(unsigned j, lp::lconstraint_kind kind, const rational & v) {
|
||||||
return m_imp.bound_is_interesting(j, kind, v);
|
return m_imp.bound_is_interesting(j, kind, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,10 +1368,10 @@ namespace smt {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void propagate_lp_solver_bound(lean::implied_bound& be) {
|
void propagate_lp_solver_bound(lp::implied_bound& be) {
|
||||||
|
|
||||||
theory_var v;
|
theory_var v;
|
||||||
lean::var_index vi = be.m_j;
|
lp::var_index vi = be.m_j;
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
v = m_term_index2theory_var.get(m_solver->adjust_term_index(vi), null_theory_var);
|
v = m_term_index2theory_var.get(m_solver->adjust_term_index(vi), null_theory_var);
|
||||||
}
|
}
|
||||||
|
@ -1392,7 +1392,7 @@ namespace smt {
|
||||||
lp_bounds const& bounds = m_bounds[v];
|
lp_bounds const& bounds = m_bounds[v];
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (unsigned i = 0; i < bounds.size(); ++i) {
|
for (unsigned i = 0; i < bounds.size(); ++i) {
|
||||||
lp::bound* b = bounds[i];
|
lra_lp::bound* b = bounds[i];
|
||||||
if (ctx().get_assignment(b->get_bv()) != l_undef) {
|
if (ctx().get_assignment(b->get_bv()) != l_undef) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1455,28 +1455,28 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
literal is_bound_implied(lean::lconstraint_kind k, rational const& value, lp::bound const& b) const {
|
literal is_bound_implied(lp::lconstraint_kind k, rational const& value, lra_lp::bound const& b) const {
|
||||||
if ((k == lean::LE || k == lean::LT) && b.get_bound_kind() == lp::upper_t && value <= b.get_value()) {
|
if ((k == lp::LE || k == lp::LT) && b.get_bound_kind() == lra_lp::upper_t && value <= b.get_value()) {
|
||||||
// v <= value <= b.get_value() => v <= b.get_value()
|
// v <= value <= b.get_value() => v <= b.get_value()
|
||||||
return literal(b.get_bv(), false);
|
return literal(b.get_bv(), false);
|
||||||
}
|
}
|
||||||
if ((k == lean::GE || k == lean::GT) && b.get_bound_kind() == lp::lower_t && b.get_value() <= value) {
|
if ((k == lp::GE || k == lp::GT) && b.get_bound_kind() == lra_lp::lower_t && b.get_value() <= value) {
|
||||||
// b.get_value() <= value <= v => b.get_value() <= v
|
// b.get_value() <= value <= v => b.get_value() <= v
|
||||||
return literal(b.get_bv(), false);
|
return literal(b.get_bv(), false);
|
||||||
}
|
}
|
||||||
if (k == lean::LE && b.get_bound_kind() == lp::lower_t && value < b.get_value()) {
|
if (k == lp::LE && b.get_bound_kind() == lra_lp::lower_t && value < b.get_value()) {
|
||||||
// v <= value < b.get_value() => v < b.get_value()
|
// v <= value < b.get_value() => v < b.get_value()
|
||||||
return literal(b.get_bv(), true);
|
return literal(b.get_bv(), true);
|
||||||
}
|
}
|
||||||
if (k == lean::LT && b.get_bound_kind() == lp::lower_t && value <= b.get_value()) {
|
if (k == lp::LT && b.get_bound_kind() == lra_lp::lower_t && value <= b.get_value()) {
|
||||||
// v < value <= b.get_value() => v < b.get_value()
|
// v < value <= b.get_value() => v < b.get_value()
|
||||||
return literal(b.get_bv(), true);
|
return literal(b.get_bv(), true);
|
||||||
}
|
}
|
||||||
if (k == lean::GE && b.get_bound_kind() == lp::upper_t && b.get_value() < value) {
|
if (k == lp::GE && b.get_bound_kind() == lra_lp::upper_t && b.get_value() < value) {
|
||||||
// b.get_value() < value <= v => b.get_value() < v
|
// b.get_value() < value <= v => b.get_value() < v
|
||||||
return literal(b.get_bv(), true);
|
return literal(b.get_bv(), true);
|
||||||
}
|
}
|
||||||
if (k == lean::GT && b.get_bound_kind() == lp::upper_t && b.get_value() <= value) {
|
if (k == lp::GT && b.get_bound_kind() == lra_lp::upper_t && b.get_value() <= value) {
|
||||||
// b.get_value() <= value < v => b.get_value() < v
|
// b.get_value() <= value < v => b.get_value() < v
|
||||||
return literal(b.get_bv(), true);
|
return literal(b.get_bv(), true);
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1484,7 @@ namespace smt {
|
||||||
return null_literal;
|
return null_literal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mk_bound_axioms(lp::bound& b) {
|
void mk_bound_axioms(lra_lp::bound& b) {
|
||||||
if (!ctx().is_searching()) {
|
if (!ctx().is_searching()) {
|
||||||
//
|
//
|
||||||
// NB. We make an assumption that user push calls propagation
|
// NB. We make an assumption that user push calls propagation
|
||||||
|
@ -1495,19 +1495,19 @@ namespace smt {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
theory_var v = b.get_var();
|
theory_var v = b.get_var();
|
||||||
lp::bound_kind kind1 = b.get_bound_kind();
|
lra_lp::bound_kind kind1 = b.get_bound_kind();
|
||||||
rational const& k1 = b.get_value();
|
rational const& k1 = b.get_value();
|
||||||
lp_bounds & bounds = m_bounds[v];
|
lp_bounds & bounds = m_bounds[v];
|
||||||
|
|
||||||
lp::bound* end = 0;
|
lra_lp::bound* end = 0;
|
||||||
lp::bound* lo_inf = end, *lo_sup = end;
|
lra_lp::bound* lo_inf = end, *lo_sup = end;
|
||||||
lp::bound* hi_inf = end, *hi_sup = end;
|
lra_lp::bound* hi_inf = end, *hi_sup = end;
|
||||||
|
|
||||||
for (unsigned i = 0; i < bounds.size(); ++i) {
|
for (unsigned i = 0; i < bounds.size(); ++i) {
|
||||||
lp::bound& other = *bounds[i];
|
lra_lp::bound& other = *bounds[i];
|
||||||
if (&other == &b) continue;
|
if (&other == &b) continue;
|
||||||
if (b.get_bv() == other.get_bv()) continue;
|
if (b.get_bv() == other.get_bv()) continue;
|
||||||
lp::bound_kind kind2 = other.get_bound_kind();
|
lra_lp::bound_kind kind2 = other.get_bound_kind();
|
||||||
rational const& k2 = other.get_value();
|
rational const& k2 = other.get_value();
|
||||||
if (k1 == k2 && kind1 == kind2) {
|
if (k1 == k2 && kind1 == kind2) {
|
||||||
// the bounds are equivalent.
|
// the bounds are equivalent.
|
||||||
|
@ -1515,7 +1515,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
SASSERT(k1 != k2 || kind1 != kind2);
|
SASSERT(k1 != k2 || kind1 != kind2);
|
||||||
if (kind2 == lp::lower_t) {
|
if (kind2 == lra_lp::lower_t) {
|
||||||
if (k2 < k1) {
|
if (k2 < k1) {
|
||||||
if (lo_inf == end || k2 > lo_inf->get_value()) {
|
if (lo_inf == end || k2 > lo_inf->get_value()) {
|
||||||
lo_inf = &other;
|
lo_inf = &other;
|
||||||
|
@ -1541,14 +1541,14 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mk_bound_axiom(lp::bound& b1, lp::bound& b2) {
|
void mk_bound_axiom(lra_lp::bound& b1, lra_lp::bound& b2) {
|
||||||
theory_var v = b1.get_var();
|
theory_var v = b1.get_var();
|
||||||
literal l1(b1.get_bv());
|
literal l1(b1.get_bv());
|
||||||
literal l2(b2.get_bv());
|
literal l2(b2.get_bv());
|
||||||
rational const& k1 = b1.get_value();
|
rational const& k1 = b1.get_value();
|
||||||
rational const& k2 = b2.get_value();
|
rational const& k2 = b2.get_value();
|
||||||
lp::bound_kind kind1 = b1.get_bound_kind();
|
lra_lp::bound_kind kind1 = b1.get_bound_kind();
|
||||||
lp::bound_kind kind2 = b2.get_bound_kind();
|
lra_lp::bound_kind kind2 = b2.get_bound_kind();
|
||||||
bool v_is_int = is_int(v);
|
bool v_is_int = is_int(v);
|
||||||
SASSERT(v == b2.get_var());
|
SASSERT(v == b2.get_var());
|
||||||
if (k1 == k2 && kind1 == kind2) return;
|
if (k1 == k2 && kind1 == kind2) return;
|
||||||
|
@ -1556,8 +1556,8 @@ namespace smt {
|
||||||
parameter coeffs[3] = { parameter(symbol("farkas")),
|
parameter coeffs[3] = { parameter(symbol("farkas")),
|
||||||
parameter(rational(1)), parameter(rational(1)) };
|
parameter(rational(1)), parameter(rational(1)) };
|
||||||
|
|
||||||
if (kind1 == lp::lower_t) {
|
if (kind1 == lra_lp::lower_t) {
|
||||||
if (kind2 == lp::lower_t) {
|
if (kind2 == lra_lp::lower_t) {
|
||||||
if (k2 <= k1) {
|
if (k2 <= k1) {
|
||||||
mk_clause(~l1, l2, 3, coeffs);
|
mk_clause(~l1, l2, 3, coeffs);
|
||||||
}
|
}
|
||||||
|
@ -1578,7 +1578,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (kind2 == lp::lower_t) {
|
else if (kind2 == lra_lp::lower_t) {
|
||||||
if (k1 >= k2) {
|
if (k1 >= k2) {
|
||||||
// k1 >= lo_inf, k1 >= x or lo_inf <= x
|
// k1 >= lo_inf, k1 >= x or lo_inf <= x
|
||||||
mk_clause(l1, l2, 3, coeffs);
|
mk_clause(l1, l2, 3, coeffs);
|
||||||
|
@ -1636,21 +1636,21 @@ namespace smt {
|
||||||
iterator begin1 = occs.begin();
|
iterator begin1 = occs.begin();
|
||||||
iterator begin2 = occs.begin();
|
iterator begin2 = occs.begin();
|
||||||
iterator end = occs.end();
|
iterator end = occs.end();
|
||||||
begin1 = first(lp::lower_t, begin1, end);
|
begin1 = first(lra_lp::lower_t, begin1, end);
|
||||||
begin2 = first(lp::upper_t, begin2, end);
|
begin2 = first(lra_lp::upper_t, begin2, end);
|
||||||
|
|
||||||
iterator lo_inf = begin1, lo_sup = begin1;
|
iterator lo_inf = begin1, lo_sup = begin1;
|
||||||
iterator hi_inf = begin2, hi_sup = begin2;
|
iterator hi_inf = begin2, hi_sup = begin2;
|
||||||
iterator lo_inf1 = begin1, lo_sup1 = begin1;
|
iterator lo_inf1 = begin1, lo_sup1 = begin1;
|
||||||
iterator hi_inf1 = begin2, hi_sup1 = begin2;
|
iterator hi_inf1 = begin2, hi_sup1 = begin2;
|
||||||
bool flo_inf, fhi_inf, flo_sup, fhi_sup;
|
bool flo_inf, fhi_inf, flo_sup, fhi_sup;
|
||||||
ptr_addr_hashtable<lp::bound> visited;
|
ptr_addr_hashtable<lra_lp::bound> visited;
|
||||||
for (unsigned i = 0; i < atoms.size(); ++i) {
|
for (unsigned i = 0; i < atoms.size(); ++i) {
|
||||||
lp::bound* a1 = atoms[i];
|
lra_lp::bound* a1 = atoms[i];
|
||||||
lo_inf1 = next_inf(a1, lp::lower_t, lo_inf, end, flo_inf);
|
lo_inf1 = next_inf(a1, lra_lp::lower_t, lo_inf, end, flo_inf);
|
||||||
hi_inf1 = next_inf(a1, lp::upper_t, hi_inf, end, fhi_inf);
|
hi_inf1 = next_inf(a1, lra_lp::upper_t, hi_inf, end, fhi_inf);
|
||||||
lo_sup1 = next_sup(a1, lp::lower_t, lo_sup, end, flo_sup);
|
lo_sup1 = next_sup(a1, lra_lp::lower_t, lo_sup, end, flo_sup);
|
||||||
hi_sup1 = next_sup(a1, lp::upper_t, hi_sup, end, fhi_sup);
|
hi_sup1 = next_sup(a1, lra_lp::upper_t, hi_sup, end, fhi_sup);
|
||||||
if (lo_inf1 != end) lo_inf = lo_inf1;
|
if (lo_inf1 != end) lo_inf = lo_inf1;
|
||||||
if (lo_sup1 != end) lo_sup = lo_sup1;
|
if (lo_sup1 != end) lo_sup = lo_sup1;
|
||||||
if (hi_inf1 != end) hi_inf = hi_inf1;
|
if (hi_inf1 != end) hi_inf = hi_inf1;
|
||||||
|
@ -1669,24 +1669,24 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct compare_bounds {
|
struct compare_bounds {
|
||||||
bool operator()(lp::bound* a1, lp::bound* a2) const { return a1->get_value() < a2->get_value(); }
|
bool operator()(lra_lp::bound* a1, lra_lp::bound* a2) const { return a1->get_value() < a2->get_value(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
lp_bounds::iterator first(
|
lp_bounds::iterator first(
|
||||||
lp::bound_kind kind,
|
lra_lp::bound_kind kind,
|
||||||
iterator it,
|
iterator it,
|
||||||
iterator end) {
|
iterator end) {
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
lp::bound* a = *it;
|
lra_lp::bound* a = *it;
|
||||||
if (a->get_bound_kind() == kind) return it;
|
if (a->get_bound_kind() == kind) return it;
|
||||||
}
|
}
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
lp_bounds::iterator next_inf(
|
lp_bounds::iterator next_inf(
|
||||||
lp::bound* a1,
|
lra_lp::bound* a1,
|
||||||
lp::bound_kind kind,
|
lra_lp::bound_kind kind,
|
||||||
iterator it,
|
iterator it,
|
||||||
iterator end,
|
iterator end,
|
||||||
bool& found_compatible) {
|
bool& found_compatible) {
|
||||||
|
@ -1694,7 +1694,7 @@ namespace smt {
|
||||||
iterator result = end;
|
iterator result = end;
|
||||||
found_compatible = false;
|
found_compatible = false;
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
lp::bound * a2 = *it;
|
lra_lp::bound * a2 = *it;
|
||||||
if (a1 == a2) continue;
|
if (a1 == a2) continue;
|
||||||
if (a2->get_bound_kind() != kind) continue;
|
if (a2->get_bound_kind() != kind) continue;
|
||||||
rational const & k2(a2->get_value());
|
rational const & k2(a2->get_value());
|
||||||
|
@ -1710,15 +1710,15 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
lp_bounds::iterator next_sup(
|
lp_bounds::iterator next_sup(
|
||||||
lp::bound* a1,
|
lra_lp::bound* a1,
|
||||||
lp::bound_kind kind,
|
lra_lp::bound_kind kind,
|
||||||
iterator it,
|
iterator it,
|
||||||
iterator end,
|
iterator end,
|
||||||
bool& found_compatible) {
|
bool& found_compatible) {
|
||||||
rational const & k1(a1->get_value());
|
rational const & k1(a1->get_value());
|
||||||
found_compatible = false;
|
found_compatible = false;
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
lp::bound * a2 = *it;
|
lra_lp::bound * a2 = *it;
|
||||||
if (a1 == a2) continue;
|
if (a1 == a2) continue;
|
||||||
if (a2->get_bound_kind() != kind) continue;
|
if (a2->get_bound_kind() != kind) continue;
|
||||||
rational const & k2(a2->get_value());
|
rational const & k2(a2->get_value());
|
||||||
|
@ -1732,7 +1732,7 @@ namespace smt {
|
||||||
|
|
||||||
void propagate_basic_bounds() {
|
void propagate_basic_bounds() {
|
||||||
for (auto const& bv : m_to_check) {
|
for (auto const& bv : m_to_check) {
|
||||||
lp::bound& b = *m_bool_var2bound.find(bv);
|
lra_lp::bound& b = *m_bool_var2bound.find(bv);
|
||||||
propagate_bound(bv, ctx().get_assignment(bv) == l_true, b);
|
propagate_bound(bv, ctx().get_assignment(bv) == l_true, b);
|
||||||
if (ctx().inconsistent()) break;
|
if (ctx().inconsistent()) break;
|
||||||
|
|
||||||
|
@ -1747,11 +1747,11 @@ namespace smt {
|
||||||
// x <= hi -> x <= hi'
|
// x <= hi -> x <= hi'
|
||||||
// x <= hi -> ~(x >= hi')
|
// x <= hi -> ~(x >= hi')
|
||||||
|
|
||||||
void propagate_bound(bool_var bv, bool is_true, lp::bound& b) {
|
void propagate_bound(bool_var bv, bool is_true, lra_lp::bound& b) {
|
||||||
if (BP_NONE == propagation_mode()) {
|
if (BP_NONE == propagation_mode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lp::bound_kind k = b.get_bound_kind();
|
lra_lp::bound_kind k = b.get_bound_kind();
|
||||||
theory_var v = b.get_var();
|
theory_var v = b.get_var();
|
||||||
inf_rational val = b.get_value(is_true);
|
inf_rational val = b.get_value(is_true);
|
||||||
lp_bounds const& bounds = m_bounds[v];
|
lp_bounds const& bounds = m_bounds[v];
|
||||||
|
@ -1761,12 +1761,12 @@ namespace smt {
|
||||||
|
|
||||||
literal lit1(bv, !is_true);
|
literal lit1(bv, !is_true);
|
||||||
literal lit2 = null_literal;
|
literal lit2 = null_literal;
|
||||||
bool find_glb = (is_true == (k == lp::lower_t));
|
bool find_glb = (is_true == (k == lra_lp::lower_t));
|
||||||
if (find_glb) {
|
if (find_glb) {
|
||||||
rational glb;
|
rational glb;
|
||||||
lp::bound* lb = 0;
|
lra_lp::bound* lb = 0;
|
||||||
for (unsigned i = 0; i < bounds.size(); ++i) {
|
for (unsigned i = 0; i < bounds.size(); ++i) {
|
||||||
lp::bound* b2 = bounds[i];
|
lra_lp::bound* b2 = bounds[i];
|
||||||
if (b2 == &b) continue;
|
if (b2 == &b) continue;
|
||||||
rational const& val2 = b2->get_value();
|
rational const& val2 = b2->get_value();
|
||||||
if ((is_true ? val2 < val : val2 <= val) && (!lb || glb < val2)) {
|
if ((is_true ? val2 < val : val2 <= val) && (!lb || glb < val2)) {
|
||||||
|
@ -1775,14 +1775,14 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!lb) return;
|
if (!lb) return;
|
||||||
bool sign = lb->get_bound_kind() != lp::lower_t;
|
bool sign = lb->get_bound_kind() != lra_lp::lower_t;
|
||||||
lit2 = literal(lb->get_bv(), sign);
|
lit2 = literal(lb->get_bv(), sign);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rational lub;
|
rational lub;
|
||||||
lp::bound* ub = 0;
|
lra_lp::bound* ub = 0;
|
||||||
for (unsigned i = 0; i < bounds.size(); ++i) {
|
for (unsigned i = 0; i < bounds.size(); ++i) {
|
||||||
lp::bound* b2 = bounds[i];
|
lra_lp::bound* b2 = bounds[i];
|
||||||
if (b2 == &b) continue;
|
if (b2 == &b) continue;
|
||||||
rational const& val2 = b2->get_value();
|
rational const& val2 = b2->get_value();
|
||||||
if ((is_true ? val < val2 : val <= val2) && (!ub || val2 < lub)) {
|
if ((is_true ? val < val2 : val <= val2) && (!ub || val2 < lub)) {
|
||||||
|
@ -1791,7 +1791,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ub) return;
|
if (!ub) return;
|
||||||
bool sign = ub->get_bound_kind() != lp::upper_t;
|
bool sign = ub->get_bound_kind() != lra_lp::upper_t;
|
||||||
lit2 = literal(ub->get_bv(), sign);
|
lit2 = literal(ub->get_bv(), sign);
|
||||||
}
|
}
|
||||||
TRACE("arith",
|
TRACE("arith",
|
||||||
|
@ -1811,27 +1811,27 @@ namespace smt {
|
||||||
++m_stats.m_bounds_propagations;
|
++m_stats.m_bounds_propagations;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_use_lists(lp::bound* b) {
|
void add_use_lists(lra_lp::bound* b) {
|
||||||
theory_var v = b->get_var();
|
theory_var v = b->get_var();
|
||||||
lean::var_index vi = get_var_index(v);
|
lp::var_index vi = get_var_index(v);
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
lean::lar_term const& term = m_solver->get_term(vi);
|
lp::lar_term const& term = m_solver->get_term(vi);
|
||||||
for (auto i = term.m_coeffs.begin(); i != term.m_coeffs.end(); ++i) {
|
for (auto i = term.m_coeffs.begin(); i != term.m_coeffs.end(); ++i) {
|
||||||
lean::var_index wi = i->first;
|
lp::var_index wi = i->first;
|
||||||
unsigned w = m_var_index2theory_var[wi];
|
unsigned w = m_var_index2theory_var[wi];
|
||||||
m_use_list.reserve(w + 1, ptr_vector<lp::bound>());
|
m_use_list.reserve(w + 1, ptr_vector<lra_lp::bound>());
|
||||||
m_use_list[w].push_back(b);
|
m_use_list[w].push_back(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void del_use_lists(lp::bound* b) {
|
void del_use_lists(lra_lp::bound* b) {
|
||||||
theory_var v = b->get_var();
|
theory_var v = b->get_var();
|
||||||
lean::var_index vi = m_theory_var2var_index[v];
|
lp::var_index vi = m_theory_var2var_index[v];
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
lean::lar_term const& term = m_solver->get_term(vi);
|
lp::lar_term const& term = m_solver->get_term(vi);
|
||||||
for (auto i = term.m_coeffs.begin(); i != term.m_coeffs.end(); ++i) {
|
for (auto i = term.m_coeffs.begin(); i != term.m_coeffs.end(); ++i) {
|
||||||
lean::var_index wi = i->first;
|
lp::var_index wi = i->first;
|
||||||
unsigned w = m_var_index2theory_var[wi];
|
unsigned w = m_var_index2theory_var[wi];
|
||||||
SASSERT(m_use_list[w].back() == b);
|
SASSERT(m_use_list[w].back() == b);
|
||||||
m_use_list[w].pop_back();
|
m_use_list[w].pop_back();
|
||||||
|
@ -1845,7 +1845,7 @@ namespace smt {
|
||||||
// have been assigned we may know the truth value of the inequality by using simple
|
// have been assigned we may know the truth value of the inequality by using simple
|
||||||
// bounds propagation.
|
// bounds propagation.
|
||||||
//
|
//
|
||||||
void propagate_bound_compound(bool_var bv, bool is_true, lp::bound& b) {
|
void propagate_bound_compound(bool_var bv, bool is_true, lra_lp::bound& b) {
|
||||||
theory_var v = b.get_var();
|
theory_var v = b.get_var();
|
||||||
TRACE("arith", tout << mk_pp(get_owner(v), m) << "\n";);
|
TRACE("arith", tout << mk_pp(get_owner(v), m) << "\n";);
|
||||||
if (static_cast<unsigned>(v) >= m_use_list.size()) {
|
if (static_cast<unsigned>(v) >= m_use_list.size()) {
|
||||||
|
@ -1861,7 +1861,7 @@ namespace smt {
|
||||||
// x >= 0, y >= 1 -> x + y >= 1
|
// x >= 0, y >= 1 -> x + y >= 1
|
||||||
// x <= 0, y <= 2 -> x + y <= 2
|
// x <= 0, y <= 2 -> x + y <= 2
|
||||||
literal lit = null_literal;
|
literal lit = null_literal;
|
||||||
if (lp::lower_t == vb->get_bound_kind()) {
|
if (lra_lp::lower_t == vb->get_bound_kind()) {
|
||||||
if (get_glb(*vb, r) && r >= vb->get_value()) { // vb is assigned true
|
if (get_glb(*vb, r) && r >= vb->get_value()) { // vb is assigned true
|
||||||
lit = literal(vb->get_bv(), false);
|
lit = literal(vb->get_bv(), false);
|
||||||
}
|
}
|
||||||
|
@ -1895,30 +1895,30 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_lub(lp::bound const& b, inf_rational& lub) {
|
bool get_lub(lra_lp::bound const& b, inf_rational& lub) {
|
||||||
return get_bound(b, lub, true);
|
return get_bound(b, lub, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_glb(lp::bound const& b, inf_rational& glb) {
|
bool get_glb(lra_lp::bound const& b, inf_rational& glb) {
|
||||||
return get_bound(b, glb, false);
|
return get_bound(b, glb, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& display_bound(std::ostream& out, lp::bound const& b) {
|
std::ostream& display_bound(std::ostream& out, lra_lp::bound const& b) {
|
||||||
return out << mk_pp(ctx().bool_var2expr(b.get_bv()), m);
|
return out << mk_pp(ctx().bool_var2expr(b.get_bv()), m);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_bound(lp::bound const& b, inf_rational& r, bool is_lub) {
|
bool get_bound(lra_lp::bound const& b, inf_rational& r, bool is_lub) {
|
||||||
m_core.reset();
|
m_core.reset();
|
||||||
m_eqs.reset();
|
m_eqs.reset();
|
||||||
m_params.reset();
|
m_params.reset();
|
||||||
r.reset();
|
r.reset();
|
||||||
theory_var v = b.get_var();
|
theory_var v = b.get_var();
|
||||||
lean::var_index vi = m_theory_var2var_index[v];
|
lp::var_index vi = m_theory_var2var_index[v];
|
||||||
SASSERT(m_solver->is_term(vi));
|
SASSERT(m_solver->is_term(vi));
|
||||||
lean::lar_term const& term = m_solver->get_term(vi);
|
lp::lar_term const& term = m_solver->get_term(vi);
|
||||||
for (auto const coeff : term.m_coeffs) {
|
for (auto const coeff : term.m_coeffs) {
|
||||||
lean::var_index wi = coeff.first;
|
lp::var_index wi = coeff.first;
|
||||||
lean::constraint_index ci;
|
lp::constraint_index ci;
|
||||||
rational value;
|
rational value;
|
||||||
bool is_strict;
|
bool is_strict;
|
||||||
if (coeff.second.is_neg() == is_lub) {
|
if (coeff.second.is_neg() == is_lub) {
|
||||||
|
@ -1945,24 +1945,24 @@ namespace smt {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assert_bound(bool_var bv, bool is_true, lp::bound& b) {
|
void assert_bound(bool_var bv, bool is_true, lra_lp::bound& b) {
|
||||||
if (m_solver->get_status() == lean::lp_status::INFEASIBLE) {
|
if (m_solver->get_status() == lp::lp_status::INFEASIBLE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scoped_internalize_state st(*this);
|
scoped_internalize_state st(*this);
|
||||||
st.vars().push_back(b.get_var());
|
st.vars().push_back(b.get_var());
|
||||||
st.coeffs().push_back(rational::one());
|
st.coeffs().push_back(rational::one());
|
||||||
init_left_side(st);
|
init_left_side(st);
|
||||||
lean::lconstraint_kind k = lean::EQ;
|
lp::lconstraint_kind k = lp::EQ;
|
||||||
switch (b.get_bound_kind()) {
|
switch (b.get_bound_kind()) {
|
||||||
case lp::lower_t:
|
case lra_lp::lower_t:
|
||||||
k = is_true ? lean::GE : lean::LT;
|
k = is_true ? lp::GE : lp::LT;
|
||||||
break;
|
break;
|
||||||
case lp::upper_t:
|
case lra_lp::upper_t:
|
||||||
k = is_true ? lean::LE : lean::GT;
|
k = is_true ? lp::LE : lp::GT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (k == lean::LT || k == lean::LE) {
|
if (k == lp::LT || k == lp::LE) {
|
||||||
++m_stats.m_assert_lower;
|
++m_stats.m_assert_lower;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1983,7 +1983,7 @@ namespace smt {
|
||||||
// Then the equality v1 == v2 is propagated to the core.
|
// Then the equality v1 == v2 is propagated to the core.
|
||||||
//
|
//
|
||||||
|
|
||||||
typedef std::pair<lean::constraint_index, rational> constraint_bound;
|
typedef std::pair<lp::constraint_index, rational> constraint_bound;
|
||||||
vector<constraint_bound> m_lower_terms;
|
vector<constraint_bound> m_lower_terms;
|
||||||
vector<constraint_bound> m_upper_terms;
|
vector<constraint_bound> m_upper_terms;
|
||||||
typedef std::pair<rational, bool> value_sort_pair;
|
typedef std::pair<rational, bool> value_sort_pair;
|
||||||
|
@ -1991,16 +1991,16 @@ namespace smt {
|
||||||
typedef map<value_sort_pair, theory_var, value_sort_pair_hash, default_eq<value_sort_pair> > value2var;
|
typedef map<value_sort_pair, theory_var, value_sort_pair_hash, default_eq<value_sort_pair> > value2var;
|
||||||
value2var m_fixed_var_table;
|
value2var m_fixed_var_table;
|
||||||
|
|
||||||
void propagate_eqs(lean::var_index vi, lean::constraint_index ci, lean::lconstraint_kind k, lp::bound& b) {
|
void propagate_eqs(lp::var_index vi, lp::constraint_index ci, lp::lconstraint_kind k, lra_lp::bound& b) {
|
||||||
if (propagate_eqs()) {
|
if (propagate_eqs()) {
|
||||||
rational const& value = b.get_value();
|
rational const& value = b.get_value();
|
||||||
if (k == lean::GE) {
|
if (k == lp::GE) {
|
||||||
set_lower_bound(vi, ci, value);
|
set_lower_bound(vi, ci, value);
|
||||||
if (has_upper_bound(vi, ci, value)) {
|
if (has_upper_bound(vi, ci, value)) {
|
||||||
fixed_var_eh(b.get_var(), value);
|
fixed_var_eh(b.get_var(), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (k == lean::LE) {
|
else if (k == lp::LE) {
|
||||||
set_upper_bound(vi, ci, value);
|
set_upper_bound(vi, ci, value);
|
||||||
if (has_lower_bound(vi, ci, value)) {
|
if (has_lower_bound(vi, ci, value)) {
|
||||||
fixed_var_eh(b.get_var(), value);
|
fixed_var_eh(b.get_var(), value);
|
||||||
|
@ -2021,16 +2021,16 @@ namespace smt {
|
||||||
|
|
||||||
bool use_tableau() const { return lp_params(ctx().get_params()).simplex_strategy() < 2; }
|
bool use_tableau() const { return lp_params(ctx().get_params()).simplex_strategy() < 2; }
|
||||||
|
|
||||||
void set_upper_bound(lean::var_index vi, lean::constraint_index ci, rational const& v) { set_bound(vi, ci, v, false); }
|
void set_upper_bound(lp::var_index vi, lp::constraint_index ci, rational const& v) { set_bound(vi, ci, v, false); }
|
||||||
|
|
||||||
void set_lower_bound(lean::var_index vi, lean::constraint_index ci, rational const& v) { set_bound(vi, ci, v, true); }
|
void set_lower_bound(lp::var_index vi, lp::constraint_index ci, rational const& v) { set_bound(vi, ci, v, true); }
|
||||||
|
|
||||||
void set_bound(lean::var_index vi, lean::constraint_index ci, rational const& v, bool is_lower) {
|
void set_bound(lp::var_index vi, lp::constraint_index ci, rational const& v, bool is_lower) {
|
||||||
if (!m_solver->is_term(vi)) {
|
if (!m_solver->is_term(vi)) {
|
||||||
// m_solver already tracks bounds on proper variables, but not on terms.
|
// m_solver already tracks bounds on proper variables, but not on terms.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lean::var_index ti = m_solver->adjust_term_index(vi);
|
lp::var_index ti = m_solver->adjust_term_index(vi);
|
||||||
auto& vec = is_lower ? m_lower_terms : m_upper_terms;
|
auto& vec = is_lower ? m_lower_terms : m_upper_terms;
|
||||||
if (vec.size() <= ti) {
|
if (vec.size() <= ti) {
|
||||||
vec.resize(ti + 1, constraint_bound(UINT_MAX, rational()));
|
vec.resize(ti + 1, constraint_bound(UINT_MAX, rational()));
|
||||||
|
@ -2043,15 +2043,15 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_upper_bound(lean::var_index vi, lean::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, false); }
|
bool has_upper_bound(lp::var_index vi, lp::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, false); }
|
||||||
|
|
||||||
bool has_lower_bound(lean::var_index vi, lean::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, true); }
|
bool has_lower_bound(lp::var_index vi, lp::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, true); }
|
||||||
|
|
||||||
bool has_bound(lean::var_index vi, lean::constraint_index& ci, rational const& bound, bool is_lower) {
|
bool has_bound(lp::var_index vi, lp::constraint_index& ci, rational const& bound, bool is_lower) {
|
||||||
|
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
|
|
||||||
lean::var_index ti = m_solver->adjust_term_index(vi);
|
lp::var_index ti = m_solver->adjust_term_index(vi);
|
||||||
theory_var v = m_term_index2theory_var.get(ti, null_theory_var);
|
theory_var v = m_term_index2theory_var.get(ti, null_theory_var);
|
||||||
rational val;
|
rational val;
|
||||||
TRACE("arith", tout << vi << " " << v << "\n";);
|
TRACE("arith", tout << vi << " " << v << "\n";);
|
||||||
|
@ -2094,7 +2094,7 @@ namespace smt {
|
||||||
if (static_cast<unsigned>(v2) < th.get_num_vars() && !is_equal(v1, v2)) {
|
if (static_cast<unsigned>(v2) < th.get_num_vars() && !is_equal(v1, v2)) {
|
||||||
auto vi1 = get_var_index(v1);
|
auto vi1 = get_var_index(v1);
|
||||||
auto vi2 = get_var_index(v2);
|
auto vi2 = get_var_index(v2);
|
||||||
lean::constraint_index ci1, ci2, ci3, ci4;
|
lp::constraint_index ci1, ci2, ci3, ci4;
|
||||||
TRACE("arith", tout << "fixed: " << mk_pp(get_owner(v1), m) << " " << mk_pp(get_owner(v2), m) << " " << bound << " " << has_lower_bound(vi2, ci3, bound) << "\n";);
|
TRACE("arith", tout << "fixed: " << mk_pp(get_owner(v1), m) << " " << mk_pp(get_owner(v2), m) << " " << bound << " " << has_lower_bound(vi2, ci3, bound) << "\n";);
|
||||||
if (has_lower_bound(vi2, ci3, bound) && has_upper_bound(vi2, ci4, bound)) {
|
if (has_lower_bound(vi2, ci3, bound) && has_upper_bound(vi2, ci4, bound)) {
|
||||||
VERIFY (has_lower_bound(vi1, ci1, bound));
|
VERIFY (has_lower_bound(vi1, ci1, bound));
|
||||||
|
@ -2148,19 +2148,19 @@ namespace smt {
|
||||||
if (m_solver->A_r().row_count() > m_stats.m_max_rows)
|
if (m_solver->A_r().row_count() > m_stats.m_max_rows)
|
||||||
m_stats.m_max_rows = m_solver->A_r().row_count();
|
m_stats.m_max_rows = m_solver->A_r().row_count();
|
||||||
TRACE("arith_verbose", display(tout););
|
TRACE("arith_verbose", display(tout););
|
||||||
lean::lp_status status = m_solver->find_feasible_solution();
|
lp::lp_status status = m_solver->find_feasible_solution();
|
||||||
m_stats.m_num_iterations = m_solver->settings().st().m_total_iterations;
|
m_stats.m_num_iterations = m_solver->settings().st().m_total_iterations;
|
||||||
m_stats.m_num_factorizations = m_solver->settings().st().m_num_factorizations;
|
m_stats.m_num_factorizations = m_solver->settings().st().m_num_factorizations;
|
||||||
m_stats.m_need_to_solve_inf = m_solver->settings().st().m_need_to_solve_inf;
|
m_stats.m_need_to_solve_inf = m_solver->settings().st().m_need_to_solve_inf;
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case lean::lp_status::INFEASIBLE:
|
case lp::lp_status::INFEASIBLE:
|
||||||
return l_false;
|
return l_false;
|
||||||
case lean::lp_status::FEASIBLE:
|
case lp::lp_status::FEASIBLE:
|
||||||
case lean::lp_status::OPTIMAL:
|
case lp::lp_status::OPTIMAL:
|
||||||
// SASSERT(m_solver->all_constraints_hold());
|
// SASSERT(m_solver->all_constraints_hold());
|
||||||
return l_true;
|
return l_true;
|
||||||
case lean::lp_status::TIME_EXHAUSTED:
|
case lp::lp_status::TIME_EXHAUSTED:
|
||||||
|
|
||||||
default:
|
default:
|
||||||
TRACE("arith", tout << "status treated as inconclusive: " << status << "\n";);
|
TRACE("arith", tout << "status treated as inconclusive: " << status << "\n";);
|
||||||
|
@ -2170,14 +2170,14 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<std::pair<rational, lean::constraint_index>> m_explanation;
|
vector<std::pair<rational, lp::constraint_index>> m_explanation;
|
||||||
literal_vector m_core;
|
literal_vector m_core;
|
||||||
svector<enode_pair> m_eqs;
|
svector<enode_pair> m_eqs;
|
||||||
vector<parameter> m_params;
|
vector<parameter> m_params;
|
||||||
|
|
||||||
// lean::constraint_index const null_constraint_index = UINT_MAX; // not sure what a correct fix is
|
// lp::constraint_index const null_constraint_index = UINT_MAX; // not sure what a correct fix is
|
||||||
|
|
||||||
void set_evidence(lean::constraint_index idx) {
|
void set_evidence(lp::constraint_index idx) {
|
||||||
if (idx == UINT_MAX) {
|
if (idx == UINT_MAX) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2327,16 +2327,16 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
theory_lra::inf_eps value(theory_var v) {
|
theory_lra::inf_eps value(theory_var v) {
|
||||||
lean::impq ival = get_ivalue(v);
|
lp::impq ival = get_ivalue(v);
|
||||||
return inf_eps(0, inf_rational(ival.x, ival.y));
|
return inf_eps(0, inf_rational(ival.x, ival.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
theory_lra::inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared) {
|
theory_lra::inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared) {
|
||||||
lean::var_index vi = m_theory_var2var_index.get(v, UINT_MAX);
|
lp::var_index vi = m_theory_var2var_index.get(v, UINT_MAX);
|
||||||
vector<std::pair<rational, lean::var_index> > coeffs;
|
vector<std::pair<rational, lp::var_index> > coeffs;
|
||||||
rational coeff;
|
rational coeff;
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
const lean::lar_term& term = m_solver->get_term(vi);
|
const lp::lar_term& term = m_solver->get_term(vi);
|
||||||
for (auto & ti : term.m_coeffs) {
|
for (auto & ti : term.m_coeffs) {
|
||||||
coeffs.push_back(std::make_pair(ti.second, ti.first));
|
coeffs.push_back(std::make_pair(ti.second, ti.first));
|
||||||
}
|
}
|
||||||
|
@ -2346,7 +2346,7 @@ namespace smt {
|
||||||
coeffs.push_back(std::make_pair(rational::one(), vi));
|
coeffs.push_back(std::make_pair(rational::one(), vi));
|
||||||
coeff = rational::zero();
|
coeff = rational::zero();
|
||||||
}
|
}
|
||||||
lean::impq term_max;
|
lp::impq term_max;
|
||||||
if (m_solver->maximize_term(coeffs, term_max)) {
|
if (m_solver->maximize_term(coeffs, term_max)) {
|
||||||
blocker = mk_gt(v);
|
blocker = mk_gt(v);
|
||||||
inf_rational val(term_max.x + coeff, term_max.y);
|
inf_rational val(term_max.x + coeff, term_max.y);
|
||||||
|
@ -2361,7 +2361,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_ref mk_gt(theory_var v) {
|
expr_ref mk_gt(theory_var v) {
|
||||||
lean::impq val = get_ivalue(v);
|
lp::impq val = get_ivalue(v);
|
||||||
expr* obj = get_enode(v)->get_owner();
|
expr* obj = get_enode(v)->get_owner();
|
||||||
rational r = val.x;
|
rational r = val.x;
|
||||||
expr_ref e(m);
|
expr_ref e(m);
|
||||||
|
@ -2393,11 +2393,11 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
app_ref mk_obj(theory_var v) {
|
app_ref mk_obj(theory_var v) {
|
||||||
lean::var_index vi = m_theory_var2var_index[v];
|
lp::var_index vi = m_theory_var2var_index[v];
|
||||||
bool is_int = a.is_int(get_enode(v)->get_owner());
|
bool is_int = a.is_int(get_enode(v)->get_owner());
|
||||||
if (m_solver->is_term(vi)) {
|
if (m_solver->is_term(vi)) {
|
||||||
expr_ref_vector args(m);
|
expr_ref_vector args(m);
|
||||||
const lean::lar_term& term = m_solver->get_term(vi);
|
const lp::lar_term& term = m_solver->get_term(vi);
|
||||||
for (auto & ti : term.m_coeffs) {
|
for (auto & ti : term.m_coeffs) {
|
||||||
theory_var w = m_var_index2theory_var[ti.first];
|
theory_var w = m_var_index2theory_var[ti.first];
|
||||||
expr* o = get_enode(w)->get_owner();
|
expr* o = get_enode(w)->get_owner();
|
||||||
|
@ -2428,9 +2428,9 @@ namespace smt {
|
||||||
bool_var bv = ctx().mk_bool_var(b);
|
bool_var bv = ctx().mk_bool_var(b);
|
||||||
ctx().set_var_theory(bv, get_id());
|
ctx().set_var_theory(bv, get_id());
|
||||||
// ctx().set_enode_flag(bv, true);
|
// ctx().set_enode_flag(bv, true);
|
||||||
lp::bound_kind bkind = lp::bound_kind::lower_t;
|
lra_lp::bound_kind bkind = lra_lp::bound_kind::lower_t;
|
||||||
if (is_strict) bkind = lp::bound_kind::upper_t;
|
if (is_strict) bkind = lra_lp::bound_kind::upper_t;
|
||||||
lp::bound* a = alloc(lp::bound, bv, v, r, bkind);
|
lra_lp::bound* a = alloc(lra_lp::bound, bv, v, r, bkind);
|
||||||
mk_bound_axioms(*a);
|
mk_bound_axioms(*a);
|
||||||
updt_unassigned_bounds(v, +1);
|
updt_unassigned_bounds(v, +1);
|
||||||
m_bounds[v].push_back(a);
|
m_bounds[v].push_back(a);
|
||||||
|
@ -2462,7 +2462,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_evidence(std::ostream& out, vector<std::pair<rational, lean::constraint_index>> const& evidence) {
|
void display_evidence(std::ostream& out, vector<std::pair<rational, lp::constraint_index>> const& evidence) {
|
||||||
for (auto const& ev : evidence) {
|
for (auto const& ev : evidence) {
|
||||||
expr_ref e(m);
|
expr_ref e(m);
|
||||||
SASSERT(!ev.first.is_zero());
|
SASSERT(!ev.first.is_zero());
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace smt {
|
||||||
typedef trail_stack<theory_seq> th_trail_stack;
|
typedef trail_stack<theory_seq> th_trail_stack;
|
||||||
typedef std::pair<expr*, dependency*> expr_dep;
|
typedef std::pair<expr*, dependency*> expr_dep;
|
||||||
typedef obj_map<expr, expr_dep> eqdep_map_t;
|
typedef obj_map<expr, expr_dep> eqdep_map_t;
|
||||||
typedef union_find<theory_seq> th_union_find;
|
typedef union_find<theory_seq> th_union_find;
|
||||||
|
|
||||||
class seq_value_proc;
|
class seq_value_proc;
|
||||||
|
|
||||||
|
@ -298,8 +298,8 @@ namespace smt {
|
||||||
scoped_vector<eq> m_eqs; // set of current equations.
|
scoped_vector<eq> m_eqs; // set of current equations.
|
||||||
scoped_vector<ne> m_nqs; // set of current disequalities.
|
scoped_vector<ne> m_nqs; // set of current disequalities.
|
||||||
scoped_vector<nc> m_ncs; // set of non-contains constraints.
|
scoped_vector<nc> m_ncs; // set of non-contains constraints.
|
||||||
unsigned m_eq_id;
|
unsigned m_eq_id;
|
||||||
th_union_find m_find;
|
th_union_find m_find;
|
||||||
|
|
||||||
seq_factory* m_factory; // value factory
|
seq_factory* m_factory; // value factory
|
||||||
exclusion_table m_exclude; // set of asserted disequalities.
|
exclusion_table m_exclude; // set of asserted disequalities.
|
||||||
|
@ -584,7 +584,7 @@ namespace smt {
|
||||||
// model building
|
// model building
|
||||||
app* mk_value(app* a);
|
app* mk_value(app* a);
|
||||||
|
|
||||||
th_trail_stack& get_trail_stack() { return m_trail_stack; }
|
th_trail_stack& get_trail_stack() { return m_trail_stack; }
|
||||||
void merge_eh(theory_var, theory_var, theory_var v1, theory_var v2) {}
|
void merge_eh(theory_var, theory_var, theory_var v1, theory_var v2) {}
|
||||||
void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) { }
|
void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) { }
|
||||||
void unmerge_eh(theory_var v1, theory_var v2) {}
|
void unmerge_eh(theory_var v1, theory_var v2) {}
|
||||||
|
|
|
@ -4748,11 +4748,11 @@ namespace smt {
|
||||||
context& ctx = get_context();
|
context& ctx = get_context();
|
||||||
ast_manager & m = get_manager();
|
ast_manager & m = get_manager();
|
||||||
|
|
||||||
// safety
|
// safety
|
||||||
if (!ctx.e_internalized(e)) {
|
if (!ctx.e_internalized(e)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if an integer constant exists in the eqc, it should be the root
|
// if an integer constant exists in the eqc, it should be the root
|
||||||
enode * en_e = ctx.get_enode(e);
|
enode * en_e = ctx.get_enode(e);
|
||||||
enode * root_e = en_e->get_root();
|
enode * root_e = en_e->get_root();
|
||||||
|
@ -7028,7 +7028,7 @@ namespace smt {
|
||||||
ast_manager & m = get_manager();
|
ast_manager & m = get_manager();
|
||||||
if (lenTester_fvar_map.contains(lenTester)) {
|
if (lenTester_fvar_map.contains(lenTester)) {
|
||||||
expr * fVar = lenTester_fvar_map[lenTester];
|
expr * fVar = lenTester_fvar_map[lenTester];
|
||||||
expr_ref toAssert(gen_len_val_options_for_free_var(fVar, lenTester, lenTesterValue), m);
|
expr_ref toAssert(gen_len_val_options_for_free_var(fVar, lenTester, lenTesterValue), m);
|
||||||
TRACE("str", tout << "asserting more length tests for free variable " << mk_ismt2_pp(fVar, m) << std::endl;);
|
TRACE("str", tout << "asserting more length tests for free variable " << mk_ismt2_pp(fVar, m) << std::endl;);
|
||||||
if (toAssert) {
|
if (toAssert) {
|
||||||
assert_axiom(toAssert);
|
assert_axiom(toAssert);
|
||||||
|
|
|
@ -36,10 +36,10 @@ namespace smt {
|
||||||
|
|
||||||
void watch_list::expand() {
|
void watch_list::expand() {
|
||||||
if (m_data == 0) {
|
if (m_data == 0) {
|
||||||
unsigned size = DEFAULT_WATCH_LIST_SIZE + HEADER_SIZE;
|
unsigned size = DEFAULT_WATCH_LIST_SIZE + HEADER_SIZE;
|
||||||
unsigned * mem = reinterpret_cast<unsigned*>(alloc_svect(char, size));
|
unsigned * mem = reinterpret_cast<unsigned*>(alloc_svect(char, size));
|
||||||
#ifdef _AMD64_
|
#ifdef _AMD64_
|
||||||
++mem; // make sure data is aligned in 64 bit machines
|
++mem; // make sure data is aligned in 64 bit machines
|
||||||
#endif
|
#endif
|
||||||
*mem = 0;
|
*mem = 0;
|
||||||
++mem;
|
++mem;
|
||||||
|
@ -62,9 +62,9 @@ namespace smt {
|
||||||
unsigned * mem = reinterpret_cast<unsigned*>(alloc_svect(char, new_capacity + HEADER_SIZE));
|
unsigned * mem = reinterpret_cast<unsigned*>(alloc_svect(char, new_capacity + HEADER_SIZE));
|
||||||
unsigned curr_end_cls = end_cls_core();
|
unsigned curr_end_cls = end_cls_core();
|
||||||
#ifdef _AMD64_
|
#ifdef _AMD64_
|
||||||
++mem; // make sure data is aligned in 64 bit machines
|
++mem; // make sure data is aligned in 64 bit machines
|
||||||
#endif
|
#endif
|
||||||
*mem = curr_end_cls;
|
*mem = curr_end_cls;
|
||||||
++mem;
|
++mem;
|
||||||
SASSERT(bin_bytes <= new_capacity);
|
SASSERT(bin_bytes <= new_capacity);
|
||||||
unsigned new_begin_bin = new_capacity - bin_bytes;
|
unsigned new_begin_bin = new_capacity - bin_bytes;
|
||||||
|
|
|
@ -2,25 +2,25 @@ def_module_params('sls',
|
||||||
export=True,
|
export=True,
|
||||||
description='Experimental Stochastic Local Search Solver (for QFBV only).',
|
description='Experimental Stochastic Local Search Solver (for QFBV only).',
|
||||||
params=(max_memory_param(),
|
params=(max_memory_param(),
|
||||||
('max_restarts', UINT, UINT_MAX, 'maximum number of restarts'),
|
('max_restarts', UINT, UINT_MAX, 'maximum number of restarts'),
|
||||||
('walksat', BOOL, 1, 'use walksat assertion selection (instead of gsat)'),
|
('walksat', BOOL, 1, 'use walksat assertion selection (instead of gsat)'),
|
||||||
('walksat_ucb', BOOL, 1, 'use bandit heuristic for walksat assertion selection (instead of random)'),
|
('walksat_ucb', BOOL, 1, 'use bandit heuristic for walksat assertion selection (instead of random)'),
|
||||||
('walksat_ucb_constant', DOUBLE, 20.0, 'the ucb constant c in the term score + c * f(touched)'),
|
('walksat_ucb_constant', DOUBLE, 20.0, 'the ucb constant c in the term score + c * f(touched)'),
|
||||||
('walksat_ucb_init', BOOL, 0, 'initialize total ucb touched to formula size'),
|
('walksat_ucb_init', BOOL, 0, 'initialize total ucb touched to formula size'),
|
||||||
('walksat_ucb_forget', DOUBLE, 1.0, 'scale touched by this factor every base restart interval'),
|
('walksat_ucb_forget', DOUBLE, 1.0, 'scale touched by this factor every base restart interval'),
|
||||||
('walksat_ucb_noise', DOUBLE, 0.0002, 'add noise 0 <= 256 * ucb_noise to ucb score for assertion selection'),
|
('walksat_ucb_noise', DOUBLE, 0.0002, 'add noise 0 <= 256 * ucb_noise to ucb score for assertion selection'),
|
||||||
('walksat_repick', BOOL, 1, 'repick assertion if randomizing in local minima'),
|
('walksat_repick', BOOL, 1, 'repick assertion if randomizing in local minima'),
|
||||||
('scale_unsat', DOUBLE, 0.5, 'scale score of unsat expressions by this factor'),
|
('scale_unsat', DOUBLE, 0.5, 'scale score of unsat expressions by this factor'),
|
||||||
('paws_init', UINT, 40, 'initial/minimum assertion weights'),
|
('paws_init', UINT, 40, 'initial/minimum assertion weights'),
|
||||||
('paws_sp', UINT, 52, 'smooth assertion weights with probability paws_sp / 1024'),
|
('paws_sp', UINT, 52, 'smooth assertion weights with probability paws_sp / 1024'),
|
||||||
('wp', UINT, 100, 'random walk with probability wp / 1024'),
|
('wp', UINT, 100, 'random walk with probability wp / 1024'),
|
||||||
('vns_mc', UINT, 0, 'in local minima, try Monte Carlo sampling vns_mc many 2-bit-flips per bit'),
|
('vns_mc', UINT, 0, 'in local minima, try Monte Carlo sampling vns_mc many 2-bit-flips per bit'),
|
||||||
('vns_repick', BOOL, 0, 'in local minima, try picking a different assertion (only for walksat)'),
|
('vns_repick', BOOL, 0, 'in local minima, try picking a different assertion (only for walksat)'),
|
||||||
('restart_base', UINT, 100, 'base restart interval given by moves per run'),
|
('restart_base', UINT, 100, 'base restart interval given by moves per run'),
|
||||||
('restart_init', BOOL, 0, 'initialize to 0 or random value (= 1) after restart'),
|
('restart_init', BOOL, 0, 'initialize to 0 or random value (= 1) after restart'),
|
||||||
('early_prune', BOOL, 1, 'use early pruning for score prediction'),
|
('early_prune', BOOL, 1, 'use early pruning for score prediction'),
|
||||||
('random_offset', BOOL, 1, 'use random offset for candidate evaluation'),
|
('random_offset', BOOL, 1, 'use random offset for candidate evaluation'),
|
||||||
('rescore', BOOL, 1, 'rescore/normalize top-level score every base restart interval'),
|
('rescore', BOOL, 1, 'rescore/normalize top-level score every base restart interval'),
|
||||||
('track_unsat', BOOL, 0, 'keep a list of unsat assertions as done in SAT - currently disabled internally'),
|
('track_unsat', BOOL, 0, 'keep a list of unsat assertions as done in SAT - currently disabled internally'),
|
||||||
('random_seed', UINT, 0, 'random seed')
|
('random_seed', UINT, 0, 'random seed')
|
||||||
))
|
))
|
||||||
|
|
|
@ -68,7 +68,7 @@ private:
|
||||||
typedef obj_map<expr, value_score> scores_type;
|
typedef obj_map<expr, value_score> scores_type;
|
||||||
typedef obj_map<expr, ptr_vector<expr> > uplinks_type;
|
typedef obj_map<expr, ptr_vector<expr> > uplinks_type;
|
||||||
typedef obj_map<expr, ptr_vector<func_decl> > occ_type;
|
typedef obj_map<expr, ptr_vector<func_decl> > occ_type;
|
||||||
obj_hashtable<expr> m_top_expr;
|
obj_hashtable<expr> m_top_expr;
|
||||||
scores_type m_scores;
|
scores_type m_scores;
|
||||||
uplinks_type m_uplinks;
|
uplinks_type m_uplinks;
|
||||||
entry_point_type m_entry_points;
|
entry_point_type m_entry_points;
|
||||||
|
@ -85,11 +85,11 @@ private:
|
||||||
unsigned m_touched;
|
unsigned m_touched;
|
||||||
double m_scale_unsat;
|
double m_scale_unsat;
|
||||||
unsigned m_paws_init;
|
unsigned m_paws_init;
|
||||||
obj_map<expr, unsigned> m_where_false;
|
obj_map<expr, unsigned> m_where_false;
|
||||||
expr** m_list_false;
|
expr** m_list_false;
|
||||||
unsigned m_track_unsat;
|
unsigned m_track_unsat;
|
||||||
obj_map<expr, unsigned> m_weights;
|
obj_map<expr, unsigned> m_weights;
|
||||||
double m_top_sum;
|
double m_top_sum;
|
||||||
obj_hashtable<expr> m_temp_seen;
|
obj_hashtable<expr> m_temp_seen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -450,7 +450,7 @@ public:
|
||||||
m_list_false = new expr*[sz];
|
m_list_false = new expr*[sz];
|
||||||
for (unsigned i = 0; i < sz; i++)
|
for (unsigned i = 0; i < sz; i++)
|
||||||
{
|
{
|
||||||
if (m_mpz_manager.eq(get_value(as[i]), m_zero))
|
if (m_mpz_manager.eq(get_value(as[i]), m_zero))
|
||||||
break_assertion(as[i]);
|
break_assertion(as[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,7 @@ public:
|
||||||
|
|
||||||
// initialize weights
|
// initialize weights
|
||||||
if (!m_weights.contains(e))
|
if (!m_weights.contains(e))
|
||||||
m_weights.insert(e, m_paws_init);
|
m_weights.insert(e, m_paws_init);
|
||||||
|
|
||||||
// positive/negative occurrences used for early pruning
|
// positive/negative occurrences used for early pruning
|
||||||
setup_occs(as[i]);
|
setup_occs(as[i]);
|
||||||
|
@ -1075,7 +1075,7 @@ public:
|
||||||
|
|
||||||
unsigned cnt_unsat = 0;
|
unsigned cnt_unsat = 0;
|
||||||
for (unsigned i = 0; i < sz; i++)
|
for (unsigned i = 0; i < sz; i++)
|
||||||
if (m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i;
|
if (m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i;
|
||||||
if (pos == static_cast<unsigned>(-1))
|
if (pos == static_cast<unsigned>(-1))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1092,7 +1092,7 @@ public:
|
||||||
|
|
||||||
unsigned cnt_unsat = 0, pos = -1;
|
unsigned cnt_unsat = 0, pos = -1;
|
||||||
for (unsigned i = 0; i < sz; i++)
|
for (unsigned i = 0; i < sz; i++)
|
||||||
if ((i != m_last_pos) && m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i;
|
if ((i != m_last_pos) && m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i;
|
||||||
|
|
||||||
if (pos == static_cast<unsigned>(-1))
|
if (pos == static_cast<unsigned>(-1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,9 +1,22 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Released under Apache 2.0 license as described in the file LICENSE.
|
|
||||||
|
|
||||||
Author: Lev Nachmanson
|
Module Name:
|
||||||
*/
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -11,7 +24,7 @@ Author: Lev Nachmanson
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace lean {
|
namespace lp {
|
||||||
class argument_parser {
|
class argument_parser {
|
||||||
std::unordered_map<std::string, std::string> m_options;
|
std::unordered_map<std::string, std::string> m_options;
|
||||||
std::unordered_map<std::string, std::string> m_options_with_after_string;
|
std::unordered_map<std::string, std::string> m_options_with_after_string;
|
||||||
|
|
|
@ -27,36 +27,36 @@ static void tst1() {
|
||||||
unsigned n = rand()%10000;
|
unsigned n = rand()%10000;
|
||||||
for (unsigned i = 0; i < n; i++) {
|
for (unsigned i = 0; i < n; i++) {
|
||||||
int op = rand()%6;
|
int op = rand()%6;
|
||||||
if (op <= 1) {
|
if (op <= 1) {
|
||||||
bool val = (rand()%2) != 0;
|
bool val = (rand()%2) != 0;
|
||||||
v1.push_back(val);
|
v1.push_back(val);
|
||||||
v2.push_back(val);
|
v2.push_back(val);
|
||||||
ENSURE(v1.size() == v2.size());
|
ENSURE(v1.size() == v2.size());
|
||||||
}
|
}
|
||||||
else if (op <= 3) {
|
else if (op <= 3) {
|
||||||
ENSURE(v1.size() == v2.size());
|
ENSURE(v1.size() == v2.size());
|
||||||
if (v1.size() > 0) {
|
if (v1.size() > 0) {
|
||||||
bool val = (rand()%2) != 0;
|
bool val = (rand()%2) != 0;
|
||||||
unsigned idx = rand()%v1.size();
|
unsigned idx = rand()%v1.size();
|
||||||
ENSURE(v1.get(idx) == v2[idx]);
|
ENSURE(v1.get(idx) == v2[idx]);
|
||||||
v1.set(idx, val);
|
v1.set(idx, val);
|
||||||
v2[idx] = val;
|
v2[idx] = val;
|
||||||
ENSURE(v1.get(idx) == v2[idx]);
|
ENSURE(v1.get(idx) == v2[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (op <= 4) {
|
else if (op <= 4) {
|
||||||
ENSURE(v1.size() == v2.size());
|
ENSURE(v1.size() == v2.size());
|
||||||
if (v1.size() > 0) {
|
if (v1.size() > 0) {
|
||||||
unsigned idx = rand()%v1.size();
|
unsigned idx = rand()%v1.size();
|
||||||
VERIFY(v1.get(idx) == v2[idx]);
|
VERIFY(v1.get(idx) == v2[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (op <= 5) {
|
else if (op <= 5) {
|
||||||
ENSURE(v1.size() == v2.size());
|
ENSURE(v1.size() == v2.size());
|
||||||
for (unsigned j = 0; j < v1.size(); j++) {
|
for (unsigned j = 0; j < v1.size(); j++) {
|
||||||
ENSURE(v1.get(j) == v2[j]);
|
ENSURE(v1.get(j) == v2[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +309,6 @@ void tst_bit_vector() {
|
||||||
tst2();
|
tst2();
|
||||||
for (unsigned i = 0; i < 20; i++) {
|
for (unsigned i = 0; i < 20; i++) {
|
||||||
std::cerr << i << std::endl;
|
std::cerr << i << std::endl;
|
||||||
tst1();
|
tst1();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ template class dl_graph<diff_logic_ext>;
|
||||||
typedef dl_graph<diff_logic_ext> dlg;
|
typedef dl_graph<diff_logic_ext> dlg;
|
||||||
|
|
||||||
struct tst_dl_functor {
|
struct tst_dl_functor {
|
||||||
smt::literal_vector m_literals;
|
smt::literal_vector m_literals;
|
||||||
void operator()(smt::literal l) {
|
void operator()(smt::literal l) {
|
||||||
m_literals.push_back(l);
|
m_literals.push_back(l);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,8 @@ void tst_expr_rand(char** argv, int argc, int& i) {
|
||||||
i += 1;
|
i += 1;
|
||||||
if (i + 1 < argc && 0 == strncmp(argv[i+1],"/rs:",3)) {
|
if (i + 1 < argc && 0 == strncmp(argv[i+1],"/rs:",3)) {
|
||||||
rand_seed = atol(argv[i+1]+4);
|
rand_seed = atol(argv[i+1]+4);
|
||||||
std::cout << "random seed:" << rand_seed << "\n";
|
std::cout << "random seed:" << rand_seed << "\n";
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i + 1 < argc && 0 == strcmp(argv[i+1],"/arith")) {
|
if (i + 1 < argc && 0 == strcmp(argv[i+1],"/arith")) {
|
||||||
|
|
297
src/test/lp.cpp
297
src/test/lp.cpp
|
@ -1,7 +1,23 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#if _LINUX_
|
#if _LINUX_
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -31,8 +47,9 @@ Author: Lev Nachmanson
|
||||||
#include "util/lp/stacked_unordered_set.h"
|
#include "util/lp/stacked_unordered_set.h"
|
||||||
#include "util/lp/int_set.h"
|
#include "util/lp/int_set.h"
|
||||||
#include "util/stopwatch.h"
|
#include "util/stopwatch.h"
|
||||||
namespace lean {
|
|
||||||
unsigned seed = 1;
|
namespace lp {
|
||||||
|
unsigned seed = 1;
|
||||||
|
|
||||||
random_gen g_rand;
|
random_gen g_rand;
|
||||||
static unsigned my_random() {
|
static unsigned my_random() {
|
||||||
|
@ -78,7 +95,7 @@ void test_matrix(sparse_matrix<T, X> & a) {
|
||||||
|
|
||||||
a.set(i, j, t);
|
a.set(i, j, t);
|
||||||
|
|
||||||
lean_assert(a.get(i, j) == t);
|
SASSERT(a.get(i, j) == t);
|
||||||
|
|
||||||
unsigned j1;
|
unsigned j1;
|
||||||
if (j < m - 1) {
|
if (j < m - 1) {
|
||||||
|
@ -155,7 +172,7 @@ void tst1() {
|
||||||
|
|
||||||
test_matrix(m10by9);
|
test_matrix(m10by9);
|
||||||
std::cout <<"zeroing m10by9\n";
|
std::cout <<"zeroing m10by9\n";
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
for (unsigned int i = 0; i < m10by9.dimension(); i++)
|
for (unsigned int i = 0; i < m10by9.dimension(); i++)
|
||||||
for (unsigned int j = 0; j < m10by9.column_count(); j++)
|
for (unsigned int j = 0; j < m10by9.column_count(); j++)
|
||||||
m10by9.set(i, j, 0);
|
m10by9.set(i, j, 0);
|
||||||
|
@ -170,7 +187,7 @@ vector<int> allocate_basis_heading(unsigned count) { // the rest of initilizatio
|
||||||
|
|
||||||
|
|
||||||
void init_basic_part_of_basis_heading(vector<unsigned> & basis, vector<int> & basis_heading) {
|
void init_basic_part_of_basis_heading(vector<unsigned> & basis, vector<int> & basis_heading) {
|
||||||
lean_assert(basis_heading.size() >= basis.size());
|
SASSERT(basis_heading.size() >= basis.size());
|
||||||
unsigned m = basis.size();
|
unsigned m = basis.size();
|
||||||
for (unsigned i = 0; i < m; i++) {
|
for (unsigned i = 0; i < m; i++) {
|
||||||
unsigned column = basis[i];
|
unsigned column = basis[i];
|
||||||
|
@ -205,7 +222,7 @@ void change_basis(unsigned entering, unsigned leaving, vector<unsigned>& basis,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
void test_small_lu(lp_settings & settings) {
|
void test_small_lu(lp_settings & settings) {
|
||||||
std::cout << " test_small_lu" << std::endl;
|
std::cout << " test_small_lu" << std::endl;
|
||||||
static_matrix<double, double> m(3, 6);
|
static_matrix<double, double> m(3, 6);
|
||||||
|
@ -218,61 +235,61 @@ void test_small_lu(lp_settings & settings) {
|
||||||
m(1, 1) = 4; m(1, 4) = 7;
|
m(1, 1) = 4; m(1, 4) = 7;
|
||||||
m(2, 0) = 1.8; m(2, 2) = 5; m(2, 4) = 2; m(2, 5) = 8;
|
m(2, 0) = 1.8; m(2, 2) = 5; m(2, 4) = 2; m(2, 5) = 8;
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
print_matrix(m, std::cout);
|
print_matrix(m, std::cout);
|
||||||
#endif
|
#endif
|
||||||
vector<int> heading = allocate_basis_heading(m.column_count());
|
vector<int> heading = allocate_basis_heading(m.column_count());
|
||||||
vector<unsigned> non_basic_columns;
|
vector<unsigned> non_basic_columns;
|
||||||
init_basis_heading_and_non_basic_columns_vector(basis, heading, non_basic_columns);
|
init_basis_heading_and_non_basic_columns_vector(basis, heading, non_basic_columns);
|
||||||
lu<double, double> l(m, basis, settings);
|
lu<double, double> l(m, basis, settings);
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
indexed_vector<double> w(m.row_count());
|
indexed_vector<double> w(m.row_count());
|
||||||
std::cout << "entering 2, leaving 0" << std::endl;
|
std::cout << "entering 2, leaving 0" << std::endl;
|
||||||
l.prepare_entering(2, w); // to init vector w
|
l.prepare_entering(2, w); // to init vector w
|
||||||
l.replace_column(0, w, heading[0]);
|
l.replace_column(0, w, heading[0]);
|
||||||
change_basis(2, 0, basis, non_basic_columns, heading);
|
change_basis(2, 0, basis, non_basic_columns, heading);
|
||||||
// #ifdef LEAN_DEBUG
|
// #ifdef Z3DEBUG
|
||||||
// std::cout << "we were factoring " << std::endl;
|
// std::cout << "we were factoring " << std::endl;
|
||||||
// print_matrix(get_B(l));
|
// print_matrix(get_B(l));
|
||||||
// #endif
|
// #endif
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
std::cout << "entering 4, leaving 3" << std::endl;
|
std::cout << "entering 4, leaving 3" << std::endl;
|
||||||
l.prepare_entering(4, w); // to init vector w
|
l.prepare_entering(4, w); // to init vector w
|
||||||
l.replace_column(0, w, heading[3]);
|
l.replace_column(0, w, heading[3]);
|
||||||
change_basis(4, 3, basis, non_basic_columns, heading);
|
change_basis(4, 3, basis, non_basic_columns, heading);
|
||||||
std::cout << "we were factoring " << std::endl;
|
std::cout << "we were factoring " << std::endl;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
{
|
{
|
||||||
auto bl = get_B(l, basis);
|
auto bl = get_B(l, basis);
|
||||||
print_matrix(&bl, std::cout);
|
print_matrix(&bl, std::cout);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
|
|
||||||
std::cout << "entering 5, leaving 1" << std::endl;
|
std::cout << "entering 5, leaving 1" << std::endl;
|
||||||
l.prepare_entering(5, w); // to init vector w
|
l.prepare_entering(5, w); // to init vector w
|
||||||
l.replace_column(0, w, heading[1]);
|
l.replace_column(0, w, heading[1]);
|
||||||
change_basis(5, 1, basis, non_basic_columns, heading);
|
change_basis(5, 1, basis, non_basic_columns, heading);
|
||||||
std::cout << "we were factoring " << std::endl;
|
std::cout << "we were factoring " << std::endl;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
{
|
{
|
||||||
auto bl = get_B(l, basis);
|
auto bl = get_B(l, basis);
|
||||||
print_matrix(&bl, std::cout);
|
print_matrix(&bl, std::cout);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
std::cout << "entering 3, leaving 2" << std::endl;
|
std::cout << "entering 3, leaving 2" << std::endl;
|
||||||
l.prepare_entering(3, w); // to init vector w
|
l.prepare_entering(3, w); // to init vector w
|
||||||
l.replace_column(0, w, heading[2]);
|
l.replace_column(0, w, heading[2]);
|
||||||
change_basis(3, 2, basis, non_basic_columns, heading);
|
change_basis(3, 2, basis, non_basic_columns, heading);
|
||||||
std::cout << "we were factoring " << std::endl;
|
std::cout << "we were factoring " << std::endl;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
{
|
{
|
||||||
auto bl = get_B(l, basis);
|
auto bl = get_B(l, basis);
|
||||||
print_matrix(&bl, std::cout);
|
print_matrix(&bl, std::cout);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
|
|
||||||
m.add_row();
|
m.add_row();
|
||||||
m.add_column();
|
m.add_column();
|
||||||
|
@ -291,7 +308,7 @@ void test_small_lu(lp_settings & settings) {
|
||||||
auto columns_to_replace = l.get_set_of_columns_to_replace_for_add_last_rows(heading);
|
auto columns_to_replace = l.get_set_of_columns_to_replace_for_add_last_rows(heading);
|
||||||
l.add_last_rows_to_B(heading, columns_to_replace);
|
l.add_last_rows_to_B(heading, columns_to_replace);
|
||||||
std::cout << "here" << std::endl;
|
std::cout << "here" << std::endl;
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -351,7 +368,7 @@ void fill_larger_sparse_matrix(static_matrix<double, double> & m){
|
||||||
|
|
||||||
int perm_id = 0;
|
int perm_id = 0;
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
void test_larger_lu_exp(lp_settings & settings) {
|
void test_larger_lu_exp(lp_settings & settings) {
|
||||||
std::cout << " test_larger_lu_exp" << std::endl;
|
std::cout << " test_larger_lu_exp" << std::endl;
|
||||||
static_matrix<double, double> m(6, 12);
|
static_matrix<double, double> m(6, 12);
|
||||||
|
@ -373,7 +390,7 @@ void test_larger_lu_exp(lp_settings & settings) {
|
||||||
|
|
||||||
dense_matrix<double, double> left_side = l.get_left_side(basis);
|
dense_matrix<double, double> left_side = l.get_left_side(basis);
|
||||||
dense_matrix<double, double> right_side = l.get_right_side();
|
dense_matrix<double, double> right_side = l.get_right_side();
|
||||||
lean_assert(left_side == right_side);
|
SASSERT(left_side == right_side);
|
||||||
int leaving = 3;
|
int leaving = 3;
|
||||||
int entering = 8;
|
int entering = 8;
|
||||||
for (unsigned i = 0; i < m.row_count(); i++) {
|
for (unsigned i = 0; i < m.row_count(); i++) {
|
||||||
|
@ -385,12 +402,12 @@ void test_larger_lu_exp(lp_settings & settings) {
|
||||||
l.prepare_entering(entering, w);
|
l.prepare_entering(entering, w);
|
||||||
l.replace_column(0, w, heading[leaving]);
|
l.replace_column(0, w, heading[leaving]);
|
||||||
change_basis(entering, leaving, basis, non_basic_columns, heading);
|
change_basis(entering, leaving, basis, non_basic_columns, heading);
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
|
|
||||||
l.prepare_entering(11, w); // to init vector w
|
l.prepare_entering(11, w); // to init vector w
|
||||||
l.replace_column(0, w, heading[0]);
|
l.replace_column(0, w, heading[0]);
|
||||||
change_basis(11, 0, basis, non_basic_columns, heading);
|
change_basis(11, 0, basis, non_basic_columns, heading);
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_larger_lu_with_holes(lp_settings & settings) {
|
void test_larger_lu_with_holes(lp_settings & settings) {
|
||||||
|
@ -432,7 +449,7 @@ void test_larger_lu_with_holes(lp_settings & settings) {
|
||||||
l.prepare_entering(8, w); // to init vector w
|
l.prepare_entering(8, w); // to init vector w
|
||||||
l.replace_column(0, w, heading[0]);
|
l.replace_column(0, w, heading[0]);
|
||||||
change_basis(8, 0, basis, non_basic_columns, heading);
|
change_basis(8, 0, basis, non_basic_columns, heading);
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,7 +496,7 @@ void test_larger_lu(lp_settings& settings) {
|
||||||
l.prepare_entering(9, w); // to init vector w
|
l.prepare_entering(9, w); // to init vector w
|
||||||
l.replace_column(0, w, heading[0]);
|
l.replace_column(0, w, heading[0]);
|
||||||
change_basis(9, 0, basis, non_basic_columns, heading);
|
change_basis(9, 0, basis, non_basic_columns, heading);
|
||||||
lean_assert(l.is_correct(basis));
|
SASSERT(l.is_correct(basis));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -550,7 +567,7 @@ void test_lp_1() {
|
||||||
m(1, 0) = -1; m(1, 2) = 3; m(1, 4) = 1;
|
m(1, 0) = -1; m(1, 2) = 3; m(1, 4) = 1;
|
||||||
m(2, 0) = 2; m(2, 1) = -1; m(2, 2) = 2; m(2, 5) = 1;
|
m(2, 0) = 2; m(2, 1) = -1; m(2, 2) = 2; m(2, 5) = 1;
|
||||||
m(3, 0) = 2; m(3, 1) = 3; m(3, 2) = -1; m(3, 6) = 1;
|
m(3, 0) = 2; m(3, 1) = 3; m(3, 2) = -1; m(3, 6) = 1;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
print_matrix(m, std::cout);
|
print_matrix(m, std::cout);
|
||||||
#endif
|
#endif
|
||||||
vector<double> x_star(7);
|
vector<double> x_star(7);
|
||||||
|
@ -604,7 +621,7 @@ void test_lp_primal_core_solver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
|
void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
|
||||||
std::cout << "testing swaps" << std::endl;
|
std::cout << "testing swaps" << std::endl;
|
||||||
|
@ -612,7 +629,7 @@ void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
|
||||||
dense_matrix<double, double> original(&m);
|
dense_matrix<double, double> original(&m);
|
||||||
permutation_matrix<double, double> q(dim);
|
permutation_matrix<double, double> q(dim);
|
||||||
print_matrix(m, std::cout);
|
print_matrix(m, std::cout);
|
||||||
lean_assert(original == q * m);
|
SASSERT(original == q * m);
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
unsigned row1 = my_random() % dim;
|
unsigned row1 = my_random() % dim;
|
||||||
unsigned row2 = my_random() % dim;
|
unsigned row2 = my_random() % dim;
|
||||||
|
@ -620,7 +637,7 @@ void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
|
||||||
std::cout << "swap " << row1 << " " << row2 << std::endl;
|
std::cout << "swap " << row1 << " " << row2 << std::endl;
|
||||||
m.swap_rows(row1, row2);
|
m.swap_rows(row1, row2);
|
||||||
q.transpose_from_left(row1, row2);
|
q.transpose_from_left(row1, row2);
|
||||||
lean_assert(original == q * m);
|
SASSERT(original == q * m);
|
||||||
print_matrix(m, std::cout);
|
print_matrix(m, std::cout);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -628,7 +645,7 @@ void test_swap_rows_with_permutation(sparse_matrix<T, X>& m){
|
||||||
#endif
|
#endif
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
void fill_matrix(sparse_matrix<T, X>& m); // forward definition
|
void fill_matrix(sparse_matrix<T, X>& m); // forward definition
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
void test_swap_cols_with_permutation(sparse_matrix<T, X>& m){
|
void test_swap_cols_with_permutation(sparse_matrix<T, X>& m){
|
||||||
std::cout << "testing swaps" << std::endl;
|
std::cout << "testing swaps" << std::endl;
|
||||||
|
@ -636,7 +653,7 @@ void test_swap_cols_with_permutation(sparse_matrix<T, X>& m){
|
||||||
dense_matrix<double, double> original(&m);
|
dense_matrix<double, double> original(&m);
|
||||||
permutation_matrix<double, double> q(dim);
|
permutation_matrix<double, double> q(dim);
|
||||||
print_matrix(m, std::cout);
|
print_matrix(m, std::cout);
|
||||||
lean_assert(original == q * m);
|
SASSERT(original == q * m);
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
unsigned row1 = my_random() % dim;
|
unsigned row1 = my_random() % dim;
|
||||||
unsigned row2 = my_random() % dim;
|
unsigned row2 = my_random() % dim;
|
||||||
|
@ -644,7 +661,7 @@ void test_swap_cols_with_permutation(sparse_matrix<T, X>& m){
|
||||||
std::cout << "swap " << row1 << " " << row2 << std::endl;
|
std::cout << "swap " << row1 << " " << row2 << std::endl;
|
||||||
m.swap_rows(row1, row2);
|
m.swap_rows(row1, row2);
|
||||||
q.transpose_from_right(row1, row2);
|
q.transpose_from_right(row1, row2);
|
||||||
lean_assert(original == q * m);
|
SASSERT(original == q * m);
|
||||||
print_matrix(m, std::cout);
|
print_matrix(m, std::cout);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -663,8 +680,8 @@ void test_swap_rows(sparse_matrix<T, X>& m, unsigned i0, unsigned i1){
|
||||||
m.swap_rows(i0, i1);
|
m.swap_rows(i0, i1);
|
||||||
|
|
||||||
for (unsigned j = 0; j < m.dimension(); j++) {
|
for (unsigned j = 0; j < m.dimension(); j++) {
|
||||||
lean_assert(mcopy(i0, j) == m(i1, j));
|
SASSERT(mcopy(i0, j) == m(i1, j));
|
||||||
lean_assert(mcopy(i1, j) == m(i0, j));
|
SASSERT(mcopy(i1, j) == m(i0, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
|
@ -678,15 +695,15 @@ void test_swap_columns(sparse_matrix<T, X>& m, unsigned i0, unsigned i1){
|
||||||
m.swap_columns(i0, i1);
|
m.swap_columns(i0, i1);
|
||||||
|
|
||||||
for (unsigned j = 0; j < m.dimension(); j++) {
|
for (unsigned j = 0; j < m.dimension(); j++) {
|
||||||
lean_assert(mcopy(j, i0) == m(j, i1));
|
SASSERT(mcopy(j, i0) == m(j, i1));
|
||||||
lean_assert(mcopy(j, i1) == m(j, i0));
|
SASSERT(mcopy(j, i1) == m(j, i0));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < m.dimension(); i++) {
|
for (unsigned i = 0; i < m.dimension(); i++) {
|
||||||
if (i == i0 || i == i1)
|
if (i == i0 || i == i1)
|
||||||
continue;
|
continue;
|
||||||
for (unsigned j = 0; j < m.dimension(); j++) {
|
for (unsigned j = 0; j < m.dimension(); j++) {
|
||||||
lean_assert(mcopy(j, i)== m(j, i));
|
SASSERT(mcopy(j, i)== m(j, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -731,7 +748,7 @@ void test_pivot_like_swaps_and_pivot(){
|
||||||
m(target_row, 3) = 0;
|
m(target_row, 3) = 0;
|
||||||
m(target_row, 5) = 0;
|
m(target_row, 5) = 0;
|
||||||
m(pivot_row, 6) = 0;
|
m(pivot_row, 6) = 0;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
print_matrix(m, std::cout);
|
print_matrix(m, std::cout);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -748,11 +765,11 @@ void test_pivot_like_swaps_and_pivot(){
|
||||||
m.pivot_row_to_row(pivot_row_0, beta, target_row, settings);
|
m.pivot_row_to_row(pivot_row_0, beta, target_row, settings);
|
||||||
// print_matrix(m);
|
// print_matrix(m);
|
||||||
for (unsigned j = 0; j < m.dimension(); j++) {
|
for (unsigned j = 0; j < m.dimension(); j++) {
|
||||||
lean_assert(abs(row[j] - m(target_row, j)) < 0.00000001);
|
SASSERT(abs(row[j] - m(target_row, j)) < 0.00000001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
void test_swap_rows() {
|
void test_swap_rows() {
|
||||||
sparse_matrix<double, double> m(10);
|
sparse_matrix<double, double> m(10);
|
||||||
fill_matrix(m);
|
fill_matrix(m);
|
||||||
|
@ -853,57 +870,57 @@ void sparse_matrix_with_permutaions_test() {
|
||||||
m.multiply_from_left(q0);
|
m.multiply_from_left(q0);
|
||||||
for (unsigned i = 0; i < dim; i++) {
|
for (unsigned i = 0; i < dim; i++) {
|
||||||
for (unsigned j = 0; j < dim; j++) {
|
for (unsigned j = 0; j < dim; j++) {
|
||||||
lean_assert(m(i, j) == dm0.get_elem(q0[i], j));
|
SASSERT(m(i, j) == dm0.get_elem(q0[i], j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto q0_dm = q0 * dm;
|
auto q0_dm = q0 * dm;
|
||||||
lean_assert(m == q0_dm);
|
SASSERT(m == q0_dm);
|
||||||
|
|
||||||
m.multiply_from_left(q1);
|
m.multiply_from_left(q1);
|
||||||
for (unsigned i = 0; i < dim; i++) {
|
for (unsigned i = 0; i < dim; i++) {
|
||||||
for (unsigned j = 0; j < dim; j++) {
|
for (unsigned j = 0; j < dim; j++) {
|
||||||
lean_assert(m(i, j) == dm0.get_elem(q0[q1[i]], j));
|
SASSERT(m(i, j) == dm0.get_elem(q0[q1[i]], j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto q1_q0_dm = q1 * q0_dm;
|
auto q1_q0_dm = q1 * q0_dm;
|
||||||
|
|
||||||
lean_assert(m == q1_q0_dm);
|
SASSERT(m == q1_q0_dm);
|
||||||
|
|
||||||
m.multiply_from_right(p0);
|
m.multiply_from_right(p0);
|
||||||
|
|
||||||
for (unsigned i = 0; i < dim; i++) {
|
for (unsigned i = 0; i < dim; i++) {
|
||||||
for (unsigned j = 0; j < dim; j++) {
|
for (unsigned j = 0; j < dim; j++) {
|
||||||
lean_assert(m(i, j) == dm0.get_elem(q0[q1[i]], p0[j]));
|
SASSERT(m(i, j) == dm0.get_elem(q0[q1[i]], p0[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto q1_q0_dm_p0 = q1_q0_dm * p0;
|
auto q1_q0_dm_p0 = q1_q0_dm * p0;
|
||||||
|
|
||||||
lean_assert(m == q1_q0_dm_p0);
|
SASSERT(m == q1_q0_dm_p0);
|
||||||
|
|
||||||
m.multiply_from_right(p1);
|
m.multiply_from_right(p1);
|
||||||
|
|
||||||
for (unsigned i = 0; i < dim; i++) {
|
for (unsigned i = 0; i < dim; i++) {
|
||||||
for (unsigned j = 0; j < dim; j++) {
|
for (unsigned j = 0; j < dim; j++) {
|
||||||
lean_assert(m(i, j) == dm0.get_elem(q0[q1[i]], p1[p0[j]]));
|
SASSERT(m(i, j) == dm0.get_elem(q0[q1[i]], p1[p0[j]]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto q1_q0_dm_p0_p1 = q1_q0_dm_p0 * p1;
|
auto q1_q0_dm_p0_p1 = q1_q0_dm_p0 * p1;
|
||||||
lean_assert(m == q1_q0_dm_p0_p1);
|
SASSERT(m == q1_q0_dm_p0_p1);
|
||||||
|
|
||||||
m.multiply_from_right(p1);
|
m.multiply_from_right(p1);
|
||||||
for (unsigned i = 0; i < dim; i++) {
|
for (unsigned i = 0; i < dim; i++) {
|
||||||
for (unsigned j = 0; j < dim; j++) {
|
for (unsigned j = 0; j < dim; j++) {
|
||||||
lean_assert(m(i, j) == dm0.get_elem(q0[q1[i]], p1[p1[p0[j]]]));
|
SASSERT(m(i, j) == dm0.get_elem(q0[q1[i]], p1[p1[p0[j]]]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto q1_q0_dm_p0_p1_p1 = q1_q0_dm_p0_p1 * p1;
|
auto q1_q0_dm_p0_p1_p1 = q1_q0_dm_p0_p1 * p1;
|
||||||
|
|
||||||
lean_assert(m == q1_q0_dm_p0_p1_p1);
|
SASSERT(m == q1_q0_dm_p0_p1_p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_swap_columns() {
|
void test_swap_columns() {
|
||||||
|
@ -1021,10 +1038,10 @@ void test_apply_reverse_from_right_to_perm(permutation_matrix<double, double> &
|
||||||
pclone[4] = 1;
|
pclone[4] = 1;
|
||||||
|
|
||||||
p.multiply_by_reverse_from_right(l);
|
p.multiply_by_reverse_from_right(l);
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
auto rev = l.get_inverse();
|
auto rev = l.get_inverse();
|
||||||
auto rs = pclone * rev;
|
auto rs = pclone * rev;
|
||||||
lean_assert(p == rs)
|
SASSERT(p == rs);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1051,8 +1068,8 @@ void test_permutations() {
|
||||||
|
|
||||||
p.apply_reverse_from_right_to_T(v);
|
p.apply_reverse_from_right_to_T(v);
|
||||||
p.apply_reverse_from_right_to_T(vi);
|
p.apply_reverse_from_right_to_T(vi);
|
||||||
lean_assert(vectors_are_equal(v, vi.m_data));
|
SASSERT(vectors_are_equal(v, vi.m_data));
|
||||||
lean_assert(vi.is_OK());
|
SASSERT(vi.is_OK());
|
||||||
}
|
}
|
||||||
|
|
||||||
void lp_solver_test() {
|
void lp_solver_test() {
|
||||||
|
@ -1200,7 +1217,7 @@ void solve_mps_double(std::string file_name, bool look_for_min, unsigned max_ite
|
||||||
compare_solutions(reader, primal_solver, solver);
|
compare_solutions(reader, primal_solver, solver);
|
||||||
print_x(reader, primal_solver);
|
print_x(reader, primal_solver);
|
||||||
std::cout << "dual cost is " << cost << ", but primal cost is " << primal_cost << std::endl;
|
std::cout << "dual cost is " << cost << ", but primal cost is " << primal_cost << std::endl;
|
||||||
lean_assert(false);
|
SASSERT(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1210,7 +1227,7 @@ void solve_mps_double(std::string file_name, bool look_for_min, unsigned max_ite
|
||||||
}
|
}
|
||||||
|
|
||||||
void solve_mps_rational(std::string file_name, bool look_for_min, unsigned max_iterations, unsigned time_limit, bool dual, argument_parser & args_parser) {
|
void solve_mps_rational(std::string file_name, bool look_for_min, unsigned max_iterations, unsigned time_limit, bool dual, argument_parser & args_parser) {
|
||||||
mps_reader<lean::mpq, lean::mpq> reader(file_name);
|
mps_reader<lp::mpq, lp::mpq> reader(file_name);
|
||||||
reader.read();
|
reader.read();
|
||||||
if (reader.is_ok()) {
|
if (reader.is_ok()) {
|
||||||
auto * solver = reader.create_solver(dual);
|
auto * solver = reader.create_solver(dual);
|
||||||
|
@ -1224,7 +1241,7 @@ void solve_mps_rational(std::string file_name, bool look_for_min, unsigned max_i
|
||||||
// for (auto name: reader.column_names()) {
|
// for (auto name: reader.column_names()) {
|
||||||
// std::cout << name << "=" << solver->get_column_value_by_name(name) << ' ';
|
// std::cout << name << "=" << solver->get_column_value_by_name(name) << ' ';
|
||||||
// }
|
// }
|
||||||
lean::mpq cost = solver->get_current_cost();
|
lp::mpq cost = solver->get_current_cost();
|
||||||
if (look_for_min) {
|
if (look_for_min) {
|
||||||
cost = -cost;
|
cost = -cost;
|
||||||
}
|
}
|
||||||
|
@ -1262,7 +1279,7 @@ void solve_mps(std::string file_name, argument_parser & args_parser) {
|
||||||
void solve_mps_in_rational(std::string file_name, bool dual, argument_parser & /*args_parser*/) {
|
void solve_mps_in_rational(std::string file_name, bool dual, argument_parser & /*args_parser*/) {
|
||||||
std::cout << "solving " << file_name << std::endl;
|
std::cout << "solving " << file_name << std::endl;
|
||||||
|
|
||||||
mps_reader<lean::mpq, lean::mpq> reader(file_name);
|
mps_reader<lp::mpq, lp::mpq> reader(file_name);
|
||||||
reader.read();
|
reader.read();
|
||||||
if (reader.is_ok()) {
|
if (reader.is_ok()) {
|
||||||
auto * solver = reader.create_solver(dual);
|
auto * solver = reader.create_solver(dual);
|
||||||
|
@ -1274,7 +1291,7 @@ void solve_mps_in_rational(std::string file_name, bool dual, argument_parser & /
|
||||||
std::cout << name << "=" << solver->get_column_value_by_name(name).get_double() << ' ';
|
std::cout << name << "=" << solver->get_column_value_by_name(name).get_double() << ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << std::endl << "cost = " << numeric_traits<lean::mpq>::get_double(solver->get_current_cost()) << std::endl;
|
std::cout << std::endl << "cost = " << numeric_traits<lp::mpq>::get_double(solver->get_current_cost()) << std::endl;
|
||||||
}
|
}
|
||||||
delete solver;
|
delete solver;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1318,7 +1335,7 @@ void test_binary_priority_queue() {
|
||||||
|
|
||||||
for (unsigned i = 0; i < 10; i++) {
|
for (unsigned i = 0; i < 10; i++) {
|
||||||
unsigned de = q.dequeue();
|
unsigned de = q.dequeue();
|
||||||
lean_assert(i == de);
|
SASSERT(i == de);
|
||||||
std::cout << de << std::endl;
|
std::cout << de << std::endl;
|
||||||
}
|
}
|
||||||
q.enqueue(2, 2);
|
q.enqueue(2, 2);
|
||||||
|
@ -1337,11 +1354,11 @@ void test_binary_priority_queue() {
|
||||||
q.dequeue();
|
q.dequeue();
|
||||||
q.remove(33);
|
q.remove(33);
|
||||||
q.enqueue(0, 0);
|
q.enqueue(0, 0);
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
unsigned t = 0;
|
unsigned t = 0;
|
||||||
while (q.size() > 0) {
|
while (q.size() > 0) {
|
||||||
unsigned d =q.dequeue();
|
unsigned d =q.dequeue();
|
||||||
lean_assert(t++ == d);
|
SASSERT(t++ == d);
|
||||||
std::cout << d << std::endl;
|
std::cout << d << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1370,7 +1387,7 @@ void solve_mps_with_known_solution(std::string file_name, std::unordered_map<std
|
||||||
std::cout << "status is " << lp_status_to_string(solver->get_status()) << std::endl;
|
std::cout << "status is " << lp_status_to_string(solver->get_status()) << std::endl;
|
||||||
if (status != solver->get_status()){
|
if (status != solver->get_status()){
|
||||||
std::cout << "status should be " << lp_status_to_string(status) << std::endl;
|
std::cout << "status should be " << lp_status_to_string(status) << std::endl;
|
||||||
lean_assert(status == solver->get_status());
|
SASSERT(status == solver->get_status());
|
||||||
throw "status is wrong";
|
throw "status is wrong";
|
||||||
}
|
}
|
||||||
if (solver->get_status() == lp_status::OPTIMAL) {
|
if (solver->get_status() == lp_status::OPTIMAL) {
|
||||||
|
@ -1381,7 +1398,7 @@ void solve_mps_with_known_solution(std::string file_name, std::unordered_map<std
|
||||||
std::cout << "expected:" << it.first << "=" <<
|
std::cout << "expected:" << it.first << "=" <<
|
||||||
it.second <<", got " << solver->get_column_value_by_name(it.first) << std::endl;
|
it.second <<", got " << solver->get_column_value_by_name(it.first) << std::endl;
|
||||||
}
|
}
|
||||||
lean_assert(fabs(it.second - solver->get_column_value_by_name(it.first)) < 0.000001);
|
SASSERT(fabs(it.second - solver->get_column_value_by_name(it.first)) < 0.000001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reader.column_names().size() < 20) {
|
if (reader.column_names().size() < 20) {
|
||||||
|
@ -1706,48 +1723,48 @@ void solve_some_mps(argument_parser & args_parser) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void solve_rational() {
|
void solve_rational() {
|
||||||
lp_primal_simplex<lean::mpq, lean::mpq> solver;
|
lp_primal_simplex<lp::mpq, lp::mpq> solver;
|
||||||
solver.add_constraint(lp_relation::Equal, lean::mpq(7), 0);
|
solver.add_constraint(lp_relation::Equal, lp::mpq(7), 0);
|
||||||
solver.add_constraint(lp_relation::Equal, lean::mpq(-3), 1);
|
solver.add_constraint(lp_relation::Equal, lp::mpq(-3), 1);
|
||||||
|
|
||||||
// setting the cost
|
// setting the cost
|
||||||
int cost[] = {-3, -1, -1, 2, -1, 1, 1, -4};
|
int cost[] = {-3, -1, -1, 2, -1, 1, 1, -4};
|
||||||
std::string var_names[8] = {"x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8"};
|
std::string var_names[8] = {"x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8"};
|
||||||
|
|
||||||
for (unsigned i = 0; i < 8; i++) {
|
for (unsigned i = 0; i < 8; i++) {
|
||||||
solver.set_cost_for_column(i, lean::mpq(cost[i]));
|
solver.set_cost_for_column(i, lp::mpq(cost[i]));
|
||||||
solver.give_symbolic_name_to_column(var_names[i], i);
|
solver.give_symbolic_name_to_column(var_names[i], i);
|
||||||
}
|
}
|
||||||
|
|
||||||
int row0[] = {1, 0, 3, 1, -5, -2 , 4, -6};
|
int row0[] = {1, 0, 3, 1, -5, -2 , 4, -6};
|
||||||
for (unsigned i = 0; i < 8; i++) {
|
for (unsigned i = 0; i < 8; i++) {
|
||||||
solver.set_row_column_coefficient(0, i, lean::mpq(row0[i]));
|
solver.set_row_column_coefficient(0, i, lp::mpq(row0[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
int row1[] = {0, 1, -2, -1, 4, 1, -3, 5};
|
int row1[] = {0, 1, -2, -1, 4, 1, -3, 5};
|
||||||
for (unsigned i = 0; i < 8; i++) {
|
for (unsigned i = 0; i < 8; i++) {
|
||||||
solver.set_row_column_coefficient(1, i, lean::mpq(row1[i]));
|
solver.set_row_column_coefficient(1, i, lp::mpq(row1[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
int bounds[] = {8, 6, 4, 15, 2, 10, 10, 3};
|
int bounds[] = {8, 6, 4, 15, 2, 10, 10, 3};
|
||||||
for (unsigned i = 0; i < 8; i++) {
|
for (unsigned i = 0; i < 8; i++) {
|
||||||
solver.set_low_bound(i, lean::mpq(0));
|
solver.set_low_bound(i, lp::mpq(0));
|
||||||
solver.set_upper_bound(i, lean::mpq(bounds[i]));
|
solver.set_upper_bound(i, lp::mpq(bounds[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<std::string, lean::mpq> expected_sol;
|
std::unordered_map<std::string, lp::mpq> expected_sol;
|
||||||
expected_sol["x1"] = lean::mpq(0);
|
expected_sol["x1"] = lp::mpq(0);
|
||||||
expected_sol["x2"] = lean::mpq(6);
|
expected_sol["x2"] = lp::mpq(6);
|
||||||
expected_sol["x3"] = lean::mpq(0);
|
expected_sol["x3"] = lp::mpq(0);
|
||||||
expected_sol["x4"] = lean::mpq(15);
|
expected_sol["x4"] = lp::mpq(15);
|
||||||
expected_sol["x5"] = lean::mpq(2);
|
expected_sol["x5"] = lp::mpq(2);
|
||||||
expected_sol["x6"] = lean::mpq(1);
|
expected_sol["x6"] = lp::mpq(1);
|
||||||
expected_sol["x7"] = lean::mpq(1);
|
expected_sol["x7"] = lp::mpq(1);
|
||||||
expected_sol["x8"] = lean::mpq(0);
|
expected_sol["x8"] = lp::mpq(0);
|
||||||
solver.find_maximal_solution();
|
solver.find_maximal_solution();
|
||||||
lean_assert(solver.get_status() == OPTIMAL);
|
SASSERT(solver.get_status() == OPTIMAL);
|
||||||
for (auto it : expected_sol) {
|
for (auto it : expected_sol) {
|
||||||
lean_assert(it.second == solver.get_column_value_by_name(it.first));
|
SASSERT(it.second == solver.get_column_value_by_name(it.first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1805,7 +1822,7 @@ std::unordered_map<std::string, double> * get_solution_from_glpsol_output(std::s
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
lean_assert(split.size() > 3);
|
SASSERT(split.size() > 3);
|
||||||
(*ret)[split[1]] = atof(split[3].c_str());
|
(*ret)[split[1]] = atof(split[3].c_str());
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
@ -1817,7 +1834,7 @@ void test_init_U() {
|
||||||
m(0, 0) = 10; m(0, 1) = 11; m(0, 2) = 12; m(0, 3) = 13; m(0, 4) = 14;
|
m(0, 0) = 10; m(0, 1) = 11; m(0, 2) = 12; m(0, 3) = 13; m(0, 4) = 14;
|
||||||
m(1, 0) = 20; m(1, 1) = 21; m(1, 2) = 22; m(1, 3) = 23; m(1, 5) = 24;
|
m(1, 0) = 20; m(1, 1) = 21; m(1, 2) = 22; m(1, 3) = 23; m(1, 5) = 24;
|
||||||
m(2, 0) = 30; m(2, 1) = 31; m(2, 2) = 32; m(2, 3) = 33; m(2, 6) = 34;
|
m(2, 0) = 30; m(2, 1) = 31; m(2, 2) = 32; m(2, 3) = 33; m(2, 6) = 34;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
print_matrix(m, std::cout);
|
print_matrix(m, std::cout);
|
||||||
#endif
|
#endif
|
||||||
vector<unsigned> basis(3);
|
vector<unsigned> basis(3);
|
||||||
|
@ -1829,7 +1846,7 @@ void test_init_U() {
|
||||||
|
|
||||||
for (unsigned i = 0; i < 3; i++) {
|
for (unsigned i = 0; i < 3; i++) {
|
||||||
for (unsigned j = 0; j < 3; j ++) {
|
for (unsigned j = 0; j < 3; j ++) {
|
||||||
lean_assert(m(i, basis[j]) == u(i, j));
|
SASSERT(m(i, basis[j]) == u(i, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1857,7 +1874,7 @@ void test_replace_column() {
|
||||||
for (unsigned column_to_replace = 0; column_to_replace < m.dimension(); column_to_replace ++) {
|
for (unsigned column_to_replace = 0; column_to_replace < m.dimension(); column_to_replace ++) {
|
||||||
m.replace_column(column_to_replace, w, settings);
|
m.replace_column(column_to_replace, w, settings);
|
||||||
for (unsigned i = 0; i < m.dimension(); i++) {
|
for (unsigned i = 0; i < m.dimension(); i++) {
|
||||||
lean_assert(abs(w[i] - m(i, column_to_replace)) < 0.00000001);
|
SASSERT(abs(w[i] - m(i, column_to_replace)) < 0.00000001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1961,7 +1978,7 @@ void test_stacked_unsigned() {
|
||||||
v = 3;
|
v = 3;
|
||||||
v = 4;
|
v = 4;
|
||||||
v.pop();
|
v.pop();
|
||||||
lean_assert(v == 2);
|
SASSERT(v == 2);
|
||||||
v ++;
|
v ++;
|
||||||
v++;
|
v++;
|
||||||
std::cout << "before push v=" << v << std::endl;
|
std::cout << "before push v=" << v << std::endl;
|
||||||
|
@ -1971,7 +1988,7 @@ void test_stacked_unsigned() {
|
||||||
v+=1;
|
v+=1;
|
||||||
std::cout << "v = " << v << std::endl;
|
std::cout << "v = " << v << std::endl;
|
||||||
v.pop(2);
|
v.pop(2);
|
||||||
lean_assert(v == 4);
|
SASSERT(v == 4);
|
||||||
const unsigned & rr = v;
|
const unsigned & rr = v;
|
||||||
std::cout << rr << std:: endl;
|
std::cout << rr << std:: endl;
|
||||||
|
|
||||||
|
@ -2010,7 +2027,7 @@ void test_stacked_vector() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_stacked_set() {
|
void test_stacked_set() {
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
std::cout << "test_stacked_set" << std::endl;
|
std::cout << "test_stacked_set" << std::endl;
|
||||||
stacked_unordered_set<int> s;
|
stacked_unordered_set<int> s;
|
||||||
s.insert(1);
|
s.insert(1);
|
||||||
|
@ -2020,7 +2037,7 @@ void test_stacked_set() {
|
||||||
s.push();
|
s.push();
|
||||||
s.insert(4);
|
s.insert(4);
|
||||||
s.pop();
|
s.pop();
|
||||||
lean_assert(s() == scopy);
|
SASSERT(s() == scopy);
|
||||||
s.push();
|
s.push();
|
||||||
s.push();
|
s.push();
|
||||||
s.insert(4);
|
s.insert(4);
|
||||||
|
@ -2028,7 +2045,7 @@ void test_stacked_set() {
|
||||||
s.push();
|
s.push();
|
||||||
s.insert(4);
|
s.insert(4);
|
||||||
s.pop(3);
|
s.pop(3);
|
||||||
lean_assert(s() == scopy);
|
SASSERT(s() == scopy);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2397,15 +2414,15 @@ void test_files_from_directory(std::string test_file_dir, argument_parser & args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::unordered_map<std::string, lean::mpq> get_solution_map(lp_solver<lean::mpq, lean::mpq> * lps, mps_reader<lean::mpq, lean::mpq> & reader) {
|
std::unordered_map<std::string, lp::mpq> get_solution_map(lp_solver<lp::mpq, lp::mpq> * lps, mps_reader<lp::mpq, lp::mpq> & reader) {
|
||||||
std::unordered_map<std::string, lean::mpq> ret;
|
std::unordered_map<std::string, lp::mpq> ret;
|
||||||
for (auto it : reader.column_names()) {
|
for (auto it : reader.column_names()) {
|
||||||
ret[it] = lps->get_column_value_by_name(it);
|
ret[it] = lps->get_column_value_by_name(it);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_reader<lean::mpq, lean::mpq> * reader) {
|
void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_reader<lp::mpq, lp::mpq> * reader) {
|
||||||
std::string maxng = args_parser.get_option_value("--maxng");
|
std::string maxng = args_parser.get_option_value("--maxng");
|
||||||
if (maxng.size() > 0) {
|
if (maxng.size() > 0) {
|
||||||
solver->settings().max_number_of_iterations_with_no_improvements = atoi(maxng.c_str());
|
solver->settings().max_number_of_iterations_with_no_improvements = atoi(maxng.c_str());
|
||||||
|
@ -2425,7 +2442,7 @@ void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_read
|
||||||
}
|
}
|
||||||
auto * lps = reader->create_solver(false);
|
auto * lps = reader->create_solver(false);
|
||||||
lps->find_maximal_solution();
|
lps->find_maximal_solution();
|
||||||
std::unordered_map<std::string, lean::mpq> sol = get_solution_map(lps, *reader);
|
std::unordered_map<std::string, lp::mpq> sol = get_solution_map(lps, *reader);
|
||||||
std::cout << "status = " << lp_status_to_string(solver->get_status()) << std::endl;
|
std::cout << "status = " << lp_status_to_string(solver->get_status()) << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2434,7 +2451,7 @@ void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_read
|
||||||
lp_status status = solver->solve();
|
lp_status status = solver->solve();
|
||||||
std::cout << "status is " << lp_status_to_string(status) << ", processed for " << sw.get_current_seconds() <<" seconds, and " << solver->get_total_iterations() << " iterations" << std::endl;
|
std::cout << "status is " << lp_status_to_string(status) << ", processed for " << sw.get_current_seconds() <<" seconds, and " << solver->get_total_iterations() << " iterations" << std::endl;
|
||||||
if (solver->get_status() == INFEASIBLE) {
|
if (solver->get_status() == INFEASIBLE) {
|
||||||
vector<std::pair<lean::mpq, constraint_index>> evidence;
|
vector<std::pair<lp::mpq, constraint_index>> evidence;
|
||||||
solver->get_infeasibility_explanation(evidence);
|
solver->get_infeasibility_explanation(evidence);
|
||||||
}
|
}
|
||||||
if (args_parser.option_is_used("--randomize_lar")) {
|
if (args_parser.option_is_used("--randomize_lar")) {
|
||||||
|
@ -2467,7 +2484,7 @@ lar_solver * create_lar_solver_from_file(std::string file_name, argument_parser
|
||||||
}
|
}
|
||||||
return reader.create_lar_solver();
|
return reader.create_lar_solver();
|
||||||
}
|
}
|
||||||
mps_reader<lean::mpq, lean::mpq> reader(file_name);
|
mps_reader<lp::mpq, lp::mpq> reader(file_name);
|
||||||
reader.read();
|
reader.read();
|
||||||
if (!reader.is_ok()) {
|
if (!reader.is_ok()) {
|
||||||
std::cout << "cannot process " << file_name << std::endl;
|
std::cout << "cannot process " << file_name << std::endl;
|
||||||
|
@ -2478,8 +2495,8 @@ lar_solver * create_lar_solver_from_file(std::string file_name, argument_parser
|
||||||
|
|
||||||
void test_lar_on_file(std::string file_name, argument_parser & args_parser) {
|
void test_lar_on_file(std::string file_name, argument_parser & args_parser) {
|
||||||
lar_solver * solver = create_lar_solver_from_file(file_name, args_parser);
|
lar_solver * solver = create_lar_solver_from_file(file_name, args_parser);
|
||||||
mps_reader<lean::mpq, lean::mpq> reader(file_name);
|
mps_reader<lp::mpq, lp::mpq> reader(file_name);
|
||||||
mps_reader<lean::mpq, lean::mpq> * mps_reader = nullptr;
|
mps_reader<lp::mpq, lp::mpq> * mps_reader = nullptr;
|
||||||
reader.read();
|
reader.read();
|
||||||
if (reader.is_ok()) {
|
if (reader.is_ok()) {
|
||||||
mps_reader = & reader;
|
mps_reader = & reader;
|
||||||
|
@ -2524,28 +2541,28 @@ void test_lar_solver(argument_parser & args_parser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_numeric_pair() {
|
void test_numeric_pair() {
|
||||||
numeric_pair<lean::mpq> a;
|
numeric_pair<lp::mpq> a;
|
||||||
numeric_pair<lean::mpq> b(2, lean::mpq(6, 2));
|
numeric_pair<lp::mpq> b(2, lp::mpq(6, 2));
|
||||||
a = b;
|
a = b;
|
||||||
numeric_pair<lean::mpq> c(0.1, 0.5);
|
numeric_pair<lp::mpq> c(0.1, 0.5);
|
||||||
a += 2*c;
|
a += 2*c;
|
||||||
a -= c;
|
a -= c;
|
||||||
lean_assert (a == b + c);
|
SASSERT (a == b + c);
|
||||||
numeric_pair<lean::mpq> d = a * 2;
|
numeric_pair<lp::mpq> d = a * 2;
|
||||||
std::cout << a << std::endl;
|
std::cout << a << std::endl;
|
||||||
lean_assert(b == b);
|
SASSERT(b == b);
|
||||||
lean_assert(b < a);
|
SASSERT(b < a);
|
||||||
lean_assert(b <= a);
|
SASSERT(b <= a);
|
||||||
lean_assert(a > b);
|
SASSERT(a > b);
|
||||||
lean_assert(a != b);
|
SASSERT(a != b);
|
||||||
lean_assert(a >= b);
|
SASSERT(a >= b);
|
||||||
lean_assert(-a < b);
|
SASSERT(-a < b);
|
||||||
lean_assert(a < 2 * b);
|
SASSERT(a < 2 * b);
|
||||||
lean_assert(b + b > a);
|
SASSERT(b + b > a);
|
||||||
lean_assert(lean::mpq(2.1) * b + b > a);
|
SASSERT(lp::mpq(2.1) * b + b > a);
|
||||||
lean_assert(-b * lean::mpq(2.1) - b < lean::mpq(0.99) * a);
|
SASSERT(-b * lp::mpq(2.1) - b < lp::mpq(0.99) * a);
|
||||||
std::cout << - b * lean::mpq(2.1) - b << std::endl;
|
std::cout << - b * lp::mpq(2.1) - b << std::endl;
|
||||||
lean_assert(-b *(lean::mpq(2.1) + 1) == - b * lean::mpq(2.1) - b);
|
SASSERT(-b *(lp::mpq(2.1) + 1) == - b * lp::mpq(2.1) - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_matrix_dimensions(std::ifstream & f, unsigned & m, unsigned & n) {
|
void get_matrix_dimensions(std::ifstream & f, unsigned & m, unsigned & n) {
|
||||||
|
@ -2566,7 +2583,7 @@ void read_row_cols(unsigned i, static_matrix<double, double>& A, std::ifstream &
|
||||||
if (line== "row_end")
|
if (line== "row_end")
|
||||||
break;
|
break;
|
||||||
auto r = split_and_trim(line);
|
auto r = split_and_trim(line);
|
||||||
lean_assert(r.size() == 4);
|
SASSERT(r.size() == 4);
|
||||||
unsigned j = atoi(r[1].c_str());
|
unsigned j = atoi(r[1].c_str());
|
||||||
double v = atof(r[3].c_str());
|
double v = atof(r[3].c_str());
|
||||||
A.set(i, j, v);
|
A.set(i, j, v);
|
||||||
|
@ -2594,7 +2611,7 @@ void read_basis(vector<unsigned> & basis, std::ifstream & f) {
|
||||||
std::cout << "reading basis" << std::endl;
|
std::cout << "reading basis" << std::endl;
|
||||||
std::string line;
|
std::string line;
|
||||||
getline(f, line);
|
getline(f, line);
|
||||||
lean_assert(line == "basis_start");
|
SASSERT(line == "basis_start");
|
||||||
do {
|
do {
|
||||||
getline(f, line);
|
getline(f, line);
|
||||||
if (line == "basis_end")
|
if (line == "basis_end")
|
||||||
|
@ -2607,7 +2624,7 @@ void read_basis(vector<unsigned> & basis, std::ifstream & f) {
|
||||||
void read_indexed_vector(indexed_vector<double> & v, std::ifstream & f) {
|
void read_indexed_vector(indexed_vector<double> & v, std::ifstream & f) {
|
||||||
std::string line;
|
std::string line;
|
||||||
getline(f, line);
|
getline(f, line);
|
||||||
lean_assert(line == "vector_start");
|
SASSERT(line == "vector_start");
|
||||||
do {
|
do {
|
||||||
getline(f, line);
|
getline(f, line);
|
||||||
if (line == "vector_end") break;
|
if (line == "vector_end") break;
|
||||||
|
@ -2641,13 +2658,13 @@ void check_lu_from_file(std::string lufile_name) {
|
||||||
indexed_vector<double> d(A.row_count());
|
indexed_vector<double> d(A.row_count());
|
||||||
unsigned entering = 26;
|
unsigned entering = 26;
|
||||||
lsuhl.solve_Bd(entering, d, v);
|
lsuhl.solve_Bd(entering, d, v);
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
auto B = get_B(lsuhl, basis);
|
auto B = get_B(lsuhl, basis);
|
||||||
vector<double> a(m);
|
vector<double> a(m);
|
||||||
A.copy_column_to_vector(entering, a);
|
A.copy_column_to_vector(entering, a);
|
||||||
indexed_vector<double> cd(d);
|
indexed_vector<double> cd(d);
|
||||||
B.apply_from_left(cd.m_data, settings);
|
B.apply_from_left(cd.m_data, settings);
|
||||||
lean_assert(vectors_are_equal(cd.m_data , a));
|
SASSERT(vectors_are_equal(cd.m_data , a));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2662,7 +2679,7 @@ void test_square_dense_submatrix() {
|
||||||
for (unsigned i = index_start; i < parent_dim; i++)
|
for (unsigned i = index_start; i < parent_dim; i++)
|
||||||
for (unsigned j = index_start; j < parent_dim; j++)
|
for (unsigned j = index_start; j < parent_dim; j++)
|
||||||
d[i][j] = i*3+j*2;
|
d[i][j] = i*3+j*2;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
unsigned dim = parent_dim - index_start;
|
unsigned dim = parent_dim - index_start;
|
||||||
dense_matrix<double, double> m(dim, dim);
|
dense_matrix<double, double> m(dim, dim);
|
||||||
for (unsigned i = index_start; i < parent_dim; i++)
|
for (unsigned i = index_start; i < parent_dim; i++)
|
||||||
|
@ -2673,7 +2690,7 @@ void test_square_dense_submatrix() {
|
||||||
for (unsigned i = index_start; i < parent_dim; i++)
|
for (unsigned i = index_start; i < parent_dim; i++)
|
||||||
for (unsigned j = index_start; j < parent_dim; j++)
|
for (unsigned j = index_start; j < parent_dim; j++)
|
||||||
d[i][j] = d[j][i];
|
d[i][j] = d[j][i];
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
for (unsigned i = index_start; i < parent_dim; i++)
|
for (unsigned i = index_start; i < parent_dim; i++)
|
||||||
for (unsigned j = index_start; j < parent_dim; j++)
|
for (unsigned j = index_start; j < parent_dim; j++)
|
||||||
m[i-index_start][j-index_start] = d[i][j];
|
m[i-index_start][j-index_start] = d[i][j];
|
||||||
|
@ -2738,7 +2755,7 @@ void test_evidence_for_total_inf_simple(argument_parser & args_parser) {
|
||||||
auto status = solver.solve();
|
auto status = solver.solve();
|
||||||
std::cout << lp_status_to_string(status) << std::endl;
|
std::cout << lp_status_to_string(status) << std::endl;
|
||||||
std::unordered_map<var_index, mpq> model;
|
std::unordered_map<var_index, mpq> model;
|
||||||
lean_assert(solver.get_status() == INFEASIBLE);
|
SASSERT(solver.get_status() == INFEASIBLE);
|
||||||
}
|
}
|
||||||
void test_bound_propagation_one_small_sample1() {
|
void test_bound_propagation_one_small_sample1() {
|
||||||
/*
|
/*
|
||||||
|
@ -2934,8 +2951,8 @@ void test_total_case_l(){
|
||||||
ls.solve();
|
ls.solve();
|
||||||
lp_bound_propagator bp(ls);
|
lp_bound_propagator bp(ls);
|
||||||
ls.propagate_bounds_for_touched_rows(bp);
|
ls.propagate_bounds_for_touched_rows(bp);
|
||||||
lean_assert(ev.size() == 4);
|
SASSERT(ev.size() == 4);
|
||||||
lean_assert(contains_j_kind(x, GE, - one_of_type<mpq>(), ev));
|
SASSERT(contains_j_kind(x, GE, - one_of_type<mpq>(), ev));
|
||||||
}
|
}
|
||||||
void test_bound_propagation() {
|
void test_bound_propagation() {
|
||||||
test_total_case_u();
|
test_total_case_u();
|
||||||
|
@ -2955,17 +2972,17 @@ void test_int_set() {
|
||||||
s.insert(1);
|
s.insert(1);
|
||||||
s.insert(2);
|
s.insert(2);
|
||||||
s.print(std::cout);
|
s.print(std::cout);
|
||||||
lean_assert(s.contains(2));
|
SASSERT(s.contains(2));
|
||||||
lean_assert(s.size() == 2);
|
SASSERT(s.size() == 2);
|
||||||
s.erase(2);
|
s.erase(2);
|
||||||
lean_assert(s.size() == 1);
|
SASSERT(s.size() == 1);
|
||||||
s.erase(2);
|
s.erase(2);
|
||||||
lean_assert(s.size() == 1);
|
SASSERT(s.size() == 1);
|
||||||
s.print(std::cout);
|
s.print(std::cout);
|
||||||
s.insert(3);
|
s.insert(3);
|
||||||
s.insert(2);
|
s.insert(2);
|
||||||
s.clear();
|
s.clear();
|
||||||
lean_assert(s.size() == 0);
|
SASSERT(s.size() == 0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3112,7 +3129,7 @@ void test_lp_local(int argn, char**argv) {
|
||||||
return finalize(0);
|
return finalize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
if (args_parser.option_is_used("--test_swaps")) {
|
if (args_parser.option_is_used("--test_swaps")) {
|
||||||
sparse_matrix<double, double> m(10);
|
sparse_matrix<double, double> m(10);
|
||||||
fill_matrix(m);
|
fill_matrix(m);
|
||||||
|
@ -3142,7 +3159,7 @@ void test_lp_local(int argn, char**argv) {
|
||||||
return finalize(ret);
|
return finalize(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
lp_settings settings;
|
lp_settings settings;
|
||||||
update_settings(args_parser, settings);
|
update_settings(args_parser, settings);
|
||||||
if (args_parser.option_is_used("--test_lu")) {
|
if (args_parser.option_is_used("--test_lu")) {
|
||||||
|
@ -3219,11 +3236,11 @@ void test_lp_local(int argn, char**argv) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
return finalize(ret);
|
return finalize(ret);
|
||||||
}
|
}
|
||||||
// lean::ccc = 0;
|
// lp::ccc = 0;
|
||||||
return finalize(0);
|
return finalize(0);
|
||||||
test_init_U();
|
test_init_U();
|
||||||
test_replace_column();
|
test_replace_column();
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
sparse_matrix_with_permutaions_test();
|
sparse_matrix_with_permutaions_test();
|
||||||
test_dense_matrix();
|
test_dense_matrix();
|
||||||
test_swap_operations();
|
test_swap_operations();
|
||||||
|
@ -3236,5 +3253,5 @@ void test_lp_local(int argn, char**argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void tst_lp(char ** argv, int argc, int& i) {
|
void tst_lp(char ** argv, int argc, int& i) {
|
||||||
lean::test_lp_local(argc - 2, argv + 2);
|
lp::test_lp_local(argc - 2, argv + 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,20 +16,20 @@
|
||||||
// and print "PASS" to indicate success.
|
// and print "PASS" to indicate success.
|
||||||
//
|
//
|
||||||
|
|
||||||
#define TST(MODULE) { \
|
#define TST(MODULE) { \
|
||||||
std::string s("test "); \
|
std::string s("test "); \
|
||||||
s += #MODULE; \
|
s += #MODULE; \
|
||||||
void tst_##MODULE(); \
|
void tst_##MODULE(); \
|
||||||
if (do_display_usage) \
|
if (do_display_usage) \
|
||||||
std::cout << #MODULE << "\n"; \
|
std::cout << #MODULE << "\n"; \
|
||||||
for (int i = 0; i < argc; i++) \
|
for (int i = 0; i < argc; i++) \
|
||||||
if (test_all || strcmp(argv[i], #MODULE) == 0) { \
|
if (test_all || strcmp(argv[i], #MODULE) == 0) { \
|
||||||
enable_trace(#MODULE); \
|
enable_trace(#MODULE); \
|
||||||
enable_debug(#MODULE); \
|
enable_debug(#MODULE); \
|
||||||
timeit timeit(true, s.c_str()); \
|
timeit timeit(true, s.c_str()); \
|
||||||
tst_##MODULE(); \
|
tst_##MODULE(); \
|
||||||
std::cout << "PASS" << std::endl; \
|
std::cout << "PASS" << std::endl; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TST_ARGV(MODULE) { \
|
#define TST_ARGV(MODULE) { \
|
||||||
|
@ -39,13 +39,13 @@
|
||||||
if (do_display_usage) \
|
if (do_display_usage) \
|
||||||
std::cout << #MODULE << "\n"; \
|
std::cout << #MODULE << "\n"; \
|
||||||
for (int i = 0; i < argc; i++) \
|
for (int i = 0; i < argc; i++) \
|
||||||
if (strcmp(argv[i], #MODULE) == 0) { \
|
if (strcmp(argv[i], #MODULE) == 0) { \
|
||||||
enable_trace(#MODULE); \
|
enable_trace(#MODULE); \
|
||||||
enable_debug(#MODULE); \
|
enable_debug(#MODULE); \
|
||||||
timeit timeit(true, s.c_str()); \
|
timeit timeit(true, s.c_str()); \
|
||||||
tst_##MODULE(argv, argc, i); \
|
tst_##MODULE(argv, argc, i); \
|
||||||
std::cout << "PASS" << std::endl; \
|
std::cout << "PASS" << std::endl; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
void error(const char * msg) {
|
void error(const char * msg) {
|
||||||
|
@ -76,49 +76,49 @@ void display_usage() {
|
||||||
void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& test_all) {
|
void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& test_all) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (i < argc) {
|
while (i < argc) {
|
||||||
char * arg = argv[i], *eq_pos = 0;
|
char * arg = argv[i], *eq_pos = 0;
|
||||||
|
|
||||||
if (arg[0] == '-' || arg[0] == '/') {
|
if (arg[0] == '-' || arg[0] == '/') {
|
||||||
char * opt_name = arg + 1;
|
char * opt_name = arg + 1;
|
||||||
char * opt_arg = 0;
|
char * opt_arg = 0;
|
||||||
char * colon = strchr(arg, ':');
|
char * colon = strchr(arg, ':');
|
||||||
if (colon) {
|
if (colon) {
|
||||||
opt_arg = colon + 1;
|
opt_arg = colon + 1;
|
||||||
*colon = 0;
|
*colon = 0;
|
||||||
}
|
}
|
||||||
if (strcmp(opt_name, "h") == 0 ||
|
if (strcmp(opt_name, "h") == 0 ||
|
||||||
strcmp(opt_name, "?") == 0) {
|
strcmp(opt_name, "?") == 0) {
|
||||||
display_usage();
|
display_usage();
|
||||||
do_display_usage = true;
|
do_display_usage = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (strcmp(opt_name, "v") == 0) {
|
else if (strcmp(opt_name, "v") == 0) {
|
||||||
if (!opt_arg)
|
if (!opt_arg)
|
||||||
error("option argument (/v:level) is missing.");
|
error("option argument (/v:level) is missing.");
|
||||||
long lvl = strtol(opt_arg, 0, 10);
|
long lvl = strtol(opt_arg, 0, 10);
|
||||||
set_verbosity_level(lvl);
|
set_verbosity_level(lvl);
|
||||||
}
|
}
|
||||||
else if (strcmp(opt_name, "w") == 0) {
|
else if (strcmp(opt_name, "w") == 0) {
|
||||||
enable_warning_messages(true);
|
enable_warning_messages(true);
|
||||||
}
|
}
|
||||||
else if (strcmp(opt_name, "a") == 0) {
|
else if (strcmp(opt_name, "a") == 0) {
|
||||||
test_all = true;
|
test_all = true;
|
||||||
}
|
}
|
||||||
#ifdef _TRACE
|
#ifdef _TRACE
|
||||||
else if (strcmp(opt_name, "tr") == 0) {
|
else if (strcmp(opt_name, "tr") == 0) {
|
||||||
if (!opt_arg)
|
if (!opt_arg)
|
||||||
error("option argument (/tr:tag) is missing.");
|
error("option argument (/tr:tag) is missing.");
|
||||||
enable_trace(opt_arg);
|
enable_trace(opt_arg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Z3DEBUG
|
#ifdef Z3DEBUG
|
||||||
else if (strcmp(opt_name, "dbg") == 0) {
|
else if (strcmp(opt_name, "dbg") == 0) {
|
||||||
if (!opt_arg)
|
if (!opt_arg)
|
||||||
error("option argument (/dbg:tag) is missing.");
|
error("option argument (/dbg:tag) is missing.");
|
||||||
enable_debug(opt_arg);
|
enable_debug(opt_arg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (arg[0] != '"' && (eq_pos = strchr(arg, '='))) {
|
else if (arg[0] != '"' && (eq_pos = strchr(arg, '='))) {
|
||||||
char * key = arg;
|
char * key = arg;
|
||||||
*eq_pos = 0;
|
*eq_pos = 0;
|
||||||
|
@ -130,7 +130,7 @@ void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& t
|
||||||
std::cerr << ex.msg() << "\n";
|
std::cerr << ex.msg() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ static void add_random_ineq(opt::model_based_opt& mbo,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
unsigned sign = r(2);
|
unsigned sign = r(2);
|
||||||
coeff = sign == 0 ? coeff : -coeff;
|
coeff = sign == 0 ? coeff : -coeff;
|
||||||
vars.push_back(var(x, rational(coeff)));
|
vars.push_back(var(x, rational(coeff)));
|
||||||
value += coeff*values[x];
|
value += coeff*values[x];
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ struct OptFoo {
|
||||||
int m_y;
|
int m_y;
|
||||||
|
|
||||||
OptFoo(int x, int y):m_x(x), m_y(y) {
|
OptFoo(int x, int y):m_x(x), m_y(y) {
|
||||||
TRACE("optional", tout << "OptFoo created: " << m_x << " : " << m_y << "\n";);
|
TRACE("optional", tout << "OptFoo created: " << m_x << " : " << m_y << "\n";);
|
||||||
}
|
}
|
||||||
|
|
||||||
~OptFoo() {
|
~OptFoo() {
|
||||||
TRACE("optional", tout << "OptFoo deleted: " << m_x << " : " << m_y << "\n";);
|
TRACE("optional", tout << "OptFoo deleted: " << m_x << " : " << m_y << "\n";);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,22 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Released under Apache 2.0 license as described in the file LICENSE.
|
|
||||||
|
|
||||||
Author: Lev Nachmanson
|
Module Name:
|
||||||
*/
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -23,7 +36,7 @@
|
||||||
#include "util/lp/lar_constraints.h"
|
#include "util/lp/lar_constraints.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
namespace lean {
|
namespace lp {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T from_string(const std::string& str) {
|
T from_string(const std::string& str) {
|
||||||
|
@ -108,13 +121,13 @@ namespace lean {
|
||||||
|
|
||||||
void fill_simple_elem(lisp_elem & lm) {
|
void fill_simple_elem(lisp_elem & lm) {
|
||||||
int separator = first_separator();
|
int separator = first_separator();
|
||||||
lean_assert(-1 != separator && separator != 0);
|
SASSERT(-1 != separator && separator != 0);
|
||||||
lm.m_head = m_line.substr(0, separator);
|
lm.m_head = m_line.substr(0, separator);
|
||||||
m_line = m_line.substr(separator);
|
m_line = m_line.substr(separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_nested_elem(lisp_elem & lm) {
|
void fill_nested_elem(lisp_elem & lm) {
|
||||||
lean_assert(m_line[0] == '(');
|
SASSERT(m_line[0] == '(');
|
||||||
m_line = m_line.substr(1);
|
m_line = m_line.substr(1);
|
||||||
int separator = first_separator();
|
int separator = first_separator();
|
||||||
lm.m_head = m_line.substr(0, separator);
|
lm.m_head = m_line.substr(0, separator);
|
||||||
|
@ -181,11 +194,11 @@ namespace lean {
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjust_rigth_side(formula_constraint & /* c*/, lisp_elem & /*el*/) {
|
void adjust_rigth_side(formula_constraint & /* c*/, lisp_elem & /*el*/) {
|
||||||
// lean_assert(el.m_head == "0"); // do nothing for the time being
|
// SASSERT(el.m_head == "0"); // do nothing for the time being
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_constraint_coeffs(formula_constraint & c, lisp_elem & el) {
|
void set_constraint_coeffs(formula_constraint & c, lisp_elem & el) {
|
||||||
lean_assert(el.m_elems.size() == 2);
|
SASSERT(el.m_elems.size() == 2);
|
||||||
set_constraint_coeffs_on_coeff_element(c, el.m_elems[0]);
|
set_constraint_coeffs_on_coeff_element(c, el.m_elems[0]);
|
||||||
adjust_rigth_side(c, el.m_elems[1]);
|
adjust_rigth_side(c, el.m_elems[1]);
|
||||||
}
|
}
|
||||||
|
@ -201,7 +214,7 @@ namespace lean {
|
||||||
add_mult_elem(c, el.m_elems);
|
add_mult_elem(c, el.m_elems);
|
||||||
} else if (el.m_head == "~") {
|
} else if (el.m_head == "~") {
|
||||||
lisp_elem & minel = el.m_elems[0];
|
lisp_elem & minel = el.m_elems[0];
|
||||||
lean_assert(minel.is_simple());
|
SASSERT(minel.is_simple());
|
||||||
c.m_right_side += mpq(str_to_int(minel.m_head));
|
c.m_right_side += mpq(str_to_int(minel.m_head));
|
||||||
} else {
|
} else {
|
||||||
std::cout << "unexpected input " << el.m_head << std::endl;
|
std::cout << "unexpected input " << el.m_head << std::endl;
|
||||||
|
@ -211,14 +224,14 @@ namespace lean {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_name(lisp_elem & name) {
|
std::string get_name(lisp_elem & name) {
|
||||||
lean_assert(name.is_simple());
|
SASSERT(name.is_simple());
|
||||||
lean_assert(!is_integer(name.m_head));
|
SASSERT(!is_integer(name.m_head));
|
||||||
return name.m_head;
|
return name.m_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void add_mult_elem(formula_constraint & c, std::vector<lisp_elem> & els) {
|
void add_mult_elem(formula_constraint & c, std::vector<lisp_elem> & els) {
|
||||||
lean_assert(els.size() == 2);
|
SASSERT(els.size() == 2);
|
||||||
mpq coeff = get_coeff(els[0]);
|
mpq coeff = get_coeff(els[0]);
|
||||||
std::string col_name = get_name(els[1]);
|
std::string col_name = get_name(els[1]);
|
||||||
c.add_pair(coeff, col_name);
|
c.add_pair(coeff, col_name);
|
||||||
|
@ -228,16 +241,16 @@ namespace lean {
|
||||||
if (le.is_simple()) {
|
if (le.is_simple()) {
|
||||||
return mpq(str_to_int(le.m_head));
|
return mpq(str_to_int(le.m_head));
|
||||||
} else {
|
} else {
|
||||||
lean_assert(le.m_head == "~");
|
SASSERT(le.m_head == "~");
|
||||||
lean_assert(le.size() == 1);
|
SASSERT(le.size() == 1);
|
||||||
lisp_elem & el = le.m_elems[0];
|
lisp_elem & el = le.m_elems[0];
|
||||||
lean_assert(el.is_simple());
|
SASSERT(el.is_simple());
|
||||||
return -mpq(str_to_int(el.m_head));
|
return -mpq(str_to_int(el.m_head));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int str_to_int(std::string & s) {
|
int str_to_int(std::string & s) {
|
||||||
lean_assert(is_integer(s));
|
SASSERT(is_integer(s));
|
||||||
return atoi(s.c_str());
|
return atoi(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +258,7 @@ namespace lean {
|
||||||
if (el.size()) {
|
if (el.size()) {
|
||||||
add_complex_sum_elem(c, el);
|
add_complex_sum_elem(c, el);
|
||||||
} else {
|
} else {
|
||||||
lean_assert(is_integer(el.m_head));
|
SASSERT(is_integer(el.m_head));
|
||||||
int v = atoi(el.m_head.c_str());
|
int v = atoi(el.m_head.c_str());
|
||||||
mpq vr(v);
|
mpq vr(v);
|
||||||
c.m_right_side -= vr;
|
c.m_right_side -= vr;
|
||||||
|
@ -263,7 +276,7 @@ namespace lean {
|
||||||
} else if (el.m_head == "+") {
|
} else if (el.m_head == "+") {
|
||||||
add_sum(c, el.m_elems);
|
add_sum(c, el.m_elems);
|
||||||
} else {
|
} else {
|
||||||
lean_assert(false); // unexpected input
|
SASSERT(false); // unexpected input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,23 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Released under Apache 2.0 license as described in the file LICENSE.
|
|
||||||
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// reads a text file
|
// reads a text file
|
||||||
|
@ -15,7 +29,7 @@ Author: Lev Nachmanson
|
||||||
#include "util/lp/lp_utils.h"
|
#include "util/lp/lp_utils.h"
|
||||||
#include "util/lp/lp_solver.h"
|
#include "util/lp/lp_solver.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lp {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct test_result {
|
struct test_result {
|
||||||
|
|
|
@ -201,7 +201,7 @@ public:
|
||||||
m_todo.push_back(d);
|
m_todo.push_back(d);
|
||||||
unsigned qhead = 0;
|
unsigned qhead = 0;
|
||||||
while (qhead < m_todo.size()) {
|
while (qhead < m_todo.size()) {
|
||||||
d = m_todo[qhead];
|
d = m_todo[qhead];
|
||||||
qhead++;
|
qhead++;
|
||||||
if (d->is_leaf()) {
|
if (d->is_leaf()) {
|
||||||
vs.push_back(to_leaf(d)->m_value);
|
vs.push_back(to_leaf(d)->m_value);
|
||||||
|
|
|
@ -236,7 +236,7 @@ template<typename T>
|
||||||
struct ptr_hash {
|
struct ptr_hash {
|
||||||
typedef T * data;
|
typedef T * data;
|
||||||
unsigned operator()(T * ptr) const {
|
unsigned operator()(T * ptr) const {
|
||||||
return get_ptr_hash(ptr);
|
return get_ptr_hash(ptr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -119,12 +119,12 @@ class inf_eps_rational {
|
||||||
bool is_rational() const { return m_infty.is_zero() && m_r.is_rational(); }
|
bool is_rational() const { return m_infty.is_zero() && m_r.is_rational(); }
|
||||||
|
|
||||||
int64 get_int64() const {
|
int64 get_int64() const {
|
||||||
SASSERT(is_int64());
|
SASSERT(is_int64());
|
||||||
return m_r.get_int64();
|
return m_r.get_int64();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 get_uint64() const {
|
uint64 get_uint64() const {
|
||||||
SASSERT(is_uint64());
|
SASSERT(is_uint64());
|
||||||
return m_r.get_uint64();
|
return m_r.get_uint64();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,45 +168,45 @@ class inf_eps_rational {
|
||||||
inf_eps_rational & operator=(const inf_eps_rational & r) {
|
inf_eps_rational & operator=(const inf_eps_rational & r) {
|
||||||
m_infty = r.m_infty;
|
m_infty = r.m_infty;
|
||||||
m_r = r.m_r;
|
m_r = r.m_r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_eps_rational & operator=(const Numeral & r) {
|
inf_eps_rational & operator=(const Numeral & r) {
|
||||||
m_infty.reset();
|
m_infty.reset();
|
||||||
m_r = r;
|
m_r = r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_eps_rational & operator+=(const inf_eps_rational & r) {
|
inf_eps_rational & operator+=(const inf_eps_rational & r) {
|
||||||
m_infty += r.m_infty;
|
m_infty += r.m_infty;
|
||||||
m_r += r.m_r;
|
m_r += r.m_r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_eps_rational & operator-=(const inf_eps_rational & r) {
|
inf_eps_rational & operator-=(const inf_eps_rational & r) {
|
||||||
m_infty -= r.m_infty;
|
m_infty -= r.m_infty;
|
||||||
m_r -= r.m_r;
|
m_r -= r.m_r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_eps_rational & operator-=(const inf_rational & r) {
|
inf_eps_rational & operator-=(const inf_rational & r) {
|
||||||
m_r -= r;
|
m_r -= r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_eps_rational & operator+=(const inf_rational & r) {
|
inf_eps_rational & operator+=(const inf_rational & r) {
|
||||||
m_r += r;
|
m_r += r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_eps_rational & operator+=(const rational & r) {
|
inf_eps_rational & operator+=(const rational & r) {
|
||||||
m_r += r;
|
m_r += r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_eps_rational & operator-=(const rational & r) {
|
inf_eps_rational & operator-=(const rational & r) {
|
||||||
m_r -= r;
|
m_r -= r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_eps_rational & operator*=(const rational & r1) {
|
inf_eps_rational & operator*=(const rational & r1) {
|
||||||
|
|
|
@ -110,12 +110,12 @@ class inf_int_rational {
|
||||||
bool is_rational() const { return m_second == 0; }
|
bool is_rational() const { return m_second == 0; }
|
||||||
|
|
||||||
int64 get_int64() const {
|
int64 get_int64() const {
|
||||||
SASSERT(is_int64());
|
SASSERT(is_int64());
|
||||||
return m_first.get_int64();
|
return m_first.get_int64();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 get_uint64() const {
|
uint64 get_uint64() const {
|
||||||
SASSERT(is_uint64());
|
SASSERT(is_uint64());
|
||||||
return m_first.get_uint64();
|
return m_first.get_uint64();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class inf_int_rational {
|
||||||
inf_int_rational & operator=(const inf_int_rational & r) {
|
inf_int_rational & operator=(const inf_int_rational & r) {
|
||||||
m_first = r.m_first;
|
m_first = r.m_first;
|
||||||
m_second = r.m_second;
|
m_second = r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_int_rational & operator=(const rational & r) {
|
inf_int_rational & operator=(const rational & r) {
|
||||||
|
@ -154,7 +154,7 @@ class inf_int_rational {
|
||||||
inf_int_rational & operator+=(const inf_int_rational & r) {
|
inf_int_rational & operator+=(const inf_int_rational & r) {
|
||||||
m_first += r.m_first;
|
m_first += r.m_first;
|
||||||
m_second += r.m_second;
|
m_second += r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_int_rational & operator*=(const rational & r) {
|
inf_int_rational & operator*=(const rational & r) {
|
||||||
|
@ -163,7 +163,7 @@ class inf_int_rational {
|
||||||
}
|
}
|
||||||
m_first *= r;
|
m_first *= r;
|
||||||
m_second *= r.get_int32();
|
m_second *= r.get_int32();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,17 +171,17 @@ class inf_int_rational {
|
||||||
inf_int_rational & operator-=(const inf_int_rational & r) {
|
inf_int_rational & operator-=(const inf_int_rational & r) {
|
||||||
m_first -= r.m_first;
|
m_first -= r.m_first;
|
||||||
m_second -= r.m_second;
|
m_second -= r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_int_rational & operator+=(const rational & r) {
|
inf_int_rational & operator+=(const rational & r) {
|
||||||
m_first += r;
|
m_first += r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_int_rational & operator-=(const rational & r) {
|
inf_int_rational & operator-=(const rational & r) {
|
||||||
m_first -= r;
|
m_first -= r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_int_rational & operator++() {
|
inf_int_rational & operator++() {
|
||||||
|
|
|
@ -123,12 +123,12 @@ class inf_rational {
|
||||||
bool is_rational() const { return m_second.is_zero(); }
|
bool is_rational() const { return m_second.is_zero(); }
|
||||||
|
|
||||||
int64 get_int64() const {
|
int64 get_int64() const {
|
||||||
SASSERT(is_int64());
|
SASSERT(is_int64());
|
||||||
return m_first.get_int64();
|
return m_first.get_int64();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 get_uint64() const {
|
uint64 get_uint64() const {
|
||||||
SASSERT(is_uint64());
|
SASSERT(is_uint64());
|
||||||
return m_first.get_uint64();
|
return m_first.get_uint64();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class inf_rational {
|
||||||
inf_rational & operator=(const inf_rational & r) {
|
inf_rational & operator=(const inf_rational & r) {
|
||||||
m_first = r.m_first;
|
m_first = r.m_first;
|
||||||
m_second = r.m_second;
|
m_second = r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_rational & operator=(const rational & r) {
|
inf_rational & operator=(const rational & r) {
|
||||||
|
@ -167,23 +167,23 @@ class inf_rational {
|
||||||
inf_rational & operator+=(const inf_rational & r) {
|
inf_rational & operator+=(const inf_rational & r) {
|
||||||
m_first += r.m_first;
|
m_first += r.m_first;
|
||||||
m_second += r.m_second;
|
m_second += r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_rational & operator-=(const inf_rational & r) {
|
inf_rational & operator-=(const inf_rational & r) {
|
||||||
m_first -= r.m_first;
|
m_first -= r.m_first;
|
||||||
m_second -= r.m_second;
|
m_second -= r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_rational & operator+=(const rational & r) {
|
inf_rational & operator+=(const rational & r) {
|
||||||
m_first += r;
|
m_first += r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_rational & operator-=(const rational & r) {
|
inf_rational & operator-=(const rational & r) {
|
||||||
m_first -= r;
|
m_first -= r;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inf_rational & operator*=(const rational & r1) {
|
inf_rational & operator*=(const rational & r1) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ class inf_s_integer {
|
||||||
inf_s_integer & operator=(const inf_s_integer & r) {
|
inf_s_integer & operator=(const inf_s_integer & r) {
|
||||||
m_first = r.m_first;
|
m_first = r.m_first;
|
||||||
m_second = r.m_second;
|
m_second = r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inf_s_integer & operator=(const rational & r) {
|
inf_s_integer & operator=(const rational & r) {
|
||||||
m_first = static_cast<int>(r.get_int64());
|
m_first = static_cast<int>(r.get_int64());
|
||||||
|
@ -90,20 +90,20 @@ class inf_s_integer {
|
||||||
inf_s_integer & operator+=(const inf_s_integer & r) {
|
inf_s_integer & operator+=(const inf_s_integer & r) {
|
||||||
m_first += r.m_first;
|
m_first += r.m_first;
|
||||||
m_second += r.m_second;
|
m_second += r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inf_s_integer & operator-=(const inf_s_integer & r) {
|
inf_s_integer & operator-=(const inf_s_integer & r) {
|
||||||
m_first -= r.m_first;
|
m_first -= r.m_first;
|
||||||
m_second -= r.m_second;
|
m_second -= r.m_second;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inf_s_integer & operator+=(const s_integer & r) {
|
inf_s_integer & operator+=(const s_integer & r) {
|
||||||
m_first += r.get_int();
|
m_first += r.get_int();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inf_s_integer & operator-=(const s_integer & r) {
|
inf_s_integer & operator-=(const s_integer & r) {
|
||||||
m_first -= r.get_int();
|
m_first -= r.get_int();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inf_s_integer & operator*=(const s_integer & r1) {
|
inf_s_integer & operator*=(const s_integer & r1) {
|
||||||
m_first *= r1.get_int();
|
m_first *= r1.get_int();
|
||||||
|
|
|
@ -19,7 +19,7 @@ z3_add_component(lp
|
||||||
lu_instances.cpp
|
lu_instances.cpp
|
||||||
matrix_instances.cpp
|
matrix_instances.cpp
|
||||||
permutation_matrix_instances.cpp
|
permutation_matrix_instances.cpp
|
||||||
quick_xplain.cpp
|
quick_xplain.cpp
|
||||||
row_eta_matrix_instances.cpp
|
row_eta_matrix_instances.cpp
|
||||||
scaler_instances.cpp
|
scaler_instances.cpp
|
||||||
sparse_matrix_instances.cpp
|
sparse_matrix_instances.cpp
|
||||||
|
|
|
@ -1,13 +1,28 @@
|
||||||
|
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
#include "util/lp/lp_utils.h"
|
#include "util/lp/lp_utils.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
// the elements with the smallest priority are dequeued first
|
// the elements with the smallest priority are dequeued first
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class binary_heap_priority_queue {
|
class binary_heap_priority_queue {
|
||||||
|
@ -22,7 +37,7 @@ class binary_heap_priority_queue {
|
||||||
void put_at(unsigned i, unsigned h);
|
void put_at(unsigned i, unsigned h);
|
||||||
void decrease_priority(unsigned o, T newPriority);
|
void decrease_priority(unsigned o, T newPriority);
|
||||||
public:
|
public:
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
bool is_consistent() const;
|
bool is_consistent() const;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
|
@ -60,10 +75,10 @@ public:
|
||||||
/// return the first element of the queue and removes it from the queue
|
/// return the first element of the queue and removes it from the queue
|
||||||
unsigned dequeue();
|
unsigned dequeue();
|
||||||
unsigned peek() const {
|
unsigned peek() const {
|
||||||
lean_assert(m_heap_size > 0);
|
SASSERT(m_heap_size > 0);
|
||||||
return m_heap[1];
|
return m_heap[1];
|
||||||
}
|
}
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
void print(std::ostream & out);
|
void print(std::ostream & out);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
#include "util/lp/binary_heap_priority_queue.h"
|
#include "util/lp/binary_heap_priority_queue.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
// is is the child place in heap
|
// this is the child place in the heap
|
||||||
template <typename T> void binary_heap_priority_queue<T>::swap_with_parent(unsigned i) {
|
template <typename T> void binary_heap_priority_queue<T>::swap_with_parent(unsigned i) {
|
||||||
unsigned parent = m_heap[i >> 1];
|
unsigned parent = m_heap[i >> 1];
|
||||||
put_at(i >> 1, m_heap[i]);
|
put_at(i >> 1, m_heap[i]);
|
||||||
|
@ -29,12 +44,12 @@ template <typename T> void binary_heap_priority_queue<T>::decrease_priority(unsi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
template <typename T> bool binary_heap_priority_queue<T>::is_consistent() const {
|
template <typename T> bool binary_heap_priority_queue<T>::is_consistent() const {
|
||||||
for (int i = 0; i < m_heap_inverse.size(); i++) {
|
for (int i = 0; i < m_heap_inverse.size(); i++) {
|
||||||
int i_index = m_heap_inverse[i];
|
int i_index = m_heap_inverse[i];
|
||||||
lean_assert(i_index <= static_cast<int>(m_heap_size));
|
SASSERT(i_index <= static_cast<int>(m_heap_size));
|
||||||
lean_assert(i_index == -1 || m_heap[i_index] == i);
|
SASSERT(i_index == -1 || m_heap[i_index] == i);
|
||||||
}
|
}
|
||||||
for (unsigned i = 1; i < m_heap_size; i++) {
|
for (unsigned i = 1; i < m_heap_size; i++) {
|
||||||
unsigned ch = i << 1;
|
unsigned ch = i << 1;
|
||||||
|
@ -49,13 +64,14 @@ template <typename T> bool binary_heap_priority_queue<T>::is_consistent() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename T> void binary_heap_priority_queue<T>::remove(unsigned o) {
|
template <typename T> void binary_heap_priority_queue<T>::remove(unsigned o) {
|
||||||
T priority_of_o = m_priorities[o];
|
T priority_of_o = m_priorities[o];
|
||||||
int o_in_heap = m_heap_inverse[o];
|
int o_in_heap = m_heap_inverse[o];
|
||||||
if (o_in_heap == -1) {
|
if (o_in_heap == -1) {
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
}
|
}
|
||||||
lean_assert(static_cast<unsigned>(o_in_heap) <= m_heap_size);
|
SASSERT(static_cast<unsigned>(o_in_heap) <= m_heap_size);
|
||||||
if (static_cast<unsigned>(o_in_heap) < m_heap_size) {
|
if (static_cast<unsigned>(o_in_heap) < m_heap_size) {
|
||||||
put_at(o_in_heap, m_heap[m_heap_size--]);
|
put_at(o_in_heap, m_heap[m_heap_size--]);
|
||||||
if (m_priorities[m_heap[o_in_heap]] > priority_of_o) {
|
if (m_priorities[m_heap[o_in_heap]] > priority_of_o) {
|
||||||
|
@ -72,11 +88,11 @@ template <typename T> void binary_heap_priority_queue<T>::remove(unsigned o) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lean_assert(static_cast<unsigned>(o_in_heap) == m_heap_size);
|
SASSERT(static_cast<unsigned>(o_in_heap) == m_heap_size);
|
||||||
m_heap_size--;
|
m_heap_size--;
|
||||||
}
|
}
|
||||||
m_heap_inverse[o] = -1;
|
m_heap_inverse[o] = -1;
|
||||||
// lean_assert(is_consistent());
|
// SASSERT(is_consistent());
|
||||||
}
|
}
|
||||||
// n is the initial queue capacity.
|
// n is the initial queue capacity.
|
||||||
// The capacity will be enlarged two times automatically if needed
|
// The capacity will be enlarged two times automatically if needed
|
||||||
|
@ -102,7 +118,7 @@ template <typename T> void binary_heap_priority_queue<T>::put_to_heap(unsigned i
|
||||||
template <typename T> void binary_heap_priority_queue<T>::enqueue_new(unsigned o, const T& priority) {
|
template <typename T> void binary_heap_priority_queue<T>::enqueue_new(unsigned o, const T& priority) {
|
||||||
m_heap_size++;
|
m_heap_size++;
|
||||||
int i = m_heap_size;
|
int i = m_heap_size;
|
||||||
lean_assert(o < m_priorities.size());
|
SASSERT(o < m_priorities.size());
|
||||||
m_priorities[o] = priority;
|
m_priorities[o] = priority;
|
||||||
put_at(i, o);
|
put_at(i, o);
|
||||||
while (i > 1 && m_priorities[m_heap[i >> 1]] > priority) {
|
while (i > 1 && m_priorities[m_heap[i >> 1]] > priority) {
|
||||||
|
@ -134,7 +150,7 @@ template <typename T> void binary_heap_priority_queue<T>::change_priority_for_ex
|
||||||
|
|
||||||
/// return the first element of the queue and removes it from the queue
|
/// return the first element of the queue and removes it from the queue
|
||||||
template <typename T> unsigned binary_heap_priority_queue<T>::dequeue_and_get_priority(T & priority) {
|
template <typename T> unsigned binary_heap_priority_queue<T>::dequeue_and_get_priority(T & priority) {
|
||||||
lean_assert(m_heap_size != 0);
|
SASSERT(m_heap_size != 0);
|
||||||
int ret = m_heap[1];
|
int ret = m_heap[1];
|
||||||
priority = m_priorities[ret];
|
priority = m_priorities[ret];
|
||||||
put_the_last_at_the_top_and_fix_the_heap();
|
put_the_last_at_the_top_and_fix_the_heap();
|
||||||
|
@ -168,13 +184,13 @@ template <typename T> void binary_heap_priority_queue<T>::put_the_last_at_the_to
|
||||||
}
|
}
|
||||||
/// return the first element of the queue and removes it from the queue
|
/// return the first element of the queue and removes it from the queue
|
||||||
template <typename T> unsigned binary_heap_priority_queue<T>::dequeue() {
|
template <typename T> unsigned binary_heap_priority_queue<T>::dequeue() {
|
||||||
lean_assert(m_heap_size > 0);
|
SASSERT(m_heap_size > 0);
|
||||||
int ret = m_heap[1];
|
int ret = m_heap[1];
|
||||||
put_the_last_at_the_top_and_fix_the_heap();
|
put_the_last_at_the_top_and_fix_the_heap();
|
||||||
m_heap_inverse[ret] = -1;
|
m_heap_inverse[ret] = -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
template <typename T> void binary_heap_priority_queue<T>::print(std::ostream & out) {
|
template <typename T> void binary_heap_priority_queue<T>::print(std::ostream & out) {
|
||||||
vector<int> index;
|
vector<int> index;
|
||||||
vector<T> prs;
|
vector<T> prs;
|
||||||
|
|
|
@ -1,10 +1,25 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include "util/lp/numeric_pair.h"
|
#include "util/lp/numeric_pair.h"
|
||||||
#include "util/lp/binary_heap_priority_queue.hpp"
|
#include "util/lp/binary_heap_priority_queue.hpp"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
template binary_heap_priority_queue<int>::binary_heap_priority_queue(unsigned int);
|
template binary_heap_priority_queue<int>::binary_heap_priority_queue(unsigned int);
|
||||||
template unsigned binary_heap_priority_queue<int>::dequeue();
|
template unsigned binary_heap_priority_queue<int>::dequeue();
|
||||||
template void binary_heap_priority_queue<int>::enqueue(unsigned int, int const&);
|
template void binary_heap_priority_queue<int>::enqueue(unsigned int, int const&);
|
||||||
|
@ -16,11 +31,11 @@ template unsigned binary_heap_priority_queue<double>::dequeue();
|
||||||
template unsigned binary_heap_priority_queue<mpq>::dequeue();
|
template unsigned binary_heap_priority_queue<mpq>::dequeue();
|
||||||
template void binary_heap_priority_queue<numeric_pair<mpq> >::enqueue(unsigned int, numeric_pair<mpq> const&);
|
template void binary_heap_priority_queue<numeric_pair<mpq> >::enqueue(unsigned int, numeric_pair<mpq> const&);
|
||||||
template void binary_heap_priority_queue<numeric_pair<mpq> >::resize(unsigned int);
|
template void binary_heap_priority_queue<numeric_pair<mpq> >::resize(unsigned int);
|
||||||
template void lean::binary_heap_priority_queue<double>::resize(unsigned int);
|
template void lp::binary_heap_priority_queue<double>::resize(unsigned int);
|
||||||
template binary_heap_priority_queue<unsigned int>::binary_heap_priority_queue(unsigned int);
|
template binary_heap_priority_queue<unsigned int>::binary_heap_priority_queue(unsigned int);
|
||||||
template void binary_heap_priority_queue<unsigned>::resize(unsigned int);
|
template void binary_heap_priority_queue<unsigned>::resize(unsigned int);
|
||||||
template unsigned binary_heap_priority_queue<unsigned int>::dequeue();
|
template unsigned binary_heap_priority_queue<unsigned int>::dequeue();
|
||||||
template void binary_heap_priority_queue<unsigned int>::enqueue(unsigned int, unsigned int const&);
|
template void binary_heap_priority_queue<unsigned int>::enqueue(unsigned int, unsigned int const&);
|
||||||
template void binary_heap_priority_queue<unsigned int>::remove(unsigned int);
|
template void binary_heap_priority_queue<unsigned int>::remove(unsigned int);
|
||||||
template void lean::binary_heap_priority_queue<mpq>::resize(unsigned int);
|
template void lp::binary_heap_priority_queue<mpq>::resize(unsigned int);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
@ -15,7 +30,7 @@
|
||||||
|
|
||||||
typedef std::pair<unsigned, unsigned> upair;
|
typedef std::pair<unsigned, unsigned> upair;
|
||||||
|
|
||||||
namespace lean {
|
namespace lp {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class binary_heap_upair_queue {
|
class binary_heap_upair_queue {
|
||||||
binary_heap_priority_queue<T> m_q;
|
binary_heap_priority_queue<T> m_q;
|
||||||
|
@ -38,7 +53,7 @@ public:
|
||||||
void enqueue(unsigned i, unsigned j, const T & priority);
|
void enqueue(unsigned i, unsigned j, const T & priority);
|
||||||
void dequeue(unsigned & i, unsigned &j);
|
void dequeue(unsigned & i, unsigned &j);
|
||||||
T get_priority(unsigned i, unsigned j) const;
|
T get_priority(unsigned i, unsigned j) const;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
bool pair_to_index_is_a_bijection() const;
|
bool pair_to_index_is_a_bijection() const;
|
||||||
bool available_spots_are_correct() const;
|
bool available_spots_are_correct() const;
|
||||||
bool is_correct() const {
|
bool is_correct() const {
|
||||||
|
|
|
@ -1,12 +1,27 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "util/lp/lp_utils.h"
|
#include "util/lp/lp_utils.h"
|
||||||
#include "util/lp/binary_heap_upair_queue.h"
|
#include "util/lp/binary_heap_upair_queue.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
template <typename T> binary_heap_upair_queue<T>::binary_heap_upair_queue(unsigned size) : m_q(size), m_pairs(size) {
|
template <typename T> binary_heap_upair_queue<T>::binary_heap_upair_queue(unsigned size) : m_q(size), m_pairs(size) {
|
||||||
for (unsigned i = 0; i < size; i++)
|
for (unsigned i = 0; i < size; i++)
|
||||||
m_available_spots.push_back(i);
|
m_available_spots.push_back(i);
|
||||||
|
@ -14,7 +29,7 @@ template <typename T> binary_heap_upair_queue<T>::binary_heap_upair_queue(unsign
|
||||||
|
|
||||||
template <typename T> unsigned
|
template <typename T> unsigned
|
||||||
binary_heap_upair_queue<T>::dequeue_available_spot() {
|
binary_heap_upair_queue<T>::dequeue_available_spot() {
|
||||||
lean_assert(m_available_spots.empty() == false);
|
SASSERT(m_available_spots.empty() == false);
|
||||||
unsigned ret = m_available_spots.back();
|
unsigned ret = m_available_spots.back();
|
||||||
m_available_spots.pop_back();
|
m_available_spots.pop_back();
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -54,7 +69,7 @@ template <typename T> void binary_heap_upair_queue<T>::enqueue(unsigned i, unsig
|
||||||
m_pairs.resize(new_size);
|
m_pairs.resize(new_size);
|
||||||
}
|
}
|
||||||
ij_index = dequeue_available_spot();
|
ij_index = dequeue_available_spot();
|
||||||
// lean_assert(ij_index<m_pairs.size() && ij_index_is_new(ij_index));
|
// SASSERT(ij_index<m_pairs.size() && ij_index_is_new(ij_index));
|
||||||
m_pairs[ij_index] = p;
|
m_pairs[ij_index] = p;
|
||||||
m_pairs_to_index[p] = ij_index;
|
m_pairs_to_index[p] = ij_index;
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +79,7 @@ template <typename T> void binary_heap_upair_queue<T>::enqueue(unsigned i, unsig
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void binary_heap_upair_queue<T>::dequeue(unsigned & i, unsigned &j) {
|
template <typename T> void binary_heap_upair_queue<T>::dequeue(unsigned & i, unsigned &j) {
|
||||||
lean_assert(!m_q.is_empty());
|
SASSERT(!m_q.is_empty());
|
||||||
unsigned ij_index = m_q.dequeue();
|
unsigned ij_index = m_q.dequeue();
|
||||||
upair & p = m_pairs[ij_index];
|
upair & p = m_pairs[ij_index];
|
||||||
i = p.first;
|
i = p.first;
|
||||||
|
@ -81,7 +96,7 @@ template <typename T> T binary_heap_upair_queue<T>::get_priority(unsigned i, uns
|
||||||
return m_q.get_priority(it->second);
|
return m_q.get_priority(it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
template <typename T> bool binary_heap_upair_queue<T>::pair_to_index_is_a_bijection() const {
|
template <typename T> bool binary_heap_upair_queue<T>::pair_to_index_is_a_bijection() const {
|
||||||
std::set<int> tmp;
|
std::set<int> tmp;
|
||||||
for (auto p : m_pairs_to_index) {
|
for (auto p : m_pairs_to_index) {
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include "util/lp/binary_heap_upair_queue.hpp"
|
#include "util/lp/binary_heap_upair_queue.hpp"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
template binary_heap_upair_queue<int>::binary_heap_upair_queue(unsigned int);
|
template binary_heap_upair_queue<int>::binary_heap_upair_queue(unsigned int);
|
||||||
template binary_heap_upair_queue<unsigned int>::binary_heap_upair_queue(unsigned int);
|
template binary_heap_upair_queue<unsigned int>::binary_heap_upair_queue(unsigned int);
|
||||||
template unsigned binary_heap_upair_queue<int>::dequeue_available_spot();
|
template unsigned binary_heap_upair_queue<int>::dequeue_available_spot();
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
#include "util/lp/linear_combination_iterator.h"
|
#include "util/lp/linear_combination_iterator.h"
|
||||||
|
@ -13,7 +28,7 @@
|
||||||
// We try to pin a var by pushing the total by using the variable bounds
|
// We try to pin a var by pushing the total by using the variable bounds
|
||||||
// In a loop we drive the partial sum down, denoting the variables of this process by _u.
|
// In a loop we drive the partial sum down, denoting the variables of this process by _u.
|
||||||
// In the same loop trying to pin variables by pushing the partial sum up, denoting the variable related to it by _l
|
// In the same loop trying to pin variables by pushing the partial sum up, denoting the variable related to it by _l
|
||||||
namespace lean {
|
namespace lp {
|
||||||
|
|
||||||
class bound_analyzer_on_row {
|
class bound_analyzer_on_row {
|
||||||
|
|
||||||
|
@ -91,11 +106,11 @@ public :
|
||||||
}
|
}
|
||||||
|
|
||||||
const impq & ub(unsigned j) const {
|
const impq & ub(unsigned j) const {
|
||||||
lean_assert(upper_bound_is_available(j));
|
SASSERT(upper_bound_is_available(j));
|
||||||
return m_bp.get_upper_bound(j);
|
return m_bp.get_upper_bound(j);
|
||||||
}
|
}
|
||||||
const impq & lb(unsigned j) const {
|
const impq & lb(unsigned j) const {
|
||||||
lean_assert(low_bound_is_available(j));
|
SASSERT(low_bound_is_available(j));
|
||||||
return m_bp.get_low_bound(j);
|
return m_bp.get_low_bound(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,22 +129,22 @@ public :
|
||||||
}
|
}
|
||||||
return a * lb(j).x;
|
return a * lb(j).x;
|
||||||
}
|
}
|
||||||
mpq monoid_max(const mpq & a, unsigned j, bool & strict) const {
|
mpq monoid_max(const mpq & a, unsigned j, bool & strict) const {
|
||||||
if (is_pos(a)) {
|
if (is_pos(a)) {
|
||||||
strict = !is_zero(ub(j).y);
|
strict = !is_zero(ub(j).y);
|
||||||
return a * ub(j).x;
|
return a * ub(j).x;
|
||||||
}
|
}
|
||||||
strict = !is_zero(lb(j).y);
|
strict = !is_zero(lb(j).y);
|
||||||
return a * lb(j).x;
|
return a * lb(j).x;
|
||||||
}
|
}
|
||||||
const mpq & monoid_min_no_mult(bool a_is_pos, unsigned j, bool & strict) const {
|
const mpq & monoid_min_no_mult(bool a_is_pos, unsigned j, bool & strict) const {
|
||||||
if (!a_is_pos) {
|
if (!a_is_pos) {
|
||||||
strict = !is_zero(ub(j).y);
|
strict = !is_zero(ub(j).y);
|
||||||
return ub(j).x;
|
return ub(j).x;
|
||||||
}
|
}
|
||||||
strict = !is_zero(lb(j).y);
|
strict = !is_zero(lb(j).y);
|
||||||
return lb(j).x;
|
return lb(j).x;
|
||||||
}
|
}
|
||||||
|
|
||||||
mpq monoid_min(const mpq & a, unsigned j, bool& strict) const {
|
mpq monoid_min(const mpq & a, unsigned j, bool& strict) const {
|
||||||
if (is_neg(a)) {
|
if (is_neg(a)) {
|
||||||
|
@ -153,7 +168,7 @@ public :
|
||||||
void limit_all_monoids_from_above() {
|
void limit_all_monoids_from_above() {
|
||||||
int strict = 0;
|
int strict = 0;
|
||||||
mpq total;
|
mpq total;
|
||||||
lean_assert(is_zero(total));
|
SASSERT(is_zero(total));
|
||||||
m_it.reset();
|
m_it.reset();
|
||||||
mpq a; unsigned j;
|
mpq a; unsigned j;
|
||||||
while (m_it.next(a, j)) {
|
while (m_it.next(a, j)) {
|
||||||
|
@ -166,7 +181,7 @@ public :
|
||||||
m_it.reset();
|
m_it.reset();
|
||||||
while (m_it.next(a, j)) {
|
while (m_it.next(a, j)) {
|
||||||
bool str;
|
bool str;
|
||||||
bool a_is_pos = is_pos(a);
|
bool a_is_pos = is_pos(a);
|
||||||
mpq bound = total / a + monoid_min_no_mult(a_is_pos, j, str);
|
mpq bound = total / a + monoid_min_no_mult(a_is_pos, j, str);
|
||||||
if (a_is_pos) {
|
if (a_is_pos) {
|
||||||
limit_j(j, bound, true, false, strict - static_cast<int>(str) > 0);
|
limit_j(j, bound, true, false, strict - static_cast<int>(str) > 0);
|
||||||
|
@ -180,7 +195,7 @@ public :
|
||||||
void limit_all_monoids_from_below() {
|
void limit_all_monoids_from_below() {
|
||||||
int strict = 0;
|
int strict = 0;
|
||||||
mpq total;
|
mpq total;
|
||||||
lean_assert(is_zero(total));
|
SASSERT(is_zero(total));
|
||||||
m_it.reset();
|
m_it.reset();
|
||||||
mpq a; unsigned j;
|
mpq a; unsigned j;
|
||||||
while (m_it.next(a, j)) {
|
while (m_it.next(a, j)) {
|
||||||
|
@ -192,8 +207,8 @@ public :
|
||||||
m_it.reset();
|
m_it.reset();
|
||||||
while (m_it.next(a, j)) {
|
while (m_it.next(a, j)) {
|
||||||
bool str;
|
bool str;
|
||||||
bool a_is_pos = is_pos(a);
|
bool a_is_pos = is_pos(a);
|
||||||
mpq bound = total / a + monoid_max_no_mult(a_is_pos, j, str);
|
mpq bound = total / a + monoid_max_no_mult(a_is_pos, j, str);
|
||||||
bool astrict = strict - static_cast<int>(str) > 0;
|
bool astrict = strict - static_cast<int>(str) > 0;
|
||||||
if (a_is_pos) {
|
if (a_is_pos) {
|
||||||
limit_j(j, bound, true, true, astrict);
|
limit_j(j, bound, true, true, astrict);
|
||||||
|
@ -272,7 +287,7 @@ public :
|
||||||
// mpq a; unsigned j;
|
// mpq a; unsigned j;
|
||||||
// while (it->next(a, j)) {
|
// while (it->next(a, j)) {
|
||||||
// if (be.m_j == j) continue;
|
// if (be.m_j == j) continue;
|
||||||
// lean_assert(bound_is_available(j, is_neg(a) ? low_bound : !low_bound));
|
// SASSERT(bound_is_available(j, is_neg(a) ? low_bound : !low_bound));
|
||||||
// be.m_vector_of_bound_signatures.emplace_back(a, j, numeric_traits<impq>::
|
// be.m_vector_of_bound_signatures.emplace_back(a, j, numeric_traits<impq>::
|
||||||
// is_neg(a)? low_bound: !low_bound);
|
// is_neg(a)? low_bound: !low_bound);
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace lean {
|
namespace lp {
|
||||||
enum breakpoint_type {
|
enum breakpoint_type {
|
||||||
low_break, upper_break, fixed_break
|
low_break, upper_break, fixed_break
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
|
@ -9,7 +24,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "util/lp/lp_settings.h"
|
#include "util/lp/lp_settings.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
inline bool is_valid(unsigned j) { return static_cast<int>(j) >= 0;}
|
inline bool is_valid(unsigned j) { return static_cast<int>(j) >= 0;}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -100,11 +115,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
T get_low_bound() const {
|
T get_low_bound() const {
|
||||||
lean_assert(m_low_bound_is_set);
|
SASSERT(m_low_bound_is_set);
|
||||||
return m_low_bound;
|
return m_low_bound;
|
||||||
}
|
}
|
||||||
T get_upper_bound() const {
|
T get_upper_bound() const {
|
||||||
lean_assert(m_upper_bound_is_set);
|
SASSERT(m_upper_bound_is_set);
|
||||||
return m_upper_bound;
|
return m_upper_bound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +171,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
T get_fixed_value() const {
|
T get_fixed_value() const {
|
||||||
lean_assert(m_is_fixed);
|
SASSERT(m_is_fixed);
|
||||||
return m_fixed_value;
|
return m_fixed_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "util/lp/linear_combination_iterator.h"
|
#include "util/lp/linear_combination_iterator.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
class column_namer {
|
class column_namer {
|
||||||
public:
|
public:
|
||||||
virtual std::string get_column_name(unsigned j) const = 0;
|
virtual std::string get_column_name(unsigned j) const = 0;
|
||||||
|
|
|
@ -1,10 +1,25 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
|
|
||||||
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
namespace lean {
|
namespace lp {
|
||||||
template <typename V>
|
template <typename V>
|
||||||
struct conversion_helper {
|
struct conversion_helper {
|
||||||
static V get_low_bound(const column_info<mpq> & ci) {
|
static V get_low_bound(const column_info<mpq> & ci) {
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -10,7 +25,7 @@
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include "util/lp/lp_settings.h"
|
#include "util/lp/lp_settings.h"
|
||||||
#include "util/lp/indexed_vector.h"
|
#include "util/lp/indexed_vector.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
template <typename T, typename X> class lp_core_solver_base; // forward definition
|
template <typename T, typename X> class lp_core_solver_base; // forward definition
|
||||||
|
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -9,7 +24,7 @@
|
||||||
#include "util/lp/lp_core_solver_base.h"
|
#include "util/lp/lp_core_solver_base.h"
|
||||||
#include "util/lp/core_solver_pretty_printer.h"
|
#include "util/lp/core_solver_pretty_printer.h"
|
||||||
#include "util/lp/numeric_pair.h"
|
#include "util/lp/numeric_pair.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
|
@ -148,7 +163,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::adjust_
|
||||||
case column_type::free_column:
|
case column_type::free_column:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
lean_assert(false);
|
SASSERT(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,7 +372,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_g
|
||||||
unsigned width = m_column_widths[col];
|
unsigned width = m_column_widths[col];
|
||||||
string s = row[col];
|
string s = row[col];
|
||||||
int number_of_blanks = width - static_cast<unsigned>(s.size());
|
int number_of_blanks = width - static_cast<unsigned>(s.size());
|
||||||
lean_assert(number_of_blanks >= 0);
|
SASSERT(number_of_blanks >= 0);
|
||||||
print_blanks(number_of_blanks, m_out);
|
print_blanks(number_of_blanks, m_out);
|
||||||
m_out << s << ' ';
|
m_out << s << ' ';
|
||||||
if (col < row.size() - 1) {
|
if (col < row.size() - 1) {
|
||||||
|
@ -368,7 +383,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_g
|
||||||
|
|
||||||
string rs = T_to_string(rst);
|
string rs = T_to_string(rst);
|
||||||
int nb = m_rs_width - static_cast<int>(rs.size());
|
int nb = m_rs_width - static_cast<int>(rs.size());
|
||||||
lean_assert(nb >= 0);
|
SASSERT(nb >= 0);
|
||||||
print_blanks(nb + 1, m_out);
|
print_blanks(nb + 1, m_out);
|
||||||
m_out << rs << std::endl;
|
m_out << rs << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,30 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include "util/lp/numeric_pair.h"
|
#include "util/lp/numeric_pair.h"
|
||||||
#include "util/lp/core_solver_pretty_printer.hpp"
|
#include "util/lp/core_solver_pretty_printer.hpp"
|
||||||
template lean::core_solver_pretty_printer<double, double>::core_solver_pretty_printer(lean::lp_core_solver_base<double, double> &, std::ostream & out);
|
template lp::core_solver_pretty_printer<double, double>::core_solver_pretty_printer(lp::lp_core_solver_base<double, double> &, std::ostream & out);
|
||||||
template void lean::core_solver_pretty_printer<double, double>::print();
|
template void lp::core_solver_pretty_printer<double, double>::print();
|
||||||
template lean::core_solver_pretty_printer<double, double>::~core_solver_pretty_printer();
|
template lp::core_solver_pretty_printer<double, double>::~core_solver_pretty_printer();
|
||||||
template lean::core_solver_pretty_printer<lean::mpq, lean::mpq>::core_solver_pretty_printer(lean::lp_core_solver_base<lean::mpq, lean::mpq> &, std::ostream & out);
|
template lp::core_solver_pretty_printer<lp::mpq, lp::mpq>::core_solver_pretty_printer(lp::lp_core_solver_base<lp::mpq, lp::mpq> &, std::ostream & out);
|
||||||
template void lean::core_solver_pretty_printer<lean::mpq, lean::mpq>::print();
|
template void lp::core_solver_pretty_printer<lp::mpq, lp::mpq>::print();
|
||||||
template lean::core_solver_pretty_printer<lean::mpq, lean::mpq>::~core_solver_pretty_printer();
|
template lp::core_solver_pretty_printer<lp::mpq, lp::mpq>::~core_solver_pretty_printer();
|
||||||
template lean::core_solver_pretty_printer<lean::mpq, lean::numeric_pair<lean::mpq> >::core_solver_pretty_printer(lean::lp_core_solver_base<lean::mpq, lean::numeric_pair<lean::mpq> > &, std::ostream & out);
|
template lp::core_solver_pretty_printer<lp::mpq, lp::numeric_pair<lp::mpq> >::core_solver_pretty_printer(lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> > &, std::ostream & out);
|
||||||
template lean::core_solver_pretty_printer<lean::mpq, lean::numeric_pair<lean::mpq> >::~core_solver_pretty_printer();
|
template lp::core_solver_pretty_printer<lp::mpq, lp::numeric_pair<lp::mpq> >::~core_solver_pretty_printer();
|
||||||
template void lean::core_solver_pretty_printer<lean::mpq, lean::numeric_pair<lean::mpq> >::print();
|
template void lp::core_solver_pretty_printer<lp::mpq, lp::numeric_pair<lp::mpq> >::print();
|
||||||
|
|
|
@ -1,12 +1,27 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
#include "util/lp/matrix.h"
|
#include "util/lp/matrix.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
// used for debugging purposes only
|
// used for debugging purposes only
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
class dense_matrix: public matrix<T, X> {
|
class dense_matrix: public matrix<T, X> {
|
||||||
|
@ -31,7 +46,7 @@ public:
|
||||||
dense_matrix(unsigned m, unsigned n);
|
dense_matrix(unsigned m, unsigned n);
|
||||||
|
|
||||||
dense_matrix operator*=(matrix<T, X> const & a) {
|
dense_matrix operator*=(matrix<T, X> const & a) {
|
||||||
lean_assert(column_count() == a.row_count());
|
SASSERT(column_count() == a.row_count());
|
||||||
dense_matrix c(row_count(), a.column_count());
|
dense_matrix c(row_count(), a.column_count());
|
||||||
for (unsigned i = 0; i < row_count(); i++) {
|
for (unsigned i = 0; i < row_count(); i++) {
|
||||||
for (unsigned j = 0; j < a.column_count(); j++) {
|
for (unsigned j = 0; j < a.column_count(); j++) {
|
||||||
|
|
|
@ -1,13 +1,28 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include "util/lp/lp_settings.h"
|
#include "util/lp/lp_settings.h"
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
#include "util/lp/numeric_pair.h"
|
#include "util/lp/numeric_pair.h"
|
||||||
#include "util/lp/dense_matrix.h"
|
#include "util/lp/dense_matrix.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
template <typename T> void print_vector(const vector<T> & t, std::ostream & out);
|
template <typename T> void print_vector(const vector<T> & t, std::ostream & out);
|
||||||
template <typename T, typename X> dense_matrix<T, X>::dense_matrix(unsigned m, unsigned n) : m_m(m), m_n(n), m_values(m * n, numeric_traits<T>::zero()) {
|
template <typename T, typename X> dense_matrix<T, X>::dense_matrix(unsigned m, unsigned n) : m_m(m), m_n(n), m_values(m * n, numeric_traits<T>::zero()) {
|
||||||
}
|
}
|
||||||
|
@ -170,7 +185,7 @@ template <typename T, typename X> void dense_matrix<T, X>::multiply_row_by_const
|
||||||
|
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
dense_matrix<T, X> operator* (matrix<T, X> & a, matrix<T, X> & b){
|
dense_matrix<T, X> operator* (matrix<T, X> & a, matrix<T, X> & b){
|
||||||
lean_assert(a.column_count() == b.row_count());
|
SASSERT(a.column_count() == b.row_count());
|
||||||
dense_matrix<T, X> ret(a.row_count(), b.column_count());
|
dense_matrix<T, X> ret(a.row_count(), b.column_count());
|
||||||
for (unsigned i = 0; i < ret.m_m; i++)
|
for (unsigned i = 0; i < ret.m_m; i++)
|
||||||
for (unsigned j = 0; j< ret.m_n; j++) {
|
for (unsigned j = 0; j< ret.m_n; j++) {
|
||||||
|
|
|
@ -1,25 +1,40 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include "util/lp/lp_settings.h"
|
#include "util/lp/lp_settings.h"
|
||||||
#include "util/lp/dense_matrix.hpp"
|
#include "util/lp/dense_matrix.hpp"
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
template lean::dense_matrix<double, double> lean::operator*<double, double>(lean::matrix<double, double>&, lean::matrix<double, double>&);
|
template lp::dense_matrix<double, double> lp::operator*<double, double>(lp::matrix<double, double>&, lp::matrix<double, double>&);
|
||||||
template void lean::dense_matrix<double, double>::apply_from_left(vector<double> &);
|
template void lp::dense_matrix<double, double>::apply_from_left(vector<double> &);
|
||||||
template lean::dense_matrix<double, double>::dense_matrix(lean::matrix<double, double> const*);
|
template lp::dense_matrix<double, double>::dense_matrix(lp::matrix<double, double> const*);
|
||||||
template lean::dense_matrix<double, double>::dense_matrix(unsigned int, unsigned int);
|
template lp::dense_matrix<double, double>::dense_matrix(unsigned int, unsigned int);
|
||||||
template lean::dense_matrix<double, double>& lean::dense_matrix<double, double>::operator=(lean::dense_matrix<double, double> const&);
|
template lp::dense_matrix<double, double>& lp::dense_matrix<double, double>::operator=(lp::dense_matrix<double, double> const&);
|
||||||
template lean::dense_matrix<lean::mpq, lean::mpq>::dense_matrix(unsigned int, unsigned int);
|
template lp::dense_matrix<lp::mpq, lp::mpq>::dense_matrix(unsigned int, unsigned int);
|
||||||
template lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::dense_matrix(lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> > const*);
|
template lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::dense_matrix(lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> > const*);
|
||||||
template void lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_left(vector<lean::mpq>&);
|
template void lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_left(vector<lp::mpq>&);
|
||||||
template lean::dense_matrix<lean::mpq, lean::mpq> lean::operator*<lean::mpq, lean::mpq>(lean::matrix<lean::mpq, lean::mpq>&, lean::matrix<lean::mpq, lean::mpq>&);
|
template lp::dense_matrix<lp::mpq, lp::mpq> lp::operator*<lp::mpq, lp::mpq>(lp::matrix<lp::mpq, lp::mpq>&, lp::matrix<lp::mpq, lp::mpq>&);
|
||||||
template lean::dense_matrix<lean::mpq, lean::mpq> & lean::dense_matrix<lean::mpq, lean::mpq>::operator=(lean::dense_matrix<lean::mpq, lean::mpq> const&);
|
template lp::dense_matrix<lp::mpq, lp::mpq> & lp::dense_matrix<lp::mpq, lp::mpq>::operator=(lp::dense_matrix<lp::mpq, lp::mpq> const&);
|
||||||
template lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::dense_matrix(unsigned int, unsigned int);
|
template lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::dense_matrix(unsigned int, unsigned int);
|
||||||
template lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >& lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::operator=(lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> > const&);
|
template lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >& lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::operator=(lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> > const&);
|
||||||
template lean::dense_matrix<lean::mpq, lean::numeric_pair<lean::mpq> > lean::operator*<lean::mpq, lean::numeric_pair<lean::mpq> >(lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&, lean::matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
|
template lp::dense_matrix<lp::mpq, lp::numeric_pair<lp::mpq> > lp::operator*<lp::mpq, lp::numeric_pair<lp::mpq> >(lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&, lp::matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
|
||||||
template void lean::dense_matrix<lean::mpq, lean::numeric_pair< lean::mpq> >::apply_from_right( vector< lean::mpq> &);
|
template void lp::dense_matrix<lp::mpq, lp::numeric_pair< lp::mpq> >::apply_from_right( vector< lp::mpq> &);
|
||||||
template void lean::dense_matrix<double,double>::apply_from_right(class vector<double> &);
|
template void lp::dense_matrix<double,double>::apply_from_right(class vector<double> &);
|
||||||
template void lean::dense_matrix<lean::mpq, lean::mpq>::apply_from_left(vector<lean::mpq>&);
|
template void lp::dense_matrix<lp::mpq, lp::mpq>::apply_from_left(vector<lp::mpq>&);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,32 +1,47 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
#include "util/lp/tail_matrix.h"
|
#include "util/lp/tail_matrix.h"
|
||||||
#include "util/lp/permutation_matrix.h"
|
#include "util/lp/permutation_matrix.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
|
|
||||||
// This is the sum of a unit matrix and a one-column matrix
|
// This is the sum of a unit matrix and a one-column matrix
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
class eta_matrix
|
class eta_matrix
|
||||||
: public tail_matrix<T, X> {
|
: public tail_matrix<T, X> {
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
unsigned m_length;
|
unsigned m_length;
|
||||||
#endif
|
#endif
|
||||||
unsigned m_column_index;
|
unsigned m_column_index;
|
||||||
public:
|
public:
|
||||||
sparse_vector<T> m_column_vector;
|
sparse_vector<T> m_column_vector;
|
||||||
T m_diagonal_element;
|
T m_diagonal_element;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
eta_matrix(unsigned column_index, unsigned length):
|
eta_matrix(unsigned column_index, unsigned length):
|
||||||
#else
|
#else
|
||||||
eta_matrix(unsigned column_index):
|
eta_matrix(unsigned column_index):
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
m_length(length),
|
m_length(length),
|
||||||
#endif
|
#endif
|
||||||
m_column_index(column_index) {}
|
m_column_index(column_index) {}
|
||||||
|
@ -61,7 +76,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
void push_back(unsigned row_index, T val ) {
|
void push_back(unsigned row_index, T val ) {
|
||||||
lean_assert(row_index != m_column_index);
|
SASSERT(row_index != m_column_index);
|
||||||
m_column_vector.push_back(row_index, val);
|
m_column_vector.push_back(row_index, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +84,7 @@ public:
|
||||||
void apply_from_right(indexed_vector<T> & w);
|
void apply_from_right(indexed_vector<T> & w);
|
||||||
|
|
||||||
T get_elem(unsigned i, unsigned j) const;
|
T get_elem(unsigned i, unsigned j) const;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
unsigned row_count() const { return m_length; }
|
unsigned row_count() const { return m_length; }
|
||||||
unsigned column_count() const { return m_length; }
|
unsigned column_count() const { return m_length; }
|
||||||
void set_number_of_rows(unsigned m) { m_length = m; }
|
void set_number_of_rows(unsigned m) { m_length = m; }
|
||||||
|
|
|
@ -1,12 +1,27 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
#include "util/lp/eta_matrix.h"
|
#include "util/lp/eta_matrix.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
|
|
||||||
// This is the sum of a unit matrix and a one-column matrix
|
// This is the sum of a unit matrix and a one-column matrix
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
|
@ -49,7 +64,7 @@ apply_from_left_local(indexed_vector<L> & w, lp_settings & settings) {
|
||||||
}
|
}
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
void eta_matrix<T, X>::apply_from_right(vector<T> & w) {
|
void eta_matrix<T, X>::apply_from_right(vector<T> & w) {
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
// dense_matrix<T, X> deb(*this);
|
// dense_matrix<T, X> deb(*this);
|
||||||
// auto clone_w = clone_vector<T>(w, get_number_of_rows());
|
// auto clone_w = clone_vector<T>(w, get_number_of_rows());
|
||||||
// deb.apply_from_right(clone_w);
|
// deb.apply_from_right(clone_w);
|
||||||
|
@ -59,8 +74,8 @@ void eta_matrix<T, X>::apply_from_right(vector<T> & w) {
|
||||||
t += w[it.first] * it.second;
|
t += w[it.first] * it.second;
|
||||||
}
|
}
|
||||||
w[m_column_index] = t;
|
w[m_column_index] = t;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
// lean_assert(vectors_are_equal<T>(clone_w, w, get_number_of_rows()));
|
// SASSERT(vectors_are_equal<T>(clone_w, w, get_number_of_rows()));
|
||||||
// delete clone_w;
|
// delete clone_w;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -68,7 +83,7 @@ template <typename T, typename X>
|
||||||
void eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
|
void eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
|
||||||
if (w.m_index.size() == 0)
|
if (w.m_index.size() == 0)
|
||||||
return;
|
return;
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
// vector<T> wcopy(w.m_data);
|
// vector<T> wcopy(w.m_data);
|
||||||
// apply_from_right(wcopy);
|
// apply_from_right(wcopy);
|
||||||
#endif
|
#endif
|
||||||
|
@ -99,12 +114,12 @@ void eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
// lean_assert(w.is_OK());
|
// SASSERT(w.is_OK());
|
||||||
// lean_assert(vectors_are_equal<T>(wcopy, w.m_data));
|
// SASSERT(vectors_are_equal<T>(wcopy, w.m_data));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
T eta_matrix<T, X>::get_elem(unsigned i, unsigned j) const {
|
T eta_matrix<T, X>::get_elem(unsigned i, unsigned j) const {
|
||||||
if (j == m_column_index){
|
if (j == m_column_index){
|
||||||
|
@ -120,7 +135,7 @@ T eta_matrix<T, X>::get_elem(unsigned i, unsigned j) const {
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
void eta_matrix<T, X>::conjugate_by_permutation(permutation_matrix<T, X> & p) {
|
void eta_matrix<T, X>::conjugate_by_permutation(permutation_matrix<T, X> & p) {
|
||||||
// this = p * this * p(-1)
|
// this = p * this * p(-1)
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
// auto rev = p.get_reverse();
|
// auto rev = p.get_reverse();
|
||||||
// auto deb = ((*this) * rev);
|
// auto deb = ((*this) * rev);
|
||||||
// deb = p * deb;
|
// deb = p * deb;
|
||||||
|
@ -129,8 +144,8 @@ void eta_matrix<T, X>::conjugate_by_permutation(permutation_matrix<T, X> & p) {
|
||||||
for (auto & pair : m_column_vector.m_data) {
|
for (auto & pair : m_column_vector.m_data) {
|
||||||
pair.first = p.get_rev(pair.first);
|
pair.first = p.get_rev(pair.first);
|
||||||
}
|
}
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
// lean_assert(deb == *this);
|
// SASSERT(deb == *this);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,43 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
#include "util/lp/numeric_pair.h"
|
#include "util/lp/numeric_pair.h"
|
||||||
#include "util/lp/eta_matrix.hpp"
|
#include "util/lp/eta_matrix.hpp"
|
||||||
#ifdef LEAN_DEBUG
|
#ifdef Z3DEBUG
|
||||||
template double lean::eta_matrix<double, double>::get_elem(unsigned int, unsigned int) const;
|
template double lp::eta_matrix<double, double>::get_elem(unsigned int, unsigned int) const;
|
||||||
template lean::mpq lean::eta_matrix<lean::mpq, lean::mpq>::get_elem(unsigned int, unsigned int) const;
|
template lp::mpq lp::eta_matrix<lp::mpq, lp::mpq>::get_elem(unsigned int, unsigned int) const;
|
||||||
template lean::mpq lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::get_elem(unsigned int, unsigned int) const;
|
template lp::mpq lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::get_elem(unsigned int, unsigned int) const;
|
||||||
#endif
|
#endif
|
||||||
template void lean::eta_matrix<double, double>::apply_from_left(vector<double>&, lean::lp_settings&);
|
template void lp::eta_matrix<double, double>::apply_from_left(vector<double>&, lp::lp_settings&);
|
||||||
template void lean::eta_matrix<double, double>::apply_from_right(vector<double>&);
|
template void lp::eta_matrix<double, double>::apply_from_right(vector<double>&);
|
||||||
template void lean::eta_matrix<double, double>::conjugate_by_permutation(lean::permutation_matrix<double, double>&);
|
template void lp::eta_matrix<double, double>::conjugate_by_permutation(lp::permutation_matrix<double, double>&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::mpq>::apply_from_left(vector<lean::mpq>&, lean::lp_settings&);
|
template void lp::eta_matrix<lp::mpq, lp::mpq>::apply_from_left(vector<lp::mpq>&, lp::lp_settings&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::mpq>::apply_from_right(vector<lean::mpq>&);
|
template void lp::eta_matrix<lp::mpq, lp::mpq>::apply_from_right(vector<lp::mpq>&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::mpq>::conjugate_by_permutation(lean::permutation_matrix<lean::mpq, lean::mpq>&);
|
template void lp::eta_matrix<lp::mpq, lp::mpq>::conjugate_by_permutation(lp::permutation_matrix<lp::mpq, lp::mpq>&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_left(vector<lean::numeric_pair<lean::mpq> >&, lean::lp_settings&);
|
template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_left(vector<lp::numeric_pair<lp::mpq> >&, lp::lp_settings&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_right(vector<lean::mpq>&);
|
template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_right(vector<lp::mpq>&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::conjugate_by_permutation(lean::permutation_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >&);
|
template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::conjugate_by_permutation(lp::permutation_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >&);
|
||||||
template void lean::eta_matrix<double, double>::apply_from_left_local<double>(lean::indexed_vector<double>&, lean::lp_settings&);
|
template void lp::eta_matrix<double, double>::apply_from_left_local<double>(lp::indexed_vector<double>&, lp::lp_settings&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::mpq>::apply_from_left_local<lean::mpq>(lean::indexed_vector<lean::mpq>&, lean::lp_settings&);
|
template void lp::eta_matrix<lp::mpq, lp::mpq>::apply_from_left_local<lp::mpq>(lp::indexed_vector<lp::mpq>&, lp::lp_settings&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_left_local<lean::mpq>(lean::indexed_vector<lean::mpq>&, lean::lp_settings&);
|
template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_left_local<lp::mpq>(lp::indexed_vector<lp::mpq>&, lp::lp_settings&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::numeric_pair<lean::mpq> >::apply_from_right(lean::indexed_vector<lean::mpq>&);
|
template void lp::eta_matrix<lp::mpq, lp::numeric_pair<lp::mpq> >::apply_from_right(lp::indexed_vector<lp::mpq>&);
|
||||||
template void lean::eta_matrix<lean::mpq, lean::mpq>::apply_from_right(lean::indexed_vector<lean::mpq>&);
|
template void lp::eta_matrix<lp::mpq, lp::mpq>::apply_from_right(lp::indexed_vector<lp::mpq>&);
|
||||||
template void lean::eta_matrix<double, double>::apply_from_right(lean::indexed_vector<double>&);
|
template void lp::eta_matrix<double, double>::apply_from_right(lp::indexed_vector<double>&);
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -12,8 +27,8 @@
|
||||||
#endif
|
#endif
|
||||||
namespace std {
|
namespace std {
|
||||||
template<>
|
template<>
|
||||||
struct hash<lean::mpq> {
|
struct hash<lp::mpq> {
|
||||||
inline size_t operator()(const lean::mpq & v) const {
|
inline size_t operator()(const lp::mpq & v) const {
|
||||||
return v.hash();
|
return v.hash();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
/*
|
/*++
|
||||||
Copyright (c) 2017 Microsoft Corporation
|
Copyright (c) 2017 Microsoft Corporation
|
||||||
Author: Lev Nachmanson
|
|
||||||
*/
|
Module Name:
|
||||||
|
|
||||||
|
<name>
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
|
||||||
|
Author:
|
||||||
|
|
||||||
|
Lev Nachmanson (levnach)
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
|
||||||
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "util/lp/lp_settings.h"
|
#include "util/lp/lp_settings.h"
|
||||||
#include "util/lp/lar_constraints.h"
|
#include "util/lp/lar_constraints.h"
|
||||||
namespace lean {
|
namespace lp {
|
||||||
struct implied_bound {
|
struct implied_bound {
|
||||||
mpq m_bound;
|
mpq m_bound;
|
||||||
unsigned m_j; // the column for which the bound has been found
|
unsigned m_j; // the column for which the bound has been found
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue