Applied Logic in Engineering



Similar documents
ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS

Lecture 8: Resolution theorem-proving

Chapter 7 Uncomputability

AUTOMATED REASONING SLIDES 3: RESOLUTION The resolution rule Unification Refutation by resolution Factoring Clausal Form and Skolemisation

Algorithmic Software Verification

CHAPTER 7 GENERAL PROOF SYSTEMS

The Point-Slope Form

Artificial Intelligence

Example: Backward Chaining. Inference Strategy: Backward Chaining. First-Order Logic. Knowledge Engineering. Example: Proof

The Modal Logic Programming System MProlog

Lecture 7: NP-Complete Problems

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

Journal of Mathematics Volume 1, Number 1, Summer 2006 pp

Algorithms are the threads that tie together most of the subfields of computer science.

Propositional Logic. A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both.

Today s Agenda. Automata and Logic. Quiz 4 Temporal Logic. Introduction Buchi Automata Linear Time Logic Summary

Computational Methods for Database Repair by Signed Formulae

Language. Johann Eder. Universitat Klagenfurt. Institut fur Informatik. Universiatsstr. 65. A-9020 Klagenfurt / AUSTRIA

Generating models of a matched formula with a polynomial delay

Logic in general. Inference rules and theorem proving

COMPUTER SCIENCE TRIPOS

2. The Language of First-order Logic

Oracle Database 10g: Introduction to SQL

Runtime Verification - Monitor-oriented Programming - Monitor-based Runtime Reflection

Theoretical Computer Science (Bridging Course) Complexity

Satisfiability Checking

µz An Efficient Engine for Fixed points with Constraints

Certamen 1 de Representación del Conocimiento

15-780: Graduate AI Lecture 3. FOL proofs. Geoff Gordon (this lecture) Tuomas Sandholm TAs Erik Zawadzki, Abe Othman

Introduction to NP-Completeness Written and copyright c by Jie Wang 1

(LMCS, p. 317) V.1. First Order Logic. This is the most powerful, most expressive logic that we will examine.

Resolution. Informatics 1 School of Informatics, University of Edinburgh

Sound and Complete Inference Rules in FOL

Chapter. NP-Completeness. Contents

Predicate Logic. For example, consider the following argument:

CS510 Software Engineering

Eventia Log Parsing Editor 1.0 Administration Guide

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Probabilità e Nondeterminismo nella teoria dei domini

Answers G53KRR

Fixed-Point Logics and Computation

NP-Completeness and Cook s Theorem

ML for the Working Programmer

Semantic Description of Distributed Business Processes

The Classes P and NP

10.2 Series and Convergence

Introduction to Logic in Computer Science: Autumn 2006

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Chapter 13: Program Development and Programming Languages

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

First-Order Stable Model Semantics and First-Order Loop Formulas

LTL Model Checking with Logic Based Petri Nets

The countdown problem

Formalization of the CRM: Initial Thoughts

How To Understand The Theory Of Computer Science

A Knowledge-based System for Translating FOL Formulas into NL Sentences

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Relational Calculus. Module 3, Lecture 2. Database Management Systems, R. Ramakrishnan 1

We used attributes in Chapter 3 to augment a context-free grammar

The ProB Animator and Model Checker for B

A Little Set Theory (Never Hurt Anybody)

Bounded Treewidth in Knowledge Representation and Reasoning 1

Course Syllabus For Operations Management. Management Information Systems

npsolver A SAT Based Solver for Optimization Problems

Software Modeling and Verification

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Databases and Information Systems 1 Part 3: Storage Structures and Indices

SQL INJECTION ATTACKS By Zelinski Radu, Technical University of Moldova

Attack Taxonomies and Ontologies

6. SQL/XML. 6.1 Introduction. 6.1 Introduction. 6.1 Introduction. 6.1 Introduction. XML Databases 6. SQL/XML. Creating XML documents from a database

Oracle SQL. Course Summary. Duration. Objectives

Boolean Algebra Part 1

