Integrity constraints & constraint logic programming Henning Christiansen Roskilde University, Denmark INAP’99, Invited DDLP’99 talk.

Slides:



Advertisements
Similar presentations
Marco Gavanelli – Università di Ferrara, Italy Marco Alberti – Universidade nova de Lisboa, Portugal Evelina Lamma – Università di Ferrara, Italy.
Advertisements

Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Inference Rules Universal Instantiation Existential Generalization
SLD-resolution Introduction Most general unifiers SLD-resolution
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.
1. An Overview of Prolog.
Logic Programming Automated Reasoning in practice.
An Introduction to the Model Verifier verds Wenhui Zhang September 15 th, 2010.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Automated Reasoning Systems For first order Predicate Logic.
Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
B. Ross Cosc 4f79 1 Frames Knowledge bases can be enhanced by using principles from frame knowledge representation (similar to object orientation) This.
1 Relational Algebra & Calculus. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
CHORD Semantics January, F-Atoms User Defined Constraint – A::B – A[B->C], A[B=>C] – A[B(V)->C], A[B(P:T0)=>T1] Built-in Constraint – 1 : Integer,
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Default and Cooperative Reasoning in Multi-Agent Systems Chiaki Sakama Wakayama University, Japan Programming Multi-Agent Systems based on Logic Dagstuhl.
Relational Data Mining in Finance Haonan Zhang CFWin /04/2003.
Inference and Resolution for Problem Solving
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
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.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
1 CILOG User Manual Bayesian Networks Seminar Sep 7th, 2006.
Lesson 6. Refinement of the Operator Model This page describes formally how we refine Figure 2.5 into a more detailed model so that we can connect it.
Describing Syntax and Semantics
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
ASP vs. Prolog like programming ASP is adequate for: –NP-complete problems –situation where the whole program is relevant for the problem at hands èIf.
Query Processing Presented by Aung S. Win.
Cooperative Query Answering Based on a talk by Erick Martinez.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Ontologies Reasoning Components Agents Simulations Belief Update, Planning and the Fluent Calculus Jacques Robin.
CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
Cs7120 (Prasad)L16-Meaning1 Procedural and Declarative Meaning of Prolog
Logic Programming Module 2AIT202 Website Lecturer: Dave Sharp Room: AG15
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
1 Relational Algebra and Calculas Chapter 4, Part A.
Formal Specification of Intrusion Signatures and Detection Rules By Jean-Philippe Pouzol and Mireille Ducassé 15 th IEEE Computer Security Foundations.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L06-1 September 26, 2006http:// Type Inference September.
CHR as grammar formalism A first report Henning Christiansen Roskilde University, D ENMARK Idea: Propagation rules of CHR:
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
Logic Programming and Prolog Goal: use formalism of first-order logic Output described by logical formula (theorem) Input described by set of formulae.
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.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
1/32 This Lecture Substitution model An example using the substitution model Designing recursive procedures Designing iterative procedures Proving that.
Reasoning about the Behavior of Semantic Web Services with Concurrent Transaction Logic Presented By Dumitru Roman, Michael Kifer University of Innsbruk,
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
MB: 26 Feb 2001CS Lecture 11 Introduction Reading: Read Chapter 1 of Bratko Programming in Logic: Prolog.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Relational Algebra Chapter 4 1.
Relational Algebra Chapter 4 1.
This Lecture Substitution model
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

Integrity constraints & constraint logic programming Henning Christiansen Roskilde University, Denmark INAP’99, Invited DDLP’99 talk

Constraint logic programming (CLP) 1980'ies:Built-in constraint solvers, e.g., CLP(R) 1990'ies:Constraint solving as programming paradigm, language support, e.g., Constraint Handling Rules (CHR) 2000'ies:Efficient (WAM-like) impl's of CHR and similar programming languages CLP expands to more and more applications This talk: Applying CLP for evaluation of integrity constraints

Motivation Names of phenomena overlap: Integrity constraint/constraint logic programming

