603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 24 A First Course in Database Systems.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

© Johan Bos Logic Programming About the course –Taught in English –Tuesday: mostly theory –Thursday: practical work [lab] Teaching material –Learn Prolog.
Some Prolog Prolog is a logic programming language
Query Answering for OWL-DL with Rules Boris Motik Ulrike Sattler Rudi Studer.
Inference Rules Universal Instantiation Existential Generalization
The Foundations: Logic and Proofs
Chapter 11 :: Logic Languages
2005conjunctive-ii1 Query languages II: equivalence & containment (Motivation: rewriting queries using views)  conjunctive queries – CQ’s  Extensions.
Lecture 11: Datalog Tuesday, February 6, Outline Datalog syntax Examples Semantics: –Minimal model –Least fixpoint –They are equivalent Naive evaluation.
AR for Horn clause logic Introducing: Unification.
Standard Logical Equivalences
ITCS 3153 Artificial Intelligence Lecture 15 First-Order Logic Chapter 9 Lecture 15 First-Order Logic Chapter 9.
Automated Reasoning Systems For first order Predicate Logic.
First Order Logic Resolution
For Friday No reading Homework: –Chapter 9, exercise 4 (This is VERY short – do it while you’re running your tests) Make sure you keep variables and constants.
Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara
Predicates and Quantifiers
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
Chapter 12 - Logic Programming
Comp 205: Comparative Programming Languages Declarative Programming Languages Logic Programming Horn-Clause Logic Prolog Lecture notes, exercises, etc.,
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
CPSC 322 Introduction to Artificial Intelligence September 20, 2004.
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Formal Models of Computation Part II The Logic Model
1 Lecture 6 Logic Programming introduction to Prolog, facts, rules Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction to.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
1 COSC3306: Programming Paradigms Lecture 8: Declarative Programming Specifications Haibin Zhu, Ph.D. Computer Science Nipissing University (C) 2003.
Logic CL4 Episode 16 0 The language of CL4 The rules of CL4 CL4 as a conservative extension of classical logic The soundness and completeness of CL4 The.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 14 A First Course in Database Systems.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 22 A First Course in Database Systems.
CHAPTER 15 & 16 Functional & Logic Programming Languages.
1 Predicate (Relational) Logic 1. Introduction The propositional logic is not powerful enough to express certain types of relationship between propositions.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 17 A First Course in Database Systems.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Automated Reasoning Systems For first order Predicate Logic.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 25 A First Course in Database Systems.
Integration Copyright © Cengage Learning. All rights reserved.
1/32 This Lecture Substitution model An example using the substitution model Designing recursive procedures Designing iterative procedures Proving that.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 21 A First Course in Database Systems.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
ece 627 intelligent web: ontology and beyond
Knowledge Based Information System
Integration 4 Copyright © Cengage Learning. All rights reserved.
1-1 An Introduction to Logical Programming Sept
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 26 A First Course in Database Systems.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Extensions of Datalog Wednesday, February 13, 2001.
Pengenalan Prolog Disampaikan Oleh : Yusuf Nurrachman, ST, MMSI.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
A First Course in Database Systems
Copyright © Cengage Learning. All rights reserved.
4 Integration.
Predicates and Quantified Statements I
Logical Inference 2 Rule-based reasoning
Logic Programming Languages
This Lecture Substitution model
Logic: Top-down proof procedure and Datalog
Chapter 11 :: Logic Languages
Horn Clauses and Unification
Chapter 1: Propositional and First-Order Logic
This Lecture Substitution model
Antiderivatives and Indefinite Integration
This Lecture Substitution model
Chapter 2: Prolog (Introduction and Basic Concepts)
Presentation transcript:

603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 24 A First Course in Database Systems

Deductive Databases Conjunctive Queries and shared variables in logic programming: An important extension to the queries discussed so far is conjunctive queries. Conjunctive queries are a conjunction of goals posed as a query. Example: father(terach, X), father(X,Y)? Goal1 AND Goal2 ?

Deductive Databases We will see this again when we discuss Datalog!! Conjunctive queries are a conjunction of goals posed as a query. Example: father(terach, X), father(X,Y)? Goal1 AND Goal2 ? In general father(terach, X), father(X,Y)? ==> Q 1, Q 2, ……., Q n ? Simple queries are a special case of conjunctive queries when there is a single goal.

Deductive Databases Q 1, Q 2, ……., Q n ? => Q 1 AND Q 2 AND …….AND Q n ? Conjunctive Query In the simplest conjunctive queries all the goals are ground, for example, father(abraham, isaac), male(lot)? The answer to this query is clearly yes as both goals in the query are facts in the program. ==> goals are ground!

Deductive Databases In general, the query Q 1, Q 2, ……., Q n ?, Q 2, ……., Q n ? Where each Q i is a ground goal is answered yes with respect to a parogram P if each Q i is implied by P. Hence, ground conjunctive queries are not very interesting!!! Conjunctive queries are interesting when there are one or more shared variables, variables that occur in two different goals of a query.

