CHR Grammars with Multiple constraint stores. Overview

Similar documents
First Workshop on Constraint Handling Rules

An Experimental CLP Platform for Integrity Constraints and Abduction

Assumptions and Abduction in Prolog

An Experimental CLP Platform for Integrity Constraints and Abduction

Chapter 3: Describing Syntax and Semantics. Introduction Formal methods of describing syntax (BNF)

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

Prolog as Description and Implementation Language in Computer Science Teaching

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Formal Languages and Compilers Lecture V: Parse Trees and Ambiguous Gr

22c:111 Programming Language Concepts. Fall Syntax III

Course on Artificial Intelligence and Intelligent Systems. A short introduction to CHR and its application for rule-based expert systems

Lexical Analysis. COMP 524, Spring 2014 Bryan Ward

CPS 506 Comparative Programming Languages. Syntax Specification

Interpreting Abduction in CLP

Propositional Logic Formal Syntax and Semantics. Computability and Logic

PL Revision overview

A simple syntax-directed

Principles of Programming Languages COMP251: Syntax and Grammars

Context Free Languages

Application: Programming Language Semantics

Simplification of integrity constraints with aggregates and arithmetic built-ins

Simplification of integrity constraints with aggregates and arithmetic built-ins

AXIOMS OF AN IMPERATIVE LANGUAGE PARTIAL CORRECTNESS WEAK AND STRONG CONDITIONS. THE AXIOM FOR nop

Syntax Analysis. Chapter 4

Syntax/semantics. Program <> program execution Compiler/interpreter Syntax Grammars Syntax diagrams Automata/State Machines Scanning/Parsing

COP 3402 Systems Software Syntax Analysis (Parser)

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Parsing. Parsing. Bottom Up Parsing. Bottom Up Parsing. Bottom Up Parsing. Bottom Up Parsing

Part I Logic programming paradigm

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Integration of abductive reasoning and constraint optimization in SCIFF

Parsing Chart Extensions 1

Packaging Theories of Higher Order Logic

Lectures 20, 21: Axiomatic Semantics

1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character

yacc, lex Source Code (C) compile Executable Parser Test on HOL Examples, TPTP Library, and TSTP Library

HW 3: Bottom-Up Parsing Techniques

Program Abstractions, Language Paradigms. CS152. Chris Pollett. Aug. 27, 2008.

Compiler Design Concepts. Syntax Analysis

Programming Languages Third Edition. Chapter 7 Basic Semantics

A Unified Logical Framework for Rules (and Queries) with Ontologies - position paper -

Principles of Programming Languages COMP251: Syntax and Grammars

Programming Languages Third Edition

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

Contents. Chapter 1 SPECIFYING SYNTAX 1

LANGUAGE PROCESSORS. Presented By: Prof. S.J. Soni, SPCE Visnagar.

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer:

ELEC 876: Software Reengineering

Introduction to Logic Programming, April 3, 2017

afewadminnotes CSC324 Formal Language Theory Dealing with Ambiguity: Precedence Example Office Hours: (in BA 4237) Monday 3 4pm Wednesdays 1 2pm

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

CS415 Compilers. Syntax Analysis. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

The Metalanguage λprolog and Its Implementation

Types and Static Type Checking (Introducing Micro-Haskell)

Knowledge Representation

A second life for Prolog

A Simple Syntax-Directed Translator

Parsing II Top-down parsing. Comp 412

EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing. Görel Hedin Revised:

1 Lexical Considerations

Simple Unification-based Type Inference for GADTs

CSE P 501 Compilers. Parsing & Context-Free Grammars Hal Perkins Spring UW CSE P 501 Spring 2018 C-1

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES ( ) (ODD) Code Optimization

The Prolog to Mercury transition guide

CS 242. Fundamentals. Reading: See last slide

Lecture Notes on Computational Interpretations of Modalities

