Numerical Representation of Strings

Slides:



Advertisements
Similar presentations
November 19, 2009Theory of Computation Lecture 19: Calculations on Strings IV 1 Numerical Representation of Strings Correspondingly, we define the following:
Advertisements

Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic.
CS 61C L02 Number Representation (1)Harvey / Wawrzynek Fall 2003 © UCB 8/27/2003  Brian Harvey ( John Wawrzynek  (Warznek) (
November 17, 2009Theory of Computation Lecture 18: Calculations on Strings III 1 Numerical Representation of Strings We will now look at several primitive.
October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 1Universality Then we append the following instruction: [C]IF K = Lt(Z) + 1 
November 10, 2009Theory of Computation Lecture 16: Computation on Strings I 1Diagonalization Another example: Let TOT be the set of all numbers p such.
CS 61C L02 Number Representation (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C.
September 17, 2009Theory of Computation Lecture 4: Programs and Computable Functions III 1 Macros Now we want to use macros of the form: W  f(V 1, …,
December 1, 2009Theory of Computation Lecture 21: Turing Machines II 1 Simulation of L n in T We will now construct a Post-Turing program Q that simulates.
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
November 12, 2009Theory of Computation Lecture 17: Calculations on Strings II 1 Numerical Representation of Strings First, we define two primitive recursive.
December 3, 2009Theory of Computation Lecture 21: Turing Machines III 1 Simulation of T in L Now the MIDDLE section of Q can be generated by replacing.
Sets, Permutations, and Combinations. Lecture 4-1: Sets Sets: Powerful tool in computer science to solve real world problems. A set is a collection of.
Chapter 4 Introduction to Set Theory
Sets Page 746.
Theory of Computation Lecture #
Relations, Functions, and Matrices
Gödel's Legacy: The Limits Of Logics
Theory of Computation Lecture 4: Programs and Computable Functions II
Set, Combinatorics, Probability & Number Theory
Cartesian product Given two sets A, B we define their Cartesian product is the set of all the pairs whose first element is in A and second in B. Note that.
Exponents Scientific Notation
Copyright © Cengage Learning. All rights reserved.
Modeling Arithmetic, Computation, and Languages
Multiple variables can be created in one declaration
Diagonalization and Reducibility
Theory of Computation Lecture 23: Turing Machines IV
Theory of Computation Lecture 14: A Universal Program V
Lecture 9 Theory of AUTOMATA
Numerical Representation of Strings
Theory of Computation Lecture 22: Turing Machines III
Great Theoretical Ideas in Computer Science
Theory of Computation Lecture 16: A Universal Program VII
Copyright 2012, 2008, 2004, 2000 Pearson Education, Inc.
Theory of Computation Lecture 5: Programs and Computable Functions III
Copyright © Cengage Learning. All rights reserved.
2.2 The Limit of a Function In this section, we will learn:
Copyright © Cengage Learning. All rights reserved.
Functional Programming
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Introduction to Finite Automata
Theory Of Computer Science
Copyright © Cengage Learning. All rights reserved.
2 Chapter Numeration Systems and Sets
Place Value: Expanding Whole Numbers 3 Ways
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Theory of Computation Lecture 21: Turing Machines II
6.001 SICP Interpretation Parts of an interpreter
Diagonalization and Reducibility
Recursively Enumerable Sets
Copyright © Cengage Learning. All rights reserved.
Theory of Computation Lecture 5: Programs and Computable Functions III
Cardinality Definition: The cardinality of a set A is equal to the cardinality of a set B, denoted |A| = |B|, if and only if there is a one-to-one correspondence.
Numerical Representation of Strings
Numerical Representation of Strings
Theory of Computation Lecture 4: Programs and Computable Functions II
Copyright © Cengage Learning. All rights reserved.
Numerical Representation of Strings
Theory of Computation Lecture 6: Primitive Recursive Functions I
Theory of Computation Lecture 22: Turing Machines II
Theory of Computation Lecture 13: A Universal Program V
Numerical Representation of Strings
Programming Languages
Theory of Computation Lecture 17: Calculations on Strings II
Theory of Computation Lecture 23: Turing Machines III
Terminology and Symbols
Reasoning with Types.
Presentation transcript:

Numerical Representation of Strings You certainly noticed that in our string representation we used symbols s1, …, sn, while in the everyday number representation we use s0, …, sn-1. So what exactly are the analogies and differences between the two systems? To find out about this, let us look at the following modified set of digits D: D = {s1, …, s10} = {1, 2, 3, 4, 5, 6, 7, 8, 9, X} Here, the X stands for a digit with the value 10, while there is no digit with the value 0. April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III

Numerical Representation of Strings So what is the number x associated with the string w = 76 ? x = 710 + 6 = 76 And what is the number for w = 3X6 ? x = 3100 + 1010 + 6 = 406 Finally, what is the number for w = XX ? x = 1010 + 10 = 110 These examples already suggest that we can use this system in a way quite similar to our “usual” system. April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III

Numerical Representation of Strings Now let us turn this around: What is the string w associated with the number x = 39? w = 39 (as long as x does not contain any 0s, w is the “usual” decimal string representing x) And what is the string for x = 100 ? w = 9X But what is the string for x = 504 ? w = 4X4 Finally, what is the string for x = 0 ? w = 0 (0 is the null string symbol) April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III

Numerical Representation of Strings We can even transfer our elementary arithmetic to the new system: X 4 + 5 9 6  1 0 4 corresponding to + 5 9 6  7 0 0 6 9 X X 2 3 - X 1 X  1 0 2 3 corresponding to - 1 0 2 0  3 3 April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III

Numerical Representation of Strings This applies even to multiplication: 3 X  X 7  4 0 corresponding to  1 0 7  4 2 8 0 2 7 X 3 9 X  4 2 7 X April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III

Numerical Representation of Strings So you see that we can easily replace our usual digit range from 0 to n-1 with the range 1 to n. In our representation of strings on the alphabet A, we use the range from 1 to n to have a bijective mapping between strings and numbers. When using a range from 0 to n-1, there is no such mapping, because different strings correspond to the same number, for example: 87 = 087 = 0087 = 00087 = … April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III

Numerical Representation of Strings Now let us return to our general case of associating numbers with strings. For an alphabet A = {s1, …, sn}, the string w = sik sik-1 … si1 , si0 is called the base n notation for the number x as defined by x = iknk + ik-1nk-1 + … + i1n1 + i0 . When n is fixed, we can consider a function of one or more variables on A* as a function of the corresponding numbers. April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III

Numerical Representation of Strings So we can speak of an m-ary partial function on A* with values in A* as being partially computable, or when it is total, we can speak of it as being computable. Similarly, we can say that an m-ary function on A* is primitive recursive. But what about predicates? Notice that for an alphabet A = {s1, …, sn} the value s1 denotes 1 in base n notation. Thus an m-ary predicate on A* is simply a total m-ary function on A* whose values are either s1 (“true”) or 0 (“false”). Therefore, it makes sense to speak of an m-ary predicate on A* as being computable. April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III

Numerical Representation of Strings For a given alphabet A, any subset of A* (any set of strings on A) is called a language on A. By associating numbers with the elements of A*, we can speak of a language on A as being r.e., recursive, or primitive recursive. Notice that our base n notation even works for n = 1, that is, an alphabet containing only one symbol. For example, if A = {s1} then x = 1 is represented by the string w = s1 x = 7 is represented by the string w = s1s1s1s1s1s1s1 : April 18, 2019 Theory of Computation Lecture 18: Calculations on Strings III