Declarative Programming. 2: theoretical backgrounds

Similar documents
Simply Logical Chapter 2 Peter Flach, clausal logic. clausal logic. expressions that can be true or false. clausal logic

Full Clausal Logic - Syntax: clauses

CSL105: Discrete Mathematical Structures. Ragesh Jaiswal, CSE, IIT Delhi

Automated Reasoning PROLOG and Automated Reasoning 13.4 Further Issues in Automated Reasoning 13.5 Epilogue and References 13.

Integrity Constraints (Chapter 7.3) Overview. Bottom-Up. Top-Down. Integrity Constraint. Disjunctive & Negative Knowledge. Proof by Refutation

Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur

COMP4418 Knowledge Representation and Reasoning

Lecture 4: January 12, 2015

Propositional Logic. Part I

Knowledge-based Systems for Industrial Applications - Propositional Logic

Logic (or Declarative) Programming Foundations: Prolog. Overview [1]

Lecture 17 of 41. Clausal (Conjunctive Normal) Form and Resolution Techniques

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Resolution (14A) Young W. Lim 6/14/14

The Resolution Principle

Chapter 16. Logic Programming Languages

Knowledge Representation. CS 486/686: Introduction to Artificial Intelligence

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Logic and its Applications

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Constraint Solving. Systems and Internet Infrastructure Security

Towards a Logical Reconstruction of Relational Database Theory

Logic Programming Languages

Knowledge Representation

Logic Programming and Resolution Lecture notes for INF3170/4171

Introduction to predicate calculus

Part I Logic programming paradigm

What is the study of logic?

Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur

Chapter 3. Describing Syntax and Semantics

Knowledge Representation and Reasoning Logics for Artificial Intelligence

Logical reasoning systems

Propositional logic (Ch. 7)

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

Software Engineering Lecture Notes

Typed Lambda Calculus

Chapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction

Declarative programming. Logic programming is a declarative style of programming.

What if current foundations of mathematics are inconsistent? Vladimir Voevodsky September 25, 2010

(More) Propositional Logic and an Intro to Predicate Logic. CSCI 3202, Fall 2010

Chapter 16. Logic Programming Languages ISBN

First Order Predicate Logic CIS 32

Signed Formulas and Annotated Logics

Typed Lambda Calculus for Syntacticians

Chapter 2 & 3: Representations & Reasoning Systems (2.2)

The Logic Paradigm. Joseph Spring. 7COM1023 Programming Paradigms

Lecture 5. Logic I. Statement Logic

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Lecture 7: January 15, 2014

CSC 501 Semantics of Programming Languages

Propositional Theories are Strongly Equivalent to Logic Programs

LOGIC AND DISCRETE MATHEMATICS

Computation Club: Gödel s theorem

What's the difference between the entailment symbol with the equals vs the entailment symbol with one line? Single turnstile meaning

THE PREDICATE CALCULUS

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

Semantic Forcing in Disjunctive Logic Programs

For next Tuesday. Read chapter 8 No written homework Initial posts due Thursday 1pm and responses due by class time Tuesday

Artificial Intelligence. Chapters Reviews. Readings: Chapters 3-8 of Russell & Norvig.

CS61A Lecture 38. Robert Huang UC Berkeley April 17, 2013

III SEMESTER B. A. PHILOSOPHY PHL3B04 - SYMBOLIC LOGIC AND INFORMATICS QUESTION BANK FOR INTERNAL ASSESSMENT. Multiple Choice Questions

Database dependency discovery: a machine learning approach

(QiuXin Hui) 7.2 Given the following, can you prove that the unicorn is mythical? How about magical? Horned? Decide what you think the right answer

A proof-producing CSP solver: A proof supplement

CSE 20 DISCRETE MATH. Fall

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Chapter 16. Logic Programming Languages ISBN

Logic Languages. Hwansoo Han

Situation Calculus and YAGI

RESULTS ON TRANSLATING DEFAULTS TO CIRCUMSCRIPTION. Tomasz Imielinski. Computer Science Department Rutgers University New Brunswick, N.

First-Order Logic PREDICATE LOGIC. Syntax. Terms

