[r-t] Rule Based Construction Notation

Richard Smith richard at ex-parrot.com
Fri Aug 1 11:47:21 UTC 2008

```Graham John wrote (slightly reordered):

> It seems quite concise for these examples.
>
> 720 PB Minor
>
> x16
> (1 = 1), x12
> (1 = 1 & 6 > 4 & 5 < 5), x14
> (1456 = 1456), x1234

1256 = 1256, I hope.

What you've written gives a 240: WHWsHx2.

When I wrote gsiril, the MicroSiril clone that is in the
Ringing Class Library, I added this functionality to it.

http://www.ex-parrot.com/~richard/gsiril/

The syntax I used is a bit different to yours (and uglier)
because I wanted to retain compatibility with MicroSiril
(well, nearly), which meant routing around for more obscure
symbols to use.

So, for example,

6 bells;
prove repeat( +-, {
+1234, /12*56/ : +1234, "s @";
+14, /1*6?/ || /1*[234]6/ : +14, "- @";
+12, /1*/ : +12;
+16;
},  { /123456/ : break } )

What does this do?

'repeat' means repeat its argument indefinitely.  In this
case, its argument is a sequence of three things:

- a piece of place-notation, +-, i.e. the cross change;
per MicroSiril, a + or & prefix is required on place-
notation;

- a lengthy rule to determine whether the next change is a
16, 12, 14 or 1234;

- a rule to see whether we've come back to rounds, and if
so, exit the loop: this is the { /123456/ : break } bit.

The rule to select one of 16, 12, 14 or 1234 is the
interesting bit.  The syntax is

{ test1 : result1 ; test2 : result2 ; ... ; default }

It evaluates test1, and if it is true applies result1 to the
composition.  If test1 fails, test2 is tried, and so on.  If
all tests fail, the default result is applied.  The cunning
bit is that within the test, you can speculatively continue
adding bits to the composition before actually doing a test.
Irrespective of the outcome of the test, these are then
unrolled.

So, +1234, /12*56/ : +1234, "s @"; means speculatively add
a 1234 single to the end of the composition and see whether
it produces a 12??56 row.  The 1234 single is then removed.
If the test succeed (i.e. if the single did produce a 12??56
row), it is reapplied.  The "s @" bit justs prints out an
's' followed by the row, just as in MicroSiril.

> 720 Kent TB Minor
>
> X12x16
> (1 < 3), 34x34.16
> (1 = 1 & 6 < 4 & 5 > 3), 34x34.14

6 bells;
prove repeat( {
+34x34.14, /16*/ || /1[234]6*/ : +34x34.14, "- @";
/1*/ || /?1*/ : +34x34.16, { /1*/: "  @" };
+-12-16;
},  { /123456/ : break } )

I'm sure that prettier syntaxes can be designed, but this
seems fairly powerful.  I frequently use it to prove magic
block peals, for example.

RAS

```