1 Logic Programming School of Informatics, University of Edinburgh Transformations Specification-Program An introduction to moving between Prolog and First.

Slides:



Advertisements
Similar presentations
1.3 Predicates and Quantifiers
Advertisements

1 Logic Programming School of Informatics, University of Edinburgh append/3 A Drosophila of L.P. append([], L, L) append([ H | T ], L, [ H | R ])  append(T,
1 Logic Programming School of Informatics, University of Edinburgh Mode Inference Given the definition of a predicate p/N infer a calling pattern p(M 1,
The Logic of Quantified Statements
10 October 2006 Foundations of Logic and Constraint Programming 1 Unification ­An overview Need for Unification Ranked alfabeths and terms. Substitutions.
2005conjunctive-ii1 Query languages II: equivalence & containment (Motivation: rewriting queries using views)  conjunctive queries – CQ’s  Extensions.
11/10/04 AIPP Lecture 6: Built-in Predicates1 Combining Lists & Built-in Predicates Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture.
Automated Reasoning Systems For first order Predicate Logic.
Models and Propositional Logic In propositional logic, a model in general simply fixes the truth value – true or false – for every proposition symbol.
1 Logic Programming. 2 A little bit of Prolog Objects and relations between objects Facts and rules. Upper case are variables. parent(pam, bob).parent(tom,bob).
Chapter 12 - Logic Programming
Introduction to Prolog What is Prolog? Application Areas of Prolog How does Prolog work? (Syntax of Prolog) Program Structure.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Computability and Complexity 8-1 Computability and Complexity Andrei Bulatov Logic Reminder.
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
Discrete Mathematics Lecture 2 Alexander Bukharovich New York University.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 26: Introduction to Logic Programming with Prolog COMP 144 Programming Language.
Inference and Resolution for Problem Solving
Inference in First-Order Logic
Proving Properties of Constraint Logic Programs by Eliminating Existential Variables Alberto Pettorossi (Università di Roma “Tor Vergata”), Maurizio Proietti.
Example 2 4 m 8 m 5m 12 m x y.
Discrete Structures Chapter 3: The Logic of Quantified Statements
Survey of Mathematical Ideas Math 100 Chapter 3, Logic
Predicates and Quantifiers
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
PROPERTIES OF EXPONENTS. PRODUCT OF POWERS PROPERTY.
1-1 Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
CSE S. Tanimoto Horn Clauses and Unification 1 Horn Clauses and Unification Propositional Logic Clauses Resolution Predicate Logic Horn Clauses.
Multi-Relational Data Mining: An Introduction Joe Paulowskey.
Statements with Multiple Quantifiers. When a statement contains more than one quantifier, we imagine the actions suggested by the quantifiers as being.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Prolog Kyle Marcotte. Outline What is Prolog? Origins of Prolog (History) Basic Tutorial TEST!!! (sort of…actually not really at all) My example Why Prolog?
Resolution Strategies One common strategy for applying resolution is called level saturation. Here you try to resolve every pair of clauses from the original.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Automated Reasoning Systems For first order Predicate Logic.
C. Varela1 Logic Programming (PLP 11) Predicate Calculus, Horn Clauses, Clocksin-Mellish Procedure Carlos Varela Rennselaer Polytechnic Institute November.
Discrete Mathematics CS 2610 August 22, Agenda Last class Propositional logic Logical equivalences This week Predicate logic & rules of inference.
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Programming Languages Third Edition Chapter 4 Logic Programming.
1-1 An Introduction to Logical Programming Sept
Simplifying Algebraic Expressions. 1. Evaluate each expression using the given values of the variables (similar to p.72 #37-49)
Distributive Property and combining like terms.. Use the Distributive Property to simplify each expression. 1. 8(m + 5) = (3x + 9) = –2(4.
Answer Extraction To use resolution to answer questions, for example a query of the form  X C(X), we must keep track of the substitutions made during.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
Relational Calculus. Relational calculus query specifies what is to be retrieved rather than how to retrieve it. – No description of how to evaluate a.
Artificial Intelligence
3. The Logic of Quantified Statements Summary
Introduction to Logic for Artificial Intelligence Lecture 2
Distributive Property
Horn Clauses and Unification
Chapter 3 Introduction to Logic 2012 Pearson Education, Inc.
Relatively Complete Refinement Type System for Verification of Higher-Order Non-deterministic Programs Hiroshi Unno (University of Tsukuba) Yuki Satake.
Logic Programming Languages
SIMPLIFY THE EXPRESSION
Introduction to Predicates and Quantified Statements II
Carlos Varela Rensselaer Polytechnic Institute November 10, 2017
(1.4) An Introduction to Logic
Horn Clauses and Unification
Horn Clauses and Unification
Horn Clauses and Unification
Horn Clauses and Unification
Discrete Mathematics Lecture 4 Logic of Quantified Statements
Dr. Yasser Nada Fall 2010/2011 Lecture 5
Distributive Property
CS589 Principles of DB Systems Fall 2008 Lecture 4a: Introduction to Datalog Lois Delcambre
Carlos Varela Rennselaer Polytechnic Institute August 30, 2007
A Tutorial Summary of Description Logic and Hybrid Rules
PROLOG.
Presentation transcript:

1 Logic Programming School of Informatics, University of Edinburgh Transformations Specification-Program An introduction to moving between Prolog and First Order Predicate Logic.

2 Logic Programming School of Informatics, University of Edinburgh Why Worry About Specifications? Equivalence p(X)  (  Y.(q(X)  r(Y))) p(X)   (  Y.(q(X)   r(Y))) p(X) :- \+ (q(X), \+ r(Y)) is logically equivalent to may be equivalent to

3 Logic Programming School of Informatics, University of Edinburgh Why Worry About Specifications? Refinement subset([], S2) subset([H|T], S2) :- member(H,S2), subset(T, S2) subset(S1, S2)  list(S1)  list(S2)   E.(member(E,S1)  member(E,S2)) subset(S1, S2) :- list(S1),list(S2), \+ (member(E,S1), \+ member(E,S2))

4 Logic Programming School of Informatics, University of Edinburgh Why Worry About Specifications? Desirable properties (e.g. termination) subset([], S2) subset([H|T], S2)  member(H,S2)  subset(T, S2) size(subset([H|T], S2)) = len([H|T]) + len(S2) = len(T) len(S2) > len(S2) = size(member(H,S2)) size(subset ([H|T], S2)) = len([H|T]) + len(S2) = len(T) len(S2) > len(T) + len(S2) = size(subset(T,S2)) size(member(H,[H|T])) = len([H|T]) = len(T) + 1 > len(T) = size(member(H,T)) len([H|T]) = len(T) + 1 size(subset(S1,S2)) = len(S1) + len(S2) size(member(E,S)) = len(S) Given:

5 Logic Programming School of Informatics, University of Edinburgh Pure Prolog l Negation l Control predicates l Meta-logical predicates l External state predicates l Clause-base altering predicates Without: p(X) :- not(q(X)), r(X). q(2). r(1). p(X) :- q(X), !, r(X). q(2). r(1). r(2). p(X) :- var(X), q(X). q(1). p(X) :- read(X). p(X) :- assert(r(X)). q(X) :- r(X).

6 Logic Programming School of Informatics, University of Edinburgh Pure Prolog to Horn Clauses p(X,Y)  (q(X)  r(Y))  s(X, Y) p(X,Y) :- (q(X), r(Y)) ; s(X, Y).

7 Logic Programming School of Informatics, University of Edinburgh Clark Completion p(a 1,…,a N )  body 1 p(b 1,…,b N )  body 2 p(X 1,…,X N )  X 1 = a 1  … X N = a N  body 1 p(Y 1,…,Y N )  Y 1 = b 1  … Y N = b N  body 2 Make head arguments into distinct variables Existentially quantify any variable in the body that is not in the head. p(X 1,…,X N )   V 1 …V i.X 1 = a 1  … X N = a N  body 1 p(Y 1,…,Y N )   W 1 …W j.Y 1 = b 1  … Y N = b N  body 2 Combine clauses p(X 1,…,X N )  (  V 1 …V i.X 1 = a 1  … X N = a N  body 1 )  (  W 1 …W j.Y 1 = b 1  … Y N = b N  body 2 )

8 Logic Programming School of Informatics, University of Edinburgh Clark Completion (Example) subset([], S2) subset([H|T], S2)  member(H,S2)  subset(T, S2) subset(S1, S2)  S1 = [] subset([H|T], S2)  S1 = [H|T]  member(H,S2)  subset(T, S2) Make head arguments into distinct variables Existentially quantify any variable in the body that is not in the head. Combine clauses subset(S1, S2)  S1 = [] subset(S1, S2)  S1 = [H|T]  member(H,S2)  subset(T, S2) subset(S1, S2)  (S1 = [])  (S1 = [H|T]  member(H,S2)  subset(T, S2))

9 Logic Programming School of Informatics, University of Edinburgh Lloyd-Topor Transformation (Simplified) H   1  V  2 H   1   2 H   1 H   2 H   1  2 H   1 (A  B)  2 H   1 A  2 H   1 B  2

10 Logic Programming School of Informatics, University of Edinburgh Lloyd-Topor Transformation (Example) p(X)  a(X)  (  Y.q(X,Y)  r(X,Y)  s(X,Y)) p(X)  a(X)   ((q(X,Y)  r(X,Y))   s(X,Y)) p(X) :- a(X), \+ ((q(X,Y) ; r(X,Y)), \+ s(X,Y))