Introduction to Logic Programming

Similar documents
What is a Logic Program. Introduction to Logic Programming. Introductory Examples. Introductory Examples. Foundations, First-Order Language

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Automated Reasoning Systems

Lecture 4: January 12, 2015

Lecture 5: Predicate Calculus. ffl Predicate Logic ffl The Language ffl Semantics: Structures

Chapter 1.3 Quantifiers, Predicates, and Validity. Reading: 1.3 Next Class: 1.4. Motivation

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

Chapter 3: Propositional Languages

Review Material: First Order Logic (FOL)

Notes. Notes. Introduction. Notes. Propositional Functions. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry.

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

Part I Logic programming paradigm

Warm-Up Problem. Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol. Give an interpretation where

SC/MATH Boolean Formulae. Ref: G. Tourlakis, Mathematical Logic, John Wiley & Sons, York University

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

CSE 20 DISCRETE MATH. Fall

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

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

Logic Programming and Resolution Lecture notes for INF3170/4171

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

Lecture 7: January 15, 2014

Introduction to Logic Programming

Computer Science and Mathematics. Part I: Fundamental Mathematical Concepts Winfried Kurth

CSE 20 DISCRETE MATH. Winter

Set 7: Predicate logic Chapter 8 R&N. ICS 271 Fall 2015

Lecture 5. Logic I. Statement Logic

15-819M: Data, Code, Decisions

LTCS Report. Concept Descriptions with Set Constraints and Cardinality Constraints. Franz Baader. LTCS-Report 17-02

Automated Reasoning. Natural Deduction in First-Order Logic

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

SOFTWARE ENGINEERING DESIGN I

logic importance logic importance (2) logic importance (3) specializations of logic Horn logic specializations of logic RDF and OWL

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 37 Resolution Rules

Constraint Solving. Systems and Internet Infrastructure Security

This book is licensed under a Creative Commons Attribution 3.0 License

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

Decision Procedures in First Order Logic

Recap Datalog Datalog Syntax Datalog Semantics. Logic: Datalog. CPSC 322 Logic 6. Textbook Logic: Datalog CPSC 322 Logic 6, Slide 1

CS 512, Spring 2017: Take-Home End-of-Term Examination

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

Logic as a framework for NL semantics. Outline. Syntax of FOL [1] Semantic Theory Type Theory

Lecture 1. 1 Notation

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

Introduction to Sets and Logic (MATH 1190)

CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Introduction & Review

CS 321 Programming Languages and Compilers. Prolog

F. Brief review of classical predicate logic (PC)

Lexicografie computationala Feb., 2012

Automata Theory for Reasoning about Actions

Mathematical Logic

Going beyond propositional logic

CSC Discrete Math I, Spring Sets

Decision Procedures for Equality Logic. Daniel Kroening and Ofer Strichman 1

8. Relational Calculus (Part II)

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

PCP and Hardness of Approximation

Data types for mcrl2

Automatic Reasoning (Section 8.3)

Semantics and Pragmatics of NLP Propositional Logic, Predicates and Functions

COMP2411 Lecture 20: Logic Programming Examples. (This material not in the book)

CSE-321 Programming Languages 2010 Midterm

Logic and Databases. Phokion G. Kolaitis. UC Santa Cruz & IBM Research - Almaden

COMP 9416, session 1, 2006 p. 1. Datalog. COMP 9416, session 1, 2006

Relational Databases

Propositional Logic. Part I

Basic Elements of Computer Algebra in MIZAR

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

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Programming Languages Third Edition

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

CITS2211 Discrete Structures Logic

COMP Logic for Computer Scientists. Lecture 23

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 9 Normal Forms

Lecture 1: Conjunctive Queries

CIS 500 Software Foundations Midterm I

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012

Multi Domain Logic and its Applications to SAT

ITCS 6150 Intelligent Systems. Lecture 13 First-Order Logic Chapter 8

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

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Lecture 5: Formation Tree and Parsing Algorithm

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

