Cognitive Computing: 2012 Consciousness and Computation: computing machinery & intelligence 3. EMULATION Mark Bishop.

Slides:



Advertisements
Similar presentations
Cognitive Computing 2013 Consciousness and Computations 8. THE REDUCTION PRINCIPLE Prof. Mark Bishop.
Advertisements

Cognitive Computing: 2012 Consciousness and Computation: computing machinery and intelligence 4. NORMA PROGRAM SPEEDUP Mark Bishop.
Cognitive Computing 2013 Consciousness and Computations 7. THE SELF APPLICABILITY PROBLEM (SAP); PENROSE ON UNDERSTANDING UNDERSTANDING Mark Bishop.
Cognitive Computing 2012 Consciousness and Computation: computing machinery and intelligence 2. ON NORMA AND nCODING Mark Bishop.
Restricted Machines Presented by Muhannad Harrim.
Intermediate Code Generation
Machine Instructions Operations
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
INSTRUCTION SET ARCHITECTURES
Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
Chapter 8 ICS 412. Code Generation Final phase of a compiler construction. It generates executable code for a target machine. A compiler may instead generate.
There are two types of addressing schemes:
Instruction Set Architecture
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Instruction Set Architecture & Design
TK 2633 Microprocessor & Interfacing
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Program Design and Development
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
1 CS Programming Languages Random Access Machines Jeremy R. Johnson.
Lecture 18 Last Lecture Today’s Topic Instruction formats
Slide 5-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
Copyright © 2010 Pearson Education, Inc
Computer Arithmetic Nizamettin AYDIN
Machine Instruction Characteristics
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Computer Architecture and the Fetch-Execute Cycle
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
Registers and MAL Lecture 12. The MAL Architecture MAL is a load/store architecture. MAL supports only those addressing modes supported by the MIPS RISC.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
CPS120: Introduction to Computer Science Operations Lecture 9.
Execution of an instruction
Copyright © 2009 Pearson Education, Inc. Chapter 5 Section 1 - Slide 1 Chapter 1 Number Theory and the Real Number System.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
A summary of TOY. 4 Main Components Data Processor Control Processor Memory Input/Output Device.
More on MIPS programs n SPIM does not support everything supported by a general MIPS assembler. For example, –.end doesn’t work Use j $ra –.macro doesn’t.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
What is a program? A sequence of steps
Chapter 7 Bit Manipulation. 7.1 Logical Operations.
LECTURE 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
Integer Operations Computer Organization and Assembly Language: Module 5.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
Calculate the Following (Group A): – – (-5) (-5) 5. 3 – (+5)
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Slide Copyright © 2009 Pearson Education, Inc. Slide Copyright © 2009 Pearson Education, Inc. Chapter 1 Number Theory and the Real Number System.
William Stallings Computer Organization and Architecture 8th Edition
Classification of Instruction Set of 8051
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
Subroutines and the Stack
Presented by: Chi Yan Hung
A Closer Look at Instruction Set Architectures: Expanding Opcodes
6.001 SICP Stacks and recursion
11/10/2018.
Operators and Expressions
ECEG-3202 Computer Architecture and Organization
Chapter 3: Selection Structures: Making Decisions
Chapter 3: Selection Structures: Making Decisions
Some Assembly (Part 2) set.html.
COMPUTING.
Presentation transcript:

Cognitive Computing: 2012 Consciousness and Computation: computing machinery & intelligence 3. EMULATION Mark Bishop

01/04/2014(c) Bishop: Consciousness and Computations2 The Universal Machine Norma Thesis: With suitable coding of data, every algorithm can be represented as a flowchart program for NORMA. But how? Some obvious criticisms of NORMA include... 1: NORMA does not define enough operations and tests: No assignment, multiply, subtract, divide etc. 2: NORMA data types are too restricted: No provision for negative or floating point numbers. 3: Access to data is too restricted: No provision for ARRAYs of numbers. 4: The restriction to flowchart programs is too restrictive: No mechanism for procedures. At the very least one needs to be able to refer to labels indirectly so that sub-routines can be constructed. 5: Other criticisms include: The lack of string handling. No logical shifts etc. The criticisms [1..4] are considered the most important.

01/04/2014(c) Bishop: Consciousness and Computations3 Informal proof of thesis To demonstrate that every algorithm can be coded as a NORMA flowchart program it is necessary to show how each of the main criticisms [1..4] can be answered. Specify a new machine NORMA+ which has the desired feature. Show how any program in NORMA+ can be –recoded as a flowchart program for NORMA.

