Chapter 4 Flashcards

1
Q

Prolog is made of..

A

Knowledge bases, which… (next flashcard)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Knowledge bases are made of…

A

clauses, which…(next flashcard)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Clauses are made of…

A

conditionals or atoms.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When writing a Prolog program made of clauses, we have to make sure that these clauses capture:

A
  1. the truth of a sentence in the KB (Aristotelian logic)
  2. the whole truth, explicitly ad implicitly!
  3. In a form suitable for back-chaining –> we must write high-quality predicates!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Saying that a program is “logically correct”, means..

A
  1. correct with regard to grammar and
  2. capturing the truth –> correct logical entailment
    • back-chaining= simply correct
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Recursion in Prolog

A

Recursion breaks down a problem into smaller pieces of the same problem such that we can apply the same algorithm to each piece and then later combining the solutions for the answer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Stack

A

Data structure that stores each “call” of a procedure: it follows a LIFO strategy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

LIFO strategy

A

Last-in, first-out strategy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When is a predicate considered recursive in Prolog?

A

When it appears in both the head and body of the clause, but with different arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can we write clauses in the program that handle recursion?

A
  1. Write a clause that handles the n = 0 case, which is, where n is the number of intermediate “blocks” (the smallest natural number).
  2. Write a clause that handles the n+1 case.

Example: if X is above Y with n+1 boxes between them, then there must be a Z that is directly below X and above Y, with n blocks between them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Mathematical induction

A

mathematical proof technique that aims at proving that a mathematical sentence hold for all natural numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Example: prove that the sum of the natural numbers up to n is equal to one half of n times (n+1) –> sum = S(n)

A
  1. Prove that S(0) is true

2. Prove that for any N, if S(n) is true, then S(n+1) is also true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which one of these two sentences is “recursively correct”?

  1. above (X, Y) :- on(X, Z), above(Z, Y)
  2. above (X, Y) :- above(Z, Y), on(X, Z)
A

The first, because when the body of a clause contains a recursive predicate, we have to make sure that its new variables are instantiated by earlier atoms ( on(X, Z) in this case).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a requirement for a problem in order for it to get solved by recursion?

A

To have a base case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is this query asking?

above(b1, b2) ( see slides of lecture 4)

A

Is b1 somewhere above b2?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is this query asking?

on(b1, b2) ( see slides of lecture 4)

A

Is b1 directly on b2?

17
Q

What is this query asking?

just_left(b1, b2) ( see slides of lecture 4)

A

Is b1 directly to the left of b2?

18
Q

What is this query asking?

left(b1, b2) ( see slides of lecture 4)

A

Is b1 somewhere to the left of b2?

19
Q

When will a recursive program terminate?

A

A recursive program terminate if the query that matches the head of a clause is always bigger (according to some size measure) than the queries from the body of the clause

Meaning: we need to make sure that every time we call the predicate again we are one step closer to meet the stopping criterion.