Shared Variables and Interference

Situation Calculus and YAGI

2/18/14. Uses for Discrete Math in Computer Science. What is discrete? Why Study Discrete Math? Sets and Functions (Rosen, Sections 2.1,2.2, 2.

Abstract Syntax Trees L3 24

Lecture 9: Predicate Logic. First: Finish Propositional Logic in Haskell. Semantics in Haskell. Syntax In Haskell. CS 181O Spring 2016 Kim Bruce

Fundamental Concepts. Chapter 1

Conjunctive queries. Many computational problems are much easier for conjunctive queries than for general first-order queries.

Model-Checking Concurrent Systems. The Model Checker Spin. The Model Checker Spin. Wolfgang Schreiner

Constraint Satisfaction Problems (CSPs)

Logic: TD as search, Datalog (variables)

Syntax-semantics interface and the non-trivial computation of meaning

Solutions to Homework 10

One of the most important areas where quantifier logic is used is formal specification of computer programs.

CIS 771: Software Specifications. Lecture: Alloy Logic (part D)

8. Negation 8-1. Deductive Databases and Logic Programming. (Sommer 2017) Chapter 8: Negation

Reasoning About Imperative Programs. COS 441 Slides 10

Transcription:

Introduction to Logic Programming Foundations, First-Order Language Temur Kutsia RISC, Johannes Kepler University Linz, Austria kutsia@risc.jku.at

What is a Logic Program Logic program is a set of certain formulas of a first-order language. In this lecture: syntax and semantics of a first-order language.

Introductory Examples Representing John loves Mary : loves(john, Mary). loves: a binary predicate (relation) symbol. Intended meaning: The object in the first argument of loves loves the object in its second argument. John, Mary: constants. Intended meaning: To denote persons John and Mary, respectively.

Introductory Examples father: A unary function symbol. Intended meaning: The father of the object in its argument. John s father loves John: loves(father(john), John).

First-Order Language Syntax Semantics

Syntax Alphabet Terms Formulas

Alphabet A first-order alphabet consists of the following disjoint sets of symbols: A countable set of variables V. For each n 0, a set of n-ary function symbols F n. Elements of F 0 are called constants. For each n 0, a set of n-ary predicate symbols P n. Logical connectives,,,,. Quantifiers,. Parenthesis (, ), and comma,.

Alphabet A first-order alphabet consists of the following disjoint sets of symbols: A countable set of variables V. For each n 0, a set of n-ary function symbols F n. Elements of F 0 are called constants. For each n 0, a set of n-ary predicate symbols P n. Logical connectives,,,,. Quantifiers,. Parenthesis (, ), and comma,. Notation: x, y, z for variables. f, g for function symbols. a, b, c for constants. p, q for predicate symbols.

Terms Definition A variable is a term. If t 1,..., t n are terms and f F n, then f (t 1,..., t n ) is a term. Nothing else is a term.

Terms Definition A variable is a term. If t 1,..., t n are terms and f F n, then f (t 1,..., t n ) is a term. Nothing else is a term. Notation: s, t, r for terms.

Terms Definition A variable is a term. If t 1,..., t n are terms and f F n, then f (t 1,..., t n ) is a term. Nothing else is a term. Notation: s, t, r for terms. Example plus(plus(x, 1), x) is a term, where plus is a binary function symbol, 1 is a constant, x is a variable.

Terms Definition A variable is a term. If t 1,..., t n are terms and f F n, then f (t 1,..., t n ) is a term. Nothing else is a term. Notation: s, t, r for terms. Example plus(plus(x, 1), x) is a term, where plus is a binary function symbol, 1 is a constant, x is a variable. father(father(john)) is a term, where father is a unary function symbol and John is a constant.

Formulas Definition If t 1,..., t n are terms and p P n, then p(t 1,..., t n ) is a formula. It is called an atomic formula. If A is a formula, ( A) is a formula. If A and B are formulas, then (A B), (A B), (A B), and (A B) are formulas. If A is a formula, then ( x.a) and ( x.a) are formulas. Nothing else is a formula.

Formulas Definition If t 1,..., t n are terms and p P n, then p(t 1,..., t n ) is a formula. It is called an atomic formula. If A is a formula, ( A) is a formula. If A and B are formulas, then (A B), (A B), (A B), and (A B) are formulas. If A is a formula, then ( x.a) and ( x.a) are formulas. Nothing else is a formula. Notation: A, B for formulas.

Eliminating Parentheses Excessive use of parentheses often can be avoided by introducing binding order.,, bind stronger than. binds stronger than. binds stronger than and. Furthermore, Omit the outer parentheses and associate,,, to the right.

Eliminating Parentheses Example The formula ( y.( x.((p(x)) ( r(y))) (( q(x)) (A B))))) due to binding order can be rewritten into ( y.( x.(p(x) r(y) q(x) (A B)))) which thanks to the convention of the association to the right and omitting the outer parentheses further simplifies to y. x.(p(x) r(y) q(x) A B).

