relating diagrams to logic - search - university of malta

35
Relating Diagrams to Logic John F. Sowa Philosophy and Computers and Systems Science State University of New York at Binghamton Internet: [email protected] Abstract. Although logic is general enough to describe anything that can be implemented on a digital computer, the unreadability of predi- cate calculus makes it unpopular as a design language. Instead, many graphic notations have been developed, each for a narrow range of purposes. Conceptual graphs are a graphic system of logic that is as general as predicate calculus, but they are as readable as the special- purpose diagrams. In fact, many popular diagrams can be viewed as special cases of conceptual graphs: type hierarchies, entity-relationship diagrams, parse trees, dataflow diagrams, flow charts, state-transition diagrams, and Petri nets. This paper shows how such diagrams can be translated to conceptual graphs and thence into other systems of logic, such as the Knowledge Interchange Format (KIF). 1 Representing Logic in Graphs Supreme genus: Generic a~fferentine: Suballern genus: Generic a~fferentiae: Subaltern genne: Generic differen,'~te: Proximate genus: Specific differonaae: Species: In~,idual~: SUBSTANCE material Immaterial ~BODY SPIRIT animate Inanimate UVING MINERAL sensitive insensitive ANIMAL PLANT ratlonal Irrational HUMAN BEAST Plato, Socrates, Aristotle .... Figure 1. Tree of Porphyry

Upload: others

Post on 12-Sep-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Relating diagrams to logic - Search - University of Malta

Relating Diagrams to Logic

John F. Sowa

Philosophy and Computers and Systems Science State University of New York at Binghamton Internet: [email protected]

Abstract. Although logic is general enough to describe anything that can be implemented on a digital computer, the unreadability of predi- cate calculus makes it unpopular as a design language. Instead, many graphic notations have been developed, each for a narrow range of purposes. Conceptual graphs are a graphic system of logic that is as general as predicate calculus, but they are as readable as the special- purpose diagrams. In fact, many popular diagrams can be viewed as special cases of conceptual graphs: type hierarchies, entity-relationship diagrams, parse trees, dataflow diagrams, flow charts, state-transition diagrams, and Petri nets. This paper shows how such diagrams can be translated to conceptual graphs and thence into other systems of logic, such as the Knowledge Interchange Format (KIF).

1 Representing Logic in Graphs

Supreme genus:

Generic a~fferentine:

Suballern genus:

Generic a~fferentiae:

Subaltern genne:

Generic differen,'~te:

Proximate genus:

Specific differonaae:

Species:

In~,idual~:

SUBSTANCE

material Immaterial

~ B O D Y SPIRIT

an imate Inanimate

UVING MINERAL

sensitive insensitive

A N I M A L PLANT

ratlonal Irrational

HUMAN BEAST

Plato, Socrates, Aristotle . . . .

Figure 1. Tree of Porphyry

Page 2: Relating diagrams to logic - Search - University of Malta

Graphic notations have been used for logic since the third century AD, when Porphyry arranged Aristotle's categories in the world's first semantic net. Figure t shows the Tree o f Porphyry, as it was usually drawn by the Scholastic logicians in the middle ages. At the top is the supreme genus or most general category S U B S T A N C E . Beneath that are the differentiae that distinguish the subaltern genera or subcategories: SUBSTANCE with the differentia material is BODY and with the differentiae material, animate, sensitive, and rational is HUMAN. At the bottom are instances of individual humans, such as Plato, Socrates, and Aristotle.

Aristotle's categories with his syllogisms for reasoning about them and Porphyry's tree for illustrating them dominated the field of logic for over two thousand years. Not until the nineteenth century did the new systems of symbolic logic become sufficiently expressive to replace the syllogism. In 1879, Gottlob

Frege developed his Begriffsschrift (concept writing), which was a complete sys- tem of first-order logic. Frege also used a kind of graphic notation, but no one else ever adopted it. Four years later, the philosopher and logician Charles Sanders Peirce independently developed an algebraic notation for logic. With a change of symbols by Giuseppe Peano, Peirce's algebraic notation has become the commonly used modern notation. As an illustration, Figure 2 represents the sentence A cat is on a mat in Frege's original Begriffsschrift, Peirce's algebraic notation, and Peano's version with the symbols ^ instead of �9 and 3 instead of Z. The fourth line shows Peirce's improvement of 1896: his existential graphs, which he continued to develop for the last twenty years of his life.

Frege (1879): , ~ o n ( x , y )

mat(y) cc#(x)

Pelrce (1883): ~x~,y(catx. maty. onxy)

Peono (1895): 3 x ~ y ( c a t ( x ) ^ mat(y) ^ on (x ,y ) )

Peirce (1896): ca t on ,, mat

Figure 2. Representing "A cat is on a mat" in four systems of logic

Although Peirce invented the algebraic notation for logic, he was never satis- fied with it. He always believed that graphs were a more versatile and readable w a y of showing logical relationships. In the last line of Figure 2, the bar between cat and on is called a line o f identity; it represents an existential quantifier 3x. The other line of identity between on and mat represents the quantifier 3y. The words cat and mat represent the predicates cat(x) and mat(y), and on represents

Page 3: Relating diagrams to logic - Search - University of Malta

the predicate on(x,y). Therefore, Peirce's graph maps directly to his algebraic notation. Frege's tree, however, represents a more roundabout paraphrase:

~(Vx)(Vy)(cat(x) m (mat(y) m ~on(x,y))).

This formula corresponds to the sentence It is false that f o r all x and al ly , i f x is a cat then i f y is a ma t then x is not on y. Even graphics cannot make such a cumbersome expression readable.

Figure 3. Existential graph for "If there is a cat, then it is on a mat."

Peirce experimented with graph notations for logic as early as 1882, but his first graphs could not express the scope of quantifiers and negations. His in- vention of 1896 was the ultimate in simplicity: an oval enclosure for showing context. The oval served as a natural delimiter for scope. When marked with appropriate qualifiers, it could represent negation, modality, and other operators, such as knowledge, belief, desire, and purpose. As an example, Figure 3 shows an existential graph for the sentence I f there is a cat, then it is on a mat.

Each oval in Figure 3 represents negation; together, they represent impli- cation, since (p = q) is equivalent to ~(p ^ ~q). When overlaid on the graph at the bottom of Figure 2, they express an if-then sentence in Figure 3. The line of identity for the cat has the scope of both ovals, but the line of identity for the mat is limited to just the inner oval. Therefore, Figure 3 may be translated to the following formula in predicate calculus:

~(3x)(cat(x) ^ ~(:my)(matCy) ^ on(x,y))).

By the operations of logic, this formula could be transformed to the following formula with the implication operator ~:

(Vx)(cat(x) ~ (3y)(mat(y) ^ on(x,y))).

Peirce's graphs, however, are actually much simpler than these formulas. Stu- dents who use the graph logic quickly learn to read a nest of two ovals as if-then and do all their reasoning directly on the graphs without translating them to predicate calculus.

The rules of inference on Peiree's graphs are stated as operations of copying or extending graphs in and out of contexts. A context with no negations or nested inside an even number of negations is said to be positive, and a context nested inside an odd number of negations is said to be negative. To represent Peirce's graphs in a linear form, a context may be enclosed by square brackets as [ ] and a negative context as --[ ]. Following are some examples:

�9 Zero negations: The outermost context is what Peirce called the sheet o f as- sertion. Any graph drawn on the sheet of assertion is in a positive context.

Page 4: Relating diagrams to logic - Search - University of Malta

�9 One negation: Any graph nested in a single oval (or nested inside brackets marked with the -, symbol) is in a negative context. The antecedent or if-part of an implication is also a negative context, since (p = q) is equivalent to -,[p --,[q]].

�9 Two negations: In Peirce's existential graphs, as in o ther systems of classical first-order logic, two negative contexts with nothing between the inner and outer contexts cancel each other out to make a positive context. The conse- quent of an implication is a positive context, since q in -~Lo -"[q]] is nested inside two negations. The two alternatives of a disjunction are also positive, since (p v q) is equivalent to - ' [--' [ p ] - ' [q]].

�9 Three or more negation~ Larger numbers of nested negations can be reduced to combinations of implications and single negations. The nest -~ [p -, [q --[r -'[s]]]], for example, is equivalent to (p ~ (q ^ (r ~ s))).

With this representation, Peirce defined five rules of inference and one axiom that state the conditions for copying or erasing graphs in positive and negative con- texts:

�9 Erasure: Any graph g may be erased in a positive context.

�9 Insertion: Any graph g may be inserted in a negative context.

�9 Iteration: If a graph g occurs in a context c, another copy o f g may be inserted in the same context c or in any context nested in c.

�9 Deiteration: Any graph g that may have been derived by iteration may be erased; i.e. i fg is identical to another graph in the same context or a containing context, g may be erased.

�9 Double negation: Two negations, ~ [ ~ [ ... ]] with nothing between the inner and outer negation, may be drawn around or erased from any set of graphs in any context.

�9 Axiom: The only axiom is the empty set; i.e. a blank sheet of assertion is the starting point for proving any theorem.

To illustrate these rules, consider the traditional rule of modus ponens, which de- rives q from the premises p and ~ ~ q). In Peirce's form, the starting premises would be

P -[~ - [q] ] .

By the rule of deiteration, the nested p may be erased, since it is identical to the outer p:

p -[ ~[q]].

Now there is a double negation with nothing between the inner and outer ne- gations. Therefore, both negative contexts may be erased:

P q. Now both p and q are in a positive context (no negations). Therefore, it is per- missible to erase ? and leave q by itself:

q.

Page 5: Relating diagrams to logic - Search - University of Malta

All other rules of inference for propositional logic can be performed by combina- tions of Peirce's rules. Conversely, Peirce's rules may be used as derived rules of inference for classical logic. For full first-order logic, the same five rules are ap- plied to lines of identity: a line of identity may be erased in a positive context, inserted in a negative context, extended (i.e. iterated) into an inner context from an outer context, or retracted (i.e. deiterated) from an inner context to an outer context; and double negations may cross lines of identity when they are drawn around or erased from any collection of graphs.

Peirce defined these rules in 1896, yet for essentially every theorem in Pr. incipia Mathematica, which was published 14 years later, Peirce's rules give shorte~ and simpler proofs. As an example, following is Proposition 3.47 from Whitehead and Russell (1910), which Leibniz had called the Praeclarum Theorema (Splendid Theorem):

((P = r ) ^ Cq ~ s) ) ~ ( (p ^ q) ~ (r' ^ s ) ) .

In the Principia, the proof of this theorem cites two other propositions, 3.22 and 3.26. The proofs of those two cite other propositions, axioms, and definitions. Altogether, the complete proof has 28 ancillary propositions with a total of 43 inference steps scattered over the first three chapters of the Principia Mathematica. By contrast, the proof of the equivalent graph in Peirce's system starts from an empty sheet of paper and takes only 7 steps. Peirce's rules are actually a generalization of the system of natural deduction by Gentzen (1934), which was published 38 years later.

Fisure 4. Existential graph for the Praeclarum Theorema

Figure 4 shows Proposition 3.47 in Peirce's original notation for existential graphs. In that form, he used an oval to enclose contexts, and the -- symbol was implicit, since negation is the only context modifier needed for first-order logic. For the four implications, each = symbol in the formula corresponds to a pair of ovals in Figure 4. To prove the theorem, it is necessary to derive Figure 4 from the axiom - a blank sheet of paper. Since nothing can be erased from a blank sheet and there are no negative contexts in which anything can be inserted, the only rule of inference that can be applied is to draw a double negation around the

Page 6: Relating diagrams to logic - Search - University of Malta

empty set. In the linear notation with the -~ symbol, that would produce the following graph:

4[ ~[ ] ].

Now there is a negative context in which other graphs may be inserted by the rule of insertion. The first step is to insert the graph ~ [p ," [r]] "-, [q "-, [s]] inside the outer negation. This operation is the equivalent of assuming the premises in na- tural deduction. The result is the following graph:

-[ ~[p ~[r]] ~[q ~[s]] 7 [ ] ] .

Now by iteration, it is possible to copy the graph -'[p -'[r]] into the empty context on the second line:

-,E ~ -~[r]] -,rq -Is1]

This graph is beginning to take a shape that looks similar to Figure 4. To make it identical to Figure 4, it is necessary to get a copy of q i n the context with p on the second line and a copy of s in the context with r. Getting q into the context with p is easy, since it is a negative context (nested 3 levels deep) and q may be inserted by the rule of insertion:

~E ~ q ~Er]2 2 ] . Since the context with r is positive, it is not possible to insert s directly. Instead, the first step is to iterate the graph -,[q ~ [s]] from the first line into the context with r on the second line:

~[-,[p q ~[r ~[q ,[s]] ]2 ] ] . Now by the rule of deiteration, the second q on the second line may be erased because it is identical to the first q on the second line:

