Search (Cont.)


     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 ).

Search Step IV
Returning to our cars database, again block_1 will not match against desoto_48 or with edsel_57. In this case we must backtrack a second time to see if there is another red item that we can find. This time we find the third clause in the database, and use that.
     red( apple_1 ).
     red( block_1 ).
     red( car_27 ).            /* third choice */
We now attempt the car goal again, but this time for car_27. Now recall what we said earlier about the dangers of over estimating the powers of Prolog. Prolog will try to match the goal car(car_27) against the database
     car( desoto_48 ).
     car( edsel_57 ).
This will fail. car_27 does not match with either desoto_48 or edsel_57. The following steps are taken next:
  1. Go back and see if there are any more possible red items.

  2. Well we have now exhausted all three choices, hence there are no more red items to choose from.

  3. Given that there are no more possible ways that we could satisfy clause 1, we now more on to clause 2, as we see on the next card.