Write Compound State

Burton Rosenberg
April 27, 2015

Gloss of diagrams, for a turing machine to write to a name-value datastore.


See the Read Compound State notes for general formatting and helper Compound
States X1 through X6. (included below)


X8: given head over blanks on D and T tapes, compares repeatedly the names
	for equality
	
	leaves heads over the blanks following the matched names
	
	however, if there is no match, exists to a not found state with the D head
	on the blank before the #, and the T head rewound.
	
X9: given head over blank on D tape, erases forward to next blank, then returns
    the head to the position at start of X9
    
X10: given heads over blanks on D and T tapes, copies from T to D up to next 
     blank, leaving heads on the blanks on which copying stopped
     
W: given the heads rewound on the D and T tapes, find a name matching the first 
   word on the T tape on the D tape, and replaces it with the value on the T tape,
   or if the name is not found on the D tape, adds the name value pair to the D
   tape; leaving the T tape blank and the D tape rewound
    

==========================================================

[text of Read Compound States notes]

There are two tapes, D, T. D contains name values pairs written over some 
alphabet S, each word delimited by the reserved blank symbol, _, and 
the ends of the taped marked with some reserved symbol #.

The transfer tape T starts with a name, which is replaced by the associated
value as paired in D.

The following compound states are defined:


X1: given head over blanks on D and T tapes, compares the next
	word for equality.
	
	exits to one of two states depending on equality or inequality.
	
	leaves head over blanks in D and T tapes after the compared words.
	
X2: given head over blank on the D tape, moves head R over next word to next
	blank.
	
X3: given head over blank on T tape, moves head L over previous word to previous
	blank.
	
X4: given head over blanks on D and T tapes, compares repeatedly the names
	for equality
	
	leaves heads over the blanks following the matched names

X5: given head over blank at end of T tape, erases tape and leaves head over first
	cell of tape
	
X6: given heads over blanks on D and T tapes, copies next word on D tape to T tape
	leaving heads at the blank follow the word
	
X7: moves head Left to start of D tape

R:	given head over # on D tape, over _ on T tape, finds match of names and replaces
	name on T tape with found value


Data format:

	D tape is: #_((S+)_(S+))*_# where first S+ is name, second S+ is value
	T tape is: _(S+)_ before, and _(S+)_ 

Assumes name given by T before is paired in dictionary D with a value (i.e. 
matching name is found in dictionary).

The arrows are coded as:
	
	Da -> Db,DL	if tape D as a, replace by b and move D head left
	Da,Tb -> Dc,Td,DL,TR 
			if tape D has a AND tape T has b, replace a by c, 
			b by d, move tape D head left, and tape T head right
	DTb -> DTR	short for Db,Tb -> DR, TR