RULE INDEX

RULE _ _ _ _ _ _ _ _ _ _ _ _ type

A rule is an instruction to replace an algebraic expression or a part of an expression by another one.

syntax:

<lhs> => <rhs> or <lhs> => <rhs> when <cond>

<lhs> is an algebraic expression used as search pattern and <rhs> is an algebraic expression which replaces matches of <rhs>. => is the operator replace.

<lhs> can contain free variables which are symbols preceded by a tilde ~ in their leftmost position in <lhs>. A double tilde marks an optional free variable. If a rule has a when <cond> part it will fire only if the evaluation of <cond> has a result true. <cond> may contain references to free variables of <lhs>.

Rules can be collected in a list which then forms a rule list. Rule lists can be used to collect algebraic knowledge for a specific evaluation context.

Rulesand rule lists are globally activated and deactivated by let, forall, clearrules. For a single evaluation they can be locally activate by where. The active rules for an operator can be visualized by showrules.

examples:


operator f,g,h; 

let f(x) => x^2; 

f(x); 

   2
  x


g_rules:={g(~n,~x)=>h(n/2,x) when evenp n,

g(~n,~x)=>h((1-n)/2,x) when not evenp n}$

let g_rules;

g(3,x); 

  h(-1,x)