1 Pierangelo Dell’Acqua Dept. of Science and Technology Linköping University Constraint programming 2001 November 13th 2001

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Types and Programming Languages Lecture 7 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Marco Gavanelli – Università di Ferrara, Italy Marco Alberti – Universidade nova de Lisboa, Portugal Evelina Lamma – Università di Ferrara, Italy.
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Artificial Intelligence Chapter 13 The Propositional Calculus Biointelligence Lab School of Computer Sci. & Eng. Seoul National University.
SLD-resolution Introduction Most general unifiers SLD-resolution
Satisfiability Modulo Theories (An introduction)
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
ISBN Chapter 3 Describing Syntax and Semantics.
Program Proving Notes Ellen L. Walker.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
CS5371 Theory of Computation
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
Orcas Constraint Handling Rules May, 2005 Jairson Vitorino and Marcos Aurélio ORCAS Orcas.
Logic in Computer Science Transparency No Chapter 3 Propositional Logic 3.6. Propositional Resolution.
December 8, 2009Theory of Computation Lecture 22: Turing Machines IV 1 Turing Machines Theorem 1.1: Any partial function that can be computed by a Post-
Methods of Proof Chapter 7, second half.
Chapter 3 Propositional Logic
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Propositional Calculus Math Foundations of Computer Science.
1 Constraint Programming: An Introduction Adapted by Cristian OLIVA from Peter Stuckey (1998) Ho Chi Minh City.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
Inequalities and Proof
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran.
Introduction Chapter 0. Three Central Areas 1.Automata 2.Computability 3.Complexity.
Propia and CHRs Transforming Constraint Specification into Constraint Behaviour.
MATH 224 – Discrete Mathematics
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
1 Knowledge Based Systems (CM0377) Lecture 4 (Last modified 5th February 2001)
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
CS6133 Software Specification and Verification
The Bernays-Schönfinkel Fragment of First-Order Autoepistemic Logic Peter Baumgartner MPI Informatik, Saarbrücken.
Logical Agents Logic Propositional Logic Summary
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CSE 230 The -Calculus. Background Developed in 1930’s by Alonzo Church Studied in logic and computer science Test bed for procedural and functional PLs.
A Quick Math Overview (not the last one!) Section 1.4, you should it read carefully! Reading the corresponding material from the book is strongly encouraged.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
Computer Science CPSC 322 Lecture 22 Logical Consequences, Proof Procedures (Ch 5.2.2)
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
CHR + D + A + O Operational Semantics in Fluent Calculus December, 2007.
We will now study some special kinds of non-standard quantifiers. Definition 4. Let  (x),  (x) be two fixed formulae of a language L n such that x is.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
Paper Presentation Classroom Assignment using Constraint Logic Programming [Slim Abdennadher, Matthias Saft, Sebastian Will] University of Munich Presented.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Logic Programming Lecture 2: Unification and proof search.
The Propositional Calculus
Logic: Top-down proof procedure and Datalog
Logics for Data and Knowledge Representation
Bottom Up: Soundness and Completeness
Constraint Handling Rules with Disjunction (CHRv)
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

1 Pierangelo Dell’Acqua Dept. of Science and Technology Linköping University Constraint programming 2001 November 13th

2 Overview 1 Motivation 2 Language CHR 3 Declarative and operational semantics 4 Properties 5 Examples of CHR constraint solvers

3 Based on FTheory and Practice of Constraint Handling Rules Thom Frühwirth, J. Logic Programming 1994:19, 20:1-679 FExamples CHR constraint solvers available at:

4 Black-box vs Glass-box solvers FIn most systems constraint solving is hard-wired in a built-in constraint solver in a low-level language: black-box approach 3efficiency 3non-extensible, unpredictable, hard to debug FSome systems facilitate defining new constraints and solvers: glass-box approach 3improved control of propagation and search 3examples CHR, HAL,...

5 Constraint Handling Rules (CHR) FDeclarative programming language for the specification and implementation of constraint solvers and programs Black-box Host language (Prolog, Lisp, … ) CHR-solver Application CHR-constraints built-in constraints FCHR-constraint solvers are open and flexible, can be maintained, debugged and analysed

6 CHR by example The partial order relation X  Y as a user-defined constraint: Computation: A=<B  C=<A  B=<C C=<A  A=<B propagates C=<B by transitivity C=<B  B=<C simplifies to B=C by antisymmetry A=<B  C=<A simplifies to A=B by antisymmetry since B=C A=B  B=C X= X=Y | true.reflexivity X= X=Y.antisymmetry X= X=<Z.transitivity

7 CHR syntax A CHR-program is a finite set of CHR-rules. There are three kinds of CHR-rules: HeadHconjunction of CHR-constraints GuardGconjunction of built-in constraints BodyBconjunction of built-in and CHR-constraints SimplificationH G | B PropagationH = => G | B SimpagationH1 \ H2 G | B

8 Declarative semantics Simplification rule H G | B  h (  g (G)  ( H   b ( B ) ) ) Propagation rule H = => G | B  h (  g (G)  ( H   b ( B ) ) ) Simpagation rule H1 \ H2 G | B  h 1  h 2 (  g (G)  (H1  H2   b (H1  B)))

9 Declarative semantics (2) Declarative semantics of a CHR-program P: Sem(P) = L P, CT where L P is the logical reading of the CHR-rules in P and CT is a theory for built-in constraints

