Creating Prolog Predicates -
prolog predicates - built on this, question did not have enough clarity posting question in context.
here question , post have done far , struggling on.
scenario (a quiet weird one)
james , victoria married, victoria in love curt. curt not love because still married , cares kylie, though more interested in henry. arthur romantically inclined towards victoria in competition henry, loves victoria despite being married crystal, whom james feeling romantic about.
1] represent information using prolog predicates.only use 2 predicate names.
this interpretation of this
is_married([james,victoria],[curt,kylie],[henry,crystal]).
is_inlove([victoria,curt],[kylie,henry],[arthur,victoria],[henry,victoria],[james,victoria]).
for second predicate, i'm unsure if should put [curt,kylie] said 'and still cares about' in scenario.
2] married on rocks if both participants romantically inclined towards other people, , not each other. how prolog rule represent statement.
my answer
∀∃x: is_married(x,y) ∧¬ is_inlove(x,y) ∨ is_inlove(y,x) → on_rocks (x)
i'm bit confused on how represent, marriage apposed 2 participants.
3]a circle of love exists when person x loves else, in turn loves else , on until in chain loves person x. assuming 1 circle of love exists, write prolog rules find circle , produce list of involved.
my answer
write_list([x|a,b,c]:-
write(x)
writelist(x,tail).
the prolog way represent each pair separate fact; similar facts form a relationship (predicate).
so have 3 is_married facts, , 5 loves facts. or six, including 1 curt:
is_married(james,victoria). is_married(curt,kylie). is_married(henry,crystal). loves(victoria,curt). % changed name loves(kylie,henry). loves(arthur,victoria). loves(henry,victoria). loves(james,victoria). loves(curt,kylie). "a marri[age] on rocks if both participants romantically inclined towards other people, , not each other." straightforward translation english prolog:
on_the_rocks(a,b):- % pair of people, marriage on rocks is_married(a,b), loves(a,c), c \= b, .....
Comments
Post a Comment