User Tools

Site Tools


magik-demo:user:query_approximation:generalization

Generalization

After the elaboration MAGIK, will answer if the query given by the user, is complete or not with respect to schema constraints and TC-statements.

If it is not complete, MAGIK will try to generate the generalized and specialized query.

In this page it is explained how works the generalization algorithm.

This schema illustrates all the steps that the generalization algorithm does. In order to be more comprehensive, we will use and example.

Suppose that:

Q = A1, A2, A3, A4

where A1, A2, A3 and A4 are atoms and we have these TC-statements

TC1 - A1(a) = A1(i)
TC2 - A2(a) = A2(i), A3(i)
TC3 - A3(a) = A3(i), A4(i)

Running MAGIK on this query and given database schema and TC-statements, we get that this query is <fc red>NOT COMPLETE</fc>

At this point the generalization algorithm enter in action.
The idea is at each iteration remove all the incomplete atoms. The algorithm will stop if there is no other atoms that are incomplete (we said that it reaches a fixed point).

1st iteration

Looking the 3 tc-statements that we have, we see that there is no information about A4 (you have to look on the left side of the equal) so, the algorithm will remove from the query the atom A4.
New query is

Q1 = A1, A2, A3

Obviously Q1 is not equal to Q, so the algorithm will continue.

2nd iteration

Now we know that A4 is incomplete. From this we can inferred that also A3 is not complete because A3 in complete iff also A4 is complete (TC3), but this is not the case. So A3 will be removed from the query.
New query is

Q2 = A1, A2 

Obviously Q2 is not equal to Q1, so the algorithm will continue.

3rd iteration

Now we know that A4 and A3 are incomplete. From this we can inferred that also A2 is not complete because A2 is complete iff also A3 is complete (TC2), but this is not the case. For this reason A2 will be removed from the query.
New query is

Q3 = A1

Obviously Q3 is not equal to Q2, so the algorithm will start another iteration

4th iteration

Now we have only A1. This atom is complete because there is no other atoms involved in its completeness (TC1). So A1 survived.
New query is

Q4 = A1

Now Q4 is equal to Q3, so we reach a fix point and the algorithm stops.

So the generalizated query Qgen is:

Qgen = A1
magik-demo/user/query_approximation/generalization.txt · Last modified: 2017/07/06 15:24 (external edit)