User:Thepigdog/Value sets

Introduction to value sets

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 =

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

:x^2 = 4

which implies,

:x = 2 \lor x = -2

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,

:x = \pm 2

Naively then,

:x + x \in 2, 0, -2

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.

= Representation =

The value set for 'x' is written as,

: V(\{2 :: x_1, -2 :: x_2\})

It is container V which has a set of tag, value pairs,

  • 2 :: x_1
  • -2 :: x_2

The value 2 is associated with the possible world x_1. The value -2 is associated with the possible world x_2. This means that the value cannot be both 2 and -2 at the same time. In the world x_1 the value of the value set must be 2. In the world x_2 the value of the value set must be -2.

The solution of the equation,

:x^2 = 4

is,

: x = V(\{2 :: x_1, -2 :: x_2\})

World Sets

A world set is a set of possible worlds that represent all possibilities. So \{x_1, x_2\} is a world set as either x = 2 (in world x_1) or x= -2 (in world x_2). There are no other possibilities.

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

:(x = 2 \land x = -2) = \text{false}

= Application of functions =

The rule for the application of functions to value sets is,

:V(M)\ V(N) = V(\{(m_v\ n_v, m_l \cap n_l) : m_v :: m_l \in M \land n_v :: n_l \in N\})

For example,

: x + x = V(\{2 :: x_1, -2 :: x_2\}) + V(\{2 :: x_1, -2 :: x_2\})

is,

: = V(\{-2+-2 :: x_1 \cap x_1, -2+2 :: x_1 \cap x_2, 2+-2 :: x_1 \cap x_2, 2+2 :: x_2\})

: = V(\{-4 :: x_1 \cap x_1, 0 :: x_1 \cap x_2, 0 :: x_2 \land x_1, 2+2 :: x_2 \cap x_1\})

The intersection of the possible world with itself is the possible world,

: x_1 \cap x_1 = x_1

: x_2 \cap x_2 = x_2

The intersection of the possible world with another possible world from the same world set is empty,

: x_1 \cap x_2 = \{\}

: x_2 \cap x_1 = \{\}

So,

: = V(\{-4 :: x_1, 0 :: \{\}, 0 :: \{\}, 4 :: x_2 \})

The empty worlds rule allows tagged values from empty worlds to be dropped

: V(K) = V(\{(v, l) : (v, l) \in K \land l \ne \{\} \}

giving,

: = V(\{-4 :: x_1, 4 :: x_2 \})

Giving the result that x + x is either -4 or 4, as expected.

= Application to Booleans =

: a \land b

Is a relationship between a, b and true that implies that both a and b must be true.

: a \lor b

Allows multiple values for a and b. If a is,

: a = V(\{\operatorname{false} :: a_1, \operatorname{true} :: a_2 \})

then for b

: b = V(\{\operatorname{true} :: a_1, \operatorname{false} :: a_2, \operatorname{true} :: a_2 \})

This means that if a is false then b must be true.

Now consider,

: x = 2 \lor x = -2

gives,

: x = V(\{\_ :: a_1, 2 :: a_2 \})

and

: x = V(\{-2 :: a_1, \_ :: a_2, -2 :: a_2 \})

unifying these two value sets gives,

: x = V(\{-2 :: a_1, 2 :: a_2\})

The pair -2 :: a_2 is dropped because of the "assert equal" rule,

:\forall m_v \forall m_l \forall n_v \forall n_l ((m_v, m_l) \in M \land (n_v, n_l) \in N) \to (m_v \ne n_v \to m_l\cap n_l = \{\} )

Its value -2 :: a_2 did not match with 2 :: a_2 .