Art of Computer programming notation question

Q = set of states (so that (s, j) represents state s at time j)
I = initial states (hence the requirement that j == 0)
Omega = final states (hence the requirement that j == N)
f = transition function

Also, there aren't three functions named f but rather f is piecewise-defined by three equations.


For full disclosure, I recently wrote an article on understanding Knuth's (pre-example) formal definition of an algorithm. A substantial portion of the below is just a copy/paste of the relevant text from the article answering your first question in depth;

Your first question on (Q, I, Ω, f)


Let us formally define a computational method to be a quadruple (Q, I, Ω, f), in which Q is a set containing subsets I and Ω and f is a function from Q into itself.

When Knuth refers to a computational method as a quadruple he is simply saying that a computational method is composed of four distinctly defined parts. He labels these four parts as (Q, I, Ω, f). He then moves on to briefly describe each component of this quadruple. I and are sets (collections of things), and Q is also a set which contains the things in the sets I and . At this point it’s easy to mistakenly assume that he means that Q contains only the sets I and and nothing else. But we later find that this is not the case. Lastly he describes f as a function from Q into itself. What this means is that f is a process which takes an input which is an element from the set Q and returns or outputs another element from Q.

Furthermore f should leave Ω pointwise fixed; that is, f(q) should equal q for all elements q of Ω.

What this essentially means is that, what our function f returns, will be the same as its argument (i.e. the value will not change) if the argument is a member or element of (thing in) set . This makes more sense when Knuth makes a clarification in his next statement; Spoiler alert - is the set of possible outputs of our computational method. Once we know this it’s a little easier to understand. Passing an output back into our function will not change it.

The four quantities Q, I, Ω, f are intended to represent respectively the states of the computation, the input, the output, and the computational rule.

So Q is a set that contains all possible states of the computation i.e. all the possible variations of input, output and all the stages in between. The set I contains all possible inputs. The set contains all possible outputs (sorry if I spoiled that revelation for you earlier). And finally, f represents the computational rule; that is, the process/es applied to each state to get the next state, eventually (hopefully) until we get our output.


To clarify, f represents a single function that has outputs defined based on its possible inputs. It only has three possible outputs in this specific example, and could have more (or less) in other algorithms. So, whats the purpose of defining the components of an algorithm in this way? By having them defined using formal notation they can also be analysed and subjected to mathematical examination when it comes to analysing specific algorithms.

Question about Treating the algorithm as a set of Strings

I answered another question on this subject here. But essentially what Knuth is doing here is using a Markov's algorithm to achieve what he has already described. It is worth studying (and working through a few examples of) Markov algorithms to help you understand exactly what is occurring here.

References

  1. Markov's Algorithms Wiki
  2. My Defining an Algorithm article.
  3. Knuth the art of computer programming ex 1.1.8

I'm not 100% sure, but it looks like Q is the set of all ordered pairs (s, j) for 0 <= J <= N. This will be your domain. It is the set of all possible states given some N and string s.

I is your subset of Q where all ordered pairs contain J=0, or your initial states. Omega is your subset of Q where all ordered pairs contain J=N, or your final states.

f is the actual function over domain Q.

EDIT

Think of the function definition being something along the lines of one function, but different cases depending on the given input. Think of a function you would writing in a language. ex:

tuple f(string s, int i)
{
    if (Tj not in s)
        (s, aj)
    else if ( p is shortest possible length such that s = pYjw)
        (pYjw,bj)
    else if ( i == N )
        (s, N)
}

Another example is the Fibonacci function definition. See how that is defined? Make sense?


if u would have gone through the euclid's gcd algorithm that he stated earlier in the book. the idea is to mark the starting of each iteration as an initial stage and then define the number of states that will come in one iteration of loop (namely N). now as you will remember that we accepted the answer and halted the computation when the remainder of m divided by n equaled zero. i.e. we were searching for a particular occurrence of a string Yj. when the compuataion reaches itz final stage in the loop it is bound to halt or reiterate.

Tags:

Notation

Taocp