Register machines L2 18

Similar documents
Models of Computation, Recall Register Machines. A register machine (sometimes abbreviated to RM) is specified by:

Parallelism and Machine Models

CSE 200 Lecture Notes Turing machine vs. RAM machine vs. circuits

CSC : Homework #3

WUCT121. Discrete Mathematics. Numbers

Algorithms (II) Yu Yu. Shanghai Jiaotong University

Honors Advanced Mathematics November 4, /2.6 summary and extra problems page 1 Recap: complex numbers

Decidability: Church-Turing Thesis

20.1 2SAT. CS125 Lecture 20 Fall 2016

8.5 Taylor Polynomials and Taylor Series

Review: complex numbers

Proofs. Chapter 2 P P Q Q

VOYAGER INSIDE ALGEBRA CORRELATED TO THE NEW JERSEY STUDENT LEARNING OBJECTIVES AND CCSS.

DRAFT. Algebraic computation models. Chapter 14

CST Part IB. Computation Theory. Andrew Pitts

CSE 20 DISCRETE MATH. Winter

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

The final is cumulative, but with more emphasis on chapters 3 and 4. There will be two parts.

Discrete Mathematics CS October 17, 2006

Chapter 5. Finite Automata

Parent Guide. Number System. Diocese of Cleveland

Math 3 Unit 5: Polynomial and Rational Representations and Modeling

A field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties:

f(x) = 2x + 5 3x 1. f 1 (x) = x + 5 3x 2. f(x) = 102x x

Semester Review Packet

Course: Algebra MP: Reason abstractively and quantitatively MP: Model with mathematics MP: Look for and make use of structure

Fall 2017 Test II review problems

Predicate Calculus - Undecidability of predicate calculus Moonzoo Kim CS Dept. KAIST

ALGEBRA GRADE 7 MINNESOTA ACADEMIC STANDARDS CORRELATED TO MOVING WITH MATH. Part B Student Book Skill Builders (SB)

Algebra II. Algebra II Higher Mathematics Courses 77

MATH III CCR MATH STANDARDS

Prentice Hall: Algebra 2 with Trigonometry 2006 Correlated to: California Mathematics Content Standards for Algebra II (Grades 9-12)

CCSS Math- Algebra. Domain: Algebra Seeing Structure in Expressions A-SSE. Pacing Guide. Standard: Interpret the structure of expressions.

1 Introduction to information theory

Mathematics - High School Algebra II

CSC 474 Information Systems Security

Topics Covered in Math 115

Algebra 2 (2006) Correlation of the ALEKS Course Algebra 2 to the California Content Standards for Algebra 2

Mathematics High School Algebra

Rational Exponents. Polynomial function of degree n: with leading coefficient,, with maximum number of turning points is given by (n-1)

YOU CAN BACK SUBSTITUTE TO ANY OF THE PREVIOUS EQUATIONS

Lecture 21: Algebraic Computation Models

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

1 Introduction (January 21)

30 Classification of States

MATH FINAL EXAM REVIEW HINTS

Chapter 4 Finite Fields

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Mathematical Foundations of Cryptography

Algebra II Introduction 1

Predicate Logic - Undecidability

PRACTICE PROBLEMS: SET 1

40h + 15c = c = h

Algebra 2 Secondary Mathematics Instructional Guide

Functional Programming Laboratory 3

Complexity, P and NP

Sequential programs. Uri Abraham. March 9, 2014

, a 1. , a 2. ,..., a n

2 Elementary number theory

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

2.6 Variations on Turing Machines

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

Assignment #2 COMP 3200 Spring 2012 Prof. Stucki

Space Complexity. The space complexity of a program is how much memory it uses.

Analysis of California Mathematics standards to Common Core standards Algebra I

Algebra 2 Khan Academy Video Correlations By SpringBoard Activity

Algebra 2 Khan Academy Video Correlations By SpringBoard Activity

The Euclidean Algorithm and Multiplicative Inverses

Honors Algebra I