10 Operational semantics A state is a tuple  F,E,D  where: F is a conjunction of CHR- and built-in constraints (goal store) E is a conjunction of CHR-constraints (CHR-store) D is a conjunction of built-in constraints (built-in constraints store)

11 CHR transitions Solve  C  F, E, D    F, E, D2  if C is a built-in constraint and CT |= (C  D)  D2 Introduce  H  F, E, D    F, H  E, D  if H is a CHR-constraint Simplify  F, H2  E, D    B  F, E, H=H2  D  if (H G | B) in P and CT |= D   h (H=H2  G)

12 CHR transitions (2) Propagate  F, H2  E, D    B  F, H2  E, H=H2  D  if (H = => G | B) in P and CT |= D   h (H=H2  G)

13 Initial and final states An initial state consists of a goal G and empty constraint stores:  G,true,true  A final state is either of the form: (i)  F,E,false  failed final state or of the form: (ii)  true,E,D  successful final state where no transition is applicable and D  false

14 CHR computations A computation of a goal G is a sequence S 0, S 1, … of states with S i  S i+1 beginning with the initial state S 0 =  G,true,true  and ending with a final state or diverging The logical meaning of a state  F,E,D , which occurs in a computation for G, is  x (F  E  D), where x are the variables in  F,E,D  but not in G An answer of a goal G is the final state of a computation for G

15 Example CHR calculus X= X=Y | true.reflexivity X= X=Y.antisymmetry X= X=<Z.transitivity  A=<B  C=<A  B=<C, true, true  Introduce  3  true, A=<B  C=<A  B=<C, true  Propagate   C=<B, A=<B  C=<A  B=<C, true  Introduce   true, A=<B  C=<A  B=<C  C=<B, true  Simplify   B=C, A=<B  C=<A, true  Solve   true, A=<B  C=<A, B=C  Simplify   A=B, true, B=C  Solve   true, true, A=B  B=C 

16 Logical equivalence of states CHR transitions preserve the logical meaning of states: Lemma Let P be a CHR program and G a goal. If C is the logical meaning of a state in a computation of G, then L P, CT |=  ( G  C) There is no distinction between successful and failed computations

17 Correspondence between semantics Theorem (Soundness) Let P be a CHR program and G a goal. If G has a computation with answer C, then L P, CT |=  ( C  G) Theorem (Completeness) Let P be a CHR program and G a goal with at least one finite computation. Let C be a conjunction of constraints. If L P, CT |=  (G  C), then G has a computation with answer C2 such that L P, CT |=  ( C  C2)

18 Example: completeness The completeness theorem does not hold if G has no finite computations: Let P be { p p } and G the goal p. Since L P is {p  p}, it holds that L P,CT |= p  p, but G has only an infinite computation

19 Example: failed computations The completeness theorem is weak for failed computations: Let P be: We have that L P, CT |=  q, but q has no failed computation. It has a successful derivation with answer q. { p q, p false }

20 Confluence Confluence: The answer of a goal G is always the same, no matter which of the applicable rules are applied { p q, p false } is not confluent { p q, p false, q false} is confluent

21 Soundness and Completeness revisited Theorem (Strong Soundness and Completeness) Let P be a terminating and confluent CHR program, G a goal and C a conjunction of constraints. Then the following are equivalent: L P, CT |=  (C  G) G has a computation with answer C2 such that: L P, CT |=  (C  C2) Every computation of G has an answer C2 such that: L P, CT |=  (C  C2)

22 CLP + CHR Any CLP language can be extended with CHR - Allow clauses for CHR constraints: introduce choices - Regard a predicate as a constraint and add CHR rules for it Idea: Don’t know and don’t care nondeterminism combined in a declarative way

23 CLP+CHR language A CLP+CHR program is a finite set of : (i)CLP clauses for predicates and CHR constraints, and (ii)CHR rules for CHR constraints. A CLP clause is of the form: H :- B 1,…,B k (k  0) an atom or a CHR constraint not a built-in constraint conjunction of atoms, CHR constraints and built-in constraints

24 CLP+CHR language (2) The logical meaning of a CLP clause is given by Clark’s completion Backward compatibility Labelling declarations (see def. 6.1 of JLP paper) are dropped, easily simulated H :- B label-with H if G lw, H G | H2, lw H2 :- B CHR constraint new predicate new CHR constraint

25 CLP+CHR transitions Unfold (revisited)  H2  F, E, D    B  F, E, H=H2  D  if (H:-B) in P, H2 is a predicate and CT |= D  h (H=H2) Label (revisited)  F, H2  E, D    B  F, E, H=H2  D  if (H:-B) in P, H2 is a CHR constraint and CT |= D  h (H=H2)

26 Examples of CHR solvers Several constraint solvers have been written in CHR, including new constraint domains such as terminological and temporal reasoning bool.plboolean constraints arc.plarc-consistency over finite domains interval.plinterval domains over integers and reals list.plequality constraints over concatenation of lists

27 Sicstus Prolog + CHR A CHR rule in SicstusProlog+CHR is of the form: H G | B H = => G | B H1 \ H2 G | B where: H is a conjunction of CHR-constraints G is a conjunction of atoms and built-in constraints B is a conjunction of atoms, built-in and CHR-constraints A CHR rule can be fired if its guard G is true Note that during the proof of the guard G no new binding can be generated for variables that occur also in H