  Answering Boolean conjunctive queries over the guarded fragment is decidable,
however, as yet no practical decision procedure exists. Meanwhile, ordered
resolution, as a practically oriented algorithm, is widely used in state-of-art
modern theorem provers. In this paper, we devise a resolution decision
procedure, which not only proves decidability of querying of the guarded
fragment, but is implementable in any `off-the-shelf' resolution theorem prover
with modest effort. Further, we extend the procedure to querying the loosely
guarded fragment.
  The difficulty in querying a knowledge base of (loosely) guarded clauses is
that query clauses are not guarded. We show however there are ways to
reformulate query clauses into (loosely) guarded clauses either directly via
the separation and splitting rules, or via performing inferences using our
top-variable inference system combining with a form of dynamic renaming.
Therefore, the problem of querying the (loosely) guarded fragment can be
reduced to deciding the (loosely) guarded fragment and possibly irreducible
query clauses, i.e., a clause that cannot derive any new conclusion. Meanwhile,
our procedure yields a goal-oriented query rewriting algorithm: Before
introducing datasets, one can produce a saturated clausal set $\mathcal{S}$
using given BCQs and (loosely) guarded theories. Clauses in $\mathcal{S}$ can
be easily transformed first-order queries, therefore query answering over the
(loosely) guarded fragment is reduced to evaluating a union of first-order
queries over datasets. As far as we know, this is the first practical decision
procedure for answering and rewriting Boolean conjunctive queries over the
guarded fragment and the loosely guarded fragment.
