Ejemplo n.º 1
0
def main():
    em = ExprManager()
    smt = SmtEngine(em)

    # Prove that for integers x and y:
    #   x > 0 AND y > 0  =>  2x + y >= 3

    integer = em.integerType()

    x = em.mkVar("x", integer)
    y = em.mkVar("y", integer)
    zero = em.mkConst(Rational(0))

    x_positive = em.mkExpr(CVC4.GT, x, zero)
    y_positive = em.mkExpr(CVC4.GT, y, zero)

    two = em.mkConst(Rational(2))
    twox = em.mkExpr(CVC4.MULT, two, x)
    twox_plus_y = em.mkExpr(CVC4.PLUS, twox, y)

    three = em.mkConst(Rational(3))
    twox_plus_y_geq_3 = em.mkExpr(CVC4.GEQ, twox_plus_y, three)

    formula = Expr(em.mkExpr(CVC4.AND, x_positive,
                             y_positive)).impExpr(Expr(twox_plus_y_geq_3))

    print "Checking validity of formula " + formula.toString() + " with CVC4."
    print "CVC4 should report VALID."
    print "Result from CVC4 is: " + smt.query(formula).toString()

    return 0
Ejemplo n.º 2
0
def main():
  em = ExprManager()
  smt = SmtEngine(em)

  # Prove that for integers x and y:
  #   x > 0 AND y > 0  =>  2x + y >= 3

  integer = em.integerType()

  x = em.mkVar("x", integer)
  y = em.mkVar("y", integer)
  zero = em.mkConst(Rational(0))

  x_positive = em.mkExpr(CVC4.GT, x, zero)
  y_positive = em.mkExpr(CVC4.GT, y, zero)

  two = em.mkConst(Rational(2))
  twox = em.mkExpr(CVC4.MULT, two, x)
  twox_plus_y = em.mkExpr(CVC4.PLUS, twox, y)

  three = em.mkConst(Rational(3))
  twox_plus_y_geq_3 = em.mkExpr(CVC4.GEQ, twox_plus_y, three)

  formula = Expr(em.mkExpr(CVC4.AND, x_positive, y_positive)).impExpr(Expr(twox_plus_y_geq_3))

  print "Checking validity of formula " + formula.toString() + " with CVC4."
  print "CVC4 should report VALID."
  print "Result from CVC4 is: " + smt.query(formula).toString()

  return 0