Remote
context
Standard
formal (Chomsky) grammars make it very difficult (although theoretically
possible) to control productions on the basis of a
remote
context,
i.e. the occurrence of a string located
anywhere
to the left or right side of the derivation position. Therefore a special
syntax of remote contexts is available in BP2.
Remote
contexts are represented between ordinary brackets in the left argument of a rul
e.
These brackets are not confused with pattern delimiters because they neither
contain '=' nor ':'.
For
instance, a rule like
(a
b c) X Y (c d) --> X e f
means
that "X Y" may be rewritten as "X e f" only if "a b c" is found somewhere
before "X Y" in the string under derivation, and "c d" somewhere after "X Y".
Note that "X" itself is a left context in the sense of conventional generative
grammars.
A
remote contex
t
may contain any string in BP syntax, including string patterns and
metavariables. It may also be negative. For instance,
#(a
b c) X --> c d e
means
that "X" may be rewritten as "c d e" only if not preceded by "a b c" in the
string under derivation.
Below
is a typical grammar using remote contexts (see "-gr.bell
s").
The problem was to generate sequences of permutations of 'a', 'b', 'c', 'd',
using simple transformations, given that sequences are never repeated. (This
problem is borrowed from the traditional art of composing bell-ringing tunes,
see Bel 1990c,1992) The sequence must begin and end with "ABCD", hence the
infinite-weight rule that terminates the generation.
RND
S
--> /4 Tune
Tune
--> Canonic New B A C D X12
End
Tune
--> Canonic New A C B D X23
End
Tune
--> Canonic New A B D C X34
End
Tune
--> Canonic New B A D C X1234
End
----------------------------------------------------------
LIN
<∞>
A B C D ?1 End --> A B C D [Infinite weight]
#(?1 ?2 ?4 ?3) ?1 ?2 ?3 ?4 X12 --> ?1 ?2 ?3 ?4 New ?1 ?2 ?4 ?3
X34
#(?2 ?1 ?4 ?3) ?1 ?2 ?3 ?4 X12 --> ?1 ?2 ?3 ?4 New ?2 ?1 ?4 ?3
X1234
#(?2 ?1 ?4 ?3) ?1 ?2 ?3 ?4 X34 --> ?1 ?2 ?3 ?4 New ?2 ?1 ?4 ?3
X1234
#(?2 ?1 ?3 ?4) ?1 ?2 ?3 ?4 X34 --> ?1 ?2 ?3 ?4 New ?2 ?1 ?3 ?4
X12
#(?2 ?1 ?4 ?3) ?1 ?2 ?3 ?4 X23 --> ?1 ?2 ?3 ?4 New ?2 ?1 ?4 ?3
X1234
#(?2 ?1 ?3 ?4) ?1 ?2 ?3 ?4 X1234 --> ?1 ?2 ?3 ?4 New ?2 ?1 ?3 ?4
X12
#(?1 ?3 ?2 ?4) ?1 ?2 ?3 ?4 X1234 --> ?1 ?2 ?3 ?4 New ?1 ?3 ?2 ?4
X23
#(?1 ?2 ?4 ?3) ?1 ?2 ?3 ?4 X1234 --> ?1 ?2 ?3 ?4 New ?1 ?2 ?4 ?3
X34
-----------------------------------------------------------
ORD
[These
rules are needed in case the infinite-weight rule could not be applied]
LEFT
X12 --> lambda
LEFT
X34 --> lambda
LEFT
X23 --> lambda
LEFT
X1234 --> lambda
LEFT
End --> lambda
LEFT
New --> lambda
LEFT
Canonic --> A B C D
-----------------------------------------------------------
SUB
[Tuning
bells... See substitutions §4.14]
A
B --> do3 B
A
#B --> do4 #B
B
--> sol3
B
--> sol4
C
--> re4
C
--> re5
D
A --> mi4 A
D
#A --> mi5 #A