                          (spec 'AnotherInt string?)
                          (spec 'AnotherInt (ref-schema 'Integer))
                          (spec 'AndAnotherInt (ref-schema 'AnotherInt)))
-  (doall (all-predicates 'AndAnotherInt))
+    (doall (all-predicates 'AndAnotherInt))
+    #_(doall (predicate-rules-for-type 'AndAnotherInt))
   #_(leaf-pred? 'AnotherInt)
   #_(all-types 'AndAnotherInt)
   #_(all-types 'AndAnotherInt)
   #_(to-leaf-types 'AAnotherInt)
   #_(to-leaf-types 'AnotherInt)
   )
-
-(defmulti apply-pred (fn [f v] (first f)))
-(defmethod apply-pred :== [[_ pred] value] (= value pred))
-(defmethod apply-pred := [[_ pred] value] (pred value))
-(defmethod apply-pred :=> [[_ pred] value] (= (cond
-                                                (map? value) :MAPP
-                                                (sequence-like? value) :SEQQ
-                                                :else :_____BAD)
-                                              pred))
+(ns-unmap *ns* 'apply-pred)
+(defmulti apply-pred (fn [f v] (second f)))
+(defmethod apply-pred :== [[t _ pred] value] (= value pred))
+(defmethod apply-pred :=  [[t _ pred] value] (pred value))
+(defmethod apply-pred :=> [[t _ pred] value] (= (cond
+                                                  (map? value) :MAPP
+                                                  (sequence-like? value) :SEQQ
+                                                  :else :_____BAD)
+                                                pred))
 
 (defn type-check-pred [pred value state]
-  (if-not (apply-pred pred value)
-    (let [error {:Error-type :failed-predicate
-                 :not (second pred)
-                 :value value
-                 :type-sig (:type-sig state)
-                 :path     (:path state)}]
-      [(if (not= (-> state :type-sig first)
-                 (last pred))
-         (assoc error :sub-type (last pred)) error)])
-    {:success-type (last pred)}))
-
+  (let [[typ _ pred-op] pred]
+    (if-not (apply-pred pred value)
+      (let [error {:Error-type :failed-predicate
+                   :not pred-op
+                   :value value
+                   :type-sig (:type-sig state)
+                   :path     (:path state)}]
+        [(if (not= (-> state :type-sig first)
+                   typ)
+           (assoc error :sub-type typ) error)])
+      {:success-type typ})))
+
+;; TODO this allows a OR reloationship??
+;; lets formalize this as an and relationship
+;; the or-spec handles the OR relationship
 (defn type-check-value [parent-type value state]
   (if-let [preds (all-predicates parent-type)]
     (let [errors   (map #(type-check-pred % value state) preds)

      [typ simple-exp])))
  ([simple-exp]
   (pred-type-help simple-exp nil)))







#_(with-schema
  (index-spec

      (empty? errors) complex
      (empty? filtered-errors) (/ complex 2.0)
      :else false)))


(defn ancester-key-rules
  "Returns all the key terminal ancester rules for a given type."
