     (log/debug (str "micro lexicon size:" (count (keys micro-lexicon))))
     (clojure.core/merge small
                         {:lexicon micro-lexicon})))
+
+(defn lookup-spec [spec indices]
+  (log/debug (str "index-fn called with spec: " 
+                  (strip-refs
+                   (dissoc (strip-refs spec)
+                           :dag_unify.core/serialized))))
+  (let [result
+        (reduce intersection-with-identity
+                (filter #(not (empty? %))
+                        (map (fn [path]
+                               (let [result
+                                     (get (get indices path)
+                                          (get-in spec path ::undefined))]
+                                 (log/trace (str "subset for path:" path " => " (get-in spec path ::undefined)
+                                                 " = " (count result)))
+                                 result))
+                             index-lexicon-on-paths)))]
+    (log/debug (str "indexed size returned: " (count result)))
+    result))
 
 (defn medium []
   (deliver-lexicon)

     :generate {:lexicon lexicon-for-generation}
     :grammar grammar
     :lexicon lexicon
     :aux2lex ;; map:<pred => subset of lexicon with that pred>
     (map-subset-by-path lexicon-for-generation [:synsem :aux])

     :pred2lex ;; map:<pred => subset of lexicon with that pred>
     (map-subset-by-path lexicon-for-generation [:synsem :sem :pred])

     :cat2lex ;; map:<cat => subset of lexicon with that cat>
     (map-subset-by-path lexicon-for-generation [:synsem :cat])
           
     :lexical-cache (atom (cache/fifo-cache-factory {} :threshold 1024))
     :lookup (fn [arg]
               (analyze arg lexicon))

   [:synsem :cat]
   [:synsem :sem :pred]])

(defn create-indices [lexicon]
  (into {}
        (map (fn [path]
               [path (map-subset-by-path lexicon path)])
             index-lexicon-on-paths)))

(defn fo-ps [expr]
  (parse/fo-ps expr fo))