CHAPTER 11. A Revision. 1. The Computers and Numbers therein

Tenth Bit Bank Mathematics Real Numbers

Pre Calculus Gary Community School Corporation Unit Planning Map

X-machines - a computational model framework.

+ 1 3 x2 2x x3 + 3x 2 + 0x x x2 2x + 3 4

LESSON RELATIONS & FUNCTION THEORY

P.1. Real Numbers. Copyright 2011 Pearson, Inc.

DR.RUPNATHJI( DR.RUPAK NATH )

Math 203A - Solution Set 1

ALGEBRA II CURRICULUM MAP

Quadratics and Other Polynomials

Sets. We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth

where Q is a finite set of states

3. Algorithms. What matters? How fast do we solve the problem? How much computer resource do we need?

Comparison of Virginia s College and Career Ready Mathematics Performance Expectations with the Common Core State Standards for Mathematics

CSE 20 DISCRETE MATH. Fall

CS 125 Section #10 (Un)decidability and Probability November 1, 2016

Common Core State Standards for Mathematics - High School PARRC Model Content Frameworks Mathematics Algebra 2

The Turing Machine. CSE 211 (Theory of Computation) The Turing Machine continued. Turing Machines

8 Primes and Modular Arithmetic

Mathematics AKS

Proofs. Chapter 2 P P Q Q

CA Compiler Construction

On String Languages Generated by Numerical P Systems

Dataflow analysis. Theory and Applications. cs6463 1

Chapter 7 Polynomial Functions. Factoring Review. We will talk about 3 Types: ALWAYS FACTOR OUT FIRST! Ex 2: Factor x x + 64

32 Divisibility Theory in Integral Domains

Turing Machines. Wolfgang Schreiner

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5

Numbers. Dr Hammadi Nait-Charif. Senior Lecturer Bournemouth University United Kingdom

INSPECT Algebra I Summative Assessment Summary

Transcription:

Register machines L2 18

Algorithms, informally L2 19 No precise definition of algorithm at the time Hilbert posed the Entscheidungsproblem, just examples. Common features of the examples: finite description of the procedure in terms of elementary operations deterministic (next step uniquely determined if there is one) procedure may not terminate on some input data, but we can recognize when it does terminate and what the result is.

Register Machines, informally L2 20 They operate on natural numbers N = {0, 1, 2,...} stored in (idealized) registers using the following elementary operations : add 1 to the contents of a register test whether the contents of a register is 0 subtract 1 from the contents of a register if it is non-zero jumps ( goto ) conditionals ( if_then_else_ )

Definition. A register machine is specified by: finitely many registers R 0, R 1,..., R n (each capable of storing a natural number); a program consisting of a finite list of instructions of the form label : body, where for i = 0, 1, 2,..., the (i+ 1) th instruction has label L i. L2 21

Definition. A register machine is specified by: L2 21 finitely many registers R 0, R 1,..., R n (each capable of storing a natural number); a program consisting of a finite list of instructions of the form label : body, where for i = 0, 1, 2,..., the (i+ 1) th instruction has label L i. Instruction body takes one of three forms: R + L R L, L HALT add 1 to contents of register R and jump to instruction labelled L if contents of R is > 0, then subtract 1 from it and jump to L, else jump to L stop executing instructions

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2 1 0 0 2

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2 1 0 0 2 0 1 0 2

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2 1 0 0 2 0 1 0 2 2 1 0 2

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2 1 0 0 2 0 1 0 2 2 1 0 2 3 1 0 1

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2 1 0 0 2 0 1 0 2 2 1 0 2 3 1 0 1 2 2 0 1

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2 1 0 0 2 0 1 0 2 2 1 0 2 3 1 0 1 2 2 0 1 3 2 0 0

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2 1 0 0 2 0 1 0 2 2 1 0 2 3 1 0 1 2 2 0 1 3 2 0 0 2 3 0 0

