HEX-Programs with Existential Quantification Thomas Eiter, Michael - - PowerPoint PPT Presentation

hex programs with existential quantification
SMART_READER_LITE
LIVE PREVIEW

HEX-Programs with Existential Quantification Thomas Eiter, Michael - - PowerPoint PPT Presentation

HEX-Programs with Existential Quantification Thomas Eiter, Michael Fink, Thomas Krennwallner, Christoph Redl { eiter,fink,tkren,redl } @kr.tuwien.ac.at September 13, 2013 Redl C. (TU Vienna) HEX-Programs September 13, 2013 1 / 18 Motivation


slide-1
SLIDE 1

HEX-Programs with Existential Quantification

Thomas Eiter, Michael Fink, Thomas Krennwallner, Christoph Redl

{eiter,fink,tkren,redl}@kr.tuwien.ac.at

September 13, 2013

Redl C. (TU Vienna) HEX-Programs September 13, 2013 1 / 18

slide-2
SLIDE 2

Motivation

HEX-Programs

Extend ASP by external sources Traditional safety not sufficient due to value invention Notion of liberal domain-expansion safety guarantees finite groundability

Example

Π=

  • r1 : t(a).

r3 : s(Y) ← t(X), & cat[X, a](Y). r2 : dom(aa). r4 : t(X) ← s(X), dom(X).

  • Contribution

Domain-specific existential quantification in rule heads Grounding algorithm extended by application-specific termination hooks Instances: model computation over acyclic programs, query answering over programs with logical existential quantifier, function symbols

Redl C. (TU Vienna) HEX-Programs September 13, 2013 2 / 18

slide-3
SLIDE 3

HEX-Programs

HEX-programs extend ordinary ASP programs by external sources

Definition (HEX-programs)

A HEX-program consists of rules of form a1 ∨ · · · ∨ an ← b1, . . . , bm, not bm+1, . . . , not bn, with classical literals ai, and classical literals or an external atoms bj.

Definition (External Atoms)

An external atom is of the form & p[q1, . . . , qk](t1, . . . , tl), p . . . external predicate name qi . . . predicate names or constants tj . . . terms Semantics: 1 + k + l-ary Boolean oracle function f&p: & p[q1, . . . , qk](t1, . . . , tl) is true under assignment A iff f&p(A, q1, . . . , qk, t1, . . . , tl) = 1. HEX- program Reasoner Implementation

  • f &p

Redl C. (TU Vienna) HEX-Programs September 13, 2013 3 / 18

slide-4
SLIDE 4

Domain-specific Existential Quantification

Idea

Introduce new values which may appear in answer sets Structure of these values matters Introduction may be subject to constraints outside the program Realization: Use value invention in rule body, transfer new values to the head

Example

iban(B, I) ← country(B, C), bank(B, N), & iban[C, N, B](I).

Example

lifetime(M, L) ← machine(M, C), & lifetime[M, C](L).

Redl C. (TU Vienna) HEX-Programs September 13, 2013 4 / 18

slide-5
SLIDE 5

Existential Quantification

We will now discuss 3 instances of our approach: Model-building over acyclic HEX∃-Programs Query Answering over positive HEX∃-Programs Function Symbols

Redl C. (TU Vienna) HEX-Programs September 13, 2013 5 / 18

slide-6
SLIDE 6

Algorithm BGroundHEX

Input: A HEX-program Π Output: A ground HEX-program Πg Πp = Π ∪ {r&

g[ Y]( X) inp

| & g[ Y]( X) in r ∈ Π} Replace all external atoms & g[ Y]( X) in all rules r in Πp by er,&

g Y(

X) while Repeat() do PIT ← ∅ NewInputTuples ← ∅ repeat Πpg ← GroundASP(Πp) for & g[ Y]( X) in a rule r ∈ Π do Ama = {Tp( c) | a( c) ∈ A(Πpg), p ∈ Ym} ∪ {Fp( c) | a( c) ∈ A(Πpg), p ∈ Ya} for Anm ⊆ {Tp( c), Fp( c) | p( c) ∈ A(Πpg), p ∈ Yn} s.t. ∄a : Ta, Fa ∈ Anm do A = (Ama ∪ Anm ∪ {Ta | a ←∈ Πpg}) \ {Fa | a ←∈ Πpg} for y ∈ { c | r&

g[ Y]( X) inp

( c) ∈ A(Πpg)s.t.Evaluate(r&

g[ Y]( X) inp

( c)) = true} do Let O = { x | f&g(A, y, x) = 1} Πp ← Πp ∪ {er,&

g[

  • y](

x) ∨ ner,&

g[

  • y](

x) ←| x ∈ O} NewInputTuples ← NewInputTuples ∪ {r&

g[ Y]( X) inp

( y)} PIT ← PIT ∪ NewInputTuples until Πpg did not change Remove input auxiliary rules and external atom guessing rules from Πpg Replace all e&

