Logic Programming Flashcards

1
Q

What is the foundation of logic programming?

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

What is the most widely used logic programming?

A

Prolog

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

How can a programmer compute in Prolog?

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

Give an example of Prolog syntax.

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

How are databases constructed in Prolog?

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

Prolog Notes:

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

Example: Constant Query

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

Example: Variable Query

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

Example: Multiple Predicates Query

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

Example : Assigning one predicate in terms of another predicate

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

Example: Notations

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

Example: Sibling Query

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

How does the interpreter work when searching data?

A

It is also possible in theory to work forward from the facts trying to see if any of the things you can prove from them are what you were looking for - that can be very time-consuming.
Fancier logic languages use both kinds of chaining, with heuristics or hints from the user to bound the searches.

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

Example: Resolution Principle

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

Prolog Unification Rules

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

List Notation

A

head(cons(H,T),H) :- isList(T).
tail(cons(H,T),T) :- isList(T).

?- head(cons(2,cons(3,nil)),X).
X = 2
?- head(cons(X,cons(3,nil)),2).
X = 2

Remark: Prolog does not have notion of “input” and “output” variables

17
Q

Syntactic Sugar For Lists

A
18
Q

Example: Stack

A
19
Q

Example: Termination

A
20
Q

Example: Arithmetic

A
21
Q

Example 1: Cut Operator

  • Always succeeds as a goal
  • “freezes” choice made when encountered
  • If cut reached when backtracking, the search of subtrees of the parent node of the cut stops, and the search continues with the grandparent node.
  • Cut “prunes” the search tree of all other siblings to the right of the node containing the cut.
A
22
Q

Example 2: Cut Operator

A
23
Q

Example: Database Manipulation

A
24
Q

Example: Non-Monotonic Reasoning

A