Logic (3A) Young W. Lim 12/5/13

Similar documents
Logic (3A) Young W. Lim 10/29/13

Logic (3A) Young W. Lim 11/2/13

Logic (3A) Young W. Lim 10/31/13

Propositional Logic Resolution (6A) Young W. Lim 12/12/16

Propositional Logic Resolution (6A) Young W. Lim 12/31/16

Propositional Logic Logical Implication (4A) Young W. Lim 4/11/17

First Order Logic (1A) Young W. Lim 11/5/13

Propositional Logic Logical Implication (4A) Young W. Lim 4/21/17

First Order Logic (1A) Young W. Lim 11/18/13

Propositional Logic Arguments (5A) Young W. Lim 10/11/16

Propositional Logic Arguments (5A) Young W. Lim 11/30/16

Propositional Logic (2A) Young W. Lim 11/8/15

First Order Logic Implication (4A) Young W. Lim 4/6/17

Propositional Logic Arguments (5A) Young W. Lim 11/8/16

Logic Background (1A) Young W. Lim 5/14/18

Logic Background (1A) Young W. Lim 12/14/15

Resolution (14A) Young W. Lim 8/15/14

Foundations of Logic Programming

Propositional Logic Arguments (5B) Young W. Lim 11/30/16

Propositional Logic Arguments (5A) Young W. Lim 11/29/16

Propositional Logic Arguments (5A) Young W. Lim 2/23/17

First Order Logic Arguments (5A) Young W. Lim 2/24/17

Logic Programs Using Semantic Trees

First Order Logic Semantics (3A) Young W. Lim 9/17/17

3. The Logic of Quantified Statements Summary. Aaron Tan August 2017

First Order Logic Semantics (3A) Young W. Lim 8/9/17

First Order Logic Arguments (5A) Young W. Lim 3/10/17

Logical reasoning - Can we formalise our thought processes?


Propositional Logic: Models and Proofs

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Introduction to Metalogic

Logical Inference 2 rule based reasoning

University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter

Learning Goals of CS245 Logic and Computation

Propositional and Predicate Logic - V

Chapter 16. Logic Programming. Topics. Logic Programming. Logic Programming Paradigm

3 The Semantics of the Propositional Calculus

Introduction to Sets and Logic (MATH 1190)

Strong AI vs. Weak AI Automated Reasoning

Propositional Logic Language

COMP 182 Algorithmic Thinking. Proofs. Luay Nakhleh Computer Science Rice University

Implication (6A) Young Won Lim 3/12/18

Implication (6A) Young Won Lim 3/17/18

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Advanced Topics in LP and FP


Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19.

Inference Methods In Propositional Logic

CSC384: Intro to Artificial Intelligence Knowledge Representation II. Required Readings: 9.1, 9.2, and 9.5 Announcements:

Lloyd-Topor Completion and General Stable Models

Prolog. Resolution (for beginners?) Resolution (cont.) Resolution (cont.) Unification. Resolution (still cont.) Resolution & Unification

ECE473 Lecture 15: Propositional Logic

arxiv: v1 [cs.lo] 8 Jan 2013

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

cis32-ai lecture # 18 mon-3-apr-2006

Propositional Logic Not Enough

Artificial Intelligence Chapter 7: Logical Agents

4 ENTER Adaptive Logics

Introduction to Answer Set Programming

Inference Methods In Propositional Logic

Two hours. Examination definition sheet is available at the back of the examination. UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

Logic. Knowledge Representation & Reasoning Mechanisms. Logic. Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning

Marie Duží

HW1 graded review form? HW2 released CSE 20 DISCRETE MATH. Fall

Logic: Propositional Logic (Part I)

Chapter 11: Automated Proof Systems (1)

MAI0203 Lecture 7: Inference and Predicate Calculus

Advanced Topics in LP and FP

Lifted Inference: Exact Search Based Algorithms

Definite Logic Programs

Higher Order ODE's (3A) Young Won Lim 7/7/14

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

Language of Propositional Logic

Section 1.2: Propositional Logic

Matrix Transformation (2A) Young Won Lim 11/10/12

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Logic and Propositional Calculus

ICS141: Discrete Mathematics for Computer Science I

CogSysI Lecture 8: Automated Theorem Proving

Propositional Logic: Review

1.1 Language and Logic

AI Principles, Semester 2, Week 2, Lecture 5 Propositional Logic and Predicate Logic

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Logic and Propositional Calculus

Mathematical Logic. Reasoning in First Order Logic. Chiara Ghidini. FBK-IRST, Trento, Italy

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic

First-Order Logic. Chapter Overview Syntax

Solutions to Sample Problems for Midterm

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

UNIFORM PROOFS AS A FOUNDATION FOR LOGIC PROGRAMMING. Computer and Information Science Department University of Pennsylvania, Philadelphia, PA 19104

