Passer au contenu

Labs · 9618 A2 20.1

Facts and Rules

Declarative programming: a knowledge base of facts and rules. Ask goals, find the matching clauses, and write your own facts, goals and rules.

11 levelsFree bench

In the exam

Exam questions on what this lab teaches, with the points that gain marks.

9618/31 May/June 2024 · Question 8(c)4 marks

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).

Points that gain marks

  1. feature(F)
  2. bodystyle(B)
  3. NOT unavailable(F, B)
  4. All the operators and punctuation right (a comma is fine for AND), and nothing extra.
  5. For example: may_choose_option(F, B) IF feature(F) AND bodystyle(B) AND NOT unavailable(F, B).

In this lab: Level 8 runs your rule on the whole knowledge base and shows every answer it gives, so you can see what a missing NOT does.

9618/31 May/June 2021 · Question 9(b)2 marks

Describe what is meant by a declarative programming language.

Points that gain marks

  1. The program says what is to be done, not how to do it.
  2. It uses facts and rules.
  3. It uses queries (goals) that the facts and rules satisfy.
  4. It can be logical (a set of logical relations) or functional (functions applied to arguments).

In this lab: In every level, you give facts, rules and goals; Prolog does the searching.

The question as printed in the exam paper

More real experiments

All labs →

Se connecter ou créer un compte

IGCSE, A-Level & AP