Expression Simplification
-------------------------
Expressions may be simplified using reduction rules.
For example:
The Roman numeral I.I.I.I may be simplified to I.V, using the reductions rule:
I.I.I.I = I.V
or, leading zeros may be removed from a balanced ternary number →bta← using:
0.¯1 = ¯1 ⍝ remove leading 0.
0. 0 = 0
0. 1 = 1
In the above example, we can use a _pattern variable_ to parameterize the values
¯1, 0, 1 and so avoid having to write three equations:
i :: ¯1 0 1 ⍝ i matches ¯1, 0 or 1
0.i = i ⍝ remove leading 0.
The set of Roman numerals might be declared:
n :: I V X L C D M ⍝ single digit numerals.
so that compression of numerals may be defined as:
/n = n ⍝ compress single digit
/(p∘n) = (/p).n ⍝ compress multiple digits.
Note that more than one pattern variable may be declared at once:
i j k :: 0 1 ⍝ i, j and k each match 0 or 1.
An empty set of values means that there is no restriction and the pattern vari-
ables match any expression:
p q r :: ⍝ p, q and r match any expression.
Some sets are infinite (or just inconveniently large) and so can't be specified
by enumerating their items. For these we have special primitive types:
← negative numbers,
→ positive numbers,
⍺ lower case letters a..z,
∊ non-simple expression.
Examples:
i j :: ← 0 → ⍝ i and j match any literal number.
k :: ← ⍝ k matches negative numbers.
l :: → ⍝ l matches positive numbers.
m :: 0 → ⍝ m matches non-negative numbers.
n :: I V X ⍝ n matches values I, V or X.
y z :: ∊ ⍝ y and z match non-simple expressions.
x :: ∊ x y z ⍝ x matches expressions and vars x, y and z.
a b :: ⍺ ⍝ a and b match lower case letters a-z.
p q :: ⍝ p and q match any values.
See also: http://en.wikipedia.org/wiki/Computer_algebra_system
See also: →reduce← →Differentiation←
Back to: →Implementation_Details←