<<

Generating Text with a Theorem Prover

Ivfin I. Garibay School of University of Central Florida Orlando, FL [email protected]

Statechart Abstract ~ Theoreml The process of documenting designs is tedious and Content Planning Question tree + Tree transformations often error-prone. We discuss a system that au- , _?_T;_J Text Planning i Hypermxt~s implicittext planner(user)[ tomatically generates documentation for the single step transition behavior of Statecharts with particu- I.oa!izatioo Tomp,ato I lar focus on the correctness of the result in the sense that the document will present all and only the facts Hyper-t exit Document corresponding to the design being documented. Our approach is to translate the Statechart into Figure 1: Conceptual view Of the system. a propositional formula, then translate this formula into a natural language report. In the later transla- spective, this problem is distinguished in that the tion pragmatic effects arise due to the way the in- formal correctness of the document being generated formation is presented. Whereas such effects can be is crucial while felicitousness of the style is rela- difficult to quantify, we account for them within an tively unimportant. This leads us to a solution abstract framework by applying a series of transfor- based on formally verifiable theorem-proving tech- mations on the structure on the report while pre- niques which allows us to approach strategic NLG is- serving soundness and completeness of the logical sues within a highly abstract and conceptually clear content. The result is an automatically generated framework. hypertext report that is both logically correct and, The system takes a statechart in the form of a to a relatively high degree of confidence, free of mis- labeled directed graph and translates it into a set leading implicatures. of propositional formulae defining its transition be- havior. A hyper-text natural language document is 1 Introduction generated on-demand from this set of formulae in Producing technical documentation is a time- response to the reader's interaction with the appli- consuming and expensive task. For instance, Re- cation. iter et al. (1995), report cases of engineers expend- Figure 1 depicts a comparative (Moore and Paris, ing five hours on documentation for each hour spent 1993; Paris et al., 1991; Hovy, 1988) conceptual view on design and of airplane documentation sets which of the system while Fig. 2 shows the system archi- weigh more than the actual airplane being docu- tecture. A prototype has been fully implemented mented. Part of the reason for this problem is the with the exception of the statechart axiomatization gap between Computer Aided Design (CAD) tools module, x and similar tools for assisting the documentation of those designs. Since research efforts focus primarily 2 A Logical Semantics for in the former, this situation is likely to get worse as Statecharts the CAD tools get more powerful while documenta- tion tools lag far behind. The graphical language of statecharts as proposed In this paper we address the matter of automatic by David Harel (Harel et al., 1987; Harel and Naa- generation of technical documentation (Reiter et al., mad, 1996), has been widely recognized as a impor- 1992; Reiter et al., 1995; RSsner and Stede, 1992; tant tool for analyzing complex reactive systems. Svenberg, 1994; Punshon et al., 1997) by studying It has been implemented in commercial applica- the problem of automatically generating documents tions like STATEMATE (Harel and Politi, 1998) describing the single step transition behavior of Stat- 1A full description of this algorithmic translation of a stat- echarts. echart from its graphical formalism to the propositional logic From a natural language generation (NLG) per- input format used in this work is described in Garibay (2000).

13 Statechart ((TV ~ WORKING v WAITING) (TV.next ~ WORKING.next V WAITING,next) ..... t ..... (WORKING --~ ~ WAITING) ~Axlomatlzatlon ) (WORKING.next --~ ~ WAITING.next) (WAITING --~ ~ WORKING) 'I...... Module I ' (WAITING.next --+ ~ WORKING.next) (WORKING ~ IMAGE A SOUND) [ Statechart Axioms (WORKING.next ~ IMAGE.next A SOUND.next) • .. ) Reduction to ~ ((TV) A I MRCNF module IN, ((WORKING A PICTURE A PIC-OFF A WAITING.next) V • ~ (WORKING ^~ (PICTURE A PIC-OFF) A ((IMAGE A PICTURE A PIC-OFF A WAITING.next) V (IMAGE A~ (PICTURE A PIC-OFF) A ((PICTURE A PIC-OFF A WAITING.next) V (PICTURE A TXT A MUTE.next A TEXT.next) V I-I to CN, module (PICTURE A~ OFF A9 TXT A PICTURE.next) ) I QuestionTree ,ode~ Theorem ] • .. ))) Prover [Information EitractionModule ~'~ k.

Hyper-text Organization/RealizationModul~ Figure 4: Section of the propositional logic transla- tion of the example statechart (Fig. 3). Generated Hyper-text Page User Interface(Browser) ] one for the next status. In practice, we incorpo- rate this into a single model with two versions of each propositional variable: P for the truth value in the current status and Pn for the truth value in the Figure 2: System architecture of the theorem prover next status 2. A full description of the algorithm based generator. The dotted box is not imple- for translating statecharts to sets of formulae can mented. be found in Garibay (2000). For a example of this translation see Fig. 4. "rv HNG { PIC OFF WOR 3 The Minimum Clausal Theory of IMAGE SOUND the Statecharts

o J VhmN( At this point, we have a formula that entails the the- ory of the single step transition behavior of a Stat- echart. We can fulfill our requirement of generat- ing a sound and complete report just by translating this formula into English. However, this approach presents a number of problems. For instance, the Figure 3: Example Statechart. AND and OR connectives do not in general have the same meaning in English as they do in logic (Gazdar, 1979), furthermore, unlike in the logical formula the and RHAPSODY from ilogix (I-Logix Inc., 2000) scope of the connectives in English is not, in gen- and has been adopted as a part of the Unified Mod- eral, well defined (Holt and Klein, 1999). To mini- eling Language (UML Revision Task Force, 1999; mize the ambiguity, we need to take the formula to Booch, 1999), an endeavor to standardize a language a form with minimal nesting of operators. of blueprints for . Potentially a more significant problem is the fact Statecharts (Fig. 3) are an extension of conven- that much of the theory (the formula plus all its logi- tional finite state machines in which the states may cal consequences) is obtainable only via complicated have a hierarchical structure. A configuration is de- inferences. Since the reader understands the trans- fined as a maximal set of non-conflicting states which lation of the formula at an intuitive level, making are active at a given time. A transition connects only limited inferences, a direct translation will fail states and is labeled with the set of events that trig- to communicate the entire theory. Hence, we would ger it, and a second set of events that are generated like to take the formula to a form that is closed, in when the transition is taken. A step of the statechart some sense, under logical consequences. relates the current configuration and the events that We address both issues by using what we refer to are active to the next configuration and the events as minimal (fully) resolved conjunctive normal form that are generated. A configuration and the set of (MRCNF). A formula is in a MRCNF if and only if events that are active is referred to as a status. 2These single step models will form the basis for a tem- We capture a step of a statechart as a pair of poral model capturing the full behavior of the statecharts as propositional models, one for the current status and described by Harel and Naamad (1996).

14 it is in conjunctive normal form (CNF) and is closed the theory is contingent upon. The reader effec- under resolution, absorption and tautology (Fitting, tively fixes the valuation of one of these variables 1990; Rogers and Vijay-Shanker, 1994). The clo- to true or false. The system then adds the reader's sure under resolution is effectively a finite approx- choice to the theory and recalculates the MRCNF. If imation of closure under consequence, that is, ev- the newly obtained theory remains contingent upon ery clause that is a logical consequence of the the- some variables, the reader then will have available ory entailed by the formula is a direct consequence a new set of choices. If not, the reader will have of some clause in the MRCNF. The other two op- reached a set of non-contingent facts (henceforth erations guarantee minimality in size by removing facts) which are consequences of all the previous clauses that are trivially true (tautology), and those choices. that are proper super-sets of another (absorption). While this process makes the information more Hence, the translation will communicate not only accessible by giving it a logical structure, it does the initial facts but also those inferred by resolution. nothing to reduce the size of the report. We resolve Moreover, a formula in this form is just a conjunc- this by generating the document on demand. While tion of disjunctions--eliminating the scoping prob- the refinement process (the core computation for on- lem. If we interpret the disjunctions as implications, demand generation) can potentially be very expen- the translation into English will be just a sequence sive in terms of time, the fact that we are adding sin- of implicative sentences that are to be interpreted gleton clauses to an already minimum set of clausal conjunctively--a typical structure for such informa- consequences allows us to use a simplified form of tion in English. the theorem prover with asymptotic time complex- ity linear in the number of clauses. 4 Organizing the Hyper-text We can visualize the process of the reader mak- Report: The Question Tree ing choices as navigating a question tree, in which each branch is labeled with a choice and each A formula in MRCNF is organized in a way that contains the theory of the Statechart as refined by resembles a sequence of implicative sentences. The the path of choices from the root to that node. In problem now is the size of this sequence. Large to this tree, a reader's choice is equivalent to the ques- begin with, its size is increased by the transforma- tion: "What are the circumstances/situations if X tion to CNF and closure under resolution. Hence, is true/false?." The root is the full theory of the the translation of MRCNF directly into a sequence transition behavior of the Statechart. The children of statements would present an uninterpretable se- of a node are obtained by fixing the valuation of quence of facts. If they are going to be understood each of its contingent propositional variables in turn by the reader there is a need for some kind of struc- and recomputing the MRCNF. The leaves are non- ture. The correct organization depends heavily on contingent theories (those containing only facts) a the reader's goals and expectations. However, be- Conceptually, the labels of each path from the root yond the assumption that the reader's generic goal to a leaf together with each one of the facts in that is to obtain information about the transition behav- leaf corresponds to all and only the valuations which ior of the statechart under consideration, we do not are models of the original theory. Therefore, the make any assumptions about what the particular question tree is sound and complete in the logical reader's goals may be. Instead we present the report sense. as a hyper-text document and allow the reader to in- teractively refine their goal by following hyper-links. 5 Generating the Hyper-text Page Effectively, the reader's queries focus the theory of under Pragmatic Considerations: the statechart in a particular aspect of its behavior 3. In this way, as in Reiter et al. (1992) and Levine Information Extraction Module et al. (1991), we use hyper-text as an implicit text This tree turns out to provide a useful framework planner, in the sense that we account for every pos- to address pragmatic issues--those that arise princi- sible model of the user/system interaction and let pally from the structure of the report itself (Gazdar, the actual reader decide which goal to pursue. 1979). By addressing these issues in the context of We will call the reader's selections choices. Each the question tree, rather than in its realization as a choice the reader makes narrows the information we report, we abstract away from a great deal of sub- have to convey, limiting it to all and only the part tle semantic detail that would otherwise obscure the that is logically consistent with that choice. We will analysis. Our approach consists of applying a se- say that the reader refines the theory by making ries of transformations that resolve these issues while the choice. At each point, the choices available to 4In general this structure is a directed acyclic graph which the reader are all the propositional variables that Reiter et al. call the question space (Reiter et al., 1995), but since we work with a tree that spans it, we prefer question 3In a process that will be precisely described shortly. tree.

15 preserving logical soundness and completeness of the that they know all and only what we have explicitly document. reported. Therefore, we can satisfy the upper bound of Quantity by reporting each fact exactly once on 5.1 Promoting facts each branch--when it first becomes non-contingent. In the question tree, the facts are either reported at To do this, we simply keep a list of all facts that the end of a chain of choices or are encoded in the have been reported in the current branch; this is the choices themselves. A sequence of these choices is extent of our model of the user. analogous to a chain of nested implications in which This transformation does not change the set of the antecedents are the choices made by the user models represented in the tree, since it only elimi- and the consequence is the theory as refined by the nates repeated literals. choices. This refinement continues until we obtain a non-contingent theory--one in which all variables 5.3 Promoting single level implications have valuations. Thus, the chain of implications One of the difficulties in using Quantity is to deter- eventually leads to a set of facts as its final con- mine what information is "required". At each node sequence. The pragmatic problem in this case re- of the question tree we have a current theory to re- lates to the amount of information to be provided port. The issue, in essence, is what to report at that (Grice's Maxim of Quantity (Grice, 1975)). This node and what to report at its descendents. On one maxim states that speakers will make their contri- hand, it seems clear that we are, at least, required bution as informative as is required, but not more to report the non-contingent facts at each node. On informative than that (Gazdar, 1979). Under this the other hand, we don't want to report the whole assumption, reporting a fact as a consequence of a theory at the root. sequence of choices explicitly denies that this fact is Our intuition is that the degree to which facts a consequence of any prefix of that sequence, in con- are relevant is inversely proportional to the diffi- trast to the logical semantics of implication. Such culty of interpreting them. Under these circum- implicatures, while not consequences of the logical stances, un-nested implications (i.e., binary disjunc- content, are valid inferences that people make on tions) are simple enough that the reader is likely to the basis of well established expectations about the expect them to be reported. From the perspective communicative act. of the question tree, this suggest, that in addition To avoid this false implicature, we present the to the facts at a node, we should also report, as im- facts to the reader as soon as they become available, plications, the facts at its non-contingent children that is, as soon as they become non-contingent in (those that are leaves). We refer to the choices lead- the theory. The transformation, in this case, moves ing to non-contingent theories as conclusive choices. the facts from the leaves to the interior nodes. This These are reported as single-level implications ("If X transformation does not change the set of models then (some sequence of facts~"). This has the effect represented in the tree simply because the move- of promoting the leaves of the tree to their parent ment of facts does not eliminate any path of the tree. pages. Hence, the transformation preserves soundness and Note that a choice that is conclusive at some page completeness of the tree. will also be conclusive at each page in the subtree In practice, the facts are just the singleton clauses rooted at that page (or, rather, at each page reached of a theory, therefore we can realize this transforma- by a sequence of choices consistent with that choice). tion by simply reporting singleton clauses as soon as In keeping with the principle of reporting a fact ex- they appear in the theory. actly once along each path, we must avoid reporting the implication at the descendent pages. To this 5.2 Reporting facts only once end, after reporting each of the conclusive choices On the other hand, facts in a theory are also facts in on a page, we report the remainder of the tree be- every consistent refinement of that theory. Hence, low that page under an "Otherwise" choice in which reporting all the facts at each node of the question the theory has been refined with the complements tree leads us to report many of them repeatedly. In of the conclusive choices. This has the effect of dra- effect, every fact reported in a node will be reported matically restructuring the tree: each of the non- in each of its children as well. This repetition of facts contingent leaves is promoted to the highest page at violates the "upper-bound" of Quantity--it reports which the choice that selects it becomes conclusive. more than is relevant. In this case Quantity requires Once again this transformation reorganizes the us to report only information that is "new". branches of the question tree without changing the In general, what is new will depend not only on set of models it represents. what is reported but on inferences the reader is likely To find the conclusive choices we run the theorem to have made (McDonald, 1992). We have, however, prover on the current theory extended, in turn, with already committed to being explicit; our assumption each literal upon which it is contingent. If the re- is that the reader makes essentially no inferences, sulting theory is non-contingent, then that literal is a

1{} ~far: Biconditional I|plications: * (the current configuration does not include the state WORKING) - the next configuration rill include the state $OFF if and only if * (the OFF is not active). the next configuration will not include the state SON. Facts: One of ~he following must be the case: * the next configuration will not include the state ~URKING. Either: - the current configuration includes the ,tats SOFF, Independent off whether: but does not include the state TEXT. * the event PIC-OFF is active, - the event ESOUNU t~ not active. - the next configuration rill include the s~ate SOFF, Depends on whether: but will not include the state SON. * the current configuration includes the states SON and SOP. - the event ESOUND will not be generated. the event MUTE Is active. O~:the current configuration Includel the state SUFF, Choices: hut does not include the state TEXT. e If the current configuration includes the state SUN [ then... ] - the event ESOUND is active. * If the current configuration duel not include the state SON ~ teen... ] - the next configuration wlll include the state SON, * If the current configuration includes the state SOP [ then... ] but wlll not include the state SDFF. * If the current configuration does not include the state SOP [ then... ] - the event ESOOND .Iii not be generated. * If the event MUTE iS active [ then.,. ] * If the event MUTE is not active [ then... ]

Figure 7: Biconditional implications and models sec- tions. Figure 5: Example of generated hyper-text page.

OtherWise: - the current configuration does ~ot include the irate TEXT - the next configuration will not include the state SON. The following choices are conclusive:

* If the event OFF is active then: - the next configuration wlll include the state WAITING, but elll not include ¢hm states PICTURE or TEXT. - the event h'UTE rill not be generated. * If the next configuration tncludel the state WAITING then: the event OFF lw active. Figure 8: Conclusive otherwise section. - the next configuration sill not include the states PICTURE or TEXT - the event NUTE will not be generated.

[Otherwise ...] 6 Hyper-text Organization and Realization Module The organization of the hyper-text page generated Figure 6: Conclusive choices section (up), non- from each node of the question tree visited by the conclusive otherwise section (bottom). user is shown in Fig. 5. At the top of the page we report (parenthetically) the set of choices that have led to this page. Next we report all of the new facts conclusive choice. To find the remainder of the tree obtained from the current theory as described in sec- to be reported under the "Otherwise" case we ex- tions 5.1 and 5.2. Then, the propositions that the tend the current theory with the negation of each of theory is no longer dependent on (those which no the conclusive choices. If the resulting theory is in- longer occur in the theory ) followed by the list of consistent we will say that the conclusive choices are propositions on which it does depend. Finally we exhaustive, if the result is a contingent theory we will present the choices or, if there are any, the conclu- say that the conclusive choices are non-exhaustive sive choices. In the first (Fig. 5), each choice is pre- with non-conclusive otherwise, and if the result is sented as an implicative sentence with a hyper-text a non-contingent theory we will say that the con- link leading to another page (another node of the clusive choices, in this case, are non-exhaustive with question tree). In the second (Fig. 6 top), we present conclusive otherwise. the set of conclusive choices followed by one of the three possible cases (described in Section 5.3) for 5.4 Aggregating pairs of single conditionals the "Otherwise" case. If the conclusive choices are exhaustive (the otherwise case is inconsistent), we It frequently happens that, at some page, two con- report the biconditional implications (Section 5.4) clusive choices lead to the same model. In this case, followed by the final models (Fig 7). If they are ex- we would report that each implies (among other haustive with a conclusive otherwise, we report the things) the other. However, these two implications otherwise as another conclusive choice (Fig 8). Fi- can be aggregated to form a biconditional. Further- nally, if they are exhaustive with a non-conclusive more, Quantity requires us to select the strongest otherwise, we report only an otherwise hyper-link connective that applies in any such case because if (Fig 6 bottom). a weaker connective is selected it suggests that no The realization module is, in essence, a pattern stronger one applies (a scalar implicature). Con- matching and template filling process. It's basic sequently, we are actually compelled to aggregate simply translates facts into fixed English these two facts into a single biconditional. language sentences. 5 Facts are represented by lit- erals. These are classified into the following cate- In practice, we use the theorem prover to either gories: current state, current event, next state, and prove or disprove, for every implication, whether its next event and the literais in each category are syn- converse is a theorem of the current theory. If proved then the biconditional is reported. 5With added html mark-up.

17 Set of Literals (facts) t Lawrence Poynter, Ehud Reiter, Paul Tyson, and ((WAITING.next OFF WORKING -PICTURE,next TXT)] John Walker. 1991. IDAS: Combining hypertext Ordering and Aggregation and natural language generation. In Third Euro- ((WORKING) (~)FF TXT) (WAITING.next -PICTUga.ne~,)) pean Workshop on Natural Language Generation, Template based realization pages 55-62, Innsbruck, Austria. The cur~n! configuration includes ti~ state WORKING The next configuration will includethe state WAITING, but will not include tbu state PICTURE David D. McDonald. 1992. Type-driven suppres- The cv©nts OFF and TXT an: active J sion of redundancy in the generation of inference- rich reports. In R. Dale, E. Hovy, D. RSsner, Figure 9: Example of realization. and O. Stock, editors, Aspects of Automated Nat- ural Language Generation, volume 587 of Lec- ture Notes in Artificial Intelligence, pages 73-88. tactically aggregated (Dalianis, 1999). The process Springer-Velag. is illustrated in Figure 9. Johanna D. Moore and C6cile L. Paris. 1993. Plan- ning text for advisory dialogues: Capturing inten- References tional and rhetorical information. Computational Grady Booch. 1999. UML in action. Communica- Linguistics, 19(4):651-694. tions of the ACM, 42(10). C~cile L. Paris, William R. Swartout, and Hercules Dalianis. 1999. Aggregation in natural William C. Mann, editors. 1991. Natural Lan- language generation. Computational Intelligence, guage Generation in Artificial Intelligence and 15(4):384-414. Computational Linguistics. Kluwer Academic Melvin Fitting. 1990. First-order Logic and Au- Publishers. tomated Theorem Proving. Springer-Verlag, New J. M. Punshon, J. P. Tremblay, P. G. Sorenson, and York. P. S. Findeisen. 1997. From formal specifications Iv£n Ibargiien Garibay. 2000. Automatic genera- to natural language: A case of study. In 12th tion of natural language documentation from stat- IEEE International Conference Automated Soft- echarts. Master's thesis, University of Central ware Engineering, pages 309-310, Incline Village, Florida. Nevada; USA, November. IEEE Computer Soci- Gerald Gazdar. 1979. Pragmatics: Implicature, ety. Presupposition, and Logical Form. Academic Ehud Reiter, Chris Mellish, and John Levine. 1992. Press. Automatic generation of on-line documentation in H. Paul Grice. 1975. Logic and conversation. In the IDAS project. In Third Conference on Ap- Peter Cole and Jerry L. Morgan, editors, Syntax plied Natural Language Processing (ANLP-1992), and Semantics: Speech Acts, volume 3, pages 41- pages 64-71, Trento, Italy. 58. Academic Press. Ehud Reiter, Chris Mellish, and John Levine. 1995. David Harel and Amnon Naamad. 1996. The Automatic generation of technical documentation. STATEMATE semantics of statecharts. ACM Applied Artificial Intelligence, 9(3):259-287. Transactions on and James Rogers and K. Vijay-Shanker. 1994. Obtain- Methodology, 5(4):293-333, Oct. ing trees from their descriptions: An application David Harel and Machal Politi. 1998. Modeling to tree-adjoining grammars. Computational Intel- Reactive Systems with Statecharts: The STATE- ligence, 10:401-421. MATE Approach. McGraw-Hill. QA 76.9 .$88 D. RSsner and M. Stede. 1992. Customizing rst H3677 1998. for the automatic production of technical man- D. Harel, A. Pnueli, J. P. Schmidt, and R. Sherman. uals. In R. Dale et al., editors, Aspects of Auto- 1987. On the formal semantics of statecharts. In mated Natural Language Generation, number 587 Symposium on Logic in Computer Science, pages in Lecture Notes in Artificial Intelligence, pages 54-64. Computer Society of the IEEE, Computer 199-214, Berlin. Springer Verlag. Society Press, June. S. Svenberg. 1994. Representing conceptual and lin- Alexander Holt and Ewan Klein. 1999. A guistic knowledge for multi-lingual generation in semantically-derived subset of english for hard- a technical domain. In Proceedings of the 7th In- ware verification. In Proceedings of the 37th An- ternational Workshop on Natural Language Gen- nual Meeting of the Association for Computa- eration, pages 245-248, Kennebunkport. tional Linguistics. UML Revision Task Force, 1999. OMG Unified Mod- Eduard H. Hovy. 1988. Generating Natural Lan- eling Language Specification , v. 1.3. Document guage under Pragmatic Constraints. Lawrence ad/99-06-09. , June. Erlbaum Associates. I-Logix Inc. 2000. http://www.ilogix.com. John Levine, Alison Cawsey, Chris Mellish,

18