concept

Facts, rules and inference

A single pass applies a positive ground rule only if all premises appear in the input facts. Empty premises are unconditional. This is a teaching function, not a Python built-in or general logic solver.

Formal Syntax & Structure

artificial-intelligence syntaxartificial-intelligence
applicable_heads(facts, rules) → sorted list of supported heads

Working Example

Example Snippetartificial-intelligence
def applicable_heads(facts, rules):    known = set(facts)    return sorted({head for premises, head in rules                   if all(p in known for p in premises)})
facts = ["low_battery", "failed_start", "manual_available"]rules = [(["check_battery", "manual_available"], "review_manual"),         (["low_battery", "failed_start"], "check_battery")]print(applicable_heads(facts, rules))print(applicable_heads(["failed_start"], rules))