summaryrefslogtreecommitdiff
path: root/Source/Provers
diff options
context:
space:
mode:
authorGravatar rustanleino <unknown>2009-10-04 07:01:06 +0000
committerGravatar rustanleino <unknown>2009-10-04 07:01:06 +0000
commitf0df4f110687974508a4c96e4ebb58a9cd7270c8 (patch)
treeb4ec1a6714d898c8f58057306a90ff40747d6be9 /Source/Provers
parentbdaa9996170aed0b2638962014fe80777b98d5c7 (diff)
Added /z3lets switch, which governs which kinds of LET expressions are sent to Z3. By default, both LET TERM and LET FORMULA expressions are used. Mode /z3lets:2 uses only LET FORMULA, which works around a current Z3 issue with LET expressions and nested quantifiers.
Diffstat (limited to 'Source/Provers')
-rw-r--r--Source/Provers/Simplify/Let2ImpliesVisitor.ssc39
-rw-r--r--Source/Provers/Simplify/ProverInterface.ssc11
-rw-r--r--Source/Provers/Z3/ProverInterface.ssc18
3 files changed, 52 insertions, 16 deletions
diff --git a/Source/Provers/Simplify/Let2ImpliesVisitor.ssc b/Source/Provers/Simplify/Let2ImpliesVisitor.ssc
index 8443d950..0dc52516 100644
--- a/Source/Provers/Simplify/Let2ImpliesVisitor.ssc
+++ b/Source/Provers/Simplify/Let2ImpliesVisitor.ssc
@@ -22,8 +22,16 @@ namespace Microsoft.Boogie.Simplify
public class Let2ImpliesMutator : SubstitutingVCExprVisitor {
public Let2ImpliesMutator(VCExpressionGenerator! gen) {
+ this(gen, false, false);
+ }
+ public Let2ImpliesMutator(VCExpressionGenerator! gen, bool keepLetTerm, bool keepLetFormula) {
base(gen);
+ this.keepLetTerm = keepLetTerm;
+ this.keepLetFormula = keepLetFormula;
}
+
+ readonly bool keepLetTerm;
+ readonly bool keepLetFormula;
public VCExpr! Mutate(VCExpr! expr) {
return Mutate(expr, new VCExprSubstitution ());
@@ -138,7 +146,8 @@ namespace Microsoft.Boogie.Simplify
substitution.PushScope(); try {
// the bindings that remain and that are later handled using an implication
- List<VCExprLetBinding!>! bindings = new List<VCExprLetBinding!> ();
+ List<VCExprLetBinding!> bindings = new List<VCExprLetBinding!> ();
+ List<VCExprLetBinding!> keepBindings = new List<VCExprLetBinding!> ();
foreach (VCExprLetBinding! binding in node) {
// in all cases we apply the substitution up to this point
@@ -149,18 +158,30 @@ namespace Microsoft.Boogie.Simplify
// a bound formula is handled using an implication; we introduce
// a fresh variable to avoid clashes
assert polarity > 0;
-
- VCExprVar! newVar = Gen.Variable(binding.V.Name, Type.Bool);
- substitution[binding.V] = newVar;
-
- bindings.Add(Gen.LetBinding(newVar, newE));
+
+ if (keepLetFormula) {
+ keepBindings.Add(Gen.LetBinding(binding.V, newE));
+
+ } else {
+ VCExprVar! newVar = Gen.Variable(binding.V.Name, Type.Bool);
+ substitution[binding.V] = newVar;
+
+ bindings.Add(Gen.LetBinding(newVar, newE));
+ }
} else {
- // a bound term is substituted
- substitution[binding.V] = newE;
+ if (keepLetTerm) {
+ keepBindings.Add(Gen.LetBinding(binding.V, newE));
+ } else {
+ // a bound term is substituted
+ substitution[binding.V] = newE;
+ }
}
}
VCExpr! newBody = Mutate(node.Body, substitution);
+ if (keepBindings.Count > 0) {
+ newBody = Gen.Let(keepBindings, newBody);
+ }
// Depending on the places where the variable occurs, we would
// have to introduce implications or equations to define the
@@ -172,7 +193,7 @@ namespace Microsoft.Boogie.Simplify
assert occ == OccurrenceTypes.None || occ == OccurrenceTypes.Pos;
}
- return Gen.Implies(Gen.AsImplications(bindings), newBody);
+ return Gen.ImpliesSimp(Gen.AsImplications(bindings), newBody);
} finally {
substitution.PopScope();
diff --git a/Source/Provers/Simplify/ProverInterface.ssc b/Source/Provers/Simplify/ProverInterface.ssc
index df7f86d6..09873d7e 100644
--- a/Source/Provers/Simplify/ProverInterface.ssc
+++ b/Source/Provers/Simplify/ProverInterface.ssc
@@ -562,21 +562,24 @@ namespace Microsoft.Boogie.Simplify
private readonly BigLiteralAbstracter! LitAbstracter;
public override string! translate(VCExpr! expr, int polarity) {
- Let2ImpliesMutator! letImplier = new Let2ImpliesMutator (Gen);
+ Let2ImpliesMutator! letImplier = new Let2ImpliesMutator(Gen);
// handle the types in the VCExpr
- TypeEraser! eraser;
+ TypeEraser eraser;
switch (CommandLineOptions.Clo.TypeEncodingMethod) {
case CommandLineOptions.TypeEncoding.Arguments:
eraser = new TypeEraserArguments((TypeAxiomBuilderArguments)AxBuilder, Gen);
break;
+ case CommandLineOptions.TypeEncoding.Monomorphic:
+ eraser = null;
+ break;
default:
eraser = new TypeEraserPremisses((TypeAxiomBuilderPremisses)AxBuilder, Gen);
break;
}
- VCExpr! exprWithoutTypes = eraser.Erase(expr, polarity);
+ VCExpr! exprWithoutTypes = eraser != null ? eraser.Erase(expr, polarity) : expr;
- TermFormulaFlattener! flattener = new TermFormulaFlattener (Gen);
+ TermFormulaFlattener! flattener = new TermFormulaFlattener(Gen);
VCExpr! exprWithLet = flattener.Flatten(exprWithoutTypes);
VCExpr! exprWithoutLet = letImplier.Mutate(exprWithLet);
diff --git a/Source/Provers/Z3/ProverInterface.ssc b/Source/Provers/Z3/ProverInterface.ssc
index 02b4f505..c3a61fe3 100644
--- a/Source/Provers/Z3/ProverInterface.ssc
+++ b/Source/Provers/Z3/ProverInterface.ssc
@@ -75,6 +75,13 @@ namespace Microsoft.Boogie.Z3
return CommandLineOptions.Clo.Z3types || BitVectors == CommandLineOptions.BvHandling.Z3Native;
}
}
+ public int Lets {
+ get
+ ensures 0 <= result && result < 4;
+ {
+ return CommandLineOptions.Clo.Z3lets;
+ }
+ }
public bool V1 = false;
public bool V2 = false; // default set in PostParse
public bool DistZ3 = false;
@@ -107,8 +114,8 @@ namespace Microsoft.Boogie.Z3
ExeName = "z3-v1.3.exe";
}
if (DistZ3) {
- ExeName = "z3-dist.exe";
- CommandLineOptions.Clo.RestartProverPerVC = true;
+ ExeName = "z3-dist.exe";
+ CommandLineOptions.Clo.RestartProverPerVC = true;
}
}
@@ -227,7 +234,6 @@ namespace Microsoft.Boogie.Z3
eraser = new TypeEraserPremisses((TypeAxiomBuilderPremisses)AxBuilder, Gen);
break;
}
-
VCExpr! exprWithoutTypes = eraser != null ? eraser.Erase(expr, polarity) : expr;
LetBindingSorter! letSorter = new LetBindingSorter(Gen);
@@ -243,6 +249,12 @@ namespace Microsoft.Boogie.Z3
sortedExpr = flattener.Flatten(sortedExpr);
sortedAxioms = flattener.Flatten(sortedAxioms);
}
+ if (Opts.Lets != 3) {
+ // replace let expressions with implies
+ Let2ImpliesMutator letImplier = new Let2ImpliesMutator(Gen, Opts.Lets == 1, Opts.Lets == 2);
+ sortedExpr = letImplier.Mutate(sortedExpr);
+ sortedAxioms = letImplier.Mutate(sortedAxioms);
+ }
//////////////////////////////////////////////////////////////////////////
//SubtermCollector! coll = new SubtermCollector (gen);