Example Translating English sentences into first-order logic formulas: 1. Every rational number is a real number. Assume: rational, real, prime: unary predicate symbols. : binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. Every rational number is a real number. x.(rational(x) real(x)) Assume: rational, real, prime: unary predicate symbols. : binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. Every rational number is a real number. x.(rational(x) real(x)) 2. There exists a number that is prime. Assume: rational, real, prime: unary predicate symbols. : binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. Every rational number is a real number. x.(rational(x) real(x)) 2. There exists a number that is prime. x. prime(x) Assume: rational, real, prime: unary predicate symbols. : binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. Every rational number is a real number. x.(rational(x) real(x)) 2. There exists a number that is prime. x. prime(x) 3. For every number x, there exists a number y such that x < y. Assume: rational, real, prime: unary predicate symbols. : binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. Every rational number is a real number. x.(rational(x) real(x)) 2. There exists a number that is prime. x. prime(x) 3. For every number x, there exists a number y such that x < y. Assume: x. y. x < y rational, real, prime: unary predicate symbols. : binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. There is no natural number whose immediate successor is 0. Assume: zero: constant succ, pred: unary function symbols. =:. binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. There is no natural number whose immediate successor is 0. x.zero. = succ(x) Assume: zero: constant succ, pred: unary function symbols. =:. binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. There is no natural number whose immediate successor is 0. x.zero. = succ(x) 2. For each natural number there exists exactly one immediate successor natural number. Assume: zero: constant succ, pred: unary function symbols. =:. binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. There is no natural number whose immediate successor is 0. x.zero. = succ(x) 2. For each natural number there exists exactly one immediate successor natural number. x. y.(y. = succ(x) z.(z. = succ(x) y. = z)) Assume: zero: constant succ, pred: unary function symbols. =:. binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. There is no natural number whose immediate successor is 0. x.zero. = succ(x) 2. For each natural number there exists exactly one immediate successor natural number. x. y.(y. = succ(x) z.(z. = succ(x) y. = z)) 3. For each nonzero natural number there exists exactly one immediate predecessor natural number. Assume: zero: constant succ, pred: unary function symbols. =:. binary predicate symbol.

Example Translating English sentences into first-order logic formulas: 1. There is no natural number whose immediate successor is 0. x.zero. = succ(x) 2. For each natural number there exists exactly one immediate successor natural number. x. y.(y. = succ(x) z.(z. = succ(x) y. = z)) 3. For each nonzero natural number there exists exactly one immediate predecessor natural number. x.( (x. = zero) y.(y. = pred(x) z.(z. = pred(x) y. = z))) Assume: zero: constant succ, pred: unary function symbols. =:. binary predicate symbol.

Semantics Meaning of a first-order language consists of an universe and an appropriate meaning of each symbol. This pair is called structure. Structure fixes interpretation of function and predicate symbols. Meaning of variables is determined by a variable assignment. Interpretation of terms and formulas.

