Module 12 Computation and Configurations Formal Definition 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
For(int i = 1; i
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
October 13, 2009Theory of Computation Lecture 11: A Universal Program III 1 Coding Programs by Numbers Gödel numbers are usually very large, even for small.
1 Module 20 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA (extra credit) and therefore.
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.
Lecture 2: Fundamental Concepts
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
1 Module 12 Computation and Configurations –Formal Definition –Important Terms –Examples.
Program Design and Development
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
1 Lecture 12 Computations –Formal Definition –Important Terms Computational Models –Formal Definition –Sequential access memory (tape) –Graphical representation.
1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Graphical representation –Formal.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapter 2 – Part 1.
1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Formal Definition –Equivalence.
Cook-Levin Theorem Circuit Satisfiability –A “first” NP-complete problem Reduction overview Example reduction.
Fall 2009ACS-1805 Ron McFadyen1 Ch 8 Recursion Recursion occurs when a method (or function) calls itself.
Requirements Model Inputs (Test Sequences) Expected outputs Implementation Verdict Author Generate Feedback.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 5 – Recursive Funtions From Deitel’s “C” Book 5.13Recursion 5.14Example Using Recursion: The Fibonacci.
Recursion Chapter 7 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
LANGUAGE TRANSLATORS: WEEK 24 TRANSLATION TO ‘INTERMEDIATE’ CODE (overview) Labs this week: Tutorial Exercises on Code Generation.
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.
1 CSC103: Introduction to Computer and Programming Lecture No 14.
FUNCTIONS AND STRUCTURED PROGRAMMING CHAPTER 10. Introduction A c program is composed of at least one function definition, that is the main() function.
Advanced Computer Architecture and Parallel Processing Rabie A. Ramadan http:
What's The Plan? Algorithmic Thinking Step-by-step directions for whatever someone, or the computer, needs to do © 2004 Lawrence Snyder.
I Power Higher Computing Software Development Development Languages and Environments.
Chapter 5 – Functions II Outline Recursion Examples Using Recursion: The Fibonacci Series.
User defined functions
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.
Manish K Parmar PGT (CS) K V VVNagar Thursday, December 24, 2015 Lesson on USER DEFINED FUNCTION IN C++ Presented by Manish K Parmar PGT Computer Science.
 Structure charts (last lesson)  Screen and page layout diagrams provide  A sketch of each page (screen) of the program  A list of the content, including.
Xiaojuan Cai Computational Thinking 1 Lecture 6 Defining Functions Xiaojuan Cai (蔡小娟) Fall, 2015.
4.3 Functions. Functions Last class we talked about the idea and organization of a function. Today we talk about how to program them.
CSC3315 (Spring 2009)1 CSC 3315 Lexical and Syntax Analysis Hamid Harroud School of Science and Engineering, Akhawayn University
Text Chapters 2 Analyzing Algorithms.  goal: predicting resources that an algorithm requires memory, communication bandwidth, hardware, memory, communication.
Methods Awesomeness!!!. Methods Methods give a name to a section of code Methods give a name to a section of code Methods have a number of important uses.
Learners Support Publications Introduction to C++
 Definition Definition  Algorithmic Representation of Computer Functions Algorithmic Representation of Computer Functions  Algorithm Description Algorithm.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
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
Functions, Part 1 of 3 Topics  Using Predefined Functions  Programmer-Defined Functions  Using Input Parameters  Function Header Comments Reading 
Computer Programming II Lecture 4. Functions - In C++ we use modules to divide the program into smaller and manageable code. These modules are called.
MUTACINIS TESTAVIMAS Benediktas Knispelis, IFM-2/2 Mutation testing.
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:
Control Structures: Examples. for-loop example Q: If a=1, b=3, and x=7, what is the value of x when the loop terminates? A: x=1 for(k=a; k
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
Simone Campanoni CFA Simone Campanoni
Chapter 6: User-Defined Functions I
ALGORITHMS part-1.
Functions in C Mrs. Chitra M. Gaikwad.
2011/11/20: Lecture 15 CMSC 104, Section 4 Richard Chang
Value returning Functions
Introduction to Algorithms
Translate, Rotate, Matrix
Theory of Computation Lecture 21: Turing Machines II
… NPDAs continued.
 Is a machine that is able to take information (input), do some work on (process), and to make new information (output) COMPUTER.
Presentation transcript:

Module 12 Computation and Configurations Formal Definition Examples

Definitions Configuration Computation 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

Computation 1 Line 1, x=?,y=?,r=? Line 2, x=10, y=3,r=? 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

Computation 2 Input: 53 10 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: 53 10 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 ...

Computations 1 and 2 Line 1, x=?,y=?,r=? Line 2, x=10, y=3,r=? Output is 1 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 ...

Observation int main(int x,y) { 2 int r = x % y; 3 if (r== 0) goto 8; 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? No! Both previous inputs, 10 3 as well as 53 10 eventually reached the same configuration (Line 3, x=10, y=3, r=1)