Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Universal-Turing-machine/J/universal-turing-machine-1.j
Normal file
16
Task/Universal-Turing-machine/J/universal-turing-machine-1.j
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
". noun define -. CRLF NB. Fixed tacit universal Turing machine code...
|
||||
|
||||
utm=.
|
||||
(((":@:(]&:>)@:(6&({::)) ,: (":@] 9&({::))) ,. ':'"_) ,. 2&({::) >@:(((48 + ]
|
||||
) { a."_)@[ ; (] $ ' '"_) , '^'"_) 3&({::))@:([ (0 0 $ 1!:2&2)@:('A changeles
|
||||
s cycle was detected!'"_)^:(-.@:(_1"_ = 1&({::))))@:((((3&({::) + 8&({::)) ;
|
||||
1 + 9&({::)) 3 9} ])@:(<@:((0 (0 {:: ])`(<@:(1 {:: ]))`(2 {:: ])} ])@:(7 3 2&
|
||||
{)) 2} ])@:(<"0@:(6&({::) (<@[ { ]) 0&({::)) 7 8 1} ])@:([ (0 0 $ 1!:2&2)@:((
|
||||
(":@:(]&:>)@:(6&({::)) ,: (":@] 9&({::))) ,. ':'"_) ,. 2&({::) >@:(((48 + ])
|
||||
{ a."_)@[ ; (] $ ' '"_) , '^'"_) 3&({::))^:(0 = 4&({::) | 9&({::)))@:(<@:(1&(
|
||||
{::) ; 3&({::) { 2&({::)) 6} ])@:(<@:(3&({::) + _1 = 3&({::)) 3} ])@:(<@:(((_
|
||||
1 = 3&({::)) {:: 5&({::)) , 2&({::) , (3&({::) = #@:(2&({::))) {:: 5&({::)) 2
|
||||
} ])^:(-.@:(_1"_ = 1&({::)))^:_)@:((0 ; (({. , ({: % 3:) , 3:)@:$ $ ,)@:(}."1
|
||||
)@:(".;._2)@:(0&({::))) 9 0} ])@:(<@:('' ; 0"_) 5} ])@:(,&(;:',,,,,'))@:(,~)
|
||||
|
||||
)
|
||||
21
Task/Universal-Turing-machine/J/universal-turing-machine-2.j
Normal file
21
Task/Universal-Turing-machine/J/universal-turing-machine-2.j
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
Noun=. ".@('(0 : 0)'"_)
|
||||
|
||||
NB. Simple Incrementer...
|
||||
NB. 0 1 Tape Symbol Scan
|
||||
NB. S p m g p m g (p,m,g) → (print,move,goto)
|
||||
QS=. (Noun _) ; 0 NB. Reading the transition table and setting the initial state
|
||||
0 1 0 _1 1 1 0
|
||||
)
|
||||
TPF=. 1 1 1 ; 0 ; 1 NB. Setting the tape, its pointer and the display frequency
|
||||
|
||||
TPF utm QS NB. Running the Turing machine...
|
||||
0 1:111
|
||||
0 :^
|
||||
0 1:111
|
||||
1 : ^
|
||||
0 1:111
|
||||
2 : ^
|
||||
0 0:1110
|
||||
3 : ^
|
||||
0 0:1111
|
||||
4 : ^
|
||||
39
Task/Universal-Turing-machine/J/universal-turing-machine-3.j
Normal file
39
Task/Universal-Turing-machine/J/universal-turing-machine-3.j
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
NB. Three-state busy beaver..
|
||||
NB. 0 1 Tape Symbol Scan
|
||||
NB. S p m g p m g (p,m,g) → (print,move,goto)
|
||||
QS=. (Noun _) ; 0 NB. Reading the transition table and setting the initial state
|
||||
0 1 1 1 1 _1 2
|
||||
1 1 _1 0 1 1 1
|
||||
2 1 _1 1 1 0 _1
|
||||
)
|
||||
TPF=. 0 ; 0 ; 1 NB. Setting the tape, its pointer and the display frequency
|
||||
|
||||
TPF utm QS NB. Running the Turing machine...
|
||||
0 0:0
|
||||
0 :^
|
||||
1 0:10
|
||||
1 : ^
|
||||
0 1:11
|
||||
2 :^
|
||||
2 0:011
|
||||
3 :^
|
||||
1 0:0111
|
||||
4 :^
|
||||
0 0:01111
|
||||
5 :^
|
||||
1 1:11111
|
||||
6 : ^
|
||||
1 1:11111
|
||||
7 : ^
|
||||
1 1:11111
|
||||
8 : ^
|
||||
1 1:11111
|
||||
9 : ^
|
||||
1 0:111110
|
||||
10 : ^
|
||||
0 1:111111
|
||||
11 : ^
|
||||
2 1:111111
|
||||
12 : ^
|
||||
2 1:111111
|
||||
13 : ^
|
||||
17
Task/Universal-Turing-machine/J/universal-turing-machine-4.j
Normal file
17
Task/Universal-Turing-machine/J/universal-turing-machine-4.j
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
NB. Probable 5-state, 2-symbol busy beaver...
|
||||
NB. 0 1 Tape Symbol Scan
|
||||
NB. S p m g p m g (p,m,g) → (print,move,goto)
|
||||
QS=. (Noun _) ; 0 NB. Reading the transition table and setting the state
|
||||
0 1 1 1 1 _1 2
|
||||
1 1 1 2 1 1 1
|
||||
2 1 1 3 0 _1 4
|
||||
3 1 _1 0 1 _1 3
|
||||
4 1 1 _1 0 _1 0
|
||||
)
|
||||
TPF=. 0 ; 0 ; _ NB. Setting the tape, its pointer and the display frequency
|
||||
|
||||
TPF utm QS NB. Running the Turing machine...
|
||||
0 0:0
|
||||
0 :^
|
||||
4 0 :101001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001...
|
||||
47176870: ^
|
||||
21
Task/Universal-Turing-machine/J/universal-turing-machine-5.j
Normal file
21
Task/Universal-Turing-machine/J/universal-turing-machine-5.j
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
NB. Sorting stress test...
|
||||
NB. 0 1 2 3 Tape Symbol Scan
|
||||
NB. S p m g p m g p m g p m g (p,m,g) ➜ (print,move,goto)
|
||||
QS=. (Noun _) ; 0 NB. Reading the transition table and setting the initial state
|
||||
0 0 _1 4 1 1 0 3 1 1 _ _ _
|
||||
1 0 _1 2 1 1 1 2 1 1 _ _ _
|
||||
2 _ _ _ 2 _1 3 2 _1 2 2 _1 4
|
||||
3 _ _ _ 1 _1 3 2 _1 3 1 1 0
|
||||
4 0 1 _1 1 _1 4 _ _ _ _ _ _
|
||||
)
|
||||
TPF=. 1 2 2 1 2 2 1 2 1 2 1 2 1 2 ; 0 ; 50 NB. Setting the tape, its pointer and the display frequency
|
||||
|
||||
TPF utm QS NB. Running the Turing machine...
|
||||
0 1:12212212121212
|
||||
0 :^
|
||||
3 2:113122121222220
|
||||
50 : ^
|
||||
1 2:111111322222220
|
||||
100: ^
|
||||
4 0:0111111222222220
|
||||
118: ^
|
||||
95
Task/Universal-Turing-machine/J/universal-turing-machine-6.j
Normal file
95
Task/Universal-Turing-machine/J/universal-turing-machine-6.j
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
NB. Structured derivation of the universal Turing machine...
|
||||
|
||||
NB.--------------------------------------------------------------------------------------
|
||||
NB. Quick and dirty tacit toolkit...
|
||||
|
||||
o=. @:
|
||||
c=."_
|
||||
|
||||
ver=. (0:`)([:^:)
|
||||
|
||||
d=. (fix=. (;:'f.')ver) (train=.(;:'`:')ver&6) (an=. <@:((,'0') (,&<) ]))
|
||||
ver=. (an f. o fix'ver')ver o an f.
|
||||
z=. ((an'')`($ ,)`) (`:6)
|
||||
d=. (a0=. `'') (a1=. (@:[) ((<'&')`) (`:6)) (a2=. (`(<(":0);_)) (`:6))
|
||||
av=. ((an o fix'a0')`) (`(an o fix'a1')) (`(an o fix'a2') ) (`:6)
|
||||
|
||||
Fetch=. (ver o train ;:'&{::')&.> o i. f.av
|
||||
tie=. ver o train ;:'`'
|
||||
|
||||
indices=. (, $~ 1 -.~ $) o (train"0 o ((1 -: L.)S:1 # <S:1) o (tie&'') o fix :: ] @:[)
|
||||
f=. ((ver o train ;:'&{')) o indices o train f.av
|
||||
|
||||
'A B'=. 2 Fetch
|
||||
head=. (;:'<@:') {.~ 2 * 1 = # o [
|
||||
h=. train o (indices o train o (A f) (head , (B f) o ] , < o an o [ , (;:'}]')c) ]) f.av
|
||||
|
||||
DropIfNB=. < o ('('"_ , ] , ')'"_) o ((}: ^: ('NB.' -: 3&{. o > o {:)) &. ;:)
|
||||
pipe=. ([ , ' o ' , ])&:>/ o |.
|
||||
|
||||
is=. ". o (, o ": o > , '=. ' , pipe o (DropIfNB;._2) o ". o ('0 ( : 0)'c)) f.av
|
||||
|
||||
NB.--------------------------------------------------------------------------------------
|
||||
|
||||
NB. Producing the main (dyadic) verb utm...
|
||||
|
||||
Note 0
|
||||
NB. X (boxed list)...
|
||||
Q - Instruction table
|
||||
S - Turing machine initial state
|
||||
|
||||
NB. Y (boxed list)...
|
||||
T - Data tape
|
||||
P - Head position pointer
|
||||
F - Display frequency
|
||||
|
||||
NB. Local...
|
||||
B - Blank defaults
|
||||
M - State and tape symbol read
|
||||
PRINT - Printing symbol
|
||||
MOVE - Tape head moving instruction
|
||||
C - Step Counter
|
||||
)
|
||||
|
||||
'Q S T P F B M PRINT MOVE C'=. 10 Fetch NB. Fetching 10 Boxes
|
||||
|
||||
DisplayTape=. > o (((48 + ]) { a.c)@[ ; ((] $ ' 'c) , '^'c))
|
||||
display=. ((((": o (]&:>) o M) ,: (":@] C)) ,. ':'c ) ,. (T DisplayTape P))
|
||||
NB. Displaying state, symbol, tape / step and pointer
|
||||
|
||||
amend=. 0 (0 {:: ])`(<@:(1 {:: ]))`(2 {:: ])} ]
|
||||
|
||||
NB. execute (monadic verb)...
|
||||
|
||||
FillLeft=. (_1 = P ) {:: B NB. Expanding and filling the tape
|
||||
FillRight=. ( P = # o T) {:: B NB. with 0's (if necessary)
|
||||
ia=. <@[ { ] NB. Selecting by the indices of an array
|
||||
|
||||
execute is
|
||||
T`(FillLeft , T , FillRight)h NB. Adjusting the tape
|
||||
P`(P + _1 = P) h NB. and the pointer (if necessary)
|
||||
M`(S ; P { T) h NB. Updating the state and reading the tape symbol
|
||||
[ (smoutput o display)^:(0 = F | C) NB. Displaying intermediate cycles
|
||||
(PRINT MOVE S)`(<"0 o (M ia Q))h NB. Performing the printing, moving and state actions
|
||||
T`(amend o ((PRINT P T)f)) h NB. Printing symbol on tape at the pointer position
|
||||
(P C)`((P + MOVE) ; 1 + C) h NB. Updating the pointer and the counter
|
||||
)
|
||||
|
||||
cc=. 'A changeless cycle was detected!'c
|
||||
halt=. _1 c = S NB. Halting when the current state is _1
|
||||
rt=. ((({. , ({: % 3:) , 3:) o $) $ ,) o (}."1) o (". ;. _2)
|
||||
NB. Reshaping the transition table as a 3D array (state,symbol,action)
|
||||
|
||||
utm is NB. Universal Turing Machine (dyadic verb)
|
||||
,~ NB. Appending the arguments in reverse order
|
||||
,&(;:5$',') NB. Appending 5 local boxes (B M PRINT MOVE C)
|
||||
B`('' ; 0 c) h NB. Setting empty blank defaults as 0
|
||||
(C Q)`(0 ; rt o Q)h NB. Setting the counter and the transition table
|
||||
execute^:(-. o halt)^:_ NB. Executing until a halt instruction is issued
|
||||
[ smoutput o cc ^: (-. o halt) NB. or a changeless single cycle is detected
|
||||
display NB. Displaying (returning) the final status
|
||||
)
|
||||
|
||||
utm=. utm f. NB. Fixing the universal Turing machine code
|
||||
|
||||
NB. The simulation code is produced by 77 (-@:[ ]\ 5!:5@<@:]) 'utm'
|
||||
Loading…
Add table
Add a link
Reference in a new issue