Motivation Names of phenomena overlap: Integrity constraint/constraint logic programming IC's: Knowledge about database for improved query-answering: – controlling update request – intentional answers – semantic query optimization – usually avioded, approximated by update routines/simple checks

Motivation Names of phenomena overlap: Integrity constraint/constraint logic programming IC's: Knowledge about database for improved query-answering: – controlling update request – intentional answers – semantic query optimization – usually avioded, approximated by update routines/simple checks CLP: A declarative, computational paradigm – delay’s – incrementality: self-simplifying, self-specializing code – produces general (quantified) answers Relevant for ICs!

The idea: Lazy negation-as-failure Restrict to positive DDB's (with ”=” and ”dif”), and IC's as ”denials”: bottom :- father(A,_), mother(A,_) bottom:- father(A,C), father(B,C), dif(A,B) tested by negation-as-failure that bottom is not the case.

The idea: Lazy negation-as-failure Restrict to positive DDB's (with ”=” and ”dif”), and IC's as ”denials”: bottom :- father(A,_), mother(A,_) bottom:- father(A,C), father(B,C), dif(A,B) tested by negation-as-failure that bottom is not the case. Lazyness?? A prospective update => a (constrained) ”hole” in the database Procedure delays when ”hole” is met Resulting computation: – known part of DB checked, specialized constr’s remain for ”holes”, – wakes up when update arrives, checking it –... and mutating into new specialized constraints for future updates.

The idea: Lazy negation-as-failure Restrict to positive DDB's (with ”=” and ”dif”), and IC's as ”denials”: bottom :- father(A,_), mother(A,_) bottom:- father(A,C), father(B,C), dif(A,B) tested by negation-as-failure that bottom is not the case. Lazyness?? A prospective update => a (constrained) ”hole” in the database Procedure delays when ”hole” is met Resulting computation: – known part of DB checked, specialized constr’s remain for ”holes”, – wakes up when update arrives, checking it –... and mutating into new specialized constraints for future updates. I.e. Incrementality!

A meta-logic approach to lazy negation-as-failure Ground representation of object language, e.g.: DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ]

A meta-logic approach to lazy negation-as-failure Ground representation of object language, e.g.: DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Instance constraints: instance( s, t ) iff s, t name object S, T with T an instance of S Example: instance(p('X'), p(a))

Instance constraints reflect object var’s to Prolog Example: instance(p('X'), Z) Z = p(Z X ) Object unification = 2* instance + 1 Prolog unification

Instance constraints reflect object var’s to Prolog Example: instance(p('X'), Z) Z = p(Z X ) Object unification = 2* instance + 1 Prolog unification Example: Object level: p(a,X) = p(Y,b) Meta-level (= Prolog): instance(p(a,'X'), Z 1 ), instance(p('Y',b), Z 2 ), Z 1 =Z 2  Z 1 = p(a, Z X ), Z 2 = p(Z Y,b), Z 1 =Z 2  Z X =b, X Y =a Thus: Semantic prop’s of ground repr. with efficiency of nonground repr.

Solving instance constraints... (sketch) Straight-forward recursive decomposition, delay’s when first argument is a variable Interacts with user constraint constant(X) iff ” X names an object constant” Examples: instance(p('X'), Z) Z = p(Z X ) instance(p(X), Z) Z = p(Z X ), instance(X,Z X ) instance(p(X),Z), constant(X) constant(X), Z = p(X) I.e. meta-var’s covered by constant take ”active” part in computation

Lazy negation-as-failure (top-level procedure) Declaratively: fails( p, q ) iff p, q names of P, Q where Q fails in P, i.e. no  with P |– Q  Top-level of implementation: fails(P,Q):- instance(Q,Q 1 ), fails1(P,Q 1 ). where fails1( p, q 1 ) iff p, q names of P, Q 1 where not P |– Q 1 fails1 /2 implemented by constraint solver and auxiliary constraints.

Lazy negation-as-failure (top-level procedure) Declaratively: fails( p, q ) iff p, q names of P, Q where Q fails in P, i.e. no  with P |– Q  Top-level of implementation: fails(P,Q):- instance(Q,Q 1 ), fails1(P,Q 1 ). where fails1( p, q 1 ) iff p, q names of P, Q 1 where not P |– Q 1 fails1 /2 implemented by constraint solver and auxiliary constraints.... but let’s see some examples first

