Example #1
0
def analyse_unsat(Formulas):
    conj = conjunctive_partition(Formulas)
    ucore = get_unsat_core(conj)
    print("Unsat core:")
    for f in ucore:
        print(f.serialize())
    return ucore
Example #2
0
    def unsat_core(self):

        res = self.solver.solve()

        if not res:
            print('Assertions:', self.fml)
            conj = conjunctive_partition(self.fml)
            ucore = get_unsat_core(conj)
            print("UNSAT-Core size '%d'" % len(ucore))
        for f in ucore:
            print(f.serialize())
Example #3
0
def get_model_or_print_ucore(formula):
    m = s.get_model(formula)
    if not m:
        print('unsat')
        from pysmt.rewritings import conjunctive_partition
        conj = conjunctive_partition(s.And(formula))
        ucore = s.get_unsat_core(conj)
        print("UNSAT-Core size '%d'" % len(ucore))
        for f in ucore:
            print(f.serialize())
        return
    return m
Example #4
0
    # We first check whether the constraints on the domain and problem
    # are satisfiable in isolation.
    assert is_sat(facts)
    assert is_sat(domain)
    assert is_unsat(problem)

    # In isolation they are both fine, rules from both are probably
    # interacting.
    #
    # The problem is given by a nesting of And().
    # conjunctive_partition can be used to obtain a "flat"
    # structure, i.e., a list of conjuncts.
    #
    from pysmt.rewritings import conjunctive_partition
    conj = conjunctive_partition(problem)
    ucore = get_unsat_core(conj)
    print("UNSAT-Core size '%d'" % len(ucore))
    for f in ucore:
        print(f.serialize())

    # The exact version of the UNSAT-Core depends on the solver in
    # use.  Nevertheless, this represents a starting point for your
    # debugging.  A possible way to approach the result is to look for
    # clauses of size 1 (i.e., unit clauses). In the facts list there
    # are only 2 facts:
    #   2_drink_milk
    #   0_nat_norwegian
    #
    # The clause ("1_color_blue" <-> "0_nat_norwegian")
    # Implies that "1_color_blue"
    # But (("3_color_blue" | "1_color_blue") <-> "2_nat_norwegian")
Example #5
0
    # We first check whether the constraints on the domain and problem
    # are satisfiable in isolation.
    assert is_sat(facts)
    assert is_sat(domain)
    assert is_unsat(problem)

    # In isolation they are both fine, rules from both are probably
    # interacting.
    #
    # The problem is given by a nesting of And().
    # conjunctive_partition can be used to obtain a "flat"
    # structure, i.e., a list of conjuncts.
    #
    from pysmt.rewritings import conjunctive_partition
    conj = conjunctive_partition(problem)
    ucore = get_unsat_core(conj)
    print("UNSAT-Core size '%d'" % len(ucore))
    for f in ucore:
        print(f.serialize())

    # The exact version of the UNSAT-Core depends on the solver in
    # use.  Nevertheless, this represents a starting point for your
    # debugging.  A possible way to approach the result is to look for
    # clauses of size 1 (i.e., unit clauses). In the facts list there
    # are only 2 facts:
    #   2_drink_milk
    #   0_nat_norwegian
    #
    # The clause ("1_color_blue" <-> "0_nat_norwegian")
    # Implies that "1_color_blue"
    # But (("3_color_blue" | "1_color_blue") <-> "2_nat_norwegian")
 def test_generators_in_shortcuts(self):
     flist = [Symbol("x"), Not(Symbol("x"))]
     gen_f = (x for x in flist)
     ucore = get_unsat_core(gen_f)
     self.assertEqual(len(ucore), 2)
 def test_shortcut(self):
     x = Symbol("x")
     core = get_unsat_core([x, Not(x)])
     self.assertEqual(len(core), 2)
     self.assertIn(x, core)
     self.assertIn(Not(x), core)
Example #8
0
 def test_generators_in_shortcuts(self):
     flist = [Symbol("x"), Not(Symbol("x"))]
     gen_f = (x for x in flist)
     ucore = get_unsat_core(gen_f)
     self.assertEqual(len(ucore), 2)
Example #9
0
 def test_shortcut(self):
     x = Symbol("x")
     core = get_unsat_core([x, Not(x)])
     self.assertEqual(len(core), 2)
     self.assertIn(x, core)
     self.assertIn(Not(x), core)