• Ei tuloksia

5KJEIBHJDA @E@@AJAHAN= " #6DA+;J=>AaabbcS,D,C

N/A
N/A
Info
Lataa
Protected

Academic year: 2022

Jaa "5KJEIBHJDA @E@@AJAHAN= " #6DA+;J=>AaabbcS,D,C"

Copied!
2
0
0

Kokoteksti

(1)

Solutions for the 2nd middle term exam 21.4. 2005

1. The CYK-table:

a a b b c

S, D, Ca

D S, D, Ca

S S, A Cb

S, A X Cb

S S, E S, C, Cc

Thus aabbc belongs to language. (Notice the same language can be de- scribed as{anbmcl|n=m∨m=l}.

For totally correct answer 10 p, detailed evaluation criteria will be in- formed later.

2. It was enough to give the correct subclass for each grammar.

a)G1 describes all integers (with possible beginning zeroes), and you can give a regular expression(01∪...∪9)(01∪...∪9) or a right-linear grammarS→0S|1S|...|9S|0|1|...|9. 2p

G2 is the same language as in task 1. It is ambiguous, e.g. stringaabbcc has two parse trees in the given grammar. We can prove that the language is in fact inherently ambiguous but this was not required. 3p

G3 can be described as {anbm|n m}. This can be solved easily by a deterministic pushdown automaton, so the language is at least deter- ministic. However, if you perform LL(1) test, you see it is also LL(1).

F IRST({aSb}F OLLOW(S))∩F IRST({B}F OLLOW(S)) ={a}∩{b, ²}=

andF IRST({bB}F OLLOW(B))∩F IRST({²}F OLLOW(B)) ={b} ∩ {²}=. 3p

b) Parsing methods:

Linear languages: deterministic nite automaton 1p LL(1)-languages: recursive parser 1p

Deterministic languages: deterministic pushdown automaton (or LR(1) parser) 1p

Unambiguous (non-deterministic) and inherently ambiguous languages:

CYK-algorithms 1p

3. Let's assume that the input is given the least signicant bit on left (easier to solve). Idea: change the second character to 1, if it was 0 or <. If it was 1, then scan to right and change all 1s to 0's until you meet 0 or <, which is changed to 1.

The machine described by transition functions:

1

(2)

δ(q1,0) = (q2,0, R) δ(q1,1) = (q2,1, R) δ(q2,0) = (q3,1, R) δ(q2, <) = (q3,1, R) δ(q2,1) = (q2,0, R)

Task: Draw the machine!

For fully correct answer 10 points. Detailed evaluation criteria will be informed later.

4. a) See e.g. lecture material. The main point was that we have no computa- tional means to test run-time properties of computer programs. Simulating the program doesn't help, because the program may not halt or we have to test all possible inputs, the set of which is typically innite. 2p b)Semantic properties: i) and iv), syntactic ii) and iii). 4 points, 1p/each.

c) i) is partially solvable: you can e.g. construct a machine which recognizes suchcM, but does not halt in No-cases, or show that the complement problem is totally unsolvable. 2p

iv) is totally unsolvable: we should check all possible inputs, which will never nish. You can also prove it easily by contradiction method. Or rea- son that because the complement problem is partially solvable (recursive- ly enumerable language), the current problem must be totally unsolvable (otherwise the problem would be solvable, which is known to be false). 2p

2

Viittaukset

LIITTYVÄT TIEDOSTOT

Kvantitatiivinen vertailu CFAST-ohjelman tulosten ja kokeellisten tulosten välillä osoit- ti, että CFAST-ohjelman tulokset ylemmän vyöhykkeen maksimilämpötilasta ja ajasta,

Vaikka tuloksissa korostuivat inter- ventiot ja kätilöt synnytyspelon lievittä- misen keinoina, myös läheisten tarjo- amalla tuella oli suuri merkitys äideille. Erityisesti

• use articulatory speech synthesis or synthesize speech on the basis of pitch, formants and intensity parameters (see the internal manual in Praat). • open 32 or 64 channel

At this point in time, when WHO was not ready to declare the current situation a Public Health Emergency of In- ternational Concern,12 the European Centre for Disease Prevention

We applied the computer program Nlogit3 (Limdep). While stochastic frontier model allows one to include z variables either as a part of production technology or a part of

It means that we have something in common The word we does not have any meaning anymore The using of the word we I am always “us/we”.. for outside partners the word “we” means

„ a game that is carried out with the help of a a game that is carried out with the help of a computer program.

We want to colour the squares in the grid using colours A, B, C and D in such a way that neighbouring squares do not have the same colour (squares that share a vertex are