if expression |
if conditional expression then expression else expression
if conditional expression then expression elseif conditional expression then expression ... else expression
|
if 3 mod 2 = 0 then <even> else <odd>
if 10 mod 15 = 0 then <FizzBuzz> elseif 10 mod 5 = 0 then <Buzz> elseif 10 mod 3 = 0 then <Fizz> else 10
|
cases expression |
cases expression: pattern,..,pattern -> expression,...,pattern,...,pattern -> expression, others -> expression end
|
cases mk_('+', 1, 2): mk_('+', x, y) -> x + y, mk_('-', x, y) -> x - y, others -> <ERROR> end
cases "03-123-4567": city^"-"^area^"-"^local -> mk_(city, area, local), others -> <ERROR> end
|
sequence |
sequence expression(nat expression) |
[0,2,4](2)
[0,2,4](10)
|
map |
map expression(expression) |
{0 |-> false, 1 |-> true}(0)
|
function (including lambda) |
function expression(expression,expression,...,expression) |
(lambda x:nat & x + 1)(2)
|
operation |
operation()
operation(expression,expression,...,expression)
|
inc()
add(2)
|
set |
{}
{expression,expression,...,expression}
|
{}
{1,2,3}
{1,2,{'3', nil}}
{1,...,10}
|
sequence |
[]
[expression,expression,...,expression]
"Strings"
|
[]
[1,2,3]
[1,2,['3', nil]]
"Strings"
"Str" = ['S', 't', 'r']
|
map |
{|->}
{expression |->expression ,expression |-> expression,...,expression |-> expression}
|
{|->}
{<apple> |-> 100, <orange> |-> 200, <cherry> |-> 150}
|
set |
{x * 2 | x in set {1, ... ,5}}
{x * 2 | x in set {1, ... ,5} & x mod 2 = 0}
{mk_(b1, b2, b1 and b2) | b1,b2 : bool}
|
sequence |
[x * 2 | x in set {1, ... ,5}]
[x * 2 | x in set {1, ... ,5} & x mod 2 = 0]
|
map |
{"0123456789"(i+1) |-> i | i in set {0,...,9}}
{"0123456789"(i+1) |-> i | i in set {0,...,9} & i mod 2 = 0}
|
membership |
in set |
T * set of T -> bool |
1 in set {1,2,3}
0 in set {1,2,3}
{1,2} in set {0, {1, 2}, 3}
|
non membership |
not in set |
T * set of T -> bool |
1 not in set {1,2,3}
0 not in set {1,2,3}
{1,2} not in set {0, {1, 2}, 3}
|
subset |
subset |
set of T * set of T -> bool |
{1,2} subset {1,2,3}
{1,2,3} subset {1,2,3}
{1,2,3} subset {1,2}
|
proper subset |
psubset |
set of T * set of T -> bool |
{1,2} psubset {1,2,3}
{1,2,3} psubset {1,2,3}
{1,2,3} psubset {1,2}
|
union |
union |
set of T * set of T -> set of T |
{1,2} union {2,3}
|
intersection |
inter |
set of T * set of T -> set of T |
{1,2} inter {2,3}
|
difference |
\ |
set of T * set of T -> set of T |
{1,2} \ {2,3}
|
cardinality (number of elements) |
card |
set of T -> nat |
card {1,...,10}
card {1, 2, nil}
card {}
|
distributed union |
dunion |
set of set of T -> set of T |
dunion {{1,2}, {2,3}}
dunion {{{1},2}, {2,3}}
|
distributed intersection |
dinter |
set of set of T -> set of T |
dinter {{1,2}, {2,3}}
dinter {{1,2, {3}}, {2,3}}
|
power set |
power |
set of T -> set of set of T |
power {1,2,3}
power {}
|
slice |
( ,..., ) |
seq of T * nat1 * nat1 -> T |
"Strings"(4,...,5)]
"Strings"(5,...,4)]
"Strings"(4,...,10)]
|
head element |
hd |
seq1 of T -> T |
hd [1,2,3]
hd "Strings"
|
tail element |
tl |
seq1 of T -> seq of T |
tl [1,2,3]
tl "Strings"
|
length |
len |
seq of T -> nat |
len [1,2,3,4,5]
len "Strings"
|
elements |
elems |
seq of T -> set of T |
elems [1,2,3,4,5]
elems "Strings"
|
indices |
inds |
seq of T -> set of nat1 |
inds [0,2,4]
inds "Strings"
|
reverse |
reverse |
seq of T -> seq of T |
reverse [0,2,4]
reverse "Strings"
|
concatenation |
^ |
seq of T * seq of T -> seq of T |
[0,2,4]^[1,3,5]
"Str"^"ings"
|
distributed concatenation |
conc |
seq of seq of T -> seq of T |
conc [[0,2,4],[1,3,5]]
conc ["Str","ings"]
|
overridng |
++ |
seq of T * map nat1 to T -> seq of T |
[0,2,4]++{2|->10}
"Your"++{1|->'H'}]
|
domain |
dom |
map T1 to T2 -> set of T1 |
dom {0 |-> false, 1 |-> true}
|
range |
rng |
map T1 to T2 -> set of T2 |
rng {0 |-> false, 1 |-> true}
|
union |
munion |
map T1 to T2 * map T1 to T2 -> map T1 to T2 |
{0 |-> false, 1 |-> true} munion {2 |-> false, 3 |-> true}
{0 |-> false, 1 |-> true} munion {1 |-> true, 2 |-> false}
{0 |-> false, 1 |-> true} munion {1 |-> false, 2 |-> false}
|
overriding |
++ |
map T1 to T2 * map T1 to T2 -> map T1 to T2 |
{0 |-> false, 1 |-> true} ++ {2 |-> false, 3 |-> true}
{0 |-> false, 1 |-> true} ++ {1 |-> false, 2 |-> false}
|
distributed union |
merge |
set of map T1 to T2 -> map T1 to T2 |
merge {{0 |-> false, 1 |-> true}, {2 |-> false, 3 |-> true}}
merge {{0 |-> false, 1 |-> true}, {1 |-> false, 2 |-> false}}
|
domain restriction |
<: |
set of T1 * map T1 to T2 -> map T1 to T2 |
{2,3} <: {0 |-> false, 1 |-> true, 2 |-> false, 3 |-> true}
|
domain exclusion |
<-: |
set of T1 * map T1 to T2 -> map T1 to T2 |
{2,3} <-: {0 |-> false, 1 |-> true, 2 |-> false, 3 |-> true}
|
range restriction |
:> |
map T1 to T2 * set of T2 -> map T1 to T2 |
{0 |-> false, 1 |-> true, 2 |-> false, 3 |-> true} :> {true, nil}
|
range exclusion |
:-> |
map T1 to T2 * set of T2 -> map T1 to T2 |
{0 |-> false, 1 |-> true, 2 |-> false, 3 |-> true} :-> {true, nil}
|
composition |
comp |
map T2 to T3 * map T1 to T2 -> map T1 to T3 |
{true|-><odd>, false|-><even>} comp {0 |-> false, 1 |-> true, 2 |-> false, 3 |-> true}
|
iteration |
** |
map T1 to T1 * nat -> map T1 to T1 |
{0 |-> 1, 1 |-> 2, 2 |-> 3, 3 |-> 3} ** 1
{0 |-> 1, 1 |-> 2, 2 |-> 3, 3 |-> 3} ** 2
{0 |-> 1, 1 |-> 2, 2 |-> 3, 3 |-> 3} ** 3
|
inverse |
inverse |
inmap T1 to T2 -> inmap T2 to T1 |
inverse {0 |-> '0', 1 |-> '1', 2 |-> '2'} |
Universal quantifier |
forall multiple bind,...,multiple bind & expression |
forall i in set {1,2,3} & i mod 4 <> 0
forall i in set {1,2,3} & i mod 2 <> 0
forall b1,b2:bool & b1 or b2
|
Existential quantifier |
exists multiple bind,...,multiple bind & expression |
exists i in set {1,2,3} & i mod 4 = 0
exists i in set {1,2,3} & i mod 2 = 0
exists b1,b2:bool & b1 and b2
|
Unique existential quantifier |
exists1 bind & expression |
exists1 i in set {1,2,3} & i mod 2 = 0
exists1 i in set {1,2,3} & i mod 2 <> 0
exists1 mk_(b1,b2):bool*bool & b1 and b2
|