**3.3 Satisfiability and implication**

Finding whether there exists a satisfiable part between two formulas or whether one implies the other is central to many database problems such as query containment, query equivalence, answering queries using views and database cache. So according to Guo (Guo S et al., 1996) implication is defined as "S implies T, denoted as S T, if and only if every assignment that satisfies S also satisfies T". Similarly satisfiability is defined as "S is satisfiable if and only if there exists at least one assignment for S that satisfies T." (Guo S et al., 1996) had given algorithm to compute implication, satisfiability and equivalence for given conjunctive formulas in integer and real domain. Let us have a formula (*Salary < 20K AND Salary > 8K AND Department = 'CS'*) is satisfiable, because the assignment {12K/*Salary* , CS/*Department*} satisfies the formula. Similarly a formula (*Salary >10K OR Salary < 12K)* is a tautology, because every assignment under this formula is satisfiable.

Satisfiability and implication results in databases (Guo et al., 1996),(J.D. Ullman, 1989),(A.Klug, 1988),(Rosenkrantz and Hunt, 1980), (Sun et al., 1989) are relevant to the computation of probe and remainder query in semantic cache query processing for a class of queries that involve inequalities of integer and real domain. Previous work models the problem into graph structure.

Rosenkrantz and Hunt (Rosenkrantz and Hunt, 1980) provided an algorithm of complexity O(|*Q*|3) for solving satisfiability problem; the expression *S* to be tested for satisfiability is the conjunction of terms of the form *X op C*, *X op Y*, and *X op Y* + *C*.

Guo et al. (Guo et al., 1996) provided an algorithm (GSW) for computing satisfiability with complexity O(|*Q*|3) involving complete operator set and predicate type X op C, X op Y and X op Y + C. Here we demonstrate GSW algorithm (Guo et al., 1996) for finding implication and satisfiability between two queries.

The GSW algorithm starts with transforming all inequalities into normalized form through given rules. It was proved by Ullman (J.D. Ullman, 1989) that these transformations still holds equality. After these transformation remaining operator set become {≤ ,≠ }.

86 Semantics – Advances in Theories and Mathematical Models

A relational query can be visualized as a rectangle with boundaries set by query predicate values. So according to (Makki K. S and Andrei S, 2009), (Makki K. S and Rockey M., 2010) semantic cache query processing based on query trimming is problem of finding intersection between two finite rectangles. Six cases that are extended form of Figure 1.1 are given in (Makki K. S and Andrei S, 2009), (Makki K. S and Rockey M., 2010) to show relationship between rectangles of user and cached queries. These rectangular representations do not depict implicit knowledge present in the semantics of user and cached queries. An technique named Flattening Bi-dimensional Interval Constraints (FBIC) was proposed (Makki K. S and Andrei S, 2009). Based on FBIC an algorithm for handling disjunctive and conjunctive queries was given by Makki (Makki K. S and Rockey M., 2010). The algorithm works for only single disjunctive case, where conjunctive cases are same as

Finding intersection between rectangles of user and cached queries was done by comparing Bounds (Lower or Upper) of both rectangles. But computing comparable bounds were not

Finding whether there exists a satisfiable part between two formulas or whether one implies the other is central to many database problems such as query containment, query equivalence, answering queries using views and database cache. So according to Guo (Guo S et al., 1996) implication is defined as "S implies T, denoted as S T, if and only if every assignment that satisfies S also satisfies T". Similarly satisfiability is defined as "S is satisfiable if and only if there exists at least one assignment for S that satisfies T." (Guo S et al., 1996) had given algorithm to compute implication, satisfiability and equivalence for given conjunctive formulas in integer and real domain. Let us have a formula (*Salary < 20K AND Salary > 8K AND Department = 'CS'*) is satisfiable, because the assignment {12K/*Salary* , CS/*Department*} satisfies the formula. Similarly a formula (*Salary >10K OR Salary < 12K)* is a

Satisfiability and implication results in databases (Guo et al., 1996),(J.D. Ullman, 1989),(A.Klug, 1988),(Rosenkrantz and Hunt, 1980), (Sun et al., 1989) are relevant to the computation of probe and remainder query in semantic cache query processing for a class of queries that involve inequalities of integer and real domain. Previous work models the

Rosenkrantz and Hunt (Rosenkrantz and Hunt, 1980) provided an algorithm of complexity O(|*Q*|3) for solving satisfiability problem; the expression *S* to be tested for satisfiability is

Guo et al. (Guo et al., 1996) provided an algorithm (GSW) for computing satisfiability with complexity O(|*Q*|3) involving complete operator set and predicate type X op C, X op Y and X op Y + C. Here we demonstrate GSW algorithm (Guo et al., 1996) for finding implication

The GSW algorithm starts with transforming all inequalities into normalized form through given rules. It was proved by Ullman (J.D. Ullman, 1989) that these transformations still

holds equality. After these transformation remaining operator set become {≤ ,≠ }.

given (Makki K. S and Andrei S, 2009), (Makki K. S and Rockey M., 2010).

tautology, because every assignment under this formula is satisfiable.

the conjunction of terms of the form *X op C*, *X op Y*, and *X op Y* + *C*.

provided by (Makki K. S and Andrei S, 2009).

**3.3 Satisfiability and implication** 

problem into graph structure.

and satisfiability between two queries.

(1) (*X ≥ Y+C*) (*Y ≤ X – C*) (2) (*X < Y +C*) (*X ≤ Y + C*) (*X ≠ Y + C*) (3) (*X > Y + C*) (*Y ≤ X – C*) (*X ≠ Y + C*) (4) (*X = Y + C*) (*Y ≤ X – C*) (*X ≤ Y + C*) (5) (*X < C*) (*X ≤ C*) (*X ≠ C*) (6) (*X > C*) (*X ≥ C*) (*X ≠ C*) (7) (*X = C*) (*X ≤ C*) (*X ≥ C*)

Satisfiability of a conjunctive query *Q* is computed by constructing a connected weighteddirected graph GQ=(VQ,EQ) of *Q* after above transformation. Where VQ are the nodes representing predicate attributes of an inequality and EQ represent an edge between two nodes. An inequality of the form X op Y + C has X and Y nodes and an edge between them with C weight. The inequality X op C is transformed to X op V0 + C by introducing a dummy node V0.

According to GSW (Guo et al., 1996) algorithm, for any query *Q* if a negative-weighted cycle (a cycle whose sum of edges weight is negative) found in GQ then *Q* is unsatisfiable. Otherwise *Q* is satisfiable. Testing satisfiability among user query *QU* and cached segment *QS* require us to construct a graph (GQu Qs) of (*QU QS*) and check GQu Qs for any negative weighted cycle. Negative weighted cycle is found through Floyd-Warshall algorithm (R.W. Floyd, 1962). Complexity of Floyd-Warshall algorithm is O(|V|3), so finding satisfiability become O(|*QU QS* |3).

An algorithm with O(|S|3 + K) complexity for solving the implication problem between two conjunctive inequalities *S* and *T* was presented by Ullman (J.D. Ullman, 1989) and Sun (Sun et al., 1989). Conjunctive queries of the form X op Y were studied by (A.Klug, 1988) and (Sun et al., 1989). Implication between conjunctive queries of the form X op Y +C was addressed by GSW algorithm (Guo et al., 1996) with complexity O(|*QU*|2 + |*QC*|). GSW Implication (Guo et al., 1996) requires that *QU* is satisfiable. At first the implication algorithm constructs the closure of *QU* i.e., a universal set that contains all those inequalities that are implied by *QU*. Then, *QU QS* if *QS* is a subset of the *QU* closure.

[(V0 ≤ Salary -1), (Salary ≤ V0 +40), (V0 ≤ Salary -20), (V0 ≤ Age -30), (Age ≤ V0 +80), (Exp ≤ V0 +40)]

Fig. 5. (a) [*QU1 QS*] and G*QU1 QS* (b) Shortest Path Table

**Example 2:** Let us have a user query *QU1* = Age,Salary,Exp Salary≥20K Age≥<sup>30</sup> Age≤<sup>80</sup> Exp≤<sup>40</sup> over cached segment *QC7* of Example 1. The directed weighted graph G*QU1 QC7* of *QU1 QC7* is shown in Figure 5(a). *QU1* is satisfiable with respect to *QC7*, as there is no negative weighted cycle in G*QU QC7.*

Semantic Cache Reasoners 89

*Q'← π Age, Department σ Age < 70 (QC1,QC2);*

We follow the results produced by maximally-contained query rewriting algorithm named bucket algorithm (Levy A.Y et al., 1996) provided above. The predicate (*Exp > 20*) is pruned because query cannot be executed over cached data as there is no information present against *Exp* attribute. Further more if the rewritten query (*Q'* shown in Figure 7) executed locally, it will give unnecessary/incorrect results. These results are maximally-contained or maximum data retrieval (MDR) but the results contain tuples that are not part of the actual user query (QU). Figure 8 (a) shows the collective dataset of cached queries QC1 and QC2 (Figure 6). The rewritten query (*Q'*) executed over cached data is shown in Figure 8 (b). The data items shown as strike circle ( ) in Figure 8 (b) are the required results of user query (QU). Where results retrieved by the rewritten query (*Q'*) are not the precise answer for the

Fig. 7. Rewritten Query Q'.

**3.4.1 Example** 

user query (QU).

**(Jhon) (Kapy)**

Cached Query QC1 and QC2.

answer cannot be determined.

EE CS BA BI

**(Sarah)**

**(Frank)**

**(Mike Jr) (Sami)**

**(Ronni)**

way to determine the available and unavailable answer from the cache.

Fig. 8. (a) Collective Data of Cached Query QC1 and QC2. (b) Rewritten Query Q' Over

Bucket algorithm does not compute probe and remainder queries separately. So there is no

A web-based cache system is different from data caching. In web cache, special proxy servers store recently visited pages for later reuse. A uniform resource locater (URL) is a user query that is posed over web cache system. Any page in cache is being used whenever a user given URL matches the cache page header. This type of caching strategy is similar to page-caching, where binary results (complete answer or no-answer) are possible but partial

**(Gage) (Ford)**

**(Nikky) (Mike)**

**(Sam) (David)**

Department

**3.5 Semantic reasoning for web queries** 

#### **3.4 Bucket algorithm**

As discussed earlier, a user of data integration system poses query in term of mediated schema, because root sources are transparent in such systems. A module of data integration system translate/reformulate a user query that refers directly to the root sources. Several reputed algorithms exist for such query reformulation/rewriting (Levy A.Y et al., 1996), (Duschka O.M. and Genesereth M.R. 1997), (Pottinger R. and Levy A. 2000). In context of semantic cache the root sources are the cache segments and the mediated schema is the cache description. The goal of the bucket algorithm (Levy A.Y et al., 1996) is to reformulate a user query that is posed on the mediated (virtual) schema into a query that refers directly to the available (local/cached) data sources. This reformulation is known as query-rewriting. Both the query and the sources are described by select-project-join queries that may include atoms of arithmetic comparison predicates. The bucket algorithm returns the maximallycontained rewriting of the query using the views. This rewriting is a maximally-contained but not an equivalent one.

We demonstrate working (in context of semantic cache query processing) of bucket algorithm with example.

$$\begin{aligned} \underline{\mathbf{Q}\_{CI}} &\leftarrow \mathfrak{n}\_{\textit{Ename, Departement}} \mathsf{\mathcal{O}}\_{\textit{Age} \geq \mathfrak{s} \textsf{o}} (\textit{Emp}); \\ \underline{\mathbf{Q}\_{C2}} &\leftarrow \mathfrak{n}\_{\textit{Age, Departement}} (\textit{Emp}); \\ \underline{\mathbf{Q}\_{C3}} &\leftarrow \mathfrak{n}\_{\textit{Age, Departement}} \mathsf{\mathcal{O}}\_{\textit{Exp} < 15 \; (\textit{Emp});} \\ \underline{\mathbf{Q}\_{U}} &\leftarrow \mathfrak{n}\_{\textit{Age, Departement}} \mathsf{\mathcal{O}}\_{\textit{Exp} > 20 \; \wedge \textit{ Age} < 70 \; (\textit{Emp});} \end{aligned}$$

Fig. 6. User Query (QU) Over Cached Queries

Let us have QC1, QC2 and QC3 (shown in Figure 6) in cache, and a user query QU (shown in Figure 6) is posed over them. As shown in Table 1 below, according to bucket algorithm both cached queries QC1 and QC2 are candidate selection for its bucket. Since there is no inconsistency between user query predicate and cached queries (i.e. *Age ≥55* consistent with *Age < 70*) when compared in isolation (atomically). Where QC3 is excluded due to predicate inconsistency (i.e. *Exp < 15* inconsistent with *Exp > 20*). In second step of bucket algorithm, elements of buckets are combined together to form a rewriting of the user query. The rewritten query (*Q*') in this case is shown in Figure 7 below.

Table 1. Contents of Bucket. The attribute not required by user query is shown as primed attribute.