IC’s evaluated by lazy negation-as-failure (examples) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ]

IC’s evaluated by lazy negation-as-failure (examples) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: fails( DB 0, bottom)

IC’s evaluated by lazy negation-as-failure (examples) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: fails( DB 0, bottom) A: yes

IC’s evaluated by lazy negation-as-failure (examples) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: fails( DB 0 & [Clause], bottom)

IC’s evaluated by lazy negation-as-failure (examples) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: fails( DB 0 & [Clause], bottom) A:... a complicated expression ready for all possibilities: Clause could be a father clause, a mother clause, or a new IC, i.e, bottom:-...

IC’s evaluated by lazy negation-as-failure (examples) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: constant(A), constant(B), fails( DB 0 & [(father(A,B):- true)],bottom)

IC’s evaluated by lazy negation-as-failure (examples) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: constant(A), constant(B), fails( DB 0 & [(father(A,B):- true)],bottom) A: fails1(jane=A),fails1((mary=B, dif(john,A)))

IC’s evaluated by lazy negation-as-failure (examples) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: constant(A), constant(B), no_duplicates(... ), fails( DB 0 & [(father(A,B):- true)],bottom) A: fails1(jane=A), fails1(mary=B)

Observations (preliminary) Constraint solver produces residual constraints similar to "simplification method" [Nicolas, 82; Sadri,Kowalski, 88], but here as by-product of checking the whole, parameterized database A flavour of constructive negation (later example: instantiates variables)

Incrementality for sequences of updates A new user constraint (example) : clause_pattern(F,(father(X,Y):-true),(constant(X),constant(Y))) iff all clauses in F obey pattern and constraints A new residual constraint: fails1( Prog, Atom * Clause(s), Continue ) iff for (each) instance of clause H: - B in Clause(s), the query H = Atom, B, Continue fails in Prog.

Incrementality for sequences of updates (example) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: clause_pattern(F,( father(X,Y):-true ),( constant(X),constant(Y) )), fails1( DB 0 & F, bottom), no_duplicates(... )

Incrementality for sequences of updates (example) DB 0 = [(bottom:- dif('A','B'), father('A','C'), father('B','C')), (bottom:- dif('A','B'), mother('A','C'), mother('B','C')), (bottom:- father('A','Z'), mother('A','X')), (father(john,mary):- true), (mother(jane,mary):- true) ] Q: clause_pattern(F,( father(X,Y):-true ),( constant(X),constant(Y) )), fails1( DB 0 & F, bottom), no_duplicates(... ) A: fails1( DB 0 & F,father(A 1,Z 1 )*F,mother(A 1,X 1 )), fails1( DB 0 & F,father(B 2,mary)*F, dif(john,B 2 )), fails1( DB 0 & F,(father(A 3,C 3 ),father(B 3,C 3 ))*F, dif(A 3,B 3 )) NB: Optimization for symmetric literals applied

View update, lazy N-a-F co-operates with abduction A constraint-based proof predicate for program synthesis: demo( p, q ) iff p, q names of P, Q where Q succeds in P

View update, lazy N-a-F co-operates with abduction A constraint-based proof predicate for program synthesis: demo( p, q ) iff p, q names of P, Q where Q succeds in P DB 1 = [(bottom:-....),..., (sibling('A','B'):-....),..., (father(john,mary):- true), (mother(jane,mary):- true) ]

View update, lazy N-a-F co-operates with abduction A constraint-based proof predicate for program synthesis: demo( p, q ) iff p, q names of P, Q where Q succeds in P DB 1 = [(bottom:-....),..., (sibling('A','B'):-....),..., (father(john,mary):- true), (mother(jane,mary):- true) ] Q: clause_pattern(F, (father...),...), clause_pattern(M, (mother...),...), fails1( DB 1 & F & M, bottom), no_duplicates(...) demo( DB 1 & F & M, sibling(bob,mary)).