Structure Structure: a pair (D, I). D is a nonempty universe, the domain of interpretation. I is an interpretation function defined on D that fixes the meaning of each symbol associating to each f F n an n-ary function f I : D n D, (in particular, c I D for each constant c) to each p P n different from. =, an n-ary relation p I on D.

Variable Assignment A structure S = (D, I) is given. Variable assignment σ S maps each x V into an element of D: σ S (x) D. Given a variable x, an assignment ϑ S is called an x-variant of σ S iff ϑ S (y) = σ S (y) for all y x.

Interpretation of Terms A structure S = (D, I) and a variable assignment σ S are given.

Interpretation of Terms A structure S = (D, I) and a variable assignment σ S are given. Value of a term t under S and σ S, Val S,σS (t): Val S,σS (x) = σ S (x). Val S,σS (f (t 1,..., t n )) = f I (Val S,σS (t 1 ),..., Val S,σS (t n )).

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given.

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Value of an atomic formula under S and σ S is one of true, false:

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Value of an atomic formula under S and σ S is one of true, false: Val S,σS (s =. t) = true iff Val S,σS (s) = Val S,σS (t).

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Value of an atomic formula under S and σ S is one of true, false: Val S,σS (s =. t) = true iff Val S,σS (s) = Val S,σS (t). Val S,σS (p(t 1,..., t n )) = true iff (Val S,σS (t 1 ),..., Val S,σS (t n )) p I.

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given.

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Values of compound formulas under S and σ S are also either true or false:

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Values of compound formulas under S and σ S are also either true or false: ValS,σS ( A) = true iff Val S,σS (A) = false.

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Values of compound formulas under S and σ S are also either true or false: ValS,σS ( A) = true iff Val S,σS (A) = false. ValS,σS (A B) = true iff Val S,σS (A) = true or Val S,σS (B) = true.

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Values of compound formulas under S and σ S are also either true or false: ValS,σS ( A) = true iff Val S,σS (A) = false. ValS,σS (A B) = true iff Val S,σS (A) = true or Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = true and Val S,σS (B) = true.

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Values of compound formulas under S and σ S are also either true or false: ValS,σS ( A) = true iff Val S,σS (A) = false. ValS,σS (A B) = true iff Val S,σS (A) = true or Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = true and Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = false or Val S,σS (B) = true.

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Values of compound formulas under S and σ S are also either true or false: ValS,σS ( A) = true iff Val S,σS (A) = false. ValS,σS (A B) = true iff Val S,σS (A) = true or Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = true and Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = false or Val S,σS (B) = true. ValS,σS (A B) = true iff Val S,σS (A) = Val S,σS (B).

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Values of compound formulas under S and σ S are also either true or false: ValS,σS ( A) = true iff Val S,σS (A) = false. ValS,σS (A B) = true iff Val S,σS (A) = true or Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = true and Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = false or Val S,σS (B) = true. ValS,σS (A B) = true iff Val S,σS (A) = Val S,σS (B). ValS,σS ( x.a) = true iff Val S,ϑS (A) = true for some x-variant ϑ S of σ S.

Interpretation of Formulas A structure S = (D, I) and a variable assignment σ S are given. Values of compound formulas under S and σ S are also either true or false: ValS,σS ( A) = true iff Val S,σS (A) = false. ValS,σS (A B) = true iff Val S,σS (A) = true or Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = true and Val S,σS (B) = true. Val S,σS (A B) = true iff Val S,σS (A) = false or Val S,σS (B) = true. ValS,σS (A B) = true iff Val S,σS (A) = Val S,σS (B). ValS,σS ( x.a) = true iff Val S,ϑS (A) = true for some x-variant ϑ S of σ S. Val S,σS ( x.a) = true iff Val S,ϑS (A) = true for all x-variants ϑ S of σ S.

Interpretation of Formulas A structure S = (D, I) is given.

Interpretation of Formulas A structure S = (D, I) is given. The value of a formula A under S is either true or false: ValS (A) = true iff Val S, σ S (A) = true for all σ S.