L2 22 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example example computation: L i R 0 R 1 R 2 0 0 1 2 1 0 0 2 0 1 0 2 2 1 0 2 3 1 0 1 2 2 0 1 3 2 0 0 2 3 0 0 4 3 0 0

Register machine computation L2 23 Register machine configuration: c = (l, r 0,..., r n ) where l = current label and r i = current contents of R i. Notation: R i = x [in configuration c] means c = (l, r 0,..., r n ) with r i = x.

Register machine computation L2 23 Register machine configuration: c = (l, r 0,..., r n ) where l = current label and r i = current contents of R i. Notation: R i = x [in configuration c] means c = (l, r 0,..., r n ) with r i = x. Initial configurations: c 0 = (0, r 0,..., r n ) where r i = initial contents of register R i.

Register machine computation L2 24 A computation of a RM is a (finite or infinite) sequence of configurations c 0, c 1, c 2,... where c 0 = (0, r 0,..., r n ) is an initial configuration each c = (l, r 0,..., r n ) in the sequence determines the next configuration in the sequence (if any) by carrying out the program instruction labelled L l with registers containing r 0,...,r n.

Halting L2 25 For a finite computation c 0, c 1,..., c m, the last configuration c m = (l, r,...) is a halting configuration, i.e. instruction labelled L l is either HALT (a proper halt ) or R + L, or R L, L with R > 0, or R L, L with R = 0 and there is no instruction labelled L in the program (an erroneous halt )

Halting L2 25 For a finite computation c 0, c 1,..., c m, the last configuration c m = (l, r,...) is a halting configuration, i.e. instruction labelled L l is either HALT (a proper halt ) or R + L, or R L, L with R > 0, or R L, L with R = 0 and there is no instruction labelled L in the program (an erroneous halt ) E.g. L 0 : R + 0 L 2 L 1 : HALT halts erroneously.

Halting L2 25 For a finite computation c 0, c 1,..., c m, the last configuration c m = (l, r,...) is a halting configuration, i.e. instruction labelled L l is either HALT (a proper halt ) or R + L, or R L, L with R > 0, or R L, L with R = 0 and there is no instruction labelled L in the program (an erroneous halt ) N.B. can always modify programs (without affecting their computations) to turn all erroneous halts into proper halts by adding extra HALT instructions to the list with appropriate labels.

Halting L2 25 For a finite computation c 0, c 1,..., c m, the last configuration c m = (l, r,...) is a halting configuration. Note that computations may never halt. For example, L 0 : R + 0 L 0 L 1 : HALT only has infinite computation sequences (0, r),(0, r+ 1),(0, r+ 2),...

Graphical representation L2 26 one node in the graph for each instruction arcs represent jumps between instructions lose sequential ordering of instructions so need to indicate initial instruction with START. instruction representation R + L R + [L] [L] R L, L R [L ] HALT HALT L 0 START [L 0 ]

L2 27 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example graphical representation: START R 1 R + 0 R 2 R + 0 HALT

L2 27 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example graphical representation: START R 1 R + 0 R 2 R + 0 HALT

L2 27 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example graphical representation: START R 1 R + 0 R 2 R + 0 HALT Claim: starting from initial configuration (0, 0, x, y), this machine s computation halts with configuration (4, x+y, 0, 0).

L2 27 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example graphical representation: START R 1 R + 0 R 2 R + 0 HALT Claim: starting from initial configuration (0, 0, x, y), this machine s computation halts with configuration (4, x+y, 0, 0).

L2 27 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example graphical representation: START R 1 R + 0 R 2 R + 0 HALT Claim: starting from initial configuration (0, 0, x, y), this machine s computation halts with configuration (4, x+y, 0, 0).

Partial functions Register machine computation is deterministic: in any non-halting configuration, the next configuration is uniquely determined by the program. So the relation between initial and final register contents defined by a register machine program is a partial function... L2 28

Partial functions Register machine computation is deterministic: in any non-halting configuration, the next configuration is uniquely determined by the program. So the relation between initial and final register contents defined by a register machine program is a partial function... L2 28 Definition. A partial function from a set X to a set Y is specified by any subset f X Y satisfying (x, y) f (x, y ) f y = y for all x X and y, y Y.

