Logic Programming Part 2: Semantics James Cheney CS 411.

Slides:



Advertisements
Similar presentations
Artificial Intelligence 8. The Resolution Method
Advertisements

CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
Ordered pairs ( x , y ) as solutions to Linear Equations
Biointelligence Lab School of Computer Sci. & Eng.
Inference Rules Universal Instantiation Existential Generalization
SLD-resolution Introduction Most general unifiers SLD-resolution
Chapter 11 :: Logic Languages
10 October 2006 Foundations of Logic and Constraint Programming 1 Unification ­An overview Need for Unification Ranked alfabeths and terms. Substitutions.
Letrec fact(n) = if zero?(n) then 1 else *(n, (fact sub1(n))) 4.4 Type Inference Type declarations aren't always necessary. In our toy typed language,
Propositional and First Order Reasoning. Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p 
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
First Order Logic Resolution
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
SECTION 21.5 Eilbroun Benjamin CS 257 – Dr. TY Lin INFORMATION INTEGRATION.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Logic seminar 5 The resolution principle Slobodan Petrović.
1 Constraint Programming Maurizio Gabbrielli Universita’ di Bologna Slides by: K. Marriott.
1 Chapter 1: Constraints What are they, what do they do and what can I use them for.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
CSE (c) S. Tanimoto, 2007 Unification 1 Unification Predicate calculus rules are sometimes so general that we need to create specializations of.
Plan for the rest of the quarter TuesdayThursday Week 7ResolutionProof carrying code Week 8No class (Sorin in DC for workshop) Predicate abstraction (Mystery.
0 1 Todays Topics Resolution – top down and bottom up j-DREW BU procedure Subsumption – change to procedure Infinite Loops RuleML input – Prolog output.
CS1502 Formal Methods in Computer Science Lecture Notes 10 Resolution and Horn Sentences.
Prolog Programming Lecture Module 13. Objective ● What is Prolog? ● Prolog program ● Syntax of Prolog ● Prolog Control Strategy ● Execution of Prolog.
Solving Systems of Equations: Elimination Method.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
9/18/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
Logic Programming Two possible work modes: 1.At the lab: Use SICstus Prolog. To load a prolog file (*.pl or *.pro extension) to the interpreter, use: ?-
UIUC CS 497: Section EA Lecture #3 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
14/10/04 AIPP Lecture 7: The Cut1 Controlling Backtracking: The Cut Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 7 14/10/04.
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
First Order Predicate Logic
Type checking and inference Applications of typing axioms / rules are replaced with type equations. A solution to the equations assigns types for every.
CSC 270 – Survey of Programming Languages Prolog Lecture 2 – Unification and Proof Search.
Unification Algorithm Input: a finite set Σ of simple expressions Output: a mgu for Σ (if Σ is unifiable) 1. Set k = 0 and  0 = . 2. If Σ  k is a singleton,
O A procedure: a set of axioms (rules and facts) with identical signature (predicate symbol and arity). o A logic program: a set of procedures defining.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Web Science & Technologies University of Koblenz ▪ Landau, Germany Procedural Semantics Soundness of SLD-Resolution.
1 Section 9.1 Automatic Reasoning Recall that a wff W is valid iff ¬ W is unsatisfiable. Resolution is an inference rule used to prove unsatisfiability.
Principles of programming languages 12: Logic programming Isao Sasano Department of Information Science and Engineering.
CSE (c) S. Tanimoto, 2008 Predicate Calculus II 1 Predicate Calculus 2 Outline: Unification: definitions, algorithm Formal interpretations and satisfiability.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
Introduction to Prolog What if all we could do was to make assertions (statements) about the world? Example: family tree parent(linda, simon).male(simon).
Resolution Preliminaries Computational LogicLecture 9 By Prof. Michael Genesereth, Computer Science, Stanford Univ Spring 2005 Modified by Charles Ling.
Prolog 3 Tests and Backtracking 1. Arithmetic Operators Operators for arithmetic and value comparisons are built-in to Prolog = always accessible / don’t.
Type checking and inference Question 2: Typing the application (if #t (+ 1 2) 3) STAGE-I: Renaming ExpressionVariable (if #t (+ 1 2) 3) T0 (+ 1 2) T1 +
3/20/20161 Programming Languages and Compilers (CS 421) Reza Zamani Based in part on slides by Mattox Beckman,
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
O A procedure: a set of axioms (rules and facts) with identical signature (predicate symbol and arity). o A logic program: a set of procedures (predicates),
Logic Programming Lecture 2: Unification and proof search.
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
1 Chapter 1: Constraints What are they, what do they do and what can I use them for.
CS5205: Foundation in Programming Languages Type Reconstruction
Completeness of the SLD-Resolution
Type checking and inference
Proving Properties of Recursive List Functions
Where Can We Draw The Line?
Programming Languages and Compilers (CS 421)
Prolog syntax + Unification
Unification Algorithm ChuChen
Soundness of SLD-Resolution
CSE (c) S. Tanimoto, 2004 Unification
CSE S. Tanimoto Unification
CSE (c) S. Tanimoto, 2002 Unification
Soundness of SLD-Resolution
Resolution Preliminaries
Presentation transcript:

Logic Programming Part 2: Semantics James Cheney CS 411

Resolution Resolution principle: –If A 1... A n  B and B,C 1,...,C m  D –Then A 1... A n,C 1,...,C m  D Proof search: –To prove B, try to prove B  False –Apply resolution until LHS is empty.

Unification In Prolog, logic variables X,Y,Z can be substituted by any other term Unification: Algorithm for finding substitution making two terms equal

Examples f(X,[Y,Z]) == f(g(Z),W) –unifies with X = g(Z), W = [Y,Z] f(X,g(X)) == f(2,g(Y)) –Doesn’t iunify: X = 2 and X = g(Y) impossible

More Examples f(X) == X –Doesn’t unify! –X = f(X) = f(f(X)) =... f(X,Y) == f(Y,g(X)) –Doesn’t unify! (Why?)

Example f XY f X Y g

f XY f X Y g

XY X Y g

Y X g Answer: X = Y

Example Y Y g Answer: X = Y

Example Answer: X = Y Y = g(Y)

Example Answer: X = Y Y = g(Y) Problem: In equation Y = f(Y), Y occurs circularly. There is no finite term satisfying this equation. Checking that this is not the case is called the occurs check. For efficiency reasons, PROLOG skips this check.

Robinson’s Algorithm Consider a general unification problem P = t 1 == u 1, t 2 == u 2,... Reduce the problem by replacing one equation with a set of equations Succeed if all equations reducible, else fail.

Robinson’s Algorithm Two constants unify if they are equal. c == c, P  P Else fail.

Robinson’s Algorithm Two function applications unify if the symbols are equal, and the corresponding arguments unify. f(t 1,...t n ) == f(u 1,...,u n ), P  t 1 == u 1,... t n == u n, P Must have equal number of arguments

Robinson’s Algorithm Two variables unify if they are the same. X == X, P  P

Robinson’s Algorithm Otherwise, a variable X unifies with a term t provided X does not occur in t. X = t, P  P[t/X] (if X not in FV(t)) Proceed by substituting t for X in P.

Operational Semantics In general, we have –a program P = {clauses}, –a goal G = {atomic goals}, –and a substitution  : Var  Term Base case: If there are no goals then succeed (P,{},  )  Yes 

Operational Semantics Inductive case: Suppose state is (P,G,  ) with G nonempty. Pick a p(t1,...,tn) in G. Assume clause p(u1,...,un) :- G’ in P. Assume  ’ unifies p(t1,...,tn) and p(u1,...,un) Then: (P,G,q)  (P,  ’G’,  ’  ).