Programming Languages Third Edition

CS221 / Autumn 2017 / Liang & Ermon. Lecture 17: Logic II

Summary of Course Coverage

1. Logic as a subject matter is the study of logics, understood as models of acceptable inference patterns

Propositional Logic. Andreas Klappenecker

Implementação de Linguagens 2016/2017

Operational Semantics

Axiomatic Specification. Al-Said, Apcar, Jerejian

Propositional Resolution Part 3. Short Review Professor Anita Wasilewska CSE 352 Artificial Intelligence

Logic and Computation

Deductive Methods, Bounded Model Checking

PROBABILISTIC GRAPHICAL MODELS SPECIFIED BY PROBABILISTIC LOGIC PROGRAMS: SEMANTICS AND COMPLEXITY

CS-171, Intro to A.I. Mid-term Exam Winter Quarter, 2014

Notes for Chapter 12 Logic Programming. The AI War Basic Concepts of Logic Programming Prolog Review questions

First Order Logic and Resolution

Self-reproducing programs. And Introduction to logic. COS 116: 3/6/2008 Sanjeev Arora

Context-Free Grammars

PdOd Kev Events I Re-world war I1 rwa

INF5390 Kunstig intelligens. First-Order Logic. Roar Fjellheim

Informatics 1. Computation and Logic. Lecture 17 The Big Ideas

6. Inference and resolution

CPS 506 Comparative Programming Languages. Programming Language Paradigm

Question 1: 25% of students lost more than 2 points Question 2: 50% of students lost 2-4 points; 50% got it entirely correct Question 3: 95% of

Submitted to the Department of Electrical Engineering and Computer Science in partial fulfillment of the requirements for the degree of.

Logic Programming and Reasoning about Actions

Chapter 3. Set Theory. 3.1 What is a Set?

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

Extending Prolog with Incomplete Fuzzy Information

Transcription:

Declarative Programming 2: theoretical backgrounds 1

Logic Systems: structure and meta-theoretical properties logic system syntax semantics proof theory defines which sentences are legal in the logical language gives a meaning to the sentences usually truth-functional: what is the truth value of a sentence given the truth value of its words specifies how to obtain new sentences (theorems) from assumed ones (axioms) through inference rules weakest form: prove nothing soundness about anything you can prove is true about completeness anything that is true can be proven 2

Logic Systems: roadmap towards Prolog propositional clausal logic statements that can be true or false clausal logic married;bachelor :- man,adult. relational clausal logic likes(peter,s):-student_of(s,peter). full clausal logic loves(x,person_loved_by(x)). statements concern relations among objects from a universe of discourse compound terms aggregate objects definite clause logic no disjunction in head Pure Prolog lacks control constructs, arithmetic of full Prolog 3

Propositional Clausal Logic - Syntax: clauses :- if ; or, and optional clause : head [:- body] head : [atom[;atom]*] zero or more body : atom[,atom]* atom : single word starting with lower case someone is married or a bachelor if he is a man and an adult married;bachelor:-man,adult. 4

Propositional Clausal Logic - Syntax: negative and positive literals of a clause clause H1;...;Hn : B1,...,Bm is equivalent to B H B H H1... Hn B1... Bm positive literals negative literals hence a clause can also be defined as a disjunction of literals L 1 L 2... L n where each L i is a literal, i.e. L i = A i or L i = A i, with A i a proposition. 5

Propositional Clausal Logic - Syntax: logic program to be read conjunctively finite set of clauses, each terminated by a period woman;man :- human. human :- man. human :- woman. is equivalent to (human (woman man)) (man human) (woman human) B H ( human woman man) ( man human) ( woman human) B H 6

Propositional Clausal Logic - Syntax: special clauses an empty body stands for true an empty head stands for false man :-. or man. :- impossible. true man impossible false man impossible 7

Propositional Clausal Logic - Semantics: Herbrand base, interpretation and models Herbrand base B P of a program P set of all atoms occurring in P Herbrand interpretation i of P when represented by the set of true propositions I: subset of Herband base mapping from Herbrand base B P to the set of truth values i : BP {true, false} An interpretation is a model for a clause if the clause is true under the interpretation. if either the head is true or the body is false An interpretation is a model for a program if it is a model for each clause in the program. H B H:-B true true true false true false true false true false false true 8

