A declarative programming language is used to represent the features that are available and the features that are unavailable on different body styles of a car.
01 feature(sunroof).
02 feature(automatic_tailgate).
03 feature(heated_seats).
04 feature(extra_seats).
05 feature(reversing_camera).
06 feature(dashboard_camera).
07 feature(air_conditioning).
08 feature(heated_windscreen).
09 feature(satnav).
10 bodystyle(saloon).
11 bodystyle(hatchback).
12 bodystyle(estate).
13 bodystyle(minivan).
14 bodystyle(convertible).
15 available(sunroof, hatchback).
16 available(sunroof, minivan).
17 available(reversing_camera, hatchback).
18 available(extra_seats, minivan).
19 available(reversing_camera, saloon).
20 unavailable(sunroof, convertible).
21 unavailable(automatic_tailgate, saloon).
22 unavailable(extra_seats, hatchback).
These clauses have the meanings:
Clause | Meaning |
|---|---|
| Sunroof is a feature. |
| Saloon is a body style. |
| Sunroof is available on a hatchback. |
| Sunroof is unavailable on a convertible. |
Sliding doors is a feature that is available on a minivan but unavailable on a hatchback.
Write additional clauses to represent this information.
23........................................................................
24........................................................................
25........................................................................
Using the variable Options, the goal:
available(Options, saloon)
returns
Options = reversing_camera
Write the result returned by the goal:
available(Options, hatchback)
Options = ........................
F may be available for B if F is a feature and B is a body style and F is not unavailable for that body style.
Write this as a rule:
may_choose_option(F, B)
IF .........................................
Did this page help you?