Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
turing(Config, Rules, TapeIn, TapeOut) :-
|
||||
call(Config, IS, _, _, _, _),
|
||||
perform(Config, Rules, IS, {[], TapeIn}, {Ls, Rs}),
|
||||
reverse(Ls, Ls1),
|
||||
append(Ls1, Rs, TapeOut).
|
||||
|
||||
perform(Config, Rules, State, TapeIn, TapeOut) :-
|
||||
call(Config, _, FS, RS, B, Symbols),
|
||||
( memberchk(State, FS) ->
|
||||
TapeOut = TapeIn
|
||||
; memberchk(State, RS) ->
|
||||
{LeftIn, RightIn} = TapeIn,
|
||||
symbol(RightIn, Symbol, RightRem, B),
|
||||
memberchk(Symbol, Symbols),
|
||||
once(call(Rules, State, Symbol, NewSymbol, Action, NewState)),
|
||||
memberchk(NewSymbol, Symbols),
|
||||
action(Action, {LeftIn, [NewSymbol|RightRem]}, {LeftOut, RightOut}, B),
|
||||
perform(Config, Rules, NewState, {LeftOut, RightOut}, TapeOut) ).
|
||||
|
||||
symbol([], B, [], B).
|
||||
symbol([Sym|Rs], Sym, Rs, _).
|
||||
|
||||
action(left, {Lin, Rin}, {Lout, Rout}, B) :- left(Lin, Rin, Lout, Rout, B).
|
||||
action(stay, Tape, Tape, _).
|
||||
action(right, {Lin, Rin}, {Lout, Rout}, B) :- right(Lin, Rin, Lout, Rout, B).
|
||||
|
||||
left([], Rs, [], [B|Rs], B).
|
||||
left([L|Ls], Rs, Ls, [L|Rs], _).
|
||||
|
||||
right(L, [], [B|L], [], B).
|
||||
right(L, [S|Rs], [S|L], Rs, _).
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
incrementer_config(IS, FS, RS, B, S) :-
|
||||
IS = q0, % initial state
|
||||
FS = [qf], % halting states
|
||||
RS = [IS], % running states
|
||||
B = 0, % blank symbol
|
||||
S = [B, 1]. % valid symbols
|
||||
incrementer(q0, 1, 1, right, q0).
|
||||
incrementer(q0, b, 1, stay, qf).
|
||||
|
||||
turing(incrementer_config, incrementer, [1, 1, 1], TapeOut).
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
busy_beaver_config(IS, FS, RS, B, S) :-
|
||||
IS = 'A', % initial state
|
||||
FS = ['HALT'], % halting states
|
||||
RS = [IS, 'B', 'C'], % running states
|
||||
B = 0, % blank symbol
|
||||
S = [B, 1]. % valid symbols
|
||||
busy_beaver('A', 0, 1, right, 'B').
|
||||
busy_beaver('A', 1, 1, left, 'C').
|
||||
busy_beaver('B', 0, 1, left, 'A').
|
||||
busy_beaver('B', 1, 1, right, 'B').
|
||||
busy_beaver('C', 0, 1, left, 'B').
|
||||
busy_beaver('C', 1, 1, stay, 'HALT').
|
||||
|
||||
turing(busy_beaver_config, busy_beaver, [], TapeOut).
|
||||
Loading…
Add table
Add a link
Reference in a new issue