Logic Programming Theory Lecture 7: Negation as Failure

Line Integrals (4A) Line Integral Path Independence. Young Won Lim 10/22/12

INTRODUCTION TO LOGIC

Higher Order ODE's (3A) Young Won Lim 12/27/15

Tecniche di Verifica. Introduction to Propositional Logic

Propositional Logic. Fall () Propositional Logic Fall / 30

Chapter 4: Classical Propositional Semantics

Resolution (7A) Young Won Lim 4/21/18

Transcription:

Copyright (c) 2013. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using OpenOffice.

Predicate Calculus Atoms Constants Numbers Simple Terms Variables Compound Terms functor(term 1,., term n ) Predicates Propositional Logic : no variable First Order Logic : variable unification (1) Every Prolog predicate : an atomic first-order logic formula (2) Commas separating subgoals : conjunctions in logic ( ^ ) (3) Prolog rules : implications (body head) : (antecedent consequent) (head :- body) : change the order of head and body (4) Queries : implications, (body ) : (antecedent consequent ) (?- body) (5) Every variable : universally quantified 3

Rules (1) Every Prolog predicate : an atomic first-order logic formula (2) Commas separating subgoals : conjunctions in logic ( ^ ) (3) Prolog rules : implications (body head) : (antecedent consequent) (head :- body) : change the order of head and body (4) Queries : implications, (body ) : (antecedent consequent ) (?- body) (5) Every variable : universally quantified head body is_bigger(x, Y) :- bigger(x, Y). x. y.(bigger(x, y) is_bigger(x, y)) antecedent consequent 4

Queries (1) Every Prolog predicate : an atomic first-order logic formula (2) Commas separating subgoals : conjunctions in logic ( ^ ) (3) Prolog rules : implications (body head) : (antecedent consequent) (head :- body) : change the order of head and body (4) Queries : implications, (body ) : (antecedent consequent ) (?- body) falsum : contradiction (5) Every variable : universally quantified empty head body (A 1 A 2 A n ) B?- is_bigger(elephant, X), is_bigger(x, donkey). x.(is_bigger(elephant, x) ^ is_bigger(x, donkey) ) antecedent consequent (A 1 A 2 A n ) B A 1 A 2 A n B B A 1 A 2 A n A 1 A 2 A n 5

First Order Logic Formulas bigger(elephant, horse). bigger(horse, donkey). is_bigger(x, Y) :- bigger(x, Y). is_bigger(x, Y) :- bigger(x, Z), is_bigger(z, Y). { bigger(elephant, horse), bigger(horse, donkey), x. y.(bigger(x, y) is_bigger(x, y)), x. y. z.(bigger(x, z) ^ is_bigger(z, y) is_bigger(x, y)) } 6

Horn Formula (A 1 A 2 A n ) B (A 1 A 2 A n ) B A 1 A 2 A n B B A 1 A 2 A n A 1 A 2 A n A 1 A 2 A n : True when all A i is false contradict This results from the negation of the goal B Therefore B follows from all A i 7

Prolog Query?- A A A Putting the negation of the goal in a query into the set of formulas. Answering means showing that the set of formulas including the translated query is logically inconsistent. to show that A follows from P, show that adding the negation of A to P will lead to a contradiction. Adding the negation of A to P contradiction P, ( A ) iff P A the negation of A A follows from P 8

Resolution in the Propositional Logic A 1 A 2 B 1 B 1 B 2 A 1 A 2 T F B 2 A 1 A 2 F T B 2 A 1 A 2 B 2 B 2 (B 1 = T ) A 1 A 2 (B 1 = F) A 1 A 2 B 1 B 1 B 2 A 1 A 2 B 2 A 1 A 2 B 1 B 1 B 2 A 1 A 2 B 2 B1 :- A1, A2?- B1, B2?- A1, A2, B2?- B1, B2 Find a fact or a rule head that matches the first subgoal b1 B1 :- A1, A2?- A1, A2, B2 Replace the the subgoal with the body of the found rule repeated until there are no more subgoals left in the query. an empty disjunction 9

Resolution in the First Order Logic Propositional Logic : no variable First Order Logic : variable unification Unification : matching in Prolog the variable instantiations for successful queries 10

Negation As Failure (1) PLANNER if (not (goal p)), then (assert p) If the goal to prove p fails, then assert p NAF used to derive not p (p is assumed not to hold) from failure to derive p not p can be different from the statement p of the logical negation of p, depending on the completeness of the inference algorithm and thus also on the formal logic system Prolog NAF literals of the form of not p can occur in the body of clauses Can be used to derive other NAF literals p q not r q s q t t not p : p is assumed not to hold p : the logical negation of p completeness of the inference algorithm semantically complete every tautology theorem sound every theorem tautology 12/05/13 11 11

