Universal Turing machine: Difference between revisions
Content added Content deleted
Cyril Nocton (talk | contribs) m (→Execution) |
Cyril Nocton (talk | contribs) |
||
Line 2,372: | Line 2,372: | ||
5-state busy beaver (first 20 cells) |
5-state busy beaver (first 20 cells) |
||
10100100100100100100...</pre> |
10100100100100100100...</pre> |
||
=== |
===Acl=== |
||
⚫ | |||
⚫ | |||
====Instruction set==== |
|||
⚫ | |||
Tmcl uses postfix notation. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
'<' : move left |
'<' : move left |
||
'>' : move right |
'>' : move right |
||
'@' : state <- |
'@' : state <- arg |
||
<symbol> : |
<symbol> : arg <- symbol</pre> |
||
====Program==== |
====Program==== |
||
Line 2,390: | Line 2,387: | ||
Tape is split into two stacks. |
Tape is split into two stacks. |
||
<pre>T = reverse ( |
<pre>T = reverse (l) . r where r is the scanned symbol. |
||
0</pre> |
|||
<syntaxhighlight lang="lisp">;; 22. |
<syntaxhighlight lang="lisp">;; 22.12.23 |
||
(defun |
(defun acl (table input state halt blank) |
||
(let (( |
(let ((l nil) |
||
( |
(r input) |
||
( |
(arg nil) |
||
( |
(exe nil)) |
||
(loop until (equal state halt) |
(loop :until (equal state halt) |
||
do (setf |
:do (setf code (cdr (assoc state table)) |
||
exe t) |
|||
(dolist ( |
(dolist (c code) |
||
(case |
(case c |
||
(= (setf |
(= (setf exe (equal (car r) arg))) |
||
(% (when |
(% (when exe (rplaca r arg))) |
||
(< (when |
(< (when exe (push (pop l) r))) |
||
(> (when |
(> (when exe (push (pop r) l))) |
||
(@ (when |
(@ (when exe (setf state arg) (return))) |
||
(t (setf |
(t (setf arg c))) |
||
(unless ( |
(unless (car r) |
||
(setf |
(setf r (cons blank (cdr r)))))) |
||
(format t "Q = <~a, ~{~a~}.~{~a~}>~%" state (reverse |
(format t "Q = <~a, ~{~a~}.~{~a~}>~%" state (reverse l) r)))</syntaxhighlight> |
||
==== |
====Tables==== |
||
Tables are stored in association lists. |
|||
<syntaxhighlight lang="lisp">(defconstant +incrementer+ '((q0 . (1 = > q0 @ b = 1 % qf @)))) |
<syntaxhighlight lang="lisp">(defconstant +incrementer+ '((q0 . (1 = > q0 @ b = 1 % qf @)))) |
||
Line 2,426: | Line 2,423: | ||
====Execution==== |
====Execution==== |
||
⚫ | |||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
|||
⚫ | |||
Q = <QF, 111.1> |
Q = <QF, 111.1> |
||
⚫ | |||
Q = <HALT, 111.111></pre> |
Q = <HALT, 111.111></pre> |
||