Partial functions L2 28 ordered pairs {(x, y) x X y Y} i.e. for all x X there is at most one y Y with (x, y) f Definition. A partial function from a set X to a set Y is specified by any subset f X Y satisfying (x, y) f (x, y ) f y = y for all x X and y, y Y.

L2 28 Notation: Partial functions f(x) = y means (x, y) f f(x) means y Y ( f(x) = y) f(x) means y Y ( f(x) = y) X Y = set of all partial functions from X to Y X Y = set of all (total) functions from X to Y Definition. A partial function from a set X to a set Y is specified by any subset f X Y satisfying (x, y) f (x, y ) f y = y for all x X and y, y Y.

L2 28 Notation: Partial functions f(x) = y means (x, y) f f(x) means y Y ( f(x) = y) f(x) means y Y ( f(x) = y) X Y = set of all partial functions from X to Y X Y = set of all (total) functions from X to Y Definition. A partial function from a set X to a set Y is total if it satisfies f(x) for all x X.

Computable functions Definition. f N n N is (register machine) computable if there is a register machine M with at least n+1 registers R 0, R 1,..., R n (and maybe more) such that for all (x 1,..., x n ) N n and all y N, the computation of M starting with R 0 = 0, R 1 = x 1,..., R n = x n and all other registers set to 0, halts with R 0 = y if and only if f(x 1,..., x n ) = y. Note the [somewhat arbitrary] I/O convention: in the initial configuration registers R 1,..., R n store the function s arguments (with all others zeroed); and in the halting configuration register R 0 stores it s value (if any). L2 29

L2 29 Computable functions Definition. f N n N is (register machine) computable if there is a register machine M with at least n+1 registers R 0, R 1,..., R n (and maybe more) such that for all (x 1,..., x n ) N n and all y N, the computation of M starting with R 0 = 0, R 1 = x 1,..., R n = x n and all other registers set to 0, halts with R 0 = y if and only if f(x 1,..., x n ) = y. N.B. there may be many different M that compute the same partial function f.

L2 30 registers: R 0 R 1 R 2 program: L 0 : R 1 L 1, L 2 L 1 : R + 0 L 0 L 2 : R 2 L 3, L 4 L 3 : R + 0 L 2 L 4 : HALT Example graphical representation: START R 1 R + 0 R 2 R + 0 HALT Claim: starting from initial configuration (0, 0, x, y), this machine s computation halts with configuration (4, x+y, 0, 0). So f(x, y) x+y is computable.

Multiplication f(x, y) xy is computable L2 32 START R + 3 R 1 R 2 R + 0 HALT R 3 R + 2

Multiplication f(x, y) xy is computable L2 32 START R + 3 R 1 R 2 R + 0 HALT R 3 R + 2

Multiplication f(x, y) xy is computable L2 32 START R + 3 R 1 R 2 R + 0 HALT R 3 R + 2

Multiplication f(x, y) xy is computable L2 32 START R + 3 R 1 R 2 R + 0 HALT R 3 R + 2

Multiplication f(x, y) xy is computable L2 32 START R + 3 R 1 R 2 R + 0 HALT R 3 R + 2 If the machine is started with (R 0, R 1, R 2, R 3 ) = (0, x, y, 0), it halts with (R 0, R 1, R 2, R 3 ) = (xy, 0, y, 0).

Further examples The following arithmetic functions are all computable. (Proof left as an exercise!) projection: p(x, y) x constant: c(x) n truncated subtraction: x y { x y if y x 0 if y > x L2 33

Further examples L2 33 The following arithmetic functions are all computable. (Proof left as an exercise!) integer division: { integer part of x/y if y > 0 x div y 0 if y = 0 integer remainder: x mod y x y(x div y) exponentiation base 2: e(x) 2 x logarithm base { 2: greatest y such that 2 log 2 (x) y x if x > 0 0 if x = 0