      (fn [& children]
        (let [[lhs rhs] children]
          [:Disjunction (-negate-formula lhs) rhs]))} tree))
-
-(defn- -reconstruct-node [key children] (into [key] children))
 
 (defn- -transform-term-negation
   [& children]

      result
      (recur result))))

(defn depth-tree-seq [tree] (tree-seq #(vector? (second %)) rest tree))

(defn walk-tree
  ([tree f]
   (walk-tree [] tree (constantly true) f))
  ([path tree filter-by f]
   "Walks the syntax tree depth-first, filtering nodes with filter-by, and then
   applying f to matched nodes (f takes path and node)."
   (let [tree-seq (depth-tree-seq tree)
         [subpath matched] (split-with (complement filter-by) tree-seq)
         path (concat path subpath)]
     (f path (first matched))
     (if (empty? (rest matched))
       nil
       (recur path (rest matched) filter-by f)))))

(defn wff->cnf
  [formula]
  "Converts a well-formed formula in string form to conjuctive-normal-form in
  tree form."
  (-> (logic-parser formula)
      simplify-tree
      transform-implications
      transform-negations))

(def example-expr "\\A x { Cigla(x) => ((\\E y {Na(x, y) && ~Piramida(y)}) && (~\\E y {Na(x,y) && Na(y,x) }) && (\\A y { ~Cigla(y) => ~Jednako(x,y)}))}")


(defn- -negate-quantifier
  [quantifier]
  (if (nonterm? quantifier :QuantifierNegation)
    (second quantifier)
    [:QuantifierNegation quantifier]))

(defn- -negate-formula
  [formula]
  (if (nonterm? formula :QuantifiedFormula)
    (let [[_ quantifier formula] formula]
      ;; This will, in turn, negate the formula in next iteration.
      [:QuantifiedFormula (-negate-quantifier quantifier) formula])
