User:BBQAl/sandbox

Ket is an open source algebra editor. It is distinct from other editors which focus on automated computation such as integration or equation solving (Mathematica, Maple etc.) or on the presentation quality of the resulting document (e.g. LaTeX). The focus of Ket is to enable the user to perform algebra quickly and efficiently. It is therefore closer to a text editor, whiteboard or to the back of an envelope. However, it does provide a range of tools to automate the individual steps of algebra.

Overview
Ket breaks equation editing into a series of small edits performed by keyboard or mouse gestures. This is because equations contain a wide assortment of symbols and notations, but also contain a great deal of repetition. As a result, it is faster to reuse existing expressions than it is to re-write them. This becomes even more pronounced when performing algebra which consists of modifying and combining existing expressions adding further repetition.

Commands are built around abstract transformations of the structure of the equation. Some commands delete, reorganize and combine existing expressions and some add new content. Commands are all responsive enough to provide instantaneous updates. The user can therefore view an equation in conventional mathematical notation while interacting with a series of small fragments.

Representations


Ket maintains three distinct representations of an equation. Equations are displayed to the user and may be exported in images in conventional mathematical notation. Internally it is most efficient to represent the equation as a Tree structure which standardizes direction commands. But when writing equation fragments or saving them to file, a custom markdown language is used which merges markdown, LaTeX and plain text mathematical notations as applicable.

Conventional mathematical notation is represented by a series of boxes within boxes each containing letters and lines to denote what function, operation, variable or value they represent. After each edit, equations are converted to this form and rendered.

However, edit commands represent the equation differently and keyboard direction commands reflect this. Analogous to a filesystem hierarchy of files and folders within folders, each equation is represented as a Tree structure. Each equation in Ket is a tree of operations and functions (tree branches) and variables and values (tree leaves).

The file format consists of its own, non-standard markdown language. Also, when editing, any equation fragments are typed in plain text and converted to the tree. The equation is represented in memory and converted to a tree map in order to display it to the user. The file format is plain text which is converted to and from a tree when files are loaded and saved.

Interaction


Various forms of interaction are possible. These include reorganizing the tree structure and performing simple algebraic operations. Mouse drags allow the user to change the order of arguments to a function. They can also add and remove fragments of an expression into another equation including substituting for a variable. While a plain text representation of pages of equations can quickly become unwieldy, working with small fragments of plain text are a quick way to replace, identify or update an existing selection. If good writing is rewriting then good algebra is reorganizing existing expressions.

Editing
The quickest form of editing is by mouse gestures to substitute one equation into another. Additionally, either through the right click menu or right-dragging in the menu items direction, arguments may be deleted, copied or added.

Ket is a modal editor which means that it changes how it displays information and how the user interacts with it depending on the mode it's in. By default, keyboard commands perform specific selection or transformation commands such as to delete the current selection, 'x'. Some commands must be followed with a direction, for example paste, 'p'. Other commands require a block of text such as to replace the selection with an equation fragment, 'r'. Editing lines of text The editor displays a list of lines of either text, equations, images or plots. In order to edit text,  starts editing text while  or  stops. Here  takes a new line and continues editing text.

All editing takes place relative to the current selection so a variety of commands to change the selection are provided. In order to move around, it is possible to use arrow keys, however it is quicker to keep your hands in the touch typing position so various keys signify directions. In addition to moving up, 'k', and down, 'j', between equations, it is possible to move in and out of each equation. That is, to select different parts of the tree. 'h' and 'l' select the previous and next expression while 'i' and 'o' select the left and right arguments of the tree. Lastly,  moves back out.

After pressing a command that requires an equation fragment, the program changes mode. Here a plain text representation of an equation fragment may be typed. This mode also allows Readline commands familiar to Bash and Emacs users.

This is then converted to an equation fragment by pressing  (or cancelled with ). Transformation commands Editing can take place at different levels of meaning. Editing need not preserve the original meaning of an expression. So for example, a polynomial pattern could be reused by copying it and replacing all of the variables with new ones. Various syntactic and semantic transformations are also possible. Some are trivial such as replacing the current selection, 'r', with a new fragment. Others may be cycled through such as the Distributive property
 * $$a (b+c) = a b+a c$$

using  and .

Commands such as replace require fragments of an equation to be represented in plain text.

Often a text fragment has already been typed and may be referred to. If the fragment exists in the current equation then use "\address" (a backslash followed by an address without quotes). Here successive digits of an address refer to the nth argument.

Similarly, existing equations may be referred to as "#1" for equation 1 etc. And an address within another equation referred to as "1#234" for the 2nd argument's 3rd argument's 4th argument within equation 1.