Skip to content

Instantly share code, notes, and snippets.

@jazibobs
Last active March 6, 2022 13:03
Show Gist options
  • Save jazibobs/6569e628548a427090752d9b31f82c04 to your computer and use it in GitHub Desktop.
Save jazibobs/6569e628548a427090752d9b31f82c04 to your computer and use it in GitHub Desktop.
Expert System - Mr. Rigby family tree expert system
/* Our knowledge base */
parent(jeff, jared).
parent(jeff, adam).
parent(diane, jared).
parent(diane, adam).
parent(george, diane).
parent(doris, diane).
parent(gerald, jeff).
parent(june, jeff).
parent(gerald, jill).
parent(june, jill).
parent(jill, aaron).
parent(jill, ireyna).
parent(jill, jason).
parent(paul, aaron).
parent(paul, ireyna).
parent(paul, jason).
parent(adam, jessica).
parent(frankie, jessica).
/* Our rules base */
grandparent(G, C) :-
parent(G, P),
parent(P, C).
sibling(A, B) :-
parent(P, A),
parent(P, B),
not(A=B).
cousin(A, B) :-
grandparent(G, A),
grandparent(G, B),
not(sibling(A, B)),
not(A=B).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment