(Co-)Inductive semantics for Constraint Handling Rules

In this paper, we address the problem of defining a fixpoint semantics for Constraint Handling Rules (CHR) that captures the behavior of both simplification and propagation rules in a sound and complete way with respect to their declarative semantics…

Authors: Remy Haemmerle

Publishe d in The ory a nd Pr actic e of L o gic Pr o gr amming, 11(4-5): 593-60 9, 2011 1 (Co-)Inductive semantics for Constr aint Hand ling R ules R ´ emy Haemmerl´ e T e chnic al University of Madrid Abstract In this pap er, we address the problem of d efining a fixp oin t semantics for Constraint Handling Rules (CHR) that ca ptures the b eha vior of b oth simplificatio n and propagation rules in a sound and complete w ay with resp ect to their declarative semanti cs. Firstly , w e show that the logical reading of states with respect to a set of simplification ru les can b e characterized by a least fix point ov er th e transition system generated by the abstract operational seman t ics of CHR. Similarly , w e demonstrate th at the logical reading of states with respect to a set of propagation rules can b e c haracterized by a greatest fixp oin t . Then, in order to take adv antag e of b oth types of rules without losing fix point characterizatio n, w e presen t an op erati onal semantics with persisten t.W e finally es tablish that this seman tics can b e characterized by tw o n ested fixp oin ts, and we show the resulting language is an elegan t framewo rk to program using coinductive reasoning. KEYWORDS : CHR, coinduction, fixp oin t, declarative seman t ics , p ersis tent constrain ts. 1 In tro duction Owing to its origins in the tra dition of Constra int Logic Pro g ramming (CLP) (Jaf- far and Lassez 1987), Constraint Handling Rules (CHR) (F r¨ uh wirth 1998) feature declarative semantics through direct interpretation in classical logic. How e v er, no attempt to provide fixp oin t semantics to the whole language , sound and complete w.r.t. this declara tiv e s eman tics has suc c eeded so far. This is particularly s urprising considering tha t the fixp oint semantics is a n impor tan t foundation of the declarative semantics of CLP . It is p e r haps b ecause CHR is the combination o f t w o inherently distinct kinds of r ule s that this formulation is not so s imple. On the one hand, the so-called Constraint Simplifica tion Rules (CSR) replace co ns train ts b y simpler ones while preserv ing their meaning. On the o ther hand, the so -called Constraint Pr op- agation Rules (CPR) add r edundan t co nstrain ts in a mono tonic way . E v en though in the declarative semantics the tw o notions merge, o ne of the main interests of the languag e comes from the explicit distinction b etw een the tw o. Indeed, it is well known that propaga tion rules are useful in practice but hav e to be managed in a different wa y from simplification rules to avoid trivia l no n-termination. (See for instance explana tions by F r ¨ uh wirth (2 009) o r Betz e t al. (2010).) Soundness o f the op erational semantics of CSR (i.e. to each deriv ation corre- sp onds a deduction) hav e b een proved b y F r ¨ uh wirth (2009), while completeness 2 R´ emy Haemmerl´ e (i.e. to ea c h deduction c o rresp onds a der iv ation) has b een tac kled by Abdennadher et al. (1999). Howev er, it is worth noticing that the completeness r e sult is limited to terminating pro grams. O n the other hand, the accuracy of CPR w.r.t. its classica l logic semantics is only giv en thro ugh its naive transla tion into CSR. Since an y s e t of propaga tion rules trivially loops when seen as simplification rules, the completeness result do es not apply to CPR. It is well kno wn that termination captur es least fixp o in t (l.f.p.) of states of a transition s ystem. Quite na turally , non-terminatio n ca ptures the g reatest fix point (g.f.p.). Starting fro m this observ ation, we show in this pap er that if they are con- sidered independently , CSR and CPR can be characterize d by a l.f.p. (or inductiv e ) and g.f.p. (or coinductive) semantics resp ectiv ely , providing along the wa y the firs t completeness result for CPR. Then, in order to take adv an ta ge of b oth t yp es of rules without lo s ing fixp oin t characterization, we present an op erational semantics ω h similar to the one r ecen tly pr oposed b y Betz et al. (201 0 ). Subsequen tly we demonstrate that this new semantics can be characteriz e d b y tw o nested fixp oint s and can b e implemented in a simple ma nner to provide the fir st logically co mplete system (w.r.t. failures) for a segment of CHR with pr opagations rules. W e show a s well this semantics yields an eleg an t fra mew or k for pr ogramming with coinductive reasoning on infinite (or non-well founded) ob jects (Ba rwise and Moss 1996). The remainder of this pap e r is structured as follows: Section 2 states the s yn tax of CHR and summarizes s ev era l sema n tics. In Section 3, w e presen t t wo fixp o in t semantics for CHR. W e show these semantics, which built ov er the transition system induced by the abstract o p erational s eman tics of CHR, offer a c haracteriz ation of logical reading o f queries w.r.t. CSR and CP R, r espectively . In Sectio n 4, we define semantics with p ersistent constra ints related to the one rec e n tly introduce d by Betz et al. (2010). W e prov e this new op erational semantics ca n b e characterized by a l.f.p. nes ted within a g.f.p., a nd giv e an implementation via a s ource-to-source transformatio n. Finally , in Section 5, w e illus tr ate the pow er of the languag e b efore concluding in Section 6. 2 Preliminaries on CHR In this sectio n, w e intro duce the syntax, the declarative semantics and tw o diff erent op erational semantics for CHR. In the next sections , both op erational s eman tics will be used, the former as theoretical foundation for our different fixpo in t semantics, and the la tter a s a target to implementation purp oses. 2.1 Syntax The for malization of CHR a s sumes a la nguage of built-in c onstr aints cont aining the equality =, false , and true o ver some theo ry C and defines user-define d c onstr aints using a different set of predicate s y m b ols. In the fo llo wing, we will denote v ariables by upp er case letters, X , Y , Z , . . . , and (user-defined or built-in) co ns train ts b y low erca se letters c, d, e . . . By a slight abuse o f notation, we will confuse conjunction and multiset of constraints, forge t braces around m ultisets and use comma for (Co-)Inductive semantics for Constr aint Hand ling Rules 3 m ultiset union. W e note fv( φ ) the set o f free v ariables of any formula φ . The notation ∃ - ¯ X φ denotes the existential closure of φ with the ex ception of v a riables in ¯ X , which remain free. In this paper, w e require the no n-logical axioms of C to b e c oher ent formula (i.e. formulas of the fo r m ∀ ( C → ∃ ¯ Z . D ), w he r e b oth C and D stand for po ssibly empt y c onjunctions of built-in constra in ts). Co ns train t theories verifying such requir emen ts corr espond to Saraswat’s simple c onstr aints systems (1991). A CHR pr o gr am is a finite s et of ep on ymo us rules of the form: r @ K \ H ⇐ ⇒ G | C , B where K (the kept he ad ), H (the r emove d he ad ) a re m ultisets o f user- defined c o n- straints resp ectiv ely , G (the gu ar d ) is a conjunction of built-in cons tr ain ts, C is a conjunction o f built-in constraints, B is a multiset of user- defined constr ain ts and, r (the rule name ) is an arbitr ary identifier assumed unique in the progr am. Rules, where both heads are empt y , are prohibited. Empty kept-head c a n b e o mitt ed to- gether with the symbol \ . The lo c al variable s of rule are the v aria bles o ccurring in the guard a nd in the b ody but not in the head that is lv( r ) = fv( G , C , B ) \ fv ( K , H ). CHR r ules a r e divided into tw o classes : simplific ation rules if the remov ed head is non empt y and pr op agation r u les otherwise. Pr opagation rules can be written using the alter nativ e syntax: r @ K = ⇒ G | C , B A CHR state is a tuple h C ; E ; ¯ X i , where C (the CHR stor e ) is a multiset o f CHR constraints, E (the built-in st or e ) is a conjunction o f built-in c onstrain ts, and X (the glob al variables ) is a set of v ar iables. I n the following, Σ will denote the set of states and Σ b the set of answers (i.e. states of the form h∅ ; C ; ¯ X i ). A state is c onsist ent if its built-in store is sa tisfiable within C (i.e. there exists an in ter pretation of C which is a mo del o f ∃ C ), inc onsist ent o therwise. 2.2 De clar ative sem antics W e s tate now the declarative sema ntics of CHR. The lo gic al r e ading of a rule and a state is as fo llo ws: Rule: K \ H ⇐ ⇒ G | C , B ∀  ( K ∧ G ) →  H ↔ ∃ -fv( K , H ) ( G ∧ C ∧ B )  State: h C ; E ; ¯ X i ∃ - ¯ X ( C ∧ E ) C P , the lo gic al re ading of a pro g ram P within a constraint theory C is the conjunc- tion of the logica l readings o f the r ules o f P with the co ns train t theory C . 2.3 Equi valenc e-b ase op er ational semantics Here, we reca ll the e quivalenc e-b ase d op erational semantics ω e of Raise r et al. (2 009). It is simila r to the very abstr act semantics ω a of F r ¨ uh wirth (2009), the mo s t gener a l op erational semant ics of CHR. W e pr efer the former b ecause it includes an explicit notion o f equiv a le nc e , that will simplify man y formulations. B ecause this is the most abstract op erational semantics w e co nsider in this pap e r, w e will refer to it a s 4 R´ emy Haemmerl´ e the abstr act (op er ational) semantics . F o r the sa k e of genera lit y , we present it in a parametric form, according to s o me so und e quiv alence r elation. W e will sa y that an equiv alence rela tion ≡ i is (lo gic al ly) soun d if t wo states e quiv- alent w.r.t. ≡ i hav e logically equiv alent r eadings in the theory C . The equiv alence class o f some state σ by ≡ i will b e noted J σ K i . F or a given pro gram P and a sound equiv alence ≡ i , the ≡ i -tr ansition r elation , noted P − → i , is the least relation satisfying the following rules: ( r @ K \ H ⇐ ⇒ G | C , B ) ∈ P ρ lv( r ) ∩ ¯ X = ∅ h K , H , D ; G ∧ E ; ¯ X i P − → i h C , K , D ; B ∧ G ∧ E ; ¯ X i σ 1 ≡ i σ ′ 1 σ ′ 1 P − → i σ ′ 2 σ ′ 2 ≡ i σ 2 σ 1 P − → i σ 2 where ρ is a rena ming. If s uch tra nsition is possible with H = ∅ , w e will s a y that the tuple r @ h K ; G ∧ E ; ¯ X i is a pr op agation r e dex for the state σ . The trans itiv e closure of the relation ( P − → i ∪ ≡ i ) is denoted by P − → ∗ i . A ≡ i -derivation is a finite or infinite sequence of the form σ 1 P − → i . . . P − → i σ n P − → i . . . A ≡ i -deriv ation is c onsistent if so are all the states cons tituting it. A ≡ i -transition is c onfl uent if whenever σ P − → ∗ i σ 1 and σ P − → ∗ i σ 2 hold, there e xists a state σ ′ such tha t σ 1 P − → ∗ i σ ′ and σ 2 P − → ∗ i σ ′ hold as well. The abstr act e quivalenc e is the least eq uiv a lence ≡ a defined over Σ verifying: 1. h C ; Y = t ∧ D ; ¯ X i ≡ a h G [ Y \ t ]; Y = t ∧ D ; ¯ X i 2. h C ; false ; ¯ X i ≡ a h D ; false ; ¯ X i 3. h C ; D ; ¯ X i ≡ a h C ; E ; ¯ X i if C  ∃ -fv ( C , ¯ X ) ( D ) ↔ ∃ -fv ( C , ¯ X ) ( E ) 4. h C ; E ; ¯ X i ≡ a h C ; E ; { Y } ∪ ¯ X i where Y / ∈ fv( C , E ). Note that this equiv a le nce is log ic ally so und (Raiser et al. 2009 ). F or a given pr o- gram P , the abstr act tr ansition systems is defined as the tuple (Σ , P − → a ). 2.4 Concr ete op er ational semantics This section presents the op erational sema n tics ω p of de Koninck et al. (2007). In this framework r ules a re a nnotated with ex plic it prior ities that re duce the non- determinism in the c hoice of the rule to apply . As initially prop osed by Abdenna dher (1997), this semantics includes a pa r tial control that prev ents the trivial lo oping of propagation rules b y res tricting their firing only once on same instances. By opp osition to the a bstract semantics, we will call it c oncr ete (op er ational) semantics . An identifie d c onstr aint is a pair noted c # i , asso ciating a CHR constraint c with an integer i . F or an y iden tified constraints, we define the functions chr ( c # i ) = c and id( c # i ) = i , and ex tend them to sequence s a nd sets of identified cons train ts. A token is a tuple ( r , ¯ ı), where r is a rule na me and ¯ ı is a sequence of integers. A c oncr ete CHR state is a tuple of the for m h h C ; D ; E ; T i i ¯ X n where C is a multiset of CHR and built-in constraints, D is a m ultise t o f identified constraints, E is a conjunction of built-in constraints, T is a set of tokens and n is an in teg e r. W e assume mor eo ver that the identifier of each iden tified co nstrain ts in the CHR store is unique and s maller than n . F o r any pro gram P , the c oncr ete tr ansition rela tion, P − → c , is defined a s following: (Co-)Inductive semantics for Constr aint Hand ling Rules 5 Solv e h h c, C ; D ; E ; T i i ¯ X n P − → c h h C ; D ; c ∧ E ; T i i ¯ X n if c is a built-in constraint and C  ∀ (( c ∧ B ) ↔ B ′ ). In tro duce h h c, C ; D ; E ; T i i ¯ X n P − → c h h C ; c # n, D ; E ; T i i ¯ X n + 1 if c is a CHR constraint. Apply h h∅ ; K , H , E ; C ; T i i ¯ X n P − → c h h B , G ; K , D ; C ∧ θ ; t ∪ T i i ¯ X n if ( p :: r @ K ′ \ H ′ ⇔ G | B ) is a rule in P of priority p r enamed with fresh v ari- ables, θ is a substitution such that chr ( K ) = K ′ θ , chr( H ) = H ′ θ , t = ( r , id( K , H )), t / ∈ T , C is sa tis fia ble within C , and C  ∀ ( C → ∃ ( θ ∧ G )). F urthermo r e, no rule of priority big ger than p exists for which the ab o ve co nditions ho ld. 3 T ransition system se man tics for pure CSR and CPR In this se ction, we pro pose a fixp oint semantics for b oth CSR and CPR progr ams. W e call it tr ansition sys tem semantics b ecause it is defined as a fixpo in t ov er the abstract transition system, built in a way similar to µ - c alculus formula (Clar k e et al. 2000 ). The pro ofs of this section are only sketched. Deta ile d versions can b e found in a technical rep ort (Haemmerl´ e 2011 ). Before formally introducing the sema n tics, we recall some standard notation and results ab o ut fixp oin ts in an arbitrary co mplete lattice ( L , ⊃ , ∩ , ∪ , ⊤ , ⊥ ). 1 . A func- tion f : L → L is monotonic if f ( X ) ⊃ f ( Y ) whenev er X ⊃ Y . An element X ∈ L is a fixp oint for f : L → L if f ( X ) = X . The le ast fix p oi nt (resp. the gr e ast est fi x p oint ) of f is its fixp oin t X satisfying Y ⊃ X (r esp. Y ⊂ X ) whenever Y is a fixp oint for f . It is denoted by µ X .f ( X ) (resp. ν X .f ( X )). T arski’s (1995) celebrated fixp oin t theorem ensur es that monoto nic functions have b oth a least and a gr eatest fixp oint . 3.1 Inductive semantics for CS R In this section, w e give a fir st fixp oint s eman tics limited to CSR. It is call inductiv e, since it is defined as a lfp. Definition 3.1 ( Inductive tr ansition system semantics for CSR ) F or a given progra m P and a n given so und equiv alence relation ≡ i , the existential imme diate c ause op er ator hP i i : 2 Σ → 2 Σ is defined a s: hP i i ( X ) = { σ ∈ Σ | there exists σ ′ ∈ Σ such that σ P − → i σ ′ and σ ′ ∈ X } The inductive (t r ansition system) semantics of a CSR pro gram Q is the set: F C ( Q ) = µ X . ( hQi a ( X ) ∪ (Σ b \ J h∅ ; fals e ; ∅i K a )) The exis ten tial immediate ca us e op erator b eing clea rly mo notonic, T arski’s the- orem ensures the inductiv e semantics o f a CSR program is w ell defined. F or a given progra m P , F C ( P ) is exactly the set o f states that can be r ewritten b y P to a consistent answer. Remark that since answers ca nnot b e rewritten b y any pr ogram, any state in F C ( P ) has a t leas t one termina ting deriv a tion. 1 F or more details ab out fixpoin ts, one can refer, for example, to Llo yd’s Book (1987). 6 R´ emy Haemmerl´ e Example 3.2 Consider the pr ogram P 1 consisting o f the tw o following rules: a, a ⇐ ⇒ true b ⇐ ⇒ b c ⇐ ⇒ fals e W e can pick the sets of c o nsisten t states of the resp e ctiv e form h a 2 i ; C ; ¯ X i a nd h a 2 i , b j ; C ; ¯ X i , where d n denotes n copies of a constraint d . Bo th s ets are fixp oints of λ X . ( hP 1 i a ( X ) ∪ (Σ b \ J h∅ ; fals e ; ∅i K a )), but only the former is the least fixp oint. Note, that no s ta te of the form h a 2 i +1 , E ; C ; ¯ X i or h c, E ; C ; ¯ X i are in such fixp o in ts. W e next present a theor e m that us es fixp oin ts sema ntics to r e form ulate results on CSR logica l semantics (F r ¨ uhwirth 19 9 8; Abdennadher et al. 1999). It says that a state that has at least one answer is in the inductiv e semantics of a co nfluen t CSR progra m if and only if its lo g ical r eading is satisfiable within the theory C P . Notice that b ecause in the context of this paper , we do not require C to be gr ound complete, we hav e to c o n tent o ur selv e s with satis fia bilit y instea d of v alidity . Nonetheless, we will see in Section 5 , that s a tisfiabilit y is particularly useful to express coinductive definitions such as bisimulation. The or em 3.3 Let P be prog ram such that P − → a is confluent. Let h D ; E ; ¯ X i b e a sta te having a t least one a nsw er . W e hav e h D ; E ; ¯ X i ∈ F C ( P ) if a nd only if ∃ ( D ∧ E ) is satisfiable within C P . Pr o of sketch As we hav e said pr eviously , F C ( P ) is the set o f states that can b e rewritten to a consistent ans w er. Hence it is s ufficien t to prov e :  E ; C ; ¯ X  P − → ∗ a  ∅ ; D ; ¯ Y  with C P 2 ¬∃ ( D ) if and o nly if C P 2 ¬∃ ( E ∧ C ) or equiv alently , the contrapo sitiv e: C P  ¬∃ ( E ∧ C ) if a nd only if  E ; C ; ¯ X  P − → ∗ a h∅ ; fals e ; ∅i “If ” a nd “only if ” directions are resp ectiv e cor ollaries of soundness and complete- ness for CHR (Lemma 3.20 and Theor em 3.2 5 in F r ¨ uhwirth’s b o ok (200 9 )). Our inductive semantics for CSR has strong connections with the fixp oint sema n- tics of Ga bbrielli and Meo (2009). In contrast to our s , this seman tics focuses on input/output b ehaviour and is not for mally related to logical se ma n tics, a lthough it is constructed in similar wa y as a l.f.p. ov er the abstract tra nsition system. How ever, bec ause it do es not distinguish propaga tion from simplification rules, this seman tics cannot character ize r e asonable progr ams using propagations. Indeed, it has b een later extended to handle propa g ation rules by adding in to the states an explicit token stor e ` a la Ab dennadher (1997) in order to remember the pro pagation histo ry (Gabbrielli et al. 2008). Nonetheless, suc h an extension lea ds to a quite complicated mo del which is mor eo ver incomplete w.r.t. logical semantics. (Co-)Inductive semantics for Constr aint Hand ling Rules 7 3.2 Coindu ctive semantics for C PR W e contin ue b y giving a similar characteriz a tion for CPR. This semantics is defined by the g.f.p. of a univ ersal v er sion of the cause op erator presen ted in Definition 3.1 . Hence we call it coinductive. Definition 3.4 ( Coinductive t r ansition system semantics for CPR ) F or a g iv en progra m P and an given sound equiv alence rela tion ≡ i , the universal (imme diate) c ause op er ator [ P ] i : 2 Σ → 2 Σ is defined as: [ P ] i ( X ) = { σ ∈ Σ | for all σ ′ ∈ Σ , σ P − → i σ ′ implies σ ′ ∈ X } The c oinductive (t r ansition system) semantics of a CPR pr ogram Q is the set: F C co ( Q ) = ν X . ( [ Q ] a ( X ) ∩ (Σ \ J h∅ ; false ; ∅i K a )) Note that contrary to the inductive semantics, the co inductive one is no t just a reformulation of the e x isting semantics. Indeed the universal es s ence of the o perator [ Q ] i conv eys that the meaning we give to CPR states relies on all of its der iv ations, whereas the e x isten tial essence of the o p erator hQi i makes explicit the fact that the classica l meaning states dep enden t on ex istence of a successful deriv ation. This semantic subtlety is fundamental for CPR completeness (Lemma 3.7). As it is the case for hQ i i , the oper ator [ Q ] i is obviously monotonic. O ur semantics is therefore well defined. Notice, that F C co ( Q ) is precisely the set of states tha t ca nnot be rewritten to an inconsistent s tates. As illustra ted by the following example, states b elonging to F C co ( Q ) hav e in g eneral only non-ter minating der iv a tions w.r.t. the abstr act op erational semantics. Example 3.5 Let C be the usual constr ain ts theoryov er integers and P 2 be the program: q ( X ) = ⇒ q ( X + 1) q (0) = ⇒ false The greatest fixpo in t of λ X . ([ P 2 ] a ( X ) ∩ (Σ \ J h∅ ; false ; ∅ i K a )) is the set of consistent states that do es not contain a CHR co nstrain t p ( X ) wher e X is nega tiv e o r null. Note the empty s e t is a lso a fixp oin t but not the grea test. Note that sta tes such as h q (1); true ; ∅ i , which are in the greatest fixp oin t, hav e only infinite der iv ations. W e give next a theorem that s tates the accura cy of the coinductiv e semantics w.r.t. the logica l reading of CPR. Remar k that for the completeness direction, we hav e to ensure that a sufficien t n um ber of c o nstrain ts is pro v ided for launc hing eac h rule of the deriv atio n. T o state the theor em w e assume the following nota tion ( n · B stand for the scalar pr oduct of the multiset B by n ): P n = { ( r @ K = ⇒ G | C , n · B ) | ( r @ K = ⇒ G | C , B ) ∈ P } The or em 3.6 ( Soundness and c ompleteness of c oinductive semantics for CPR ) Let P b e a CPR pr ogram and n b e some integer grea ter than the maximal num b er of constra in ts o ccurring in the head o f any rule of P . W e hav e:  n · E ; C ; ¯ X  ∈ F C co ( P n ) if and only if ( E ∧ C ) is s a tisfiable within C P . 8 R´ emy Haemmerl´ e The pro of o f the theo rem is ba sed on the following completeness lemma, th at ensures that to ea ch in tuitionistic deduction in the theo ry C P corresp o nds a CP R deriv ation w.r.t. the program P . In the following, we use the notation T  E → ∃ X . F and E ⊢ T ∃ X . F to emphasize that a deduction within a theory T is do ne in the cla ssical logic mo del framework and the int uitionistic pro of framework, resp ec- tively . F o r tunately , bo th lines of r easoning coincide in our setting. This remark able prop ert y is due to the fact we are rea soning in a fragment of cla ssical logic, known as c oher ent lo gic , wher e cla ssical prov ability coincides with intuitionistic prov ability . L emma 3.7 ( Int uitionistic c ompleteness of CPR ) Let P b e a C P R pr ogram a nd n b e so me integer gre ater than the maximal num ber of constraints o ccurring in the heads of P . Let E and F (r e s p. C and D ) b e tw o multiset of CHR (r esp. built-in) constra in ts. If E ∧ C ⊢ C P ∃ ¯ X . ( F ∧ D ), then there exist F ′ and D ′ such that h n · E ; C ; fv( F , C ) i P n − − → ∗ a  n · F ′ ; D ′ ; ¯ Y  and F ′ ∧ D ′ ⊢ C ∃ ¯ X . ( F ∧ C ). Pr o of sketch By structural induction on the pro of tree π o f E ∧ C ⊢ C P ∃ ¯ X . ( F ∧ D ). F or the case where π is a logical axiom, we use the reflexivity of P n − − → ∗ a . F or the cas e where π is a no n-logical axiom from C , we use the definition of ≡ a . F or the case where π is a non-logica l axio m corresp onding to a propa gation rule K = ⇒ G | B c , B b , we cho ose F ′ = ( E , B c ) and D ′ = ( C ∧ G ∧ B b ), and apply r . F or the case where π ends with a cut o r a right intro duction of a co njunct ion, w e use induction h yp othesis and the fact that cons tr ain ts a re never consumed along a CPR deriv ation. Other cases ar e more straightforward. Pr o of sketch of The or em 3.6 As we have noted previous ly , F C co ( P n ) is the set of sta tes that ca nnot b e rewr itten to an incons isten t states. Hence it is sufficient to pr o ve:  n · E ; C ; ¯ X  6 P n − − → ∗ a h∅ ; fals e ; ∅i if and o nly if C P 2 ¬∃ ( E ∧ C ) or equiv alently the co n trap ositive: C P  ∀ ( ( E ∧ C ) → false ) if and only if  n · E ; C ; ¯ X  P n − − → ∗ a h∅ ; fals e ; ∅i The “if ” dir ection is direct b y soundness of CHR. F or the “only if ” dire ction, since C P is a c oher ent lo gic the ory (i.e. a set o f formulas of the form ∀  F → ∃ ¯ X . F ′  , wher e bo th F and F ′ are co njunctions of ato mic prop ositions), it ca n b e assumed without loss of g eneralit y that E ∧ C ⊢ C P false (See B ezem and Co q uand’s w o rk ab o ut coherent logic (2005)). The r esult is then direct, by Lemma 3.7. The co inductive semantics for CP R, has strong similarities with the fixp oint s e - mantics of CLP (Jaffar and Lassez 1987 ). Both are defined by fixp oin t of somehow dual op erators and fully abstract the lo g ical mea ning of pro grams. Nonetheles s the coinductiv e seman tics of CPR is not comp ositional. That is not a particular drawbac k of our s eman tics, since the logica l semantics we characterize is neither comp ositional. Indeed, if the lo gical rea dings of tw o states are indep enden tly con- sistent, then one cannot ensure th at so is their conjunction. It should b e noticed (Co-)Inductive semantics for Constr aint Hand ling Rules 9 that this non- compositiona lit y pre vents the immediate caus e op erators to b e de- fined over the C -ba se (i.e. the cr oss pro duct of the set of CHR constra in ts and the set of conjunctions of built-in cons train ts) as it is done for CLP , and requir es a definition over set of states. 4 T ransition system semantics for CHR wi th p ersistent constrain ts In this section, we a im at obtaining a fixpo in t seman tics fo r the whole la nguage. Nonetheless, one has to notice that the completeness result for CSR needs, among other things, the termination of P − → a , while the equiv alent result for CPR is based on the mono tonic evolution of the co nstrain ts store along deriv ations. Hence com- bining naively CSR a nd CP R will break b oth pro perties, lea ding consequently to an incomplete mo del. In order to pr o vide an a ccurate fixp oin t semantics to pro grams combining b oth kinds of r ules (meanwhile re mo ving unsatisfactory scalar pro duct in the wording of CPR c o mpleteness), w e in tro duce a notion of p ersistent c onstr aints , following ideas of Betz et a l. (2010) for their semantics ω ! . Persistent co nstrain ts are sp ecial CHR constraint s acting as classical logic statements (i.e. they a re not consumable and their multiplicit y do es not matter). Since they act as linea r log ic statements (i.e. they ar e consumable and t heir m ultiplicity matters ), usual CHR constraints are called line ar . Bec ause it combines p ersisten t and linear constr a in ts in a slightly less tra nsparen t w ay tha t ω ! , we call this sema n tics hybrid , and note it ω h . Due to the space limitations, the (non-tr iv ial) pro ofs of the section are omitted, but can b e found in the extended version of this pap er. 4.1 Hybrid op er ational se mantics ω h On the contrary of ω ! , the kind of a constraint (linear o r pe rsisten t) in ω h , is not dynamically deter mined according the type of rules fro m which it w as produced, but statically fixed. Hence, w e will as sume the set of CHR co nstrain ts symbols is divided in tw o : the line ar sym b ols and the p ersistent sy m b ols. Naturally , CHR constraints built from the linear (res p. p ersistent) symbols ar e called linear (r esp. per sisten t) constr ain ts. A hybrid ru le is a CHR rule where the kept hea d co n tains only p ersistent co ns train ts and the remov ed head contains only linear cons train ts. W e will deno te b y Σ p , the set o f pur ely p ersistent s ta tes ( i.e. states of the form h P ; C ; ¯ X i wher e P is a set of p ersistent constr ain ts). P s will refer to the set o f simplification rules of a h ybrid prog ram P , res pectively . The h y br id semantics is expressed as a particular instance of the equiv a lence based s eman tics presented in Section 2 .3. It uses the abstract state equiv alence extended by a c ontr action rule enfor cing the imp otency of p ersistent constraints. Definition 4.1 ( Hybrid op er ational tr ansition ) The hybrid e quivalenc e is the smallest r elation, ≡ h , ov er states containing ≡ a sat- isfying the following rule: h c, c, C ; D ; ¯ X i ≡ h h c, C ; D ; ¯ X i if c is a p ersistent constraints The hybrid t ra nsition system is defined a s the tuple (Σ , P − → h ). 10 R´ emy Haemmerl´ e The h y br id pr ograms are pro grams where pro pagation rules “commute” with simplification rules in the sense of abstract rewriting systems (T erese 2003). In other w ords, deriv ations can b e permuted so that simplification rules a re fired first, and propagatio n rules fire only when simplification rule firings are exhausted. In- deed, the syn tactica l restr ic tion preven ts the pro pagation head constraints to b e consumed by simplification rules, hence o nce a propa gation rule is applicable, then it will b e so for ever. Of course, num b er of CHR pro grams do no t resp ect the h ybr id syntax a nd therefore cannot b e run in our framework. Nonetheless, what we lo ose with this restriction, we comp ensate by pionee r ing a logically complete a pproach to solve the problem of trivial no n-termination (see next Theorem 4.8 ). 4.2 Hybrid tr ansition s ystem semantics W e present the transition system semantics for hybrid progra ms. This semantics is express e d by fixpo in ts over the hybrid transitio n sy stem. It is built using the immediate cause o perator s we have defined in the pr evious section. Definition 4.2 ( Hybrid tr ansition system semantics ) The hybrid (t r ansition system) semantics of a hybrid progr a m P is defined as: F C h ( P ) = ν X . ([ P ] h ( X ) ∩ µ Y . ( hP s i h ( Y ) ∪ (Σ p \ J h∅ ; false ; ∅i K h ))) The theorem we give nex t states soundness and co mpleteness of the hybrid tran- sition s ystem semantics o f c o nfluen t progra ms, provided the states r espect a data- sufficiency pro perty . In this pap er, we do no t address the problem of proving conflu- ence of h ybrid programs, but claim it ca n be tackled by extending straightforwardly the work of Abdenna dher et al. (1999) or b y adequately ins tanstiating the notion of abstract critical pair we prop osed in a previous work (Haemmerl ´ e and F ages 2007). Definition 4.3 ( Data-sufficient s tate ) A hybrid s ta te σ is data-sufficient w.r.t. a hybrid pr ogram P if any state σ ′ accessible form σ can b e simplified (i.e. rewr itten b y P s ) into a purely per sisten t sate (i.e. for any state σ ′ ∈ Σ, if σ P − → ∗ h σ ′ , then there exists a sa te σ ′′ ∈ Σ p s.t. σ ′ P s − − → ∗ h σ ′′ ). This pr operty ensures there is at lea st one computation where propaga tion rules are applied only once all linear constraints hav e b een completely simplified. It is a natural extension of the eponymous pro p erty for CSR (Abdenna dher et a l. 19 99). The or em 4.4 ( Soundness and c ompleteness of hybrid tr ansition system semantics ) Let P b e a hybrid prog r am such that P s is confluent . Let h L , P ; E ; ¯ X i b e a data- sufficient state w.r.t. P . W e have: h L , P ; E ; ¯ X i ∈ F C h ( P ) if a nd only if ( L ∧ P ∧ E ) is satis fia ble within C P The following prop osition states that it is s ufficien t to consider only one fa ir deriv ation. This result is fundamen tal to allow the h ybrid semantics to be e fficien tly implemen ted. (Co-)Inductive semantics for Constr aint Hand ling Rules 11 Definition 4.5 ( Pr op agation fair derivation ) A de r iv ation σ 0 P − → h σ 1 P − → h . . . is pr op agatio n fair if for an y propagation redex r @ h K ; E ; ¯ X i of a state σ i in the deriv ation, there exist tw o states σ j , σ j +1 such that the transitio n from σ j to σ j +1 is a propa gation application where the reduced redex is iden tical or stro ng er to r @ h K ; E ; ¯ X i (i.e. the reduced redex is of the fo r m r @ h K ; F ; ¯ Y i with C  ∃ - ¯ Y F → ∃ - ¯ X E ). Pr op osition 4.6 ( Soun dness and c ompleteness of pr op agation fair derivations ) Let P b e a hybrid pr ogram such that P s is confluent and terminating. Let σ b e a data-sufficient state. σ ∈ F C h ( P ) holds if and only if there is a consistent pr opagation fair deriv atio n star ting from σ . 4.3 Implementation of the hybri d semantics W e co ntin ue by addre s sing the question o f implementing the hybrid semantics in a s ound and co mplete wa y . F or this purp ose, we assume without loss of gene r alit y that the constraint symbols f / 1, f / 2 , a/ 2, c f / 1, and c a / 1 are fresh w.r.t. the progra m P we consider. The implementation of a hybrid pr ogram P co nsists in a source-to - source transla tion P ⋄ int ended to be exe c uted in the concr ete semantics ω p . This transfor mation is g iv en in de ta il in Fig ure 1. In order to b e executed an hybrid state σ ha s to be transla ted in to a concrete state σ ⋄ as fo llo ws: if L and ( c 1 , . . . , c n ) ar e m ultisets o f linear and p ersisten t cons tr ain ts resp ectiv e ly , then h L , d 1 , . . . d n ; D ; V i ⋄ = h h L , f ( d 1 ) , . . . , f ( d n ) , c f (0) , c a (0); ∅ ; D ; ∅ i i V 0 Before going further, let us give some in tuition ab out the behaviour of the trans- lation. If a r ule needs tw o o ccurrences of the same p ersistent constraint, step 1 will insert an eq uiv a len t rule which needs only o ne o ccurrence of the co ns train t. In the translation e ac h persistent co nstrain t can be applied in three differen t successive states: fr esh , indicated by f / 1 , fr ozen , indicated by f / 2, a nd alive , indicated by a/ 2. Step 2 e nsures, on the one hand, that o nly alive constra in ts can b e used to la unc h a rule, and on the other hand, that the p ersistent constraint s of the right-hand side are inserted as fresh. Each frozen a nd a liv e constraint is assoc iated to a time stamp indicating the order in which it has b een as serted. The fresh constr ain ts ar e time stamp ed and marked as frozen as soon as possible b y stamp , the rule of highest priority (the c o nstrain t c f / 1 indicating the next av ailable time sta mp). O nly if no other rule can b e applied, the u nfr e eze rule turns the oldest fro zen constr ain t into an alive constr ain t while preser v ing its time sta mp (the co nstrain t c a / 1 indicating the next constra in t to be unfrozen). Rule set preven ts trivia l lo ops, by removing the youngest o ccurrence o f t wo iden tica l p ersistent constraints. F rom a pro of po in t of view, the application of this la s t rule corr esponds to the detection o f a cycle in a coinduction pro of, the p ersistent constra in ts repre sen ting coinduction hypothes ises (Barwise and Mo s s 19 96). The tw o following theorems state that our implementation is sound a nd complete w.r.t. failure. Theorem 4.7 shows furthermore that the implement ation we prop ose here is sound w.r.t. finite success. It is worth noting that it is hop eless to lo ok for 12 R´ emy Haemmerl´ e Let P ⋄ the program P where simplification and propagation rules are given wi th the priorities 3 and 4 resp ectiv ely . App ly the follo wing steps: step 1 . A pply the follow ing rules until con vergence : If ( p :: c, d, K \ H ⇐ ⇒ G | B , L , P )) is in P ⋄ , with C  ∃ ( c = d ) then add the ru le ( p :: c, K \ H ⇐ ⇒ c = d ∧ G | B , L , P ) to P ⋄ step 2 Substitut e an y rule ( p :: c 1 , . . . , c m \ H ⇐ ⇒ G | B , L , d 1 , . . . d n ) by ( p :: a ( X 1 , c 1 ) , . . . , a ( X m , c m ) \ H ⇐ ⇒ G | B l , L , f ( d 1 ) , . . . , f ( d n )) where x 1 , . . . x m are pairwise distinct v ariables step 3 Add to P ⋄ the rules: 1 :: stamp @ f ( X ) , c f ( Y ) ⇐ ⇒ f ( Y , X ) , c f ( Y + 1) 2 :: set @ a ( Y , X ) \ a ( Z, X ) ⇐ ⇒ Y < Z | ⊤ 5 :: unfr e eze @ f ( Y , X ) , c a ( Y ) ⇐ ⇒ a ( Y , X ) , c a ( Y + 1) Fig. 1. Source- t o-source translation for hybrid programs a complete implementation w.r.t. to success , s inc e the problem to know if a data- sufficient state is in the coinductive semantics is undecida ble. The in tuition b ehind this claim is that o therwise it would p ossible to solve the halting problem. The or em 4.7 ( Soundness w.r.t. suc c ess and failur e ) Let P b e a hybrid pr ogram such that P s is confluent , and let  C ; E ; ¯ X  ⋄ → ∗ P ⋄ h h∅ ; D ; F ; T i i ¯ Y i 6→ P ⋄ be a terminating deriv ation.  C ; E ; ¯ X  ∈ F C h ( P ) ho lds if and only if F is s atisfiable within C . The or em 4.8 ( Completeness w.r.t. failur e ) Let P b e a hybrid pr ogram such that P s is confluent and terminating. Let  C ; E ; ¯ X  be a da ta-sufficien t state. If  C ; D ; ¯ X  / ∈ F C h ( P ), then any concrete der iv a tion start- ing form  C ; D ; ¯ X  ⋄ finitely fails. The implementation we prop ose has str ong connections with the co -SLD, an implemen tation of the g .f.p. semantics of Logic Pro gramming pro posed b y Simo n et al. (2006). Both are ba sed on a dynamic synthesis of coinductive hypothesis es and a cycle detection in pr o ofs. But b ecause it is limited to rational recursio n, the co- SLD is log ic ally incomplete w .r .t. b oth succe s ses and failures (i.e. there are queries true a nd false w.r.t. the logic a l re ading of a progra m that cause the interpreter to lo op). That cont rasts with CHR, where an y coherent constraint system can b e used without lo osing logica l completeness w.r .t. failures. 5 Applications In this section, we illustr a te the p o wer of CHR fo r co inductiv e reas oning when it is provided with its fixp oin t semantics. In par ticular we show it yields an elegant framework to r ealize coinductive equality pro ofs for la nguages a nd reg ular expres- sions as pre s en ted by Rutten (1 9 98). 5.1 Coindu ctive language e qu ality pr o of Firstly , let us in tro duce the classica l no tion o f bina ry a uto maton in a s lig h tly dif- ferent wa y from usual. A binary automaton is a pair ( L , f ) wher e L is a p ossibly (Co-)Inductive semantics for Constr aint Hand ling Rules 13 L 1 L 2 a L 3 a K 1 K 2 b a a b b b a b D = ( f ( L 1 , (0 , L 2 , L 3 )) , f ( L 2 , (1 , L 2 , L 3 )) , f ( L 3 , (1 , L 3 , L 2 )) , f ( K 1 , (0 , K 2 , K 2 )) , f ( K 2 , (1 , K 2 , K 2 ))) Fig. 2. A binary automaton and its CPR representation. infinite set of states and f : L → { 0 , 1 } × L × L is a function called destructor . Let us assume so me automato n ( L , f ). F or any s tate L ∈ L suc h that f ( L ) = ( T , L a , L b ), we write L a − → L a , and L b − → L b , and t ( L ) = T . L ( L ) = { a 1 . . . a n | L a 1 − → L 1 a 2 − → . . . a n − − → L n ∧ t ( L n ) = 1 } is the la nguage accepted by a state L . A bisimulation betw een states is a r elation R ⊂ L × L verifying: If K R L then        t ( K ) = t ( L ) , K a − → K a , L a − → L a , K a R L a , and K b − → K b , L b − → L b , K b R L b , Contrary to the sta ndard definition, in the presen t setting, an automa ton do es not hav e an initial state a nd ma y hav e a n infinite num b er of states. As repr e sen ted here, an automaton is a particula r coalgebr a (Barwise and Moss 199 6). Due to the space limitatio ns, we will not enter in details in the topic of co a lgebra 2 , but only state the following Coinductive Pr o of Principle (Rutten 19 98; Barwise and Mos s 1996) which g iv es rise to the represe ntation of automata as coalg ebra: In o rder to prove the equality of the la nguages recognize d by tw o states K and L , it is sufficien t to establish the existence o f a bisimulation relatio n in L that includes the pair ( K , L ). A nice application of CPR consists in the po ssibilit y to directly repre sen t coalge- bra a nd prove bisimulation betw een s tates. F o r instance, o ne can easily repre sen t a finite automaton using v aria bles f or states and binary user-defined constraints (of main symbol f / 2) for the destructor function. Figure 2 gives an ex a mple of a n automaton and its represent ation a s a multiset D of CHR co nstrain ts . Once the automaton representation is fixed, o ne ca n translate the definition o f bisimulation int o a sing le pro pagation r ule: f ( L , ( L t , L a , L b )) , f ( K, ( K t , K a , K b )) , L ∼ K = ⇒ L t = K t , L a ∼ K a , L b ∼ K b Using coinductive pro of principle and Theo rem 3.6, it is s imple to prove t wo states of the coa lgebra repre sen ted b y D accept or not the same language. F or example, to conclude that L 1 and K 1 recognize the same langua ge while L 1 and K 2 do not, one can pro ve the execution of h 3 · ( D , L 1 ∼ K 1 ); ⊤ ; ∅i nev e r reaches inconsistent s ta tes, while there are inconsistent deriv ations star ting fro m h 3 · ( D , L 1 ∼ K 2 ); ⊤ ; ∅i . 2 W e inv ite unfamiliar readers to refer to the gen tle introduction of Rutten (19 98). 14 R´ emy Haemmerl´ e 5.2 Coindu ctive solver for r e gular expr essions W e ha ve just shown that CPR yields a nice fra mew or k for coinductiv e reasoning ab out coalgebra . Nonetheless the ex plicit representation of a n automaton by user defined cons train ts (as in Figure 2) would limit ourselves to finite state automata. One simple idea to circumven t this limitation is to implictly represent infinite states automata. F or instance, o ne ca n represent states using regular expressio ns a nd implemen t the computation of the destr uctor function using deriv atives (R utten 1998). Let us a ssume the following sy ntax for r egular expressions: E ::= L | a | b | E , E | E ∗ L ::= [] | [ E | L ] where a and b are ch aracters , ( ∗ ) and ( , ) stand for the Kleene star a nd the con- catenation operato rs resp ectiv ely , and a list corresp onds to the alternation of its elements. Here fo llows a pos sible implementation of the destr uctor function 3 : f ([] , R ) ⇐ ⇒ R = (0 , [] , []) . f ( a, R ) ⇐ ⇒ R = (0 , [[] ∗ ] , []) . f ( b , R ) ⇐ ⇒ R = (0 , [] , [[] ∗ ]) . f ([ E | L ] , R ) ⇐ ⇒ R = ( T , A, B ) , f ( E , ( E t , E a , E b )) , f ( L, ( L t , L a , L b )) , or ( E t , L t , T ) , merg e ( E a , L a , A ) , merg e ( E b , L b , B ) . f ( E ∗ , R ) ⇐ ⇒ R = (1 , [( E a , [ E ∗ ])] , [( E b , [ E ∗ ])]) , f ( E , ( , E a , E b )) . f (( E , F ) , R ) ⇐ ⇒ f ( E , ( E t , E a , E b )) , f conc ( E t , E a , E b , F , R ) . f conc (0 , E a , E b , F , R ) ⇐ ⇒ R = (0 , [( E a , F )] , [( E b , F )]) . f conc (1 , E a , E b , F , R ) ⇐ ⇒ R = ( T , A, B ) , f ( F, F a , F b )) , merg e ([( E a , F )] , F a , A ) , merg e ([( E b , F )] , F b , B ) . where or/ 3 unifies its third arg ument with the Bo olean disjunction of its tw o first elements and me rg e/ 3 unifies its last arg umen t with the ordered union o f the lists given as fir st ar gumen ts. Now o ne ca n adapt the e ncoding o f bisimulation given in the prev io us subsection a s follows: L ∼ K = ⇒ nonv ar ( L ) , nonvar ( K ) | f ( L, ( T , L a , L b ) ) , f ( K, ( T , K a , K b ) ) , L a ∼ K a , L b ∼ K b . W e ar e now able to prove equality of regula r expression using the implementation of CHR hybrid semantics provided in Section 4.3 . F or exa mple, the following state leads to an irreducible consistent state. This implies thanks to the Co inductiv e Pro of Pr inciple together with Theor em 4.4 a nd Theo rem 4.7 that the t w o regular expressions recog nize the s ame la ng uage/ h (( b ∗ , a ) ∗ , ( a, b ∗ )) ∗ ∼ [[] ∗ , ( a, [ a, b ] ∗ ) , ([ a, b ] ∗ , ( a, ( a, [ a, b ] ∗ )))]; ⊤ ; ∅i ⋄ It should b e underline d that the us e of simplification rules instead of propagation rules for enco ding the des tructor function is essential here in order to av oid rapid saturation of the memory by useless constraints. Notice that on the one hand, the confluence of the set o f s implifica tion rules needed by the theorems of Section 4 can 3 A complete v ers i on of program can be found in tec hnical rep ort version of the paper. (Co-)Inductive semantics for Constr aint Hand ling Rules 15 be easily inferred, since the pro gram is deterministic. On the other ha nd, termina- tion of the the set o f simplification rules, w hich is requir ed by Theo r em 4.8 ca n b e easily established by using, for instance, techniques we have recently pro posed for single-headed prog rams (Haemmerl´ e et al. 2 011). Of cours e, no one sho uld b e surpr ised that e q uiv a lence of regular express ions is decidable. The in teresting po in t here is that the notion of co algebra a nd bisimula- tion c a n b e ca sted natur a lly in CHR. Moreover, it is worth noticing the prog ram given has the prop erties required b y a constra in t so lver. Firstly the pro gram is ef- fective, i.e. it can a ctually pr o ve o r disprove if that tw o expr essions a re equal. The first pa rt of the cla im ca n be pr o ved using Kleene theo rem (Rutten 1998 ) and the idempo tency and co mm utativity of the alternation, enfor ced he r e b y the mer ge/3 predicate. The second part is direct by the completeness w.r.t. failures. Secondly , the pr o gram is incremental: it can deal with par tia lly instanciated expressions by freezing some computations pro vided without enoug h informatio n. Last, but not least, one can eas ily add to the sys tem new expressio ns (as for instance ǫ , E ?, or E + ). F or this purp ose it is just necess a ry to provide a new simplification rule for computing the result of the corresp onding destructor function. F or e x ample, we can add to the progr am the following rule a nd prov e as pr eviously that a + and ( a, a ∗ ) recognize the same lang ua ge while a + and a ∗ do not: f ( K + , R ) ⇐ ⇒ R = ( T , [ K a , ( K a , K + )] , [ K b , ( K b , K + )]) , f ( K, ( T , K a , K b )) . 6 Conclusion W e have defined a l.f.p. se ma n tics for CHR simplification rules and a g .f.p. seman- tics for CHR propag ations rules , and prov ed bo th to b e acc ur ate w.r .t. the logica l reading of the rules. By using a hybrid op erational s eman tics with p ersistent con- straints similar to the one of Betz et a l., we were able to c har acterize CHR pro grams combining b oth simplificatio n and pro pagation r ules by a fixpo in t semantics with- out losing completeness w.r.t. to logical semantics. In doing so, we have improv ed noticeably re s ults ab out logical s eman tics o f CHR. Subseq uen tly w e propose d an implemen tation of this h ybrid semantics and showed it yields an elegant fr amew o r k for prog ramming with co inductiv e r easoning. The observ atio n that non-termina tion of all deriv ations star ting from a given state ensures this latter to be in the coinductiv e semantics o f an hybrid progr am, suggests that the statics analysis o f universal non-termina tion of a CHR prog ram might b e worth in vestigating. The co mparison of CHR to other coinductiv e pro gramming frameworks suc h that the cir cular coinductiv e rewr iting of Goguen et a l. (2000) may suggest it should b e p ossible to improv e completenes s with res pect to succe ss of the implementation pro posed here. A cknow le dgements The research leading to these results ha s r eceiv ed funding fr om the Madr id Reg io nal Gov ernment under the CM pro ject P 2009/TIC/1 465 (PROMETIDOS), the Span- ish Ministry of Science under the MEC pro ject TIN-2008- 0 5624 DOVES , and the 16 R´ emy Haemmerl´ e Europ ean Sev enth F ramework Pr ogramme FP/ 2007-201 3 under gra n t agreement 21548 3 (S-CUBE). W e are grateful to C´ esar S´ anchez, for in teresting discussions ab out coinduction, and to Santiago Zanella B´ eguelin, for re fer ring us to Bezem and C o quand’s work. A t the end, w e would like to tha nk reviewers for their helpful and constructive comments. References Abdennadhe r, S. 1997. Op erational semantics and confluence of Constrain t Propagation Rules. In CP . LNCS, vol. 1330. Springer, 252–266. Abdennadhe r, S. , Fr ¨ uhwir th, T. , a n d Meuss, H. 1999. Confluence and semantics of Constrain t Simplification R u les. Constr aints 4, 2, 133–16 5. Bar wise , J. and Moss, L. 1996. Vicious cir cles . CSLI Pub lica tions. Betz, H. , Raiser, F. , and Fr ¨ uhwir th, T. 2010. A complete and terminating execution mod el for Constrain t Handling R ules. TPLP 10, Sp ecia l Issue 4-6 (ICLP), 597–610. Bezem, M . and Coquand, T. 2005. Au t oma ting coherent logic. In LP AR . LNCS, vol. 3835. Springer, 246–260. Clarke, E. M. , G r umberg, O. , and Peled, D. A. 2000. Mo del Che cking . MIT Press. de Koninck, L. , Schrijvers, T. , and Demoen, B . 2007. User-definable rule priorities for CHR . In PPDP . ACM, 25–36. Fr ¨ uhwir th, T. 1998. Theory and practice of Constraint Handling Rules. J. L o g. Pr o- gr am. 37, 1-3, 95–138. Fr ¨ uhwir th, T. 2009. Constr aint Hand ling Rules . Cambridge U niv ersity Press. Gabbrielli, M. and Meo, M. 2009. A comp ositio nal semantic s for Co nstrain t Handling Rules. A CM T r ans. Comput. L o g. 10, 2. Gabbrielli, M. , Meo, M. , and T ac chella, P. 2008. A comp ositio nal seman tics for CHR with propagation rules. In Constr aint Hand ling Rules: Curr ent Re se ar ch T opics . LNAI, vol. 5388. Springer, 119–160. Goguen, J. A. , Lin, K. , and Rosu, G. 2000. Circular coinductive rewriting. In Auto- mate d Softwar e Engine ering . 123–132. Haemmerl ´ e, R. 2011. T ow ard a logically complete fixp oin t s eman tics for Constraint Hangling Rules. T ec h. R ep. CLIP3/20 11, T ec h nical Universit y of Madrid. Haemmerl ´ e, R. and F a ges, F. 2007. Abstract critical pairs and conflu ence of arbitrary binary relations. I n R T A . Number 4533 in LNCS. Springer, 214–228. Haemmerl ´ e, R . , Lopez-Ga r cia, P. , and He menegildo, M. V. 2011. CLP pro jection for Constraint Hand li ng R ules. In T o app e ar i n PPDP . ACM. Jaff ar, J. and Lassez, J.-L . 1987. Constrain t Logic Programming. In POPL . ACM, 111–119 . Llo yd , J. 1987. F oundat ions of L o gic Pr o gr am m ing . S pringer. Raiser, F. , Betz, H. , and Fr ¨ uhwir th, T . 2009. Equiv alence of CHR states rev isi ted. In CHR . Rep ort CW 555. Kath. Univ. Leuven, 34–48 . Rutten, J. 1998. Automata and coinduction (an exercise in coalgebra). In CONC U R . LNCS, vol. 1466. Springer, 194–218. Sarasw a t, V. A. , Rinard , M. C. , and P anangaden, P. 1991. Seman tic foundations of concu rren t constrain t programming. In POPL . ACM. Simon, L. , M a ll y a, A. , B ansal, A. , and Gu pt a , G. 2006. Coi nductive logic program- ming. In ICLP . LNCS, vol. 4079. 330–345 . (Co-)Inductive semantics for Constr aint Hand ling Rules 17 T arski, A. 1995 . A lattice-theoritical fixp oint theorem and its applications. Pacific Journal of Mathematics 5, 2, 285–309. Terese . 2003. T erm R ewriting Systems . V ol. 55. Cam brid ge Universit y Press.

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment