Module knowledge_base

Source
Expand description

Defines a dictionary of predicates (facts and rules).

The dictionary is implemented as a HashMap. Each entry is a list (vector)
of facts and/or rules, indexed by predicate name.

A predicate’s name consists of its functor and its arity, separated by a slash.

For example, for the rule,

grandfather($X, $Y) :- father($X, $Z), father($Z, $Y).

the predicate name is: grandfather/2.

Functions§

add_rules
Adds facts and rules to a knowledge base.
count_rules
Counts the number of facts and rules for the given predicate.
format_kb
Formats the knowledge base for display. Use for debugging.
get_rule
Fetches a rule (or fact) from the knowledge base.
make_fact
Makes a fact.
make_rule
Makes a rule.
print_kb
Prints a formatted knowledge base. Use for debugging.
test_kb
Creates a knowledge base with a few facts and rules for testing.

Type Aliases§

KnowledgeBase