Bevezet\303\251s a matematik\303\241baJ\303\241rai AntalEzek a programok csak szeml\303\251ltet\303\251sre szolg\303\241lnak.1. HalmazokLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn2. Term\303\251szetes sz\303\241mok3. A sz\303\241mfogalom b\305\221v\303\255t\303\251seLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn4. V\303\251ges halmazokLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn5. V\303\251gtelen halmazokLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn6. Sz\303\241melm\303\251letLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn7. Gr\303\241felm\303\251letLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn8. AlgebraLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn9. K\303\263dol\303\241sLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10. Algoritmusok10.1. Sz\303\241m\303\255t\303\241si modellekrestart;10.1.1. Sz\303\241m\303\255t\303\241si modellek10.1.2. P\303\251lda.f:=proc();
if nargs<2 then args else
if nargs>2 then
if args[3]=2 then
if args[2]=0 then args[1] else args[1],args[2],3 fi;
else args[2],args[1] mod args[2],2 fi;
else args[1],args[2],2 fi;
fi; end;172,62;f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.3. Szimul\303\241l\303\241s.10.1.4. P\303\251lda.f:=proc();
if nargs=3 then args else
if nargs<3 then args[1],1,0,args[2],0,1,0,2
else
if args[8]=2 then
if args[4]=0 then args[1..3] else args[1..7],"3.1" fi;
else
if args[8]="3.1" then args[1..6],floor(args[1]/args[4]),"3.2"
else args[4],args[5],args[6],args[1]-args[7]*args[4],args[2]-args[7]*args[5],args[3]-args[7]*args[6],args[7],2 fi;
fi;
fi;
fi; end;172,62;f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);f(%);LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.5. Szimul\303\241ci\303\263k sebess\303\251g\303\251nek \303\266sszehasonl\303\255t\303\241sa.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.6. Ord\303\263.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn->10.1.7. Feladat.->10.1.8. Feladat.10.1.9. Feladat.10.1.10. Algoritmus.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.11. Turing-g\303\251pek.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnT1:=proc(b,a) [h,a,"="] end; T1(h,"x");T2:=proc(b,a) if b=h then [h,a,"="] else [b," ","<"] fi; end;
T2("s","x");
T3:=proc(b,a) if b="h" then ["h",a,"="]
elif a<>" " then ["s",a,"<"] else ["h",a,">"] fi; end;
T3("s","1"); T3("s","2"); T3("s"," ");LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.12. Turing-g\303\251p, mint sz\303\241m\303\255t\303\241si elj\303\241r\303\241s; bemenet \303\251s kimenet.with(StringTools):
space:=" ";start:="s";halt:="h";llength:=30;rlength:=30;
Ts:=proc(T::procedure) global space,start,halt,llength,rlength;
local k,i,L,LL,LLL,wl,wm,wr,w;
if type(nargs,odd) or nargs<4 then
error "odd number of words",nargs-2; fi;
k:=(nargs-2)/2;L:=[args[2]];lprint(Fill(" ",llength+rlength));
for i to k do
wl:=args[2*i+1]; wr:=args[2*i+2];
if length(wl)=0 then wm:=space; else wm:=wl[-1]; fi;
while length(wl)>0 do
if wl[1]<>space then break; else wl:=wl[2..-1]; fi;
od;
while length(wr)>0 do
if wr[-1]<>space then break; else wr:=wr[1..-2]; fi;
od;
if length(wl)>llength then w:=wl[-llength..-1];
else w:=cat(Fill(space,llength-length(wl)),wl); fi;
if length(wr)>rlength then w:=cat(w,wr[1..rlength]);
else w:=cat(w,wr,Fill(space,rlength-length(wr))); fi;
lprint(w);
L:=[op(L),wm];
od;
w:=cat(Fill(" ",llength-1),"^",L[1]);
if length(L[1])<rlength then w:=cat(w,Fill(" ",rlength-length(L[1]))); fi; lprint(w);
LL:=T(op(L)); LLL:=[T,LL[1]];
for i to k do
wl:=args[2*i+1]; wr:=args[2*i+2];
if length(wl)>0 then wl:=wl[1..-2]; fi;
if length(wr)>0 then wm:=wr[1]; wr:=wr[2..-1]; else wm:=space fi;
if LL[k+1+i]="=" then wl:=cat(wl,LL[i+1]); wr:=cat(wm,wr); fi;
if LL[k+1+i]="<" then wr:=cat(LL[i+1],wm,wr); fi;
if LL[k+1+i]=">" then wl:=cat(wl,LL[i+1],wm); fi;
LLL:=[op(LLL),wl,wr];
od; op(LLL); end;T3,"s","123","";Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.13. Megjegyz\303\251s.10.1.14. P\303\251ld\303\241k.T1,"h","abc","def";Ts(%):Ts(%):Ts(%):T2,"s","abc","def";Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):T3,"s","123","";Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):T4:=proc(b,a) if b="s" then ["0","a",">"]
elif b="0" then ["1","b",">"]
elif b="1" then ["2","r",">"]
elif b="2" then ["3","a",">"]
elif b="3" then ["4","k",">"]
elif b="4" then ["5","a",">"]
elif b="5" then ["6","d",">"]
elif b="6" then ["7","a",">"]
elif b="7" then ["8","b",">"]
elif b="8" then ["9","r",">"]
elif b="9" then ["h","a","="]
elif b="h" then ["h","a","="] fi; end;T4,"s","","";Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):T5:=proc(b,a1,a2)
if b="s" then
if a1<>" " then ["s",a1,a2,"<","="] else ["c",a1,a1,">","<"] fi;
elif b="c" then
if a1<>" " then ["c",a1,a1,">","<"] else ["r",a1,a1,"<",">"] fi;
elif b="r" then
if a2<>" " then ["r",a1,a2,"=",">"] else ["h",a1,a2,"=","<"] fi;
else ["h",a1,a2,"=","="] fi; end;T5,"s","abcd","","","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):T63:=proc(b,a1,a2,a3)
if b="s" then
if a1="1" and a2="1" then ["c",a1,a2,"0","<","<","<"]
elif a1="1" or a2="1" then ["s",a1,a2,"1","<","<","<"]
elif a1="0" or a2="0" then ["s",a1,a2,"0","<","<","<"]
else ["b",a1,a2,a3,"=","=",">"] fi;
elif b="c" then
if a1="1" and a2="1" then ["c",a1,a2,"1","<","<","<"]
elif a1="1" or a2="1" then ["c",a1,a2,"0","<","<","<"]
elif a1="0" or a2="0" then ["s",a1,a2,"1","<","<","<"]
else ["b",a1,a2,"1","=","=",">"] fi;
elif b="b" then
if a3<>" " then ["b",a1,a2,a3,"=","=",">"]
else ["h",a1,a2,a3,"=","=","<"] fi;
else ["h",a1,a2,a3,"=","=","="] fi; end;T63,"s","10111","","1011","","","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):T62:=proc(b,a1,a2)
if b="s" then
if a1="1" and a2="1" then ["c",a1,"0","<","<"]
elif a1="1" or a2="1" then ["s",a1,"1","<","<"]
elif a1="0" or a2="0" then ["s",a1,"0","<","<"]
else ["b",a1,a2,"=",">"] fi;
elif b="c" then
if a1="1" and a2="1" then ["c",a1,"1","<","<"]
elif a1="1" or a2="1" then ["c",a1,"0","<","<"]
elif a1="0" or a2="0" then ["s",a1,"1","<","<"]
else ["b",a1,"1","=",">"] fi;
elif b="b" then
if a2<>" " then ["b",a1,a2,"=",">"]
else ["h",a1,a2,"=","<"] fi;
else ["h",a1,a2,"=","="] fi; end;T62,"s","11","","11","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn->10.1.15. Feladat.->10.1.16. Feladat.->10.1.17. Feladat.10.1.18. Feladat.10.1.19. Feladat.10.1.20. Feladat.10.1.21. Turing-g\303\251p szimul\303\241l\303\241sa cs\303\266kkentett jelk\303\251szlettel.T3unary:=proc(b,a)
if b="s" then
if a=" " then ["sb",a,"<"] else ["sI",a,"<"] fi;
elif b="sb" then
if a=" " then ["s0"," ",">"] else ["s2","I",">"] fi;
elif b="sI" then
if a=" " then ["s1"," ",">"] else ["s3","I",">"] fi;
elif b="s0" then ["s0>"," ",">"]
elif b="s1" then ["s1<","I","<"]
elif b="s2" then ["s2<"," ","<"]
elif b="s3" then ["s3<","I","<"]
elif b="s0>" then ["h",a,">"]
elif b="s1<" then ["s",a,"<"]
elif b="s2<" then ["s",a,"<"]
elif b="s3<" then ["s",a,"<"]
else ["h",a,"="] fi; end;T3unary,"s"," II II","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.22. Feladat.10.1.23. P\303\251ld\303\241k.TO1:=proc(b,a)
if b="s" then
if a<>" " then ["sb",a,"<"] else ["r",a,">"] fi;
elif b="sb" then
if a<>" " then [cat("s",a)," ","<"] else ["bb"," ",">"] fi;
elif b="b" then
if a<>" " then ["b",a,">"] else ["bb",a,">"] fi;
elif b="bb" then [cat("b",a),a,"<"]
elif b[1]="b" then ["s",b[2],"<"]
elif b="r" then
if a<>" " then ["r",a,">"] else ["h",a,"<"] fi;
elif b="h" then ["h",a,"="]
else if a<>" " then [cat("s",a),b[2],"<"] else ["b",b[2],">"] fi; fi;
end;TO1,"s","123","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):TO2:=proc(b,a)
if b="s" then
if a<>" " then [cat("s",a)," ",">"] else [">",a,">"] fi;
elif b=">" then
if a<>" " then [">",a,">"] else ["h",a,"<"] fi;
elif b="h" then ["h",a,"="]
elif length(b)=2 then
if a=" " then [cat(b,"<"),b[2],"<"] else [b,a,">"] fi;
else
if a=" " then ["s",b[2],"<"] else [b,a,"<"] fi;
fi; end;TO2,"s","123","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):TO3:=proc(b,a)
if b="s" then
if a<>" " then ["l",a,"<"] else ["h",a,"="] fi;
elif b="l" then
if a=" " then ["h",a,">"] else ["r",a,"="] fi;
elif b[1]="r" and b<>"r" then
if a=" " then [cat(">",b[2],"-")," ",">"]
else [cat(">",b[2],"+"),a,">"] fi;
elif b[1]=">" then
if a=" " then [b,a,">"] else [cat("w",b[2..-1]),a,">"] fi;
elif b[1]="w" then
if a<>" " then [b,a,">"]
elif b[3]="+" then ["<",b[2],"<"]
else ["h",b[2],"="] fi;
elif b="h" then ["h",a,"="]
elif b="<" then
if a<>" " then ["<",a,"<"] else ["r",a,"<"] fi;
else
if a=" " then ["r",a,"<"] else [cat("r",a)," ","<"] fi;
fi; end;TO3,"s","123","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):TO4:=proc(b,a)
if b="s" then
if a<>" " then ["=",a,">"] else ["h",a,"="] fi;
elif b="=" then ["==",a,"<"]
elif b="==" then ["1"," ","<"]
elif b="1" then
if a<>" " then ["0",a,"<"] else [">1",a,">"] fi;
elif b="0" then
if a<>" " then ["1",a,"<"] else [">0","1",">"] fi;
elif b=">0" or b=">1" then
if a=" " then [cat("=",b[2]),a,">"] else [b,a,">"] fi;
elif b="=0" or b="=1" then ["?",b[2],"<"]
elif b="?" then ["??",a,"<"]
elif b="??" then
if a=" " then [">>",a,">"] else ["d1"," ","<"] fi;
elif b=">>" then [">",a,">"]
elif b=">" then
if a<>" " then [">",a,">"] else ["h",a,"<"] fi;
elif b="d1" then ["d0",a,"<"]
elif b="d0" then
if a<>" " then ["d1"," ","<"] else ["t",a,">"] fi;
elif b="t" then ["t>"," ",">"]
elif b="t>" then
if a<>" " then ["t>",a,">"] else ["t=","1",">"] fi;
elif b="t=" then
if a=" " then ["=",a,"="] else ["t<",a,"<"] fi;
elif b="t<" then
if a<>" " then ["t<",a,"<"] else ["t",a,">"] fi;
else ["h",a,"="] fi; end;TO4,"s","11111","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):TO5:=proc(b,a)
if b="s" then
if a=" " then ["h",a,"="] else ["s<",a,"<"] fi;
elif b="s<" then
if a=" " then ["??",a,">"] else [b,a,"<"] fi;
elif b="??" then
if a=" " then ["==",a,"<"] else ["=",a,"<"] fi;
elif b="==" then ["h",a,"<"]
elif b="=" then ["d",a,"<"]
elif b="d" then
if a=" " then [">",a,">"] else ["dd",a,"<"] fi;
elif b="dd" then
if a=" " then [">","1",">"] else ["d<"," ","<"] fi;
elif b="d<" then
if a<>" " then [b,a,"<"] else ["d>","1",">"] fi;
elif b="d>" then
if a<>" " then [b,a,">"] else ["d","1","<"] fi;
elif b=">" then
if a<>" " then [b,a,">"] else ["?","1",">"] fi;
elif b="?" then
if a="1" then ["??"," ",">"] else ["0<"," ","<"] fi;
elif b="0<" then
if a<>" " then [b,a,"<"] else ["0=",a,">"] fi;
elif b="0=" then ["0>"," ",">"]
elif b="0>" then
if a<>" " then [b,a,">"] else ["??",a,">"] fi;
else ["h",a,"="] fi end;TO5,"s","0101","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):TO6:=proc(b,a)
if b="s" then
if a=" " then ["h",a,"="] else ["s>",a,">"] fi;
elif b="s>" then ["ss"," ",">"]
elif b="ss" then ["s<","I","<"]
elif b="s<" then ["d"," ","<"]
elif b="d" then ["d<"," ","<"]
elif b="d<" then
if a<>" " then [b,a,"<"] else ["d<<",a,"<"] fi;
elif b="d<<" then
if a<>" " then [b,a,"<"] else ["d>","I",">"] fi;
elif b="d>" then
if a<>" " then [b,a,">"] else ["d?",a,">"] fi;
elif b="d?" then
if a<>" " then ["d>>",a,">"] else ["r","I",">"] fi;
elif b="d>>" then
if a<>" " then [b,a,">"] else ["d",a,"<"] fi;
elif b="r" then
if a=" " then [b,"I",">"] else ["ds"," ","<"] fi;
elif b="ds" then ["m<"," ","<"]
elif b="m<" then
if a<>" " then [b,a,"<"] else ["a",a,"<"] fi;
elif b="a" then ["a<"," ","<"]
elif b="a<" then
if a<>" " then [b,a,"<"] else ["a<<",a,"<"] fi;
elif b="a<<" then
if a<>" " then [b,a,"<"] else ["a>","I",">"] fi;
elif b="a>" then
if a<>" " then [b,a,">"] else ["a?",a,">"] fi;
elif b="a?" then
if a<>" " then ["a>>",a,">"] else ["ra","I",">"] fi;
elif b="a>>" then
if a<>" " then [b,a,">"] else ["a",a,"<"] fi;
elif b="ra" then
if a=" " then [b,"I",">"] else ["rr",a,"<"] fi;
elif b="rr" then ["m>"," ",">"]
elif b="m>" then
if a<>" " then [b,a,">"] else ["md",a,"<"] fi;
elif b="md" then ["m?"," ","<"]
elif b="m?" then
if a<>" " then ["m<",a,"<"] else ["ad"," ","<"] fi;
elif b="ad" then
if a<>" " then [b," ","<"] else ["h",a,"<"] fi;
else ["h",a,"="] fi; end;
TO6,"s","II","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):TO7:=proc(b,a)
if b="s" then
if a=" " then ["h",a,"="] else ["s<",a,"<"] fi;
elif b="s<" then
if a<>" " then [b,a,"<"] else ["ss"," ","<"] fi;
elif b="ss" then ["d","I","="]
elif b="d" then ["d<"," ","<"]
elif b="d<" then
if a<>" " then [b,a,"<"] else ["d<<",a,"<"] fi;
elif b="d<<" then
if a<>" " then [b,a,"<"] else ["d>","I",">"] fi;
elif b="d>" then
if a<>" " then [b,a,">"] else ["d?",a,">"] fi;
elif b="d?" then
if a<>" " then ["d>>",a,">"] else ["r","I",">"] fi;
elif b="d>>" then
if a<>" " then [b,a,">"] else ["d",a,"<"] fi;
elif b="r" then
if a=" " then [b,"I",">"] else ["mm",a,"<"] fi;
elif b="mm" then ["m<"," ","<"]
elif b="m<" then
if a<>" " then [b,a,"<"] else ["a",a,"<"] fi;
elif b="a" then ["a<"," ","<"]
elif b="a<" then
if a<>" " then [b,a,"<"] else ["a<<",a,"<"] fi;
elif b="a<<" then
if a<>" " then [b,a,"<"] else ["a>","I",">"] fi;
elif b="a>" then
if a<>" " then [b,a,">"] else ["a?",a,">"] fi;
elif b="a?" then
if a<>" " then ["a>>",a,">"] else ["ra","I",">"] fi;
elif b="a>>" then
if a<>" " then [b,a,">"] else ["a",a,"<"] fi;
elif b="ra" then
if a=" " then [b,"I",">"] else ["rr",a,"<"] fi;
elif b="rr" then ["m>"," ",">"]
elif b="m>" then
if a<>" " then [b,a,">"] else ["md",a,"<"] fi;
elif b="md" then ["m?"," ","<"]
elif b="m?" then
if a<>" " then ["m<",a,"<"] else ["rm"," ",">"] fi;
elif b="rm" then
if a=" " then [b,"I",">"] else ["rrm",a,"<"] fi;
elif b="rrm" then ["c<<"," ","<"]
elif b="c<<" then
if a<>" " then [b,a,"<"] else ["c<<<",a,"<"] fi;
elif b="c<<<" then
if a<>" " then [b,a,"<"] else ["c<<<<",a,"<"] fi;
elif b="c<<<<" then
if a<>" " then [b,a,"<"] else ["cd",a,">"] fi;
elif b="cd" then ["c?"," ",">"]
elif b="c?" then
if a<>" " then ["c>",a,">"] else ["i>",a,">"] fi;
elif b="c>" then
if a<>" " then [b,a,">"] else ["c>>",a,">"] fi;
elif b="c>>" then
if a<>" " then [b,a,">"] else ["c>>>",a,">"] fi;
elif b="c>>>" then
if a<>" " then [b,a,">"] else ["c>>>>"," ",">"] fi;
elif b="c>>>>" then
if a=" " then [b,a,">"] else ["c??"," ",">"] fi;
elif b="c??" then
if a<>" " then ["c<",a,"<"] else ["h<",a,"<"] fi;
elif b="c<" then
if a=" " then [b,a,"<"] else ["c<<",a,"<"] fi;
elif b="h<" then
if a=" " then [b,a,"<"] else ["h<<",a,"<"] fi;
elif b="h<<" then
if a<>" " then [b,a,"<"] else ["h<<<",a,"<"] fi;
elif b="h<<<" then
if a<>" " then [b,a,"<"] else ["h<<<<",a,"<"] fi;
elif b="h<<<<" then
if a<>" " then [b,a,"<"] else ["h>",a,">"] fi;
elif b="h>" then
if a<>" " then [b," ",">"] else ["h>>",a,">"] fi;
elif b="h>>" then
if a<>" " then [b," ",">"] else ["hd",a,">"] fi;
elif b="hd" then ["h>>>"," ",">"]
elif b="h>>>" then
if a<>" " then [b,a,">"] else ["h",a,"<"] fi;
elif b="i>" then
if a<>" " then [b," ",">"] else ["i>>","I",">"] fi;
elif b="i>>" then
if a<>" " then [b,a,">"] else ["rs",a,">"] fi;
elif b="rs" then
if a=" " then [b,"I",">"] else ["s<<",a,"<"] fi;
elif b="s<<" then
if a<>" " then [b,a,"<"] else ["d",a,"<"] fi;
else ["h",a,"="] fi; end;
TO7,"s","III","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%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(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.24. Szavak k\303\263dol\303\241sa sz\303\241mm\303\241 \303\251s vissza.Digits36:="0123456789abcdefghijklmnopqrstuvwxyz"; length(%);
digit2number:=proc(d::string) searchtext(d,Digits36)-1 end;
digit2number("a");string2number:=proc(s::string,r::posint) local i,n; n:=0;
for i to length(s) do n:=n*r+digit2number(s[i]) od; n; end;
string2number("f0",16); string2number("eg",16);number2string:=proc(n::nonnegint,r::posint) local nn,nnn,s;
s:=""; nn:=n;
while nn>0 do
nnn:=irem(nn,r); nn:=iquo(nn,r); s:=cat("",Digits36[nnn+1],s);
od; s; end;
number2string(240,16);number2stringnon0:=proc(n::nonnegint,r::posint) local nn,nnn,s;
s:=""; nn:=n;
while nn>0 do
nnn:=irem(nn-1,r)+1; nn:=iquo(nn-nnn,r); s:=cat("",Digits36[nnn+1],s);
od; s; end;
number2stringnon0(240,16);LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.25. Turing-g\303\251p szimul\303\241l\303\241sa egy szalaggal.# In the general Turing One-tape simulator:
# T is the Turing-machine to simulate;
# k is the number of the tapes of T;
# x a character, not <,>,= and not in the tape ABC of T.
TOsimul:=proc(b,a) local i,j,ii,xx,bb,bbb,L;
global k,T,x; xx:=cat(x$j=1..k);
if b=start then [cat("<h1"," "$j=1..k,start," "$j=1..2*k),a,"="]
elif b=halt then [halt,a,"="]
elif b[1..2]="<h" then i:=digit2number(b[3]); ii:=Digits36[i+2];
if i<k then
if a<>" " then
[cat("<h",ii,b[4..2+i],a,b[4+i..-1])," ","<"]
elif b[3+i]<>" " and b[3+i]<>x then
[cat("<h",ii,b[4..2+i],x,b[4+i..-1]),b[3+i],"<"]
else
[cat("<h",ii,b[4..-1]),a,"<"] fi;
else
if a<>" " then
[cat("<a1",b[4..2+i],a,b[4+i..-1])," ","<"]
elif b[3+i]<>" " and b[3+i]<>x then
[cat("<a1",b[4..2+i],x,b[4+i..-1]),b[3+i],"<"]
else
[cat("<a1",b[4..-1]),a,"<"] fi;
fi;
elif b[1..2]="<a" then i:=digit2number(b[3]); ii:=Digits36[i+2];
if i<k then
if b[3+i]<>" " and b[3+i]<>x then
[cat("<a",ii,b[4..-2*k+i-2],a,b[-2*k+i..-1]),a,"<"]
else [cat("<a",ii,b[4..-1]),a,"<"] fi;
else
if b[3+i]<>" " and b[3+i]<>x then
bb:=cat("<h1",b[4..-2*k+i-2],a,b[-2*k+i..-1])
else bb:=cat("<h1",b[4..-1]) fi;
if bb[4..3+k]=xx then ii:=Digits36[k+1];
L:=T(bb[4+k..-2*k-1],bb[j]$j=-2*k..-k-1);
[cat(">a",ii," "$j=1..k,op(L)),a,"="]
else
[bb,a,"<"]
fi;
fi;
elif b[1..2]=">a" then i:=digit2number(b[3]); ii:=Digits36[i];
if i>1 then
if b[3+i]<>" " and b[3+i]<>x and b[-2*k+i-1]<>x then
[cat(">a",ii,b[4..-2*k+i-2],x,b[-2*k+i..-1]),b[-2*k+i-1],">"]
else [cat(">a",ii,b[4..-1]),a,">"] fi;
else ii:=Digits36[k+1];
if b[3+i]<>" " and b[3+i]<>x and b[-2*k+i-1]<>x then
[cat(">h",ii,b[4..-2*k+i-2],x,b[-2*k+i..-1]),b[-2*k+i-1],">"]
else [cat(">h",ii,b[4..-1]),a,">"] fi;
fi;
elif b[1..2]=">h" then i:=digit2number(b[3]); ii:=Digits36[i];
if i>1 then if i=k then bbb:="" else bbb:=bb[-k+i..-1] fi;
if b[3+i]=space and a<>space then
bb:=cat(">h",ii,b[4..2+i],a,b[4+i..-1]);
if bb[-k+i-1]="<" then
[bb,a,">"]
else [bb,space,">"] fi;
elif b[3+i]<>space and b[3+i]<>x then
if b[-k+i-1]="<" then
bb:=cat(">h",ii,b[4..2+i],x,b[4+i..-1]);
[cat(bb[1..-k+i-2],space,bbb),space,">"]
elif b[-k+i-1]="=" then
bb:=cat(">h",ii,b[4..2+i],x,b[4+i..-1]);
[cat(bb[1..-k+i-2],space,bbb),b[3+i],">"]
elif b[-k+i-1]=">" then
bb:=cat(">h",ii,b[4..-1]);
[cat(bb[1..-k+i-2],x,bbb),space,">"]
else
bb:=cat(">h",ii,b[4..2+i],x,b[4+i..-1]);
[cat(bb[1..-k+i-2],space,bbb),b[3+i],">"] fi;
else
[cat(">h",ii,b[4..-1]),space,">"] fi;
else ii:=Digits36[k+1]; if i=k then bbb:="" else bbb:=b[-k+i..-1] fi;
if b[3+i]=space and a<>space then
bb:=cat(">a",ii,b[4..2+i],a,b[4+i..-1]);
if bb[-k+i-1]="<" then
L:=[bb,a,">"]
else L:=[bb,space,">"] fi;
elif b[3+i]<>space and b[3+i]<>x then
if b[-k+i-1]="<" then
bb:=cat(">a",ii,b[4..2+i],x,b[4+i..-1]);
L:=[cat(bb[1..-k+i-2],space,bbb),space,">"]
elif b[-k+i-1]="=" then
bb:=cat(">a",ii,b[4..2+i],x,b[4+i..-1]);
L:=[cat(bb[1..-k+i-2],space,bbb),b[3+i],">"]
elif b[-k+i-1]=">" then
bb:=cat(">a",ii,b[4..-1]);
L:=[cat(bb[1..-k+i-2],x,bbb),space,">"]
else
bb:=cat(">a",ii,b[4..2+i],x,b[4+i..-1]);
L:=[cat(bb[1..-k+i-2],space,bbb),b[3+i],">"] fi;
else
L:=[cat(">a",ii,b[4..-1]),space,">"] fi;
bb:=L[1];
if bb[4..3+k]=xx then
if bb[4+k]=halt then [halt,a,"<"] else
[cat("<h1"," "$j=1..k,bb[4+k..-2*k-1]," "$j=1..2*k),a,"="] fi;
else L fi;
fi;
fi; end;T:=T62; # Turing mashine to simulate
k:=2; # Number of tapes
x:="."; # A character not <,>,=, and not in the tape ABC
TOsimul,"s","11 11ff","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.26. Megjegyz\303\251s.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.27. Feladat.10.1.28. Szem\303\251tgy\303\274jt\303\251s.# In the general garbage collection:
# T is the original Turing-machine;
# k is the number of the tapes of T;
# x a character, not <,>,=,space and start and not in the tape ABC of T.
Tgarbage:=proc() local i,ii,j,k,b,a,L,LL; global T,x;
k:=nargs-1; b:=args[1]; a:=args[2..k+1];
if b=start then [cat(start,start),a,"="$j=1..k]
elif b=halt then [halt,a,"="$j=1..k]
elif b[1]=start and b[2..-1]<>halt then
L:=[a]; LL:=[];
for i to k do
if L[i]=x then LL:=[op(LL),space] else LL:=[op(LL),L[i]] fi;
od;
L:=T(b[2..-1],op(LL));
LL:=[cat(start,L[1])];
for i to k do
if L[i+1]=space then LL:=[op(LL),x] else LL:=[op(LL),L[i+1]] fi;
od;
[op(LL),op(L[k+2..-1])]
elif b=cat(start,halt) then [cat(x,"1",x),a,">","="$j=2..k]
elif b[1]=x and b[3..-1]=x then
i:=digit2number(b[2]);
[cat(b,">"),a[1..i-1],x,a[i+1..-1],"="$j=1..i-1,">","="$j=i+1..k]
elif b[1]=x and b[3..-1]=cat(x,">") then
i:=digit2number(b[2]);
if a[i]<>space then
[b,a[1..i-1],space,a[i+1..-1],"="$j=1..i-1,">","="$j=i+1..k]
else
[cat(b[1..3],"="),a[1..i-1],space
,a[i+1..-1],"="$j=1..i-1,"<","="$j=i+1..k] fi;
elif b[1]=x and b[3..-1]=cat(x,"=") then
i:=digit2number(b[2]);
if a[i]<>x then
[b,a[1..i-1],space,a[i+1..-1],"="$j=1..i-1,"<","="$j=i+1..k]
else
[cat(b[1..3],"<"),a[1..i-1],space,
a[i+1..-1],"="$j=1..i-1,"<","="$j=i+1..k] fi;
elif b[1]=x and b[3..-1]=cat(x,"<") then
i:=digit2number(b[2]);
if a[i]=space then
[cat(b[1..2],space,"<"),a[1..i-1],x,
a[i+1..-1],"="$j=1..i-1,"<","="$j=i+1..k]
elif a[i]=x then
[cat(b[1..2],space,"<"),a[1..i-1],x,
a[i+1..-1],"="$j=1..i-1,"<","="$j=i+1..k]
else
[b,a,"="$j=1..i-1,"<","="$j=i+1..k] fi;
elif b[1]=x and b[3..-1]=cat(space,"<") then
i:=digit2number(b[2]);
if a[i]=space then
[cat(b[1..2],">",x),a[1..i-1],space,
a[i+1..-1],"="$j=1..i-1,"<","="$j=i+1..k]
else
[b,a[1..i-1],space,a[i+1..-1],"="$j=1..i-1,"<","="$j=i+1..k] fi;
elif b[1]=x and b[3..-1]=cat(">",x) then
i:=digit2number(b[2]);
if a[i]=x then
[b[1..3],a[1..i-1],space,a[i+1..-1],"="$j=1..i-1,">","="$j=i+1..k]
else
[b,a[1..i-1],space,a[i+1..-1],"="$j=1..i-1,">","="$j=i+1..k] fi;
else
i:=digit2number(b[2]); ii:=Digits36[i+2];
if a[i]=space then
if i=k then
[halt,a[1..i-1],space,a[i+1..-1],"="$j=1..i-1,"<","="$j=i+1..k]
else
[cat(x,ii,x),a[1..i-1],space,
a[i+1..-1],"="$j=1..i-1,"<",">","="$j=i+2..k] fi;
else
[b,a,"="$j=1..i-1,">","="$j=i+1..k] fi;
fi; end;
T:=T62; # Turing mashine to add garbage collection
k:=2; # Number of tapes
x:="*"; # A character not <,>,=,start and space and not in the tape ABC
Tgarbage,"s","11","","11","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.29. Univerz\303\241lis Turing-g\303\251pek. UT:=proc(b,a1,a2,a3)
if b="s" then
if a3<>" " then
if a2=" " then ["h",a1,a2,a3,"=","=","="]
elif a2=a3 then ["s",a1,a2,a3,"=","<","<"]
else ["t0",a1,a2,a3,"=","<","<"] fi;
else ["s1",a1,a2,a3,"=","=","="] fi;
elif b="s1" then
if a1=a2 then ["v0",a1,a2,a3,"=","<",">"]
else ["t1",a1,a2,a3,"=","<",">"] fi;
elif b="t0" then
if a3<>" " then ["t0",a1,a2,a3,"=","<","<"]
else ["t1",a1,a2,a3,"=","<",">"] fi;
elif b="t1" then
if a3<>" " then ["t1",a1,a2,a3,"=","<",">"]
else ["t2",a1,a2,a3,"=","<","<"] fi;
elif b="t2" then ["s",a1,a2,a3,"=","<","="]
elif b="v0" then
if a3<>" " then ["v0",a1,a2,a3,"=","=",">"]
else ["e0",a1,a2,a3,"=","=","<"] fi;
elif b="e0" then
if a3<>" " then ["e0",a1,a2,a2,"=","<","<"]
else ["e1",a1,a2,a3,"=","=","="] fi;
elif b="e1" then ["e2",a2,a2,a3,"=","<","="]
elif b="e2" then
if a2=" " then ["v1",a1,a2,a3,"=",">",">"]
elif a2="0" then ["v1",a1,a2,a3,"<",">",">"]
else ["v1",a1,a2,a3,">",">",">"] fi;
elif b="v1" then ["v2",a1,a2,a3,"=",">","="]
elif b="v2" then
if a2=" " and a3<>" " then ["v4",a1,a2,a3,"=","<","="]
elif a3<>" " then ["v2",a1,a2,a3,"=",">",">"]
else ["v3",a1,a2,a3,"=",">","<"] fi;
elif b="v3" then
if a3<>" " then ["v3",a1,a2,a3,"=",">","<"]
else ["v1",a1,a2,a3,"=",">",">"] fi;
elif b="v4" then
if a2=" " then ["v4",a1,a2,a3,"=","<","="]
else ["v5",a1,a2,a3,"=","=","="] fi;
elif b="v5" then
if a3<>" " then ["v5",a1,a2,a3,"=","=",">"]
else ["s",a1,a2,a3,"=","=","<"] fi;
else ["h",a1,a2,a3,"=","=","="] fi; end;
# A one-tape Turing machine: delete one letter from left hand side
T:=proc(b,a)
if b="s" then
if a=" " then ["d"," ",">"] else ["s",a,"<"] fi;
elif b="d" then ["b"," ",">"]
elif b="b" then
if a<>" " then ["b",a,">"] else ["h",a,"<"] fi;
else ["h",a,"="] fi end;T,"s","01","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):UT,"s","01","",cat("1 01 00","0000000","0100100","1 10 01","1 10001","1 10101","0 11 10","1010010","1110110"),"","00","":Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts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(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):Ts(%):LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn*10.1.30. Egyszalagos univerz\303\241lis Turing-g\303\251p. 10.1.31. Feladat.10.1.32. F\303\251lszalagos Turing-g\303\251pek. 10.1.33. F\303\251lszalagos Turing-g\303\251p szimul\303\241l\303\241sa Turing-g\303\251pen.10.1.34. Turing-g\303\251p szimul\303\241l\303\241sa f\303\251lszalagos g\303\251pen. 10.1.35. Post-g\303\251p szimul\303\241l\303\241sa f\303\251lszalagos g\303\251pen. 10.1.36. T\303\251tel: Post-g\303\251p szimul\303\241l\303\241sa Turing-g\303\251pen.10.1.37. T\303\251tel: Turing-g\303\251p szimul\303\241l\303\241sa Post-g\303\251pen. 10.1.38. Korl\303\263tozott g\303\251pmodellek.10.1.39. T\303\251tel.10.1.40. RAM-g\303\251p. 10.1.41. RAM-g\303\251p v\303\251grehajt\303\241si ideje.10.1.42. P\303\251ld\303\241k.10.1.43. Feladat.10.1.44. Turing-g\303\251p szimul\303\241l\303\241sa RAM-g\303\251pen.10.1.45. Megjegyz\303\251s.10.1.46. RAM-g\303\251p szimul\303\241l\303\241sa Turing-g\303\251pen.10.1.47. Megjegyz\303\251s.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.1.48. T\303\241rolt program\303\272 g\303\251p.*10.1.49. Markov-automat\303\241k. *10.1.50. Turing-g\303\251p szimul\303\241l\303\241sa Markov-automat\303\241n. *10.1.51. Markov-automata szimul\303\241l\303\241sa Turing-g\303\251pen.*10.1.52. Sejtautomat\303\241k.*10.1.53. P\303\251ld\303\241k.*10.1.54. Sejtautomata szimul\303\241l\303\241sa Turing-g\303\251pen.*10.1.55. Turing-g\303\251p szimul\303\241l\303\241sa sejtautomat\303\241n. *10.1.56. Church-f\303\251le lambda-kalkulus.->10.1.57. Feladat.10.1.58. Tov\303\241bbi feladatok.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.2. Kisz\303\241m\303\255that\303\263s\303\241g10.2.1. Kisz\303\241m\303\255that\303\263 f\303\274ggv\303\251nyek.10.2.2. Nyelvek.10.2.3. Eld\303\266nthet\305\221 nyelvek.10.2.4. Felsorolhat\303\263 nyelvek.10.2.5. Kisz\303\241m\303\255that\303\263 parci\303\241lis f\303\274ggv\303\251nyek.->10.2.6. Feladat.->10.2.7. Feladat.10.2.8. Feladat.->10.2.9. Feladat.10.2.10. T\303\251tel.10.2.11. Megjegyz\303\251s.10.2.12. A Church-t\303\251zis.10.2.13. T\303\251tel.10.2.14. Lemma.10.2.15. T\303\251tel.->10.2.16. Feladat.10.2.17. A meg\303\241ll\303\241si feladat.10.2.18. T\303\251tel.10.2.19. T\303\251tel.10.2.20. T\303\251tel.10.2.21. T\303\251tel.10.2.22. Matematikai probl\303\251m\303\241k algoritmikus megoldhatatlans\303\241ga.10.2.23. Diophantoszi egyenletek algoritmikus megoldhatatlans\303\241ga.10.2.24. Domin\303\263-probl\303\251ma.10.2.25. Parci\303\241lis rekurz\303\255v \303\251s primit\303\255v rekurz\303\255v f\303\274ggv\303\251nyek.10.2.26. P\303\251ld\303\241k primit\303\255v rekurz\303\255v f\303\274ggv\303\251nyekre.*10.2.27. T\303\251tel.*10.2.28. T\303\251tel.*10.2.29. Rekurz\303\255v f\303\274ggv\303\251nyek.->10.2.30. Feladat.->10.2.31. Feladat.->10.2.32. Feladat.->10.2.33. Feladat.->10.2.34. Feladat.->10.2.35. Feladat.->10.2.36. Feladat.10.2.37. Tov\303\241bbi feladatok.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.3. Id\305\221 \303\251s t\303\241r10.3.1. Algoritmusok id\305\221- \303\251s t\303\241rig\303\251nye.10.3.2. P\303\251ld\303\241k.10.3.3. Nemdeterminisztikus Turing-g\303\251pek.10.3.4. T\303\251tel.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.3.5. Tan\303\272.10.3.6. P\303\251ld\303\241k.10.3.7. Tan\303\272-t\303\251tel.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.3.8. K\303\266vetkezm\303\251ny.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn10.3.9. Megjegyz\303\251s.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn->10.3.10. Feladat.->10.3.11. Feladat.->10.3.12. Feladat.->10.3.13. Feladat.10.3.14. Tov\303\241bbi feladatok.LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0Yn