Slide 14.28: Search (cont.) Slide 14.30: Search (cont.) Home |
fun( X ) :- red( X ), car( X ). fun( X ) :- blue( X ), bike(X). red( apple_1 ). /* database of red items */ red( block_1 ). red( car_27 ). car( desoto_48 ). /* database of cars */ car( edsel_57 ).This program says that red cars or blue bikes are fun. It then goes on to name some examples of each type of object.
?- fun( What ).
We first attempt to prove something is fun.
To do this we have two clauses of fun that we can use
fun( X ) :- red( X ), car( X ). /* clause 1 */ fun( X ) :- blue( X ), bike( X ). /* clause 2 */Using the first clause, we can now look to see if we can find some red object.