(in-package cl-user)

#+:mcl
(eval-when (:compile-toplevel :load-toplevel :execute)
  (require :opentransport))

#+:lispworks
(eval-when (:compile-toplevel :load-toplevel :execute)
  (require "comm"))

(defpackage racer
  (:use common-lisp nrql-symbols #+:allegro excl)
  (:export "+TOP-SYMBOL+"
           "+BOTTOM-SYMBOL+"
           "TBOX"
           "INIT-TBOX"
           "SAVE-TBOX"
           "DELETE-TBOX"
           "FORGET-TBOX"
           "CURRENT-TBOX"
           "SET-NOMINALS-DISJOINT-P"
           "NOMINALS-DISJOINT-P"
           "FIND-TBOX"
           "SET-FIND-TBOX"
           "CREATE-TBOX-CLONE"
           "CLONE-TBOX"
           "TBOX-NAME"
           "IN-TBOX"
           "INIT-ABOX"
           "SET-CURRENT-TBOX"
           "SET-CURRENT-ABOX"
           "SAVE-ABOX"
           "DELETE-ABOX"
           "FORGET-ABOX"
           "CURRENT-ABOX"
           "FIND-ABOX"
           "SET-FIND-ABOX"
           "CREATE-ABOX-CLONE"
           "CLONE-ABOX"
           "ABOX-NAME"
           "IN-ABOX"
           "*TOP*"
           "TOP"
           "*BOTTOM*"
           "BOTTOM"
           "AT-LEAST"
           "AT-MOST"
           "EXACTLY"
           "SOME"
           "ALL"
           "NOT"
           "AND"
           "OR"
           "INV"
           "DEFINE-TBOX"
           "SIGNATURE"
           "ENSURE-TBOX-SIGNATURE"
           "ENSURE-ABOX-SIGNATURE"
           "GET-KB-SIGNATURE"
           "GET-TBOX-SIGNATURE"
           "GET-ABOX-SIGNATURE"
           "IN-KNOWLEDGE-BASE"
           "DEFINE-PRIMITIVE-CONCEPT"
           "DEFPRIMCONCEPT"
           "DEFINE-CONCEPT"
           "DEFCONCEPT"
           "IMPLIES"
           "EQUIVALENT"
           "DISJOINT"
           "DEFINE-DISJOINT-PRIMITIVE-CONCEPT"
           "ADD-DISJOINTNESS-AXIOM"
           "ADD-CONCEPT-AXIOM"
           "FORGET-CONCEPT-AXIOM"
           "FORGET-CONSTRAINT"
           "FORGET-CONSTRAINED-ASSERTION"
           "FORGET-DISJOINTNESS-AXIOM"
           "FORGET-DISJOINTNESS-AXIOM-STATEMENT"
           "DEFINE-PRIMITIVE-ROLE"
           "DEFPRIMROLE"
           "DEFINE-PRIMITIVE-ATTRIBUTE"
           "DEFPRIMATTRIBUTE"
           "DEFCDATTRIBUTE"
           "DEFINE-CONCRETE-DOMAIN-ATTRIBUTE"
           "ADD-ROLE-AXIOMS"
           ;"ADD-ROLE-AXIOM" ;now obsolete?
           "DEFINE-DISTINCT-INDIVIDUAL"
           "DEFINE-INDIVIDUAL"
           "ADD-INDIVIDUAL"
           "STATE"
           "INSTANCE"
           "RELATED"
           "ADD-CONCEPT-ASSERTION"
           "ADD-ROLE-ASSERTION"
           "FORGET-CONCEPT-ASSERTION"
           "FORGET-ROLE-ASSERTION"
           "FORGET"
           "FORGET-STATEMENT"
           "CONCEPT-SATISFIABLE?"
           "CONCEPT-SATISFIABLE-P"
           "ALC-CONCEPT-COHERENT"
           "CONCEPT-SUBSUMES?"
           "CONCEPT-SUBSUMES-P"
           "CONCEPT-EQUIVALENT?"
           "CONCEPT-EQUIVALENT-P"
           "CONCEPT-DISJOINT?"
           "CONCEPT-DISJOINT-P"
           "CLASSIFY-TBOX"
           "CHECK-TBOX-COHERENCE"
           "TBOX-COHERENT-P"
           "TBOX-COHERENT?"
           "TBOX-CLASSIFIED-P"
           "TBOX-CLASSIFIED?"
           "TBOX-PREPARED-P"
           "TBOX-PREPARED?"
           "TBOX-CYCLIC-P"
           "TBOX-CYCLIC?"
           "CYCLIC-CONCEPTS-IN-TBOX"
           "ATOMIC-CONCEPT-DESCENDANTS"
           "ATOMIC-CONCEPT-ANCESTORS"
           "ATOMIC-CONCEPT-CHILDREN"
           "ATOMIC-CONCEPT-PARENTS"
           "ATOMIC-CONCEPT-SYNONYMS"
           "CONCEPT-SYNONYMS"
           "CONCEPT-DESCENDANTS"
           "CONCEPT-OFFSPRING"
           "CONCEPT-CHILDREN"
           "CONCEPT-ANCESTORS"
           "CONCEPT-PARENTS"
           "CONCEPT-IS-PRIMITIVE-P"
           "CONCEPT-IS-PRIMITIVE?"
           "CONCEPT-INSTANCES"
           "TAXONOMY"
           "ROLE-PARENTS"
           "ROLE-CHILDREN"
           "ROLE-OFFSPRING"
           "ROLE-ANCESTORS"
           "ROLE-DESCENDANTS"
           "ROLE-INVERSE"
           "ATOMIC-ROLE-PARENTS"
           "ATOMIC-ROLE-CHILDREN"
           "ATOMIC-ROLE-ANCESTORS"
           "ATOMIC-ROLE-DESCENDANTS"
           "ATOMIC-ROLE-INVERSE"
           "DEFINE-ABOX"
           "REALIZE-ABOX"
           "CHECK-ABOX-COHERENCE"
           "ABOX-REALIZED-P"
           "ABOX-REALIZED?"
           "ABOX-PREPARED-P"
           "ABOX-PREPARED?"
           "ABOX-CONSISTENT-P"
           "ABOX-CONSISTENT?"
           "ABOX-UNA-CONSISTENT-P"
           "ABOX-UNA-CONSISTENT?"
           "ROLE-SUBSUMES?"
           "ROLE-SUBSUMES-P"
           "INDIVIDUAL-P"
           "INDIVIDUAL?"
           "CD-OBJECT-P"
           "CD-OBJECT?"
           "INDIVIDUAL-TYPES"
           "INDIVIDUAL-DIRECT-TYPES"
           "INDIVIDUAL-INSTANCE?"
           "INDIVIDUAL-INSTANCE-P"
           "INDIVIDUAL-FILLERS"
           "INDIVIDUAL-ATTRIBUTE-FILLERS"
           "INDIVIDUALS-RELATED?"
           "INDIVIDUALS-RELATED-P"
           "INDIVIDUALS-EQUAL?"
           "INDIVIDUALS-NOT-EQUAL?"
           "INDIVIDUALS-EQUAL-P"
           "INDIVIDUALS-NOT-EQUAL-P"
           "INSTANTIATORS"
           "MOST-SPECIFIC-INSTANTIATORS"
           "RETRIEVE-CONCEPT-INSTANCES"
           "RETRIEVE-INDIVIDUAL-FILLED-ROLES"
           "INDIVIDUAL-FILLED-ROLES"
           "RETRIEVE-DIRECT-PREDECESSORS"
           "DIRECT-PREDECESSORS"
           "RETRIEVE-RELATED-INDIVIDUALS"
           "RETRIEVE-INDIVIDUAL-FILLERS"
           "RETRIEVE-INDIVIDUAL-ATTRIBUTE-FILLERS"
           "TOLD-VALUE"
           "RELATED-INDIVIDUALS"
           "ALL-TBOXES"
           "DELETE-ALL-TBOXES"
           "ALL-ABOXES"
           "DELETE-ALL-ABOXES"
           "LOOP-OVER-ABOXES"
           "LOOP-OVER-TBOXES"
           "ALL-ROLES"
           "ALL-FEATURES"
           "ALL-TRANSITIVE-ROLES"
           "ALL-ATTRIBUTES"
           "ATTRIBUTE-TYPE"
           "ATTRIBUTE-HAS-RANGE"
           "ATTRIBUTE-DOMAIN"
           "ATTRIBUTE-DOMAIN-1"
           "ATTRIBUTE-HAS-DOMAIN"
           "ALL-ATOMIC-CONCEPTS"
           "ALL-EQUIVALENT-CONCEPTS"
           "ALL-INDIVIDUALS"
           "ALL-CONCEPT-ASSERTIONS-FOR-INDIVIDUAL"
           "ALL-ROLE-ASSERTIONS-FOR-INDIVIDUAL-IN-DOMAIN"
           "ALL-ROLE-ASSERTIONS-FOR-INDIVIDUAL-IN-RANGE"
           "ALL-ROLE-ASSERTIONS"
           "ALL-ATTRIBUTE-ASSERTIONS"
           "ALL-CONCEPT-ASSERTIONS"
           "ALL-CONSTRAINTS"
           "ROLE-P"
           "ROLE?"
           "TRANSITIVE-P"
           "TRANSITIVE?"
           "FEATURE-P"
           "FEATURE?"
           "CD-ATTRIBUTE-P"
           "CD-ATTRIBUTE?"
           "SYMMETRIC-P"
           "SYMMETRIC?"
           "REFLEXIVE-P"
           "REFLEXIVE?"
           "CONCEPT-P"
           "CONCEPT?"
           "DESCRIBE-TBOX"
           "DESCRIBE-CONCEPT"
           "DESCRIBE-ROLE"
           "DESCRIBE-ABOX"
           "DESCRIBE-INDIVIDUAL"
           "ALC-CONCEPT-COHERENT"
           "VALIDATE-TRUE"
           "VALIDATE-FALSE"
           "VALIDATE-SET"
           "VERIFY-WITH-CONCEPT-TREE-LIST"
           "VERIFY-WITH-ABOX-INDIVIDUALS-LIST"
           "VERIFY-WITH-CONCEPT-TREE"
           "TEST-ASSERT"
           "TEST-VERIFY-WITH-CONCEPT-TREE-LIST"
           "TEST-VERIFY-WITH-ABOX-INDIVIDUALS-LIST"
           "DISPLAY-GRAPH"
           "PRINT-TBOX-TREE"
           "WITH-RACER-STATISTICS"
           "WITH-SAT-STATISTICS"
           "WITH-KB-STATISTICS"
           "WITH-VERBOSE-STATISTICS"
           "CONSTRAINED"
           "ADD-ATTRIBUTE-ASSERTION"
           "CONSTRAINTS"
           "ADD-CONSTRAINT-ASSERTION"
           ">="
           "<="
           ">"
           "<"
           "<>"
           "="
           "*"
           "+"
           "-"
           "A"
           "AN"
           "NO"
           "ENSURE"
           "MIN"
           "MAX"
           "RANGE"
           "EQUAL"
           "STRING="
           "STRING<>"
           "COMPLEX"
           "REAL"
           "INTEGER"
           "CARDINAL"
           "STRING"
           "BOOLEAN"
           "XML-READ-TBOX-FILE"
           "RDFS-READ-TBOX-FILE"
           "RACER-READ-FILE"
           "RACER-READ-DOCUMENT"
           "DAML-READ-FILE"
           "DAML-READ-DOCUMENT"
           "OWL-READ-FILE"
           "OWL-READ-DOCUMENT"
           "DIG-READ-FILE"
           "DIG-READ-DOCUMENT"
           "ASSOCIATED-TBOX"
           "SET-ASSOCIATED-TBOX"
           "ASSOCIATED-ABOXES"
           "SAVE-KB"
           "INCLUDE-KB"
           "IMPORT-KB"
           "CLEAR-DEFAULT-TBOX"
           "COMPUTE-INDEX-FOR-INSTANCE-RETRIEVAL"
           "ENSURE-SUBSUMPTION-BASED-QUERY-ANSWERING"
           "ENSURE-SMALL-TBOXES"
           "PUBLISH"
           "PUBLISH-1"
           "UNPUBLISH"
           "UNPUBLISH-1"
           "SUBSCRIBE"
           "SUBSCRIBE-1"
           "UNSUBSCRIBE"
           "UNSUBSCRIBE-1"
           "INIT-SUBSCRIPTIONS"
           "INIT-SUBSCRIPTIONS-1"
           "INIT-PUBLICATIONS"
           "INIT-PUBLICATIONS-1"
           "CHECK-SUBSCRIPTIONS"
           "FUNCTIONAL"
           "ROLE-IS-FUNCTIONAL"
           "TRANSITIVE"
           "ROLE-IS-TRANSITIVE"
           "INVERSE"
           "INVERSE-OF-ROLE"
           "DECLARE-DISJOINT"
           "DOMAIN"
           "ROLE-HAS-DOMAIN"
           ;;"RANGE"
           "ROLE-HAS-RANGE"
           "IMPLIES-ROLE"
           "ROLE-HAS-PARENT"
           "GET-TBOX-LANGUAGE"
           "GET-ABOX-LANGUAGE"
           "GET-META-CONSTRAINT"
           "GET-CONCEPT-DEFINITION"
           "GET-CONCEPT-NEGATED-DEFINITION"
           "GET-CONCEPT-DEFINITION-1"
           "GET-CONCEPT-NEGATED-DEFINITION-1"
           "ATOMIC-ROLE-RANGE"
           "ROLE-RANGE"
           "ATOMIC-ROLE-DOMAIN"
           "ROLE-DOMAIN"
           "DEFAULT"
           "LOGGING-ON"
           "LOGGING-OFF"
           "TBOX-NAMESPACES"
           "REMOVE-PREFIX"
           "GET-NAMESPACE-PREFIX"
           "EXPT"
           "STORE-TBOX-IMAGE"
           "STORE-TBOXES-IMAGE"
           "STORE-ABOX-IMAGE"
           "STORE-ABOXES-IMAGE"
           "STORE-KB-IMAGE"
           "STORE-KBS-IMAGE"
           "RESTORE-ABOX-IMAGE"
           "RESTORE-ABOXES-IMAGE"
           "RESTORE-TBOX-IMAGE"
           "RESTORE-TBOXES-IMAGE"
           "RESTORE-KB-IMAGE"
           "RESTORE-KBS-IMAGE"
           "MIRROR"
           "CLEAR-MIRROR-TABLE"
           "KB-ONTOLOGIES"
           "COMPUTE-IMPLICIT-ROLE-FILLERS"
           "COMPUTE-ALL-IMPLICIT-ROLE-FILLERS"
           "CONSTRAINT-ENTAILED-P"
           "CONSTRAINT-ENTAILED?"
           "ROLES-EQUIVALENT"
           "ROLES-EQUIVALENT-1"
           "ATOMIC-ROLE-SYNONYMS"
           "ROLE-SYNONYMS"
           "PRINT-ABOX-INDIVIDUALS"
           "INDIVIDUAL-TOLD-DATATYPE-FILLERS"
           "RETRIEVE-INDIVIDUAL-TOLD-DATATYPE-FILLERS"
           "ROLE-USED-AS-DATATYPE-PROPERTY-P"
           "ROLE-IS-USED-AS-DATATYPE-PROPERTY"
           "DATATYPE-ROLE-RANGE"
           "DATATYPE-ROLE-HAS-RANGE"
           "SET-SERVER-TIMEOUT"
           "GET-SERVER-TIMEOUT"
           "DEFINE-DATATYPE-PROPERTY"
           "ADD-DATATYPE-PROPERTY"
           "WITH-UNIQUE-NAME-ASSUMPTION"
           "WITHOUT-UNIQUE-NAME-ASSUMPTION"
           "SET-UNIQUE-NAME-ASSUMPTION"
           "RETRIEVE-INDIVIDUAL-SYNONYMS"
           "INDIVIDUAL-SYNONYMS"

               
           "ATTRIBUTE-FILLER"
           "SET-ATTRIBUTE-FILLER"
           "DATATYPE-ROLE-FILLER"
           "ADD-DATATYPE-ROLE-FILLER"
                  

           "GET-TBOX-VERSION"
           "GET-ABOX-VERSION"

           "INDIVIDUAL-ATTRIBUTE-VALUE"
           "RETRIEVE-INDIVIDUAL-ATTRIBUTE-VALUE"
           "CREATE-TBOX-INTERNAL-MARKER-CONCEPT"

           "PARSE-EXPRESSION"

           "ROLE-USED-AS-ANNOTATION-PROPERTY-P"
           "ROLE-IS-USED-AS-ANNOTATION-PROPERTY"
           "ADD-ANNOTATION-CONCEPT-ASSERTION"
           "ADD-ANNOTATION-ROLE-ASSERTION"
           "ALL-ANNOTATION-CONCEPT-ASSERTIONS"
           "ALL-ANNOTATION-ROLE-ASSERTIONS"

           "TRUE?"
           "FALSE?"

           "CREATE-TBOX-INTERNAL-MARKER-CONCEPT"

           "RACER-INTERNAL%HAS-STRING-VALUE"
           "RACER-INTERNAL%HAS-INTEGER-VALUE"
           "RACER-INTERNAL%HAS-CARDINAL-VALUE"
           "RACER-INTERNAL%HAS-REAL-VALUE"
           "RACER-INTERNAL%HAS-BOOLEAN-VALUE"

           "INTERNAL-INDIVIDUALS-RELATED-P"

           "WITHOUT-SIGNATURE-CHECKS"

           "WITH-CRITICAL-SECTION"
                  
           "WITH-SERVER-CONNECTION"
           "*DEFAULT-RACER-HOST*"
           "*DEFAULT-RACER-TCP-PORT*"
           "*VERBOSE-CONNECTION*"
           "*WITH-SERVER-CONNECTION*"
           "*SERVICE-REQUEST-VERBOSE*"
           "OPEN-SERVER-CONNECTION"
           "REOPEN-SERVER-CONNECTION"
           "CLOSE-SERVER-CONNECTION"))

(eval-when (:load-toplevel :execute)
  (defun use-racer-in-cl-user ()
    (dolist (package '(racer nrql-symbols))
      (loop for sym being the external-symbols of (find-package package) do
          (let ((cl-user-sym (find-symbol (symbol-name sym) 'cl-user)))
            (when cl-user-sym
              (unintern cl-user-sym 'cl-user)))
          (import sym 'cl-user)))))

(eval-when (:load-toplevel :execute)
  (use-racer-in-cl-user))


(defpackage racer-user
  (:use common-lisp racer))