2.1 Complexity Classes

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

How To Pass A Master Degree In Germany

Lecture 1. Basic Concepts of Set Theory, Functions and Relations

XML Databases 6. SQL/XML

Georg Cantor and Set Theory

Petri Net based Verification and

Computability Theory

How To Understand And Understand Common Lisp

NUMBER SYSTEMS. William Stallings

Factoring Polynomials

Transcription:

Applied Logic in Engineering Logic Programming Technische Universität München Institut für Informatik Software & Systems Engineering Dr. Maria Spichkova M. Spichkova WS 2012/13: Applied Logic in Engineering 1

Logic Programs Logic programs: set of (definite Horn) clauses Programming language ProLog: based on Horn clauses Restriction to the Horn form: Why? Efficiency of the algorithms Simpler answer situations Most of the mathematical theories seem to be axiomatizable in terms of Horn formulas (i.e. this does not seem to be a real restriction in practice) M. Spichkova WS 2012/13: Applied Logic in Engineering 2

Clausal Form CNF: (L 11 L 1n1 ) (L m1 L mnm ) Clausal form: set notation of formulas in CNF {{L 11,..., L 1n1 },..., {L m1,..., L mnm }} clauses Empty clause: Halting clause Unit clause: clause which contains only one literal. Horn clause: clause which contain only one (at most one) positive literal M. Spichkova WS 2012/13: Applied Logic in Engineering 3

Clausal Form (2) Definite clause: horn clause which contains a positive literal Fact: definite unit clause Fact: just one positive literal {L} Procedure clause: clause which contain only one positive literal ProLog: L. L 1 L n L (L 1 L n ) L (L 1 L n ) L L (L 1 L n ) {L, L 1,..., L n } ProLog: Procedure head Procedure body L : L 1,..., L n. Procedure call M. Spichkova WS 2012/13: Applied Logic in Engineering 4

Clausal Form (3) Goal clause (query clause): horn clause which contains only negative literals (L 1 L n ) L 1 L n ProLog:? L 1,..., L n. L 1 L n 0 (L 1 L n ) 0 { L 1,..., L n } M. Spichkova WS 2012/13: Applied Logic in Engineering 5

Horn Clause Programs Configuration: a pair (G, sub) where G is a goal clause and sub is a substitution Transition relation for configurations: G 1 has a form there is a clause C in the logic program F after that its variables are renamed so that G 1 and C do not have variables in common B and A i are unifiable (G 1, sub 1 ) F (G 2, sub 2 ) G 1 = { A 1, A 2,..., A k } (k 1) i {1,..., k} C = {B, C 1, C 2,..., C n } (n 0) Then the G 2 has the form (s is here a most general unifier) G 2 = { A 1,..., A i 1, C 1, C 2,..., C n, A i+1,..., A k }s sub 2 = sub 1 s M. Spichkova WS 2012/13: Applied Logic in Engineering 6

Horn Clause Programs (2) A computation of the logical program F on input is a (finite or infinite) sequence of the form If the sequence is final, and the last configuration of it has the form then this computation is called successful, and the formula G = { A 1, A 2,..., A k } (k 1) (G, []) F (G 1, sub 1 ) F (G 2, sub 2 ) F... (A 1 A k )sub (, sub) is called the result of the computation Logic programs are nondeterministic: Each configuration can have more than one successor configuration M. Spichkova WS 2012/13: Applied Logic in Engineering 7

Example from [Schöning1989] Logic program: ProLog notation: F = { {P (x, z), Q(x, y), P (y, z)}, {P (u, u)}, {Q(a, b)} } p(x, Z) :- q(x, Y), p(y, Z). p(u, U). q(a, b). Find the computations for the following goal clauses: G = { P (v, b)}? - p(v, b). M. Spichkova WS 2012/13: Applied Logic in Engineering 8

