## Bestfitting simplified

With the simplification of contexts, bestfitting becomes simpler as well, as does the semantics for identifiers in expressions.

An equation *q* is, conceptually, a triple (*x _{q}*,

*K*,

_{q}*E*), where

_{q}*x*is the variable being defined,

_{q}*K*is the set of contexts where the equation is valid, and

_{q}*E*is the defining expression.

_{q}Given two equations *q* and *q’*, we write *q* ⊂ *q’* if *x _{q}* =

*x*and

_{q’}*K*⊃

_{q}*K*.

_{q’}If we have a set of equations σ, then best(σ) consists of the bestfit equations in σ , i.e.,

best(σ) = {*q* ∊ σ | ∄ *q'* ∊ σ. *q* ⊂ *q'*}

The restriction of a set of equations σ to an identifier *x* and a context κ is written

σ|*x*κ = {*q* ∊ σ | *x* = *x _{q}* and κ ∊

*K*}

_{q}We can now write the semantics for identifiers in equations.

⟦*x*⟧σκ =

let {*q*_{1}, ..., *q*_{n}} = best(σ|*x*κ) in

let *v _{i}* = ⟦

*E*⟧σκ in

_{qi}*v*⊕ ⋯ ⊕

_{1}*v*

_{n}where ⊕ is the combining operator. The simplest combining operator checks that all of its arguments are identical, and returns that value. In the general language, each identifier could have its own combining operator, which could be any commutative, associative operator.

## Reply