Home » Cut with Failure

Cut with Failure

In this section, we will specify another use of ‘cut‘. It is used to specify exceptions to general rules. In the following example, we have names of birds in the database as follows:

The following shows the natural rule to add this:

The above rule means that ‘all birds can fly’.

The above rule is very general. We cannot ensure that the goal cry_fly(penguins) will always fail? So, we are going to change the predicate can_fly definition in this approach as follows:

However, the desired result is not provided by the above:

The head of the first can_fly clause and the goal can_fly(penguins) are matched with each other. In the body of that clause, we are trying to satisfy the goal, and the goal obviously fails. Now, the system looks at the second can_fly clause. The head and the goal match with each other, and the goal is also satisfied in the body of the clause, i.e., bird(A), so the goal can_fly(penguins) succeeds. But this is not the desired result.

We can achieve the desired result by replacing the clause can_fly by

As before, the head of the first can_fly clause and the goal can_fly(penguins) are matched with each other. In the body of that clause, we are trying to satisfy the goal, the goal obviously fails. But here the cut prevents it from backtracking the system, so the goal can_fly(penguins) fails.

Cut with failure is the combination of fail and goals !.


You may also like