01/04/2014(c) Bishop: Consciousness and Computations4 Answer to 1st criticism Assignment to a constant (eg. A := 0) Theorem: Every WHILE program can be mapped onto a corresponding flowchart program. WHILE (A <> 0) DO A := A -1; END; This WHILE program can be written as a macro. Similar macros can be written for (A := 1), (A := 2) etc.

01/04/2014(c) Bishop: Consciousness and Computations5 Addition A := A + B using [a]; Consider a macro to calculate (A := A + B). We need to use an extra register a, hence we write the macro as {A := A + B using a} a := 0; WHILE (B <> 0) DO {adds B into A and makes a copy of B} A := A + 1; a := a + 1; B := B - 1; END; WHILE (a <> 0) DO {resets B to original value} a := a - 1; B := B + 1; END;

01/04/2014(c) Bishop: Consciousness and Computations6 Assignment to a register A := B using [a]; A := 0; A := A + B using a;

01/04/2014(c) Bishop: Consciousness and Computations7 Subtraction A := A - B using [a, b]; a := B using b; WHILE (a <> 0) DO A := A - 1; a := a - 1; END;

01/04/2014(c) Bishop: Consciousness and Computations8 Register Test Operations 1 ?(A < 2) using [a, b]; IF ?(A < 2) THEN L2: TRUE ELSE L1: FALSE END; a := A using b; IF (a = 0) THEN GOTO L2; a := a - 1; IF (a = 0) THEN GOTO L2; L1:FALSE; L2:TRUE;

01/04/2014(c) Bishop: Consciousness and Computations9 Multiplication A := A x B using a, b, c; a := A using b; b := B using c; A := 0; WHILE (b <> 0) DO A := A + a using c; b := b - 1; END;

01/04/2014(c) Bishop: Consciousness and Computations10 Division A := A DIV B using [a..e]; {Remainder held in e} e := A using a; A := 0; WHILE (e >= B using [a..c]) DO e := e - B using d; {[a..c] still in use} INC A END;

NORMA and primes: on testing for integer division Div (A, B)? {True iff A is exactly divisible by B} a := A; WHILE (a >= B) DO a := a – B; IF (a = 0) THEN GOTO Label-Divisible ELSE GOTO Label-NOT-Divisible 01/04/2014(c) Bishop: Consciousness and Computations11

