0

After searching extensively online, the information provided regarding proof/derivation/binary trees felt somewhat over my head. Here is my SWI-Prolog code:

number_book(111, brave_new_world).
number_book(222, lord_of_the_flies).
number_book(333, fight_club).
number_book(444, wind_in_the_willows).
number_book(555, the_hobbit).

author_book(huxley_aldus, brave_new_world).
author_book(golding_william, lord_of_the_flies).
author_book(palahniuk_chuck, fight_club).
author_book(grahame_kenneth, wind_in_the_willows).
author_book(tolkien_jrr, the_hobbit).

author_fore_sur(huxley_aldus, aldus, huxley).
author_fore_sur(golding_william, william, golding).
author_fore_sur(palahniuk_chuck, chuck, palahniuk).
author_fore_sur(grahame_kenneth, kenneth, grahame).
author_fore_sur(tolkien_jrr, jrr, tolkien).

id_sur_fore(1202, smith, john).
id_sur_fore(1332, thompson, kevin).
id_sur_fore(4556, anderson, edward).

house_post_id(5, dh1_3pr, 1202).
house_post_id(123, ne3_4ty, 1332).
house_post_id(45, dh3_6kl, 4556).

borrowed_id(333, 1202).
borrowed_id(222, 1332).
borrowed_id(555, 4556).

book_out(333, date(2014, 06, 11)).
book_out(222, date(2014, 06, 17)).
book_out(555, date(2014, 06, 27)).

book_in(333, date(2014, 06, 18)).
book_in(222, date(2014, 07, 08)).
book_in(555, date(2014, 07, 20)).

book_due(333, date(2014, 06, 11)).
book_due(222, date(2014, 07, 10)).
book_due(555, date(2014, 07, 18)).

on_loan(D, Title) :-
book_out(Id, D1), D1 @=< D,
book_in(Id, D2), D @< D2,
number_book(Id, Title).

all_on_loan(D, All) :- findall(Title, on_loan(D, Title), All).

all_on_loan_today(All) :- date(D), all_on_loan(D, All).


overdue(Id, Days, Months, Years) :-
        book_in(Id, date(Y1, M1, D1)),
                book_due(Id,date(Y2, M2, D2)),
         Days is D1-D2,
             Months is M1-M2,
                     Years is Y1-Y2.

If anyone would be able to explain in layman's terms how to begin about mapping this I'd be eternally grateful; its driving me mad.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
fleggle
  • 61
  • 5
  • To clarify the notions used see: http://stackoverflow.com/search?q=[prolog]+is%3Aanswer+proof+tree+SLD – false Jun 23 '14 at 21:46
  • And: http://en.wikipedia.org/wiki/SLD_resolution#SLD_resolution_strategies – false Jun 23 '14 at 21:54

0 Answers0