Specifying Syntax. An English Grammar. Components of a Grammar. Language Specification. Types of Grammars. 1. Terminal symbols or terminals, Σ

! Use of formal notations. ! in software system descriptions. ! for a broad range of effects. ! and varying levels of use. !

LECTURE NOTES ON COMPILER DESIGN P a g e 2

A programming language requires two major definitions A simple one pass compiler

CMPS Programming Languages. Dr. Chengwei Lei CEECS California State University, Bakersfield

CS164: Midterm I. Fall 2003

Propositional Logic. Andreas Klappenecker

CA Compiler Construction

Semantic Analysis. Lecture 9. February 7, 2018

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

Knowledge Sharing Among Heterogeneous Agents

LOGIC AND DISCRETE MATHEMATICS

Introduction to Parsing

Implementação de Linguagens 2016/2017

Safe Stratified Datalog With Integer Order Does not Have Syntax

Lecture 09: Data Abstraction ++ Parsing is the process of translating a sequence of characters (a string) into an abstract syntax tree.

CLF: A logical framework for concurrent systems

Computer Science Department Carlos III University of Madrid Leganés (Spain) David Griol Barres

Compilers and computer architecture: A realistic compiler to MIPS

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

INF5390 Kunstig intelligens. First-Order Logic. Roar Fjellheim

Hoare Logic: Proving Programs Correct

Consider a description of arithmetic. It includes two equations that define the structural types of digit and operator:

CSC 501 Semantics of Programming Languages

UNIT I Programming Language Syntax and semantics. Kainjan Sanghavi

Transaction management with integrity checking

Data-Flow Analysis Foundations

Syntax. In Text: Chapter 3

SOFTWARE ARCHITECTURE 5. COMPILER

Overview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics

Language Reference Manual simplicity

CSE 582 Autumn 2002 Exam 11/26/02

5. Semantic Analysis!

Transcription:

CHR Grammars with Multiple constraint stores Henning Christiansen Roskilde University, Computer Science, P.O.Box 260, DK-4000 Roskilde, Denmark henning@ruc.dk, http://www.ruc.dk/ henning Overview Introduction to CHR Grammars Abductive language interpretation in CHRG The need for multiple constraint stores to handle all interp s in parallel Proposal for new architecture optimized for multiple constraint stores Conclusion

Introduction to CHR Grammars Prolog CHR DCG CHR Grammars Example: Grammar for simple sentences with coordination Peter likes and Mary detests spinach subj(a), verb(v), obj(b) ::> sent(s(a,v,b)). subj(a), verb(v) /- [and], sent(s(_,_,b)) ::> sent(s(a,v,b)). Notice context sensitive rules: /- indicates right context. Compiles into subj(n0,n1,a), verb(n1,n2,v), obj(n2,n3,b) ==> sent(n0,n3,s(a,v,b)). subj(n0,n1,a), verb(n1,n2,v), token(n2,n3,and), sent(n3,n4,s(_,_,b)) ==> sent(n0,n2,s(a,v,b)).

General properties of CHRG Syntactic sugar over CHR High expressibility: contains full power of CHR (and Prolog) plus... Several advantages for NLP; documented elsewhere Implemented by compile-on-load CHR... followed by CHR Prolog... Fully equipped with top-level pred s, auxiliaries, passive optimizations Available for SICSTUS Prolog on www

Abductive language interpretation in CHRG Basically following scheme of [Abdennadher, Christiansen, FQAS200]: Abducibles CHR constraints Integrity constraints CHR rules Efficient: No metainterpreter Price: Slightly limited use of negation compared with some abd. frameworks Translating abductive language interpretation into deduction...

Translating abductive language interpretation into deduction Rule perfect for deductive verification of correct utterance wrt. known semantic context: [help], {have_problem} ::> exclamation. Move abducibles to other side of implication: A rule perfect for abductive reasoning to figure out feasible semantic context [help] ::> exclamation, {have_problem}. Easy to formalize and prove correct [Christiansen, NLULP2002, TPLP2005] Works perfectly for unambiguous grammars In general, extra machinery needed to avoid mixing up different interpretations

