Prolog - How do I represent my code in a proof/derivation/binary tree? -
after searching extensively online, info provided regarding proof/derivation/binary trees felt on head. here 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 d1-d2, months m1-m2, years y1-y2. if able explain in layman's terms how begin mapping i'd eternally grateful; driving me mad.
tree binary prolog proof
No comments:
Post a Comment