View update, lazy N-a-F co-operates with abduction A constraint-based proof predicate for program synthesis: demo( p, q ) iff p, q names of P, Q where Q succeds in P DB 1 = [(bottom:-....),..., (sibling('A','B'):-....),..., (father(john,mary):- true), (mother(jane,mary):- true) ] Q: clause_pattern(F, (father...),...), clause_pattern(M, (mother...),...), fails1( DB 1 & F & M, bottom), no_duplicates(...) demo( DB 1 & F & M, sibling(bob,mary)). A: F = [(father(john,bob):-true) | F 1 ], or M = [(mother(jane,bob):-true) | F 1 ]

”Co-operative” human-machine dialogue (example) U:Isn’t aunt Dora the mother of Mary? Let's ask... Q: demo( DB 0, mother(dora,mary)) A: no

”Co-operative” human-machine dialogue (example) U:Isn’t aunt Dora the mother of Mary? Let's ask... Q: demo( DB 0, mother(dora,mary)) A: no U:!?!?Hmmmm, perhaps they forgot to add it to the database? Q: fails( DB 0 & [(mother(dora,mary):-true)], bottom)

”Co-operative” human-machine dialogue (example) U:Isn’t aunt Dora the mother of Mary? Let's ask... Q: demo( DB 0, mother(dora,mary)) A: no U:!?!?Hmmmm, perhaps they forgot to add it to the database? Q: fails( DB 0 & [(mother(dora,mary):-true)], bottom) A: no U:... but why? I'm confused... do you have a mother for Mary? Q: constant(A), demo( DB 0, mother(A, mary))

”Co-operative” human-machine dialogue (example) U:Isn’t aunt Dora the mother of Mary? Let's ask... Q: demo( DB 0, mother(dora,mary)) A: no U:!?!?Hmmmm, perhaps they forgot to add it to the database? Q: fails( DB 0 & [(mother(dora,mary):-true)], bottom) A: no U:... but why? I'm confused... do you have a mother for Mary? Q: constant(A), demo( DB 0, mother(A, mary)) A: A = jane (no more answers)

”Co-operative” human-machine dialogue (example) U:Isn’t aunt Dora the mother of Mary? Let's ask... Q: demo( DB 0, mother(dora,mary)) A: no U:!?!?Hmmmm, perhaps they forgot to add it to the database? Q: fails( DB 0 & [(mother(dora,mary):-true)], bottom) A: no U:... but why? I'm confused... do you have a mother for Mary? Q: constant(A), demo( DB 0, mother(A, mary)) A: A = jane (no more answers) U:So Jane is the only known mother, but why can't we add aunt Dora? Q: constant(A), fails( DB 0 & [(mother(A,mary):- true)], bottom)

”Co-operative” human-machine dialogue (example) U:Isn’t aunt Dora the mother of Mary? Let's ask... Q: demo( DB 0, mother(dora,mary)) A: no U:!?!?Hmmmm, perhaps they forgot to add it to the database? Q: fails( DB 0 & [(mother(dora,mary):-true)], bottom) A: no U:... but why? I'm confused... do you have a mother for Mary? Q: constant(A), demo( DB 0, mother(A, mary)) A: A = jane (no more answers) U:So Jane is the only known mother, but why can't we add aunt Dora? Q: constant(A), fails( DB 0 & [(mother(A,mary):- true)], bottom) A: A = jane (no more answers) U:... so Jane is the only possible mother...

Observations (continued) Constraint solver produces residual constraints similar to "simplification method" [Nicolas, 82; Sadri, Kowalski, 88], but here as by-product of checking the whole, parameterized database A flavour of constructive negation

Observations (continued) Constraint solver produces residual constraints similar to "simplification method" [Nicolas, 82; Sadri, Kowalski, 88], but here as by-product of checking the whole, parameterized database A flavour of constructive negation Implies an incremental evaluation of IC’s: for each update, evaluate it, and prepare for next update

