1 / 16

Logic Programming

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

jens
Download Presentation

Logic Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logic Programming

  2. Formal Logics- Recap • Formulas • w/out quantifiers • Free Variables • Bound Variables • Assignments and satisfaction • Validity and satisfiability

  3. 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

  4. 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

  5. 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

  6. 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

  7. Is it even feasible? • Hilbert’s first decision problem: given a first order logic formula, decide whether it is satisfiable • Undecidable!

  8. 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,…

  9. 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.

  10. 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

  11. 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).

  12. Variables and constants • Variables begin with an upper-case, constants with lower-case • Variables in facts are universally quantified

  13. Rules • father(Dad, Child) :- parent(Dad, Child), male(Dad). • ancestor (Anc, Child) :- parent(Anc, X), ancestor(X, Child).

  14. 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.

  15. Variables • Variables in facts are universally quantified • In queries they are existentially quantified • father(X,Ron). • ?- father(Y,Ron). true

  16. Proofs

More Related