1 / 29

Cognitive Computing: 2012

This article explores the limitations of NORMA and proposes NORMA+, a new machine that addresses criticisms relating to operations, data types, access to data, and flowchart programs. Examples of how these criticisms can be overcome are provided.

hamel
Download Presentation

Cognitive Computing: 2012

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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. (c) Bishop: Consciousness and Computations

  3. 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. (c) Bishop: Consciousness and Computations

  4. 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. (c) Bishop: Consciousness and Computations

  5. 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; (c) Bishop: Consciousness and Computations

  6. Assignment to a register A := B using [a]; A := 0; A := A + B using a; (c) Bishop: Consciousness and Computations

  7. Subtraction A := A - B using [a, b]; a := B using b; WHILE (a <> 0) DO A := A - 1; a := a - 1; END; (c) Bishop: Consciousness and Computations

  8. 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; (c) Bishop: Consciousness and Computations

  9. 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; (c) Bishop: Consciousness and Computations

  10. 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; (c) Bishop: Consciousness and Computations

  11. 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 (c) Bishop: Consciousness and Computations

  12. 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] (c) Bishop: Consciousness and Computations

  13. On calculating the kth prime A := PRIME (K) {Stores the Kth 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; (c) Bishop: Consciousness and Computations

  14. 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 (c) Bishop: Consciousness and Computations

  15. 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. (c) Bishop: Consciousness and Computations

  16. 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. (c) Bishop: Consciousness and Computations

  17. 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. (c) Bishop: Consciousness and Computations

  18. 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 = P1a1× P2a2× P3a3 ... × Pnan, where Pj = jth prime. (c) Bishop: Consciousness and Computations

  19. 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. (c) Bishop: Consciousness and Computations

  20. 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 / b If b divides exactly into a = a otherwise (c) Bishop: Consciousness and Computations

  21. 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. (c) Bishop: Consciousness and Computations

  22. 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; (c) Bishop: Consciousness and Computations

  23. Proof of theorem 2 • The test ?(A [n] = 0) uses the test div (Pn, A) to RETURN the correct value, where Pn = 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. (c) Bishop: Consciousness and Computations

  24. 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} (c) Bishop: Consciousness and Computations

  25. 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. (c) Bishop: Consciousness and Computations

  26. Jump tables (c) Bishop: Consciousness and Computations

  27. 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} (c) Bishop: Consciousness and Computations

  28. 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. (c) Bishop: Consciousness and Computations

  29. 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. (c) Bishop: Consciousness and Computations

More Related