Package spade :: Module logic :: Class FolKB
[hide private]
[frames] | no frames]

Class FolKB

source code


A knowledge base consisting of first-order definite clauses >>> kb0 = FolKB([expr('Farmer(Mac)'), expr('Rabbit(Pete)'), ... expr('(Rabbit(r) & Farmer(f)) ==> Hates(f, r)')]) >>> kb0.tell(expr('Rabbit(Flopsie)')) >>> kb0.retract(expr('Rabbit(Pete)')) >>> kb0.ask(expr('Hates(Mac, x)'))[x] Flopsie >>> kb0.ask(expr('Wife(Pete, x)')) False

Instance Methods [hide private]
 
__init__(self, initial_clauses=[]) source code
 
tell(self, sentence)
Add the sentence to the KB
source code
 
ask_generator(self, query)
Yield all the substitutions that make query true.
source code
 
retract(self, sentence)
Remove the sentence from the KB
source code

Inherited from KB: ask

Method Details [hide private]

__init__(self, initial_clauses=[])
(Constructor)

source code 
Overrides: KB.__init__

tell(self, sentence)

source code 

Add the sentence to the KB

Overrides: KB.tell
(inherited documentation)

ask_generator(self, query)

source code 

Yield all the substitutions that make query true.

Overrides: KB.ask_generator
(inherited documentation)

retract(self, sentence)

source code 

Remove the sentence from the KB

Overrides: KB.retract
(inherited documentation)