@@ -287,7 +287,6 @@ def is_literal(s):
287
287
>>> is_literal(expr('x')) # XXX I guess this is intended?
288
288
True
289
289
"""
290
- #XXX return is_symbol(s.op) or (s.op == '~' and is_literal(s.args[0]))
291
290
return is_symbol (s .op ) or (s .op == '~' and is_symbol (s .args [0 ].op ))
292
291
293
292
def literals (s ):
@@ -788,7 +787,7 @@ def WalkSAT(clauses, p=0.5, max_flips=10000):
788
787
class PLWumpusAgent (agents .Agent ):
789
788
"An agent for the wumpus world that does logical inference. [Fig. 7.19]" ""
790
789
def __init__ (self ):
791
- KB = FOLKB () ## shouldn't this be a propositional KB? ***
790
+ KB = FolKB () ## shouldn't this be a propositional KB? ***
792
791
x , y , orientation = 1 , 1 , (1 , 0 )
793
792
visited = set () ## squares already visited
794
793
action = None
@@ -843,8 +842,7 @@ def unify(x, y, s):
843
842
elif isinstance (x , str ) or isinstance (y , str ) or not x or not y :
844
843
# orig. return if_(x == y, s, None) but we already know x != y
845
844
return None
846
- elif issequence (x ) and issequence (y ) and len (x ) == len (y ):
847
- # Assert neither x nor y is []
845
+ elif issequence (x ) and issequence (y ) and len (x ) == len (y ) and x :
848
846
return unify (x [1 :], y [1 :], unify (x [0 ], y [0 ], s ))
849
847
else :
850
848
return None
@@ -871,11 +869,10 @@ def occur_check(var, x, s):
871
869
elif isinstance (x , Expr ):
872
870
return (occur_check (var , x .op , s ) or
873
871
occur_check (var , x .args , s ))
874
- elif isinstance (x , list ):
872
+ elif isinstance (x , ( list , tuple ) ):
875
873
return any (occur_check (var , element , s )
876
874
for element in x )
877
875
else :
878
- assert isinstance (x , (str , int )), x
879
876
return False
880
877
881
878
def extend (s , var , val ):
0 commit comments