

![0_image_0.png](0_image_0.png)

backtracking over the current query pack conjunction conj ( Q ) is stopped: all branches have reported success.

## 3.1.2 A Meta-Interpreter For Query Packs

The first implementation of the query pack execution algorithm is the meta-interpreter meta_execute_qp(Q) . The meta-interpreter uses the following labelling in its representation of a query pack:
- Query pack number All the non-leaf query packs in the tree are numbered, depth first, from left to right (qp(i)).

- Query number Each leaf is numbered, from left to right. If the original queries were nmbered sequentially, then the numbers at the leaves correspond with these (q(i)).

- Child number For each non-leaf query pack with N children, all children are numbered

from 1 up to N sequentially (ch(i)).
Consider the query pack a, (b, (c or d or c) or f or g, (h or i or j)). Note that the atoms in the example could in general be arbitrary conjunctions of non-ground terms. Its labelling is shown in Figure 3.

A labelled query pack Q is then represented as a Prolog term as follows (with Q f the father of Q):
- A leaf Q is represented by the term (c, leaf (qpnbf, chnb, qnb)) with c the conj (Q),

qpnbf the query pack number of Q f , chnb the child number of Q w.r.t. Q f , and qnb the query number of Q.

- A non-leaf Q is represented by the term (c,or(cs,qpnbf,qpnb,chnb,totcs) with c the conj(Q), cs the list children(Q), qpnbf the query pack number of Qf, qpnb the query pack number of Q , chnb the child number of Q w.r.t. Q f , and totcs the total number of children(Q)). The query pack number of the father of the root query pack is assumed to be zero.