Research Article

Lolisa: Formal Syntax and Semantics for a Subset of the Solidity Programming Language in Mathematical Tool Coq

Algorithm 2

Formal version of Algorithm A written in Lolisa.
Coq 8.8;
Definition Example : = 
 (Fun public payable (Efun (Some example) Tundef) pnil nil);;
  (Var (Some public) Evar (Some index) Tuint));;
  (Assignv (Evar (Some index) Tuint)
  (Econst (@Vmap Iaddress Tuint indexes (Mstr_id Iaddress msg (sender ∼>>\\\)) None));;
   (Var (Some public) (Evar (Some open) Tuint));;
   (Var (Some public) (Evar (Some close) Tuint));;
   (Var (Some public) (Evar (Some quota) Tuint));;
   …
   (If (Econst (@Vmap Iaddress Tbool priviledges
    (Mstr_id Iaddress msg (sender ∼>>\\\)) None))
   ((Assignv (Evar (Some open) Tuint) (Evar (Some privilegeOpen) Tuint));;
    (Assignv (Evar (Some close) Tuint) (Evar (Some privilegeClose) Tuint));;
   …;; nil)
   ((Assignv (Evar (Some open) Tuint) (Evar (Some ordinaryOpen) Tuint));;
    (Assignv (Evar (Some close) Tuint) (Evar (Some ordinaryClose) Tuint));;
   …;; nil)
   (If ((Evar (Some now) Tuint) (<) (Evar (Some open) Tuint) (||)
   (Evar (Some now) Tuint) (>) (Evar (Some close) Tuint))
   (Throw;; nil) (Snil;; nil));;
   (If ((Evar (Some subscription) Tuint) (+) (Evar (Some rate) Tuint) (>)
    TOKEN_TARGET_AMOUNT)
   (Throw;; nil) (Snil;; nil));;
   …
   (If ((Econst (Vfield Tuint (Fstruct _0xmsg msg) (values ∼> \\) None))
   (<=) (Evar (Some finalLimit) Tuint))
 ((Fun_call (Econst (Vfield (Tfid (Some safe)) (Fstruct _0xaddress safe) (send ∼> \\) None))
  (pccons (Econst (Vfield Tuint (Fstruct _0xmsg msg) (values ∼> \\) None)) pcnil));;
   (Assignv (Econst (@Vmap Iuint Tuint deposits (Mvar_id Iuint index) None))
    ((Econst (Vfield Tuint (Fstruct _0xmsg msg) (values ∼> \\) None)) (+)
    ((Econst (@Vmap Iuint Tuint deposits (Mar_id Iuint index) None))));;
  (Assignv (Evar (Some subscription) Tuint) ((Econst Vfield Tuint (Fstruct _0xmsg msg)
   (values ∼> \\) None)) (+) (Evar (Some finalLimit) Tuint) (/)
   (Econst (Vint (INT I64 Unsigned 1000 000 000 000 000 000))) (x)
   (Evar (Some rate) Tuint))));; nil) …;; nil);; nil.