ProLog: Programm direct_flight(munich, berlin). direct_flight(munich, dresden). direct_flight(berlin, toronto). direct_flight(toronto, montreal). Facts connection(x, Y) :- direct_flight(x, Y). connection(x, Y) :- direct_flight(x, Z), connection(z, Y). Rules M. Spichkova WS 2012/13: Applied Logic in Engineering 9

ProLog: Queries direct_flight(munich, berlin). direct_flight(munich, dresden). direct_flight(berlin, toronto). direct_flight(toronto, montreal). connection(x, Y) :- direct_flight(x, Y). connection(x, Y) :- direct_flight(x, Z), connection(z, Y).?- connection(montreal, dresden). no M. Spichkova WS 2012/13: Applied Logic in Engineering 10

ProLog: Queries (2) direct_flight(munich, berlin). direct_flight(munich, dresden). direct_flight(berlin, toronto). direct_flight(toronto, montreal). connection(x, Y) :- direct_flight(x, Y). connection(x, Y) :- direct_flight(x, Z), connection(z, Y).?- connection(munich, dresden). yes M. Spichkova WS 2012/13: Applied Logic in Engineering 11

ProLog: Queries direct_flight(munich, berlin). direct_flight(munich, dresden). direct_flight(berlin, toronto). direct_flight(toronto, montreal). connection(x, Y) :- direct_flight(x, Y). connection(x, Y) :- direct_flight(x, Z), connection(z, Y).?- connection(munich, X) berlin dresden toronto montreal no M. Spichkova WS 2012/13: Applied Logic in Engineering 12

ProLog: Syntax Correct? Animal(baer, mammal) animal(tiger, mammal)). Animal(sparrow) animal(bird, _flamingo). animal(salmon. fish); Plant(rose) plant[palm]. plant(tulip). is flower (tulip). Creature(x) = animal(x), plant(x) Correct! animal(baer, mammal). animal(tiger, mammal). animal(sparrow). animal(sparrow, bird). animal(_flamingo, bird). animal(flamingo, bird). animal(salmon, fish). plant(rose). plant(palm). Without warnings plant(tulip). creature(x) :- animal(x, _). creature(x) :- plant(x). is_flower(tulip). creature(x) :- animal(x), plant(x). M. Spichkova WS 2012/13: Applied Logic in Engineering 13

ProLog: Queries (4) animal(baer, mammal). animal(tiger, mammal). animal(sparrow, bird). animal(flamingo, bird). animal(salmon, fish). plant(rose). plant(palm). plant(tulip). is_flower(tulip). creature(x) :- animal(x, _). creature(x) :- plant(x).?- animal(animal, X). Animal = baer X = mammal ; Animal = tiger X = mammal ; Animal = sparrow X = bird ; Animal = flamingo X = bird ; Animal = salmon X = fish ; M. Spichkova WS 2012/13: Applied Logic in Engineering 14

ProLog: Queries (5) animal(baer, mammal). animal(tiger, mammal). animal(sparrow, bird). animal(flamingo, bird). animal(salmon, fish). plant(rose). plant(palm). plant(tulip). is_flower(tulip). creature(x) :- animal(x, _). creature(x) :- plant(x).?- animal(_, X). X = mammal ; X = mammal ; X = bird ; X = bird ; X = fish ; M. Spichkova WS 2012/13: Applied Logic in Engineering 15

ProLog: Queries (6) animal(baer, mammal). animal(tiger, mammal). animal(sparrow, bird). animal(flamingo, bird). animal(salmon, fish). plant(rose). plant(palm). plant(tulip). is_flower(tulip). creature(x) :- animal(x, _). creature(x) :- plant(x).?- animal(tiger, X). X = mammal ; no?- animal. WARNING: undefined predicate: animal/0 However there are definitions for: animal/2 M. Spichkova WS 2012/13: Applied Logic in Engineering 16

ProLog: Order p(x, Z) :- q(x,y), p(y, Z). p(x, X). q(a,b). p(x, Z) :- p(y, Z), q(x,y). p(x, X). q(a,b).?- p(t,b).?- p(t,b). M. Spichkova WS 2012/13: Applied Logic in Engineering 17