Logic Programming Automated Reasoning in practice.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

1 Knowledge Representation Introduction KR and Logic.
Some Prolog Prolog is a logic programming language
Logic: The Big Picture Propositional logic: atomic statements are facts –Inference via resolution is sound and complete (though likely computationally.
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Inference Rules Universal Instantiation Existential Generalization
SLD-resolution Introduction Most general unifiers SLD-resolution
Chapter 11 :: Logic Languages
AR for Horn clause logic Introducing: Unification.
Automated Reasoning Systems For first order Predicate Logic.
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
Default Reasoning the problem: in FOL, universally-quantified rules cannot have exceptions –  x bird(x)  can_fly(x) –bird(tweety) –bird(opus)  can_fly(opus)
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
1 DCP 1172 Introduction to Artificial Intelligence Chang-Sheng Chen Topics Covered: Introduction to Nonmonotonic Logic.
Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
Everything You Need to Know (since the midterm). Diagnosis Abductive diagnosis: a minimal set of (positive and negative) assumptions that entails the.
For Friday Finish chapter 10 No homework (get started on program 2)
1 Applied Computer Science II Resolution in FOL Luc De Raedt.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
A Probabilistic Framework for Information Integration and Retrieval on the Semantic Web by Livia Predoiu, Heiner Stuckenschmidt Institute of Computer Science,
Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language.
The idea of completion In LP one uses “if” but mean “iff” [Clark78] This doesn’t imply that -1 is not a natural number! With this program we mean: This.
Auto-Epistemic Logic Proposed by Moore (1985) Contemplates reflection on self knowledge (auto-epistemic) Allows for representing knowledge not just about.
Knoweldge Representation & Reasoning
ASP vs. Prolog like programming ASP is adequate for: –NP-complete problems –situation where the whole program is relevant for the problem at hands èIf.
Let remember from the previous lesson what is Knowledge representation
Artificial Intelligence Chapter 17 Knowledge-Based Systems Biointelligence Lab School of Computer Sci. & Eng. Seoul National University.
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
ASP vs. Prolog like programming ASP is adequate for: –NP-complete problems –situation where the whole program is relevant for the problem at hands èIf.
First Order Logic. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about first order.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Review I Rosen , 3.1 Know your definitions!
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
Pattern-directed inference systems
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
Logical Agents Logic Propositional Logic Summary
1 Knowledge Representation. 2 Definitions Knowledge Base Knowledge Base A set of representations of facts about the world. A set of representations of.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
Propositional Logic Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma Guadalajara
Albert Gatt LIN3021 Formal Semantics Lecture 4. In this lecture Compositionality in Natural Langauge revisited: The role of types The typed lambda calculus.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
October 17, 2012Introduction to Artificial Intelligence Lecture 11: Knowledge Representation and Reasoning I 1Semantics In propositional logic, we associate.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 24, 2012.
Automated Reasoning Systems For first order Predicate Logic.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
First-Order Logic Semantics Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read: FOL.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Knowledge Representation Lecture 2 out of 5. Last Week Intelligence needs knowledge We need to represent this knowledge in a way a computer can process.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Announcements No office hours today!
Lecture 1 – Formal Logic.
Artificial Intelligence Chapter 17 Knowledge-Based Systems
Knowledge-Based Systems Chapter 17.
Artificial Intelligence Chapter 17 Knowledge-Based Systems
Chapter 7: Beyond Definite Knowledge
CS 416 Artificial Intelligence
Back to “Serious” Topics…
Artificial Intelligence Chapter 17. Knowledge-Based Systems
Artificial Intelligence Chapter 17 Knowledge-Based Systems
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Presentation transcript:

Logic Programming Automated Reasoning in practice

2  But: people seldom reason monotonically !  First order logic is monotone: G T ’ Motivation: monotonicity T|=F1 F2 F3 + Fred is a penguin Birds fly + Fred is a bird Fred flies

3 Default reasoning:  Is a form of reasoning that we’d like to use permanently  otherwise the rules are far too complex!  Is usually supported by hierarchy, inheritance and exceptions in OOP  also an early AI-formalism  CANNOT be expressed in FOL  independent on the knowledge representation !!  CAN be expressed in some FOL extensions  non-monotone logics  the simplest one of those is … …

4 Logic Programming  Resolution-based automated reasoning:  restricted to Horn clauses  restricted to backwards linear resolution  BUT: with 3 important new extensions:  return Answer Substitutions  Least-model semantics instead of standard FOL model semantics  Extending Horn clause logic with Negation as Finite Failure

Answer substitutions The link to programming

6 Answer substitutions anc(x,y)  parent(x,y) (1) anc(x,y)  parent(x,z)  anc(z,y) (2) parent(A,B) (3) parent(B,C) (4) false  anc(u,v) false  parent(x1,z1)  anc(z1,y1) (2) {u/x1,v/y1} false  anc(B,y1) (3) {x1/A,z1/B} false  parent(B,y1) (1) {x2/B, y2/y1} false  (4) {y1/C} Answer: Yes,  u  v anc(u,v) That is: u = A and v = C (composition of all mgu’s applied to the goal variables)

7 The third answer: u = B and v = C Another answer: u = A and v = B And computes ALL answers false  anc(u,v) false  parent(x1,y1) (1) {u/x1,v/y1} false  (3) {x1/A,y1/B} false  (4) {x1/B,y1/C} anc(x,y)  parent(x,y) (1) anc(x,y)  parent(x,z)  anc(z,y) (2) parent(A,B) (3) parent(B,C) (4) false  anc(u,v)

8 Logic PROGRAMMING  By computing answer substitutions Logic Programming serves as a de basis for a number of “general purpose” programming languages.  Prolog, Mercury, XSB, …  with an efficiency comparable with C !  and even faster for some programs.

9 Practical programming?  Example arithmetic: double_plus_1(x,y)  y is 2*x + 1  Example lists: append([], list, list)  append([x|list1], list2, [x|list3])  append(list1, list2, list3) false  double_plus_1(3,z) Yes: z=7 false  double_plus_1(2,5) Yes false  append([1,2], [3,4,5], z) Yes: z= [1,2,3,4,5] false  append([1,2], y, [1,2,3]) Yes: y= [3] false  append(x, y, [1,2]) Yes: x = [], y = [1,2] x = [1], y = [2] x = [1], y = [2] …

Least model semantics Specify in a more compact way

11 Least model semantics  Example: a database: celebrity(Crabé)celebrity(Jambers)celebrity(Peeters) celebrity(Lisa)celebrity(Tieleman)celebrity(Samson)  Is DeSchreye a celebrity ?? false  celebrity(DeSchreye)  We get no proof of inconsistency !  FOL semantics says: celebrity(DeSchreye) is not logically entailed, thus: we do not know if it is true or not!  Least model semantics says: ~ celebrity(DeSchreye)

12  What are the atomic consequences of theory T? T  In FOL: Formally: the idea Consequences are in the intersection: p en ~r. We do not know anything about the truth of q and s. model 3 q ~s model 2 p ~r ~q s model 1  In LP: Consequences are in the intersection: p en ~r. Other predicates are NOT true: ~q and ~s.

13 Relation with FOL celebrity(Crabé)celebrity(Jambers)celebrity(Peeters) celebrity(Lisa)celebrity(Tieleman)celebrity(Samson)  The logic program: celebrity(Crabé)celebrity(Jambers)celebrity(Peeters)~celebrity(DeSchreye)~celebrity(Janssens)… celebrity(Lisa)celebrity(Tieleman)celebrity(Samson)~celebrity(Cobain)~celebrity(Dali)…  is equivalent to the infinite FOL theory:  x celebrity(x)  (x = Crabé)  (x = Jambers)  (x = Peeters)  (x = Lisa)  ( x = Tieleman)  (x = Samson) (x = Lisa)  ( x = Tieleman)  (x = Samson)  or also to:

14 The “closed” assumption  Logic programming provides a compact way to express ‘complete knowledge’ on some subject.  If you do not say that something is true, than it is false.  In other words: Logic Programming supports formulating definitions of the concepts.  Not just state what is true about these concepts (=FOL) !  The Closed World Assumption !  (= everything not entailed by the theory is false)

15 How relevant is the change of semantics?  In FOL: {smart(Kelly)} implies neither strong(Kelly) nor ~strong(Kelly)  In LP: {smart(Kelly)} implies ~strong(Kelly)  In particular: LP is a non-monotone logic !!  In {smart(Kelly), strong(Kelly)}, ~strong(Kelly) is no longer entailed.  Knowledge is differently represented in these 2 formalisms.  Also: some concepts can be completely axiomatized in LP but not in FOL.  Ex.: the natural numbers !

Negation as finite failure

17 Negation as finite failure  The basic idea:  extending the representation power of Logic Programming beyond the Horn Clauses logic  How?  equivalent:  allow disjunctions in the heads  allow negation before the body atoms –both give complete predicate logic ! –(but: with the least model semantics we will get something different from FOL!) Here: Introduce negations in bodies !

18  Not the meaning of standard negation Meaning of negation as finite failure If all attempts to prove B using linear LP-resolution, fail in a finite time, conclude than not(B)  not(B) means:  This is meaningful only with the least model semantics (where everything that is not proven to be ‘true’, is considered to be ‘false’)

19  Try to prove that “anc(John,B)” holds! false  anc(John,B) The ancestor example anc(x,y)  parent(x,y) (1) anc(x,y)  parent(x,z)  anc(z,y) (2) parent(A,B) (3) parent(B,C) (4) false  anc(u,v)  Conclusion: not anc(John,B) false  parent(John,B) (1) {x/John,y/B}fails false  parent(John,z)  anc(z,B) (2) {x/John,y/B}fails

20 even(0) even(s(s(x)))  even(x) odd(y)  not even(y) false  odd(s(s(s(0)))) false  even(s(s(s(0)))) Another example false  not even(s(s(s(0)))) false  even(s(0)) {x/s(0)} fails Proof for even(s(s(s(0)))) fails: conclusion not even(s(s(s(0)))) false 

21 q  q p  not q false  p false  q And another example  But ~q is true according to the least model semantics! false  not q false  q … Proof for q goes into infinite derivation: no conclusion for q no answer

22 {x/Fly} false <- locomotion(Fred,x) false <- abnormal1(Fred) Default reasoning in LP (1): locomotion(x,Fly)  isa(x,Bird), not abnormal1(x) locomotion(x,Walk)  isa(x,Ostrich), not abnormal2(x) isa(x,Bird)  isa(x,Ostrich) abnormal1(x)  isa(x,Ostrich) Also known: isa(Fred,Bird), Prove that:  x locomotion(Fred,x) false <- isa(Fred,Bird), not abnormal1(Fred) false <- not abnormal1(Fred) false <- fails false <- isa(Fred,Ostrich)

23 Default reasoning in LP (2): Also known: isa(Fred,Ostrich), Prove that:  x locomotion(Fred,x) locomotion(x,Fly)  isa(x,Bird), not abnormal1(x) locomotion(x,Walk)  isa(x,Ostrich), not abnormal2(x) isa(x,Bird)  isa(x,Ostrich) abnormal1(x)  isa(x,Ostrich) isa(Fred,Bird) {x/Fly} false <- locomotion(Fred,x) false <- abnormal1(Fred) false <- isa(Fred,Bird), not abnormal1(Fred) false <- not abnormal1(Fred) false <- isa(Fred,Ostrich) false <- fails (for this branch) backtracking: the 2nd branch

24 Default reasoning (3): Also known: isa(Fred,Ostrich), Prove that:  x locomotion(Fred,x) locomotion(x,Fly)  isa(x,Bird), not abnormal1(x) locomotion(x,Walk)  isa(x,Ostrich), not abnormal2(x) isa(x,Bird)  isa(x,Ostrich) abnormal1(x)  isa(x,Ostrich) isa(Fred,Bird) {x/Walk} false <- locomotion(Fred,x) false <- abnormal2(Fred) false <- isa(Fred,Ostrich), not abnormal2(Fred) false <- not abnormal2(Fred) false <- fails

25  A specific programming language based on LP. Prolog  Uses a depth-first strategy to search linear resolution proofs.  incomplete  can get stuck in infinite branches  Has a bunch of built-in predicates (sometimes without logical meaning) for:  Numerical computations, input-output, changing the search strategy, meta-programming, etc.  More recent LP languages: Goedel, Mercury, Hal,..

26 Beyond FOL and Logic Programming  Logic Programming is very useful if you have a COMPLETE knowledge over your predicates  FOL is very useful if your knowledge is INCOMPLETE  Combine !  Open Logic Programming  LP-definitions for the part for which you have a complete knowledge,  FOL formulae for the rest.

27 Constraint Logic Programming  Integrate constraint processing techniques (consistency, forward checking, looking ahead, …) with Logic Programming.  Advantages of Logic for knowledge representation  Advantages of Constraint solving for efficient problem solving  A number of languages: CHIP, Eclipse, Sicsus, etc.