anchor.diff:                                     (terminals (grammar-terminals grammar))
                                      (nonterminals (grammar-nonterminals grammar)))
     "Compute nonterminals reachable for each nonterminal of the grammar using only chain rules.
  -RESULT: (lambda nonterminal) => finite-set of chainable nonterminals"
  +RESULT: (lambda nonterminal) => finite-set of chainable child nonterminals"
     (grammar-nonterminal-fixpoint (lambda (head body head-set mapping-function)
                                     (declare (ignore head))
                                     (finite-set-add (finite-set-union head-set
  
positive.code:                                 (finite-set-filter (lambda (rule)
                                                       (grammar-chain-rule-p terminals nonterminals rule))
                                                     grammar)))
  
  (defun grammar-body-function (grammar)
    "Indexes productions by head.
  
negative.code:         grammar)))
  
  
  ;; Hopcroft '79 p. 91
  (defun grammar-remove-unit (grammar)
    "Remove unit productions from the grammar."
    ;; FIXME: sometimes reorders and loses the start symbol
    (let* ((terminals (grammar-terminals grammar))
           (nonterminals (grammar-nonterminals grammar))
           (chainable (grammar-chainable-parent-function  grammar terminals nonterminals)))
      (rewrite-grammar-list
       (lambda (production)
         (unless (grammar-chain-rule-p terminals nonterminals production)
           (let* ((b (car production))
                  (alpha (cdr production))
                  (a-list (funcall chainable b)))
             (cons production
                   (finite-set-map 'list (lambda (a) (cons a alpha)) a-list)))))
       grammar :recursive nil)))
  
  
  (defun grammar-print (grammar &optional (output *standard-output*))
    (grammar-map nil (curry-list #'format output  "~&~A => ~{~A~^ ~}~%") grammar))
  