# Algebraic

ALT is based on three core algebraic (bag) operations called union `|`

, intersection `&`

and negation `!`

.

The union of two values may contain duplicates and maintains order. The union of two values that are not compatible is allowed. Here are the basic rewrite rules for union:

U1:

U2:

U3:

U4:

U5:

U6:

U7:

The intersection of two values that are not compatible always results in `none`

. The intersection between two `struct`

s is a special case and is discussed in a separate section.
Here are the basic rewrite rules for intersection:

I1:

I2:

I3:

I4:

I5:

I6:

I7:

ALT also allows the negation of values. This feature has many interesting properties (but has been proven very hard to implement correctly for regular expressions). Here are the basic rewrite rules for negation:

N1:

N2:

N3:

N4:

N5:

N6: