Algorithms and Programs
[9/100%]Construct programs that compute, in the variable , the following functions, and prove their correctness. For two-argument functions, the value of the variable must remain unchanged.
, where and ;
, where if , and otherwise;
— factorial;
— integer quotient;
;
— exponentiation;
;
— the remainder of dividing by ;
— the number of distinct divisors of , .
Construct a program with labels that, given a natural number , computes the Fibonacci number .
Construct programs that compute, in the variable , the following functions:
Let a program П with a single input variable compute, in the variable , some everywhere-defined one-to-one function whose range coincides with the set of all natural numbers . Let . Construct a program that computes the function inverse to : if .
Let П be a program with . It follows from the definitions that, for different choices of input and output variables, the program can compute different functions.
What is the maximum number of functions of variables that П can compute? How many different functions in total can П compute? Functions having a different number of arguments are considered distinct a priori.
Construct a program that computes the maximum number of different functions of variables.
Construct a program , that computes, for each , the maximum number of different functions of variables.
Solve the previous problem in the case where the possible input variables are ordered in advance.
Determine how many pairwise non-equivalent programs with labels there are, having at most statements and only one variable, which is simultaneously the input and output variable.
Determine which everywhere-defined functions can be computed by bounded programs with labels that have only one variable, which is simultaneously the input and output variable.
Let a program with labels contain only propositional variables and assignments with Boolean connectives (similarly to the linear programs of Section 13.2). Propose a method that allows one to determine which function such a program computes.