diff --git a/docs/alpha/michelson.rst b/docs/alpha/michelson.rst index 13082d1781277e56c7daabd2f3ace5246d760815..9aeb0c6b472e20a93716e180b0cbcda6daff97d7 100644 --- a/docs/alpha/michelson.rst +++ b/docs/alpha/michelson.rst @@ -651,130 +651,16 @@ A detailed description of the following instructions can be found in the `intera Operations on maps ~~~~~~~~~~~~~~~~~~ -- ``EMPTY_MAP 'key 'val``: Build a new, empty map from keys of a - given type to values of another given type. - - The ``'key`` type must be comparable (the ``COMPARE`` primitive must - be defined over it). - -:: - - :: 'S -> map 'key 'val : 'S - - > EMPTY_MAP _ _ / S => {} : S - - -- ``GET``: Access an element in a map, returns an optional value to be - checked with ``IF_SOME``. - -:: - - :: 'key : map 'key 'val : 'S -> option 'val : 'S - - > GET / x : {} : S => None : S - > GET / x : { Elt k v ; } : S => opt_y : S - iff COMPARE / x : k : [] => 1 : [] - where GET / x : { } : S => opt_y : S - > GET / x : { Elt k v ; } : S => Some v : S - iff COMPARE / x : k : [] => 0 : [] - > GET / x : { Elt k v ; } : S => None : S - iff COMPARE / x : k : [] => -1 : [] - -- ``MEM``: Check for the presence of a binding for a key in a map. - -:: - - :: 'key : map 'key 'val : 'S -> bool : 'S - - > MEM / x : {} : S => false : S - > MEM / x : { Elt k v ; } : S => r : S - iff COMPARE / x : k : [] => 1 : [] - where MEM / x : { } : S => r : S - > MEM / x : { Elt k v ; } : S => true : S - iff COMPARE / x : k : [] => 0 : [] - > MEM / x : { Elt k v ; } : S => false : S - iff COMPARE / x : k : [] => -1 : [] - -- ``UPDATE``: Assign or remove an element in a map. - -:: - - :: 'key : option 'val : map 'key 'val : 'S -> map 'key 'val : 'S - - > UPDATE / x : None : {} : S => {} : S - > UPDATE / x : Some y : {} : S => { Elt x y } : S - > UPDATE / x : opt_y : { Elt k v ; } : S => { Elt k v ; } : S - iff COMPARE / x : k : [] => 1 : [] - where UPDATE / x : opt_y : { } : S => { } : S - > UPDATE / x : None : { Elt k v ; } : S => { } : S - iff COMPARE / x : k : [] => 0 : [] - > UPDATE / x : Some y : { Elt k v ; } : S => { Elt k y ; } : S - iff COMPARE / x : k : [] => 0 : [] - > UPDATE / x : None : { Elt k v ; } : S => { Elt k v ; } : S - iff COMPARE / x : k : [] => -1 : [] - > UPDATE / x : Some y : { Elt k v ; } : S => { Elt x y ; Elt k v ; } : S - iff COMPARE / x : k : [] => -1 : [] - -- ``GET_AND_UPDATE``: A combination of the ``GET`` and ``UPDATE`` instructions. - -:: - - :: 'key : option 'val : map 'key 'val : 'S -> option 'val : map 'key 'val : 'S - -This instruction is similar to ``UPDATE`` but it also returns the -value that was previously stored in the ``map`` at the same key as -``GET`` would. - -:: - - > GET_AND_UPDATE / x : None : {} : S => None : {} : S - > GET_AND_UPDATE / x : Some y : {} : S => None : { Elt x y } : S - > GET_AND_UPDATE / x : opt_y : { Elt k v ; } : S => opt_y' : { Elt k v ; } : S - iff COMPARE / x : k : [] => 1 : [] - where GET_AND_UPDATE / x : opt_y : { } : S => opt_y' : { } : S - > GET_AND_UPDATE / x : None : { Elt k v ; } : S => Some v : { } : S - iff COMPARE / x : k : [] => 0 : [] - > GET_AND_UPDATE / x : Some y : { Elt k v ; } : S => Some v : { Elt k y ; } : S - iff COMPARE / x : k : [] => 0 : [] - > GET_AND_UPDATE / x : None : { Elt k v ; } : S => None : { Elt k v ; } : S - iff COMPARE / x : k : [] => -1 : [] - > GET_AND_UPDATE / x : Some y : { Elt k v ; } : S => None : { Elt x y ; Elt k v ; } : S - iff COMPARE / x : k : [] => -1 : [] - -- ``MAP body``: Apply the body expression to each element of a map. The - body sequence has access to the stack. - -:: - - :: (map 'key 'val) : 'A -> (map 'key 'b) : 'A - iff body :: [ (pair 'key 'val) : 'A -> 'b : 'A ] - - > MAP body / {} : S => {} : S - > MAP body / { Elt k v ; } : S => { Elt k v' ; } : S'' - where body / Pair k v : S => v' : S' - and MAP body / { } : S' => { } : S'' - -- ``ITER body``: Apply the body expression to each element of a map. - The body sequence has access to the stack. - -:: - - :: (map 'elt 'val) : 'A -> 'A - iff body :: [ (pair 'elt 'val : 'A) -> 'A ] - - > ITER body / {} : S => S - > ITER body / { Elt k v ; } : S => ITER body / { } : S' - iff body / (Pair k v) : S => S' - -- ``SIZE``: Get the cardinality of the map. - -:: - - :: map 'key 'val : 'S -> nat : 'S +A detailed description of the following instructions can be found in the `interactive Michelson reference manual `__. - > SIZE / {} : S => 0 : S - > SIZE / { _ ; } : S => 1 + s : S - where SIZE / { } : S => s : S +- ``EMPTY_MAP 'key 'val``: Build a new, empty map (`documentation `__). +- ``GET``: Access an element in a map (`documentation `__). +- ``MEM``: Check for the presence of a binding for a key in a map (`documentation `__). +- ``UPDATE``: Add, update, or remove an element in a map (`documentation `__). +- ``GET_AND_UPDATE``: A combination of the ``GET`` and ``UPDATE`` instructions (`documentation `__). +- ``MAP body``: Apply the body expression to each element of a map (`documentation `__). +- ``ITER body``: Apply the body expression to each element of a map (`documentation `__). +- ``SIZE``: Get the cardinality of the map (`documentation `__). Operations on ``big_maps``