Académique Documents
Professionnel Documents
Culture Documents
6.806 PSET 4
Problem 1(a):
We’re given a CFG 𝐺′: (𝑁, Σ, 𝑅, 𝑆, 𝑃) where 𝐺′ is not necessarily in Chomsky normal form.
To do so, we need to make sure that:
𝜋(𝑖, 𝑗, 𝑘, 𝑋) = max{ 𝑣1 , 𝑣2 }
Where 𝑖 ≤ 𝑙 ≤ 𝑗, 𝑃, 𝑄 ∈ 𝑁, and 𝑤1 , 𝑤2 ∈ sentence. We then analyze the initial case:
𝜋(𝑖, 𝑖, 𝑗, 𝑄) = Pr(𝑄(𝑗) → 𝑤𝑖 ) where 𝑤𝑖 ∈ sentence.
We need to populate this table and then backtrack in order to come up with the optimal parse
tree.
Given a query: 𝑥0 , 𝑥1 , … 𝑥𝑛
Recursively solve and memoize: ∀ 𝑡𝑒𝑟𝑚𝑖𝑛𝑎𝑙𝑠 𝑘 ∈ sentence, 𝜋(0, 𝑛, 𝑘 , 𝑆) by the above
updating rules. In addition, we also want to know what was the optimal children nodes, since
we needed to find this anyways, we should memorize this as well. Create an additional
dictionary the maps the tuples of subproblems (𝑒. 𝑔 (0, 𝑛, 𝑘, 𝑆) → (𝑃(𝑘), 𝑄(𝑤𝑠 ), 𝑘, 𝑤𝑠 , 𝑙)
where we found via the above update rule that 𝑃, 𝑄 are optimal children, with the parent’s
word 𝑘 going to the left subchildren and some other optimal terminal 𝑤𝑠 for 𝑄. In this case
the 𝑃(𝑘) child subtree should produce words from (0, 𝑙) and 𝑄(𝑤𝑠 ) from (𝑙 + 1, 𝑛) (with
optimal probabilities).
Once the recursion is done, we can build tree node by node, by starting at the root:
We first start with the biggest subproblem: 𝜋(0, 𝑛, 𝑘 , 𝑆), we search the tuple (0, 𝑛, 𝑘, 𝑆) in
our dictionary and obtain (𝑃(𝑘), 𝑄(𝑤𝑠 ), 𝑘, 𝑤𝑠 , 𝑙). We then find the children nodes, by
considering: 𝜋(0, 𝑙, 𝑘 , 𝑃) for the left child and 𝜋(𝑙 + 1, 𝑛, 𝑤𝑠 , 𝑄) for the second child. We
repeat the process by continuously looking up the respective optimal nodes and then output
this as a final result.