1 Module 12 Computation and Configurations –Formal Definition –Important Terms –Examples.

Slides:



Advertisements
Similar presentations
User-Defined Functions Like short programs Can operate on their own data Can receive data from callers and return data to callers.
Advertisements

Theory of Computer Science - Algorithms
Dry Runs and Trace Tables
Functional Verification III Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 23.
Control Flow Analysis (Chapter 7) Mooly Sagiv (with Contributions by Hanne Riis Nielson)
Chapter 5 ( ) of Programming Languages by Ravi Sethi
Translate, Rotate, Matrix Pages Function Function Definition Calling a function Parameters Return type and return statement.
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
1 Module 15 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
1 Module 19 LNFA subset of LFSA –Theorem 4.1 on page 131 of Martin textbook –Compare with set closure proofs Main idea –A state in FSA represents a set.
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
1 Lecture 16 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
Program Design and Development
1 Lecture 12 Computations –Formal Definition –Important Terms Computational Models –Formal Definition –Sequential access memory (tape) –Graphical representation.
Module 12 Computation and Configurations Formal Definition Examples.
1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Graphical representation –Formal.
Revision Using Recursion1 Recursion. Revision Using Recursion2 Recall the Recursion Pattern Recursion: when a method calls itself Classic example--the.
Copyright © 2003 Pearson Education, Inc. Slide 1.
1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Formal Definition –Equivalence.
Requirements Model Inputs (Test Sequences) Expected outputs Implementation Verdict Author Generate Feedback.
Recursion.
Exercise Find the opposite (additive inverse) of 4.3. – 4.3.
7.5 Inverse Function 3/13/2013. x2x+ 3 x What do you notice about the 2 tables (The original function and it’s inverse)? The.
Recursion Chapter 7 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Lecture 8. How to Form Recursive relations 1. Recap Asymptotic analysis helps to highlight the order of growth of functions to compare algorithms Common.
LANGUAGE TRANSLATORS: WEEK 24 TRANSLATION TO ‘INTERMEDIATE’ CODE (overview) Labs this week: Tutorial Exercises on Code Generation.
10/14/2015cosc237/recursion1 Recursion A method of defining a concept which refers to the concept itself A method of solving a problem by reducing it to.
Lecture 12 Recursion part 1 Richard Gesick. Recursion A recursive method is a method that calls itself. A recursive method is capable of solving only.
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
Previously Repetition Structures While, Do-While, For.
Advanced Computer Architecture and Parallel Processing Rabie A. Ramadan http:
Differentiability for Functions of Two (or more!) Variables Local Linearity.
The Law of Diminishing Returns: a. Given a fixed factor (i.e. “In the short run …”) b. if a large enough quantity of a variable factor is used c. then.
I Power Higher Computing Software Development Development Languages and Environments.
Chapter 5 – Functions II Outline Recursion Examples Using Recursion: The Fibonacci Series.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Algorithms and Programming Functions Lecture 28. Summary of Previous Lecture while statement for statement break statement Nested loops.
KIC/Computer Programming & Problem Solving 1.  Header Files  Storage Classes  Scope Rules  Recursion Outline KIC/Computer Programming & Problem Solving.
Python Functions : chapter 3
Solving Complex Problems. Review A subroutine is a set of instructions to perform a particular computation –used to solve subproblems of more complex.
4.3 Functions. Functions Last class we talked about the idea and organization of a function. Today we talk about how to program them.
Text Chapters 2 Analyzing Algorithms.  goal: predicting resources that an algorithm requires memory, communication bandwidth, hardware, memory, communication.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
1 CSC103: Introduction to Computer and Programming Lecture No 16.
Review. Problem 1 What is the output of the following piece of code void increment(int x) { x++; } int main() { int y = 10; increment(y); cout
The Law of Diminishing Returns: a. Given a fixed factor (i.e. “In the short run …”) b. if a large enough quantity of a variable factor is used c. then.
Nested For Loops. First, the rules to these loops do not change. We are sticking one loop inside another. while(condition) { // loop body } do { // loop.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
FUNCTIONS (C) KHAERONI, M.SI. OBJECTIVE After this topic, students will be able to understand basic concept of user defined function in C++ to declare.
Program Development and Design Using C++, Third Edition
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Notes:Relations and Functions Section 1-6 Student Objective: The students will be able to identify relations and functions and evaluate functions. 1.Definitions:
Recursion Chapter 10 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
Pseudocode FORTRAN (original) INPUT number
Instructions for test_function
Functions + Overloading + Scope
Chapter 6: User-Defined Functions I
ALGORITHMS part-1.
ALGORITHM Basic CONCEPTS of Basic Concepts of Algorithm
What should we teach regarding…
Lecture 17 Recursion part 1 Richard Gesick.
Introduction to Algorithms
PPT1: How failures come to be
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Marginal product first rises due to increasing marginal returns and then falls due to diminishing marginal returns. Adding workers first increases output.
Lecture 12 Recursion part 1 CSE /26/2018.
Programming with Recursion
CSE 1020:Software Development
 Is a machine that is able to take information (input), do some work on (process), and to make new information (output) COMPUTER.
Presentation transcript:

1 Module 12 Computation and Configurations –Formal Definition –Important Terms –Examples

2 Computations and Configurations

3 Computations * What is a computation? Is the computation just the output produced by running P on x? –No, we define a computation to be a trace of the entire execution

4 Exercise * 1 int main(int x,y) { 2 int r = x % y; 3 if (r== 0) goto 8; 4 x = y; 5 y = r; 6 r = x % y; 7 goto 3; 8 return y; } Execute the above program on input

5 Definitions Configuration –Functional Definition Given the original program and the current configuration of a computation, someone should be able to complete the computation –Contents of a configuration for a C ++ program current instruction to be executed current value of all variables Computation –Complete sequence of configurations

6 Computation 1 1 int main(int x,y) { 2 int r = x % y; 3 if (r== 0) goto 8; 4 x = y; 5 y = r; 6 r = x % y; 7 goto 3; 8 return y; } Input: 10 3 Line 1, x=?,y=?,r=? Line 2, x=10, y=3,r=? Line 3, x=10, y=3, r=1 Line 4, x=10, y=3, r=1 Line 5, x= 3, y=3, r=1 Line 6, x=3, y=1, r=1 Line 7, x=3, y=1, r=0 Line 3, x=3, y=1, r=0 Line 8, x=3, y=1, r=0 Output is 1

7 Computation 2 int main(int x,y) { 2 int r = x % y; 3 if (r== 0) goto 8; 4 x = y; 5 y = r; 6 r = x % y; 7 goto 3; 8 return y; } Input: Line 1, x=?,y=?,r=? Line 2, x=53, y=10, r=? Line 3, x= 53, y=10, r=3 Line 4, x=53, y=10, r=3 Line 5, x=10, y=10, r=3 Line 6, x=10, y=3, r=3 Line 7, x=10, y=3, r=1 Line 3, x=10, y=3, r=1...

8 Computations 1 and 2 Line 1, x=?,y=?,r=? Line 2, x=53, y=10, r=? Line 3, x= 53, y=10, r=3 Line 4, x=53, y=10, r=3 Line 5, x=10, y=10, r=3 Line 6, x=10, y=3, r=3 Line 7, x=10, y=3, r=1 Line 3, x=10, y=3, r=1... Line 1, x=?,y=?,r=? Line 2, x=10, y=3,r=? Line 3, x=10, y=3, r=1 Line 4, x=10, y=3, r=1 Line 5, x= 3, y=3, r=1 Line 6, x=3, y=1, r=1 Line 7, x=3, y=1, r=0 Line 3, x=3, y=1, r=0 Line 8, x=3, y=1, r=0 Output is 1

9 Observation * int main(int x,y) { 2 int r = x % y; 3 if (r== 0) goto 8; 4 x = y; 5 y = r; 6 r = x % y; 7 goto 3; 8 return y; } Line 3, x= 10, y=3, r=1 Program and current configuration –Together, these two pieces of information are enough to complete the computation –Are they enough to determine what the original input was? Uncertain Both previous inputs, 10 3 as well as eventually reached above configuration