Chapter 16 Flashcards

(35 cards)

1
Q

Difference between Logical programming and procedural programming?

A

Logical = specify results
Procedural = show how to get to results

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

What is a proposition?

A

A logical statement that may or may not be true

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

What represents a object in proposition?

A

Constants or variables

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

What are the types of propositions?

A

Atomic + compound

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

What does a compound term consist of?

A

Functor and order list of parameters

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

Compound term in Prolog example

A

student(jon) student = functor, jon = argument

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

What are the 2 forms for propositions?

A

Facts ( assumed to be true) and queries (truth to be determined.

Fact = jon is a student.
query = is jon a student?

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

What is a compound proposition?

A

2+ atomic propositions

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

What are the 2 quantifiers?

A

Exists (backwards E) universal (upside down A)

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

Is resolution an inference principle?

A

Yes

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

What is the unification process?

A

Finds values for variables in propositions such that the matching process can move forward

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

What happens after instantiating a variable with a value and the matching fails?

A

Backtrack and instantiate variable with different value

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

What are the 2 types of Horn caluses?

A

Headed (single atomic proposition on the left
Headless ( father(bob, jake) )

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

Can all propositions be stated as Horn clauses?

A

No only most

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

What is meant by “ Logic programming is nonprocedural”?

A

Dont state how the result must be computed but rather the form of the result

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

What is a atom in Prolog?

A

String of letter, digits and underscores starting with lowercase

17
Q

What is a variable in Prolog?

A

same as atom but starts with Uppercase letter

18
Q

What are the 3 kinds of statements in Prolog?

A

Fact, Rule and Goal

19
Q

Example of a fact statement in prolog:

A

female(shelly) aka headless Horn clauses

20
Q

Example of atomic rule statement in prolog:

A

ancestor(mary,shelly) :- mother(mary,shelly) (headed horn clause)

21
Q

Example of universal rule statement in prolog

A

(headed horn clause)
parent(X,Y) :- mother(X,Y).
parent(X,Y) :- father(X,Y).
grandparent(X,Z) :- parent(X,Y), parent(Y,Z) === x is a grand parent of Z if X is a parent of Y and Y is a parent of Z

22
Q

How are goal used in prolog?

A

?- man(fred). aka is fred a man?
Conjunctive propositions:
?- father(X,mike). ( find all the X such that X is mikes father

23
Q

What are the 2 different inferencing approaches?

A

Bottom-up resolution aka forward chaining ( begin with facts and go to goal)
Top-down aka backward chaining ( begin at goal and go to fact ( prolog uses this))

24
Q

What happens if a goal has many sub goals?

A

Use BFS or DFS ( prolog uses dfs)
DFS = find complete proof for one before working on another

25
How can you see each step of variable instantiations in prolog?
With *trace*
26
What are the 4 events of the tracing model?
Call, Exit, Redo, Fail
27
How do you assign an arithmetic expression to a variable in prolog?
A is B / 17 + C All variables on RHS must be instantiated, all on the LHS must not be instantiated
28
Is Sum is Sum + Number "legal" and why?
No because either Sum is instantiated which would make the LHS illegal or not instantiated which would make the RHS illegal
29
How does a list with a head and tail look like in prolog?
[H | T ]
30
Why should the base case of recursion always be at the top in prolog?
cause prolog uses top to bottom matching,
31
How do you check if X is a member of list Y in prolog?
member(X, Y)
32
How do you add items to a list in prolog?
append (X,Y,Z) append X and Y to make Z append([a, b], [c, d], [a, b, c, d]) should be true
33
What does the reverse proposition do in prolog?
reverse(X,Y) checks if Y is the reversed version of X
34
What is the problem with prolog?
no Resolution order control (always top to bottom with facts and rules, and left to right with subgoals Closed-world assumption ( if false maybe just not enough to prove right) negation problem intrinsic limitations
35
How do you stop backtracking in subgoals?
! valid_member(X) :- member(X, [...]), !, test(X).