g[

  • y](

x) in Πpg by & g[ y]( x) return Πpg

Redl C. (TU Vienna) HEX-Programs September 13, 2013 6 / 18

slide-7
SLIDE 7

Model-building over Acyclic HEX∃-Programs

Definition

A HEX∃-program is a finite set of rules of form ∀ X∃ Y : atom[ X′ ∪ Y] ← conj[ X], (1) where X and Y are disjoint sets of variables, X′ ⊆ X, atom[ X].

Definition

For HEX∃-program Π let T∃(Π) be the HEX-program where each r = ∃ Y : atom[ X′ ∪ Y] ← conj[ X] is replaced by atom[ X′ ∪ Y] ← conj[ X], & exists| ˜

X′|,|˜ Y|[r,

X′]( Y), where f&existsn,m(A, r, x, y) = 1 iff y = φ1, . . . , φm is a vector of fresh and unique null values for r, x and do not appear in Π, and f&existsn,m(A, r, x, y) = 0 otherwise.

Redl C. (TU Vienna) HEX-Programs September 13, 2013 7 / 18

slide-8
SLIDE 8

Model-building over Acyclic HEX∃-Programs

Example

Program Π: employee(john). employee(joe). r1 : ∃Y : office(X, Y) ← employee(X). r2 : room(Y) ← office(X, Y) Program T∃(Π): employee(john). employee(joe). r′

1 :

  • ffice(X, Y) ← employee(X), &

exists1,1[r1, X](Y). r2 : room(Y) ← office(X, Y) The unique answer set of T∃(Π) is {employee(john), employee(joe), office(john, φ1),

  • ffice(joe, φ2), room(φ1), room(φ2)}.

Redl C. (TU Vienna) HEX-Programs September 13, 2013 8 / 18

slide-9
SLIDE 9

Model-building over Acyclic HEX∃-Programs

For de-safe programs we do not need the hooks, thus let GroundDESafeHEX be the instantiation of BGroundHEX where Repeat repeats exactly once Evaluate return always true Then:

Proposition

For de-safe programs Π, AS(GroundDESafeHEX(Π)) ≡pos AS(Πg).

Redl C. (TU Vienna) HEX-Programs September 13, 2013 9 / 18

slide-10
SLIDE 10

Query Answering over Positive HEX∃-Programs

Definition

A Datalog∃-program is a finite set of rules of form ∀ X∃ Y : atom[ X′ ∪ Y] ← conj[ X] where X and Y are disjoint sets of variables, X′ ⊆ X. Disallowed: default negation, general external atoms.

Definition

A homomorphism is a mapping h : N ∪ V → C ∪ V. A homomorphism h is called substitution if h(N) = N for all N ∈ N .

Definition

Model of a program: set of atoms M s.t. whenever there is a substitution h with h(B(r)) ⊆ M for some r ∈ Π, then h|

X(H(r)) is substitutive to some atom in M.

Definition

A conjunctive query q is of form ∃ Y :← conj[ X ∪ Y] with free variables X.

Redl C. (TU Vienna) HEX-Programs September 13, 2013 10 / 18

slide-11
SLIDE 11

Query Answering over Positive HEX∃-Programs

Answer of a CQ q with free variables X wrt. model M: ans(q, M) = {h|

X | h is a substitution and h| X(q) is substitutive to some a ∈ M}

Answer of a CQ q wrt. a program Π: ans(q, Π) = {h | h ∈ ans(q, M) ∀M ∈ mods(Π)}

Redl C. (TU Vienna) HEX-Programs September 13, 2013 11 / 18

slide-12
SLIDE 12

Query Answering over Positive HEX∃-Programs

Answer of a CQ q with free variables X wrt. model M: ans(q, M) = {h|

X | h is a substitution and h| X(q) is substitutive to some a ∈ M}

