-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,635 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
states = {q1,q2,q3,q4} | ||
input_alphabet = {0,1} | ||
start_state = q1 | ||
accept_states = {q4} | ||
delta = | ||
q1,0 -> {q1,q2}; | ||
q1,1 -> q1; | ||
q2,0 -> q3; | ||
q2,1 -> q3; | ||
q3,0 -> q4; | ||
q3,1 -> q4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This NFA recognizes the language described by the regular expression 0*1*2* | ||
|
||
states = {q0,q1,q2} | ||
input_alphabet = {0,1,2} | ||
start_state = q0 | ||
accept_states = {q2} | ||
delta = | ||
q0,0 -> q0; | ||
q0, -> q1; | ||
q1,1 -> q1; | ||
q1, -> q2; | ||
q2,2 -> q2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// This context-free grammar generates the language of balanced (square bracket) parentheses. | ||
|
||
S -> [S] | SS | ; | ||
|
||
// The line above is equivalent to writing | ||
// S -> [S]; | ||
// S -> SS; | ||
// S -> ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// matches any binary string containing the substring 010 | ||
B = (0|1)*; // subexpression matching any binary string | ||
B 010 B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// This TM counts the number of a's on the first tape and writes that | ||
// number of 0's on the second tape. It demonstrates the use of the ? | ||
// wildcard in specifying transition rules. Note that because they have | ||
// no wildcard symbols, the rules | ||
// q1,a_ -> q1,a0,RR; | ||
// and | ||
// q1,__ -> qA,__,SS; | ||
// overrride the wildcard rule | ||
// q1,?_ -> q1,?_,RS; | ||
|
||
states = {q,qA,qR} | ||
input_alphabet = {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z} | ||
tape_alphabet_extra = {0,_} | ||
start_state = q | ||
accept_state = qA | ||
reject_state = qR | ||
num_tapes = 2 | ||
delta = | ||
q,?_ -> q, ?_,RS; | ||
q,a_ -> q, a0,RR; | ||
q,__ -> qA,__,SS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This TM computes the function f(0^n) = 0^{2n}. | ||
|
||
states = ? // the state names are inferred from the rest of the definition | ||
input_alphabet = {0} | ||
tape_alphabet = {_,!} | ||
start_state = q0 | ||
accept_state = qA | ||
reject_state = qR | ||
num_tapes = 2 | ||
delta = | ||
q0,0_ -> q1,0!,SR; | ||
q1,0_ -> q2,00,SR; | ||
q2,0_ -> q1,00,RR; | ||
q1,__ -> qD,__,SL; | ||
qD,_0 -> qD,_0,SL; | ||
qD,_! -> qA,_!,SR; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This TM computes the function f(0^n) = 0^{2n}. | ||
|
||
states = {q0,q1,q2,qD,qA,qR} | ||
input_alphabet = {0} | ||
tape_alphabet_extra = {!,_} | ||
start_state = q0 | ||
accept_state = qA | ||
reject_state = qR | ||
num_tapes = 2 | ||
delta = | ||
q0,0_ -> q1,0!,SR; | ||
q1,0_ -> q2,00,SR; | ||
q2,0_ -> q1,00,RR; | ||
q1,__ -> qD,__,SL; | ||
qD,_0 -> qD,_0,SL; | ||
qD,_! -> qA,_!,SR; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// This DFA recognizes { x in {0,1}* | x does not end in 000 } | ||
|
||
states = {q, // last bit was a 1 or non-existent | ||
q0, // last two bits were 10 | ||
q00, // last three bits were 100 | ||
q000} // last three bits were 000 | ||
|
||
input_alphabet = {0,1} | ||
|
||
start_state = q // no last bit when we start | ||
|
||
accept_states = {q,q0,q00} // accept if last three bits were not 000 | ||
|
||
delta = | ||
// if we see a 1, reset | ||
q,1 -> q; | ||
q0,1 -> q; | ||
q00,1 -> q; | ||
q000,1 -> q; | ||
|
||
// if we see a 0, count one more 0 than before | ||
q,0 -> q0; | ||
q0,0 -> q00; | ||
q00,0 -> q000; | ||
|
||
// until we get to three | ||
q000,0 -> q000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// This TM recognizes the language { w in {0,1}* | w = w^R } | ||
|
||
states = {s,r00,r11,r01,r10,l,lx,qA,qR} | ||
input_alphabet = {0,1} | ||
tape_alphabet_extra = {x,_} | ||
start_state = s | ||
accept_state = qA | ||
reject_state = qR | ||
delta = | ||
s,0 -> r00,x,R; | ||
s,1 -> r11,x,R; | ||
r00,0 -> r00,0,R; | ||
r00,1 -> r01,1,R; | ||
r01,0 -> r00,0,R; | ||
r01,1 -> r01,1,R; | ||
r10,0 -> r10,0,R; | ||
r10,1 -> r11,1,R; | ||
r11,0 -> r10,0,R; | ||
r11,1 -> r11,1,R; | ||
r00,_ -> lx,_,L; | ||
r11,_ -> lx,_,L; | ||
r00,x -> lx,x,L; | ||
r11,x -> lx,x,L; | ||
lx, 0 -> l,x,L; | ||
lx, 1 -> l,x,L; | ||
lx, x -> qA,x,S; | ||
l, 0 -> l,0,L; | ||
l, 1 -> l,1,L; | ||
l, x -> s,x,R; | ||
s, x -> qA,x,S; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// This TM recognizes the language { w:w | w is a string in {0,1}* } | ||
// It is the same as the one described in w-marker-w.tm. | ||
|
||
// It demonstrates the use of the ? wildcard in specifying transition rules. | ||
|
||
states = {q1,q2,q3,q4,q5,q6,q7,q8,qA,qR} | ||
input_alphabet = {0,1,:} | ||
tape_alphabet_extra = {x,_} | ||
start_state = q1 | ||
accept_state = qA | ||
reject_state = qR | ||
num_tapes = 1 | ||
delta = | ||
q1,0 -> q2,x,R; | ||
q1,1 -> q3,x,R; | ||
q1,: -> q8,:,R; | ||
q2,? -> q2,?,R; | ||
q2,: -> q4,:,R; | ||
q3,? -> q3,?,R; | ||
q3,: -> q5,:,R; | ||
q4,0 -> q6,x,L; | ||
q4,x -> q4,x,R; | ||
q5,1 -> q6,x,L; | ||
q5,x -> q5,x,R; | ||
q6,? -> q6,?,L; | ||
q6,: -> q7,:,L; | ||
q7,? -> q7,?,L; | ||
q7,x -> q1,x,R; | ||
q8,x -> q8,x,R; | ||
q8,_ -> qA,_,R; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
states = {q1,q2,q3,q4,q5,q6,q7,q8,qA,qR} | ||
input_alphabet = {0,1,:} | ||
tape_alphabet_extra ={x,_} | ||
start_state = q1 | ||
accept_state = qA | ||
reject_state = qR | ||
num_tapes = 1 | ||
delta = | ||
q1,0 -> q2,x,R; | ||
q1,1 -> q3,x,R; | ||
q1,: -> q8,:,R; | ||
q2,? -> q2,?,R; | ||
q2,: -> q4,:,R; | ||
q3,? -> q3,?,R; | ||
q3,: -> q5,:,R; | ||
q4,0 -> q6,x,L; | ||
q4,x -> q4,x,R; | ||
q5,1 -> q6,x,L; | ||
q5,x -> q5,x,R; | ||
q6,? -> q6,?,L; | ||
q6,: -> q7,:,L; | ||
q6,x -> q6,x,L; | ||
q7,? -> q7,?,L; | ||
q7,x -> q1,x,R; | ||
q8,x -> q8,x,R; | ||
q8,_ -> qA,_,R; |
Oops, something went wrong.