4.3 Consider the following two questions that are logically equivalent: (a) ? schedule(riva at Start, riva at

Question:

4.3 Consider the following two questions that are logically equivalent:

(a) ? schedule(riva at Start, riva at End, Schedule), member( arrive( malcesine at), Schedule), before( 17:00, Start).

(b) ? sail( riva at Start, _), before( 17:00, Start), schedule( riva at Start, riva at End, Schedule), member( arrive(malcesine at _), Schedule). Compare the ways Prolog constructs the answer in case

(a) and in case (b). Which question produces the answer more efficiently? Why? Can we simplify question

(b) to: ?- before( 17:00, Start), schedule( riva at Start, riva at End, Schedule), member(arrive( malcesine at _), Schedule). You can also measure the actual Prolog execution times when answering these questions. This can be done by a Prolog built-in predicate which is for this purpose typically called by statistics( runtime, T). T is a list of two values: first, total execution time in milliseconds from the start of the Prolog session, and second, execution time since the previous call of statistics( runtime, ). For example: ?- statistics(runtime, T1), schedule(...), statistics( runtime, T2). Suppose Prolog answered, among other things, T2 =[1315, 215]. This means that to solve the query schedule(...), Prolog needed 215 msec.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: