anchor.diff:    (assert (grammar-nonterminalp terminals nonterminals (car production)))
     (and (= 2 (length production))
          (grammar-nonterminalp terminals nonterminals (second production))))
  +
   
   (defun grammar-nonterminal-fixpoint (function grammar)
     "Compute a fixpoint mapping from nonterminals of grammar to some set.
  
positive.code:         grammar)))
  
  
  (defun grammar-remove-unit (grammar)
    (let ((nonterms (grammar-nonterminals grammar))
          (unit-prod (make-finite-set :mutable t))
          (unit-body (make-hash-table :test #'equal))
          (modified))
      ;; find unit nonterminals
      (grammar-map nil
                   (lambda (head body)
                     (when (and (= 1 (length body))
                                (finite-set-inp (first body) nonterms))
                       (finite-set-nadd unit-prod (cons head body))
                       (push head (gethash (first body) unit-body ))))
                   grammar)
      ;; rewrite
      (setq grammar
            (rewrite-grammar
             (lambda (head body)
               ;;(format t "rewrite ~A => ~A~&" head body)
               (cond
                 ((finite-set-inp (cons head body) unit-prod)
                  (setq modified t)
                  nil)
                 ((and (finite-set-inp head unit-body))
                  (cons (cons head body)
                        (loop for A in (gethash head unit-body)
                           for p = (cons A body)
                           unless (finite-set-inp p unit-prod)
                           collect p)))
                 (t (list (cons head body)))))
             grammar :keep-repeated t))
      (if modified
          (grammar-remove-unit grammar)
          grammar)))
  
  (defun grammar-print (grammar &optional (output *standard-output*))
    (grammar-map nil (curry-list #'format output  "~&~A => ~{~A~^ ~}~%") grammar))
  
negative.code:                                 (finite-set-filter (lambda (rule)
                                                       (grammar-chain-rule-p terminals nonterminals rule))
                                                     grammar)))
  
  (defun grammar-chainable-parent-function (grammar &optional
                                      (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 parent nonterminals"
    (let* ((chainable (grammar-chainable-function grammar terminals nonterminals)))
      (curry-right #'gethash
                   (finite-set-fold (lambda (hash A)
                                      (finite-set-fold (lambda (hash B)
                                                         (setf (gethash b hash)
                                                               (finite-set-add (gethash b hash) a))
                                                         hash)
                                                       hash (funcall chainable a)))
                                    (make-hash-table :test #'equal)
                                    nonterminals))))
  
  (defun grammar-body-function (grammar)
    "Indexes productions by head.
  