1/43
Looks like no tags are added yet.
Logic programming languages
Logic programming languages use programs expressed in symbolic logic
Logical inferencing process
is used to generate results
Logical programming
is declarative instead of procedural
Desired results are specified, not the method for producing them
Proposition
A proposition is a logical statement that may or may not be true
Objects in propositions are represented by _____________
simple terms: constants or variables
Constant
⢠Constant - A symbol that represents an object
Variable
⢠Variable - A symbol that can represent different objects at different times
Atomic Propositions
⢠Atomic propositions consist of compound terms
Compound terms
⢠Compound term - one element of a mathematical relation written in a form that
has the appearance of a mathematical function
Functor - function symbol that names the relationship
Ordered list of parameters (tuple)
student(jim)
like(Bob, MacOS)
Symbolic logic
can be used for the three basic needs of formal logic
⢠Express propositions
⢠Express relationship between propositions
⢠Describe how new propositions can be inferred from other propositions
The form used for logic programming
The form used for logic programming is first-order predicate calculus
What can propositions be?
⢠Can be a fact or a query
Fact is assumed to be true
Query is a proposition whose truth is to be determined
Compound Proposition
A compound proposition can have two or more atomic propositions that are connected by operators
Clausal form
⢠As defined, there are too many ways to state the same thing
⢠Need a standard form for propositions
⢠This is the clausal form
B1 āŖ B2 ⪠⦠⪠Bn ā A1 ā© A2 ā© .. ā© Am
This means that if all of the As are true, then at least one B is true
Antecedent - right side
Consequent - left side
⢠likes(bob, tuna) ā likes(bob, fish) ā© fish(tuna)
Propositions are used to discoverā¦
New theorems that can be inferred from known axioms and theorems
Resolution
an inference principle that allows inferred propositions to be computed from given propositions
Unification
Unification - finding values for variables in propositions that allows
the matching process to succeed
Instantiation
Instantiation - assigning temporary values to variables to allow
unification to succeed
After instantiating a variable with a value, if matching fails, we may
need to backtrack and instantiate with a different value
Refutation complete
Refutation complete - Given a set of inconsistent propositions, resolution can prove them to be inconsistent
Proof by contradiction
Assume the negative of a theorem, then prove it true by finding an
inconsistency
Theorem proving is theā¦
basis of logic programming
⢠Must use the restricted form for propositions
⢠Horn clause
Headed - single atomic proposition on the left side
Headless - empty left side (facts)
Declarative semantics
⢠There is a simple way to determine the meaning of each statement
⢠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
The Basic Elements of Prolog
Term, constant, atom, variable, Instantiation, Structure
Term
Term - a constant, variable, or structure
Constant
Constant - an atom or an integer
Atom
Atom - symbolic value of Prolog
Consists of either
⢠String of letters, digits, and underscores starting with a lowercase letter
⢠String of printable ASCII characters delimited by apostrophes
Variable
Variable - any string of letters, digits, and underscores beginning with
an uppercase letter
Instantiation
binding of a variable to a value
⢠Lasts only as long as it takes to satisfy one complete goal
Structure
Structure - represents atomic proposition
⢠functor (parameter list)
Fact statements
Used for the hypothesis
Headless horn clauses
⢠female(jill)
⢠male(bill)
⢠father(bill, jill)
Rule statements
⢠Used for the hypothesis
⢠Headed Horn clause
⢠Right side: antecedent (if part)
May be a single term or conjunction
⢠Left side: consequent (then part)
Must be a single term
⢠Conjunction - multiple terms separated by logical AND operations
Goal statements
⢠For theorem proving, theorem is in the form of proposition that we want the system to prove or disprove - goal statement
⢠Same format as headless Horn
man(fred)
System will respond with yes or no.
father(X, mike)
System will try to find a value for X for which the theorem is true
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, must find a chain of inference rules and/or facts
⢠Process of proving a subgoal is called matching, satisfying, or resolution
Approaches to inferencing process of Prolog
⢠Bottom-up resolution, forward chaining
Begin with the facts and rules of a database and attempt to find a sequence that leads to a goal. Works well with a large set of possible answers.
Matching
is the process of proving a proposition
Satisfying the subgoal
Proving a subgoal is called satisfying the subgoal
Bottom-up resolution, forward chaining
Begin with the facts and rules of a database and attempt to find a sequence that
leads to a goal. Works well with a large set of possible answers.
Top-down resolution, backward chaining
Begin with the goal and attempt to find a sequence that leads to set of facts
in database. Works well with a small set of possibly correct answers.
Prolog implementations use
backward chaining
When a goal has more than one subgoal
⢠Depth-first search: find a complete proof for the first subgoal before working on others
⢠Breadth-first search: work on all subgoals in parallel
⢠Prolog uses depth-first search
Backtracking
⢠With a goal with multiple subgoals, if a subgoal fails truth, reconsider a previous subgoal to find an alternative solution
⢠Begin where the previous search left off
⢠Can take lots of time and space because it may find all possible proofs to every subgoal
Simple Arithmetic
⢠Integer variables and arithmetic is supported
⢠is operator (not an assignment)
⢠A is B / 17 + C - LEGAL
⢠Sum is Sum + Number - ILLEGAL!
Trace