module Types: sig endexception Type_error of string * Location.location
types module to signal a type error
in the input file.val equals : Abstract.eva_type -> Abstract.eva_type -> bool
equals t1 t2
Returns whether the 2 given terms t1 and t2 are equal.
Note: We make no differences between user and base types,
i.e. USERTYPE s and BASETYPE s are considered equal.
EVA_CONS and EVA_APP,
components of various types are allowed in LAEVA
(provided they respect the signature of the function symbol in EVA_APP)
and not in the abstract syntax,
where all the components of a tuple must have type EVA_NUMBER
(see Abstract.eva_type.
We provide here two function for type checking which correspond to each of the discipline:
Types.type_lterm_laeva which conforms to the LAEVA discipline,
and checks in EVA_APP terms the type of the arguments againts the declared
signature. Types.type_lterm which conforms to the disipline of the abstract syntax.
It must be call after term conversion and type coercion.val type_lterm : Symbols.eva_symbol_list -> Abstract.eva_lterm -> Abstract.eva_typetype_lterm sl t
checks that the given located term t is well typed
wrt to the given symbol list sl
according to the abstract syntax type discipline (see remark above):EVA_APP(c, args), the terms of args must all have type EVA_NUMBEREVA_CONS(t, l), t must have type EVA_NUMBEREVA_CRYPT(a, k, t), a must have type EVA_SALGO and
k and t must have type EVA_NUMBER.Type_error if the given term slslsl.Type_error if the given term contains alias symbols
or some leaf symbol is not conform to symbol list sl.t.
Note: the term t must NOT contain alias symbols
Note: this function should not be applied directly
to terms obtained after parsing EVA protocol spec.
Translator.convert_leterm (Translator.check_lterm)
and Types.coerce_lterm should be applied first.
val type_lterm_laeva : Symbols.eva_symbol_list -> Abstract.eva_lterm -> Abstract.eva_typetype_lterm_laeva sl t
checks the typing of the given located term t
wrt to the given symbol list sl,
according to the type discipline of LAEVA (aka concrete syntax)
which is less resctrictive than the discipline for the abstract syntax
(see remark above):EVA_APP(c, args),
the type of the terms of args must follow the declared signature of c,EVA_CONS(t, l), the type of t is not checked.EVA_CRYPT(a, k, t), a must have type EVA_SALGO, the
types of k and t are not checked.Translator.convert_lterm,
and not yet casted,
for conformity of terms against
the type declaration of function symbols.Type_error if the given term slslsl as described above.Type_error if the given term contains alias symbols
or some leaf symbol is not conform to the symbol list sl.t.
Note: the term must NOT contain alias symbols
Note: this function should not be applied directly
to terms obtained after parsing EVA protocol spec.
Translator.convert_leterm (optionaly Translator.check_lterm)
should be applied first.
Note: this function will likely fail when
applied to coerced located terms as returned by
Types.coerce_lterm (hence well typed terms wrt EVA semantics).
val coerce_lterm : Symbols.eva_symbol_list -> Abstract.eva_lterm -> Abstract.eva_ltermcoerce_lterm sl t
typechecks the given located term t
wrt the given symbol list sl
and casts it to the type EVA_NUMBER (see Abstract.eva_type,Type_error if the given term contains symbols not declared in sl
or is not well formed (arity) according sl
or is not well typed according to sl.Type_error if some leaf symbol
in the given term t is not conform to symbol list sl.
Note: the symbols in the term t must be conform to
the entries in symbol list sl, in particular
this function should not be applied directly
to terms obtained after parsing EVA protocol spec,
see Translator.convert_lterm and Translator.check_lterm.
val descend_coerce_lterm : Symbols.eva_symbol_list -> Abstract.eva_lterm -> Abstract.eva_ltermval cast : Abstract.eva_lterm -> Abstract.eva_type -> Abstract.eva_ltermcast_term t tyt a located termty an EVA typet by applying
the appropriate coercion function.
NB: the coercion is not applied recursively.val coerce_spec : Symbols.eva_symbol_list -> Abstract.eva_spec -> Abstract.eva_speccoerce_spec sl sp
applies Types.coerce_lterm sl
to every term of the given spec sp,
except in (codomains of) sessions.
Note: that the session (i.e. substitutions)\
do not need to be coerced because they are applied
to coerced (typed) variable.