BBOX Interpreter

Introduction

BBOX is a language for black box algorithms. We present a BBOX interpreter for GAP.

Example

Suppose we have the two BBOX programs M22.find (a finder for M22) and M22.check (a checker for M22). We can load them into GAP as follows:


gap> find := prepareblackbox("bbox/spor/M22.find");
[ [ "set", "V", 0 ], [ "rand", 1 ], [ "ord", 1, "A" ], [ "incr", "V" ], 
  [ "_if", "V", "gt", 1000, "then", "timeout" ], 
  [ "_if", "A", "notin", 1, 2, 3, 4, 5, 6, 7, 8, 11, "then", "fail" ], 
  [ "_if", "A", "noteq", 8, "then", "jmp", 2 ], [ "mu", 1, 1, 3 ], 
  [ "mu", 3, 3, 2 ], [ "set", "X", 0 ], [ "incr", "X" ], 
  [ "_if", "X", "gt", 1000, "then", "timeout" ], [ "rand", 4 ], 
  [ "cjr", 3, 4 ], [ "mu", 2, 3, 5 ], [ "ord", 5, "D" ], 
  [ "_if", "D", "notin", 2, 3, 4, 5, 6, 7, 8, 11, "then", "fail" ], 
  [ "_if", "D", "noteq", 11, "then", "jmp", 11 ], [ "mu", 5, 3, 6 ], 
  [ "mu", 5, 6, 7 ], [ "ord", 7, "E" ], 
  [ "_if", "E", "noteq", 11, "then", "jmp", 11 ], [ "oup", 2, 2, 3 ] ]
gap> check := prepareblackbox("bbox/spor/M22.check");
[ [ "chor", 1, 2 ], [ "chor", 2, 4 ], [ "mu", 1, 2, 3 ], [ "chor", 3, 11 ], 
  [ "mu", 3, 2, 4 ], [ "mu", 3, 4, 5 ], [ "chor", 5, 11 ], [ "mu", 5, 2, 6 ], 
  [ "chor", 6, 6 ] ]

Now let us use the finder to find standard generators for M22:


gap> G := MathieuGroup(22);
Group([ (1,2,3,4,5,6,7,8,9,10,11)(12,13,14,15,16,17,18,19,20,21,22), 
  (1,4,5,9,3)(2,8,10,7,6)(12,15,16,20,14)(13,19,21,18,17), 
  (1,21)(2,10,8,6)(3,13,4,17)(5,19,9,18)(11,22)(12,14,16,20) ])
gap> g := blackbox(G, find, [], rec());;
gap> a := g.gens[1];
(1,5)(2,8)(7,12)(9,22)(10,14)(11,21)(13,18)(15,16)
gap> b := g.gens[2];
(2,4,5,10)(3,18)(6,12)(7,17,22,8)(9,11,20,15)(13,16,14,19)

We can also use the checker to test them:


gap> ans := blackbox(G, check, [a,b], rec(verbose := true));
  1. chor 1 2 
  2. chor 2 4 
  3. mu 1 2 3 
  4. chor 3 11 
  5. mu 3 2 4 
  6. mu 3 4 5 
  7. chor 5 11 
  8. mu 5 2 6 
  9. chor 6 6 
rec( multiply := 4, invert := 0, power := 0, order := 5, class := 0, 
  random := 0, timetaken := 0, conjugate := 0, conjugateinplace := 0, 
  commutator := 0, vars := [  ], callstack := [  ], result := true )

Because ans.result is true, the checker succeeded.

Source code


Last updated 23rd September 2005 Valid HTML 4.01! Valid CSS!