%% Prolog Introduction and Critique %% ** Show examples of append, member, delete %% Clauses %% ready('tea',[['tea','cup'],['hot chocolate','mug']],'cup'). Yes %% ready(+Drink,+Pairs,-Container). %% description already done ready(Drink,Pairs,Container) :- member(Pair,Pairs), Pair=[Drink,Container]. %% Clauses objection %% ready1('tea',[['tea','over-saturated'],['hot chocolate','watery']],Result,Quality). Result=0, Quality='over-saturated'. %%ready1(+Drink,+Pairs,-Result,-Quality). ready1(Drink,Pairs,Result,Quality) :- member(Pair,Pairs), Pair=[Drink,Quality], Result=0. %% Terms %% run([pole,tree,library],Start,Destination). Start=pole,Destination=library. %% run(+Points,-Start,-Destination). run(Points,Start,Destination) :- Points=[Start|Rest], finddestination(Rest,Destination). finddestination(Rest,Destination) :- Rest=[_Point|Rest1],finddestination(Rest1,Destination). finddestination(Rest,Destination) :- Rest=[Destination]. %% Terms objection %% run1(horse,[[horse,tied],[dog,tied]],Result,Quality). Result=0, Quality=tied. %%ready1(+Animal,+Pairs,-Result,-Action). ready1(Animal,Pairs,Result,Action) :- member(Pair,Pairs), Pair=[Animal,Action], Result=0. %% Facts %% the_children_climb. %% climb(tom,frame). Yes climb(tom,frame). %% Facts objection %% climb(frame,[[frame,frozen],[ladder,broken]],Result,Quality). Result=0, Quality=frozen. %%ready1(+Object,+Pairs,-Result,-Quality). ready1(Object,Pairs,Result,Quality) :- member(Pair,Pairs), Pair=[Object,Quality], Result=0. %% Predicate name %% buy(carrots,[[carrots,fresh],[zucchini,delicious]],Quality). Quality=fresh. %% ready(+Food,+Pairs,-Quality). buy(Food,Pairs,Container) :- member(Pair,Pairs), Pair=[Food,Quality]. %% Predicate name objection %% buy(carrots,[[carrots,misplaced],[eggplant,forgotten]],Result,Action). Result=0, Action=misplaced. %%ready1(+Food,+Pairs,-Result,-Action). ready1(Food,Pairs,Result,Action) :- member(Pair,Pairs), Pair=[Food,Action], Result=0. %% First Argument %% ate('Paul','banana'). Yes ate('Paul','banana'). %% First Argument objection %% ate(Paul,[[Paul,lands],[Robert,slides]],Result,Action). Result=0, Quality=lands. %%ready1(+Person,+Pairs,-Result,-Action). ready1(Person,Pairs,Result,Action) :- member(Pair,Pairs), Pair=[Person,Quality], Result=0. %% ate('Paul'). No ate(Person) :- not(lands(Person)). lands('Paul'). %% Second Argument %% swallowed('Robert','tomato'). Yes swallowed('Robert','tomato'). %% Second Argument objection %% ate1(tomato). No ate1(Food) :- not(squashed(Food)). squashed(tomato). %% Commas %% loves('Helen','John'). Yes loves('Helen','John'). %% Commas objection %% kissed('John'). No kissed(Person) :- not(squeezed(Person)). squeezed('John'). %% Atoms %% planted('John','seeds'). Yes planted('John','seeds'). %% Atoms objection %% tripped('John'). No tripped('John') :- fail. %% Rules %% in3(apple,bag). Yes in2(Object1,Object2) :- in3(Object1,Object3), in3(Object3,Object2). in3(apple,box). in3(box,bag). %% Rules objection %% regurgitate(apple). No regurgitate(Food) :- not(slip_on(Food)). slip_on(apple). %% Head %% on(lid,table). Yes on(Object1,Object2) :- on1(Object1,Object3), on1(Object3,Object2). on1(lid,teapot). on1(teapot,table). %% Head objection %% pull(teapot). No pull(Object) :- not(inaccessible(Object)). inaccessible(teapot). %% Body %% next_to('Lily','Tess'). Yes next_to(Person1,Person2) :- next_to1(Person1,Person3), next_to1(Person3,Person2). next_to1('Lily','Jenny'). next_to1('Jenny','Tess'). %% Body objection %% clean('Lily'). No clean(Person) :- not(late(Person)). late('Lily'). %% First subgoal behind(Person1,Person2) :- behind1(Person1,Person3), behind1(Person3,Person2). behind1('Paul','Pauline'). behind1('Pauline','Jack'). %% First subgoal objection walk(Person) :- not(trip(Person)). trip('Paul'). %% Second subgoal above(Object1,Object2) :- above(Object1,Object3), above(Object3,Object2). above('top of bun','veggie patty'). above('veggie patty','bottom of bun'). %% Second subgoal objection eat(Filling) :- not(watery(Filling)). watery('veggie patty'). %% Full stops %% Tony is describing Joanne, Paul and Jan. left(X,Z) :- left(X,Y), left(Y,Z). left('Joanne','Paul'). left('Paul','Jan'). %% Full stops objection stop(Person) :- fall(Person). fall('Tony'). %% Variables ancestor(Grandparent,Child) :- parent(Grandparent,Parent), parent(Parent,Child). parent('Margaret','Maggie'). parent('Maggie','Quentin'). %% Variables objection blind('Margaret').