To answer your questions:
expand_term is a predicate, found in many Prologs under various names,
which causes the system to preprocess every term it reads during a
'consult' before asserting it. In such systems, if you were to define
(e.g.)
expand_term( X===>Y, Result ) :
.... somehow convert X===>Y into Result ...
then every occurrence of X===>Y will be translated, and Result will be
asserted.
DCG rules are implemented this way: expand_term will recognise X>Y,
call a grammarruletoProlog translator, and assert the result.
See Chapter 9 (I think) of O'Keefe's "The Craft of Prolog" for more
examples, and discussion.
The all...where construct was intended to act like a setformer in maths.
An example log:
? grips.
: 1+2.
Result = 3.
: do consult(user).
 b(1). b(2). b(3).

Done
: all X where b(X).
Result = [3, 2, 1].
This means that the GRIPS translator has to recognise all...where and act
accordingly, translating it into a call to fpbagof. 'all' and 'where'
are declared as operators, with associativities and precedences chosen
to give the right effect. If this doesn't work on your system, it may be
because mine assumes priorities in the range 1..255. Some systems assume
a wider range of 1..1200, in which case, you'll have to adjust the
precedence numbers.
Jocelyn