Negation As Failure (2) The semantics of NAF remained an open issue until Keith Clark [1978] showed that it is correct with respect to the completion of the logic program, where, loosely speaking, "only" and are interpreted as "if and only if", written as "iff" or " ". the completion of the four clauses above is p q not r q s t t true r false s false interpreted p q q t q not r s t 12/05/13 12 12

Negation As Failure (3) the completion of the four clauses above is p q not r q s t t true r false s false interpreted p q q t q not r s t ~q r p ~s q ~t q t The NAF inference rule simulates reasoning explicitly with the completion, where both sides of the equivalence are negated and negation on the right-hand side is distributed down to atomic formulae. to show not p, NAF simulates reasoning with the equivalences not p not q r ( false) not q not s not t ( false) not t false not r true not s true The NAF derives not r not s t q p 12/05/13 13 13

Negation As Failure (4) In the non-propositional case, (predicate logic with variables) the completion needs to be augmented with equality axioms, to formalise the assumption that individuals with distinct names are distinct. NAF simulates this by failure of unification. For example, given only the two clauses p(a) p(b) t NAF derives not p(c). The completion of the program is p(x) X=a X=b equality axioms augmented with unique names axioms and domain closure axioms. The completion semantics is closely related both to circumscription and to the closed world assumption. 12/05/13 14 14

Negation As Failure (5) The concept of logical negation in Prolog is problematical, in the sense that the only method that Prolog can use to tell if a proposition is false is to try to prove it (from the facts and rules that it has been told about), and then if this attempt fails, it concludes that the proposition is false. This is referred to as negation as failure. An obvious problem is that Prolog may not have been told some critical fact or rule, so that it will not be able to prove the proposition. In such a case, the falsity of the proposition is only relative to the "mini-world-model" defined by the facts and rules known to the Prolog interpreter. This is sometimes referred to as the closed-world assumption. p q not r q s t t true r false s false interpreted p q q t q not r s t A less obvious problem is that, depending again on the rules and facts known to the Prolog interpreter, it may take a very long time to determine that the proposition cannot be proven. In certain cases, it might "take" infinite time. 12/05/13 15 15

Negation As Failure (6) Because of the problems of negation-as-failure, negation in Prolog is represented in modern Prolog interpreters using the symbol \+, which is supposed to be a mnemonic for not provable with the \ standing for not and the + for provable. In practice, current Prolog interpreters tend to support the older operator not as well, as it is present in lots of older Prolog code, which would break if not were not available. Examples:?- \+ (2 = 4). true.?- not(2 = 4). true. 12/05/13 16 16

Negation As Failure (7) Arithmetic comparison operators in Prolog each come equipped with a negation which does not have a "negation as failure" problem, because it is always possible to determine, for example, if two numbers are equal, though there may be approximation issues if the comparison is between fractional (floating-point) numbers. So it is probably best to use the arithmetic comparison operators if numeric quantities are being compared. Thus, a better way to do the comparisons shown above would be:?- 2 =\= 4. true. 12/05/13 17 17

Negation As Failure Example 1 bachelor(p) :- male(p), not(married(p)). male(henry). male(tom). married(tom). The first three responses are correct and as expected. The answer to the fourth query might have been unexpected at first. But consider that the goal?-not(married(who)) fails because for the variable binding Who=tom, married(who) succeeds, and so the negative goal fails. Thus, negative goals?-not(g) with variables cannot be expected to produce bindings of the variables for which the goal g fails. Right Associative operator?- bachelor(henry). Yes?-bachelor(tom). No?-bachelor(Who). Who=henry; No?- not(married(who)). No. For the variable binding Who=tom, married(who) succeeds not(married(who)) fails Negative goals with variables cannot be expected to produce bindings of the variables for which the goals fails 12/05/13 18 18

Negation As Failure Example 2 p(x) :- q(x), not(r(x)). r(x) :- w(x), not(s(x)). q(a). q(b). q(c). s(a). s(c). w(a). w(b). p(x) p(a) p(b) p(c) q(x) not(r(x)) q(a) not(r(a)) q(b) not(r(b)) q(c) true true true not(r(c)) r(x) r(a) r(b) r(c) w(x) not(s(x)) w(a) true not(s(a)) w(b) true not(s(b)) w(c) not(s(c)) s(x) s(a) true s(b) s(c) true 12/05/13 19 19

References [1] en.wikipedia.org [2] en.wiktionary.org [3] U. Endriss, Lecture Notes : Introduction to Prolog Programming [4] http://www.learnprolognow.org/ Learn Prolog Now! [5] http://www.csupomona.edu/~jrfisher/www/prolog_tutorial [6] www.cse.unsw.edu.au/~billw/cs9414/notes/prolog/intro.html [7] www.cse.unsw.edu.au/~billw/dictionaries/prolog/negation.html 20

21