                                                          (->edge i (inc i)))))
     (fixpoint! state)
     (get-facts state :known|pretended connected))
+
+  (deffact return "[x] is connected to 2")
+
+  (let [plan (-> empty-flow-plan
+                 (add-shape :known edge)
+                 (add-shape :pretended connected)
+                 (add-shape :pretended return)
+                 (add-rules [(Rule. [(Recall. :known|pretended (->edge 'x 'y))
+                                     (Output. :pretended (->connected 'x 'y))])
+                             (Rule. [(Recall. :known|pretended (->edge 'x 'y))
+                                     (Recall. :known|pretended (->connected 'y 'z))
+                                     (Output. :pretended (->connected 'x 'z))])
+                             (Rule. [(Recall. :known|pretended (->connected 'x 2))
+                                     (Output. :pretended (->return 'x))])]))
+        state (flow-plan->flow-state plan)]
+    (add-facts state :known|pretended edge #js [(->edge 0 1) (->edge 1 2) (->edge 2 3) (->edge 3 1)])
+    (time (fixpoint! state))
+    (get-facts state :known|pretended return))
   )
 
 (comment

        [plan index-b'] (add-flow plan (->Index nodes-b index-ixes-b))
        _ (assert (= index-b index-b'))
        [plan lookup-b] (add-flow plan (->Lookup [index-b] index-a lookup-ixes-b val-ixes-b))]
    [plan [lookup-a lookup-b] (vec (distinct (concat vars-a vars-b)))]))

(defn add-rule [plan rule]
  (let [recalls (filter #(= Recall (type %)) (:clauses rule))

;; PATTERNS

(defn pattern->vars [pattern]
  (vec (for [value (.-values pattern)]
         (if (symbol? value)
           value
           '_))))

(defn pattern->filter [pattern]
  `(pattern->filter* ~(.-shape pattern)))