",[ -'[p -,[r22 "[q "~[s]] -,[-~[p q ~[r ~ [ - [ s ] ] 22 ] ] .

Finally, the double negation around s on the second line may be erased. After 7 rule applications, the result is the linear representation of the graph in Figure 4:

- [ -[p -,[r]] ~[q "~[s]] ",[ ~[p q ~[r s]] ] 2.

This derivation should be compared to the 43 inference steps with 28 references to other propositions in the Principia Mathematica. Furthermore, all of the steps in Peirce's rules consist of copying and erasing graphs in various contexts. There are no substitutions, no complex transformations, and no need to destroy the structure of nested contexts. In simplicity, elegance, and power, Peirce's system was a distinct improvement over his successors.

Besides using contexts for negation, Peirce attached other modifiers to them for representing modal and intensional operators. As early as 1898, he used his graphs as a metalanguage for talking about graphs. Figure 5 shows a graph from

Page 7: Relating diagrams to logic - Search - University of Malta

his Cambridge Lectures of 1898 (page 151). In explaining that graph, Peirce said "When we wish to assert something about a proposition without asserting the proposition itself, we will enclose it in a lightly drawn oval." In his later work, Peirce developed the metalanguage capabilities in great detail. He even stated all the rules of inference for existential graphs in existential graphs themselves (Roberts 1973). In effect, Peirce defined an interpreter for existential graphs in existential graphs. If he had had a digital computer to work with, he would have had the graphic equivalent of a logic programming system.

much to be wished

Figure 5. Using existential graphs as a metalanguage for lt~|kin,~ about graphs

Peirce called his graph logic "the luckiest find of my career" and believed that it represented "the logic of the future." Many people working with conceptual graphs are convinced that Peirce was right. They have established an interna- tional coalition of developers and theorists who are working to implement and extend Peirce's original vision. Their coalition, called the Peirce Project, has been set up to implement Peirce's logic and apply it to conceptual graphs and related systems, such as feature logic, KL-ONE, and Prolog.

2 Conceptual Graphs

Although Peirce's graphs were more readable than his algebraic notation, they were ignored by mathematicians, who found the algebraic notation more familiar (at least to them). Yet that notation, which has been successfully used in math- ematics, has been a clumsy tool for linguistics and artificial intelligence. Linguists developed trees and graphs, as in Tesni~re's dependency grammar (1959) and Chomsky's transformational grammar (1957). During the 1970s, AI researchers developed semantic networks that were general enough to represent aU of logic. Conceptual graphs are a synthesis of Peirce's existential graphs with Tesni~re's dependency graphs and the semantic networks of AI. Figure 6 shows a conce p- tual graph for the same sentence represented by the formulas in Figure 2.

Figure 6. Conceptual graph for "A, cat is on a mat"

In a conceptual graph, the boxes are called concepts, and the circles are called conceptual relations. The formula operator ~b translates them into predicate cal- culus. It maps the circles to predicates with each arc as one argument of the predicate. It maps the boxes to quantified variables with a monadic predicate to

Page 8: Relating diagrams to logic - Search - University of Malta

designate the type. When applied to Figure 6, @ assigns a variable x to the con- cept [CAT] and a variable y to the concept [MAT]. The default quantifier that governs these variables is the existential 3. The type labels CAT and MAT be- come m0nadic predicates cat(x) and mat(y); and the relation ON becomes a dyadic predicate on(x,y). The arrow pointing towards the circle represents the first argument of the relation, and the arrow pointing away represents the second argument. The result of @ is the following formula:

(3x)(3y)(cat{x) ^ mat(y) ^ on(x,y)).

To save space on the printed page, there is also a linear notation with square brackeis instead of boxes and parentheses instead of circles:

[CAT]§ (ON)§

The graph notation is usually more readable, and the linear notation is easier to type. But both forms are exactly equivalent, and they can be automatically translated to other forms of logic and knowledge representation.

The concept box is normally separated by a colon with the typefield on the left and the referentfieM on the right. With a blank referent field, as in [CAT], the default is an existential quantifier 3. The referent field may also be a name as in [CAT: Yojo], read the cat Yojo. The following table shows other referents and their readings in English:

Kind of referent Example English reading Universal [CAT: ~ every cat Singular [CAT: @ 1 ] exactly one cat Generic set [CAT: {*}] cats Counted set [CAT: {*}@3] three cats Set of individuals [CAT: {Yojo,Tigerlily}] Yojo and Tigerlily List of individuals [CAT: < Yojo,Tigerlily > ] Yojo and then Tigerlily Question [CAT: ~ which cat? Plural question [CAT: {*}?] which cats? Measure [Interval: @ 5see] interval of 5 seconds

Following are four more conceptual graphs that illustrate a universal quantifier, a negation, a disjunction, and an implication:

Every cat is on a mat.

[CAT" V]§247

I t is false that every dog is on a mat.

-,[[DOG." V]§247

Either the cat Yojo is on a mat, or the dog Macula is running. [[CAT: Yojo]§247 Macula]§247

I f a cat is on a mat, then i t is happy. IF: [CAT: *x]-~ (ON)-~ [MAT] THEN: [?x] §247

The relation AGNT in the third graph represents the agent relation that links the act RUN to the actor Macula. In the fourth graph, the ATTR relation links the cat x to the attribute HAPPY. The variable *x for the cat in the IF-context is

Page 9: Relating diagrams to logic - Search - University of Malta

referenced by the concept [?x] in the THEN-context. For any variable, an asterisk indicates the first or defining occurrence of the variable, and the question mark indicates a subsequent reference to the concept node where the variable is defined. The concept [~] is actually an abbreviation for the concept [T: ~], where T is the type label of the most general concept type at the top of the type hierarchy.

Since conceptual graphs are based on Peirce's existential graphs, the only primitive logical operators are the existential quantifier (shown by a blank referent field), conjunction (shown by juxtaposition), and negation (shown by a context box marked with the symbol --~). All other operators are defined in terms of these three primitives. The universal quantifier V in the referent field is defined by expansion to the existential and a nest of two negations. Following is the ex- pansion of the graph for Every cat is on a mat to a form that is equivalent to Peirce's graph in Figure 2:

[CAT: V'I"~ (ON) § 7[ [CAT: *X] "~[ [?x]-)'(ON)+[MAT] ]].

The expanded graph with two nested negations may be read as an implication: I f there is a cat, then it is on a mat. For improved readability, this graph may also be written with the keywords IF and THEN:

IF:' [CAT: *x] THEN: [?x] § (ON)-~ [MAT].

The symbols IF and THEN are actuaUy type labels, defined as subtypes of PROPOSITION with an attached negation. Following is the def'mition of the type label IF; the type label THEN has exactly the same definition.

type IF(x) is -,[PROPOSITION: ?x].

The relation OR is also defined in terms of nested negations:

relation Oa(p,q) is "[PROPOSITION:-,[PROPOSITION: ?p] -,[PROPOSITION: ?q]].

Since this def'mition is completely symmetric, the arrowheads on the arcs of the OR relation are not necessary and may be omitted.

,F:

THEN:

Figure 7. Implication: "If a cat is on a mat, then it is happy."

Figure 7 illustrates the pure graph notation for an implication. Instead of the pair of variables *x and ~ to show references, a dotted line, called a coreference link, is used. Peirce's line of identity combined two functions: it represented an

Page 10: Relating diagrams to logic - Search - University of Malta

10

existentially quantified variable, and it also showed coreference links between different contexts. In conceptual graphs, those two functions are distinguished: the concept nodes are the points where quantification is specified, and the dotted lines (or variables) show coreference. The rules of inference for conceptual graphs are identical to Peirce's rules, except for a change of notation and terminology. Other common proof procedures may also be applied to conceptual graphs, since they can be defined in terms of Peirce's rules.

All of the operations on conceptual graphs are based on combinations of four rules, caUed the canonical f o rma t ion rules (Sown 1984). If u and v are any con- ceptual graphs (possibly the same graph), a conceptual graph w may be canonically derived from them by an application of one or more of the following rules:

* Copy. w is an exact copy of u.

�9 Restrict . Let c be a concept of u that is not nested inside any context and with a referent that is either a constant or an existential quantifier. Then w is u with c restricted either by type or by referent: restriction by type replaces the type label of c with some subtype; and restriction by referent replaces an existential quantifier with a constant.

�9 Join. Let c be a concept of u and d a concept of v, where neither c nor d is nested inside a context and both c and d have identical type and referent fields. Then w is the graph obtained by deleting d and ~ankkng to c all arcs of conceptual relations that had been linked to d.

* Simplify. w is u where one of a pair of duplicate conceptual relations in u has been deleted. Two conceptual relations r and s in the graph u are said to be duplicates i f they are of exactly the same type, and for each i, the i-th arc of r is attached to the same concept as the bth arc of s.

These four rules are central to every conceptual graph system. They are used in theorem proving, natural language processing, and database retrieval. Any graph derived by them is a specialization of the graphs from which it was derived: if a graph v is canonically derived from the graphs {ul ..... u,}, then v logically implies every one of the u's. Therefore, these rules form the basis for defining a gener- alization hierarchy over conceptual graphs (Sown 1984). Figure 8 shows a sample generalization hierarchy; for each dark arrow, the graph above is a generalization, and the graph below is a specialization.

In Figure 8, the top graph says that an animate being is the agent (AGNT) of some act that has an entity as patient (PTNT) of the act. Below it are two specializations: a graph for a robot washing a truck, and a graph for an animal chasing an entity. Both of these graphs were derived from the top graph by re- peated applications of the rule for restricting type labels to subtypes. The graph for an animal chasing an entity has three subgraphs: a human chasing a human, a cat chasing a mouse, and the dog Macula chasing a Chevrolet. These three graphs were also derived by repeated application of the rule of restriction. The derivation from [ANIMAL] to [DOG: Macula] required both a restriction by type from ANIMAL to DOG and a restriction by referent from an existential quanti- fier to the name Macula.

Page 11: Relating diagrams to logic - Search - University of Malta

11

.j-J

CAI:

Figure 8. A generalization hierarchy of conceptual graphs

Besides restriction, a join was used to specialize the graph for a human chasing a human to the graph for a senator chasing a secretary around a desk. The join was performed by merging the concept [CHASE] in upper graph with the concept [CHASE] in the following graph:

[CHASE] + (ARND)+ [DESK].

The two graphs at the bottom of Figure 8 were derived by both restriction and join. The graph on the left says that the cat Yojo is vigorously chasing a brown mouse. It was derived by restricting [CAT] to [CAT: Yojo] and by joining the foUowing two graphs:

[C HAS E] § (MANR) + IV I GOROUS]. [MOUSE]§ (ATTR)+ [BROWN].

In these two graphs, the relation (MANR) represents manner, and the relation (ATTR) represents attribute. The bottom right graph of Figure 8 says that the cat Tigerlily is chasing a gray mouse. It was derived from the graph above it by one restriction and one join.

Since the four formation rules are heavily used in every conceptual graph sys- tem, they are usually implemented in highly optimized code. Levinson and Ellis 0992) took advantage of these rules and the hierarchy they define to develop highly efficient algorithms for graph searching and retrieval. These algorithms are fast enough to be used in a general database system built around conceptual

Page 12: Relating diagrams to logic - Search - University of Malta

12

graphs. For other papers on the research and applications of conceptual graphs, see the book edited by Nagle et al. (1992).

3 Mapping Conceptual Graphs to KIF

Because of their generality and readability, conceptual graphs have been proposed as the initial normative language for conceptual schemas by the ANSI X3H4 Committee on Information Resource Dictionary Systems (Perez & Sarris, 1993). They are also being developed as a semantically equivalent graphic representation for the Knowledge Interchange Format (KIF) of the ARPA-sponsored Know- ledge Sharing Effort (Genesereth & Fikes, 1992). Conceptual graphs were de- signed to have a direct mapping to and from natural languages; their graphic notation was designed for human readability. KIF had somewhat different design goals: it was designed for ease of mapping to and from computer systems; human readability, although desirable, was a secondary consideration. Following is the KIF form of the sentence A cat is on a mat:

(exists (?x ?y) (and (cat ?x) (mat ?y) (on ?x ?y)))

KIF uses a LISP-like notation with the function or operator symbol at the be- ginning of a parenthesized list, followed by a string of operands; variables are prefixed with a question mark, as ~ and ~. Symbols like 3, V, and ^, which are not available in most character sets, are representcd by strings like exists, foralI, and and. Although the basic form of KIF is an untypcd version of logic, KIF also permits the prcdicates that specify types to be written after the corresponding variables in the quantifier list. In typed notation, the KIF statement becomes '

(exists ((?x cat) (?y mat)) (on ?x ?y))

The typed form is slightly shorter than the untyped form, and it maps more di- rectly to and from conceptual graphs and other versions of typed or sorted logic. As examples, following are four conceptual graphs discussed in Section 2 and their translations into KIF:

[CAT: V]§247 (forall (?x cat) (exists (?y mat) (on ?x ?y))) -[[DOG: V]§247 (not (forall (?x dog) (exists (?y mat) (on ?x ?y)))) [[CAT: Yojo]§247 Macula]§247 (or (exists (?x mat) (and (cat Yojo) (on Yojo ?x)))

(exists (?y run) (and (dog Macula) (agnt ?y Macula)))) IF: [CAT: *x]§247 THEN: [?x]§247 [HAPPY]. (forall ((?x cat) (?y mat))

(=> (on ?x ?y) (exists (?z happy) (attr ?x ?z))))

Note how the variables in conceptual graphs are translated to KIF:

*x in a conceptual graph indicates the defining node for a variable, which corresponds to ?x in the KIF quantifier list for the variable.

Page 13: Relating diagrams to logic - Search - University of Malta

13

in a conceptual graph indicates a reference to a node defined by *x. It corresponds to a use of ~ in KIF in a position other than a quantifier list.

In KIF, the scope of quantifiers is shown by nested parentheses. In conceptual graphs, the scope may be shown either by nested context boxes or by precedence relations between quantifiers. The universal quantifier u for example, usually has precedence over existential quantifiers in the same context; that precedence can be overruled by explicit context boxes or brackets. Extra contexts may also be needed to limit the scope of negations. The sentence S o m e dog is not on a mat would be represented by the following conceptual graph and KIF statement:

[DOG: *xl ~[[?x]+(ON)'-)"[MAT]]. (exists (?x dog) (not (exists (?y mat) (on ?x ?y))))

This graph and formula may also be read There exists a dog, which is not on a mat. A subordinate clause in English behaves like the CG brackets or the KIF parentheses in limiting the scope of quantifiers and negations.

Both conceptual graphs and KIF are essentially first-order languages that in- clude metalanguage facilities. For conceptual graphs, the metalanguage facilities follow Peirce's use of contexts to enclose graphs about which something is being said. As an example, the following conceptual graph corresponds to Peirce's existential graph in Figure 5:

[WISH] + (PTNT) + [S I TUATION" [PERSON: #you]- - - [GI RL l'-~ (ATTR)"~ [GOOD] I .

This graph may be read It is wished that you are a good girl. T h e concept [WISH] is linked by the patient relation (PTNT) to the situation that is wished. Since the person who wishes that situation is not mentioned, the English translation is an impersonal form It is wished that .... Inside the situation box is a nested graph that describes the situation; it says that the person #you is coreferent (dotted line) with a girl that has attribute (ATTR) good.

The conceptual graph for the wishing has two features that must be expanded before they can be translated to KIF. The fLrst is the indexical referent #you, which is neither a constant nor a quantified variable. Instead, it is a context- dependent reference to some person who is being addressed by the speaker. Be- fore the graph can be translated to KIF, the symbol #you must be replaced by a name or other identifier of that person. If the speaker were talking to a girl named Sally, then the referent #you would be replaced by the name Sally. The second step is to expand the concept [SITUATION] to a form that explicitly says that the situation is described by a proposition stated by the nested graph:

[WISH l § (PTNT) § [SI TUATI ON] - (DSCR)§ [PERSON: Sal ly] - - -[GIRL]§247 I .

Literally, this graph says It is wished that there exist a situation described by the proposition that Sally is a good gir l Since this graph is too long to be written on one line, the hyphen at the end of the first line indicates that the relations at- tached to the concept [SITUATION] are continued on subsequent lines. The description relation (DSCR) links the situation to a proposition that describes it; that proposition is stated by the nested conceptual graph, which now explicitly mentions the person Sally instead of the context-dependent #you. In this form, the conceptual graph can be translated directly to KIF:

Page 14: Relating diagrams to logic - Search - University of Malta

14

(exists ((?x wish) (?y situation)) (dscr ?y '(exists ((?z girl) (?w good))

(and (person Sally) (= Sally ?z) (attr ?z ?w) )))) This KIF expression says that there e~sts an x of type wish and a y of type situ- ation, where y is described by a quoted expression. Then the quoted expression says that there exists a girl z and an instance of goodness w, where Sally is a person, Sally is equal to the girl z, and z has the attribute of goodness w.

As this example illustrates, Peirce's enclosed existential graphs correspond to nested conceptual graphs, which correspond to quoted expressions in KIF. These mechanisms of EGs, CGs, and KIF provide a metalanguage capability that ena- bles those languages to talk about expressions in the languages. By means of the metatanguage, it is possible to extend the languages by defining new kinds of op- erators and the axioms that relate them. This mechanism allows various modal and higher-order features to be introduced into the languages without going be- yond a first-order style of model theory and reasoning. The full details of this technique are beyond the scope of this paper, but some examples will be given in subsequent sections.

4 Representing Trees

Since trees are a specialized kind of graph, tree notations can be mapped directly to conceptual graphs. Yet the tree notations used in computer science are typi- cally used for highly specialized purposes and leave many details implicit that would be made explicit in a conceptual graph. As an example, Figure 9 shows two common kinds of trees: a type hierarchy and a parse tree.

ENTITY

/ 1 \ PLANT MINE|AL ANIJ~. / \

U|IIT IANGAIIO0 DOG

ASS~g~ql)Cr / \ VlltlMli OP[IATOI [XI~L~SlON

VUI~.i O ~ l t VJ~UUIL[

' T 4. ~m

Figure 9. A type hierarchy and a parse tree

The two trees in Figure 9 have the same shape, but their arcs have very dif- ferent meaning. In the type hierarchy on the left, each arc represents a subtype relation: plant, mineral, and animal are subtypes of entity; rabbit, kangaroo, and dog are subtypes of animal. In the parse tree on the right, each arc represents the part-of relation: a variable, :-- operator, and expression are parts of an assign- ment statement; and a variable, + operator, and variable are parts of an ex- pression. Another important difference between the two trees is the question of whether the branches are ordered or unordered. The type hierarchy is unordered: it makes no difference whether the subtrees are listed in the order plant, mineral,

Page 15: Relating diagrams to logic - Search - University of Malta

15

animal or animal, mineral, plant. The parse tree, however, has a strict ordering: moving the branches around would create a very different, probably ungram- matical statement.

Another difference between the two trees is the distinction between instances and types. The parse tree relates instances: " + " is an instance of an operator, which is part of the expression "A + B"; that instance of an expression is part of an assignment statement "X:---A + B." Every level of the parse tree says that the instances below are parts of the current instance, which in turn is part of the larger instance above. The type hierarchy, however, relates types of instances: the arq that shows plant as a subtype of entity is a metalevel statement that in- eludes vast numbers of instances of plants within its scope. Logic can be used at either the instance level or the type level. Following are six pairs of formulas in logic that correspond to each of the six arcs in the type hierarchy:

plant < entity. (Vx) {plant(x) = entity(x)). mineral r entity. {u ~ entity{x)). animal < entity. {Vx) {animal{x) ~ entity{x)). rabbit < animal. {Vx) (rabbit{x) = animal {x)). kangaroo < animal. {Vx)(kangaroo{x) ) animal{x)). dog 4 animal. {Vx) (dog{x) = animal{x)).

Each formula on the left is a metalevel statement about types and subtypes; the corresponding formula on the right is a statement about instances of those types. The operator < is used here to represent the subtype relation: the type plant is a subtype of the type entity. The formula on the fight relates the instances: for every x, if x is an instance of plant, then x is an instance of entity. For each of these formulas in predicate calculus notation, there is an exactly equivalent statement in CGs and KIF:

[Type: entity]+{SUBT)+[Type: plant]. [Plant: V*x] [Entity: ?x]. {subtype entity plant) {forall {?x plant) {entity ?x))

Figure 10. Type hierarchy of Figure 9 drawn as a conceptual graph

Figure 10 shows the six conceptual graphs for the metalevel arranged in a tree that has exactly the same shape as Figure 9, but with more detail. As this ex-

Page 16: Relating diagrams to logic - Search - University of Malta

16

ample illustrates, tree diagrams can be mapped in a one-to-one fashion into con- ceptual graphs. But since conceptual graphs are a general-purpose notation, they usually have more detail than the special-purpose trees that leave many details implicit. If the detail is not important or is well understood, there is no reason to show it explicitly. People who are used to seeing type hierarchies in the form of Figure 9 can continue to draw them in that style as iong as they like. For a computer, however, no detail is implicitly "understood," and conceptual graphs provide a convenient way of showing the details explicitly. A graphic facility could offer users the option of seeing the details as in Figure I0 or suppressing them as in Figure 9.

Figure 11 shows the parse tree represented as a conceptual graph. Instead of the SUBT relation to link levels, it uses the PART relation to show that each lower constituent is a part of the one above. To show the ordering, each node except the top is linked by the NEXT relation to a sibling node on the right. The referent fields of each concept node are filled with the representation of the cor- responding instance: the concept [Assignment: "X: = A + B"] shows that the com- plete assignment statement is represented by the string "X: = A + B " . The parse tree could also be drawn with the referent fields left blank; in that case, the con- cept [Assignment] would say that there exists an instance of an assignment, but it would leave the exact representation implicit.

] AH~NMWT: "~.A+r [

Figure 11. A parse tree expressed as a conceptual graph

The grammar rules that are used to derive a parse tree are usually stated in a linear notation, such as Backus-Naur form:

Assignment : := Var iable " :=" Expression

This grammar rule could also be expressed as a conceptual graph. Figure 12 says that every assignment has three parts: a variable, next an operator " : - -" , and next an expression. Figures 11 and 12 show the intimate relationship between grammar rules and parse trees: each grammar rule is a little triangle that can be joined with other grammar rules to build a parse tree. The rules of logic that al- low the universal quantifier V to be instantiated with particular instances deter- mine the constraints on the way the triangles are assembled.

Page 17: Relating diagrams to logic - Search - University of Malta

17

I ASSIGNMENT- v I

=,, .s ,0, I

Figure 12. A grammar rule expressed as a conceptual graph

Figure 12 can also be translated to other systems of logic, such as KIF:

(forall (?x assignment) (exists ((?y variable) (?z operator) (?w expression))

(and (part ?x ?y) (part ?x ?z) (part ?x ?w) (next ?y ?z) (next ?z ?w) (repr ?y ':=) )))

Although the KIF form is semantically equivalent to the conceptual graph, its structure does not illustrate the close correspondence between the parse tree and the grammar rule.

As these examples illustrate, tree diagrams can be mapped in a one-to-one fashion into conceptual graphs. But since conceptual graphs are a general- purpose notation, they usually have more detail than the special-purpose trees that leave many details implicit. If the detail is not important or is well under- stood, there is no reason to show it explicitly. People who are used to seeing type hierarchies and parse trees like Figure 5 can continue to draw them in that style as long as they like. But conceptual graphs subsume those special-purpose no- tations and embed them in a more general framework of logic. In effect, concep- tual graphs unify such notations by forming a bridge between each of them and all the rest of logic. A computer system could use conceptual graphs internally to represent the full detail and allow display options for omitting detail that is not of interest for a particular application.

5 Representing Entity-Relationship Diagrams

Design languages, such as entity-relationship diagrams (Chen 1976), are usually metalanguages that talk about entity types rather than instances. The metalevel tends to be good for representing generalizations in a succinct way: whenever the same principle or constraint can be stated at either the metalevel or the instance level, the metastatement is usually shorter and more readable. Yet some kinds of constraints can only be expressed at the instance level. Those constraints can be expressed in ordinary fLrst-order logic, which talks about instances and quan- tifies over them with the V and 3 quantifiers. Unlike E-P. diagrams, conceptual graphs and KIF have a foundation in first-order logic. That means that they are primarily designed to talk about instances; yet both of them can also be used to talk about instances of types. When used in that way, they become

Page 18: Relating diagrams to logic - Search - University of Malta

18

metalanguages that can express anything expressible in the specialized design languages.

As an example, Figure 13 shows an E-R diagram for part of a university da- tabase. The four boxes represent the entity types for departments, courses, sections, and students. The four diamonds represent relations between those types: Offers is a l-to-n relation between departments and courses; Has is a l-to-n relation between courses and sections; Enrolls is an n-to-m relation between students and sections; and Major is an n-to-1 relation between students and de- partments. The pairs of numbers like 1-to-n or n-to-m are called participation counts. They express a constraint on the number of tuples in a relational database that stores that relation.

~ DEPARTMENT

I=~ ECTION

Figure 13. Entity-Relationship diagram for a university database

Although E-K diagrams like Figure 13 are good for expressing constraints on one relation at a time, they cannot represent constraints that involve two or more relations. The following constraint cannot be expressed in an E-R diagram be- cause it involves both the Enrolls and Has relations:

No student may be enrolled in two or more sections o f the same course.

Sometimes such constraints may be represented by redesigning the E-R schema: The two dyadic relations Enrolls and Has might be combined in a single triadic relation linking the entity types Student, Section, and Course. But it is usually inconvenient and sometimes impossible to redesign the database when a new constraint is added 3r changed. In full first-order logic, any constraint can be stated without redesigning the relations.

Entity-relationship diagrams are another special-purpose notation that can be embedded in a more general framework of logic. The diamonds in an E-R dia- gram represent constraints on the relations between entity types. The circles in a conceptual graph represent particular instances of relations. Figure 14 shows a diamond taken from Figure 13, which states a constraint on the Has relation be- tween the entity types Course and Section. The circles below the diamond show instances of the Has relation between particular courses and sections.

Page 19: Relating diagrams to logic - Search - University of Malta

19

Type Constraint:

Instances:

Figure 14. E-R type constraint and CG instances

In effect, the diamond represents the relation as a whole, and the circles rep- resent individual tuples in that relation. Whereas the diamond shows that Has is a 1-to-n relation between courses and sections, the circles show that course Calculus I has two sections M1A and M1B, course Calculus II has two sections M2A and M2B, and course Topology has one section M37. This example illus- trates the point that E-R, diagrams are essentially a metalanguage for talking about types, and conceptual graphs are a language for talking about instances. But the metalanguage capabilities of conceptual graphs and KIF allow them to represent the same information as an E-R, diagram in an exactly equivalent way.

Figure 15 shows the E-R. diagram in Figure 13 translated to a conceptual graph at the metalevel. Each diamond node becomes a concept of type R,elation; each entity node becomes a concept of type Type; and the participation counts on the arcs become concepts of type Participation, whose referent is a list of the participation counts on the arcs of the corresponding relation. As an example, consider the concept [R,elation: offers] in the upper right of Figure 15: its first argument (ARG1) must be of type department; its second argument (AR,G2) must be of type course; and it has a characteristic (CHR,C) participation count < 1,n >. Figure 15 thus captures all the information in Figure 13. As with type hierarchies, the E-R` diagram is simpler than the conceptual graph, since it is a more specialized notation. But as before, the conceptual graph may be considered the underlying representation, which could be displayed in the form of Figure 13 for users who are familiar with E-R notation. For interchange with other sys- tems, it could also be translated to KIF or other languages.

Page 20: Relating diagrams to logic - Search - University of Malta

20

I '~176176176176 "~ I I ' ~ 1 7 6 ","- I

[ Type:studenl [ [ Tu [

, , , . . - o , , o ~ , . , - o ~ i

Figure 15. E-R diagram of Figure 13 translated to a metalevel conceptual graph

Although metalevel conceptual graphs tend to be bulkier than the equivalent E-R diagrams, conceptual graphs can express instance-level constraints that E-R diagrams cannot represent. Figure 16, for example, shows the constraint that no student may be enrolled in two different sections of the same course.

J Figure 16. A constraint represented by an instance-level conceptual graph

The context box around Figure 16 is marked by the -~ symbol for negation. Each of the four concept boxes inside has an implicit existential quantifier. Figure 16 therefore represents the sentence I t is fa lse that there ex i s t s a student x , enrolled

Page 21: Relating diagrams to logic - Search - University of Malta

21

in two different sections y and z o f the course w. The conceptual graph could also be translated to the following statement in KIF:

(not (exists ((student ?x) (section ?y) (section ?z) (course ?w)) (and (enr ?x ?y) (enr ?x ?z) (/= ?y ?z) (has ?w ?y) (has ?w ?z)) ))

For every constraint, there is a corresponding query that asks whether there exists anything that violates the constraint. Figure 17 shows the query graph for the question that asks whether any student is violating the constraint in Figure 16: Which student is enrolled in two different sections o f the same course? The query graph in Figure 17 has the same shape as the constraint graph in Figure 16, but without the surrounding negation. / SEC.ON

Figure 17. A database query represented as a conceptual graph

The question mark in the concept [STUDENT: 9.] of Figure 17 is what char- acterizes that graph as a query. When used by itself, as in Figure 17, the question mark asks the question Which student?. When used with a variable name, as in ~ , the question mark indicates a reference to some other node marked *x. These two uses of the ? symbol correspond to the two uses of the word which in English: ? by itself corresponds to the interrogative which for asking questions; and ? with a variable corresponds to the relative pronoun which used to make a reference to something else in the sentence. In the query language SQL, the question mark maps to the SELECT verb that designates which field in the database contains the answer. The query graph in Figure 17 could be translated to the following SQL statement:

SELECT FROM WHERE AND AND AND AND

Besides graphs can Figure 17.

STUDENT.A ENR.A, ENR.B, HAS.C, HAS.D STUDENT.A = STUDENT.B SECTION.A -= SECTION.B SECTION.A = SECTION.C SECTION.B = SECTION.D COURSE.C = COURSE.D

representing E-R diagrams, constraints, and queries, conceptual also represent the answers to queries. Figure 18 answers the query in It expresses the sentence The student Tom Brown is enrolled in sections

Page 22: Relating diagrams to logic - Search - University of Malta

22

MIA and M1B of the course Calculus L Tom is therefore the culprit who violated the constraint expressed in Figure 16.

( I

SkrC11ON: MIA

MS, IN ON:

COURSE: Calculus I ]

J Figure 18. A constraint violation in answer to the query

As these examples illustrate, logic in the form of either conceptual graphs or KIF can do everything that E-R diagrams can do plus a lot more: it can express arbitrary constraints, queries, and even the answers to queries. But besides making statements, logic has associated inference rules that can carry out com- putations. In fact, any computation that can be performed by any digital com- puter can be simulated by logical inferences. That includes translations, function evaluation, and execution of arbitrary procedures, either in serial or parallel fashion.

6 Mapping the Metalevel to the Instance Level

Conceptual graphs and KIF can express statements at both the metalevel and the instance level, and they can also express rules for translating from one level to the other. As an example, consider the following metalevel and instance-level graphs for saying that the type entity has a subtype plant:

[Type: entity]§247 plant]. [Plant: V*x] [Entity: ?x]. In order to translate from the metalevel to the instance level, there must be a rule whose IF-clause matches the graph on the left and whose THEN-clause produces the graph on the right. Following is such a rule:

IF: [Type: *tl]§247 *t2] THEN: [~t2: V*xl [~t1: ?x].

When this rule is applied, the variable *tl matches "entity," and *t2 matches "plant." Then the operator �9 translates the names from the referent field to type labels in the type field. The result generated from the THEN-clause is a graph that says every instance *x of plant is also an instance ~ of entity.

Page 23: Relating diagrams to logic - Search - University of Malta

23

IF:

I THEN:

Figure 19. Rule for translating from the metalevel to the instance level

For translating E-K diagrams to conceptual graphs, the first step is to trans- late a diagram such as Figure 13 into a metalevel graph such as Figure 15. Then IF -THEN rules in the CG form can generate instance-level constraints from Fig- ure 15. Figure 19 shows an IF -THEN rule for translating me~.astatLnnents about 1-to-n relations between types. The IF-part of this rule matches either the Offers relation or the Has relation of Figure 15. When matched to the Offers relation, the variable *tl matches "department", *t2 matches "course," and *r matches "offers." As a conclusion, the rule in Figure 19 generates the following two graphs at the instance level:

[Department: V]§247 {*}].

[Course: V]§247 @i]. The In'st graph says that every department offers a set of courses, and the second one says that every course is offered by exactly one department. Note the p op- erator in the THEN-context of Figure 19; it translates names of relations to re- lation labels just as T translates names of types to type labels. The z and P operators perform the following services:

�9 When the variables *tl and *t2 match the names of types, such as "depart- ment" and "course," the operator �9 translates them to the corresponding type labels "Department" and "Course."

�9 When the variable *r matches the name of a relation, such as "offers," the operator p translates it to the corresponding relational label "Offers."

The operators x and p are the only special features needed to relate metalevel conceptual graphs to instance-level graphs. The syntax and inference rules for existential graphs, conceptual graphs, and KIF are the same at both the metalevel and the instance level.

Page 24: Relating diagrams to logic - Search - University of Malta

24

IF: [ Relatlon: "r ~ Transltlve I

THEN: THEN:

Figure 20. Generating an instance-level axiom for transitive relations

The rules for translating the metalevel to the instance level can take account of a n y kinds of attributes of types or relations. Figure 20 shows a rule for gen- erating instance-level axioms for transitive relations. FoUowing is a graph, which says that the greater-than relation has the attribute transitive:

[Rel ati on: greater-than] § (ATTR)§ [Transitive]. "

This graph matches the outer IF-context of Figure 20. The conclusion is the fol- lowing IF -THEN rule, which is an instance-level axiom for the greater-than re- lation:

IF: [*x] § (Greater-than)-~ [*y] § (Greater-than) § [*z] THEN: [?x]-*(Greater-than)§ [?z].

This rule says I f x is greater than y and y is greater than z, then x is greater than z. But there is no reason why the operator p must map a lower-case name into an upper-case label. It could just as well map the name "greater-than" into a relation label represented by the symbol >. With that label, the conclusion would be the following rule:

IF: [ *x ]§ [*y]§ (>)§ F'z] THEN: [?x]§247

This example suggests a question that is often discussed in AI and database theory: Should relations have attributes? Before answering that question, con- sider the following three sentences in English:

1. The relation greater-than is transitive.

2. Five is greater than three.

3. I f x is greater than y and y is greater than z, then x is greater than z.

The fin'st sentence is a metastatement about the relation greater-than. The second sentence is an instance-level statement that uses the relation greater-than to say something about the particular numbers 5 and 3. And the third sentence is an

Page 25: Relating diagrams to logic - Search - University of Malta

25

instance-level statement that expresses a general axiom or constraint about the way that the greater-than relation may be used. These sentences illustrate the point that any statement about attributes of types and relations is a metastatement. Any statement that uses the types and relations to talk about other things is an instance-level statement. English, conceptual graphs, and KIF all permit metastatements about the attributes of types and relations. But at the instance level, those attributes map into axioms that state constraints on how the types and relations may be used. Although English, CGs, and KIF permit metalevel and instance-level assertions in separate clauses of the same statement, none of them permit metalevel and instance-level assertions about the same thing af the same time.

7 Functions and Procedures

Functional programs, which do not have side effects, are the easiest to represent in conceptual graphs, KIF, or any other system of logic. By def'mition, a function is a relation that has one argument called the output, which has a single value for each combination of values of the other arguments, called the inputs. In concep- tual graphs, the output concept of a function is attached to its last arc, whose arrow points away from the circle. If F is a function from type T1 to type T2, the constraint of a single output for each input can be stated by the following con- ceptual graph:

IT1: V]+(F)§ @1]. This graph says that for every input of type T1, F has exactly one output of type T2. Combinations of functions form dataflow diagrams, as in Figure 21.

Numben ?a ~ Number

I Numben ?b ~ f ' Numben *x ]

Figure 21. A dataflow diagram written as a conceptual graph

The variables ?a, 7b, and ?c are inputs that refer to concept nodes on other graphs. The output variable *x marks a defining node that could be referenced elsewhere by ~ . The functions (+) and (*) each take two numbers as input and generate one number as output. The function (CS2N) converts a character string input to a number as output. Figure 21 could be mapped to the following state- ment in KIF:

(* (+ ?a ?b) (cs2n ?c)-?x) In a more conventional programming language like Pascal, Figure 21 or its KIF equivalent would correspond to an assignment statement:

X := (a + b) * csen(c);

Page 26: Relating diagrams to logic - Search - University of Malta

26

Conceptual graphs were designed to represent natural language, but they can also represent arithmetic in a readable fashion - although not quite as concisely as KIF, Pascal, or APL.

Although any dataflow graph can be mapped to an assignment statement, not every assignment statement can be mapped to a dataflow graph. In particular, no assignment that changes the value of a variable is permitted. The following assignment cannot be mapped to a dataflow graph, since it changes the value of a variable that was already defined elsewhere:

X := X + 1;

Functional languages, which prohibit such assignments, are therefore called single assignment languages. Variables in those languages are not truly variable, since their values can never be modified after their first assignment.

funct ion Facto (n ,x ) is

[ Integer: 2 ~,,~,f...

. Integer: ?x [

Figure 22. Defining a recursive function with a conceptual graph

Dataflow diagrams by themselves are not sufficient for a complete computa- tional system. But when combined with a conditional function and the ability to def'me recursive functions, they form the basis for a complete language that can compute any function that is computable by a Turing machine. Figure 22 shows a conceptual graph for defining the function facto, which computes the factorial x of a nonnegative integer n. It could be translated to the following function de- fruition in KIF:

(deffunct~on facto (?n integer) := (cond ((> 2 ?n) 1)

(true (* ?n (facto (1- ?n)))) ))

In Figure 22, both variables ?n and .gx are marked with ? rather than * because the def'ming occurrences are in the top line that specifies the name of the function and its input and output variables. The relation (I-) corresponds to the KIF function I-, which subtracts I from its input. The relation (COND) corresponds to the conditional in KIF: its first argument is a Boolean value; if true, the output of COND is equal to the second argument; otherwise, the output of COND is equal to the third argument. The features illustrated in Figures 21 and 22 contain

Page 27: Relating diagrams to logic - Search - University of Malta

27

all the structure needed for a language that can specify any computable function. The inference rules of logic make such specifications executable, and a compiler can translate them into more conventional programming languages.

Although functional languages are complete in the sense that they can com- pute any computable function, they cannot be used to show time dependencies or to enforce a particular order of execution. That property makes them desirable for parallel hardware, since such dependencies can make parallel execution diffi- cult or impossible to achieve. But for many purposes, time dependencies are sig- nificant and must be represented explicitly. Procedural languages are good for such specifications, and Figure 23 shows three graphic notations for representing procedures: a flow chart, a finite-state machine, and a Petri net.

<

I I Flow Chart

Q Finite-State Machine

b -

( ,c

f - - - -

() Petrl Net

Figure 23. Three graphic notations for specifying procedures

Flow charts, illustrated on the left of Figure 23, were invented by John von Neumann to specify programs for his early stored-program computers. The boxes represent computational events, and the diamonds represent decisions where the flow of execution can take an alternative path. In the finite-state machine, the circles represent possible states in a computation. The arcs mark the transitions from one state to the next, but the events that cause the state changes are not shown explicitly. The Petri net on the right is a merger of the flow chart and the l'mite-state machine: the circles correspond to the states of a f'mite-state machine, and the bars correspond to the events of a flow chart. The state p is the precon- dition of the event a, and the state q is the postcondition of a and the precondition of the next event b. The decision c in the flow chart represents a condition that may be true or false of the state r in the finite-state machine or the Petri net. If the condition c is true in state r, the successor event is d; if c is false, the successor event is f . Any of the three diagrams in Figure 23 could be mapped to a concep- tual graph. But since the Petri net is the most general, a representation for Petri nets would subsume the other two.

Figure 24 shows the In, st two states and event of the Petri net and their rep- resentation as a conceptual graph. The starting state p is described by a concept of type STATE, which contains a nested conceptual graph that describes p. The

Page 28: Relating diagrams to logic - Search - University of Malta

28

successor relation (SUCC) links that state to a concept of type EVENT, which contains another nested conceptual graph that describes the event a. Another successor relation links the event a to the state q, which contains a nested con- ceptual graph that describes q. In a general Petri net, an event may have multiple predecessor or successor states. In the corresponding conceptual graph, the event concepts would also have multiple predecessor or successor states linked to the events by relations of type SUCC.

G

Q I

Figure 24. Mapping a Petri net to a conceptual graph

A conceptual graph that describes a Petri net can be translated directly to a statement in KIF. For each state or event concept that contains a nested con- ceptual graph, the corresponding KIF statement would describe the state or event by a KIF statement that was derived from the nested conceptual graph. The graph in Figure 24 would map to a statement of the following form in KIF:

(exists ((?p state) (?a event) (?q state)) (and (riser ?p @)

(succ ?p ?a) (dscr ?a ~) (succ ?a ?q) (dscr ?q X)))

In this KIF statement, the Greek letters ~b, ~, and X are abbreviations of the nested KIF statements that would be derived by translating the corresponding nested conceptual graphs in Figure 24. The two succ relations in the KIF state- ment are direct translations of the SUCC relations in the graph. The dscr re- lations represent the use of nested conceptual graphs as descriptions of the states and events: (dscr ?p r says that the state p is described by the KIF statement r which would be translated from the nested conceptual graph that describes the the state p. Similarly, ~ would be a translation of the nested CG for the event a, and X would be a translation of the nested CG for the state q.

The conceptual graph in Figure 24 is not a procedure, but a history of the execution of some process. Instead of specifying a procedure that may be exe- cuted many times, the states and events of the graph all have implicit existential quantifiers that indicate that they existed at some point in history. To distinguish

Page 29: Relating diagrams to logic - Search - University of Malta

29

processes, procedures, and histories in a logical description, several distinctions must be observed:

* A process is an evolving sequence of states and events, in which one of the states or events is marked as current at a context-dependent time called #now.

�9 A procedure is a generic pattern of states and events that determines the pos- sible evolution of an entire family of processes. Each process in the family is considered a separate activation of the procedure.

�9 A history is a record of the sequence of states and events that existed in the evolution of some process. Each state and event of a history may be marked with a t ime stamp that records its duration or point in time.

r

r

~ 11ME: 20~3:19 GMT [

Procedure Process History

Figure 25. Representing a procedure, a process, and a history

Figure 25 shows three conceptual graphs that represent a procedure, a process, and a history. In the procedure on the left, the first state is marked with a uni- versal quantifier V. It implies that every state of that description is followed by an event of the kind described in the next concept box, which is followed by an- other state of the kind described in the third concept box. The graph in the middle shows a process. It has the same structure as the procedure, but its first state has an attached relation (PTIM), which indicates that the state exists at the point in time #now. The graph on the tight is a history in which the first and third boxes have attached relations (DUR) to indicate their duration; and the event in the middle has an attached relation (PTIM) to indicate the point in time when it occurred.

The examples in Figures 18 and 25 show that logic in either the CG or KIF notations can describe procedures, processes, and histories. But logic is much more than notation. It also includes rules of inference that can transform the notation to execute the procedures, simulate the processes, and generate records of the histories. The f ir ing rules that determine when the events in a Petri net are executed can be stated as axioms at the KIF or CG metalevel. Then the proof techniques of logic could use those axioms to determine how the privileged time #now would move from one state to another during the evolution of a process. The trace of that proof would be a history of the process. Thus, the proof tech-

Page 30: Relating diagrams to logic - Search - University of Malta

30

niques of logic could execute the KIF or CG descriptions interpretively. For better performance, the descriptions could be compiled into executable code in a more traditional programming language. See the paper by Sowa (1993) for fur- ther discussion of these points.

8 Encapsulating Object Descriptions

To represent the encapsulated objects of object-oriented systems, logic must sup- port contexts whose structure reflects the nest of encapsulations. In conceptual graphs, contexts are represented by concept boxes that contain nested graphs that describe the object represented by the concept. In KIF, the nesting is represented by the' description relation dscr, which links an object to a KIF statement that describes it. As an example, Figure 26 shows a graph for a birthday party that occurred at the point in time (PTIM) of 26 May 1992.

[ BIRTHDAY-PARTY ~ - ~ ~ DATE: 26 May 1992 [

Figure 26. A birthday party on 26 May 1992

The concept box with the label BIRTHDAY-PARTY says that there exists a birthday party, but it doesn't specify any details. The PTIM relation indicates that it occurred on the date 26 May 1992. To see the details of the party, it is necessary to open up the box and look inside. With a graphic display and a mouse for pointing, a person could click on the box, and the system would expand it to the context in Figure 27. In that graph, the large outer box is the same concept of type BIRTHDAY-PARTY that was shown in Figure 26. But now, the expanded box contains nested conceptual graphs that describe the party.

BIRTHDAY-PARTY:

Figure 27. Expanded view of the birthday-party context

Inside the large box in Figure 27, the first graph says that 40 guests are giving presents to a person named Marvin, and the second one says that 50 candles are on a cake. The relations AGNT, PTNT, and RCPT are linguistic case relations

Page 31: Relating diagrams to logic - Search - University of Malta

31

that indicate the agent (guests who are giving), the patient (presents that are being given), and the recipient (the birthday boy, Marvin). The notation {*} indicates a set of things, and the qualifiers "@40" and "@50" indicate the count of ele- ments in the sets.

The nested graphs in Figure 27 describe the birthday party. Semantically, the nesting has the effect of quoting the graphs, which are linked to the birthday party by an implicit description relation (DSCR); see the paper by Sowa (1993) for further details. In KIF, the corresponding statement says there exists some- thing ?b of type birthday party, which has as description a quoted statement that is a translation of the conceptual graphs nested inside the outer box of Figure 27:

(exists (?b birthday_party) (dscr ?b

' (exists (and

((?x set) (?zl givel (?z2 setl (?y set) (person Marvin) (rcpt ?zl Marvin) (count ?x 401 (forall (?ml1 (=> (member ?ml ?x)

(and (guest ?ml1 (agnt ?zl ?m11)1) (count ?y 5B1 (forall (?m2)

(forall (?m3)

(?z3 cake) (?p process))

(=> (member ?m2 ?y) (and (candle ?m2) (on ?m2 ?z31)))

(=> (member ?m3 ?z2) (and (present ?m31 (ptnt ?zl ?m3)1)) 1)1)

This statement says that there exists a birthday party ?b, which is described by a quoted statement, which says that there exists a set ~ , an instance of giving ?zl, a set ?z2, a set ~ , a cake ?z3, and a process ?p; the person Marvin is the recipient of the giving zl; the set ~ has 40 members, and for all ?ml in the set ~ , ?ml is a guest and ?ml is an agent of ?zl; the set ~ has 50 members, and for all ?m2 in the set ~ , ?m2 is a candle and ?m2 is on the cake ?z3; and for all ?m3 in the set ?z2, ?m3 is a present and ?m3 is a patient of the giving ?zl. The nesting in CGs, which corresponds to quoted statements in KIF, is another use of metalanguage. Other applications of logic to object-oriented systems have also used metalevel facilities, as in the F-logic by Kifer and Lausen (1989). The general metalevel features of CGs and KIF can simulate F-logic and other logics that have been developed to formalize O-O systems.

At the bottom of the box in Figure 27 is another concept [PROCESS]. By clicking on that box, a person could expand it to a context that shows the steps in the process. In Figure 28, the process box contains three other nested contexts: a state with duration 15 seconds, followed by an event that occurs at the point in time 20:23:19 Greenwich Mean Time, followed by a state with duration 5 Sec- onds. The relation DUR represents duration, PTIM represents point in time, and SUCC represents successor. DUR links a context to a time interval during which the graphs that describe the context are true; PTIM links a context to a time point, which may be considered a very short interval whose starting and ending times are not distinguishable.

At the top of Figure 28, two new variables *x and *y appear on the concepts of the 40 guests and the 50 candles. Those variables mark defining nodes that arereferenced by variables of the form ~ for the guests and .'?y for the candles in

Page 32: Relating diagrams to logic - Search - University of Malta

32

graphs nested inside the process context. In the pure graph notation, variables are not needed, since coreference links are shown by dotted lines. But when the graphs contain a lot of detail, variables can help to reduce the clutter. An inter- active display could provide an option of showing coreference links either as var- iables or as dotted lines.

mRTHDAY-PAR~:

PROCE~:

Figure 28. Expanded view of the birthday party to show details of the process

In Figure 28, the graphs nested inside the concepts of type STATE and EVENT are too small to be read. By clicking on the box for the first state, a person could zoom in to see the details in Figure 29. The expanded state shows the candles .?y burning while the guests ~ sing the song "Happy Birthday." Then the event box could be expanded to show Marvin blowing out the candles, and the next state would show the candles smoking for5 seconds. Context boxes can encapsulate details at any level. At a lower level, the concept [SING] might be expanded to show one guest singing in the key of G while another is singing in G fiat. In this way, the encapsulated description of any object could be contained in a single context box, which could be expanded to show the details or contracted to hide them. Sowa (1993) develops this technique further and applies it to the description of object-oriented systems.

Page 33: Relating diagrams to logic - Search - University of Malta

33

Figure 29. Expanded view of the first state of the process in Figure 28

The boxes of conceptual graphs are a highly readable way of marking con- texts, in KIF, each nest corresponds to a dscr relation with a quoted KIF state- ment as its second argument. FoUowing is the KIF form of the graph in Figure 28:

(exists (?b blrthday_party) (dscr ?b

'(exists ((?x set) (?zl give) (?z2 set) (?y set) (?z3 cake) (?p process)) (and (person Marvin) (rcpt ?zl Marvin)

(count ?x 4B) (forall (?ml) (=>(member ?ml ?x)

(and (guest ?ml) (agnt ?zl ?ml)))) (count ?y 5B) (forall (?m2) (=> (member ?m2 ?y)

(and (candle ?m2). (on ?m2 ?z3)))) (forall (?m3) (=> (member ?m3 ?z2)

(and (present ?m3) (ptnt ?zl ?m3)))) (dscr ?p

'(exists ((?sl state) (?e event) (?s2 state) (?z4 interval) (?z5 interval))

(and (dur ?sl ?z4) (measure ?z4 15see) (succ ?sl ?e) (time 2B:23:19GMT) (prim ?e 2B:23:1gGMT) (succ ?e ?s2) (dur ?s2 ?zS) (measure ?z5 5sec) (dscr ?sl

'(exists ((?z6 sing) (?z7 burn)) (and (song Happy_Birthday)

(ptnt ?z6 Happy_Birthday) (=> (member ?m4 ,,?x) (agnt ?z6 ?m4)) (=~ (member ?mS ,,?y) (ptnt ?z7 ?mS)) )))

(dscr ?e '(exists (?z8 blow_out)

(and (agnt ?z8 Marvin) (=> (member ?m6 ,,?y) (ptnt ?z8 ?m6)) )))

(dscr ?s2 '(exists ((?z9 generate) (?zlB smoke))

(and (rslt ?zg ?zlB) (=> (member ?m7 ,,?y) (inst ?zg ?roT)) ))) )))

)))

A lengthy formula like this may not be very readable, but it is precise, and it can be automaticaUy translated to other knowledge representation languages. To im- prove readability, the technique of zooming in and out of the context boxes may

Page 34: Relating diagrams to logic - Search - University of Malta

34

be used. Although the complete KIF description of the details of the birthday party is a lot to read, the system could display one context at a time upon request.

Although conceptual graphs are quite readable, they are a formal language that would normally be used by programmers, systems analysts, and other pro- fessionals. End users would usually prefer natural languages. But even pro- grammers use natural language for comments, documentation, and help facilities. Since conceptual graphs were originally designed as a semantic representation for natural language, they can help to form a bridge between KIF and other com- puter languages and the natural languages that everyone reads, writes, and speakS. Parsers and generators have been implemented for translating them to and from English, French, German, Italian, Spanish, Portuguese, and Japanese. Following is a stylized English description that could be generated directly from Figure 28:

There is a birthday party B. In B, 4B guests X are giving presents to the person Marvin. 56) candles Y are on a cake. There is a process P.

In the process P, there is a state $I with a duration of 15 seconds. The state $1 is followed by an event E at the time 2B:23:15 GMT. The event E is followed by a state $2 with a duration of 5 seconds.

In the state $1, the candles Y are burning. The guests X are singing the song Happy Birthday.

In the event E, the person Marvin blows out the candles Y.

In the state S2, the candles Y are generating smoke.

Translating a natural language to a formal language is difficult because of the ambiguities in ordinary language. But generating natural language from an un- ambiguous formal language, such as conceptual graphs, is a much simpler task. For stylized English, the generation process can be simplified further by using variables instead of pronouns and mapping the context structure of the graphs to the natural language paragraphs. Such stylized language may not be elegant, but it is useful for comments and explanations.

References

Chen, Peter Pin-Shan (1976) "The entity-relationship model-toward a unified view of data," ACM Transactions on Database Systems 1:I, pp. 9-36.

Chomsky, Noam (1957) Syntactic Structures, Mouton, The Hague.

Genesereth, M. R., & R. E. Fikes (1992) "Knowledge Interchange Format, Ver- sion 3.0 Reference Manual," Report Logic-92-1, Computer Science Department, Stanford University.

Gentzen, Gerhard (1934) "Untersuchungen fiber das logische Schliessen", Mathematische Zeitschrift, XXXIX, 176-210.

Kifer, Michael, & Georg Lausen (1989) "F-logic: A higher-order language for reasoning about objects, inheritance, and scheme," Proc. 1989 ACM SIGMOD Conference, pp. 134-146.

Page 35: Relating diagrams to logic - Search - University of Malta

35

Levinson, Robert A., & Gerard Ellis (1992) "Multilevel hierarchical retrieval," Knowledge Based Systems, vol. 5, no. 3, pp. 233-244.

Nagle, T. E., J. A. Nagle, L. L. Gerholz, & P. WI Eldund, eds. (1992) Conceptual Structures: Current Research and Practice, Ellis Horwood, New York.

Peirce, Charles Sanders (1898) Reasoning and the Logic of Things: T h e Cambridge Conferences Lectures of 1898, ed. by K. L. Ketner, Harvard Univer- sity Press, Cambridge, MA, 1992.

Perez, Sandra, & Anthony SalTiS, eds. (1993) IRDS Conceptual Schema, X3H4 Technical Report, American National Standards Institute, New York.

Roberts, Don D. (1973) The Existential Graphs of Charles S. Peirce, Mouton, The Hague.

Sowa, John F. (1984) Conceptual Structures: Information Processing in Mind and Machine, Addison-Wesley, Reading, MA.

Sowa, John F. (1993) "Logical foundations for representing object-oriented sys- tems," Journal of Experimental and Theoretical Artificial Intelligence ( JETAI) to appear in vol. 5.

Tesni6re, Lucien (1959) Eldments de Syntaxe Structurale, 2rid edition, Librairie C. Klincksieck, Paris, 1965.

Whitehead, Alfred North, & Bertrand Russell (1910) Principia Mathematica, Cambridge University Press, Cambridge.