Constraint Grammars Thierry Martinez Acknowledgments to Rémy Haemmerlé for the original impulse to this work. Contraintes Project–Team, INRIA Paris–Rocquencourt, France 21 July 2008 Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 1 / 22
Outline Introduction. 1 Context-Free Constraint Grammars. Definition & Applications. 2 Domain-Sensitive Constraint Grammars. Definitions & Applications. 3 Conclusions & Perspectives. 4 Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 2 / 22
Constraint Sets. Observational confluence nil(L) \ positive_list(L) ⇐⇒ true. list(L, H, T) \ positive_list(L) ⇐⇒ H > 0, positive_list(T). Confluent for queries modelling a list (first arguments of list tokens are pair-wise distincts). Non-confluent for queries modelling a tree (with two list tokens sharing a common first argument). Characterizing (L)CC Stores Describing Global Constraints Given a set of constraints S : either there exists a satisfied constraint in S : REGULAR ( x 1 ,..., x n , L ) with S = { x 1 = u 1 ∧···∧ x n = u n } u ∈ L or all the constraints of S are satisfied: � � ALL - DIFFERENT ( x 1 ,..., x n ) with S = x i � x j i � j Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 3 / 22
Linear Constraint Systems. Let V be a set of variables. If C is a set of formulae over the set of variables V , let C [ C ] be the closure of C by conjunction ( ⊗ ) and variable hiding ( ∃ ). If � is a binary relation over C , let � � be the closure of � by the rules of linear logic. Definition A (linear) constraint system is a pair ( C , ⊢ ) where: C is a set of formulae closed by conjunction ( ⊗ ) and variable hiding ( ∃ ); ⊢ ⊆ C 2 is a relation closed by the rules of linear logic. Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 4 / 22
Examples of Constraint Systems � � . Let Σ be a signature. Let t ( Σ ) = f ( v 1 ,..., v n ) | f / n ∈ Σ . linear-token system The linear-token system over Σ is the constraint system . TOK ( Σ ) = ( C [ t ( Σ )], � � ). linear-token system with equality The linear-token system with equality over Σ is the � � . constraint system TOK = ( Σ ) = ( C [ t ( Σ ) ∪ !( x = y | x , y ∈ V ) ], � � ), where � is the smallest relation with the axioms of the equality theory: � !( x = x ); !( x = y ) � !( y = x ); !( x = y ) ⊗ !( y = z ) � !( x = z ); f ( x 0 ,..., x n ) ⊗ !( x 0 = y 0 ) ⊗···⊗ !( x n = y n ) � f ( y 0 ,..., y n ) Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 5 / 22
Context-Free Constraint Grammars (CFCG). Definition A context-free constraint grammar (CFCG) is a tuple ( V , C , ⊢ , Σ , P ) where: V is a set of variables and ( C , ⊢ ) is a constraint-system over V ; Σ is the signature of non-terminal symbols: � � . N f ( y 1 ,..., y n ) | f / n ∈ Σ and y 1 ,..., y n ∈ V pair-wise distincts = . = C [ C ∪ N ]. P ⊆ N × C is the set of productions, with C � � Every production ( f ( y 1 ,..., y n ), u ) ∈ P is such that fv( u ) ⊆ y 1 ,..., y n . A production is denoted: f ( y 1 ,..., y n ) � u . Example: h ( X , Y ) � edge( X , Y ) h ( X , Y ) � ∃ Z .edge( X , Z ) ⊗ h ( Z , Y ) Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 6 / 22
Derivations for CFCGs. . Let ( V , C , ⊢ , Σ , P ) be a context-free constraint grammar. Let C = C [ C ∪ N ]. Definition 2 be the smallest relation satisfying the following rules: Let → ⊆ C f ( y 1 ,..., y n ) � u u → v u → v u → v ( f ( y 1 ,..., y n )) σ → ( u ) σ ∃ x . u → ∃ xv u ⊗ w → v ⊗ w w ⊗ u → w ⊗ v A derivation is a sequence ( c i ) i with elements in C such that c 0 → c 1 → .... Example: h ( X , Y ) � edge( X , Y ) h ( X , Y ) � ∃ Z .edge( X , Z ) ⊗ h ( Z , Y ) h ( A , B ) → ∃ X 1 .edge( A , X 1 ) ⊗ h ( X 1 , B ) → ∃ X 1 X 2 .edge( A , X 1 ) ⊗ edge( X 1 , X 2 ) ⊗ h ( X 2 , B ) → ∃ X 1 X 2 .edge( A , X 1 ) ⊗ edge( X 1 , X 2 ) ⊗ edge( X 2 , B ) Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 7 / 22
Languages accepted by CFCGs. . . = C [ C ∪ N ]. Let G = ( V , C , ⊢ , Σ , P ) be a context-free constraint grammar. Let C Definition The constraint language accepted by a schema c 0 ∈ C and the grammar G is: L G ( c 0 ) = { c ∈ C | ( ∃ n )( ∃ ( c i ) 0 ≤ i ≤ n )( c 0 → ··· → c n ∧ c n ⊣⊢ c )} Example: h ( X , Y ) � edge( X , Y ) h ( X , Y ) � ∃ Z .edge( X , Z ) ⊗ h ( Z , Y ) � � L G ( h ( A , B )) = hamiltonian paths from A to B Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 8 / 22
Link with Hyperedge Replacement Graph Grammars. Claim Over linear token systems, context-free constraint grammars have the same expressive power than hyperedge replacement graph grammars. H. Ehrig, M. Nagl, and G. Rozenberg, editors. Graph Grammars and Their Application to Computer Science , Lect. Notes Comp. Sci. 153. Springer, 1983. Theorem (K.-J. Lange and E. Welzl 87) Hyperedge replacement graph language membership problem is NP-complete. Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 9 / 22
Hypergraphs. E is a tuple ( E , E Σ , E λ ), with E Σ alphabet and E λ : E → E Σ . A labelled set ˙ Definition A hypergraph is a tuple ( V , ˙ E , S , → ), where: V is the set of vertices; ˙ E is the labelled set of hyperedges; S is the alphabet of selectors; s → ⊆ E × S × V is the incidence relation. ( e , s , v ) ∈ → is denoted e → v . s s → is functional: ( ∀ e s v 1 v 2 ) e → v 1 ∧ e → v 2 ⇒ v 1 = v 2 Vertices are represented as fat dots, hyperedges as boxes. Let H ( V , E , S ) the set of hypergraphs over V , E , S . 1 2 b 1 2 0 2 a 3 Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 10 / 22
Embedding of Hypergraphs into Constraints. Let H = ( V , ˙ E , S , → ) be a hypergraph. � � . s For all e ∈ E , let dom( e ) = s ∈ S | ( ∃ v ∈ V )( e → v ) . . Let n ( e ) =| dom( e ) | and r e : {1,..., n ( e ) � → dom( e )}. � � . f / n ∈ E Σ × N | ( ∃ e ∈ E )( f = E λ ( e ) and n = n ( e )) Let Σ = . Definition The constraint-embedding of the hypergraph h is the following constraint of TOK ( Σ ): � � � . [ E λ ( e )]( y 1 ,..., y n ) � h � = ( ∃ v 1 ... v n ) e ∈ E ∧ n = n ( e ) ∧ y i = r e ( i ) Proposition For every closed constraint c ∈ TOK ( Σ ) , there exists a hypergraph h such that � h � ⊣⊢ c Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 11 / 22
Hypergraph Isomorphism. Definition . . = ( V ,( E , E Σ , E λ = ( V ,( E , E Σ , E λ Two hypergraphs h 0 0 ), S , → 0 ) and h 1 1 ), S , → 1 ) are isomorphic , denoted h 0 ≃ h 1 , when there exist σ V : V � → V and σ E : E � → E such that: ( ∀ e ∈ E )( E λ 0 ( e ) = E λ 1 ( σ E ( e ))); s s ( ∀ e ∈ E )( ∀ s ∈ S )( ∀ v ∈ V )( e → 0 v ⇐⇒ ( σ E ( e ) → 1 σ V ( v )). Proposition h 0 ≃ h 1 ⇐⇒ � h 0 � ⊣⊢ � h 1 � Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 12 / 22
Hyperedge Replacement Graph Grammars (HRGs). Let N , V , E , E Σ , S be defined accordingly to the following definition. We denote H + ( N , V , E , E Σ , S ) the set of augmented hypergraphs , that is E Σ and vertices are in � hypergraphs whose edges are labelled with � V . Definition A h-edge replacement graph grammar is a tuple ( N , V , E , E Σ , S , P ), with: E Σ . N is the alphabet of non-terminals, such that E Σ ∩ N = � ; � = E Σ ⊎ N ; V is the set of vertices; E is the set of hyperedges and E Σ the set of ground labels; . S is the alphabet of selectors, such that V ∩ S = � ; � V = V ⊎ S ; P ⊆ N × P ( S ) × H + ( N , V , E , E Σ , S ) is the set of productions. 0 1 e 0 0 0 0 0 0 ; e H � H � H 1 1 1 1 1 1 Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 13 / 22
Derivations for HRGs. Let ( N , V , E , E Σ , S , P ) be a hyperedge replacement graph grammar. Definition Let → ⊆ H + ( N , V , E , E Σ , S ) 2 be the relation such that: ( V 0 , ˙ E 0 , S , → 0 ) → ( V 1 , ˙ E 1 , S , → 1 ) iff there exist: a hyperedge e ∈ E 0 ; a production ( n , S p ,( V p , ˙ E p , S , → p )) ∈ P ; σ E 0 → 1 : E 0 \{ e } � → E 1 , σ V 0 → 1 : V 0 � → V 1 , σ E p → 1 : E p � → E 1 , σ V p → 1 : V p \ S � → V 1 such that: E λ 0 ( e ) = n ; im( σ E 0 → 1 ) ⊎ im( σ E p → 1 ) = E 1 and im( σ V 0 → 1 ) ⊎ im( σ V p → 1 ) = V 1 ; ( ∀ e 0 ∈ E 0 \{ e })( ∀ e p ∈ E p )( ∀ s s ′ ∈ S )( ∀ v 0 ∈ V 0 )( ∀ v p ∈ V p \ S ) s s → 0 v 0 ⇐⇒ σ E → 1 σ V e 0 0 → 1 ( e 0 ) 0 → 1 ( v 0 ) E λ 0 ( e 0 ) = E λ 1 ( σ E 0 → 1 ( e 0 )) s s → p v p ⇐⇒ σ E → 1 σ V e p p → 1 ( e p ) p → 1 ( v p ) E λ p ( e p ) = E λ 1 ( σ E p → 1 ( e p )) s ′ s ′ s → p s ⇐⇒ σ E → 1 σ V e → 0 v 0 ∧ e p p → 1 ( e p ) 0 → 1 ( v 0 ) Thierry Martinez (INRIA) Constraint Grammars 2008/07/21 14 / 22
Recommend
More recommend