# The Bali Matrix

The Bali Matrix is a two-dimensional Origami matrix that is used to synthesize the bali2jak, bali2javacc, balicomposer, and bali2layer tools. This is the simplest of the two origami matrices used in building AHEAD.

The Bali Matrix is shown below:

| Base | CodeGen | Bali2jak | bali2javacc | BaliComposer | bali2layer
Core | dsl/kernel build/bali/bali dsl/bali/bali dsl/bali/visitor dsl/bali/collect | dsl/support/codegen | dsl/bali/bali2jak | dsl/bali/bali2javacc | dsl/bali/composer | dsl/bali/bali2layerOptions dsl/bali/bali2layer dsl/bali/bali2layerGUI
withRequireFeature | build/bali/require dsl/bali/require |  | dsl/bali/requireComposer | dsl/bali/requireBali2javacc | dsl/bali/requireComposer |
withoutRequireFeature |  |  |  |  |  |

The bold names denote layers that are generated.

# Dimensional Equations

A tool is specified by a pair of dimensional equations. One equation defines the language dialect (i.e., a composition of rows), the other defines the tool itself (i.e., a composition of columns).

There are only two language dialects:

- With = Core withRequireFeature

- Without = Core withoutREquireFeature

- Note: the first term (Core) is the inner-most in an AHEAD equation. (This is a legacy decision of AHEAD that continues to haunt me).

There are 4 tool equations, again the first term (Base) is the innermost term of AHEAD expression.

- bali2layer tool = Base CodeGen bali2layer
- bali2javacc Tool = Base CodeGen bali2javacc
- bali2layer tool = Base CodeGen bali2layer
- baliComposer Tool = Base composer

So, to see the matrix that is folded (summed) to produce the bali2layer tool for the With language: take the above matrix, remove the unneeded columns and rows:

| Base | CodeGen | bali2layer
Core | dsl/kernel build/bali/bali dsl/bali/bali dsl/bali/visitor dsl/bali/collect | dsl/support/codegen | dsl/bali/bali2layerOptions dsl/bali/bali2layer dsl/bali/bali2layerGUI
withRequireFeature | build/bali/require dsl/bali/require |  |

Next, either sum the rows, then columns:

> bali2layer = dsl/kernel build/bali/bali dsl/bali/bali dsl/bali/visitor dsl/bali/collect build/bali/require dsl/bali/require dsl/support/codegen dsl/bali/bali2layerOptionsdsl/bali/bali2layer dsl/bali/bali2layerGUI

OR equivalently, sum the columns and then the rows:

> bali2layer = dsl/kernel build/bali/bali dsl/bali/bali dsl/bali/visitor dsl/bali/collect dsl/support/codegendsl/bali/bali2layerOptionsdsl/bali/bali2layerdsl/bali/bali2layerGUi build/bali/requiredsl/bali/require

It is this equivalence of the above two equations that needs to be proven/demonstrated.