コード例 #1
0
ファイル: symbolic_test.py プロジェクト: zeta1999/dreal4
 def test_inequality(self):
     # Boolean Variable != Boolean Variable
     self.assertEqual(b1 != b2, Not(Iff(b1, b2)))
     # Boolean Variable != Formula
     self.assertEqual(b1 != (x > 3), Not(Iff(b1, x > 3)))
     # Formula != Boolean Variable
     self.assertEqual((x > 3) != b1, Not(Iff(x > 3, b1)))
     # Scalar Variable != Scalar Variable
     self.assertEqual(str(x != y), '(x != y)')
     # Scalar Variable != Expression
     self.assertEqual(str(x != (y + 3)), '(x != (3 + y))')
     # Expression != Scalar Variable
     self.assertEqual(str((3 + y) != x), '((3 + y) != x)')
     # Expression != Expression
     self.assertEqual(str((1 + x) != (2 + y)), '((1 + x) != (2 + y))')
コード例 #2
0
ファイル: symbolic_test.py プロジェクト: zeta1999/dreal4
    def test_logical(self):
        f1 = (x == 0)
        f2 = (y == 0)
        self.assertEqual(str(Not(f1)), "!((x == 0))")
        self.assertEqual(str(Implies(f1, f2)), str(Or(Not(f1), f2)))
        self.assertEqual(str(Iff(f1, f2)),
                         str(And(Implies(f1, f2), Implies(f2, f1))))

        # Test single-operand logical statements
        self.assertEqual(str(And(x >= 1)), "(x >= 1)")
        self.assertEqual(str(Or(x >= 1)), "(x >= 1)")
        # Test binary operand logical statements
        self.assertEqual(str(And(x >= 1, x <= 2)), "((x >= 1) and (x <= 2))")
        self.assertEqual(str(Or(x <= 1, x >= 2)), "((x >= 2) or (x <= 1))")
        # Test multiple operand logical statements
        self.assertEqual(str(And(x >= 1, x <= 2, y == 2)),
                         "((y == 2) and (x >= 1) and (x <= 2))")
        self.assertEqual(str(Or(x >= 1, x <= 2, y == 2)),
                         "((y == 2) or (x >= 1) or (x <= 2))")
コード例 #3
0
def dReal_check(barrier,
                vector_field,
                region=TUNCALI_PHASE_U,
                exclude=TUNCALI_PHASE_X0):
    final_conjuncts = [
        region.formula(delta=EPSILON, strict=True),
        Not(exclude.formula(strict=True))
    ]

    # Check that there are feasible points in this region
    sanity = CheckSatisfiability(And(*final_conjuncts), EPSILON)
    if sanity is None:
        raise RuntimeError("empty satisfiability region")

    # ... and that having negative Lie derivative is required.
    ld = barrier.lie_derivative(vector_field, region.variables, mp=DREAL)
    final_conjuncts.append(ld > -EPSILON)
    result = CheckSatisfiability(And(*final_conjuncts), EPSILON)
    return result  # should be None
コード例 #4
0
ファイル: symbolic_test.py プロジェクト: zeta1999/dreal4
 def test_logical2(self):
     self.assertEqual(str(And(b1, b2, Implies(b1, b2))),
                      "(b1 and b2 and (b2 or !(b1)))")
     self.assertEqual(str(Or(b1, b2, Implies(b1, b2))),
                      "(b1 or b2 or !(b1))")
     self.assertEqual(str(Not(b1)), "!(b1)")