On the testing for prime aPrime (A)?{NB. Zero and one are neither prime nor composite} IF (A < 2) THEN GOTO [Label-NOT-Prime] j := A - 1; WHILE NOT (Div (A, j) DO j := j – 1; IF (j = 1) THEN GOTO [Label-Prime] ELSE GOTO [Label-NOT-Prime] 01/04/2014(c) Bishop: Consciousness and Computations12

On calculating the k th prime A := PRIME (K){Stores the K th prime in A, where the 1st prime is 2} A := 0; k := K; WHILE (k <> 0) DO k := k – 1; A := A + 1; WHILE NOT ( aPrime (A) ) DO A := A + 1; END; 01/04/2014(c) Bishop: Consciousness and Computations13

01/04/2014(c) Bishop: Consciousness and Computations14 Answer to criticism 2 Representing negative numbers An arbitrary integer m can easily be represented as the order pair (n, d) of non negative integers: n = |m| d = 0 IF (m >= 0) d = 1 otherwise

01/04/2014(c) Bishop: Consciousness and Computations15 Representing fixed length real numbers Using a similar idea to that used for negative numbers, operations on a non negative rational number r can be defined in terms of the ordered pair (a, b), where (b > 0) and (r = a/b). Since arithmetic on rationals conforms to the following rules: Addition & Subtraction (a,b) ± (c,d) = (ad ± bc, bd) Multiplication (a,b) × (c,d) = (ac, bd) Division (a,b) / (c,d) = (ad, bc) iff (c <> 0) Equality ?((a,b) = (c,d)) iff (ad = bc)... there is no problem constructing appropriate NORMA programs using fixed length reals.

01/04/2014(c) Bishop: Consciousness and Computations16 Answer to 3rd criticism To answer criticism 3 we define a new machine SAM (Simple Array Machine) with more flexible access to data. SAM augments NORMA by possessing the array of registers, A[1], A [2].... A [n] in addition to the standard registers A,B.... Y, which are now referred to as index registers. The operations defined by SAM are those of NORMA plus the array operations: A [J] := A [J] + 1; A [J] := A [J] - 1; where J is any index register. A [n] := A [n] + 1; A [n] := A [n] - 1; where n is any positive integer.

01/04/2014(c) Bishop: Consciousness and Computations17 Array test operations SAM also has the array test operations: ?(A [J] = 0) ?(A [n] = 0) SAMs input and output functions are the same as NORMAs except that the input function also initialises each array register to zero.

01/04/2014(c) Bishop: Consciousness and Computations18 Theorem 2: NORMA can simulate SAM Proof: We have to show how any given program P for SAM can be translated into a NORMA program Q such that: NORMA (Q) = SAM (P) Method: Pack all of SAM array into a single NORMA register. If at some stage in the computation a SAM array contains [a1, a2,.. an] then at the equivalent stage a NORMA register will contain A. A = P 1 a1 × P 2 a2 × P 3 a3... × P n an, where P j = j th prime.

01/04/2014(c) Bishop: Consciousness and Computations19 Increment indexed array To define Q from P, we translate each SAM instruction into a sequence of NORMA instructions as follows: All index register instructions are left unchanged. Array operations of the form A [J] := A [J] + 1 are translated into: B := PRIME (J); A := A × B Where PRIME is the PRIME number function defined earlier.

01/04/2014(c) Bishop: Consciousness and Computations20 Decrement indexed array Array operations of the form A [J] := A [J] - 1 are translated into: B := PRIME (J); A := A DIV B; Where DIV is a special integer division defined by: a DIV b= a / bIf b divides exactly into a = aotherwise

01/04/2014(c) Bishop: Consciousness and Computations21 Testing an array element A test of the form ?(A [J] <> 0) is translated into: B := PRIME (J) RETURN div (A, B) Where div (A,B) is TRUE when A is exactly divisible by B and FALSE otherwise. ie. The test div (A, B) will return TRUE just in the case that A [J] 0.

01/04/2014(c) Bishop: Consciousness and Computations22 INC and DEC array using a constant index, n An operation of the form (A [n] = A [n] + 1) is translated into: B := PRIME (n); A := A × B; Similarly (A [n] = A [n] - 1) is translated into: B := PRIME (n); A := A DIV B;

01/04/2014(c) Bishop: Consciousness and Computations23 Proof of theorem 2 The test ?(A [n] = 0) uses the test div (P n, A) to RETURN the correct value, where P n = PRIME (n). Now each operation and test of Q must be replaced by the corresponding NORMA macro; And if we ensure that Q initially sets A to 1 to represent the input condition of SAMs array then … … the simulation clearly works and hence Theorem 2 is proved.

01/04/2014(c) Bishop: Consciousness and Computations24 Answer to criticism 4 - only flowcharts To answer criticism 4 we need to define a new machine SIM (Simple Indirect Machine). In a SIM program P with labels (1.. l.. k), the operations defined by SIM are those given by NORMA plus the following two Indirect Jump calls: l:GOTO (A);{GOTO a where a is the content of register A} l:IF (T) THEN GOTO (A); {IF TRUE GOTO label a}

01/04/2014(c) Bishop: Consciousness and Computations25 Theorem 3: NORMA can simulate SIM Proof: We have to show how any given program P for SIM can be translated into a NORMA program Q such that: NORMA (Q) = SIM (P) Method: Use a Jump Table. For each register (eg. A) that appears in the program we need to define an extra segment of code, tableA.

01/04/2014(c) Bishop: Consciousness and Computations26 Jump tables

01/04/2014(c) Bishop: Consciousness and Computations27 For the SIM Indirected jump This extra code can be added after instruction k of SIM program P. We can now replace the new SIM instructions by the following NORMA code: SIM l:GOTO (A); NORMA l:GOTO tableA; {Where tableA is label of jump table for the A reg}

01/04/2014(c) Bishop: Consciousness and Computations28 The SIM indirected test SIM l:IF (T) THEN GOTO (A); NORMA l:IF (T) THEN GOTO tableA; {Where tableA is label of the jump table for the A register} Now each operation and test of SIM Q must be replaced by the corresponding NORMA macro. It is now clear that the resulting NORMA program Q is equivalent to the SIM program P. The simulation clearly works and hence Theorem 3 is proved.

HOMEWORK: Implement NORMA_STACK Prove that the machine NORMA_STACK is no more powerful than the universal machine NORMA by designing two MACROs to implement: (a) X=POP which removes the top value from the STACK and places it into the X register; (b) PUSH (X) which places the contents of the X register on to the top of the STACK; and submit a short (no more than 1-page) report detailing their operation. 01/04/2014(c) Bishop: Consciousness and Computations29