Design a Turing machine which computes the sum of two numbers in base $2$












0












$begingroup$


Question:




Design a Turing machine which computes the sum of two numbers in base $2$. For example, If the input is $110x1$, The machine should return $000x111$ (which means: $6+1=7$)






My try:



At each iteration, decrease the first number by $1$, and increase the second one by $1$. Repeat this until the first number becomes $0$. (I know how to increase and decrease a number in base $2$ using a Turing machine)





Problem:



(I) I don't know what to do if the input is like $111x001$. My algorithm is not general enough to solve this one too.

(II) It seems like the numbers should have the same number of digits. But I'm not sure of that. Can we design the machine without presuming this condition?










share|cite|improve this question









$endgroup$

















    0












    $begingroup$


    Question:




    Design a Turing machine which computes the sum of two numbers in base $2$. For example, If the input is $110x1$, The machine should return $000x111$ (which means: $6+1=7$)






    My try:



    At each iteration, decrease the first number by $1$, and increase the second one by $1$. Repeat this until the first number becomes $0$. (I know how to increase and decrease a number in base $2$ using a Turing machine)





    Problem:



    (I) I don't know what to do if the input is like $111x001$. My algorithm is not general enough to solve this one too.

    (II) It seems like the numbers should have the same number of digits. But I'm not sure of that. Can we design the machine without presuming this condition?










    share|cite|improve this question









    $endgroup$















      0












      0








      0





      $begingroup$


      Question:




      Design a Turing machine which computes the sum of two numbers in base $2$. For example, If the input is $110x1$, The machine should return $000x111$ (which means: $6+1=7$)






      My try:



      At each iteration, decrease the first number by $1$, and increase the second one by $1$. Repeat this until the first number becomes $0$. (I know how to increase and decrease a number in base $2$ using a Turing machine)





      Problem:



      (I) I don't know what to do if the input is like $111x001$. My algorithm is not general enough to solve this one too.

      (II) It seems like the numbers should have the same number of digits. But I'm not sure of that. Can we design the machine without presuming this condition?










      share|cite|improve this question









      $endgroup$




      Question:




      Design a Turing machine which computes the sum of two numbers in base $2$. For example, If the input is $110x1$, The machine should return $000x111$ (which means: $6+1=7$)






      My try:



      At each iteration, decrease the first number by $1$, and increase the second one by $1$. Repeat this until the first number becomes $0$. (I know how to increase and decrease a number in base $2$ using a Turing machine)





      Problem:



      (I) I don't know what to do if the input is like $111x001$. My algorithm is not general enough to solve this one too.

      (II) It seems like the numbers should have the same number of digits. But I'm not sure of that. Can we design the machine without presuming this condition?







      automata turing-machines






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Sep 30 '17 at 15:36









      Arman MalekzadehArman Malekzadeh

      1,7951028




      1,7951028






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.



          Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.



          To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            I thought of the shift but I don't know how ...
            $endgroup$
            – Arman Malekzadeh
            Oct 1 '17 at 6:21











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "69"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2451687%2fdesign-a-turing-machine-which-computes-the-sum-of-two-numbers-in-base-2%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0












          $begingroup$

          I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.



          Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.



          To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            I thought of the shift but I don't know how ...
            $endgroup$
            – Arman Malekzadeh
            Oct 1 '17 at 6:21
















          0












          $begingroup$

          I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.



          Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.



          To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            I thought of the shift but I don't know how ...
            $endgroup$
            – Arman Malekzadeh
            Oct 1 '17 at 6:21














          0












          0








          0





          $begingroup$

          I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.



          Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.



          To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.






          share|cite|improve this answer











          $endgroup$



          I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.



          Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.



          To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited Oct 1 '17 at 12:48

























          answered Sep 30 '17 at 21:45









          Bram28Bram28

          60.6k44590




          60.6k44590












          • $begingroup$
            I thought of the shift but I don't know how ...
            $endgroup$
            – Arman Malekzadeh
            Oct 1 '17 at 6:21


















          • $begingroup$
            I thought of the shift but I don't know how ...
            $endgroup$
            – Arman Malekzadeh
            Oct 1 '17 at 6:21
















          $begingroup$
          I thought of the shift but I don't know how ...
          $endgroup$
          – Arman Malekzadeh
          Oct 1 '17 at 6:21




          $begingroup$
          I thought of the shift but I don't know how ...
          $endgroup$
          – Arman Malekzadeh
          Oct 1 '17 at 6:21


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2451687%2fdesign-a-turing-machine-which-computes-the-sum-of-two-numbers-in-base-2%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Berounka

          Sphinx de Gizeh

          Different font size/position of beamer's navigation symbols template's content depending on regular/plain...