Context-Free Grammars & Languages

Answer & solution
Official answer: A
Worked explanation
Empty strings are permitted for the starred variables in L1. Setting x=y=ε produces every binary w, so repeated appearances of x impose no restriction at all. For L2, the grammar below is more informative than incorrectly invoking closure under complement of context-free languages. Write V→b|aVa|aVb|bVa|bVb in addition to the displayed U productions. U and V wrap arbitrary equal numbers of symbols around different central letters. Concatenating them makes the central positions differ by half the total length. Conversely, if unequal halves of length m differ at position r, choose first component length 2r−1 and second length 2(m−r)+1. Their centers land at r and m+r. This proves both grammar inclusions, hence context-freeness without claiming that arbitrary complements of CFLs are CFLs.
Derivation and answer
For L1 choose x=ε, y=ε and let w be any binary string; hence L1=Σ*, regular. For L2 a CFG can guess a differing position in the two equal-length halves. Explicitly let U generate all odd-length strings with central a via U→a|aUa|aUb|bUa|bUb, and V generate those with central b by the analogous rules with base b. S→UV|VU then generates exactly even-length strings whose two halves differ somewhere. If component lengths are 2i+1 and 2j+1, their differing central symbols are i+j+1 positions apart, exactly half the total length. Conversely any mismatch supplies such a split. Thus L2 is context-free and A holds.