Boehm - Jacopini Theorem - PowerPoint PPT Presentation

1 / 4
About This Presentation
Title:

Boehm - Jacopini Theorem

Description:

goto instructions can be expressed via if and while. ... Replace each instruction (Sj) according to these rules: goto Rule. Replace. Lk: goto Lm; ... – PowerPoint PPT presentation

Number of Views:62
Avg rating:3.0/5.0
Slides: 5
Provided by: David58
Category:

less

Transcript and Presenter's Notes

Title: Boehm - Jacopini Theorem


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
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
(lock) loc m if-goto
Rule Replace Lk if (cond) goto Lm
with if (lock) if (cond)
locm else loc other
Rule Replace Lk instructionk
with if (lock) instructionk
loc
4
Example
loc 1 while (loc!7) if (loc1)
j1 loc if (loc2) if (jgtN)
loc 6 else loc
if (loc3) aj0 loc
if (loc4) j j 1 loc
if (loc5) loc2 if (loc6)
write(the end) loc
Original j 1 Top if (jgtN) goto
Done aj 0 j j 1
goto Top Done write( the end)
The End!
Write a Comment
User Comments (0)
About PowerShow.com