The inside-outside algorithm computes the expected rule counts, and its update never lowers the likelihood full
This proof shows: correctness.
Notation. G=(V,Σ,P,S) is in Chomsky normal form: every rule is A→BC with B,C∈V, or A→a with a∈Σ, or S→ε, and in the last case S is on no right side. θ(r)≥0 is the probability of rule r. For a sentence w=a1⋯an, T(w) is the set of parse trees of w from S, and Pθ(t)=∏rθ(r)fr(t), where fr(t) is the number of uses of r in t. Z(w)=∑t∈T(w)Pθ(t). A node of a tree is labeled by (A,i,j) when it has the nonterminal A and its yield is ai+1⋯aj. For n≥1, TA(i,j) is the set of trees with root A and yield ai+1⋯aj, and β(A,i,j), α(A,i,j) are the values that the algorithm computes at lines L4, L5 and L7 to L9.
Fact 1 (spans). For n≥1, no tree of T(w) uses S→ε, since S is on no right side and the root has a nonempty yield. Every node has a nonempty yield, so the two children of a binary node have nonempty yields that split the span of the node: i<k<j. Hence a proper descendant of a node has a strictly shorter span. Two nodes with the same span cannot be nested, and two nodes that are not nested have disjoint spans, so a tree has at most one node with a given span (i,j).
Lemma 1 (inside). For n≥1 and 0≤i<j≤n, β(A,i,j)=∑t∈TA(i,j)Pθ(t).
Proof. By induction on j−i. If j=i+1, a tree in TA(i,i+1) is a single rule A→ai+1, since a binary rule would need a span of length at least 2. Line L4 sums θ(A→ai+1). If j−i≥2, the root uses a binary rule A→BC and splits at a unique k with i<k<j, and the tree is determined by the rule, k, a tree of TB(i,k) and a tree of TC(k,j). Its probability is the product of θ(A→BC) and the probabilities of the two subtrees. Summing over all choices, and using the induction for the shorter spans, gives the sum at line L5, which runs after all shorter spans are final. □
Outside trees. For n≥1, an outside tree for (A,i,j) is a tree with root S and yield a1⋯aiAaj+1⋯an, in which exactly one leaf, the hole, is the nonterminal A. Its probability is the product of θ over its rules. Let O(A,i,j) be the set of outside trees.
Lemma 2 (outside). For n≥1, α(A,i,j)=∑u∈O(A,i,j)Pθ(u).
Proof. By induction on n−(j−i). For (i,j)=(0,n), the hole spans the whole sentence. If it is not the root, its parent spans more than n symbols, which is impossible by the argument of Fact 1. So the only outside tree is the hole alone, as root, with A=S and probability 1, which is line L7. For a shorter span, the hole is not the root, and its parent is a binary node (D,i′,j′) with a rule D→XY. Either the hole is the left child, so A=X, i′=i, j′>j, and the right child is a complete tree of TY(j,j′); or it is the right child, so A=Y, j′=j, i′<i, and the left child is a tree of TX(i′,i). Cutting the tree at the parent gives an outside tree for (D,i′,j′) with a longer span. This is a bijection between O(A,i,j) and the triples of a parent rule and position, an outside tree of the parent, and a sibling tree. The probability is the product of the parts. By the induction for the longer span and Lemma 1 for the sibling, the sum is the total that line L9 adds to α(A,i,j). Line L8 processes spans by decreasing length, so α(D,i′,j′) is final when it is used. □
Lemma 3 (node marginals). For n≥1, ∑{Pθ(t):t∈T(w) has a node (A,i,j)}=α(A,i,j)β(A,i,j).
Proof. By Fact 1, a tree has at most one node with the span (i,j). Cutting a tree at its node (A,i,j) gives an outside tree of O(A,i,j) and an inside tree of TA(i,j), and putting the inside tree into the hole is the inverse. The probability of the tree is the product of the two. Lemma 1 and Lemma 2 give the result. □
Lemma 4 (expected counts). For a sentence with Z(w)>0, the values that lines L3, L10 and L11 add for w are Eθ[fr∣w]=∑t∈T(w)Pθ(t)fr(t)/Z(w) for every rule r, and Z(w) at line L6 is the probability of w.
Proof. If n=0, the only tree is S→ε, used once, so line L3 is right. Let n≥1. By Lemma 1, line L6 computes β(S,0,n)=Z(w). For a binary rule r=A→BC, fr(t) is the number of triples i<k<j such that t has a node (A,i,j) that uses r with split k, because a node has one span and one split. So
t∑Pθ(t)fr(t)=i<k<j∑∑{Pθ(t):t has a node (A,i,j) that uses r at k}. As in Lemma 3, such trees correspond to an outside tree for (A,i,j), a tree of TB(i,k) and a tree of TC(k,j), so the inner sum is α(A,i,j)θ(r)β(B,i,k)β(C,k,j). Dividing by Z(w) gives line L10. For r=A→a, fr(t) is the number of positions i with ai+1=a such that t has the node (A,i,i+1) with this rule, and the same argument gives α(A,i,i+1)θ(r)/Z(w), which is line L11. □
Lemma 5 (the update maximizes the expected log probability). Let c(r) be the totals of line L1 to line L11 over the sentences with Z(w)>0, and Q(θ′)=∑rc(r)logθ′(r), with 0log0=0 and clog0=−∞ for c>0. Among all θ′ such that the rules of each nonterminal sum to 1, line L12 gives a maximizer of Q.
Proof. Q is a sum over the nonterminals A of QA=∑A→γc(A→γ)logθ′(A→γ), and the constraints are separate for each A. If CA=∑γc(A→γ)=0, QA=0 for every choice, and line L12 keeps θ. If CA>0, let θ^(A→γ)=c(A→γ)/CA. For any θ′ with θ′(A→γ)>0 whenever c(A→γ)>0, the concavity of log (Jensen's inequality) gives
QA(θ′)−QA(θ^)=CAc>0∑θ^(A→γ)logθ^(A→γ)θ′(A→γ)≤CAlogc>0∑θ′(A→γ)≤CAlog1=0. Other θ′ give QA=−∞. So θ^, which is line L12, is a maximizer. □
Theorem. EM-STEP returns θ′ with the rules of each nonterminal summing to 1 (for every nonterminal that has a rule with a positive expected count, and otherwise its old values), and ∏wZθ′(w)≥∏wZθ(w), where both products run over the sentences of the corpus with Zθ(w)>0.
Proof. The normalization is line L12. By Lemma 4, the totals are c(r)=∑wEθ[fr∣w], summed over the sentences with Zθ(w)>0. Fix such a w, and let q(t)=Pθ(t)/Zθ(w) for t∈T(w), which is a probability distribution on the trees with q(t)>0. For any θ′, Jensen's inequality gives
logZθ′(w)≥logq(t)>0∑Pθ′(t)=logq(t)>0∑q(t)q(t)Pθ′(t)≥t∑q(t)logq(t)Pθ′(t), with equality for θ′=θ, because then Pθ(t)/q(t)=Zθ(w) for every t. Subtracting the two cases,
logZθ′(w)−logZθ(w)≥t∑q(t)(logPθ′(t)−logPθ(t))=r∑Eθ[fr∣w](logθ′(r)−logθ(r)). Summing over the sentences gives ∑wlogZθ′(w)−∑wlogZθ(w)≥Q(θ′)−Q(θ). Q(θ) is finite, because a rule with c(r)>0 is used in a tree of positive probability, so θ(r)>0. By Lemma 5, Q(θ′)≥Q(θ) for the θ′ of line L12, which also satisfies the constraints of Lemma 5. So the sum of the logarithms does not decrease, and the products satisfy the claim. ■