Slide 14.28: Search (cont.)
Slide 14.30: Search (cont.)
Home

Search (Cont.)


Search Step I
Consider the following examples.
     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.

Search Step II
Let's now ask what is a fun item. To do this we enter the following query
     ?- 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.