Lurch Deductive Engine

Class

BindingExpression

A binding in general is defined in the documentation for the BindingInterface. Refer there for the general principles. This class uses that interface to implement bindings whose bodies are Expressions.

Constructor

new BindingExpression(…args)

Construct a new BindingExpression instance from the given array of bound variables (one or more Symbols) and body (required Expression). Recall from the documentation of the BindingInterface that bindings do not contain an operator, so BindingExpressions are almost always wrapped in an application to add an operator to them.

For example, when encoding something like $\bigcup_i A_i$, the documentation for BindingInterface gives the following example way to do so.

new Application(
    new LurchSymbol( '⋃' ),
    new BindingExpression(
        new LurchSymbol( 'i' ),
        new Application(
            new LurchSymbol( 'subscript' ),
            new LurchSymbol( 'A' ),
            new LurchSymbol( 'i' )
        )
    )
)

As a second example, $\sum_{i=1}^n i^2$, could be encoded as follows, if we already had Symbols i, n, Sum, and power defined.

new Application(
    Sum, Symbol( 1 ), n,
    new BindingExpression( i, new Application( power, i, Symbol( 2 ) ) )
)

Note that while it is possible later to remove children from a BindingExpression so that it does not have the required structure of symbols-then-body, this is almost certain to result in the members of this class malfunctioning or throwing errors. Clients should not remove the necessary children of a BindingExpression; that is not supported.

Although it is unnecessarily to repeat the same variable twice on the list of bound variables, we do not explicitly forbid it.

Parameters

  • args Expression <repeatable>

    the list of one or more Symbols that this expression binds, followed by its body, which must be of type Expression.

Throws

This constructor throws an error if any argument is not an Expressions, or if any argument but the last is not a Symbols, or if the list of bound symbols is empty.

Source

Classes

BindingExpression