Podcast
Questions and Answers
Which of the following best describes the approach of logic programming languages?
Which of the following best describes the approach of logic programming languages?
- Stating the desired result without specifying how to obtain it. (correct)
- Employing algorithms optimized for speed and memory usage.
- Using mathematical equations to define program logic.
- Specifying detailed procedures to achieve a result.
What constitutes a proposition in the context of logic programming?
What constitutes a proposition in the context of logic programming?
- A logical statement that can be either true or false. (correct)
- A function call that returns a boolean value.
- A comment within the code explaining a function.
- A data structure used to store variables.
In symbolic logic, what is the purpose of 'predicate calculus'?
In symbolic logic, what is the purpose of 'predicate calculus'?
- To optimize the performance of logical operations.
- To translate logical statements into machine code.
- To define the syntax of a programming language.
- To provide a particular form of symbolic logic used for logic programming. (correct)
How do variables in logic programming differ from those in imperative languages?
How do variables in logic programming differ from those in imperative languages?
What are the two main components of a compound term in logic programming?
What are the two main components of a compound term in logic programming?
In predicate calculus, what distinguishes a 'fact' from a 'query'?
In predicate calculus, what distinguishes a 'fact' from a 'query'?
Which logical operator represents 'a implies b'?
Which logical operator represents 'a implies b'?
What does the universal quantifier ($\forall$) signify in predicate calculus?
What does the universal quantifier ($\forall$) signify in predicate calculus?
Why is the concept of 'clausal form' important in logic programming?
Why is the concept of 'clausal form' important in logic programming?
What is the primary role of 'resolution' in predicate calculus?
What is the primary role of 'resolution' in predicate calculus?
In the context of resolution, what is 'unification'?
In the context of resolution, what is 'unification'?
What is the purpose of 'proof by contradiction' in theorem proving?
What is the purpose of 'proof by contradiction' in theorem proving?
What are the two forms of a 'Horn clause'?
What are the two forms of a 'Horn clause'?
What does 'declarative semantics' refer to in logic programming?
What does 'declarative semantics' refer to in logic programming?
Logic programming is considered 'nonprocedural'. What does this entail?
Logic programming is considered 'nonprocedural'. What does this entail?
Which universities were pivotal in the development of Prolog?
Which universities were pivotal in the development of Prolog?
In Prolog, what are the two possible forms an atom can take?
In Prolog, what are the two possible forms an atom can take?
In Prolog, what does the term 'instantiation' refer to?
In Prolog, what does the term 'instantiation' refer to?
What is the purpose of 'fact statements' in Prolog?
What is the purpose of 'fact statements' in Prolog?
What is the function of the 'antecedent' in a rule statement?
What is the function of the 'antecedent' in a rule statement?
What is the effect of using variables in Prolog rules?
What is the effect of using variables in Prolog rules?
What is the purpose of a 'goal statement' in Prolog?
What is the purpose of a 'goal statement' in Prolog?
In Prolog's inferencing process, what is a 'subgoal'?
In Prolog's inferencing process, what is a 'subgoal'?
What is 'matching' in the context of Prolog's inferencing process?
What is 'matching' in the context of Prolog's inferencing process?
What distinguishes 'bottom-up resolution' from 'top-down resolution' in logic programming?
What distinguishes 'bottom-up resolution' from 'top-down resolution' in logic programming?
What type of search strategy does Prolog primarly use?
What type of search strategy does Prolog primarly use?
In Prolog, what is 'backtracking'?
In Prolog, what is 'backtracking'?
How is the is
operator used in Prolog arithmetic?
How is the is
operator used in Prolog arithmetic?
What is the purpose of the 'trace' feature in Prolog?
What is the purpose of the 'trace' feature in Prolog?
What does the notation [Head | Tail]
represent in Prolog?
What does the notation [Head | Tail]
represent in Prolog?
What does the underscore character _
signify when used within a Prolog rule or fact?
What does the underscore character _
signify when used within a Prolog rule or fact?
What is the 'closed-world assumption' in Prolog?
What is the 'closed-world assumption' in Prolog?
Which of the following are example application areas of logic programming?
Which of the following are example application areas of logic programming?
Which statements accurately reflect the summary of Logic Programming?
Which statements accurately reflect the summary of Logic Programming?
What is a key deficiency of Prolog related to control?
What is a key deficiency of Prolog related to control?
What are the four tracing models?
What are the four tracing models?
Flashcards
Logic Language Programs
Logic Language Programs
Programs in logic languages are expressed in symbolic logic.
Logical Inferencing
Logical Inferencing
Using a logical inferencing process to produce results.
Declarative Programming
Declarative Programming
Only specification of results are stated, the procedures are not.
Proposition
Proposition
A logical statement that may or may not be true.
Signup and view all the flashcards
Symbolic Logic
Symbolic Logic
Logic used for the basic needs of formal logic, expressing propositions and relationships.
Signup and view all the flashcards
Predicate Calculus
Predicate Calculus
A particular form of symbolic logic used for logic programming.
Signup and view all the flashcards
Object Representation
Object Representation
Represent objects in propositions.
Signup and view all the flashcards
Constant
Constant
A symbol that represents an object.
Signup and view all the flashcards
Variable
Variable
A symbol that can represent different objects at different times.
Signup and view all the flashcards
Compound Term
Compound Term
One element of a mathematical relation, written like a mathematical function.
Signup and view all the flashcards
Functor
Functor
The function symbol that names the relationship in a compound term.
Signup and view all the flashcards
Fact Propositions
Fact Propositions
Propositions that are assumed to be true.
Signup and view all the flashcards
Query Propositions
Query Propositions
Propositions where the truth is to be determined.
Signup and view all the flashcards
Compound Propositions
Compound Propositions
Propositions having two or more atomic propositions.
Signup and view all the flashcards
Negation
Negation
¬a
Signup and view all the flashcards
Conjunction
Conjunction
a ∩ b
Signup and view all the flashcards
Disjunction
Disjunction
a ∪ b
Signup and view all the flashcards
Universal Quantifier
Universal Quantifier
∀X.P
Signup and view all the flashcards
Existential Quantifier
Existential Quantifier
∃X.P
Signup and view all the flashcards
Clausal Form
Clausal Form
A standard form for propositions, B₁ ∪ B₂ ∪ ... ∪ Bₙ ⊂ A₁ ∩ A₂ ... ∩ Aₘ
Signup and view all the flashcards
Antecedent
Antecedent
The right side of the clause, the 'if' part.
Signup and view all the flashcards
Consequent
Consequent
The left side of the clause.
Signup and view all the flashcards
Predicate Calculus
Predicate Calculus
Discovering new theorems inferred from known axioms and theorems.
Signup and view all the flashcards
Resolution
Resolution
An inference principle that allows inferred propositions to be computed from given propositions.
Signup and view all the flashcards
Unification
Unification
Finding values for variables in propositions that allows matching process to succeed.
Signup and view all the flashcards
Instantiation
Instantiation
Assigning temporary values to variables to allow unification to succeed.
Signup and view all the flashcards
Hypotheses
Hypotheses
A set of pertinent propositions in proof by contradiction.
Signup and view all the flashcards
Goal
Goal
Negation of theorem stated as a proposition in proof by contradiction.
Signup and view all the flashcards
Theorem Proving
Theorem Proving
Basis for logic programming, restricted form.
Signup and view all the flashcards
Horn Clause
Horn Clause
Can have only two forms, headed and headless.
Signup and view all the flashcards
Headed Horn Clause
Headed Horn Clause
Single atomic proposition on the left side.
Signup and view all the flashcards
Headless Horn Clause
Headless Horn Clause
Empty left side (used to state facts).
Signup and view all the flashcards
Declarative Semantics
Declarative Semantics
There is a simple way to determine the meaning of each statement.
Signup and view all the flashcards
Nonprocedural Programming
Nonprocedural Programming
Programs do not state how a result is computed, but rather the form of the result.
Signup and view all the flashcards
Origins of Prolog
Origins of Prolog
University of Aix-Marseille (Calmerauer & Roussel) for natural language processing.
Signup and view all the flashcards
Term
Term
A constant, variable, or a structure.
Signup and view all the flashcards
Constant
Constant
An atom or an integer.
Signup and view all the flashcards
Atom
Atom
Symbolic value of Prolog.
Signup and view all the flashcards
Variable
Variable
Any string of letters, digits, and underscores beginning with an uppercase letter.
Signup and view all the flashcards
Instantiation
Instantiation
Binding of a variable to a value.
Signup and view all the flashcardsStudy Notes
Introduction
- Logic languages are expressed in a form of symbolic logic.
- Logical referencing is used to produce results.
- Logic languages are declarative, meaning only results are specified, not the procedures.
Proposition
- A proposition is a logical statement that may or may not be true.
- Propositions consist of objects and relationships between objects.
Symbolic Logic
- Symbolic logic expresses propositions.
- Symbolic logic expresses relationships between propositions.
- Symbolic logic describes how propositions can be inferred from other propositions.
- Predicate calculus is a form of symbolic logic used for logic programming.
Object Representation
- Objects in propositions are represented by simple terms consisting of constants and variables.
- A constant is a symbol that represents an object.
- A variable is a symbol that can represent different objects at different times.
- Object representation in logic programming is different from variables in imperative languages.
Compound Terms
- Atomic propositions consist of compound terms.
- A compound term is one element of a mathematical relation, written like a mathematical function.
- Mathematical functions are a mapping that can be written as a table.
Parts of a Compound Term
- Compound terms are composed of a functor and an ordered list of parameters (tuple).
- The functor is a function symbol that names the relationship.
- Examples include
student(jon)
,like(seth, OSX)
,like(nick, windows)
,like(jim, linux)
.
Forms of a Proposition
- Propositions can be stated as facts or queries.
- A fact is a proposition assumed to be true.
- A query is a proposition whose truth is to be determined.
- Compound propositions have two or more atomic propositions.
- Propositions are connected by operators.
Logical Operators
- Negation: ¬a (not a)
- Conjunction: a ∩ b (a and b)
- Disjunction: a ∪ b (a or b)
- Equivalence: a = b (a is equivalent to b)
- Implication: a ⊃ b (a implies b), a ⊂ b (b implies a)
Quantifiers
- Universal: ∀X.P (For all X, P is true)
- Existential: ∃X.P (There exists a value of X such that P is true)
Clausal Form
- Clausal form is a standard form for propositions.
- B₁ ∪ B₂ ∪ ... ∪ Bₙ ⊂ A₁ ∩ A₂ ∩ ... ∩ Aₘ means if all the As are true, then at least one B is true
- Antecedent is the right side of the expression.
- Consequent is the left side of the expression.
Predicate Calculus and Proving Theorems
- Propositions are used to discover new theorems that can be inferred from known axioms and theorems.
- Resolution is an inference principle that allows inferred propositions to be computed from given propositions.
Resolution
- Unification finds values for variables that allows a matching process to succeed.
- Instantiation assigns temporary values to the variable to allow unification to succeed.
- Backtracking is sometimes required if the matching fails after instantiating a variable, and a different value needs to be instantiated.
Proof by Contradiction
- Hypotheses: set of pertinent propositions.
- Goal: theorem negation stated as a proposition.
- Theorem proven by finding an inconsistency.
Theorem Proving
- Theorem proving is the basis for logic programming.
- When propositions are used for resolution, only a restricted form can be used.
- Horn clauses have only two forms: headed and headless.
- Headed: single atomic proposition on left side.
- Headless: empty left side (used to state facts).
- Most propositions can be stated as Horn clauses.
Overview of Logic Programming
- Declarative semantics: a simple way to determine the meaning of each statement that is simpler than the semantics of imperative languages.
- Programming is nonprocedural: Programs do not state how a result is to be computed, but rather the form of the result.
Example: Sorting a List
- Describe the characteristics of a sorted list, not the process of rearranging a list i.e. sort(old_list, new_list) ⊂ permute (old_list,new_list) ∩ sorted (new_list)
- The formula* sorted (list) ⊂ ∀j such that 1≤ j < n, list(j) ≤ list (j+1)* is an example of describing the characteristics of a sorted list.
The Origins of Prolog
- University of Aix-Marseille (Calmerauer & Roussel): Natural language processing
- University of Edinburgh (Kowalski): Automated theorem proving
Terms
- Edinburgh syntax of Prolog is used.
- A term is a constant, variable, or structure.
- A constant is an atom or an integer.
- An atom is a symbolic value of Prolog and consists of a string of letters, digits, and underscores beginning with a lowercase letter or a string of printable ASCII characters delimited by apostrophes.
Terms: Variables and Structures
- A variable is any string of letters, digits, and underscores beginning with an uppercase letter.
- Instantiation is the binding of a variable to a value and lasts only as long as it takes to satisfy one complete goal.
- Structure represents atomic proposition functor (parameter list)
Fact Statements
- Fact statements are used for the hypotheses.
- They are headless Horn clauses i.e.
female(shelley).
,male(bill).
,father(bill, jake).
Rule Statements
- Rule statements are used for the hypotheses.
- They are headed Horn clauses
- The right side of a rule statement is the antecedent (if part) which may be single term or conjunction
- The left side of a rule statement is the consequent (then part) which must be single term
- Conjunction is multiple terms separated by logical AND operations (implied).
Example Rules
- Variables can be used to generalize meaning i.e. universally quantified objects.
parent(X,Y):- mother(X,Y).
is an example of a rule statement.grandparent(X,Z):- parent(X,Y), parent(Y,Z).
is an example of a rule statement.
Goal Statements
- For theorem proving, a theorem is in the form of a proposition that is to be proven or disproven via a goal statement.
- Goal statements have the same format as headless Horn clauses i.e.
man(fred)
- Conjunctive propositions and propositions with variables are also legal goals i.e.
father(X, mike)
Inferencing Process of Prolog
- Queries are called goals.
- If a goal is a compound proposition, each of the facts is a subgoal.
- To prove a goal is true, a chain of inference rules and/or facts.
- Proving a subgoal is called matching, satisfying, or resolution.
Approaches
- Matching is the process of proving a proposition.
- Proving a subgoal is called satisfying the subgoal.
- Bottom-up resolution is forward chaining which begins with facts and rules of database and finds sequence that leads to goal effectively for large sets of correct answers
- Top-down resolution, or backward chaining, begins with a goal and attempts to find sequence that leads to set of facts in database, effective for small sets of correct answers
- Prolog implementations use backward chaining.
Subgoal Strategies
- When a goal has more than one subgoal, either depth-first or breadth-first search strategies can be used.
- Depth-first search finds a complete proof for the first subgoal before working on others.
- Breadth-first search works on all subgoals in parallel.
- Prolog uses depth-first search and can be done with fewer computer resources.
Backtracking
- When one of multiple subgoals cannot be satisfied, the previous subgoal is reconsidered to find an alternate solution.
- Begin search where previous search left off.
- Backtracking can take lots of time and space because all possible proofs to every subgoal may need to be found.
Simple Arithmetic
- Prolog supports integer variables and integer arithmetic.
is
operator takes an arithmetic expression as right operand and variable as left operand.- A
is
operator is not the same as an assignment statement
Example
speed(ford,100).
speed(chevy,105).
speed(dodge,95)
speed(volvo,80).
time(ford,20)
time(chevy,21).
time(dodge,24).
time(volvo,24).
distance(X,Y) :- speed(X,Speed), time(X,Time), Y is Speed * Time.
- Distance is computed as Speed * Time
- A query example is
distance(chevy, Chevy_Distance).
Trace
- A trace is a built-in structure that displays instantiations at each step.
- The tracing model of execution includes four events: Call, Exit, Redo, Fail.
- Call is the beginning of attempt to satisfy goal.
- Exit is when a goal has been satisfied.
- Redo is when backtrack occurs.
- Fail is when goal fails.
Example
likes(jake,chocolate).
likes(jake, apricots)
likes(darcie, licorice).
likes(darcie, apricots)
trace.
likes(jake, X), likes(darcie, X).
(1) 1 Call: likes(jake, _0)?
(1) 1 Exit: likes(jake, chocolate)
(2) 1 Call: likes(darcie, chocolate)?
(2) 1 Fail: likes(darcie, chocolate)
(1) 1 Redo: likes(jake, _0)?
(1) 1 Exit: likes(jake, apricots)
(3) 1 Call: likes(darcie, apricots)?
(3) 1 Exit: likes(darcie, apricots)
X = apricots
List Structures
- List is a basic data structure (besides atomic propositions we have already seen) which is a sequence of elements.
- Elements can be atoms, atomic propositions, or other terms (including other lists)
[apple, prune, grape, kumquat]
is a list of atoms[]
an empty list[X | Y]
is the head X and tail Y
Append Example
append([], List, List).
append([Head | List_1], List_2, [Head | List_3]) :-
append (List 1, List 2, List 3).
More Examples
- Underscore character means an anonymous variable, meaning instantiation does not matter.
reverse([], []).
reverse([Head | Tail], List) :-
reverse (Tail, Result),
append (Result, [Head], List).
member(Element, [Element | _]).
member(Element, [_ | List]) :-
member(Element, List).
Deficiencies of Prolog
-
Resolution order control
-
Order Matches are non deterministic as all matches would be attempted concurrently in a pure logic programming environment
-
In Closed-world assumption the only knowledge is what in the database.
-
Negation Problem in which Anything not stated in the database is assumed to be false
-
Intrinsic limitations
-
It is easy to state a sort process in logic, but does not know how to sort.
Applications of Logic Programming
- Relational database management systems
- Expert systems
- Natural language processing
Summary
- Symbolic logic provides the basis for logic programming.
- Logic programs should be nonprocedural.
- Prolog statements are facts, rules, or goals.
- Resolution is the primary activity of a Prolog interpreter.
- Although there are a number of drawbacks with the current state of logic programming, it has been used in a number of areas.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.