   (all 
     (nestedtype ?nested)
     (equals ?outer (.getOuterClass ?nested)))) ;also returns other outer types
+
+(defn
+  nestedtype-outertype+
+  "Relation between a nested and one of its encompassing outer types."
+  [?nested ?outer]
+  (conde
+    [(nestedtype-outertype ?nested ?outer)]
+    [(fresh [?o]
+            (nestedtype-outertype ?nested ?o)
+            (nestedtype-outertype ?o ?outer))]))
 
 
 (defn

     (fresh [?type]
            (type-member ?type ?member))]))

;(defn
;  type-member
;  "Relation between a type and one of its declared members as known to the weaver."

(defn- 
  resolvedmember-synthetic?
  [?resolvedmember ?syntheticbool]
  (all
    (member ?resolvedmember)
    (equals ?syntheticbool (.isSynthetic ?resolvedmember))))

(defn
  syntheticmember
  "Relation of synthetic members."
  [?resolvedmember]
  (all
    (resolvedmember-synthetic? ?resolvedmember true)))
  
(defn
  nonsyntheticmember
  "Relation of nonsynethic members."
  [?resolvedmember]
  (all
     (resolvedmember-synthetic? ?resolvedmember false)))


(defn
  aspect-declaredinterface

    (succeeds (.isNested ?resolvedtype))))

(defn
  topleveltype
  "Relation of non-nested types known to the AspectJ weaver."
  [?type]
  (all
    (type ?type)
    (equals false (.isNested ?type))))

(defn
  nestedtype-outertype
  "Relation between a nested and its immediate outer type.

   e.g., (ekeko* [?i ?o]  (interface ?i) (nestedtype-outertype ?i ?o))

