See also Operator Precedence Rules.
| Symbol | Description | Example |
| := | assignment means "is assigned the value" |
> x := 5; > y := 3*x-5; > S := {1, 9, 2, 4}; > T := [3.2, 5, -4.1]; |
| .. | iteration |
> S := {1..5}; > S; {2,1,3,4,5}; > T := [1..5]; > T; [1,2,3,4,5] |
| | | means "such that" used in Set Formers and Tuple Formers |
> S := {1..7}; > S2 := {x | x in S | x > 5}; > S2; {7,6}; > T := [1..7]; > T2 := [x | x in T | x > 5]; > T2; [6,7]; |
| : | same as "|" used in Set Formers and Tuple Formers |
See Above |
| Operator | Description | Example |
| + | Addition | > 8713+246; 8959; |
| - | Subtraction | > 593.7-12.25; 581.450; |
| * | multiplication | > 123456789012345678901 * 12345; 1524074060357407406032845; |
| / | division (real division of reals and/or integers) | > 47/2; 23.500; |
| div | integer division | > 47 div 2; 23; > 46.3 div 23; !Error: Bad arguments in: 46.300 div 23; |
| mod | remainder from integer division | > 12 mod 5; 2; |
| ** | exponeniation (raise to a power) | > 2.5**4;; 39.063; |
| Operator | Description | Example |
| = | equal | > 15.3/2 = 7.65; true; |
| /= | not equal | > 15.3/2 /= 7.65; false; |
| < | less than | > 2**5 < 30; false; |
| > | greater than | > 2**5 > 30; true; |
| <= | less than or equal | > 2**5 < = 32; true; |
| >= | greater than or equal | > 2**5 > = 32; true; |
| Operator | Description | Example |
| and | true if both expressions are true; false if either or both are false | > (5>4) and(7<9); true; > (5>4) and(7>9); false; > (5<4) and(7<9); false; > (5<4) and(7>9); false; |
| or | true if either or both expressions are true; false only if both are false | > (5>4) or(7<9); true; > (5>4) or(7>9); true; > (5<4) or(7<9); true; > (5<4) or(7>9); false; |
| not | true if expression is false; false if expression is true | > not(5>4); false; > not(5<4); true; |
| impl | logical implication. false if left expression is true and second is false; otherwise true | > (5>4) impl(7<9); true; > (5>4) impl(7>9); false; > (5<4) impl(7<9); true; > (5<4) impl(7>9); true; |
| = | logical equivalence. true if both expressions are true or both false; false if one expression is true and other is false | > (5>4) = (7<9); true; > (5>4) = (7>9); false; > (5<4) = (7<9); false; > (5<4) = (7>9); true; |
| iff | if and only if (same as logical equivalence) | > (5>4) = (7<9); true; > (5>4) = (7>9); false; > (5<4) = (7<9); false; > (5<4) = (7>9); true; |
| Operator | Description | Example |
| forall | true if condition is true for all values in the set or tuple (Universal Quantifier) |
> forall x in {1..5} | x < 5; false; > forall x in [1..5] | x < 5; false; |
| exists | true if condition is true for at least one value in the set or tuple (Existential Quantifier) |
> exists x in {1..5} | x < 5; true; > exists x in [1..5] | x < 5; true; |
| choose | returns a value from the set or tuple for which the condition is true or OM if there are none for which it's true |
> choose x in {1..5} | x < 5; 2; > choose x in [1..5] | x < 5; 4; |
| Operator | Description | Example |
| union + |
set of all elements that are in either or both sets | > {1..5} union {3,4}; {2,1,5,4,3}; |
| inter * |
set of all elements that are in both sets | > {1..5} inter {3,4}; {4,3}; |
| - | set of all elements in the first set that are not in the second set | > {1..5} - {3,4}; {2,1,5}; |
| = | true if all elements of first set are in second set and all elements of the second set are in the first | > {1..5} = {3,4}; false; |
| /= | true if either set contains at least one element that is not in the other set | > {1..5} /= {3,4}; true; |
| in notin |
"in" is true if the given element is in the set "notin" is true if the given element is not in the set |
> x := 3; > S := {2,3,5,7,11}; > x in S; true; > x notin S; false; |
| arb | returns an arbitrary element of the set | > S := {2,3,5,7,11}; > arb(S); 3; > arb(S); 11; |
| forall exists choose |
See Above (Predicate Operators) | |
| # | number of elements in the set | > S := {2,3,5,7,11}; > #(S); 5; |
| % | causes a binary operation to be performed on all elements of the set. e.g. %+ means add up the elements, %* means multiply them all together | > %+{1..5}; 15; > 5%+{1..5}; 20; > %*{1..5}; 120; > 5%*{1..5}; 600; |
| with | insert the given element into the set | > S := {1..5}; > x := 17; > S2 := S with x; > S2; {3,4,17,5,1,2}; |
| less | remove the given element from the set | > S := {1..5}; > x := 4; > S2 := S less x; > S2; {3,5,1,2}; |
| take from | remove an arbitrary element from the set and assign it to the given variable | > S := {1..5}; take x from S; > S; {1,3,5,4}; > x; 2; |
| subset | true if first set is a subset of second set |
> S1 := {1..5}; > S2 := {3,5}; > S3 := {}; > S1 subset S2; false; > S2 subset S1; true; > S3 subset S1; true; |
| Operator | Description | Example |
| + | concatenates two tuples | > [1..5]+[3,4]; [1,2,3,4,5,3,4]; |
| * | repeats the components of the tuple | > 3*[3,4]; [3,4,3,4,3,4]; |
| = | true if two tuples have same number of components and every component of the first tuple is in the second at the same index | > [1..5] = [3,4]; false; |
| /= | true if two tuples have different number of components or if some component of the first tuple is not in the second tuple at the same index | > [1..5] /= [3,4]; true; |
| in notin |
"in" is true if the given element is in the tuple "notin" is true if the given element is not in the tuple |
> x := 3; > S := [2,3,5,7,11]; > x in S; true; > x notin S; false; |
| arb | returns an arbitrary component of the tuple | > T := [2,3,5,7,11]; > arb(T); 7; > arb(T); 2; |
| forall exists choose |
See Above (Predicate Operators) | |
| # | index of the last non-OM component if all components are "defined," then it's the number of components |
> T := [2,3,5,7,11]; > #(T); 5; > T := [2,OM,5,7,OM]; > #(T); 4; |
| % | causes a binary operation to be performed on all components of the tuple. e.g. %+ means add up the components, %* means multiply them all together | > %+[1..5]; 15; > 5%+[1..5]; 20; > %*[1..5]; 120; > 5%*[1..5]; 600; |
| with | insert the given component into the tuple at the end | > T := [1..5]; > x := 17; > T2 := T with x; > T2; [1,2,3,4,5,17}; |
| take fromb | remove one component from the beginning of the tuple and assign it to the given variable | > T := [1..5]; take x from T; > T; [2,3,4,5]; > x; 1; |
| take from | same as take fromb | See Above |
| take frome | remove one component from the end of the tuple and assign it to the given variable | > T := [1..5]; take x from T; > T; [1,2,3,4]; > x; 5; |