Propositional Clausal Logic - Semantics: example (1) program P woman;man :- human. human :- man. human :- woman. Herbrand base B P {woman,man,human} 2 3 possible Herbrand Interpretations I={woman} J={woman, man} K={woman, man, human} L={man} M={man, human} n={(woman,false), (man,false), (human,false)} N={human} O={woman, human} P= 9

Propositional Clausal Logic - Semantics: example (2) program P woman;man :- human. human :- man. human :- woman. H1... Hn B1... Bm for all clauses: either one atom in head is true or one atom in body is false 4 Herbrand interpretations are models for the program I={woman} J={woman, man} K={woman, man, human} L={man} N={human} M={man, human} O={woman, human} P= 10

Propositional Clausal Logic - Semantics: entailment P C P entails C clause C is a logical consequence of program P if every model of P is also a model of C program P woman. woman;man :- human. human :- man. human :- woman. P human models of P J = {woman,man,human} I = {woman,human} 11 intuitively preferred: doesn t assume anything to be true that doesn t have to be true

Propositional Clausal Logic - Semantics: minimal models no subset is a model itself could define best model to be the minimal one BUT woman;man :- human. human. has 3 models of which 2 are minimal K = {woman, human} L = {man, human} M = {woman,man,human} clauses have at most one atom in the head A definite logic program has a unique minimal model. 12

Propositional Clausal Logic - Proof Theory: inference rules how to check that P C without computing all models for P and checking that each is a model for C? by applying inference rules, C can be derived from P: P C purely syntactic, not concerned with semantics e.g., resolution has_wife:-man,married! has_wife;bachelor:-man,adult! married;bachelor:-man,adult! happens to be a logical consequence of the program consisting of both input clauses 13

Propositional Clausal Logic - Proof Theory: man adult married bachelor man married has_wife case analysis of resolution either married, in order for second clause to be true as well: man has_wife or married, in order for first clause to be true as well: man adult bachelor therefore man adult bachelor man has_wife 14

Propositional Clausal Logic - Proof Theory: special cases of resolution E2 absent E1=A E3B modus ponens A A B A A B resolution E1 E2 E2 E3 E1 E3 E1= A E2=B E3 absent B A B B A B A B B A If it s raining it s wet; it s not wet, so it s not raining modus tollens 15

Propositional Clausal Logic - Proof Theory: successive applications of the resolution inference rule A proof or derivation of a clause C from a program P is a sequence of clauses C 0,...,C n =C such that i 0...n : either C i P or C i is the resolvent of C i1 and C i2 (i 1 <i,i 2 <i). If there is a proof of C from P, we write P C square:-rectangle,equal_sides! rectangle:-parallelogram,right_angles! square:-parallelogram,right_angles,equal_sides! resolvent can be used in further resolutions 16

Propositional Clausal Logic - Meta-theory: resolution is sound for propositional clausal logic if P C then P C because every model of the two input clauses is also a model for the resolvent by case analysis on truth value of resolvent 17

Propositional Clausal Logic - Meta-theory: resolution is incomplete incomplete the tautology a :- a is true under any interpretation hence any model for a program P is also a model of hence P a :- a however, resolution cannot establish P a :- a a :- a 18

Propositional Clausal Logic - Meta-theory: resolution is refutation-complete P C it derives the empty clause from any inconsistent set of clauses entailment reformulated each model of P is also a model of C no model of P is a model of C P C has no model P C is inconsistent C = L 1 L 2... L n C = L 1 L 2... L n = { L 1, L 2..., L n } = set of clauses itself refutationcomplete it can be shown that: if Q is inconsistent then Q if P C then P C empty clause false :- true for which no model exists 19

Propositional Clausal Logic - Meta-theory: example proof by refutation using resolution P happy :- has_friends. friendly :- happy. friendly :- has_friends. C P C happy :- has_friends. friendly :- happy. has_friends. :- friendly. = (friendly:-has_friends) = (friendly has_friends) = friendly has_friends P C 20