Ma/CS 6c Assignment #1 Due Wednesday, April 7 at 1 p.m. (40%) 1 * . (a) Prove the correctness of the following algorithm for recognizing when a given string S is a P-wﬀ: If S = s 1 s 2 ...s n , compute w ( s n ) ,w ( s n )+ w ( s n-1 ) ,...,w ( s n )+ w ( s n-1 )+ ··· + w ( s 1 ) = w ( S ). If all these sums are ≥ 1 and w ( S ) = 1, then S is a P-wﬀ; otherwise, it is not. (Recall that w ( p ) = 1 , w ( ¬ ) = 0 , w ( * ) =-1, if * = ∧ , ∨ , ⇒ , ⇔ .) Apply this algorithm to the strings: (i) qp ⇒ ¬ ttr ⇒ ∧¬ stuv ; (ii) ⇒⇔ ¬ ∧ pq ∨ ¬ p ¬ qs . If any of these strings is a P-wﬀ, write down the corresponding wﬀ. (40%) 2. Show that unique readability holds for the formal language described below (whose grammatically correct strings we call
This is the end of the preview.
access the rest of the document.
Formal grammar, grammatically correct strings, parse tree TA