Answer of a CQ q wrt. a program Π: ans(q, Π) = {h | h ∈ ans(q, M) ∀M ∈ mods(Π)}

Definition

Model U of a program Π is universal if, for each M ∈ mods(Π), there is a homomorphism h s.t. h(U) ⊆ M.

Proposition

Let U be a universal model of Datalog∃-program Π. Then for each CQ q, h ∈ ans(q, Π) iff h ∈ ans(q, U) and h : V → C \ N .

Redl C. (TU Vienna) HEX-Programs September 13, 2013 11 / 18

slide-13
SLIDE 13

Query Answering over Positive HEX∃-Programs

Answer of a CQ q with free variables X wrt. model M: ans(q, M) = {h|

X | h is a substitution and h| X(q) is substitutive to some a ∈ M}

Answer of a CQ q wrt. a program Π: ans(q, Π) = {h | h ∈ ans(q, M) ∀M ∈ mods(Π)}

Definition

Model U of a program Π is universal if, for each M ∈ mods(Π), there is a homomorphism h s.t. h(U) ⊆ M.

Proposition

Let U be a universal model of Datalog∃-program Π. Then for each CQ q, h ∈ ans(q, Π) iff h ∈ ans(q, U) and h : V → C \ N . ⇒ Key issue: Computing (finite subsets of) a universal model

Redl C. (TU Vienna) HEX-Programs September 13, 2013 11 / 18

slide-14
SLIDE 14

Query Answering over Positive HEX∃-Programs

Example

Let Π be the following Datalog∃-program: person(john). person(joe). r1 : ∃Y : father(X, Y) ← person(X). r2 : person(Y) ← father(X, Y). Then T∃(Π) is the following program: person(john). person(joe). r′

1 :

father(X, Y) ← person(X), & exists1,1[r1, X](Y). r2 : person(Y) ← father(X, Y).

Redl C. (TU Vienna) HEX-Programs September 13, 2013 12 / 18

slide-15
SLIDE 15

Query Answering over Positive HEX∃-Programs

Input: A HEX-program Π = T∃(Π∃) for some Datalog∃-program Π∃, the count of freeze steps cfreeze Output: A ground HEX-program Πg s.t. A ∈ AS(Πg) is sound and complete for query answering Πp = Π ∪ {r&

g[ Y]( X) inp

| & g[ Y]( X) in r ∈ Π} Replace all external atoms & g[ Y]( X) in all rules r in Πp by er,&

g Y(

X) for f = 0, . . . , cfreeze do PIT ← ∅ NewInputTuples ← ∅ repeat Πpg ← GroundASP(Πp) for & g[ Y]( X) in a rule r ∈ Π do Ama = {Tp( c) | a( c) ∈ A(Πpg), p ∈ Ym} ∪ {Fp( c) | a( c) ∈ A(Πpg), p ∈ Ya} for Anm ⊆ {Tp( c), Fp( c) | p( c) ∈ A(Πpg), p ∈ Yn} s.t. ∄a : Ta, Fa ∈ Anm do A = (Ama ∪ Anm ∪ {Ta | a ←∈ Πpg}) \ {Fa | a ←∈ Πpg} for y ∈ { c | r&

g[ Y]( X) inp

( c) ∈ A(Πpg) which is not homomorphic to any a ∈ PIT} do Let O = { x | f&g(A, y, x) = 1} Πp ← Πp ∪ {er,&

g[

  • y](

x) ∨ ner,&

g[

  • y](

x) ←| x ∈ O} NewInputTuples ← NewInputTuples ∪ {r&

g[ Y]( X) inp

( y)} PIT ← PIT ∪ NewInputTuples until Πpg did not change Remove input auxiliary rules and external atom guessing rules from Πpg Replace all e&

g[

  • y](

x) in Πpg by & g[ y]( x) return Πpg

Redl C. (TU Vienna) HEX-Programs September 13, 2013 13 / 18

slide-16
SLIDE 16

Query Answering over Positive HEX∃-Programs

Example (ctd.)

Let Π be the following Datalog∃-program: person(john). person(joe). r1 : ∃Y : father(X, Y) ← person(X). r2 : person(Y) ← father(X, Y). Then T∃(Π) is the following program: person(john). person(joe). r′

1 :