Interpretation of Formulas A structure S = (D, I) is given. The value of a formula A under S is either true or false: ValS (A) = true iff Val S, σ S (A) = true for all σ S. S is called a model of A iff Val S (A) = true.

Interpretation of Formulas A structure S = (D, I) is given. The value of a formula A under S is either true or false: ValS (A) = true iff Val S, σ S (A) = true for all σ S. S is called a model of A iff Val S (A) = true. Written S A.

Example Formula: x.(p(x) q(f (x), a))

Example Formula: x.(p(x) q(f (x), a)) Define S = (D, I) as D = {1, 2}, ai = 1, fi (1) = 2, f I (2) = 1, p I = {2}, q I = {(1, 1), (1, 2), (2, 2)}.

Example Formula: x.(p(x) q(f (x), a)) Define S = (D, I) as D = {1, 2}, ai = 1, fi (1) = 2, f I (2) = 1, p I = {2}, q I = {(1, 1), (1, 2), (2, 2)}. If σ S (x) = 1, then Val S,σS ( x.(p(x) q(f (x), a))) = true.

Example Formula: x.(p(x) q(f (x), a)) Define S = (D, I) as D = {1, 2}, ai = 1, fi (1) = 2, f I (2) = 1, p I = {2}, q I = {(1, 1), (1, 2), (2, 2)}. If σ S (x) = 1, then Val S,σS ( x.(p(x) q(f (x), a))) = true. If σ S (x) = 2, then Val S,σS ( x.(p(x) q(f (x), a))) = true.

Example Formula: x.(p(x) q(f (x), a)) Define S = (D, I) as D = {1, 2}, ai = 1, fi (1) = 2, f I (2) = 1, p I = {2}, q I = {(1, 1), (1, 2), (2, 2)}. If σ S (x) = 1, then Val S,σS ( x.(p(x) q(f (x), a))) = true. If σ S (x) = 2, then Val S,σS ( x.(p(x) q(f (x), a))) = true. Hence, S A.

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A.

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A. A formula A is unsatisfiable, if S A for no S.

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A. A formula A is unsatisfiable, if S A for no S. If A is valid, then A is unsatisfiable and vice versa.

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A. A formula A is unsatisfiable, if S A for no S. If A is valid, then A is unsatisfiable and vice versa. The notions extend to (multi)sets of formulas.

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A. A formula A is unsatisfiable, if S A for no S. If A is valid, then A is unsatisfiable and vice versa. The notions extend to (multi)sets of formulas. For {A 1,..., A n }, just formulate them for A 1 A n.

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A. A formula A is unsatisfiable, if S A for no S. If A is valid, then A is unsatisfiable and vice versa. The notions extend to (multi)sets of formulas. For {A 1,..., A n }, just formulate them for A 1 A n. Formulas

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A. A formula A is unsatisfiable, if S A for no S. If A is valid, then A is unsatisfiable and vice versa. The notions extend to (multi)sets of formulas. For {A 1,..., A n }, just formulate them for A 1 A n. Valid Non-valid

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A. A formula A is unsatisfiable, if S A for no S. If A is valid, then A is unsatisfiable and vice versa. The notions extend to (multi)sets of formulas. For {A 1,..., A n }, just formulate them for A 1 A n. Valid Non-valid Satisfiable Unsat

Validity, Unsatisfiability A formula A is valid, if S A for all S. Written A. A formula A is unsatisfiable, if S A for no S. If A is valid, then A is unsatisfiable and vice versa. The notions extend to (multi)sets of formulas. For {A 1,..., A n }, just formulate them for A 1 A n. Valid Non-valid sat Unsat

Validity, Unsatisfiability Valid Non-valid sat Unsat x.p(x) y.p(y) is valid. p(a) x.p(x) is satisfiable non-valid. x.p(x) y. p(y) is unsatisfiable.

