query answering with description logic ontologies Meghyn Bienvenu ( CNRS & Université de Montpellier ) Magdalena Ortiz ( Vienna University of Technology )
conjunctive queries
y P 1 t 1 P n t n where every variable in some t i appears in either x or y and every P i A union of CQs (UCQ) is a first-order query q x of the form q 1 x q n x where the q i x are CQs with same tuple x of free vars (unions of) conjunctive queries IQs quite restricted: No selections and joins as in DB queries Most work on OMQA adopts (unions of) conjunctive queries (CQs) A conjunctive query (CQ) is a first-order query q x of the form is either a concept or role name 3/31
y P 1 t 1 P n t n where every variable in some t i appears in either x or y and every P i A union of CQs (UCQ) is a first-order query q x of the form q 1 x q n x where the q i x are CQs with same tuple x of free vars (unions of) conjunctive queries IQs quite restricted: No selections and joins as in DB queries A conjunctive query (CQ) is a first-order query q x of the form is either a concept or role name 3/31 Most work on OMQA adopts (unions of) conjunctive queries (CQs)
A union of CQs (UCQ) is a first-order query q x of the form q 1 x q n x where the q i x are CQs with same tuple x of free vars (unions of) conjunctive queries IQs quite restricted: No selections and joins as in DB queries is either a concept or role name y and every P i 3/31 Most work on OMQA adopts (unions of) conjunctive queries (CQs) A conjunctive query (CQ) is a first-order query q ( ⃗ x ) of the form y . P 1 ( ⃗ t 1 ) ∧ · · · ∧ P n ( ⃗ ∃ ⃗ t n ) where every variable in some ⃗ t i appears in either ⃗ x or ⃗
(unions of) conjunctive queries IQs quite restricted: No selections and joins as in DB queries x of free vars is either a concept or role name y and every P i 3/31 Most work on OMQA adopts (unions of) conjunctive queries (CQs) A conjunctive query (CQ) is a first-order query q ( ⃗ x ) of the form y . P 1 ( ⃗ t 1 ) ∧ · · · ∧ P n ( ⃗ ∃ ⃗ t n ) where every variable in some ⃗ t i appears in either ⃗ x or ⃗ A union of CQs (UCQ) is a first-order query q ( ⃗ x ) of the form q 1 ( ⃗ x ) ∨ · · · ∨ q n ( ⃗ x ) where the q i ( ⃗ x ) are CQs with same tuple ⃗
what can we express as cqs? Find pairs of restaurants and dishes they serve which contain an spicy ingredient: Find restaurants that serve a vegetarian menu and a menu with a spicy main dish, and that both have the same cake as dessert: In general, not expressible as instance queries! 4/31 ∃ z . serves ( x , y ) ∧ Dish ( y ) ∧ hasIngred ( y , z ) ∧ Spicy ( z ) q 1 ( x , y ) = q 2 ( x ) = ∃ y 1 , y 2 , z 1 , z 2 . serves ( x , y 1 ) ∧ vegMenu ( y 1 ) ∧ hasDessert ( y 1 , z 1 ) ∧ Cake ( z 1 ) ∧ serves ( x , y 2 ) ∧ Menu ( y 2 ) ∧ hasMain ( y 2 , z 2 ) ∧ Spicy ( z 2 ) ∧ hasDessert ( y 2 , z 1 )
what can we express as cqs? Find pairs of restaurants and dishes they serve which contain an spicy ingredient: Find restaurants that serve a vegetarian menu and a menu with a spicy main dish, and that both have the same cake as dessert: In general, not expressible as instance queries! 4/31 ∃ z . serves ( x , y ) ∧ Dish ( y ) ∧ hasIngred ( y , z ) ∧ Spicy ( z ) q 1 ( x , y ) = q 2 ( x ) = ∃ y 1 , y 2 , z 1 , z 2 . serves ( x , y 1 ) ∧ vegMenu ( y 1 ) ∧ hasDessert ( y 1 , z 1 ) ∧ Cake ( z 1 ) ∧ serves ( x , y 2 ) ∧ Menu ( y 2 ) ∧ hasMain ( y 2 , z 2 ) ∧ Spicy ( z 2 ) ∧ hasDessert ( y 2 , z 1 )
what can we express as ucqs? Find restaurants that serve a dish that contains an spicy ingredient, or that contains an ingredient that contains an spicy ingredient: 5/31 ( ) q 1 ( x ) = ∃ y , z . serves ( x , y ) ∧ Dish ( y ) ∧ hasIngred ( y , z ) ∧ Spicy ( z ) ∨ ( ∃ y 1 , y 2 , z . serves ( x , y 1 ) ∧ Dish ( y 1 ) ∧ hasIngred ( y 1 , y 2 ) ∧ hasIngred ( y 2 , z ) ∧ Spicy ( z ) )
cqs and other query languages CQs correspond to: ∙ select-project-join queries of relational algebra / SQL ∙ basic graph patterns of SPARQL 6/31 Alternatively, CQs and UCQs can be seen as Datalog rules
y 1 P 1 1 t 1 n 1 t 1 1 t 1 n 1 t 1 y 2 P 2 1 t 2 n 2 t 2 1 t 2 n t 2 y P 1 t 1 P n t n P 1 t 1 P n t n n 2 q x q x P 2 . 1 . P 2 P 2 n . . . . cqs and ucqs in datalog n 1 1 P 1 CQs: UCQs: q x 1 7/31 n 1 q x P 1 1 P 1 y . P 1 ( ⃗ t 1 ) ∧ · · · ∧ P n ( ⃗ x ) ← P 1 ( ⃗ t 1 ) , . . . , P n ( ⃗ q ( ⃗ x ) = ∃ ⃗ q ( ⃗ t n ) t n ) ⇝
cqs and ucqs in datalog t 1 . . . . . . t 2 t 2 t 2 CQs: t 2 t 1 t 1 t 1 7/31 UCQs: y . P 1 ( ⃗ t 1 ) ∧ · · · ∧ P n ( ⃗ x ) ← P 1 ( ⃗ t 1 ) , . . . , P n ( ⃗ q ( ⃗ x ) = ∃ ⃗ q ( ⃗ t n ) t n ) ⇝ 1 ( ⃗ n 1 ( ⃗ 1 ( ⃗ n 1 ( ⃗ q ( ⃗ x ) = ∃ ⃗ 1 ) ∧ · · · ∧ P 1 n 1 ) q ( ⃗ x ) ← P 1 1 ) , . . . , P 1 n 1 ) y 1 . P 1 1 ( ⃗ n 2 ( ⃗ 1 ( ⃗ n ( ⃗ ∨ ∃ ⃗ 1 ) ∧ · · · ∧ P 2 n 2 ) q ( ⃗ x ) ← P 2 1 ) , . . . , P 2 n ) y 2 . P 2 ⇝ 1 ( ⃗ n ℓ ( ⃗ 1 ( ⃗ n ℓ ( ⃗ y ℓ . P ℓ t ℓ 1 ) ∧ · · · ∧ P ℓ x ) ← P ℓ t ℓ 1 ) , . . . , P ℓ ∨ ∃ ⃗ t ℓ n ℓ ) q ( ⃗ t ℓ n ℓ )
semantics of cqs r t A for every atom A t q ∙ t t for every atom r t t such that: q We write q a if is a match for q x in and x a ∙ y to objects in 8/31 from the variables in x is a mapping x y in an interpretation y A match for q x ∙ We can also use the notion of a match clear Recall that ⃗ a ∈ cert ( q , K ) iff ⃗ a ∈ ans ( q , I ) for every model I of K ∙ A CQ q ( ⃗ x ) is an FO formula , its satisfaction in an interpretation is ⃗ a ∈ ans ( q , I ) iff I | = q ( ⃗ x �→ ⃗ a )
semantics of cqs r t A for every atom A t q ∙ t t for every atom r t t such that: q We write q a if is a match for q x in and x a ∙ y to objects in 8/31 from the variables in x is a mapping x y in an interpretation y A match for q x ∙ We can also use the notion of a match clear Recall that ⃗ a ∈ cert ( q , K ) iff ⃗ a ∈ ans ( q , I ) for every model I of K ∙ A CQ q ( ⃗ x ) is an FO formula , its satisfaction in an interpretation is ⃗ a ∈ ans ( q , I ) iff I | = q ( ⃗ x �→ ⃗ a )
semantics of cqs ∙ We can also use the notion of a match a x and is a match for q x in q a if We write 8/31 clear Recall that ⃗ a ∈ cert ( q , K ) iff ⃗ a ∈ ans ( q , I ) for every model I of K ∙ A CQ q ( ⃗ x ) is an FO formula , its satisfaction in an interpretation is ⃗ a ∈ ans ( q , I ) iff I | = q ( ⃗ x �→ ⃗ a ) A match for q ( ⃗ x ) = ∃ ⃗ y .φ ( ⃗ x ,⃗ y ) in an interpretation I is a mapping π y to objects in ∆ I such that: from the variables in ⃗ x ∪ ⃗ ∙ π ( t ) ∈ A I for every atom A ( t ) ∈ q ∙ π ( t , t ′ ) ∈ r I for every atom r ( t , t ′ ) ∈ q
semantics of cqs clear a ∙ We can also use the notion of a match 8/31 Recall that ⃗ a ∈ cert ( q , K ) iff ⃗ a ∈ ans ( q , I ) for every model I of K ∙ A CQ q ( ⃗ x ) is an FO formula , its satisfaction in an interpretation is ⃗ a ∈ ans ( q , I ) iff I | = q ( ⃗ x �→ ⃗ a ) A match for q ( ⃗ x ) = ∃ ⃗ y .φ ( ⃗ x ,⃗ y ) in an interpretation I is a mapping π y to objects in ∆ I such that: from the variables in ⃗ x ∪ ⃗ ∙ π ( t ) ∈ A I for every atom A ( t ) ∈ q ∙ π ( t , t ′ ) ∈ r I for every atom r ( t , t ′ ) ∈ q = π q ( ⃗ a ) if π is a match for q ( ⃗ x ) in I and π ( ⃗ x ) = ⃗ We write I |
semantics of cqs (cont.) iff iff Answering CQs = deciding if there is a match in every model Challenge: how do we check that? infinitely many models models can be infinite 9/31 ⃗ a ∈ cert ( q , K ) for every model I of K we have ⃗ a ∈ ans ( q , I ) = π q ( ⃗ for every model I of K there exists a match π such that I | a )
semantics of cqs (cont.) iff iff Answering CQs = deciding if there is a match in every model Challenge: how do we check that? infinitely many models models can be infinite 9/31 ⃗ a ∈ cert ( q , K ) for every model I of K we have ⃗ a ∈ ans ( q , I ) = π q ( ⃗ for every model I of K there exists a match π such that I | a )
semantics of cqs (cont.) iff iff Answering CQs = deciding if there is a match in every model Challenge: how do we check that? infinitely many models models can be infinite 9/31 ⃗ a ∈ cert ( q , K ) for every model I of K we have ⃗ a ∈ ans ( q , I ) = π q ( ⃗ for every model I of K there exists a match π such that I | a )
An answer to a (U)CQ q in the universal model property ans q why? harder than answering CQs Note: due to the universal model property , answering UCQs is not gives us the certain answers to q over So: cert q iff a a matches of (U)CQs are preserved under homomorphisms is an answer to q in every model of 10/31 For Horn DLs, each satisfiable K has a universal model I K I K is ‘contained’ in every model I of K ⇝ formally, there is a homomorphism from I K to I
Note: due to the universal model property , answering UCQs is not the universal model property harder than answering CQs why? 10/31 For Horn DLs, each satisfiable K has a universal model I K I K is ‘contained’ in every model I of K ⇝ formally, there is a homomorphism from I K to I An answer to a (U)CQ q in I K is an answer to q in every model of K ⇝ matches of (U)CQs are preserved under homomorphisms ⃗ a ∈ cert ( q , K ) iff ⃗ a ∈ ans ( q , I K ) So: I K gives us the certain answers to q over K
Recommend
More recommend