User:Thepigdog/Value container

A Value Set is an object, which represents the set of values a variable may have. The value set behaves mathematically as a single value, while internally representing multiple values. To achieve this the the Value Set tracks the value along with the context, or world, in which they occurred.

Multiple solutions to an equation

edit

In mathematics, an expression must represent a single value. For example consider the equation,

 

which implies,

 

But this is a bit long winded, and it does not allow us to work with multiple values at the same time. If further conditions or constraints are added to x we would like to consider each value to see if it matches the constraint. So naively we would like to write,

 

Naively then,

 

but this is wrong. Each x must represent a single value in the expression. Either x is 2 or x = -2. This can be resolved by keeping track of the two values so that we make sure that the values are used consistently, and this is what a value set does.

Worlds

edit

A world is a possibility, or alternative, associated with a proposition. The value for x is either 2 or -2. By identifying these values with worlds we can track values so that values from different worlds are not combined. The value container for x, for the equations above is,

 

which says that x = 2 in world A and -2 in world B. Note that A and B are names used to identify worlds. The only property of these worlds we are interested in is there identity, and I am using A and B here, purely to represent this identity. The worlds A and B are defined by,

A is the world in which proposition x = 2 may be asserted.
B is the world in which proposition x = -2 may be asserted.

A world is somewhat like a set and set notation is used to represent the intersection of worlds. The intersection of worlds is a world where the conjunction of the propositions is true.

A value container is not a set, but it contains a set,

 

The : operator is used to tag the value with the world.

World Sets

edit

A world set is a set of worlds that represent all possibilities. So   is a world set as either x = 2 (in world A) or x= -2 (in world B).

Worlds from the same world set are mutually exclusive, so it is not possible that the propositions for both worlds A and B are true at the same time.

 

Law for functions of a value container

edit

A value container contains a set of tagged values. The tagged value set for a container X is written  .

 

where F is a function and X is a value container, and F(X) is the container obtained by applying F to X.

This law may be applied with Currying to give laws for the application of functions to multiple parameters. For example,

 

may be derived. From the previous example,

 

because,

 
 

Terms from empty worlds may be dropped.

Use of value containers

edit

Value containers allow the construction of inverse functions for functions that are a many to one mapping. In many cases this allows us to use inverse functions to solve equations. By choosing the evaluation order so as to minimize the number of values in the value set, efficient evaluation may be achieved.

It is helpful to regard an equation like,

 

as a relationship between 3 values. Based on which values are provided the value that is not provided may be calculated. This simple approach allows the evaluation of variables constrained by logic in most situations.

The standard form of value containers

edit

The standard form of value containers is to not merge tagged values, even if they have the same value. Each tagged value always has the intersection of all the worlds from which it was formed.

This convention allows a simple rule for determining if a world is empty. If a world no longer is present in a value container, then the world is empty. For example,

 

gives,

 
 
 

and as B and D are not in the last value container then B and D are empty, which gives,

 
 

The constraint evaluation paradigm

edit

Value containers may be used to implement a simple form of logic in a computer language, based on narrowing. This paradigm is based almost completely on the evaluation of expressions. Narrowing occurs when worlds are shown to be empty.

Evaluation order

edit

The evaluation order must be flexible so as evaluation to proceed in the order best suited to reducing the number of values in value containers. The measure used to choose this order is the product of the number of values in the input to the calculation.