The following short examples illustrate the usage of specific controls of the inference mechanism in grammars of Bol Processor (BP2 and BP3).
_destru
This instruction is useful in pattern grammars containing repetition and pseudo-repetition markers. For instance, the following grammar creates a sequence of two occurrences of variable "X" which may further be derived as "abc" or "de".
S --> (= X)(: X)
X --> abc
X --> de
In the first rule, (= ) is called a master parenthesis and (: ) a slave parenthesis — containing a copy of the former. This master-slave dependency is maintained throughout subsequent derivations.
The only eligible final derivations would be "abcabc" or "dede". However, the final string would be displayed for instance "(= abc)(: abc)". To obtain a usable string in which 'a', 'b', 'c' may be further instantiated as sound-objects, it is necessary to remove structural markers. The Bol Processor does it automatically once the final string has been created, i.e. there are no more candidate rules for further derivations. However, the user may want to display strings without their markers. Instruction _destru is used to this effect.
Let us consider for instance "-gr.tryDESTRU":
-se.tryDESTRU
-al.abc
// This grammar produces various patterns on alphabet …
RND
gram#1[1] <2-1> S --> (= (= X) S (:X)) (: (= X) S (:X))
gram#1[2] <2-1> X --> Y
gram#1[3] <2-1> X --> Y S Z
gram#1[4] <2-1> X --> Z
ORD
gram#2[1] LEFT S --> lambda [This is an erasing rule]
LIN
_destru
gram#3[1] X X --> abca
gram#3[2] Z Y --> abc
gram#3[3] Y Z --> cba
gram#3[4] Y Y --> cbbc
gram#3[5] Z Z --> lambda [This is an erasing rule]
The first rule in subgrammar #1 creates a self-embedding pattern in which the start symbol S is created again recursively. This recursivity might produce unlimited strings. To avoid this, each rule in subgrammar #1 is assigned initial weight "2" decreased by "1" once the rule has been fired. Therefore, no rule may be used more than 2 times. Subgrammar #2 contains a single rule deleting the left-over "S".
Subgrammar #3 destroys the structure by erasing all parentheses and master/slave markers, then it rewrites variables "X", "Y", "Z" as strings of terminal symbols. Tracing the production shows for instance that workstring
(=(= Z)(=(= Y)(: Y))(:(= Y)(: Y))(: Z))(:(= Z)(=(= Y)(: Y))(:(= Y)(: Y))(: Z))
is replaced with "Z Y Y Y Y Z Z Y Y Y Y ZZ Y Y Y Y Z Z Y Y Y Y Z".
Rewriting is then done strictly from left to right due to the LIN instruction.
The following is a series of 10 items produced by this grammar:
abccbbccbaabccbbccba
cbacbacbacbacbacbacbacbacbacbacbacba
abccbbccbaabccbbccba
cbaabccbaabc
cbacbacbacbacbacbacbacbacbacbacbacba
abcabcabcabcabcabcabcabc
abcabcabcabcabcabcabcabc
cbbcabcabcabccbbcabcabcabccbbcabcabcabccbbcabcabcabc
cbacbacbacba
cbbccbbccbacbbccbbccbacbbccbbccbacbbccbbccba
Complex patterns are visible on the following sound rendering of the first item using "-so.abc" sound-object prototypes.