Skip to content

Commit

Permalink
Fix for issue 32 (#281)
Browse files Browse the repository at this point in the history
* fixed issue 32

* spelling mistake fixed
  • Loading branch information
shazqadeer authored Sep 3, 2020
1 parent 33ffd0e commit cf4f174
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
18 changes: 12 additions & 6 deletions Source/Provers/SMTLib/ProverInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2413,21 +2413,27 @@ protected string VCExpr2String(VCExpr expr, int polarity)
// Console.Write("Linearising ... ");

// handle the types in the VCExpr
TypeEraser eraser;
VCExpr exprWithoutTypes;
switch (CommandLineOptions.Clo.TypeEncodingMethod)
{
case CommandLineOptions.TypeEncoding.Arguments:
eraser = new TypeEraserArguments((TypeAxiomBuilderArguments) AxBuilder, gen);
{
TypeEraser eraser = new TypeEraserArguments((TypeAxiomBuilderArguments) AxBuilder, gen);
exprWithoutTypes = AxBuilder.Cast(eraser.Erase(expr, polarity), Type.Bool);
break;
}
case CommandLineOptions.TypeEncoding.Monomorphic:
eraser = null;
{
exprWithoutTypes = expr;
break;
}
default:
eraser = new TypeEraserPremisses((TypeAxiomBuilderPremisses) AxBuilder, gen);
{
TypeEraser eraser = new TypeEraserPremisses((TypeAxiomBuilderPremisses) AxBuilder, gen);
exprWithoutTypes = AxBuilder.Cast(eraser.Erase(expr, polarity), Type.Bool);
break;
}
}

VCExpr exprWithoutTypes = eraser == null ? expr : eraser.Erase(expr, polarity);
Contract.Assert(exprWithoutTypes != null);

LetBindingSorter letSorter = new LetBindingSorter(gen);
Expand Down
6 changes: 4 additions & 2 deletions Source/VCExpr/TypeErasure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public TypeCtorRepr(Function ctor, List<Function /*!*/> /*!*/ dtors)
// concrete in two subclasses, one for type erasure with type
// premisses in quantifiers (the semantic approach), and one for
// type erasure with explicit type arguments of polymorphic
// functions (the syntacted approach).
// functions (the syntactic approach).
[ContractClass(typeof(TypeAxiomBuilderContracts))]
public abstract class TypeAxiomBuilder : ICloneable
{
Expand Down Expand Up @@ -585,6 +585,8 @@ internal TypeAxiomBuilder(TypeAxiomBuilder builder)
}

public abstract Object /*!*/ Clone();

public abstract VCExpr Cast(VCExpr expr, Type toType);
}

[ContractClassFor(typeof(TypeAxiomBuilder))]
Expand Down Expand Up @@ -827,7 +829,7 @@ public override bool UnchangedType(Type type)
type.IsRegEx;
}

public VCExpr Cast(VCExpr expr, Type toType)
public override VCExpr Cast(VCExpr expr, Type toType)
{
Contract.Requires(toType != null);
Contract.Requires(expr != null);
Expand Down
5 changes: 2 additions & 3 deletions Test/sequences/intseq.bpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ function {:builtin "seq.extract"} IntSeqExtract(s: IntSeq, pos: int, len: int):
procedure test()
{
var s: IntSeq;

s := IntSeqConcat(EmptyIntSeq(), IntSeqUnit(0));
s := IntSeqConcat(s, IntSeqUnit(1));
s := IntSeqConcat(s, IntSeqUnit(2));
assert IntSeqLen(s) == 3;
assert IntSeqExtract(s, 1, 2) == IntSeqConcat(IntSeqUnit(1), IntSeqUnit(2));
// Commenting out for now - doesn't work on earlier versions of z3.
// assert IntSeqNth(s, 1) == 1;
assert IntSeqNth(s, 1) == 1;
}
9 changes: 9 additions & 0 deletions Test/test20/issue-32.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %boogie "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function {:identity} Lit<T>(x: T) : T;
axiom Lit(true);

procedure test()
{
assert Lit(true);
}
2 changes: 2 additions & 0 deletions Test/test20/issue-32.bpl.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Boogie program verifier finished with 1 verified, 0 errors

0 comments on commit cf4f174

Please sign in to comment.