towards making theory of
play

Towards Making Theory of Describing a For-Loop . . . Computation - PowerPoint PPT Presentation

Theory of . . . Pedagogical Problem Notion of a Recursive . . . How to Describe a . . . Towards Making Theory of Describing a For-Loop . . . Computation Course More Resulting Description . . . Beyond For-Loops: A . . . Understandable and


  1. Theory of . . . Pedagogical Problem Notion of a Recursive . . . How to Describe a . . . Towards Making Theory of Describing a For-Loop . . . Computation Course More Resulting Description . . . Beyond For-Loops: A . . . Understandable and Resulting Meaning Acknowledgment Relevant: Recursive Home Page Functions, For-Loops, and Title Page While-Loops ◭◭ ◮◮ ◭ ◮ Olga Kosheleva 1 and Vladik Kreinovich 2 Page 1 of 10 Go Back Departments of 1 Teacher Education and 2 Computer Science University of Texas at El Paso, El Paso, TX 79968, USA Full Screen olgak@utep.edu, vladik@utep.edu Close Quit

  2. Theory of . . . Pedagogical Problem 1. Theory of Computation Is Useful Notion of a Recursive . . . • Results of theory of computation are useful. How to Describe a . . . Describing a For-Loop . . . • Example: finite automata are a useful technique in de- Resulting Description . . . signing computer hardware and in designing compilers. Beyond For-Loops: A . . . • Textbooks describe this usefulness reasonably well. Resulting Meaning • However, proofs are also useful: Acknowledgment Home Page – to avoid rewriting code, programmers try to make Title Page it as general as possible; ◭◭ ◮◮ – however, too general problems are often algorithmi- cally unsolvable ; ◭ ◮ – in this case, attempts to write a general problem Page 2 of 10 are a waste of time ; Go Back – a programmer must be able to tell when a general Full Screen problem is not solvable. Close Quit

  3. Theory of . . . Pedagogical Problem 2. Pedagogical Problem Notion of a Recursive . . . • Reminder: students need to be able to tell when a How to Describe a . . . problem is not algorithmically solvable. Describing a For-Loop . . . Resulting Description . . . • Important: they need to understand the existing non- Beyond For-Loops: A . . . solvability proofs. Resulting Meaning • Goal: the students will be able to adjust these proofs Acknowledgment to the new situations. Home Page • Problem: many proofs use abstract notions whose rel- Title Page evance to computing is unclear. ◭◭ ◮◮ • It is thus necessary: to explain the relation between ◭ ◮ the abstract notions and computer practice. Page 3 of 10 • What we do: we show this relation on the example of Go Back recursive functions – one of the first abstract notions. Full Screen Close Quit

  4. Theory of . . . Pedagogical Problem 3. Notion of a Recursive Function: Brief History Notion of a Recursive . . . • Origin: this notion was invented in the 1930s by Alonzo How to Describe a . . . Church. Describing a For-Loop . . . Resulting Description . . . • Church’s motivation: to describe what is computable Beyond For-Loops: A . . . and what is not computable. Resulting Meaning • Once computers appeared: many parts of Church’s de- Acknowledgment scription were used when designing progr. languages. Home Page • In time, programming languages and Church’s nota- Title Page tions evolved in different directions: ◭◭ ◮◮ – in theoretical analysis, we want to have models ◭ ◮ which are simple – to make analysis easier; Page 4 of 10 – in programming languages, we want to add features if this makes programming simpler. Go Back • However: we will show that the theoretical notions can Full Screen still be related to programming practice. Close Quit

  5. Theory of . . . Pedagogical Problem 4. How to Describe a For-Loop in Precise Terms? Notion of a Recursive . . . • Let us start with a simple program for computing a m : How to Describe a . . . Describing a For-Loop . . . power = 1 ; Resulting Description . . . for ( int i = 1 ; i < = m ; i + +) Beyond For-Loops: A . . . Resulting Meaning { power = power ∗ a } ; Acknowledgment • This is not a precise mathematical notation, because: Home Page – in math, the variable is assumed to have the same Title Page value in different parts of the equation, but ◭◭ ◮◮ – power = power ∗ a means that power is assigned a ◭ ◮ new value: the product of the old value and a . Page 5 of 10 • To make the description mathematically precise, we Go Back must thus explicitly indicate the iteration number. Full Screen Close Quit

  6. Theory of . . . Pedagogical Problem 5. Describing a For-Loop (cont-d) Notion of a Recursive . . . • To make the description mathematically precise, we How to Describe a . . . must explicitly indicate the iteration number: Describing a For-Loop . . . Resulting Description . . . power ( 0 ) = 1 Beyond For-Loops: A . . . power ( i + 1 ) = power ( i ) ∗ a Resulting Meaning • The value of the variable power also depends on a : Acknowledgment Home Page power ( a , 0 ) = 1 Title Page power ( a , i + 1 ) = power ( a , i ) ∗ a ◭◭ ◮◮ • In a general for-loop with parameters a = a 1 , . . . , a k in ◭ ◮ which a variable h changes: Page 6 of 10 – we first assign some initial value to the variable: Go Back h ( a , 0 ) = f ( a ); – on each iteration, we use the previous value of h , a , Full Screen i to produce a new value h ( a , i + 1 ) = g ( a , i , h ( a , i )). Close Quit

  7. Theory of . . . Pedagogical Problem 6. Resulting Description of a For-Loop Notion of a Recursive . . . • Let a = a 1 , . . . , a k be a list of parameters. How to Describe a . . . Describing a For-Loop . . . • To describe a for-loop in which a variable h changes we Resulting Description . . . need to know: Beyond For-Loops: A . . . – an algorithm f ( a ) assigning an initial value to h ; Resulting Meaning this value may depend on the parameters a ; Acknowledgment – an algorithm g ( a , i , h ( a , i )) that describes what is Home Page happening inside the loop, on each iteration. Title Page • Once we have these two algorithms f and g , we can ◭◭ ◮◮ describe a function h computed by the for-loop: ◭ ◮ h ( a , 0 ) = f ( a ); h ( a , i + 1 ) = g ( a , i , h ( a , i )) . Page 7 of 10 • This is exactly Church’s primitive recursion ! Go Back • So, primitive recursion can be described as a natural Full Screen formalization of a for-loop. Close Quit

  8. Theory of . . . Pedagogical Problem 7. Beyond For-Loops: A While-Loop Notion of a Recursive . . . • In the traditional for-loop , we know beforehand how How to Describe a . . . many iterations we make. Describing a For-Loop . . . Resulting Description . . . • In some algorithms, we run iterations x k until the pro- cess converges; e.g., to compute x = √ a : Beyond For-Loops: A . . . Resulting Meaning x k +1 = 1 � � x k + a x 0 = 1 , 2 · , until | x k +1 − x k | ≤ ε. Acknowledgment x k Home Page • In this case, we run a while-loop , which runs until a Title Page stopping condition P is satisfied. ◭◭ ◮◮ • So, to describe while-loops, we need to describe the ◭ ◮ smallest m for which P ( n, m ) holds. Page 8 of 10 def • This value f ( n ) = µm.P ( n, m ) is exactly Church’s µ - Go Back recursion! Full Screen • Thus, the basic ideas behind recursive functions are exactly natural formalizations of for- and while-loops. Close Quit

  9. Theory of . . . Pedagogical Problem 8. Resulting Meaning Notion of a Recursive . . . • We have shown: that How to Describe a . . . Describing a For-Loop . . . – primitive recursion corresponds to for-loops, and Resulting Description . . . – mu-recursion corresponds to while-loops. Beyond For-Loops: A . . . • From this viewpoint: many theoretical results acquire Resulting Meaning natural practical meaning. Acknowledgment Home Page • Example: the result that not every computable func- tion is primitive recursive. Title Page ◭◭ ◮◮ • This is the first, simplest example of the diagonal con- struction that is later used in many other proofs. ◭ ◮ • Meaning of the result: Page 9 of 10 – while-loops are needed, Go Back – because not all computable functions can be com- Full Screen puted by using only for-loops. Close Quit

  10. 9. Acknowledgment Theory of . . . Pedagogical Problem Notion of a Recursive . . . This work was supported in part How to Describe a . . . Describing a For-Loop . . . • by the National Science Foundation grants HRD-0734825 Resulting Description . . . (Cyber-ShARE Center) and DUE-0926721, and Beyond For-Loops: A . . . Resulting Meaning • by Grant 1 T36 GM078000-01 from the National Insti- Acknowledgment tutes of Health. Home Page Title Page ◭◭ ◮◮ ◭ ◮ Page 10 of 10 Go Back Full Screen Close Quit

Recommend


More recommend