Chapter 16 Flashcards

(66 cards)

1
Q

Other name for Logic programming languages

A

Declarative Programming languages

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

How are logic programs expressed?

A

Form of symbolic logic

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

Is it declarative or procedural?

A

Declarative: Only specify the form of results

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

What is a proposition?

A

Logical statement that can be true or false

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

What does a proposition consist of?

A

1+ objects and Relationships among objects

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

What are the 3 basic needs of formal logic?

A

Express propositions
Express relationships between propositions
Describe how new propositions can be inferred from other propositions

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

What is 1st order predicate calculus.

A

Form of symbolic logic that is used for logic programming

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

Object representation in predicate calculus

A

Represent objects in propositions.

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

What is a constant in predicate calculus?

A

A symbol that represents a particular object

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

What is a variable in predicate calculus?

A

A symbol that can represent different objects at different times

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

Is variables in imperative languages the same as in predicate calculus?

A

No

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

What are the 2 types of propositions?

A

Atomic propositions
Compound propositions

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

How does atomic propositions differ from compound propositions?

A

Compound propositions represent mathematical relations (written like mathematical functions)

Atomic propositions are represented by compound terms

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

What are the 2 parts of a compound term?

A

Functor (function symbol that names the relation)

Ordered list of parameters (tuples)

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

Example of a compound term:

A

student(jon)
like(seth, osx)

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

What are the 2 forms of propositions?

A

Fact: (assumed to be true)
Query: Truth of a proposition is to be determined

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

Example of fact and query

A

Fact = Jon is a student
Query = Can you prove that Jon is a student?

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

What are compound propositions?

A

2+ atomic propositions where atomic propositions are connected by operators

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

What are the 5 logical Operators?

A

negation
conjunction
disjunction
equivalence
implication

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

How many logical operators are there?

A

5

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

What are the quantifiers and and what do they mean?

A

Universal (upside down A) AX.P -> For all X, P is True

Existential (Backwards E) EX.P -> There exists a value of X such that P is true

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

How do we infer facts from known propositions?

A

Using resolution since resolution is an inference principle

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

What does the unification process do?

A

Finds values for variables in propositions that allow the matching process to succeed

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

What is instantiation?

A

Assigning temporary values to variables to allow unification to succeed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What happens if matching fails when instantiating a variable?
You backtrack and instantiate the variable with a different value
26
Steps of Proof by Contradiction
Hypotheses (set of assumed propositions) Theorem (new proposition we want to infer) Goal (Negation of theorem stated as a proposition) Proof by contradiction (Theorem proved by finding an inconsistency with the goal)
27
What are Horn Clauses?
An "if-then" statement
28
What are the different types of Horn Clauses?
Headed (single atomic propositions on the left) Headless (Empty left side)
29
Headed Horn Clause example
Rich(X) ∨ WorksHard(X) ∧ OwnsBusiness(X) Rich(X) (Someone is rich) is true if WorksHard(X) (they work hard) and OwnsBusiness(X) (they own a business) are both true.
30
Headless Horn Clause
father(bob, jake) bob is the father of jake
31
What type of clauses are 1) Facts 2) Queries 3) Rules
1+2) Headless 3) Headed
32
Which is simpler, Logic programming semantics or imperative language semantics?
Logic programming
33
Overview of logic programming
Programs only state the form of the result (not how its computed) Uses predicate calculus (descriptive
34
Difference between imperative and logic using a "Sort the list" example
imperative = Describe Alg. to sort the list. Computer executes the steps of the Alg Logic = describe the characteristics of a sorted list
35
Why was prolog designed?
For natural language processing
36
When was prolog designed?
1970s
37
A constant, variable or structure describes what in prolog?
A term
38
What is a constant in prolog?
An atom on int
39
What do atoms consist of in Prolog?
string of letters, digits and underscores starting with a lowercase letter
40
What do variables consist of in Prolog?
String of letters, digits and underscores starting with a uppercase letter
41
What are the kind of statements in prolog?
Fact, Rule and Goal statements
42
Example of a fact statement:
male(bill)
43
Example of a specific rule statement:
(right side = if part, left = then part) ancestor(mary, shelly) :- mother(mary, shelly).
44
Example of a general rule
parent(X,Y) :- mother(X,Y). X is parent of Y if X is mother of Y or sibling(X,Y) :- mother (M,X), mother, (M,Y), father(F,X), father(F,Y).
45
Example of a goal statement (the statement that you want to prove)
?- man(fred)
46
What are the different inferencing approaches in prolog?
Bottom-up/"forward chaining" = begin with facts and rules. attempt to find sequence of matches that leads to goal (building toward goal) Top-down/backward chaining = begin with goal, attempt to find sequence of matches that leads to facts (break down)
47
What is used when there are multiple sub goals in prolog?
Breadth-first search and DFS
48
What is the problem with backtracking?
Can take lots of time and space
49
What does the tracing model do in prolog?
Display variable instantiations at each step
50
What are the 4 events of the tracing model?
Call (beginning of attempt to satisfy goal) Exit (When a goal has been satisfied) Redo (when backtracking occurs) Fail (when goal fails)
51
What does the "is" operator do in prolog?
Assigns variable a value A is B/17 + C
52
What is the difference between the LHS and RHS of the "is" operator in prolog?
RHS must be instantiated LFS must NOT be instantiated
53
Is Sum is Sum + number legal in prolog?
No. 1) it is not an assignment statement 2) LHS and RHS cannot be both instantiated and not instantiated
54
Simple Arithmetic Example in Prolog
distance(X,Y) :- speed(X,Speed),time(X,Time), Y is Speed * Time.
55
What are the different types of list structures in Prolog?
Simple list: [apple, prune] Complex list: [[a,b],son(x,bob)] Empty list: [] List with head x and tail y: [X|Y]
56
What is "_" in prolog?
An anonymous variable (is used to "ignore" something like the head of a list for example)
57
What does the "member" proposition do in prolog?
Checks if X is a member of Y (member(X,Y)) It is also built in "function"
58
What does append do in prolog?
Appends X to Y and makes list Z append(X,Y,Z)
59
What does the reverse proposition do in Prolog?
Reverses the list X and stores it in Y reverse(X, Y)
60
What are the deficiencies of Prolog?
Resolution order control Closed-world assumption The negation problem Intrinsic limitations
61
Why is resolution order control a deficiency of Prolog?
It has a unpredictable execution. (the order of execution isnt constant so it might take unexpected routes to the goal) Programmer can affect efficiency by placing more likely success rules higher up in program
62
Why is the negation problem a deficiency of Prolog?
It relies on Horn Clauses. If info is missing the closed-world assumption cant determine truth or falsehood. Which can lead to incomplete negation
63
How is a cut denoted in prolog and what does it do?
Denoted by ! and subgoals to the left of the cut cannot be re-satisfied through backtracking
64
What is the problem with closed world assumptions?
If the program answers false it isnt necessarily false but could also maybe just not be proven
65
What is the problem with intrinsic limitations?
Some tasks are impossible to specify efficiently
66
What are some applications of Logic Programming?
RDMS Expert systems Natural language processing