Observations (continued) Constraint solver produces residual constraints similar to "simplification method" [Nicolas, 82; Sadri, Kowalski, 88], but here as by-product of checking the whole, parameterized database A flavour of constructive negation Implies an incremental evaluation of IC’s: for each update, evaluate it, and prepare for next update Use of constraints provides optimal interleaving with abductive procedure for free for view update (opp. algorithms [Decker, Kowalski & al, Denecker & al,...] with explicit scheduling)

Observations (continued) Constraint solver produces residual constraints similar to "simplification method" [Nicolas, 82; Sadri, Kowalski, 88], but here as by-product of checking the whole, parameterized database A flavour of constructive negation Implies an incremental evaluation of IC’s: for each update, evaluate it, and prepare for next update Use of constraints provides optimal interleaving with abductive procedure for free for view update (opp. algorithms [Decker, Kowalski & al, Denecker & al,...] with explicit scheduling) IC’s used to produce useful answers in human-machine dialogue (though not giving ”arguments”)

Observations (continued) Constraint solver produces residual constraints similar to "simplification method" [Nicolas, 82; Sadri, Kowalski, 88], but here as by-product of checking the whole, parameterized database A flavour of constructive negation Implies an incremental evaluation of IC’s: for each update, evaluate it, and prepare for next update Use of constraints provides optimal interleaving with abductive procedure for free for view update (opp. algorithms [Decker, Kowalski & al, Denecker & al,...] with explicit scheduling) IC’s used to produce useful answers in human-machine dialogue (though not giving ”arguments”)... now, let’s have a look at that constraint solver

Constraint solver for lazy negation-as-failure – Simplified CHR’s; first version for known program and query

fails1(_,true) fail

Constraint solver for lazy negation-as-failure – Simplified CHR’s; first version for known program and query fails1(_,true) fail fails1(P, (Q1,(A=B),Q2)) (A=B -> fails1(P,(Q1,Q2));true)

Constraint solver for lazy negation-as-failure – Simplified CHR’s; first version for known program and query fails1(_,true) fail fails1(P, (Q1,(A=B),Q2)) (A=B -> fails1(P,(Q1,Q2));true) fails1(P, (Q1,dif(A,B),Q2)) A==B or both are constants or one is a variable free in (Q1,Q2) | (A==B -> true;fails1(P,(Q1,Q2)))

Constraint solver for lazy negation-as-failure – Simplified CHR’s; first version for known program and query fails1(_,true) fail fails1(P, (Q1,(A=B),Q2)) (A=B -> fails1(P,(Q1,Q2));true) fails1(P, (Q1,dif(A,B),Q2)) A==B or both are constants or one is a variable free in (Q1,Q2) | (A==B -> true;fails1(P,(Q1,Q2))) fails1(P, (Q1, A, Q2)) A names an atom | fails1(P, A*P, (Q1,Q2))

Constraint solver for lazy negation-as-failure – Simplified CHR’s; first version for known program and query fails1(_,true) fail fails1(P, (Q1,(A=B),Q2)) (A=B -> fails1(P,(Q1,Q2));true) fails1(P, (Q1,dif(A,B),Q2)) A==B or both are constants or one is a variable free in (Q1,Q2) | (A==B -> true;fails1(P,(Q1,Q2))) fails1(P, (Q1, A, Q2)) A names an atom | fails1(P, A*P, (Q1,Q2)) fails1(_, _*[], _) true

Constraint solver for lazy negation-as-failure – Simplified CHR’s; first version for known program and query fails1(_,true) fail fails1(P, (Q1,(A=B),Q2)) (A=B -> fails1(P,(Q1,Q2));true) fails1(P, (Q1,dif(A,B),Q2)) A==B or both are constants or one is a variable free in (Q1,Q2) | (A==B -> true;fails1(P,(Q1,Q2))) fails1(P, (Q1, A, Q2)) A names an atom | fails1(P, A*P, (Q1,Q2)) fails1(_, _*[], _) true fails1(P, A*[C|Cs], Cont) fails1(P, A*C, Cont), fails1(P, A*Cs, Cont)