father(X, Y) ← person(X), & exists1,1[r1, X](Y). r2 : person(Y) ← father(X, Y). For cfreeze = 1 ⇒ program with single answer set {person(john), person(joe), father(john, φ1), father(joe, φ2), person(φ1), person(φ2)}

Redl C. (TU Vienna) HEX-Programs September 13, 2013 14 / 18

slide-17
SLIDE 17

Query Answering over Positive HEX∃-Programs

Example (ctd.)

Let Π be the following Datalog∃-program: person(john). person(joe). r1 : ∃Y : father(X, Y) ← person(X). r2 : person(Y) ← father(X, Y). Then T∃(Π) is the following program: person(john). person(joe). r′

1 :

father(X, Y) ← person(X), & exists1,1[r1, X](Y). r2 : person(Y) ← father(X, Y). For cfreeze = 1 ⇒ program with single answer set {person(john), person(joe), father(john, φ1), father(joe, φ2), person(φ1), person(φ2)}

Proposition

For a shy program Π, GroundDatalog∃(Π, k) has a unique answer set which is sound and complete for answering CQs with up to k existential variables.

Redl C. (TU Vienna) HEX-Programs September 13, 2013 14 / 18

slide-18
SLIDE 18

Function Symbols

Definition (Terms)

The set of terms T is defined as the least set s.t. T ⊇ V ∪ C and f ∈ C, t1, . . . , tn ∈ T implies f(t1, . . . , tn) ∈ T . For each k ∈ N two external predicates & composek and & decomposek with arI(& composek) = 1 + k and arO(& composek) = 1 and arI(& decomposek) = 1 and arO(& decomposek) = 1 + k. Following [Calimeri et al., 2007], f&composek(A, f, X1, . . . , Xk, T) = f&decomposek(A, T, f, X1, . . . , Xk) = 1, iff T = f(X1, . . . , Xk). Note: & decomposek supports a well-ordering

Redl C. (TU Vienna) HEX-Programs September 13, 2013 15 / 18

slide-19
SLIDE 19

Function Symbols

Definition

Let Π be a HEX-program with function symbols. Then Tf (Π) is the program where each f(t1, . . . , tn) in a rule r is recursively replaced by a new variable V. If f(t1, . . . , tn) appears in H(r) or in the input list of some external atom in B(r), then & composen[f, t1, . . . , tn](V) is added to B(r), and otherwise & decomposen[V](f, t1, . . . , tn) is added to B(r).

Example

Program Π: q(z). q(y). p(f(f(X))) ← q(X). r(X) ← p(X). r(X) ← r(f(X)). Then Tf (Π) is: q(z). q(y). p(V) ← q(X), & compose1[f, X](U), & compose1[f, U](V). r(X) ← p(X). r(X) ← r(V), & decompose1[V](f, X).

Redl C. (TU Vienna) HEX-Programs September 13, 2013 16 / 18

slide-20
SLIDE 20

Conclusion

ASP Programs with External Sources

Ordinary safety not sufficient due to value invention Notion of liberal domain-expansion safety guarantees finite groundability

Contribution

Domain-specific existential quantifier in heads realized by external sources Advantage: Easy extensibility, e.g., data types, side constraints Grounding algorithm extended by application-specific termination hooks Instances: model building over acyclic programs, query answering with logical existential quantifier, function symbols

Future Work

Combination of query answering with function symbols, default negation Model-building over programs with infinite but finitely representable models

Redl C. (TU Vienna) HEX-Programs September 13, 2013 17 / 18

slide-21
SLIDE 21

References

Calimeri, F., Cozza, S., and Ianni, G. (2007). External Sources of Knowledge and Value Invention in Logic Programming. Annals of Mathematics and Artificial Intelligence, 50(3–4):333–361. Eiter, T., Ianni, G., Schindlauer, R., and Tompits, H. (2006). Effective Integration of Declarative Rules with External Evaluations for Semantic-Web Reasoning. In 3rd European Semantic Web Conference (ESWC’06), volume 4011 of LNCS, pages 273–287. Springer. Leone, N., Manna, M., Terracina, G., and Veltri, P . (2012). Efficiently computable datalog∃ programs. In KR. Syrj¨ anen, T. (2001). Omega-restricted logic programs. In 6th International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR’01), volume 2173 of LNCS, pages 267–279. Springer.

Redl C. (TU Vienna) HEX-Programs September 13, 2013 18 / 18