Week 9 Intro to Prolog Flashcards

(18 cards)

1
Q

Logic programming

A

Logic is used to express knowlege (describe program)
Inference is used to compute and obtain solutions to programs

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

Advantages of logic programming

A

Advantages:
. declarative style of programming
. program can be used in different ways
. PRECISE AND SIMPLE SEMANTICS
. same formalism to write programs , manipulate them , prove properties

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

Disadvantage of logic programming

A

The capability to handle arithmetic and IO operations comes at the expense of declarative semantics
. Only a fragment of classical first order logic

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

What is domain of computation in prolog

A

Terms

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

What are terms

A

Variable (X,Y,Z)
function symbols ie f with arity n that takes t1 … tn as arguments where t1…tn are terms

function with arity 0 is a constant ie a (lowecase)
function with arity n>=1 f(t1…tn)

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

Predicate symbols

A

if p is a predicate with arity n and has arguments t1 …tn where t1..tn are terms then p(t1…tn) is an Atomic formula A

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

What is a literal

A

Atomic formula or its negation

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

IMPORTANT

A

PREDICATES TAKE TERMS AS ARGUMENTS NOT OTHER PREDICATES

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

horn clause

A

disjunction of literals of which at most one is positive

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

definite horn clause

A

disjunction of literals where there is exactly one positive literal

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

Horn clause 3 cases

A

One positive (fact)
one positive some negfative (rule)
only negatives (goal)

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

What is a program in prolog

A

set of definite horn clauses ie a set of facts and rules

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

IMPORTANT NOTE ABOUT VARIABLES

A

ALL VARIABLES IN PROLOG INDIVIDUALLY UNIVERSALLY QUANTIFIED

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

What is a value

A

term associated to variables by means of a substitutiobn

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

Substitiution

A

partial mapping of Variables to terms

NOT TERMS TO VARIABLES AS NOT ALL TERMS CAN BE REPLACED (IE CONSTANTS …

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

IMPORTANT FACT ABOUT SUBSTITUTION

A

simultaneously replace each variable

ie t = loves ( X, Y) σ = {X -> Y , Y -> a }

tσ = loves( Y , a)

NOT loves(a,a) since we simultaneously replace not one after the other

17
Q

JUST READ

A

Order of clauses significant as resolution applied in program order
selection function picks leftmost goal

18
Q

Just READ - Language limitationbs

A

Negation:

Prolog programs are composed of definite clauses which contain one +ve literal. Therefore it is impossible to state facts involving negative statements or rules with negative literals in their head

General Resolution:

If there was no restrictions then 1) clauses can be resolved in multiple ways, 2) we need to arbitrarily chose the next pair of clauses
Consequences: resolution of a program with a goal can be made unique and deterministic, Resolvent of 2 clauses will either be empty(success) or generate a new goal