简体   繁体   中英

PROLOG bike touring task, create rules and queries

I was given this task but I am struggling to formulate the appropriate rules in the correct format. I don't know the exact ways to use the less than/more than signs for this task (>, <, <= etc.)

These are the facts and rules given:

tour(france, 49, 770).
tour(spain, 20, 150).
tour(germany, 26, 370).
tour(italy, 42, 330).
tour(belgium, 46, 540).

medium(germany).
medium(italy).

fitnesslevel(untrained).
fitnesslevel(good).
fitnesslevel(perfect).

fitness_higher(good, untrained).
fitness_higher(perfect, good).

more_fit(F1, F2) :- fitness_higher(F1, F2).
more_fit(F1, F2) :- fitness_higher(F1, F), more_fit(F, F2).

fitness(max, untrained).
fitness(lucy, perfect).

The following are the tasks I was given

1) Add rules for the following predicates:

  • easy(T): A tour T is easy, if it is shorter than 30 km and its maximum height is 150m.
  • hard(T): A tour T is hard, if its maximum height is above 450m.

2) Add rules for this following predicate: suitable(T, P).

  • Easy Tours are suitable for all persons regardless of their fitnesslevel.
  • Average Tours are suitable for all persons who are above an untrained fitnesslevel.
  • Hard Tours are suitable only for persons with a perfect fitnesslevel.

3) Which is the correct query to find out which tours are suitable for Max and Lucy?

You write:

I was given this task but I am struggling to formulate the appropriate rules in the correct format. I don't know the exact ways to use the less than/more than signs for this task (>, <, <= etc.)

You should maybe start smaller. Try to read the docs and understand how to use the comparisons for this task. If there is something you don't understand, write a minimal code sample that we can also run. Show what you expect and what you get instead. You could than ask how to fix it.

As it stands, your question is equivalent of posting your homework assignment and asking someone to work out a solution for you and post it here. It works, sometimes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM