title: Böhm-Jacopini theorem
body: <p>According to Böhm-Jacopini theorem, an algorithm can be written using only three statements:</p>
  
  <ul>
  <li>sequence</li>
  <li>selection</li>
  <li>iteration</li>
  </ul>
  
  <p>Lots of teachers, assumes that theorem as an act of faith, and they teach to not use (goto, jump, break, multiple return, etc...) because these instructions are evil.</p>
  
  <p>But when I ask for an explanation, no one is able to provide a proof of theorem.</p>
  
  <p>Personally I don't think that the theorem is false, but I think that it's applicability in real world is not always the better choice.</p>
  
  <p>So I've done a my little search, and these are my doubts:</p>
  
  <ol>
  <li><p>The theorem has been proven on induction on the structure of the flow chart, but it's really applicable in a computer program?<br>
  According to wikipedia "Böhm and Jacopini's was not really practical as a program transformation algorithm, and thus opened the door for additional research in this direction".</p></li>
  <li><p>A consequence of theorem prove that each "goto" can be translated into selection or iteration by induction, but what about efficiency? 
  I can't find any proof shows that each algorithm can be rewritten preserving the same performance.</p></li>
  <li><p>Recursion, a recursive algorithm can really be written using only sequence, selection and iteration?
  I know that some recursive algorithms can be optimized as loops (think to tail recursion), but can really be applicable to all?</p></li>
  <li><p>Clean code, I know that an abuse of jumps can create a monstrous code, but I think in some case a correct use of break in a loop can improve the code readability.</p></li>
  </ol>
  
  <p>Sample:</p>
  
  <pre><code>n = 0;
  while (n &lt; 1000 || (cond1 &amp;&amp; cond2) || (cond3 &amp;&amp; cond4) || (cond5 &amp;&amp; cond6)) 
  {  
     n++;  
     //The rest of code  
  }   
  </code></pre>
  
  <p>Can be  rewritten as :</p>
  
  <pre><code>for (n = 0; n &lt; 1000; n++)
  {
     if (cond1 &amp;&amp; cond2) break;
     elseif (cond2 &amp;&amp; cond3) break;
     elseif (cond4 &amp;&amp; cond5) break;
     elseif (cond6 &amp;&amp; cond7) break;
     //The rest of code
  }
  </code></pre>
  
  <p>Personally I think that the theorem has not been created for write better code, and the idea that a clean code must follow this theorem has been spread into world for a strange subjective reason.</p>
  
  <ol start="5">
  <li>I found this interesting article : <a href="https://www.cs.cornell.edu/~kozen/papers/bohmjacopini.pdf" rel="nofollow">https://www.cs.cornell.edu/~kozen/papers/bohmjacopini.pdf</a>
  I think this prove that real program must not be forced to follow the Jaopini Theorem.<br>
  Do you share the same conclusions?</li>
  </ol>
  
  <p>Summarizing the question, I need to know if a program that uses only (sequence, selection and iteration) is really better than any other that uses different statements, and if there are proves or if it's all subjective.</p>