Logical Consequence Definition A formula A is a logical consequence of the formulas B 1,..., B n, if every model of B 1 B n is a model of A.

Logical Consequence Definition A formula A is a logical consequence of the formulas B 1,..., B n, if every model of B 1 B n is a model of A. Example mortal(socrates) is a logical consequence of x.(person(x) mortal(x)) and person(socrates). cooked(apple) is a logical consequence of x.( cooked(x) tasty(x)) and tasty(apple). genius(einstein) is not a logical consequence of x.person(x) genius(x) and person(einstein).

Logic Programs Logic programs: finite non-empty sets of formulas of a special form, called program clauses.

Logic Programs Logic programs: finite non-empty sets of formulas of a special form, called program clauses. Program clause: where x 1.... x k. B 1 B n A, k, n 0, A and the B s are atomic formulas, x1,..., x k are all the variables which occur in A, B 1,..., B n.

Logic Programs Logic programs: finite non-empty sets of formulas of a special form, called program clauses. Program clause: where x 1.... x k. B 1 B n A, k, n 0, A and the B s are atomic formulas, x1,..., x k are all the variables which occur in A, B 1,..., B n. Usually written in the inverse implication form without quantifiers and conjunctions: A B 1,..., B n

Goal Goals or queries of logic programs: formulas of the form x 1.... x k. B 1 B n, where k, n 0, the B s are atomic formulas, x1,..., x k are all the variables which occur in B 1,..., B n.

Goal Goals or queries of logic programs: formulas of the form x 1.... x k. B 1 B n, where k, n 0, the B s are atomic formulas, x1,..., x k are all the variables which occur in B 1,..., B n. Usually written without quantifiers and conjunction: B 1,..., B n

Goal Goals or queries of logic programs: formulas of the form x 1.... x k. B 1 B n, where k, n 0, the B s are atomic formulas, x1,..., x k are all the variables which occur in B 1,..., B n. Usually written without quantifiers and conjunction: B 1,..., B n The problem is to find out whether a goal is a logical consequence of the given logic program or not.

The Problem and the Idea Let P be a program and G be a goal. Problem: Is G a logical consequence of P?

The Problem and the Idea Let P be a program and G be a goal. Problem: Is G a logical consequence of P? Idea: Try to show that the set of formulas P { G} is inconsistent.

The Problem and the Idea Let P be a program and G be a goal. Problem: Is G a logical consequence of P? Idea: Try to show that the set of formulas P { G} is inconsistent. How? This we will learn in this course.

Example Let P consist of the two clauses: x.mortal(x) person(x). person(socrates). Goal: G = x.mortal(x).

Example Let P consist of the two clauses: x.mortal(x) person(x). person(socrates). Goal: G = x.mortal(x). G is equivalent to x. mortal(x).

Example Let P consist of the two clauses: x.mortal(x) person(x). person(socrates). Goal: G = x.mortal(x). G is equivalent to x. mortal(x). The set { x.mortal(x) person(x), person(socrates), x. mortal(x)} is inconsistent.

Example Let P consist of the two clauses: x.mortal(x) person(x). person(socrates). Goal: G = x.mortal(x). G is equivalent to x. mortal(x). The set { x.mortal(x) person(x), person(socrates), x. mortal(x)} is inconsistent. Hence, G is a logical consequence of P.

Example Let P consist of the two clauses: x.mortal(x) person(x). person(socrates). Goal: G = x.mortal(x). G is equivalent to x. mortal(x). The set { x.mortal(x) person(x), person(socrates), x. mortal(x)} is inconsistent. Hence, G is a logical consequence of P. We can even compute the witness term for the goal: x = socrates.

Example Let P consist of the two clauses: x.mortal(x) person(x). person(socrates). Goal: G = x.mortal(x). G is equivalent to x. mortal(x). The set { x.mortal(x) person(x), person(socrates), x. mortal(x)} is inconsistent. Hence, G is a logical consequence of P. We can even compute the witness term for the goal: x = socrates. How? This we will learn in this lecture.