Deductive Databases Shared variables example: Query: father(haran, X), male(X)? The scope of a variable in a conjunctive query is the whole conjunction. Query: p(X),q(X)? Reads: “Is there an X such that both p(X) and q(X)?

Deductive Databases Like in simple queries, variables in conjunctive queries are implicitly existentially quantified. Shared variables are used as a means of constraining a simple query by restricting the range variable. We have already seen as example with the query plus(X,X,4)? where the solution of numbers adding up to 4 was restricted to the numbers being the same.

Deductive Databases Consider the query father(haran,X), male (X)? Here solutions to the query father(haran,X)? are restricted to children that are male. Based on our family database, there is only one solution, {X=lot}. Alternatively, this query can be viewed as restricting solutions to the query male(X)? to individuals who have Haran for a father.

Deductive Databases A slightly different use of a shared variable can be seen in the query father(terach, X),father(X,Y)? On the one hand, restricts the sons of terach to those who are themselves fathers. On the other hand, it considers individuals Y, whose fathers are sons of terach.

The Deductive Databases The query father(terach, X),father(X,Y)? has several solutions: 1){X=abraham, Y=isaac} 2){X=haran, Y=lot}

Deductive Databases Conjunctive Query: A conjunctive query is a logical consequence of a program P if all goals in the conjunction are consequences of P, where shared variables are instantiated to the same values in different goals. This instance then deduces the conjuncts in the query via generalization.

Deductive Databases Conjunctive Queries: The restriction to ground instances is unnecessary, and will be lifted in later discussions. Operationally, to solve conjunctive query A 1, A 2, ……., A n ? Using a program P, find a substitution  such that A 1 ... A n  are ground instances of facts in P. The same substitution applied to all the goals ensures that instances of variables are common throughout the query.

Deductive Databases Example: father(haran,X), male(X)? Applying the substitution {X=lot} to the query gives the ground instance father(haran, lot), male (lot)? Which is a consequence of the program P.

Deductive Databases RULES: Interesting conjunctive queries are defining relationships in their own right!!! The query father(haran,X), male(X)? Asking for a son of Haran.

Deductive Databases RULES: The query father(terach, X),father(X,Y)? Asking about grandchildren of Terach.

Deductive Databases This brings us to the third and most important statement in logic programming, A RULE, which enables us to define new relationships in terms of existing relationships. Rules are statements of the form: A  B 1, B 2, ……., B n where n  0.

Deductive Databases A  B 1, B 2, ……., B n  Horn clause A is the head of the rule, and the B i ’ s are its body. Both A and the B i ’ s are goals. Rules, facts and queries are also called Horn clauses, or clauses for short.

Deductive Databases A  B 1, B 2, ……., B n  Horn clause NOTE: A fact is just a special case of a rule when n=0. Facts are also called unit clauses. There is a special name for clauses with one goalin the body, namely when n=1.

Deductive Databases A clause with one goal in the body is called a iterative clause. As for facts, variables appearing in rules are universally quantified, and their scope is the whole rule.

Deductive Databases RULES: son(X,Y)  father(Y, X), male (X). Expresses the son relationship daughter(X,Y)  father(Y, X), female (X). Expresses the daughter relationship grandfather(X, Z) father (X, Y), father (Y, Z). Expresses the grandfather relationship

Deductive Databases RULES: Rules can be viewed in two ways. 1)A means of expressing new or complex queries in terms of simple queries. A query son(X, haran)? to the program that contain the rule son(X,Y)  father(Y, X), male (X). is translated to the query father(haran, X), male(X)? according to the rule, and solved as before.

Deductive Databases A new query about the son relationship has been built from simple queries involving father and male relationships. Interpreting rules in this way is their procedural reading. Procedural reading for the grandfather rule: “To answer a query is X the grandfather of Y, answer the conjunctive query is X the father of Z and Z the father of Y.”

Deductive Databases grandfather(X, Z) father (X, Y), father (Y, Z). Procedural reading for the grandfather rule: “To answer a query is X the grandfather of Y, answer the conjunctive query is X the father of Z and Z the father of Y.”

Deductive Databases RULES: 2)The second view of rules come from interpreting the rule as a logical axiom. The backward arrow (  ) is used to denote logical implication

Deductive Databases RULES: son(X,Y)  father(Y, X), male (X). The son rule reads:”X is a son of Y if Y is the father of X and X is male.” The associated reading of this rule is known as the declarative reading.

Deductive Databases Rule: The declarative reading of the grandfather rule is: “For all X, Y, and Z, X is the grandfather of Z if X is the father of Y and Y is the father of Z.”  (X,Y,Z)(grandfather(X, Z) father (X, Y), father (Y, Z)).

Deductive Databases Next Lecture MORE Deductive Databases