Theory of Computation Exercises Assignment

Question 1

Convert the non deterministic transtion diagram below into an equivalent transition diagram

without epsilon-transitions:

Explain your construction by explicitly enumerating the changes performed on the state transition

diagram.

Question 2: Convert the following transition diagram into an equivalent regular expression:

Question 3:

Prove that the following languages are not regular:

A)

B)

Question 4:

Consider the following context-free grammar with start symbol S and terminals a, b:

S→aaaaSb S→aaS S→Sb S→ε

A) Give a parse tree for the string aaaabb.

B) Is the above grammar ambiguous? Explain.

Question 5:

Explain formally why each of the two grammars below (with axiom and sole nontermi- nal S) is not

suitable for recursive descent parsing.

A) S→ε S→0S0

B) S→1 S→0S0 S→0S1

Question 5:

Verify the validity of the following correctness statements by adding all the intermediate assertions

(that is, give the proof tableau). All variables are of type int. Clearly state any mathematical facts and

inference rules used

A)

B)

Question 6: What should the pre-condition P be in each of the following correctness statements for

the statement to be an instance of Hoare’s assignment axiom? All variables are of type int.

• A) P { x = y z; } Exists(x = 0; x < 2*y) u*x <= v z

• B) P { x = y z;} ForAll( y = 0; y < x ) Exists ( z = 0; z __= y*v
Question 7:
Use the array-component assignment axiom (two times) to find the most general suffi- cient precondition P for the code fragment below. A is an array of integers, x is an integer variable, and we
assume that all the subscripts are within the range of subscripts for A.
A) Complete the tableau and thus write the assertion P using the notation from the arraycomponent assignment axiom.
B) Rewrite the assertion P obtained in Question a in a logically equivalent form that does not contain
any notation (A | I → E). Explain your rewriting.
Question 8:
Assume a declarative interface where n and max are constant integers, and A is an array of
integers of size max. For non negative integers x and i, power(x,i) denotes xi (the i-th power
of x), that is, power(x,0) = 1 and power(x,i 1) = x * power(x,i). Consider the following
(partial) correctness statement:
A) Choose a loop invariant for the while loop in the code and explain your choice.
B) Give a complete proof tableau for the above correctness statement by adding all the intermediate
assertions. State all the mathematical facts that are used in the proof.
C) Does the loop terminate? Explain.
Question 9:
For positive integers x and i, power(x,i) denotes xi that is, power(x,0) = 1 and power(x,i 1) = x *
power(x,i). The following statement is partially correct:
Does the program always terminate? If yes, then explain why. If not, then strengthen the
pre-condition of the program so that it terminates and explain why the new pre-condition
insures termination.
Question 10:__

The price is based on these factors:

Academic level

Number of pages

Urgency

Basic features

- Free title page and bibliography
- Unlimited revisions
- Plagiarism-free guarantee
- Money-back guarantee
- 24/7 support

On-demand options

- Writer’s samples
- Part-by-part delivery
- Overnight delivery
- Copies of used sources
- Expert Proofreading

Paper format

- 275 words per page
- 12 pt Arial/Times New Roman
- Double line spacing
- Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Delivering a high-quality product at a reasonable price is not enough anymore.

That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more