Skip to main content Accessibility help
×
Hostname: page-component-7bb8b95d7b-nptnm Total loading time: 0 Render date: 2024-09-20T12:07:43.904Z Has data issue: false hasContentIssue false

1 - Getting started

from Part I - CHR tutorial

Published online by Cambridge University Press:  10 February 2010

Thom Frühwirth
Affiliation:
Universität Ulm, Germany
Get access

Summary

This chapter is a basic introduction to CHR using simple examples. They introduce the types of rules used in CHR, their behavior and basic ingredients of the language such as logical variables and built-in constraints. Last but not least, we define the concrete syntax of CHR and we informally describe how CHR executes its rules.

In this book, we will use the concrete syntax of CHR with Prolog as the host language in the practical programming parts and mathematical abstract syntax in the formal Part II.

How CHR works

For programming, we recommend using a CHR implementation from K.U. Leuven, since they are currently the most recent and advanced. The CHR rules themselves will also be executable in other Prolog implementations of CHR and with minor modifications in K.U. Leuven JCHR, an implementation of CHR in Java and in the K.U. Leuven CHR library for C.

When we write a CHR program, we can mix host language statements and CHR code. The CHR-specific part of the program consists of declarations and rules.

Propositional rules

We start programming in CHR with rules that only involve propositions, i.e. constraints without arguments. Syntactically, constraints are similar to procedure calls.

Example 1.1.1 (Weather) Everybody talks about the weather, and we do as well.

Declarations. They introduce the CHR constraints we are going to define by the rules. They are specific to the implementation and the host language. Later in this book, we will usually skip the declarations and concentrate on the rules.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2009

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Getting started
  • Thom Frühwirth, Universität Ulm, Germany
  • Book: Constraint Handling Rules
  • Online publication: 10 February 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511609886.003
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Getting started
  • Thom Frühwirth, Universität Ulm, Germany
  • Book: Constraint Handling Rules
  • Online publication: 10 February 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511609886.003
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Getting started
  • Thom Frühwirth, Universität Ulm, Germany
  • Book: Constraint Handling Rules
  • Online publication: 10 February 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511609886.003
Available formats
×