Constraint solver for lazy negation-as-failure – Simplified CHR’s; first version for known program and query fails1(_,true) fail fails1(P, (Q1,(A=B),Q2)) (A=B -> fails1(P,(Q1,Q2));true) fails1(P, (Q1,dif(A,B),Q2)) A==B or both are constants or one is a variable free in (Q1,Q2) | (A==B -> true;fails1(P,(Q1,Q2))) fails1(P, (Q1, A, Q2)) A names an atom | fails1(P, A*P, (Q1,Q2)) fails1(_, _*[], _) true fails1(P, A*[C|Cs], Cont) fails1(P, A*C, Cont), fails1(P, A*Cs, Cont) fails1(P,A*(H:-B), Cont) copy_term((A,Cont),(A1,Cont1)), instance((H:-B),(H1,B1)), fails1(P,(H1=A1,B1, Cont1))

Constraint solver for lazy negation-as-failure – Simplified CHR’s; first version for known program and query fails1(P,A*(H:-B), Cont) copy_term((A,Cont),(A1,Cont1)), instance((H:-B),(H1,B1)), fails1(P,(H1=A1,B1, Cont1))

Adapt for partly known object program and query Definition: External variable: appears in arg's to fails Externally dependent variable A : A external or instance( External,... A... )

Adapt for partly known object program and query Definition: External variable: appears in arg's to fails Externally dependent variable A : A external or instance( External,... A... ) Replace copy_term by internal_copy_term : as copy_term, but keep external variables, copy instance constraints (also keeping external var’s)

Adapt for partly known object program and query Definition: External variable: appears in arg's to fails Externally dependent variable A : A external or instance( External,... A... ) Replace copy_term by internal_copy_term : as copy_term, but keep external variables, copy instance constraints (also keeping external var’s) Principle: –process literals where result (yes/no) is predictable, –delay for the rest (typically due to external variables) –various optimizations for = and dif

Correctness properties (still need to be formalized) Local soundness and completeness of each rule obvious

Correctness properties (still need to be formalized) Local soundness and completeness of each rule obvious Computation rule á la Prolog => termination á la Prolog

Correctness properties (still need to be formalized) Local soundness and completeness of each rule obvious Computation rule á la Prolog => termination á la Prolog More eager com. rule => better ”precision” in detecting inconsistencies early; problematic for recursive programs

Efficient implementations Prolog-like setting: Replace metainterpreter by extended WAM functionality copy_internal_term replaced by operations on WAM stacks CHR’s loop for rules-to-apply replaced by low-level message passing – allowing complex guards to simplify dynamically Needs more detailed control of unfolding in order to employ Prolog’s indexing techniques Ex: dif(peter,mary), dif(peter,dolly),.... => \+ mother(peter,_)

Efficient implementations Prolog-like setting: Replace metainterpreter by extended WAM functionality copy_internal_term replaced by operations on WAM stacks CHR’s loop for rules-to-apply replaced by low-level message passing – allowing complex guards to simplify dynamically Needs more detailed control of unfolding in order to employ Prolog’s indexing techniques Ex: dif(peter,mary), dif(peter,dolly),.... => \+ mother(peter,_) Relational database (RDB) setting: Use Prolog as ”semantic engine” interfaced with RDB as efficient fact base Embed functionality in RBD system

Conclusion Relating integrity constraints and constraint logic programming: –Integrity constraints represented as calls to CLP constraints Strategy: lazy negation-as-failure CLP provides –incremental evaluation –self-specializing, self-simplifying code – not unlike a partial evaluation approach [Leuschel, De Schreye, 1998]

Conclusion Relating integrity constraints and constraint logic programming: –Integrity constraints represented as calls to CLP constraints Strategy: lazy negation-as-failure CLP provides –incremental evaluation –self-specializing, self-simplifying code – not unlike a partial evaluation approach [Leuschel, De Schreye, 1998] To do next: consider update by deletion –in present model must be described by deleted_ facts include negation to object language –we expect: possible, but with the ”usual” complexity try out suggested ”efficient implementations”

Final remark CLP highly suited for evaluation of ICs ^ and modeling!