@@ -47,7 +47,7 @@ def __init__(self, sentence=None):
47
47
abstract
48
48
49
49
def tell (self , sentence ):
50
- "Add the sentence to the KB"
50
+ "Add the sentence to the KB. "
51
51
abstract
52
52
53
53
def ask (self , query ):
@@ -671,19 +671,19 @@ def dpll(clauses, symbols, model):
671
671
P , value = find_unit_clause (clauses , model )
672
672
if P :
673
673
return dpll (clauses , removeall (P , symbols ), extend (model , P , value ))
674
- P = symbols . pop () # XXX is this side-effect more global than desired?
674
+ P , symbols = symbols [ 0 ], symbols [ 1 :]
675
675
return (dpll (clauses , symbols , extend (model , P , True )) or
676
676
dpll (clauses , symbols , extend (model , P , False )))
677
677
678
- def find_pure_symbol (symbols , unknown_clauses ):
678
+ def find_pure_symbol (symbols , clauses ):
679
679
"""Find a symbol and its value if it appears only as a positive literal
680
680
(or only as a negative) in clauses.
681
681
>>> find_pure_symbol([A, B, C], [A|~B,~B|~C,C|A])
682
682
(A, True)
683
683
"""
684
684
for s in symbols :
685
685
found_pos , found_neg = False , False
686
- for c in unknown_clauses :
686
+ for c in clauses :
687
687
if not found_pos and s in disjuncts (c ): found_pos = True
688
688
if not found_neg and ~ s in disjuncts (c ): found_neg = True
689
689
if found_pos != found_neg : return s , found_pos
0 commit comments