declare fun {Sentence X0 X} P P1 N X1 in P={NounPhrase N P1 X0 X1} P1={VerbPhrase N X1 X} P end fun {NounPhrase N P1 X0 X} choice P P2 P3 X1 X2 in P={Determiner N P2 P1 X0 X1} P3={Noun N X1 X2} P2={RelClause N P3 X2 X} P [] N={Name X0 X} P1 end end fun {VerbPhrase S X0 X} choice O P1 X1 in P1={TransVerb S O X0 X1} {NounPhrase O P1 X1 X} [] {IntransVerb S X0 X} end end fun {RelClause S P1 X0 X} choice P2 X1 in X0=who|X1 P2={VerbPhrase S X1 X} and(P1 P2) [] X0=X P1 end end