input(case1, [1, 0, 1, 0, 0, 1]).
input(case2, [1, 0, 1, 1, 1, 1]).
input(case3, [1, 1, 1, 1, 1, 1]).
input(case4, []).
output(case1, [1, 0, 1, 0, 1, 0, #]).
output(case2, [1, 1, 0, 0, 0, 0, #]).
output(case3, [1, 0, 0, 0, 0, 0, 0, #]).
output(case4, [1, #]).
addsOne(case1, true).
addsOne(case2, true).
addsOne(case3, true).
addsOne(case4, true).

clause(1,
       compute([], var('Outtape')),
       (start(anonymous(1), var('I')), find(var('I'), [], #, [], var('Outtape')))).
clause(2,
       compute([var('Head') | var('Tail')], var('Outtape')),
       (start(anonymous(1), var('I')),
        find(var('I'), [], var('Head'), var('Tail'), var('Outtape')))).
clause(3,
       find(var('State'), var('Left'), var('Cell'), var('Right'), var('Outtape')),
       (t([var('State'), var('Cell'), var('Write'), var('Move')], var('Next')),
        move(var('Move'), var('Left'), var('Write'), var('Right'), var('A'), var('B'), var('C')),
        continue(var('Next'), var('A'), var('B'), var('C'), var('Outtape')))).
clause(4,
       continue(halt, var('Left'), var('Cell'), var('Right'), var('Outtape')),
       (rever(var('Left'), var('R')),
        append(var('R'), [var('Cell') | var('Right')], var('Outtape')))).
clause(5,
       continue(var('State'), var('Left'), var('Cell'), var('Right'), var('Outtape')),
       find(var('State'), var('Left'), var('Cell'), var('Right'), var('Outtape'))).
clause(6, move(l, [], var('Cell'), var('Right'), [], #, [var('Cell') | var('Right')]), true).
clause(7,
       move(l, [var('Head') | var('Tail')], var('Cell'), var('Right'), var('Tail'), var('Head'), [var('Cell') | var('Right')]),
       true).
clause(8,
       move(s, var('Left'), var('Cell'), var('Right'), var('Left'), var('Cell'), var('Right')),
       true).
clause(9, move(r, var('Left'), var('Cell'), [], [var('Cell') | var('Left')], #, []), true).
clause(10,
       move(r, var('Left'), var('Cell'), [var('Head') | var('Tail')], [var('Cell') | var('Left')], var('Head'), var('Tail')),
       true).
clause(11, rever([], []), true).
clause(12,
       rever([var('A') | var('B')], var('C')),
       (rever(var('B'), var('D')), append(var('D'), [var('A')], var('C')))).
clause(13, start(add1, 0), true).
clause(14, t([0, 0, 0, r], 0), true).
clause(15, t([0, 1, 1, r], 0), true).
clause(16, t([0|"##l"], 1), true).
clause(17, t([1, 0, 1, s], halt), true).
clause(18, t([1, 1, 0, l], 1), true).
clause(19, t([1, #, 1, s], halt), true).
clause(20, case(case1, [1, 0, 1, 0, 0, 1]), true).
clause(21, case(case2, [1, 0, 1, 1, 1, 1]), true).
clause(22, case(case3, [1, 1, 1, 1, 1, 1]), true).
clause(23, case(case4, []), true).
clause(24, input(var('Case'), var('Intape')), case(var('Case'), var('Intape'))).
clause(25,
       output(var('Case'), var('Outtape')),
       (case(var('Case'), var('Intape')), compute(var('Intape'), var('Outtape')))).
clause(26,
       addsOne(var('Case'), true),
       (case(var('Case'), var('Intape')), compute(var('Intape'), anonymous(1)))).

step(input(case1, [1, 0, 1, 0, 0, 1]),
     rule(24),
     ['Case' = case1, 'Intape' = [1, 0, 1, 0, 0, 1]],
     [case(case1, [1, 0, 1, 0, 0, 1])]).
step(case(case1, [1, 0, 1, 0, 0, 1]), fact(20), [], []).
step(input(case2, [1, 0, 1, 1, 1, 1]),
     rule(24),
     ['Case' = case2, 'Intape' = [1, 0, 1, 1, 1, 1]],
     [case(case2, [1, 0, 1, 1, 1, 1])]).
step(case(case2, [1, 0, 1, 1, 1, 1]), fact(21), [], []).
step(input(case3, [1, 1, 1, 1, 1, 1]),
     rule(24),
     ['Case' = case3, 'Intape' = [1, 1, 1, 1, 1, 1]],
     [case(case3, [1, 1, 1, 1, 1, 1])]).
step(case(case3, [1, 1, 1, 1, 1, 1]), fact(22), [], []).
step(input(case4, []), rule(24), ['Case' = case4, 'Intape' = []], [case(case4, [])]).
step(case(case4, []), fact(23), [], []).
step(output(case1, [1, 0, 1, 0, 1, 0, #]),
     rule(25),
     ['Case' = case1, 'Outtape' = [1, 0, 1, 0, 1, 0, #], 'Intape' = [1, 0, 1, 0, 0, 1]],
     [case(case1, [1, 0, 1, 0, 0, 1]), compute([1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(compute([1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #]),
     rule(2),
     ['Head' = 1, 'Tail' = [0, 1, 0, 0, 1], 'Outtape' = [1, 0, 1, 0, 1, 0, #], 'I' = 0],
     [start(add1, 0), find(0, [], 1, [0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(start(add1, 0), fact(13), [], []).
step(find(0, [], 1, [0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [],
      'Cell' = 1,
      'Right' = [0, 1, 0, 0, 1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1],
      'B' = 0,
      'C' = [1, 0, 0, 1]],
     [t([0, 1, 1, r], 0),
      move(r, [], 1, [0, 1, 0, 0, 1], [1], 0, [1, 0, 0, 1]),
      continue(0, [1], 0, [1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(t([0, 1, 1, r], 0), fact(15), [], []).
step(move(r, [], 1, [0, 1, 0, 0, 1], [1], 0, [1, 0, 0, 1]),
     fact(10),
     ['Left' = [], 'Cell' = 1, 'Head' = 0, 'Tail' = [1, 0, 0, 1]],
     []).
step(continue(0, [1], 0, [1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1],
      'Cell' = 0,
      'Right' = [1, 0, 0, 1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #]],
     [find(0, [1], 0, [1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(find(0, [1], 0, [1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1],
      'Cell' = 0,
      'Right' = [1, 0, 0, 1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = 0,
      'Move' = r,
      'Next' = 0,
      'A' = [0, 1],
      'B' = 1,
      'C' = [0, 0, 1]],
     [t([0, 0, 0, r], 0),
      move(r, [1], 0, [1, 0, 0, 1], [0, 1], 1, [0, 0, 1]),
      continue(0, [0, 1], 1, [0, 0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(t([0, 0, 0, r], 0), fact(14), [], []).
step(move(r, [1], 0, [1, 0, 0, 1], [0, 1], 1, [0, 0, 1]),
     fact(10),
     ['Left' = [1], 'Cell' = 0, 'Head' = 1, 'Tail' = [0, 0, 1]],
     []).
step(continue(0, [0, 1], 1, [0, 0, 1], [1, 0, 1, 0, 1, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [0, 1],
      'Cell' = 1,
      'Right' = [0, 0, 1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #]],
     [find(0, [0, 1], 1, [0, 0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(find(0, [0, 1], 1, [0, 0, 1], [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [0, 1],
      'Cell' = 1,
      'Right' = [0, 0, 1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 0, 1],
      'B' = 0,
      'C' = [0, 1]],
     [t([0, 1, 1, r], 0),
      move(r, [0, 1], 1, [0, 0, 1], [1, 0, 1], 0, [0, 1]),
      continue(0, [1, 0, 1], 0, [0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(move(r, [0, 1], 1, [0, 0, 1], [1, 0, 1], 0, [0, 1]),
     fact(10),
     ['Left' = [0, 1], 'Cell' = 1, 'Head' = 0, 'Tail' = [0, 1]],
     []).
step(continue(0, [1, 0, 1], 0, [0, 1], [1, 0, 1, 0, 1, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 0, 1],
      'Cell' = 0,
      'Right' = [0, 1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #]],
     [find(0, [1, 0, 1], 0, [0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(find(0, [1, 0, 1], 0, [0, 1], [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 0, 1],
      'Cell' = 0,
      'Right' = [0, 1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = 0,
      'Move' = r,
      'Next' = 0,
      'A' = [0, 1, 0, 1],
      'B' = 0,
      'C' = [1]],
     [t([0, 0, 0, r], 0),
      move(r, [1, 0, 1], 0, [0, 1], [0, 1, 0, 1], 0, [1]),
      continue(0, [0, 1, 0, 1], 0, [1], [1, 0, 1, 0, 1, 0, #])]).
step(move(r, [1, 0, 1], 0, [0, 1], [0, 1, 0, 1], 0, [1]),
     fact(10),
     ['Left' = [1, 0, 1], 'Cell' = 0, 'Head' = 0, 'Tail' = [1]],
     []).
step(continue(0, [0, 1, 0, 1], 0, [1], [1, 0, 1, 0, 1, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [0, 1, 0, 1],
      'Cell' = 0,
      'Right' = [1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #]],
     [find(0, [0, 1, 0, 1], 0, [1], [1, 0, 1, 0, 1, 0, #])]).
step(find(0, [0, 1, 0, 1], 0, [1], [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [0, 1, 0, 1],
      'Cell' = 0,
      'Right' = [1],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = 0,
      'Move' = r,
      'Next' = 0,
      'A' = [0, 0, 1, 0, 1],
      'B' = 1,
      'C' = []],
     [t([0, 0, 0, r], 0),
      move(r, [0, 1, 0, 1], 0, [1], [0, 0, 1, 0, 1], 1, []),
      continue(0, [0, 0, 1, 0, 1], 1, [], [1, 0, 1, 0, 1, 0, #])]).
step(move(r, [0, 1, 0, 1], 0, [1], [0, 0, 1, 0, 1], 1, []),
     fact(10),
     ['Left' = [0, 1, 0, 1], 'Cell' = 0, 'Head' = 1, 'Tail' = []],
     []).
step(continue(0, [0, 0, 1, 0, 1], 1, [], [1, 0, 1, 0, 1, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [0, 0, 1, 0, 1],
      'Cell' = 1,
      'Right' = [],
      'Outtape' = [1, 0, 1, 0, 1, 0, #]],
     [find(0, [0, 0, 1, 0, 1], 1, [], [1, 0, 1, 0, 1, 0, #])]).
step(find(0, [0, 0, 1, 0, 1], 1, [], [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [0, 0, 1, 0, 1],
      'Cell' = 1,
      'Right' = [],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 0, 0, 1, 0, 1],
      'B' = #,
      'C' = []],
     [t([0, 1, 1, r], 0),
      move(r, [0, 0, 1, 0, 1], 1, [], [1, 0, 0, 1, 0, 1], #, []),
      continue(0, [1, 0, 0, 1, 0, 1], #, [], [1, 0, 1, 0, 1, 0, #])]).
step(move(r, [0, 0, 1, 0, 1], 1, [], [1, 0, 0, 1, 0, 1], #, []),
     fact(9),
     ['Left' = [0, 0, 1, 0, 1], 'Cell' = 1],
     []).
step(continue(0, [1, 0, 0, 1, 0, 1], #, [], [1, 0, 1, 0, 1, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 0, 0, 1, 0, 1],
      'Cell' = #,
      'Right' = [],
      'Outtape' = [1, 0, 1, 0, 1, 0, #]],
     [find(0, [1, 0, 0, 1, 0, 1], #, [], [1, 0, 1, 0, 1, 0, #])]).
step(find(0, [1, 0, 0, 1, 0, 1], #, [], [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 0, 0, 1, 0, 1],
      'Cell' = #,
      'Right' = [],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = #,
      'Move' = l,
      'Next' = 1,
      'A' = [0, 0, 1, 0, 1],
      'B' = 1,
      'C' = "#"],
     [t([0|"##l"], 1),
      move(l, [1, 0, 0, 1, 0, 1], #, [], [0, 0, 1, 0, 1], 1, "#"),
      continue(1, [0, 0, 1, 0, 1], 1, "#", [1, 0, 1, 0, 1, 0, #])]).
step(t([0|"##l"], 1), fact(16), [], []).
step(move(l, [1, 0, 0, 1, 0, 1], #, [], [0, 0, 1, 0, 1], 1, "#"),
     fact(7),
     ['Head' = 1, 'Tail' = [0, 0, 1, 0, 1], 'Cell' = #, 'Right' = []],
     []).
step(continue(1, [0, 0, 1, 0, 1], 1, "#", [1, 0, 1, 0, 1, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [0, 0, 1, 0, 1],
      'Cell' = 1,
      'Right' = "#",
      'Outtape' = [1, 0, 1, 0, 1, 0, #]],
     [find(1, [0, 0, 1, 0, 1], 1, "#", [1, 0, 1, 0, 1, 0, #])]).
step(find(1, [0, 0, 1, 0, 1], 1, "#", [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [0, 0, 1, 0, 1],
      'Cell' = 1,
      'Right' = "#",
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [0, 1, 0, 1],
      'B' = 0,
      'C' = [0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [0, 0, 1, 0, 1], 0, "#", [0, 1, 0, 1], 0, [0, #]),
      continue(1, [0, 1, 0, 1], 0, [0, #], [1, 0, 1, 0, 1, 0, #])]).
step(t([1, 1, 0, l], 1), fact(18), [], []).
step(move(l, [0, 0, 1, 0, 1], 0, "#", [0, 1, 0, 1], 0, [0, #]),
     fact(7),
     ['Head' = 0, 'Tail' = [0, 1, 0, 1], 'Cell' = 0, 'Right' = "#"],
     []).
step(continue(1, [0, 1, 0, 1], 0, [0, #], [1, 0, 1, 0, 1, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [0, 1, 0, 1],
      'Cell' = 0,
      'Right' = [0, #],
      'Outtape' = [1, 0, 1, 0, 1, 0, #]],
     [find(1, [0, 1, 0, 1], 0, [0, #], [1, 0, 1, 0, 1, 0, #])]).
step(find(1, [0, 1, 0, 1], 0, [0, #], [1, 0, 1, 0, 1, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [0, 1, 0, 1],
      'Cell' = 0,
      'Right' = [0, #],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'Write' = 1,
      'Move' = s,
      'Next' = halt,
      'A' = [0, 1, 0, 1],
      'B' = 1,
      'C' = [0, #]],
     [t([1, 0, 1, s], halt),
      move(s, [0, 1, 0, 1], 1, [0, #], [0, 1, 0, 1], 1, [0, #]),
      continue(halt, [0, 1, 0, 1], 1, [0, #], [1, 0, 1, 0, 1, 0, #])]).
step(t([1, 0, 1, s], halt), fact(17), [], []).
step(move(s, [0, 1, 0, 1], 1, [0, #], [0, 1, 0, 1], 1, [0, #]),
     fact(8),
     ['Left' = [0, 1, 0, 1], 'Cell' = 1, 'Right' = [0, #]],
     []).
step(continue(halt, [0, 1, 0, 1], 1, [0, #], [1, 0, 1, 0, 1, 0, #]),
     rule(4),
     ['Left' = [0, 1, 0, 1],
      'Cell' = 1,
      'Right' = [0, #],
      'Outtape' = [1, 0, 1, 0, 1, 0, #],
      'R' = [1, 0, 1, 0]],
     [rever([0, 1, 0, 1], [1, 0, 1, 0]), append([1, 0, 1, 0], [1, 0, #], [1, 0, 1, 0, 1, 0, #])]).
step(rever([0, 1, 0, 1], [1, 0, 1, 0]),
     rule(12),
     ['A' = 0, 'B' = [1, 0, 1], 'C' = [1, 0, 1, 0], 'D' = [1, 0, 1]],
     [rever([1, 0, 1], [1, 0, 1]), append([1, 0, 1], [0], [1, 0, 1, 0])]).
step(rever([1, 0, 1], [1, 0, 1]),
     rule(12),
     ['A' = 1, 'B' = [0, 1], 'C' = [1, 0, 1], 'D' = [1, 0]],
     [rever([0, 1], [1, 0]), append([1, 0], [1], [1, 0, 1])]).
step(rever([0, 1], [1, 0]),
     rule(12),
     ['A' = 0, 'B' = [1], 'C' = [1, 0], 'D' = [1]],
     [rever([1], [1]), append([1], [0], [1, 0])]).
step(rever([1], [1]),
     rule(12),
     ['A' = 1, 'B' = [], 'C' = [1], 'D' = []],
     [rever([], []), append([], [1], [1])]).
step(rever([], []), fact(11), [], []).
step(append([], [1], [1]), builtin, [], []).
step(append([1], [0], [1, 0]), builtin, [], []).
step(append([1, 0], [1], [1, 0, 1]), builtin, [], []).
step(append([1, 0, 1], [0], [1, 0, 1, 0]), builtin, [], []).
step(append([1, 0, 1, 0], [1, 0, #], [1, 0, 1, 0, 1, 0, #]), builtin, [], []).
step(output(case2, [1, 1, 0, 0, 0, 0, #]),
     rule(25),
     ['Case' = case2, 'Outtape' = [1, 1, 0, 0, 0, 0, #], 'Intape' = [1, 0, 1, 1, 1, 1]],
     [case(case2, [1, 0, 1, 1, 1, 1]), compute([1, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(compute([1, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #]),
     rule(2),
     ['Head' = 1, 'Tail' = [0, 1, 1, 1, 1], 'Outtape' = [1, 1, 0, 0, 0, 0, #], 'I' = 0],
     [start(add1, 0), find(0, [], 1, [0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(find(0, [], 1, [0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [],
      'Cell' = 1,
      'Right' = [0, 1, 1, 1, 1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1],
      'B' = 0,
      'C' = [1, 1, 1, 1]],
     [t([0, 1, 1, r], 0),
      move(r, [], 1, [0, 1, 1, 1, 1], [1], 0, [1, 1, 1, 1]),
      continue(0, [1], 0, [1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(move(r, [], 1, [0, 1, 1, 1, 1], [1], 0, [1, 1, 1, 1]),
     fact(10),
     ['Left' = [], 'Cell' = 1, 'Head' = 0, 'Tail' = [1, 1, 1, 1]],
     []).
step(continue(0, [1], 0, [1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1],
      'Cell' = 0,
      'Right' = [1, 1, 1, 1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(0, [1], 0, [1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(find(0, [1], 0, [1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1],
      'Cell' = 0,
      'Right' = [1, 1, 1, 1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = r,
      'Next' = 0,
      'A' = [0, 1],
      'B' = 1,
      'C' = [1, 1, 1]],
     [t([0, 0, 0, r], 0),
      move(r, [1], 0, [1, 1, 1, 1], [0, 1], 1, [1, 1, 1]),
      continue(0, [0, 1], 1, [1, 1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(move(r, [1], 0, [1, 1, 1, 1], [0, 1], 1, [1, 1, 1]),
     fact(10),
     ['Left' = [1], 'Cell' = 0, 'Head' = 1, 'Tail' = [1, 1, 1]],
     []).
step(continue(0, [0, 1], 1, [1, 1, 1], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [0, 1],
      'Cell' = 1,
      'Right' = [1, 1, 1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(0, [0, 1], 1, [1, 1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(find(0, [0, 1], 1, [1, 1, 1], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [0, 1],
      'Cell' = 1,
      'Right' = [1, 1, 1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 0, 1],
      'B' = 1,
      'C' = [1, 1]],
     [t([0, 1, 1, r], 0),
      move(r, [0, 1], 1, [1, 1, 1], [1, 0, 1], 1, [1, 1]),
      continue(0, [1, 0, 1], 1, [1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(move(r, [0, 1], 1, [1, 1, 1], [1, 0, 1], 1, [1, 1]),
     fact(10),
     ['Left' = [0, 1], 'Cell' = 1, 'Head' = 1, 'Tail' = [1, 1]],
     []).
step(continue(0, [1, 0, 1], 1, [1, 1], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 0, 1],
      'Cell' = 1,
      'Right' = [1, 1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(0, [1, 0, 1], 1, [1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(find(0, [1, 0, 1], 1, [1, 1], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 0, 1],
      'Cell' = 1,
      'Right' = [1, 1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 1, 0, 1],
      'B' = 1,
      'C' = [1]],
     [t([0, 1, 1, r], 0),
      move(r, [1, 0, 1], 1, [1, 1], [1, 1, 0, 1], 1, [1]),
      continue(0, [1, 1, 0, 1], 1, [1], [1, 1, 0, 0, 0, 0, #])]).
step(move(r, [1, 0, 1], 1, [1, 1], [1, 1, 0, 1], 1, [1]),
     fact(10),
     ['Left' = [1, 0, 1], 'Cell' = 1, 'Head' = 1, 'Tail' = [1]],
     []).
step(continue(0, [1, 1, 0, 1], 1, [1], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 1, 0, 1],
      'Cell' = 1,
      'Right' = [1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(0, [1, 1, 0, 1], 1, [1], [1, 1, 0, 0, 0, 0, #])]).
step(find(0, [1, 1, 0, 1], 1, [1], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 1, 0, 1],
      'Cell' = 1,
      'Right' = [1],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 1, 1, 0, 1],
      'B' = 1,
      'C' = []],
     [t([0, 1, 1, r], 0),
      move(r, [1, 1, 0, 1], 1, [1], [1, 1, 1, 0, 1], 1, []),
      continue(0, [1, 1, 1, 0, 1], 1, [], [1, 1, 0, 0, 0, 0, #])]).
step(move(r, [1, 1, 0, 1], 1, [1], [1, 1, 1, 0, 1], 1, []),
     fact(10),
     ['Left' = [1, 1, 0, 1], 'Cell' = 1, 'Head' = 1, 'Tail' = []],
     []).
step(continue(0, [1, 1, 1, 0, 1], 1, [], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 1, 1, 0, 1],
      'Cell' = 1,
      'Right' = [],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(0, [1, 1, 1, 0, 1], 1, [], [1, 1, 0, 0, 0, 0, #])]).
step(find(0, [1, 1, 1, 0, 1], 1, [], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 1, 1, 0, 1],
      'Cell' = 1,
      'Right' = [],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 1, 1, 1, 0, 1],
      'B' = #,
      'C' = []],
     [t([0, 1, 1, r], 0),
      move(r, [1, 1, 1, 0, 1], 1, [], [1, 1, 1, 1, 0, 1], #, []),
      continue(0, [1, 1, 1, 1, 0, 1], #, [], [1, 1, 0, 0, 0, 0, #])]).
step(move(r, [1, 1, 1, 0, 1], 1, [], [1, 1, 1, 1, 0, 1], #, []),
     fact(9),
     ['Left' = [1, 1, 1, 0, 1], 'Cell' = 1],
     []).
step(continue(0, [1, 1, 1, 1, 0, 1], #, [], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 1, 1, 1, 0, 1],
      'Cell' = #,
      'Right' = [],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(0, [1, 1, 1, 1, 0, 1], #, [], [1, 1, 0, 0, 0, 0, #])]).
step(find(0, [1, 1, 1, 1, 0, 1], #, [], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 1, 1, 1, 0, 1],
      'Cell' = #,
      'Right' = [],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = #,
      'Move' = l,
      'Next' = 1,
      'A' = [1, 1, 1, 0, 1],
      'B' = 1,
      'C' = "#"],
     [t([0|"##l"], 1),
      move(l, [1, 1, 1, 1, 0, 1], #, [], [1, 1, 1, 0, 1], 1, "#"),
      continue(1, [1, 1, 1, 0, 1], 1, "#", [1, 1, 0, 0, 0, 0, #])]).
step(move(l, [1, 1, 1, 1, 0, 1], #, [], [1, 1, 1, 0, 1], 1, "#"),
     fact(7),
     ['Head' = 1, 'Tail' = [1, 1, 1, 0, 1], 'Cell' = #, 'Right' = []],
     []).
step(continue(1, [1, 1, 1, 0, 1], 1, "#", [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1, 1, 1, 0, 1],
      'Cell' = 1,
      'Right' = "#",
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(1, [1, 1, 1, 0, 1], 1, "#", [1, 1, 0, 0, 0, 0, #])]).
step(find(1, [1, 1, 1, 0, 1], 1, "#", [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1, 1, 1, 0, 1],
      'Cell' = 1,
      'Right' = "#",
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [1, 1, 0, 1],
      'B' = 1,
      'C' = [0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [1, 1, 1, 0, 1], 0, "#", [1, 1, 0, 1], 1, [0, #]),
      continue(1, [1, 1, 0, 1], 1, [0, #], [1, 1, 0, 0, 0, 0, #])]).
step(move(l, [1, 1, 1, 0, 1], 0, "#", [1, 1, 0, 1], 1, [0, #]),
     fact(7),
     ['Head' = 1, 'Tail' = [1, 1, 0, 1], 'Cell' = 0, 'Right' = "#"],
     []).
step(continue(1, [1, 1, 0, 1], 1, [0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1, 1, 0, 1],
      'Cell' = 1,
      'Right' = [0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(1, [1, 1, 0, 1], 1, [0, #], [1, 1, 0, 0, 0, 0, #])]).
step(find(1, [1, 1, 0, 1], 1, [0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1, 1, 0, 1],
      'Cell' = 1,
      'Right' = [0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [1, 0, 1],
      'B' = 1,
      'C' = [0, 0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [1, 1, 0, 1], 0, [0, #], [1, 0, 1], 1, [0, 0, #]),
      continue(1, [1, 0, 1], 1, [0, 0, #], [1, 1, 0, 0, 0, 0, #])]).
step(move(l, [1, 1, 0, 1], 0, [0, #], [1, 0, 1], 1, [0, 0, #]),
     fact(7),
     ['Head' = 1, 'Tail' = [1, 0, 1], 'Cell' = 0, 'Right' = [0, #]],
     []).
step(continue(1, [1, 0, 1], 1, [0, 0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1, 0, 1],
      'Cell' = 1,
      'Right' = [0, 0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(1, [1, 0, 1], 1, [0, 0, #], [1, 1, 0, 0, 0, 0, #])]).
step(find(1, [1, 0, 1], 1, [0, 0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1, 0, 1],
      'Cell' = 1,
      'Right' = [0, 0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [0, 1],
      'B' = 1,
      'C' = [0, 0, 0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [1, 0, 1], 0, [0, 0, #], [0, 1], 1, [0, 0, 0, #]),
      continue(1, [0, 1], 1, [0, 0, 0, #], [1, 1, 0, 0, 0, 0, #])]).
step(move(l, [1, 0, 1], 0, [0, 0, #], [0, 1], 1, [0, 0, 0, #]),
     fact(7),
     ['Head' = 1, 'Tail' = [0, 1], 'Cell' = 0, 'Right' = [0, 0, #]],
     []).
step(continue(1, [0, 1], 1, [0, 0, 0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [0, 1],
      'Cell' = 1,
      'Right' = [0, 0, 0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(1, [0, 1], 1, [0, 0, 0, #], [1, 1, 0, 0, 0, 0, #])]).
step(find(1, [0, 1], 1, [0, 0, 0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [0, 1],
      'Cell' = 1,
      'Right' = [0, 0, 0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [1],
      'B' = 0,
      'C' = [0, 0, 0, 0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [0, 1], 0, [0, 0, 0, #], [1], 0, [0, 0, 0, 0, #]),
      continue(1, [1], 0, [0, 0, 0, 0, #], [1, 1, 0, 0, 0, 0, #])]).
step(move(l, [0, 1], 0, [0, 0, 0, #], [1], 0, [0, 0, 0, 0, #]),
     fact(7),
     ['Head' = 0, 'Tail' = [1], 'Cell' = 0, 'Right' = [0, 0, 0, #]],
     []).
step(continue(1, [1], 0, [0, 0, 0, 0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1],
      'Cell' = 0,
      'Right' = [0, 0, 0, 0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #]],
     [find(1, [1], 0, [0, 0, 0, 0, #], [1, 1, 0, 0, 0, 0, #])]).
step(find(1, [1], 0, [0, 0, 0, 0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1],
      'Cell' = 0,
      'Right' = [0, 0, 0, 0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = s,
      'Next' = halt,
      'A' = [1],
      'B' = 1,
      'C' = [0, 0, 0, 0, #]],
     [t([1, 0, 1, s], halt),
      move(s, [1], 1, [0, 0, 0, 0, #], [1], 1, [0, 0, 0, 0, #]),
      continue(halt, [1], 1, [0, 0, 0, 0, #], [1, 1, 0, 0, 0, 0, #])]).
step(move(s, [1], 1, [0, 0, 0, 0, #], [1], 1, [0, 0, 0, 0, #]),
     fact(8),
     ['Left' = [1], 'Cell' = 1, 'Right' = [0, 0, 0, 0, #]],
     []).
step(continue(halt, [1], 1, [0, 0, 0, 0, #], [1, 1, 0, 0, 0, 0, #]),
     rule(4),
     ['Left' = [1],
      'Cell' = 1,
      'Right' = [0, 0, 0, 0, #],
      'Outtape' = [1, 1, 0, 0, 0, 0, #],
      'R' = [1]],
     [rever([1], [1]), append([1], [1, 0, 0, 0, 0, #], [1, 1, 0, 0, 0, 0, #])]).
step(append([1], [1, 0, 0, 0, 0, #], [1, 1, 0, 0, 0, 0, #]), builtin, [], []).
step(output(case3, [1, 0, 0, 0, 0, 0, 0, #]),
     rule(25),
     ['Case' = case3, 'Outtape' = [1, 0, 0, 0, 0, 0, 0, #], 'Intape' = [1, 1, 1, 1, 1, 1]],
     [case(case3, [1, 1, 1, 1, 1, 1]), compute([1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(compute([1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(2),
     ['Head' = 1, 'Tail' = [1, 1, 1, 1, 1], 'Outtape' = [1, 0, 0, 0, 0, 0, 0, #], 'I' = 0],
     [start(add1, 0), find(0, [], 1, [1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(0, [], 1, [1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [],
      'Cell' = 1,
      'Right' = [1, 1, 1, 1, 1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1],
      'B' = 1,
      'C' = [1, 1, 1, 1]],
     [t([0, 1, 1, r], 0),
      move(r, [], 1, [1, 1, 1, 1, 1], [1], 1, [1, 1, 1, 1]),
      continue(0, [1], 1, [1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(r, [], 1, [1, 1, 1, 1, 1], [1], 1, [1, 1, 1, 1]),
     fact(10),
     ['Left' = [], 'Cell' = 1, 'Head' = 1, 'Tail' = [1, 1, 1, 1]],
     []).
step(continue(0, [1], 1, [1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1],
      'Cell' = 1,
      'Right' = [1, 1, 1, 1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(0, [1], 1, [1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(0, [1], 1, [1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1],
      'Cell' = 1,
      'Right' = [1, 1, 1, 1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 1],
      'B' = 1,
      'C' = [1, 1, 1]],
     [t([0, 1, 1, r], 0),
      move(r, [1], 1, [1, 1, 1, 1], [1, 1], 1, [1, 1, 1]),
      continue(0, [1, 1], 1, [1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(r, [1], 1, [1, 1, 1, 1], [1, 1], 1, [1, 1, 1]),
     fact(10),
     ['Left' = [1], 'Cell' = 1, 'Head' = 1, 'Tail' = [1, 1, 1]],
     []).
step(continue(0, [1, 1], 1, [1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 1],
      'Cell' = 1,
      'Right' = [1, 1, 1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(0, [1, 1], 1, [1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(0, [1, 1], 1, [1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 1],
      'Cell' = 1,
      'Right' = [1, 1, 1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 1, 1],
      'B' = 1,
      'C' = [1, 1]],
     [t([0, 1, 1, r], 0),
      move(r, [1, 1], 1, [1, 1, 1], [1, 1, 1], 1, [1, 1]),
      continue(0, [1, 1, 1], 1, [1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(r, [1, 1], 1, [1, 1, 1], [1, 1, 1], 1, [1, 1]),
     fact(10),
     ['Left' = [1, 1], 'Cell' = 1, 'Head' = 1, 'Tail' = [1, 1]],
     []).
step(continue(0, [1, 1, 1], 1, [1, 1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 1, 1],
      'Cell' = 1,
      'Right' = [1, 1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(0, [1, 1, 1], 1, [1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(0, [1, 1, 1], 1, [1, 1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 1, 1],
      'Cell' = 1,
      'Right' = [1, 1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 1, 1, 1],
      'B' = 1,
      'C' = [1]],
     [t([0, 1, 1, r], 0),
      move(r, [1, 1, 1], 1, [1, 1], [1, 1, 1, 1], 1, [1]),
      continue(0, [1, 1, 1, 1], 1, [1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(r, [1, 1, 1], 1, [1, 1], [1, 1, 1, 1], 1, [1]),
     fact(10),
     ['Left' = [1, 1, 1], 'Cell' = 1, 'Head' = 1, 'Tail' = [1]],
     []).
step(continue(0, [1, 1, 1, 1], 1, [1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 1, 1, 1],
      'Cell' = 1,
      'Right' = [1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(0, [1, 1, 1, 1], 1, [1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(0, [1, 1, 1, 1], 1, [1], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 1, 1, 1],
      'Cell' = 1,
      'Right' = [1],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 1, 1, 1, 1],
      'B' = 1,
      'C' = []],
     [t([0, 1, 1, r], 0),
      move(r, [1, 1, 1, 1], 1, [1], [1, 1, 1, 1, 1], 1, []),
      continue(0, [1, 1, 1, 1, 1], 1, [], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(r, [1, 1, 1, 1], 1, [1], [1, 1, 1, 1, 1], 1, []),
     fact(10),
     ['Left' = [1, 1, 1, 1], 'Cell' = 1, 'Head' = 1, 'Tail' = []],
     []).
step(continue(0, [1, 1, 1, 1, 1], 1, [], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 1, 1, 1, 1],
      'Cell' = 1,
      'Right' = [],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(0, [1, 1, 1, 1, 1], 1, [], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(0, [1, 1, 1, 1, 1], 1, [], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 1, 1, 1, 1],
      'Cell' = 1,
      'Right' = [],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = r,
      'Next' = 0,
      'A' = [1, 1, 1, 1, 1, 1],
      'B' = #,
      'C' = []],
     [t([0, 1, 1, r], 0),
      move(r, [1, 1, 1, 1, 1], 1, [], [1, 1, 1, 1, 1, 1], #, []),
      continue(0, [1, 1, 1, 1, 1, 1], #, [], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(r, [1, 1, 1, 1, 1], 1, [], [1, 1, 1, 1, 1, 1], #, []),
     fact(9),
     ['Left' = [1, 1, 1, 1, 1], 'Cell' = 1],
     []).
step(continue(0, [1, 1, 1, 1, 1, 1], #, [], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 0,
      'Left' = [1, 1, 1, 1, 1, 1],
      'Cell' = #,
      'Right' = [],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(0, [1, 1, 1, 1, 1, 1], #, [], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(0, [1, 1, 1, 1, 1, 1], #, [], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 0,
      'Left' = [1, 1, 1, 1, 1, 1],
      'Cell' = #,
      'Right' = [],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = #,
      'Move' = l,
      'Next' = 1,
      'A' = [1, 1, 1, 1, 1],
      'B' = 1,
      'C' = "#"],
     [t([0|"##l"], 1),
      move(l, [1, 1, 1, 1, 1, 1], #, [], [1, 1, 1, 1, 1], 1, "#"),
      continue(1, [1, 1, 1, 1, 1], 1, "#", [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(l, [1, 1, 1, 1, 1, 1], #, [], [1, 1, 1, 1, 1], 1, "#"),
     fact(7),
     ['Head' = 1, 'Tail' = [1, 1, 1, 1, 1], 'Cell' = #, 'Right' = []],
     []).
step(continue(1, [1, 1, 1, 1, 1], 1, "#", [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1, 1, 1, 1, 1],
      'Cell' = 1,
      'Right' = "#",
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(1, [1, 1, 1, 1, 1], 1, "#", [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(1, [1, 1, 1, 1, 1], 1, "#", [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1, 1, 1, 1, 1],
      'Cell' = 1,
      'Right' = "#",
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [1, 1, 1, 1],
      'B' = 1,
      'C' = [0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [1, 1, 1, 1, 1], 0, "#", [1, 1, 1, 1], 1, [0, #]),
      continue(1, [1, 1, 1, 1], 1, [0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(l, [1, 1, 1, 1, 1], 0, "#", [1, 1, 1, 1], 1, [0, #]),
     fact(7),
     ['Head' = 1, 'Tail' = [1, 1, 1, 1], 'Cell' = 0, 'Right' = "#"],
     []).
step(continue(1, [1, 1, 1, 1], 1, [0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1, 1, 1, 1],
      'Cell' = 1,
      'Right' = [0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(1, [1, 1, 1, 1], 1, [0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(1, [1, 1, 1, 1], 1, [0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1, 1, 1, 1],
      'Cell' = 1,
      'Right' = [0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [1, 1, 1],
      'B' = 1,
      'C' = [0, 0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [1, 1, 1, 1], 0, [0, #], [1, 1, 1], 1, [0, 0, #]),
      continue(1, [1, 1, 1], 1, [0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(l, [1, 1, 1, 1], 0, [0, #], [1, 1, 1], 1, [0, 0, #]),
     fact(7),
     ['Head' = 1, 'Tail' = [1, 1, 1], 'Cell' = 0, 'Right' = [0, #]],
     []).
step(continue(1, [1, 1, 1], 1, [0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1, 1, 1],
      'Cell' = 1,
      'Right' = [0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(1, [1, 1, 1], 1, [0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(1, [1, 1, 1], 1, [0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1, 1, 1],
      'Cell' = 1,
      'Right' = [0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [1, 1],
      'B' = 1,
      'C' = [0, 0, 0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [1, 1, 1], 0, [0, 0, #], [1, 1], 1, [0, 0, 0, #]),
      continue(1, [1, 1], 1, [0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(l, [1, 1, 1], 0, [0, 0, #], [1, 1], 1, [0, 0, 0, #]),
     fact(7),
     ['Head' = 1, 'Tail' = [1, 1], 'Cell' = 0, 'Right' = [0, 0, #]],
     []).
step(continue(1, [1, 1], 1, [0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1, 1],
      'Cell' = 1,
      'Right' = [0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(1, [1, 1], 1, [0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(1, [1, 1], 1, [0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1, 1],
      'Cell' = 1,
      'Right' = [0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [1],
      'B' = 1,
      'C' = [0, 0, 0, 0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [1, 1], 0, [0, 0, 0, #], [1], 1, [0, 0, 0, 0, #]),
      continue(1, [1], 1, [0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(l, [1, 1], 0, [0, 0, 0, #], [1], 1, [0, 0, 0, 0, #]),
     fact(7),
     ['Head' = 1, 'Tail' = [1], 'Cell' = 0, 'Right' = [0, 0, 0, #]],
     []).
step(continue(1, [1], 1, [0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [1],
      'Cell' = 1,
      'Right' = [0, 0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(1, [1], 1, [0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(1, [1], 1, [0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [1],
      'Cell' = 1,
      'Right' = [0, 0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [],
      'B' = 1,
      'C' = [0, 0, 0, 0, 0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [1], 0, [0, 0, 0, 0, #], [], 1, [0, 0, 0, 0, 0, #]),
      continue(1, [], 1, [0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(l, [1], 0, [0, 0, 0, 0, #], [], 1, [0, 0, 0, 0, 0, #]),
     fact(7),
     ['Head' = 1, 'Tail' = [], 'Cell' = 0, 'Right' = [0, 0, 0, 0, #]],
     []).
step(continue(1, [], 1, [0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [],
      'Cell' = 1,
      'Right' = [0, 0, 0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(1, [], 1, [0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(1, [], 1, [0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [],
      'Cell' = 1,
      'Right' = [0, 0, 0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 0,
      'Move' = l,
      'Next' = 1,
      'A' = [],
      'B' = #,
      'C' = [0, 0, 0, 0, 0, 0, #]],
     [t([1, 1, 0, l], 1),
      move(l, [], 0, [0, 0, 0, 0, 0, #], [], #, [0, 0, 0, 0, 0, 0, #]),
      continue(1, [], #, [0, 0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(move(l, [], 0, [0, 0, 0, 0, 0, #], [], #, [0, 0, 0, 0, 0, 0, #]),
     fact(6),
     ['Cell' = 0, 'Right' = [0, 0, 0, 0, 0, #]],
     []).
step(continue(1, [], #, [0, 0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(5),
     ['State' = 1,
      'Left' = [],
      'Cell' = #,
      'Right' = [0, 0, 0, 0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #]],
     [find(1, [], #, [0, 0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(find(1, [], #, [0, 0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(3),
     ['State' = 1,
      'Left' = [],
      'Cell' = #,
      'Right' = [0, 0, 0, 0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'Write' = 1,
      'Move' = s,
      'Next' = halt,
      'A' = [],
      'B' = 1,
      'C' = [0, 0, 0, 0, 0, 0, #]],
     [t([1, #, 1, s], halt),
      move(s, [], 1, [0, 0, 0, 0, 0, 0, #], [], 1, [0, 0, 0, 0, 0, 0, #]),
      continue(halt, [], 1, [0, 0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(t([1, #, 1, s], halt), fact(19), [], []).
step(move(s, [], 1, [0, 0, 0, 0, 0, 0, #], [], 1, [0, 0, 0, 0, 0, 0, #]),
     fact(8),
     ['Left' = [], 'Cell' = 1, 'Right' = [0, 0, 0, 0, 0, 0, #]],
     []).
step(continue(halt, [], 1, [0, 0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]),
     rule(4),
     ['Left' = [],
      'Cell' = 1,
      'Right' = [0, 0, 0, 0, 0, 0, #],
      'Outtape' = [1, 0, 0, 0, 0, 0, 0, #],
      'R' = []],
     [rever([], []), append([], [1, 0, 0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #])]).
step(append([], [1, 0, 0, 0, 0, 0, 0, #], [1, 0, 0, 0, 0, 0, 0, #]), builtin, [], []).
step(output(case4, [1, #]),
     rule(25),
     ['Case' = case4, 'Outtape' = [1, #], 'Intape' = []],
     [case(case4, []), compute([], [1, #])]).
step(compute([], [1, #]),
     rule(1),
     ['Outtape' = [1, #], 'I' = 0],
     [start(add1, 0), find(0, [], #, [], [1, #])]).
step(find(0, [], #, [], [1, #]),
     rule(3),
     ['State' = 0,
      'Left' = [],
      'Cell' = #,
      'Right' = [],
      'Outtape' = [1, #],
      'Write' = #,
      'Move' = l,
      'Next' = 1,
      'A' = [],
      'B' = #,
      'C' = "#"],
     [t([0|"##l"], 1), move(l, [], #, [], [], #, "#"), continue(1, [], #, "#", [1, #])]).
step(move(l, [], #, [], [], #, "#"), fact(6), ['Cell' = #, 'Right' = []], []).
step(continue(1, [], #, "#", [1, #]),
     rule(5),
     ['State' = 1, 'Left' = [], 'Cell' = #, 'Right' = "#", 'Outtape' = [1, #]],
     [find(1, [], #, "#", [1, #])]).
step(find(1, [], #, "#", [1, #]),
     rule(3),
     ['State' = 1,
      'Left' = [],
      'Cell' = #,
      'Right' = "#",
      'Outtape' = [1, #],
      'Write' = 1,
      'Move' = s,
      'Next' = halt,
      'A' = [],
      'B' = 1,
      'C' = "#"],
     [t([1, #, 1, s], halt),
      move(s, [], 1, "#", [], 1, "#"),
      continue(halt, [], 1, "#", [1, #])]).
step(move(s, [], 1, "#", [], 1, "#"), fact(8), ['Left' = [], 'Cell' = 1, 'Right' = "#"], []).
step(continue(halt, [], 1, "#", [1, #]),
     rule(4),
     ['Left' = [], 'Cell' = 1, 'Right' = "#", 'Outtape' = [1, #], 'R' = []],
     [rever([], []), append([], [1, #], [1, #])]).
step(append([], [1, #], [1, #]), builtin, [], []).
step(addsOne(case1, true),
     rule(26),
     ['Case' = case1, 'Intape' = [1, 0, 1, 0, 0, 1]],
     [case(case1, [1, 0, 1, 0, 0, 1]), compute([1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, #])]).
step(addsOne(case2, true),
     rule(26),
     ['Case' = case2, 'Intape' = [1, 0, 1, 1, 1, 1]],
     [case(case2, [1, 0, 1, 1, 1, 1]), compute([1, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, #])]).
step(addsOne(case3, true),
     rule(26),
     ['Case' = case3, 'Intape' = [1, 1, 1, 1, 1, 1]],
     [case(case3, [1, 1, 1, 1, 1, 1]), compute([1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, #])]).
step(addsOne(case4, true),
     rule(26),
     ['Case' = case4, 'Intape' = []],
     [case(case4, []), compute([], [1, #])]).
