///////////////////////////////////////////////////////////////////////////////////// public bool Visit(VCExprLiteral node, LineariserOptions options) { if (node == VCExpressionGenerator.True) { wr.Write("true"); } else if (node == VCExpressionGenerator.False) { wr.Write("false"); } else if (node is VCExprIntLit) { BigNum lit = ((VCExprIntLit)node).Val; if (lit.IsNegative) { // In SMT2 "-42" is an identifier (SMT2, Sect. 3.2 "Symbols") wr.Write("(- 0 {0})", lit.Abs); } else { wr.Write(lit); } } else if (node is VCExprRealLit) { BigDec lit = ((VCExprRealLit)node).Val; if (lit.IsNegative) { // In SMT2 "-42" is an identifier (SMT2, Sect. 3.2 "Symbols") wr.Write("(- 0.0 {0})", lit.Abs.ToDecimalString()); } else { wr.Write(lit.ToDecimalString()); } } else if (node is VCExprFloatLit) { BigFloat lit = ((VCExprFloatLit)node).Val; wr.Write("(" + lit.ToBVString() + ")"); } else if (node is VCExprRModeLit) { RoundingMode lit = ((VCExprRModeLit)node).Val; wr.Write(lit.ToString()); } else if (node is VCExprStringLit) { String lit = ((VCExprStringLit)node).Val; wr.Write("\"" + lit.ToString() + "\""); } else { Contract.Assert(false); throw new cce.UnreachableException(); } return(true); }
//////////////////////////////////////////////////////////////////////////// public override VCExpr Visit(VCExprLiteral node, VCExpr that) { Contract.Requires(that != null); Contract.Requires(node != null); Contract.Ensures(Contract.Result<VCExpr>() != null); if (node.Equals(that)) return node; return AbstractWithVariable(node, that); }
//////////////////////////////////////////////////////////////////////////// public override VCExpr Visit(VCExprLiteral node, bool arg) { Contract.Requires(node != null); Contract.Ensures(Contract.Result <VCExpr>() != null); VCExprIntLit intLit = node as VCExprIntLit; if (intLit != null) { if (NegConstantDistance > intLit.Val || intLit.Val > ConstantDistance) { return(Represent(intLit.Val)); } } return(node); }
public Term Visit(VCExprLiteral node, bool arg) { if (node == VCExpressionGenerator.True) { return(new BoolConst(true)); } if (node == VCExpressionGenerator.False) { return(new BoolConst(false)); } if (node is VCExprIntLit lit) { return(new TermWithExplicitType(new IntConst(lit.Val), PrimitiveType.CreateIntType())); } throw new NotImplementedException(); }
///////////////////////////////////////////////////////////////////////////////////// public bool Visit(VCExprLiteral node, LineariserOptions options) { //Contract.Requires(node != null); //Contract.Requires(options != null); if (options.AsTerm) { if (node == VCExpressionGenerator.True) { wr.Write("{0}", boolTrueName); } else if (node == VCExpressionGenerator.False) { wr.Write("{0}", boolFalseName); } else if (node is VCExprIntLit) { BigNum lit = ((VCExprIntLit)node).Val; wr.Write(lit); } else { Contract.Assert(false); throw new cce.UnreachableException(); } } else { if (node == VCExpressionGenerator.True) { wr.Write("{0}", TRUEName); } else if (node == VCExpressionGenerator.False) { wr.Write("{0}", FALSEName); } else if (node is VCExprIntLit) { System.Diagnostics.Debug.Fail("One should never write IntLit as a predicate!"); } else { Contract.Assert(false); throw new cce.UnreachableException(); } } return(true); }
public Term Visit(VCExprLiteral node, LineariserOptions options) { Contract.Requires(options != null); Contract.Requires(node != null); if (node == VCExpressionGenerator.True) { return(cm.z3.MkTrue()); } else if (node == VCExpressionGenerator.False) { return(cm.z3.MkFalse()); } else if (node is VCExprIntLit) { return(cm.z3.MkNumeral(((VCExprIntLit)node).Val.ToInt, cm.z3.MkIntSort())); } else if (node is VCExprRealLit) { string m = ((VCExprRealLit)node).Val.Mantissa.ToString(); BigInteger e = ((VCExprRealLit)node).Val.Exponent; string f = BigInteger.Pow(BigInteger.Abs(e), 10).ToString(); if (e == 0) { return(cm.z3.MkNumeral(m, cm.z3.MkRealSort())); } else if (((VCExprRealLit)node).Val.Exponent > 0) { return(cm.z3.MkMul(cm.z3.MkNumeral(m, cm.z3.MkRealSort()), cm.z3.MkNumeral(f, cm.z3.MkRealSort()))); } else { return(cm.z3.MkDiv(cm.z3.MkNumeral(m, cm.z3.MkRealSort()), cm.z3.MkNumeral(f, cm.z3.MkRealSort()))); } } else { Contract.Assert(false); throw new cce.UnreachableException(); } }
public bool Visit(VCExprLiteral node, TextWriter wr) { //Contract.Requires(wr != null); //Contract.Requires(node != null); if (node == VCExpressionGenerator.True) { wr.Write("true"); } else if (node == VCExpressionGenerator.False) { wr.Write("false"); } else if (node is VCExprIntLit) { wr.Write(((VCExprIntLit)node).Val); } else { Contract.Assert(false); throw new cce.UnreachableException(); } return(true); }
public Term Visit(VCExprLiteral node, bool arg) { throw new ProofGenUnexpectedStateException(GetType(), "only expect variables and function operations in extractors"); }
public override Dictionary <VCExprVar, Polarity> Visit(VCExprLiteral node, Polarity arg) { return(new Dictionary <VCExprVar, Polarity>()); }
public override bool Visit(VCExprLiteral node, bool arg) { Contract.Requires(node != null); return(true); }