OntoMorph: A Translation System for Symbolic Knowledge Hans Chalupsky Loom/PowerLoom Group USC Information Sciences Institute USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 1 Overview Motivation Translation Problem OntoMorph Overview OntoMorph Applications Conclusions USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 2 Motivation Observations Ontology development collaborative but independent Repeated merges/imports are the norm Different tasks solved using different KR systems different syntax, knowledge models, expressivity Different tasks require different modeling styles Translation problem is ubiquitous Merging of semantically overlapping ontologies Distributed heterogeneous agent communication Integration of independently developed K-based systems Porting of K-based systems to different KR infrastructure USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 3 Some Opinions “We need standards, KIF, OKBC, HPKB upper structure, etc. to minimize translation needs….” “We’ll never decide on that standard representation language, everybody has their own favorite…” “People will hack through any representation available…” “We better learn to live in a world where everybody represents things differently…” “What’s the big deal, I can write any X-to-KIF translator in 5 Prolog clauses/minutes” “Writing translators is not really difficult…” Sound familiar? USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 4 The Translation Problem Target KB Source KB KBs describable in some linear syntax sentence-based translation single expression to whole KB arbitrary semantic shift allowed morphing USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 5 Translation Dimensions KR language syntax KR language expressivity class distinction vs. attribute relations, argument order, argument reification, naming conventions,... Model coverage and granularity Representation paradigms quantification, negation, defaults, sets, modals, ... Modeling conventions KIF, Loom, PowerLoom, MELD, SNePS, OntoLingua, … time, action, plans, causality, propositional attitudes, ... Inference system bias collections vs. individuals, subclass-of vs. =>, ... USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 6 Example: Syntax Differences Loom: (defconcept Automobile “The class of passenger cars.” :is-primitive Road-Vehicle) MELD: (#$isa #$Automobile #$Collection) (#$genls #$Automobile #$RoadVehicle) (#$comment #$Automobile “The class of passenger cars”) KIF: (defrelation Automobile (?x) “The class of passenger cars” :=> (Road-Vehicle ?x)) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 7 Example: Model Differences Ontology A Ontology B Vehicle WheeledVehicle M151 Automotive-Device TrackedVehicle HMMWV M1 M60 maxSlopeRange (AngleRange -60 45) USC INFORMATION SCIENCES INSTITUTE M-1 M-151 traction-type traction-type tracked wheeled max-gradient 45 Loom/PowerLoom Group 8 Traditional Translation Methods Manual translation is slow tedious error-prone hard to repeat hard to document and trace often simply not practical Special-purpose translators are tedious to write hard to maintain not easily reusable USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 9 Need: Translation Tool Desiderata: Translate arbitrary KR languages No fixed knowledge model Concise, declarative specification of transformations Support for automatic, repeatable translations USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 10 Solution: OntoMorph Rapid and concise specification of KB translators via Syntactic rewriting pattern-directed rewrite rules sentence-level transformation of syntax trees based on pattern matching Semantic rewriting modulates syntactic rewriting uses integrated PowerLoom KR system based on (partial) semantic models uses logical inference USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 11 OntoMorph Rewrite Engine Pattern language and execution model similar to PLisp (Pattern Lisp), Lisp-70 Pattern Matcher Features Rapid generation of ontology and KR language translators Rewrites arbitrary syntax trees Powerful pattern language for concise specification and destructuring of expressions Full backtracking (can parse Type-0 languages) Named rule sets provide modularization and search control Seamless integration with PowerLoom facilitates semantic rewriting Available in Lisp, C++ and Java (written in STELLA) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 12 Pattern Language Literals match themselves: foo, hans, 2, (a (b c) d), etc. Variables match complete subtrees: ?x, ?bar, ? Sequence variables match tree subsequences: (??x foo ??y), ?? Grouping (AND) matches a sequence of tokens: {a ?x c} Alternatives (OR) match alternative token sequences: {a|(b ?x)|c d} Optionals match optional token sequences: {a [b c]} USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 13 Pattern Language, cont. Repetition matches a pattern multiple times: {a|b}+, {a|b}*1-2 Binding input matched by a pattern to a variable: ?x := {a|(b ?y)|c} matched against (b d) binds ?x to (b d). USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 14 Example Pattern Match key-value pairs in any order: (defconcept ?name {?is := {:is | :is-primitive} ?def | :characteristic ?cha | :annotations ?ann := {(documentation ?doc) | (:and ?? (documentation ?doc) ??) | ?}}*0-3) Example pattern instance: (defconcept Dog :annotations (:and Object-Type (documentation “Canine”)) :is-primitve Animal) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 15 Basic Operation Rewrite Rule Syntax pattern => result Execution Model Example Rule: (isa ?i ?c) => (?c ?i) Input stream: ( isa car1 Ford ) ( speed car1 ……… USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 16 Basic Operation Rule Syntax pattern => result Execution Model Example Rule: (isa ?i ?c) => (?c ?i) Input stream: ( isa car1 Ford ) ( speed car1 ……… USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 17 Basic Operation Rule Syntax pattern => result Execution Model Example Rule: (isa ?i ?c) => (?c ?i) Input stream: ( Ford car1 ) ( speed car1 ……… USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 18 Named Rule Sets and Recursion Rule Set Syntax (defruleset name pattern1 => result1 ... patternN => resultN) Function calls and rule recursion Rule sets and functions can be invoked recursively Arguments are consumed and results pushed back onto the input stream. {<Term> ?result} <Term ?x> <is-atom? ?x> USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 19 Rewrite Rule Example Rule definition: (defruleset Term (?op := {\+|-|\*|/} ?x ?y) => (?op <Term ?x> <Term ?y>) (1\+ ?x) => (\+ <Term ?x> 1) (1- ?x) => (- <Term ?x> 1) (square ?x) => (\* <Term ?x> <Term ?x>) ?x => ?x ) (defruleset Condition (lt ?x ?y) => (negative? (- <Term ?x> <Term ?y>)) (gt ?x ?y) => <Condition (lt ?y ?x)> ) Rule application: (rewrite (gt (/ (1+ M) N) (square N)) Condition) => (negative? (- (* N N) (/ (+ M 1) N))) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 20 Rewrite Rule Example: Turing Machine (defruleset Turing (?p := (??x (?s ?h ?act ?ss) ??y) ?s (?l ?h ?r)) => <Turing (?p ?ss <Move-Head ?act (?l ?h ?r)>)> (?prog ?state ((??l) ?h (??r))) => (??l ?h ??r) ) (defruleset Move-Head {R ((??l) ?h ())} => ((??l ?h) $ ()) {R ((??l) ?h (?r ??rt))} => ((??l ?h) ?r (??rt)) {L (() ?h (??r))} => (() $ (?h ??r)) {L ((??lt ?l) ?h (??r))} => ((??lt) ?l (?h ??r)) {?new (?l ?h ?r)} => (?l ?new ?r) ) Compute f(x) = x + 2: (rewrite ( ((s1 $ R s2) (s2 1 R s2) (s2 $ 1 s3) (s3 1 R s3) (s3 $ 1 s1)) s1 (() $ (1 1 1)) ) Turing) => ($ 1 1 1 1 1) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 21 Semantic Rewriting Syntactic rewriting very useful but limited: (defruleset Conflate-Truck-Types ({Light-Truck | Heavy-Truck | ... } ?x) => (Truck ?x) ) Instead, use semantic test: (defruleset Conflate-Truck-Types {(?class ?x) <ask (subset-of ?class Truck)>} => (Truck ?x) ) Semantic rewriting via integration with PowerLoom KRS USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 22 Two-Pass Translation Scheme Source KB Pass 1: Import Rules PowerLoom KB Pass 2: Translation Rules Target KB USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 23 Rewriting Non-Lisp-Style Expressions Lisp-style s-expressions for tree representation. Rewriting not limited to Lisp-style languages. Rewrite engine operates on input stream of tokens. Currently, STELLA reader serves as tokenizer. Other tokenizers can easily be substituted. Rewrite engine could specify tokenizers. special-purpose tokenizers will be much more efficient. USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 24 OntoMorph Application: Input Translation for COA Critiquer USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 25 Input Translation for COA Critiquer OntoMorph USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 26 Fusion Output to EXPECT: Translation Issues Different Names (defruleset Rename-Collection FixMilitaryTask => FIX {ProtectingSomething | Protecting…Region} => PROTECT Translation-LocationChange => MOVE … … …) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 27 Fusion Output to EXPECT: Translation Issues cont. Different Syntax: MELD/KIF => Loom (isa task1 Fix-MilitaryTask) => (Fix task1) (isa COAMt COASpecificationMicrotheory) => (COA COAMt) (relationInstanceExistsCount subOrgsDirect unit1 ArmoredSpec) => (:about unit1 (:exactly 2 subOrgsDirect ArmoredSpec)) (defruleset Rewrite-Frame-Predicate (relationInstanceExistsCount ?rel ?inst ?type ?count) => (:ABOUT <Rewrite-Term ?inst> (:EXACTLY ?count <Rename-Relation ?rel> <Rename-Collection ?type>)) ) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 28 Fusion Output to EXPECT: Translation Issues cont. Different Representations (taskHasPurpose BlueDivisionTask (thereExists ?p (isa ?p (CollectionSubsetFn ProtectingSomething (TheSetOf ?obj (and (objectTakenCareOf ?obj Boundary1) (performedBy ?obj BlueDivision1))))))) => (and (Protect protect-000) (Purpose-Action Protect-000) (purpose-of BlueDivisionTask Protect-000) (action-obj Protect-000 Boundary1) (who protect-000 BlueDivision1)) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 29 Fusion Output to EXPECT: Translation Issues cont. (defruleset Rewrite-Purpose-Pattern1 {(taskHasPurpose ?task (thereExists ?var (isa ?var (CollectionSubsetFn ?type (TheSetOf ?action ?body))))) <Generate-Skolem-Name ?type> ?purpose} => (AND (<Rename-Collection ?type> ?purpose) (PURPOSE-ACTION ?purpose) (PURPOSE-OF ?task ?purpose) <Rewrite-Purpose-SetOf-Body ?body ?action ?purpose> ) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 30 Fusion Output to EXPECT: Translation Issues cont. Missing Representations Some COA structure was not explicitly represented EXPECT critiquer needed task / subCOA associations Some essential COA structure was embedded in comments (defruleset Track-COA-Assertion (unitAssignedToTask ?task ?unit) => <!ASSERT (AND (Term ?task) (Term ?unit) (unitAssignedToTask ?task ?unit))>) (defruleset Get-Task-Assigned-To-Unit {?unit <RETRIEVE \?t (= (unitAssignedToTask \?t) ?unit)> ?task} => <OBJECT-NAME ?task> ) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 31 Fusion Output to EXPECT: Summary File-based translation of Fusion output MELD to KIF to Loom Required ~30 rewrite rule sets Tree destructuring capability very useful for rewriting complex purpose representations Semantic rewriting needed to recover unrepresented COA structure USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 32 Translation between Distributed Heterogeneous Agents USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 33 Rosetta Translation Service Rosetta aN PLANET Plan Ontology (HPKB) a2 Agents Agent Capabilities Ontology aN a1 M CoABS Grid Operators a1 USC INFORMATION SCIENCES INSTITUTE Domain Model Agent Model Operators Mapping KB Domain Model a2 Agent Models Loom/PowerLoom Group 34 Rosetta Translation Service Agent2 model Agent1 model Capabilities/ requests KB of representation reformulation rules Requested service by Agent1 Capabilities/ requests Capability of Agent2 Rosetta Wrapper Agent1 USC INFORMATION SCIENCES INSTITUTE Wrapper Agent2 Loom/PowerLoom Group 35 ForMAT to Prodigy Translation via Rosetta ForMAT request: (:goal (G-144 :send-hawk ((force 42nd-Hawk-Battalion) (geographic-location Big-Town)))) Format-To-Rosetta translation: (find (object Plans) (for (Objective-Based-Goal (send-unit (object 42nd-Hawk-Battalion) (to Big-Town))))) Rosetta goal representation translation: (find (object Plans) (for (State-Based-Goal (is-deployed (object 42nd-Hawk-Battalion) (at Big-Town))))) Rosetta-To-Prodigy translation: (:find-plans (is-deployed 42nd-Hawk-Battalion Big-Town)) USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 36 Using Rosetta with CoABS TIE 1: Ontology-Based Transformations Problem: Diverse views and languages (e.g., helicopters had segments, SAMSITE finder queried with SQL about regions) Without Rosetta: helicopter wrappers had to turn route segments into areas and issue query in SQL message sent: :content select distinct s.LAT, s.LON from SAMSITE s where s.LAT< 29.3843 and s.LAT> 29.355 and s.LON< 48.0399 and s.LON> 48.011 :receiver ARIADNE_TEAMCORE :sender TEAMARIADNE USC INFORMATION SCIENCES INSTITUTE With Rosetta: helicopter wrappers form request using route segments message sent: :content find SAMSITES from DP_A to LZ_A :sender TEAMARIADNE :receiver Rosetta Loom/PowerLoom Group 37 Conclusion Translation is a common problem with K-based systems OntoMorph tool makes it easier to write translators OntoMorph applications so far: Within HPKB to translate Fusion output Within CoABS/HPKB TIE to implement Rosetta ontology-based agent translation services (joint work with Y. Gil and J. Blythe) Future Work Develop library of operators to support common transformations Semi/Automatic generation of translators (some related work in database integration community, but larger schemas, higher expressivity, inconsistency, etc.) Rewrite rule compiler USC INFORMATION SCIENCES INSTITUTE Loom/PowerLoom Group 38