<?xml version="1.0"?>
<turing-machine version="0.1">

<!-- This Turing machine (TM) implements ROT13, which is
     a simple substitution cipher. ROT13 is symmetric. Thus, 
     if the cipher text that is generated by the TM is fed into the 
     TM again, then the original plaintext will be produced.

     If this Turing machine processes the following input tape:
         kfyg vf ghevat pbzcyrgr$
     then it will produce the following final tape:
         xslt is turing complete$ 

     This Turing Machine Markup Language (TMML) document complies
     with the DTD for TMML, which is available at 
     https://www.thelyonsfamily.us/turing/tmml.dtd.

     This Turing machine can be executed by an XSLT stylesheet that is
     available at https://www.thelyonsfamily.us/turing/utm.xsl. This stylesheet
     is a Universal Turing Machine.

     The following Instant Saxon command will execute the Turing machine
     described by this TMML document using the utm.xsl stylesheet:

        saxon rot13_tm.xml utm.xsl tape="plaintext$"

     This TMML document is available at 
     https://www.thelyonsfamily.us/turing/rot13_tm.xml.

     Developed by Bob Lyons.
-->

<!-- 

     Copyright (c) 2001. Robert C. Lyons. All rights reserved.

-->

    <!-- The symbols for the Turing machine. We define a symbol 
         for each lower case letter in the English alphabet. 
         We also define a symbol for an end of 
         text marker (i.e., "$"). The Turing machine will 
         stop when it reads the "$" symbol on the tape.
         We use the default value for the blank symbol (i.e.,
         the space character).
    -->
    <symbols>abcdefghijklmnopqrstuvwxyz$</symbols>

    <!-- The states for the Turing machine.
         There should be one start state and one or more halt states.
    -->
    <states>
        <state start="yes">replace-symbol</state>
        <state halt="yes">stop</state>
    </states>

    <!-- The transition function for the Turing machine.
         This transition function implements ROT13, which is
         a simple substitution cipher in which "a" is replaced by "n",
         "b" is replaced by "o", "c" is replaced by "p", "d" is replaced 
         by "q", and so on.
    -->
    <transition-function>
        <mapping>
            <from current-state="replace-symbol" current-symbol="a"/>
            <to next-state="replace-symbol" next-symbol="n" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="b"/>
            <to next-state="replace-symbol" next-symbol="o" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="c"/>
            <to next-state="replace-symbol" next-symbol="p" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="d"/>
            <to next-state="replace-symbol" next-symbol="q" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="e"/>
            <to next-state="replace-symbol" next-symbol="r" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="f"/>
            <to next-state="replace-symbol" next-symbol="s" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="g"/>
            <to next-state="replace-symbol" next-symbol="t" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="h"/>
            <to next-state="replace-symbol" next-symbol="u" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="i"/>
            <to next-state="replace-symbol" next-symbol="v" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="j"/>
            <to next-state="replace-symbol" next-symbol="w" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="k"/>
            <to next-state="replace-symbol" next-symbol="x" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="l"/>
            <to next-state="replace-symbol" next-symbol="y" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="m"/>
            <to next-state="replace-symbol" next-symbol="z" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="n"/>
            <to next-state="replace-symbol" next-symbol="a" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="o"/>
            <to next-state="replace-symbol" next-symbol="b" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="p"/>
            <to next-state="replace-symbol" next-symbol="c" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="q"/>
            <to next-state="replace-symbol" next-symbol="d" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="r"/>
            <to next-state="replace-symbol" next-symbol="e" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="s"/>
            <to next-state="replace-symbol" next-symbol="f" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="t"/>
            <to next-state="replace-symbol" next-symbol="g" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="u"/>
            <to next-state="replace-symbol" next-symbol="h" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="v"/>
            <to next-state="replace-symbol" next-symbol="i" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="w"/>
            <to next-state="replace-symbol" next-symbol="j" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="x"/>
            <to next-state="replace-symbol" next-symbol="k" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="y"/>
            <to next-state="replace-symbol" next-symbol="l" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="z"/>
            <to next-state="replace-symbol" next-symbol="m" movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol=" "/>
            <to next-state="replace-symbol" next-symbol=" " movement="right"/>
        </mapping>
        <mapping>
            <from current-state="replace-symbol" current-symbol="$"/>
            <to next-state="stop" next-symbol="$" movement="right"/>
        </mapping>
    </transition-function>
</turing-machine>