Up
Go up to 1 Defining a Simple Relation

Solution to the happy question

The simplest solution is:
happy(P,D) <- student(P) & holiday(D).
happy(P,D) <- teaching(P,C) & midterm(C,D).
happy(david,tuesday).
happy(david,sunday).
Alternatively, the last two clauses could be replaced by:
happy(david,D) <- tuesday(D).
happy(david,D) <- sunday(D).
This is probably better as there may be many different Tuesdays that we would want to consider as a Tuesday. We probaly don't want to do the same thing for the constant david, as we mean a particular David, not just anyone called David.
Computational Intelligence online material, ©David Poole, Alan Mackworth and Randy Goebel, 1999

Up