CSC 350 Exam 2 Page 1 of 6 Name___ KEY ___ 87 points _____ MULTIPLE CHOICE/SHORT ANSWER. 3 points each. For multiple choice, choose the ONE best answer. 1. Tagsets are used to a) define the meaning of words b) define the meaning of sentences C c) show parts of speech of words d) label the antecedents of pronouns 2. A unification-based grammar a) is another name for context-free grammar. b) is the best way to pass attributes up and down the parse tree. c) uses unification to encode and exchange values during parsing. C d) is the only way to capture the notion of noun/verb number agreement. 3. What is true of a type 0 (unrestricted grammar) language? a) It takes the power of a Turing machine to recognize some of the languages in this set. b) It takes the power of a Turing machine to recognize any language in this set. c) A finite automaton has enough power to recognize any language in this set. d) A finite automaton lacks the power to recognize A any language in this set. 4. It appears clear that type 2 (context-free) languages a) are powerful enough to generate any human language. b) require additional mechanisms, such as transformations, to generate a human language. c) are more powerful than type 1 languages. B d) require more skill to manipulate than type 1 languages. 5. Bottom-up parsing a) is the method of choice for human-created parsers. b) is used by Prolog when interpreting a definite clause grammar. c) can use a shift/reduce procedure to generate a parse tree by starting at the root. d) can use a shift/reduce procedure to generate a parse tree D by starting at the leaves. 6. Top down parsing a) passes attributes down the parse tree. b) passes attributes up the parse tree. c) begins at the leaves and combines a "forest" into a single tree. D d) begins at start symbol and adds nodes to build a tree. 7. Rode is a homophone of A a) road b) walked c) traveled d) bicycled 8. Sail is a ___________ of ship. C a) hypernym b) hyponym c) meronym d) holonym 9. What would be a reasonable translation into Prolog of "If high investment in something brought low returns then low investment in it will bring high returns." a) investment_return(low,X,high) :- investment_return(high,X,low). b) investment_return(high,X,low) :- investment_return(high,X,low). c) investment_return(low,X,high) :- investment_return(low,X,high). A d) investment_return(high,X,high) :- investment_return(low,X,high). CSC 350 Exam 2 Page 2 of 6 Name___ KEY ___ 87 points _____ 10. Prolog is said to be a logic programming system because a) facts are inferred in a procedural manner by calling predicates in a logical, sequential manner. b) facts are inferred logically by showing nothing is known to refute them. c) facts are inferred logically by showing they can be derived deductively from other predicates and facts. C d) Prolog programs use the logic of the host computer. Consider the following grammar for NLP of e-purchases. sent --> verb, obj, vcomp, ['.']. verb --> [remove] ; [add]. obj --> [X]. vcomp --> prep, [my], [cart] ; []. prep --> [to] ; [from]. 11. Which sentence is not recognized by the grammar? a) add buckwheat_pancakes to my cart. b) add to my cart buckwheat_pancakes. c) remove buckwheat_pancakes to my cart. B d) remove buckwheat_pancakes from my cart. 12. Which set of rules completes the modification to correctly match 'verb' with the appropriate 'prep'? sent --> verb(V), obj, vcomp(V), ['.']. verb(V) --> [V]. vcomp(X) --> prep(X), [my], [cart] ; []. a) prep(X) --> [to], {X = to} ; [from], {X = from}. b) prep(X) --> [to], {X == to} ; [from], {X == from}. c) prep(X) --> [to], {X == add} ; [from], {X == remove}. C d) prep(X) --> [add], {X == add} ; [remove], {X == remove}. 13. We add a shoppingcart/1 predicate to the code. And assume a user starts with it preloaded with some basics: shoppingcart([bread, milk, skittles]). Which rule correctly updates the shopping cart? a) sent --> [add], obj(X), vcomp, ['.'], {shopping_cart(X)}. b) sent --> [add], obj(X), vcomp, ['.'], {shopping_cart([X])}. c) sent --> [add], obj(X), vcomp, ['.'], {assert(shopping_cart([X]))}. d) sent --> [add], obj(X), vcomp, ['.'], {shopping_cart(Y), append([X],Y,Z), D assert(shopping_cart(Z))}. 14. The grammar above was stated using a) Backus Naur Form (BNF) b) Extended Backus Naur Form (EBNF) C c) a Prolog definite clause grammar d) a Prolog difference list 15. A system of "predicates" and how these predicates would change in evaluation upon interpretation of a sentence is known as a) denotational semantics b) axiomatic semantics B c) operational semantics d) an alphabet CSC 350 Exam 2 Page 3 of 6 Name___ KEY ___ 87 points _____ 16. The parse tree of a sentence is a) inherent in the language. b) inherent in the grammar used. B c) identical for all grammars. d) identical for all sentences. 17. Syntax can be captured in B a) vocabulary b) a grammar c) a set of phonemes d) an alphabet 18. Semantics is a) the form of the sentences of a language. b) the meaning of the sentences of a language. c) always defined in terms of a template. B d) always defined in terms of a grammar. 19. Pattern matching is matching a given input against a set of existing patterns. This makes Prolog especially useful in a rapidly prototyped template system. Which patterns will be matched by the given query? | ?- translate([a,b],X). A. translate([X,Y,Z | Rest],Z) :- translate(Rest,_). B. translate([X,Y | Rest],[X]) :- translate(Y). C. translate([X],Y) :- translate(Y). D. translate(X,X). D a) A only b) B only c) B and C d) B and D 20. Unification: Respond as Prolog would: ?- record(city(X),contaminants( [benzene(A),toluene(B)|Rest])) = record(city(oswego),contaminants( [benzene(1),toluene(1000),styrene(100)])). a) X = oswego A = 1 B = 1000 Rest = 100 b) X = oswego A = 1 B = 1000 Rest = styrene(100) c) X = oswego A = 1 B = 1000 Rest = [styrene(100)] C d) X = city(oswego) A = benzene(1) B = toluence(1000) Rest = styrene(100) 21. A web-based template system gets its parameters a) from the name assigned to the INPUT element in the web form. b) positionally from the web form, so that the first INPUT element of the form will be parameter #1, etc. c) from the URL the user types in or clicks on to reach the form. A d) by lexical parsing of the URL of the form's web page. 22. The X-Bar hypothesis a) has been shown to be the mechanism the brain uses to decode sentences. b) is provably better than any programmable alternatives. c) places specifiers to the right of nouns in all languages. D d) organizes linguistic elements as binary trees. CSC 350 Exam 2 Page 4 of 6 Name___ KEY ___ 87 points _____ Consider the following context free grammar, G, for a variant of Morse code. The productions are numbered beneath their rule arrow. Terminal = { dah, dit } Nonterminals = { A, B } Productions = { A --> dah, A --> dah B, B --> dit, B --> dit A, A --> B } 1 2 3 4 5 Start = A 23. Write down the 5 shortest sentences in the language. Answer: { dah, dah dit, dit, dit dah, dit dit } [note that "dah dah" is not included] 24. Derive "dah dit dit dit" from A using a left-most derivation. Be sure to label the "arrows" with the production used. (Productions are numbered from left to right starting with 1.) Answer: A ==> dah B 2 ==> dah dit A 4 ==> dah dit B 5 ==> dah dit dit A 4 ==> dah dit dit B 5 ==> dah dit dit dit 3 CSC 350 Exam 2 Page 5 of 6 Name___ KEY ___ 87 points _____ The following language is part of a front-end for an automatic solitaire playing program which lets an IT worker continue to play while fielding a user's call. QUERIES: where is the red queen? where is the black king? : where is the ? COMMANDS: place the red queen on the black king. : place the on the . The term can be either: red or black. The term can be any of: jack, queen, king. A grammar to recognize this language starts likes this: sent --> query ; cmmd . query --> [where], [is], [the], card(C,R), ['?']. cmmd --> [place], [the], card(C1,R1), [on], [the], card(C2,R2), ['.']. 25. Finish the prolog CFG for this language. You need to add one rule: to recognize 'card(C,R)', but only accept red or black for C and jack, queen, king for R. card(C,R) --> [C], [R], { (C == red ; C == black), (R == jack ; R == queen ; R == king)}. 26. Modify the "cmmd --> ..." production to add semantics to "remember" (with an assert) where the card of that color and rank is located. cmmd --> [place], [the], card(C1,R1), [on], [the], card(C2,R2), ['.'], add this: { assert(is_on(C1,R1,C2,R2)) }. 27. Modify the "query --> ..." production to add semantics to retrieve and print the location of a particular card you had remembered earlier. [Bonus points if you determine whether a card is on or under another when asked this query.] query --> [where], [is], [the], card(C,R), ['?'], add this: { ( is_on(C,R,C2,R2), write('The '), write(C), write(' '), write(R), write(' is on the '), write(C2), write(' '), write(R2), write('.'); is_on(C2,R2,C,R), write('The '), write(C), write(' '), write(R), write(' is under the '), write(C2), write(' '), write(R2), write('.'); write('I don''t know.') ), nl }. CSC 350 Exam 2 Page 6 of 6 Name___ KEY ___ 87 points _____ 28. If A and B are true statements and X and Y are false statements, which one of the following compound statements is true? A a. ~(B * Y) b. A * (X + (B * Y)) c. ~A * (X + ~B) d. ~X * (X + ~B) 29. Of which argument form is the following a substitution instance? p => q q => r .. p => q a. ~p => ~q b. p => q c. p d. p => q ~q => ~r q => r q q => r C .. ~p => ~q .. r .. p .. (p => q) * (q => r) The last 2 questions are bonus questions - points added to total if correct. 30. Display the following argument symbolically. If Obama is correct then if a citizen is bitter then the aforementioned citizien will cling to his rifle. The citizen clings to his rifle. Therefore, if Obama is correct then the citizen is bitter. O => ( B => C) C .. O => B 31. Which prolog code returns the second-to-last element of a list? a. penult([X,Y|_],Y). b. penult([X,Y],X). c. penult([X,Y],X). penult([X|Xs],Y) :- penult(Xs,Y). C d. penult([X,Y],X). penult([X|Xs],Y) :- penult([X|Xs],Y).