Architecture, Design and Implementation of a Mathematical Derivation Editor Johannes Eriksson
What is the Derivation Editor? The Mathematical Derivation Editor (nicknamed “Mathedit”) is work in progress; it aims be a useful tool for creating, editing and correctness checking mathematical papers. 2 / 24
Main developers Gaudi software factory Ralph-Johan Back Main director and producer Victor Bos Designer Viorel Preoteasa Designer Johannes Eriksson Developer What is the Derivation Editor? 3 / 24
Goals • Outlining editor • Editing of hierarchically structured text • Useful for writing mathematical papers • Input of special characters • Editing structured calculational proof Examples from Back, Grundy, v. Wright: Structured Calculation Proof What is the Derivation Editor? 4 / 24
Goals (Continued) • Correctness checking • Export to presentation formats such as HTML and LaTeX • Extensible • Define an API to allow users to modify and extend the editor's behaviour What is the Derivation Editor? 5 / 24
Features 6 / 24
Basic text editing The basic features of a graphical text editor: • Basic editing commands (type character, delete, move cursor,...) • Editable keybindings • Input of unicode characters (using a keybinding or the menu) • Cut, copy, paste via system clipboard • Load and save files (XML) Features 7 / 24
Outlining • Hierarchically structured text • Strict outlining • Possiblity to collapse/expand items Features 8 / 24
Formula syntax • Expression and rule markup • Syntax understanding • Mathematical profiles • Profile interface • The universal profile (UP) Features 9 / 24
Derivation • Determines applicable rules by unification • Steps can be generated automatically or written manually • Correctness checking • Parsing of complete derivations • Re-application of rules, compares terms • Nested derivations • Result of a conditional rule • Focuses on a subexpression • Assumptions = scoped rules Features 10 / 24
Other features • Extensibility, user-defined tools • Some source code features (mainly syntax highlighting) • Export filters • HTML with Javascript or CSS • LaTeX • Possibility to #include documents • Hyperlinks between documents • Other minor features Features 11 / 24
Development 12 / 24
People The programming work has been carried out by computer science and computer engineering students from Åbo Akademi, who have been em- ployed as programmers at the Gaudi Software Factory. The bulk of the work has been done during the two summers of 2002 and 2003, when four programmers worked full-time. Some part-time work during the semesters. Several different teams, altogether 11 individuals have been working as programmers on the project. Development 13 / 24
Extreme programming • Short iterations • Pair programming • Unit tests • Continuous refactoring Development 14 / 24
Development tools • Python language • Linux PCs • xemacs editor • Gaudi Sourceforge on xprog0.cs.abo.fi • Task tracking • Bugtracking Development 15 / 24
Architecture, design and implementation 16 / 24
Stepwise Feature Introduction (SFI) A bottom-up, incremental software development methodology. Soft- ware is built in thin layers where each successive layer introduces a new feature and does not break the functionality of previous layers. • Classes in a new layer become subclasses of the corresponding classes in previous layer, i.e. the application is extended by inherit- ance of its classes. • Overridden methods should preserve functionality from previous layers. • The different components (packages, modules, classes) and the lay- er hierarchy are orthogonal partitionings of the software. Architecture, design and implementation 17 / 24
Layer structure of Mathedit Architecture, design and implementation 18 / 24
Layer structure of Mathedit (Continued) Main window, menu, toolbar and command pat- Command tern. Multiple (empty) windows. Frame Text editing (unicode) with the QTextEdit widget, Text Open, Save, Save As, Save All. Our own docu- ment model. Multiple views of the same document, New View MV command. Copy, cut and paste text. Edit Support for undo/redo of editing commands. Ex- CmdList tended the document model with a command list. Extended the document model and editing capab- Outline1 ilities of the text widget to support an outlining structure. Support for collapsing and expanding an item. Outline2 Collapse hides all lines indented deeper than the current line, expand shows them again. Rich text formatting of text. Format Formula syntax. Is is possible to define math- Derivation emathical expressions, which the editor parses Architecture, design and implementation 19 / 24
Layer structure of Mathedit (Continued) according to its grammar. Perform mathemathical derivations by applying rules on expressions. Possibility to add own profiles. Profile Filters for export to HTML and LaTeX, import of Filter LaTeX. Syntax highlighting for programming languages. Highlight Possibility to connect custom functions to hooks Hook in mathedit. Architecture, design and implementation 20 / 24
Special solutions to aid in SFI • Naming conventions. Each class/subclass name is prefixed with to identify the layer it belongs to. Example: Layername_ Text_Document , Outline1_Document , Derivation_Document , ... • Store metadata, e.g. the list of layers. Possible to find out the layer of any class as well as the layer's position in the hierarchy. • Import modules by “try-and-catch”. Reduces the amount of factory methods. layers = [ Command, Frame, Text, ... ] layeri = layers.index(layer) while layeri>=0: try: exec("import "+layer+"_"+modulename) except ImportError: layeri -= 1 layer = layers[layeri] else: return eval(layer+"_"+modulename) raise "No module " + modulename Architecture, design and implementation 21 / 24
Advantages of SFI • Works well with incremental software development • Each layer can be run as a standalone application, making it easier to track down bugs • Unit tests can follow layer hierachy Architecture, design and implementation 22 / 24
Disadvantages of SFI • Can make some refactorings difficult • Changes to existing features may not fit well into the hierarchy • Large number of classes and deep inheritance hierarchies may be difficult to deal with Architecture, design and implementation 23 / 24
Implementation • Python 2.2 • Interpreted, object-oriented language • Easy to learn • Garbage collection • Highly dynamic • Introspective power • www.python.org • Qt 3.1 • A cross-platform C++ widget toolkit • Language bindings for Python (PyQt) • www.trolltech.com Architecture, design and implementation 24 / 24
Recommend
More recommend