Presentation is loading. Please wait.

Presentation is loading. Please wait.

Numerical Representation of Strings

Similar presentations


Presentation on theme: "Numerical Representation of Strings"— Presentation transcript:

1 Numerical Representation of Strings
To avoid confusion, we will not use decimal digits as symbols in our alphabets. Accordingly, a string of decimal digits will always be meant to refer to a number. We will now define some useful functions for string operations. The first function will be CONCAT. April 23, 2019 Theory of Computation Lecture 19: Calculations on Strings IV

2 Numerical Representation of Strings
Let A be some fixed alphabet containing n symbols, A = {s1, …, sn}. For each m  1, we define CONCATn(m) as follows: CONCATn(1)(u) = u CONCATn(m+1)(u1, …, um, um+1) = zum+1, where z = CONCATn(m)(u1, …, um). This means that for given strings u1, …, um  A*, CONCATn(m)(u1, …, um) is obtained by concatenating the strings u1, …, um. April 23, 2019 Theory of Computation Lecture 19: Calculations on Strings IV

3 Numerical Representation of Strings
We will usually omit the superscript, i.e., the number of arguments. For example: CONCAT3 (s3s1s2, s1s3) = s3s1s2s1s3 Translating this equation from strings to numbers: CONCAT3 (32, 6) = 294 It is also true that CONCAT5 (s3s1s2, s1s3) = s3s1s2s1s3 CONCAT5 (82, 8) = 2058 Obviously, the definition of CONCAT depends on the base n. April 23, 2019 Theory of Computation Lecture 19: Calculations on Strings IV

4 Numerical Representation of Strings
We will now look at several primitive recursive functions on strings. These functions will be useful for our further discussion of calculation on strings. It will be helpful to remember the functions g and h: g(0, n, x) = x g(m + 1, n, x) = Q+(g(m, n, x), n), then g(m, n, x) = um. h(m, n, x) = R+(g(m, n, x), n), then im = h(m, n, x), m = 0, …, k. April 23, 2019 Theory of Computation Lecture 19: Calculations on Strings IV

5 Numerical Representation of Strings
1.) f(u) = |u| This “length” function is defined on A* and yields a natural number. How can we compute f on the number associated with A*? For each t, the number tj=0 nj has the base n representation s1[t+1]. (The expression s[m] stands for the string that consists of m times the symbol s.) April 23, 2019 Theory of Computation Lecture 19: Calculations on Strings IV

6 Numerical Representation of Strings
For example, given the alphabet A = {s1, s2 ,s3} and t = 2: The string representation of tj=0 3j = s1s1s1. This number is the smallest number whose base 3 representation contains t + 1 symbols. If we subtract 1 from the string s1s1s1, it becomes s3s3. So the length |u| can be defined as follows: |u| = mint≤u (tj=0 nj > u). Obviously, this function is primitive recursive. April 23, 2019 Theory of Computation Lecture 19: Calculations on Strings IV


Download ppt "Numerical Representation of Strings"

Similar presentations


Ads by Google