summaryrefslogtreecommitdiff
path: root/prolog/problems/family_relations/intro_en.html
blob: 6f2a8d68c063474c8a461028c207726936817bc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Prolog: family relations</title>
  <link rel="stylesheet" type="text/css" href="/css/codeq.css" />
  <link rel="stylesheet" type="text/css" href="../../style.css" />
</head>
<body>

<h1>Prolog: family relations</h1>
<p>
The first set of tasks is an introduction to Prolog. At the same time we will refresh our knowledge of family relations – that’s right, we will deal with aunts, uncles, grandparents, ancestors and descendants.
</p>

<h2>Knowledge base</h2>
<p>
Everything Prolog knows is written in its knowledge base, which is simply a Prolog program. This is usually loaded from one or more files, which are loaded automatically in <span class="codeq">CodeQ</span>. The figure below shows a graphical representation of the knowledge base for this set.
</p>

<figure>
  <a href="famrel.svg" target="_blank">
    <img src="famrel.svg" />
  </a>
  <figcaption>The graph (forest) of family relations</figcaption>
</figure>

<p>
The knowledge base itself is of course not represented in graphical form; it actually looks like this:
</p>
<pre>
parent(tina, william).
parent(thomas, william).
parent(thomas, sally).
parent(thomas, jeffrey).
parent(william, vanessa).
…
female(tina).
female(sally).
female(vanessa).
…
male(william).
male(thomas).
male(jeffrey).
…
</pre>

  </body>
</html>