Download Slides set 9

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Logic Programming
Formal Logics- Recap
• Formulas
– w/out quantifiers
• Free Variables
• Bound Variables
• Assignments and satisfaction
• Validity and satisfiability
Formal Logics- Proofs
• Satisfaction of a formula should be proved
– Based on facts (assertions, assumptions, axioms)
and inference rules
• We are led to a notion of Proof Trees
– Why trees?
• Proofs are informative!
– E.g. assignment to an existential variable
Logic and Programming
• Can we automate the process of proving
logical statements?
• First we need a syntax for defining assertions,
rules,..
• Then we need an automated proof system
Logic and Programming
• Can we automate the process of proving logical
statements?
• First we need a syntax for defining facts, rules,
statements to-be-proved
• Then we need an automated proof system
• Note that in principle we may need to use a fact
multiple times so no a-priori bound on the proof size
Applications
• Theory behind database query languages is
based on logic
– Querying a database = looking for a satisfying
assignment to a query, based on the database
facts
• Automated Verification
– Describe (e.g. Java) program as logical rules,
constraints on behavior as query
• Automated Theorem Proving
Is it even feasible?
• Hilbert’s first decision problem: given a first
order logic formula, decide whether it is
satisfiable
• Undecidable!
Tradeoff
• Classic tradeoff between expressive power of
languages and complexity of evaluation
• There are decidable fragments of First Order
Logic which are still quite expressive
• SQL, Datalog, Description Logic, Prolog,…
Sub-cases
• We start with Relational Logic Programming
– Facts are relations between elements, relatively
simple rules allow to infer new relations
• Then move on to Full Logic Programming
– Allow function symbols etc.
Syntax
• We consider the Prolog syntax for describing
facts and rules
• Very similar to the Datalog syntax
• Other LP languages use different syntax, but
similar ideas
Facts
•
•
•
•
•
•
•
% Signature: parent(Parent, Child)/2
% Purpose: Parent is a parent of Child
parent(rina, moshe).
parent(rina, rachel).
parent(rachel, yossi).
parent(reuven, moshe).
% Signature: male(Person)/1
•
•
•
•
•
•
•
•
% Purpose: Person is a male.
male(moshe).
male(yossi).
male(reuven).
% Signature: female(Person)/1
% Purpose: Person is a female.
female(rina).
female(rachel).
Variables and constants
• Variables begin with an upper-case, constants
with lower-case
• Variables in facts are universally quantified
Rules
• father(Dad, Child) :parent(Dad, Child), male(Dad).
• ancestor (Anc, Child) :parent(Anc, X), ancestor(X, Child).
Queries
• ?- father(D,C).
– D = reuven,
– C = moshe.
• ?- father(reuven,moshe).
– true.
• ?- mother(M,C).
–
–
–
–
–
–
–
M = rina,
C = moshe ;
M = rina,
C = rachel ;
M = rachel,
C = yossi ;
fail.
Variables
• Variables in facts are universally quantified
– In queries they are existentially quantified
• father(X,Ron).
• ?- father(Y,Ron).
true
Proofs