public void NoFold() { var pair = GetSimpleAndConstantFoldingBuilder(); var sb = pair.Item1; var cfb = pair.Item2; var xPair = GetBoundVarAndIdExpr("x", BasicType.Int); var freeVarX = xPair.Item1; var x = xPair.Item2; var yPair = GetBoundVarAndIdExpr("y", BasicType.Int); var freeVarY = yPair.Item1; var y = yPair.Item2; var fb = new FunctionCallBuilder(); var dummyFunc = fb.CreateCachedUninterpretedFunctionCall("f", BPLType.Bool, new List <BPLType>() { BPLType.Int, BPLType.Int }); var triggerExpr = sb.UFC(dummyFunc, x, y); var trigger = new Trigger(Token.NoToken, /*pos=*/ true, new List <Expr>() { triggerExpr }, null); var foldedResult = cfb.ForAll(new List <Variable>() { freeVarX, freeVarY }, cfb.Lt(x, y), trigger); var simpleResult = sb.ForAll(new List <Variable>() { freeVarX, freeVarY }, sb.Lt(x, y), trigger); CheckIsBoolType(foldedResult); CheckIsBoolType(simpleResult); Assert.AreEqual(simpleResult, foldedResult); // FIXME: Equals() currently doesn't check triggers, so do it manually Assert.IsInstanceOf <ForallExpr>(foldedResult); Assert.IsInstanceOf <ForallExpr>(simpleResult); var foldedResultAsForAll = foldedResult as ForallExpr; var simpleResultAsForAll = simpleResult as ForallExpr; Assert.IsNotNull(foldedResultAsForAll.Triggers); Assert.IsNull(foldedResultAsForAll.Triggers.Next); Assert.IsNotNull(simpleResultAsForAll.Triggers); Assert.IsNull(simpleResultAsForAll.Triggers.Next); Assert.AreSame(foldedResultAsForAll.Triggers, simpleResultAsForAll.Triggers); // Use this gross Boogie API too Assert.IsTrue(BinderExpr.EqualWithAttributesAndTriggers(simpleResult, foldedResult)); }
private Expr buildQuant(bool isForAll, SetupTriggersDeligate sutd) { var builder = MkBuilder(); Assert.IsNotNull(builder); var xPair = GetVarAndIdExpr("x", BasicType.Int, /*isBound=*/ true); var xVar = xPair.Item1; var xId = xPair.Item2; var yPair = GetVarAndIdExpr("y", BasicType.Int, /*isBound=*/ true); var yId = yPair.Item2; var yVar = yPair.Item1; var fcb = new FunctionCallBuilder(); var funcCall = fcb.CreateCachedUninterpretedFunctionCall("f", BPLType.Int, new List <BPLType>() { BPLType.Int, BPLType.Int }); // get triggers var triggers = sutd(builder, funcCall, xId, yId); var body = builder.Gt(builder.UFC(funcCall, xId, yId), xId); Expr result = null; if (isForAll) { result = builder.ForAll(new List <Variable>() { xVar, yVar }, body, triggers); } else { result = builder.Exists(new List <Variable>() { xVar, yVar }, body, triggers); } return(result); }
public void simpleForallWithTrigger() { var builder = GetSimpleBuilder(); var free0Pair = GetVarAndIdExpr("x", BasicType.Int); var free1Pair = GetVarAndIdExpr("y", BasicType.Int); Variable free0Var = free0Pair.Item1; Variable free1Var = free1Pair.Item1; IdentifierExpr x = free0Pair.Item2; IdentifierExpr y = free1Pair.Item2; var fb = new FunctionCallBuilder(); var dummyFunc = fb.CreateCachedUninterpretedFunctionCall("f", BPLType.Bool, new List <BPLType>() { BPLType.Int, BPLType.Int }); var triggerExpr = builder.UFC(dummyFunc, x, y); var trigger = new Trigger(Token.NoToken, /*pos=*/ true, new List <Expr>() { triggerExpr }, null); var root = builder.ForAll(new List <Variable>() { free0Var, free1Var }, builder.Gt(builder.Add(x, y), builder.Sub(x, y)), trigger); Assert.AreEqual("(forall x: int, y: int :: { f(x, y) } x + y > x - y)", root.ToString()); DuplicateAndCheck(root, builder); }