Problem with abduction and ambiguous grammars Delivers all grammar nodes (syntax trees) and their abducibles in one big mess Solution: Each syntax tree has its own local constraint store Example: Three syntax trees each with its set of abducibles in local store c 1 1 c 2 2 c 3 3 Assume rules so 1, 2 ==> 12, {c 12 } and 2, 3 ==> 23, {c 23 } Then derivation should produce new trees c 1 c 2 c 12 12 c 2 c 3 c 23 23 and apply integrity constraints CHR rules to the new local stores Can be implemented in SICStus version of CHR with indexing technique and copying of constraints Needless to say: Very inefficient

Proposal for a new and optimized architecture written in C Goal: Evaluate all different abductive interpretations in parallel efficient copying of constraints (therefore C) with efficient pruning by integrity constraints Sketch of a prototype currently under development Several details still need to be worked out suggestions, comments well-come Ignored in this talk: Context sensitive rules implies restrictions on when grammar rule can apply

Procedural semantics A multi constraint store: a set of pairs G, S where G a grammar symbol and S a constraint store of abducible atoms. A derivation is a sequence of m. c. stores M 1,..., M n, such that: M 1 has one component for each input token, e.g.: M 1 = { token(0,1,the),, token(1,2,man),, token(2,3, walks), } M i+1 is derived from M i if either: There is an instance of a grammar rule G 1,..., G m ::>G 0, {A} with G j, S j M i for j = 1... m; A is a set of abducibles. Then M i+1 = M i { G 0, S 1 S m A } An integrity constraint can apply to a local constraint store S in M i producing a new store S and possible sideeffects on variables in G given by substitution σ. Then M i+1 = M i \ { G, S } { Gσ, S }. However, if S is failed, M i+1 = M i \ { G, S }. No rule is applied twice to the same constraints. Detailed computation rule...

Detailed computation rule: Components of the M 0 are entered one by one from left to right, each at a point when no rule can apply. Whenever a grammar rule is applied, integrity constraints apply as long as possible before a grammar rule can apply.

Representation local constraint stores Relative addressing so that copying becomes easy. Example with unary abducibles p(x), q(y), r(z) p q r variable offset=0 variable offset=0 variable offset=0 Unify X=Y: p q r variable offset=1 variable offset=0 variable offset=0 Unify X=a, Z=Y: p q r variable offset=1 constant=a variable offset=-1 Observe: Combining diff. stores copy into consecutive cells Deletion caused by propagation rule: marking bit

Ideas for optimization based on techniques from data integration [Christiansen, Martinenghi, LOPSTR2004, FOIKS2004] Assume Γ (C) is the set of ICs testing a set local constraint store Let Γ (C 1, C 2 ) be a specialized and optimized IC based on assumptions C 1 and C 2 are consistent separately, i.e., all rules have applied Let Γ (C 1, A) be a specialized and optimized IC based on assumptions C 1 is consistent, i.e., all rules have applied A is known in advance (apart from instantiation of variables) Incremental algorithm for copying and integrity checking of S new = S 1 S m A: 1. i := 1; S new := S 1 ; 2. S new := Γ (S new, S i ); 3. if S new = failure then failure-exit; 4. if i < m then {i := i + 1; go to 2}; 5. S new := Γ (S new, A); 6. if S new = failure then failure-exit else normal-exit; ((Ignored addition of new abducibles by ICs; easy to add))

Conclusion :) Ongoing implementation; no disappointments yet Ambition: To produce a barrier-breaking environment for abductive language interpretation Flexible language for expressing detailed and strong ICs... needed to keep down explosive complexity Very efficient check and pruning Pointing forward to language processing with all phases in cooperative parallel: Lexical, morphologic, ontologic, semantics, pragmatic...