Americas
Europe
Q2E
Expert-verifiedFind five other valid sentences, besides those given in Exercise 1.
(a) The sleepy hare runs quickly
(b) The happy hare runs slowly.
(c) The happy tortoise passes the hare
(d) The hare passes the tortoise.
(e) The tortoise passes the happy hare
The use of grammar helps when we consider the two classes of problems that arise most frequently in applications to programming languages:
(1) How can we determine whether a combination of words is a valid sentence in a formal language?
(2) How can we generate valid sentences in a formal language? Before giving a technical definition of grammar,
Given notation is:
\({\bf{Sentence}} \to {\bf{noun phrase transitive verb phrase noun phrase}}\)
\({\bf{Sentence}} \to {\bf{noun phrase intransitive verb phrase}}\)
\({\bf{Noun phrase}} \to {\bf{article adjective noun}}\)
\({\bf{Noun phrase}} \to {\bf{article noun}}\)
\({\bf{Transitive verb phrase}} \to {\bf{transitive verb\;}}\)
\({\bf{Intransitive verb phrase}} \to {\bf{intransitive verb adverb}}\)
\({\bf{Intransitive verb phrase}} \to {\bf{in transitive verb}}\)
\({\bf{Article}} \to {\bf{the}}\)
\({\bf{Adjective}} \to {\bf{sleepy}}\)
\({\bf{Adjective}} \to {\bf{happy}}\)
\({\bf{Noun}} \to {\bf{tortoise}}\)
\({\bf{Noun}} \to {\bf{hare}}\)
\({\bf{Transitive verb}} \to {\bf{passes}}\)
\({\bf{Intransitive verb}} \to {\bf{runs}}\)
\({\bf{Adverb}} \to {\bf{quickly}}\)
\({\bf{Adverb}} \to {\bf{slowly}}\)
Noun phrase intransitive verb phrase:
(Article, adjective, noun) intransitive verb phrase
(Article, adjective, noun, intransitive verb phrase, adverb)
Hence, the sentence is: the sleepy hare runs quickly.
Noun phrase intransitive verb phrase:
(Article, adjective, noun) intransitive verb phrase
(Article, adjective, noun, intransitive verb phrase, adverb)
Hence, the sentence is: the happy hare runs slowly.
Noun phrase transitive verb phrase:
(Article, adjective, noun) transitive verb phrase
(Article, adjective, noun, transitive verb phrase, noun phrase)
(Article, adjective, noun, transitive verb phrase, article, noun)
Hence, the sentence is: the happy tortoise passes the hare.
Noun phrase transitive verb phrase:
(Article, noun) transitive verb phrase
(Article, noun, transitive verb phrase, noun phrase)
(Article, noun, transitive verb phrase, article, noun)
Hence, the sentence is: the hare passes the tortoise.
Noun phrase transitive verb phrase:
(Article, noun) transitive verb phrase
(Article, noun, transitive verb phrase, noun phrase)
(Article, noun, transitive verb phrase, article, adjective, noun)
Hence, the sentence is: The tortoise passes the happy hare.
94% of StudySmarter users get better grades.
Sign up for free