1 / 4

Boehm - Jacopini Theorem

Boehm - Jacopini Theorem. The essence of the theorem is that every program that uses goto instructions can be expressed via if and while. In other words, a language that includes if and while is functionally equivalent to the same language with go. Boehm - Jacopini Theorem.

kagami
Download Presentation

Boehm - Jacopini Theorem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Boehm - Jacopini Theorem The essence of the theorem is that every program that uses goto instructions can be expressed via if and while. In other words, a language that includes if and while is functionally equivalent to the same language with go.

  2. Boehm - Jacopini Theorem Each instruction could be if, goto, etc. Begin with a segment of code, including goto instructions: S1; S2; ... SN Step 1 Relabel every instruction (Sj) with Lj and update gotos to match. L1: S1; L2: S2; ... LN: SN Step 2 Select an integer variable, call it loc, not used in the program. Wrap the following around the entire program: loc = 1; while (loc != N) { translatedCodeGoesHere }

  3. Step 3 Replace each instruction (Sj) according to these rules: goto Rule Replace Lk: goto Lm; with if (loc==k) loc = m; if-goto Rule Replace Lk: if (cond) goto Lm; with if (loc==k) { if (cond) loc=m; else loc++; } other Rule Replace Lk: instructionk; with if (loc==k) {instructionk; loc++;}

  4. Example loc = 1; while (loc!=7) { if (loc==1) { j=1; loc++; } if (loc==2) { if (j>N) loc = 6; else loc++; } if (loc==3) { a[j]=0; loc++; } if (loc==4) { j = j + 1; loc++; } if (loc==5) loc=2; if (loc==6) { write(“the end”); loc++; } } Original j = 1; Top: if (j>N) goto Done; a[j] = 0; j = j + 1; goto Top; Done: write( “the end”); The End!

More Related