123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318(**************************************************************************)(* *)(* This file is part of WP plug-in of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat a l'energie atomique et aux energies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)(* -------------------------------------------------------------------------- *)(* --- Engine Signature --- *)(* -------------------------------------------------------------------------- *)(** Generic Engine Signature *)openFormatopenPlibtypeop=|Opofstring(** Infix or prefix operator *)|Assocofstring(** Left-associative binary operator (like + and -) *)|Callofstring(** Logic function or predicate *)typelink=|F_callofstring(** n-ary function *)|F_substofstring*string(** n-ary function with substitution
first value is the link name, second is the
substitution (e.g. "foo(%1,%2)") *)|F_leftofstring(** 2-ary function left-to-right + *)|F_rightofstring(** 2-ary function right-to-left + *)|F_listofstring*string(** n-ary function with (cons,nil) constructors *)|F_assocofstring(** associative infix operator *)|F_bool_propofstring*string(** Has a bool and prop version *)typecallstyle=|CallVar(** Call is [f(x,...)] ; [f()] can be written [f] *)|CallVoid(** Call is [f(x,...)] ; in [f()], [()] is mandatory *)|CallApply(** Call is [f x ...] *)typemode=|Mpositive(** Current scope is [Prop] in positive position. *)|Mnegative(** Current scope is [Prop] in negative position. *)|Mterm(** Current scope is [Term]. *)|Mterm_int(** [Int] is required but actual scope is [Term]. *)|Mterm_real(** [Real] is required but actual scope is [Term]. *)|Mint(** Current scope is [Int]. *)|Mreal(** Current scope is [Real]. *)typeflow=Flow|Atomtypecmode=Cprop|Ctermtypeamode=Aint|Arealtypepmode=Positive|Negative|Booleantype('x,'f)ftrigger=|TgAny|TgVarof'x|TgGetof('x,'f)ftrigger*('x,'f)ftrigger|TgSetof('x,'f)ftrigger*('x,'f)ftrigger*('x,'f)ftrigger|TgFunof'f*('x,'f)ftriggerlist|TgPropof'f*('x,'f)ftriggerlisttype('t,'f,'c)ftypedef=|Tabs|Tdefof't|Trecof('f*'t)list|Tsumof('c*'tlist)listtypescope=[`Auto|`Unfolded|`Definedofstring]moduletypeEnv=sigtypettypetermvalcreate:unit->tvalcopy:t->tvalclear:t->unitvalused:t->string->boolvalfresh:t->sanitizer:('a->string)->?suggest:bool->'a->stringvaldefine:t->string->term->unitvalunfold:t->term->unitvalshared:t->term->boolvalshareable:t->term->boolvalset_indexed_vars:t->unitvaliter:(string->term->unit)->t->unitend(** Generic Engine Signature *)classtypevirtual['z,'adt,'field,'logic,'tau,'var,'term,'env]engine=object(** {3 Linking} *)methodsanitize:string->stringmethodvirtualdatatype:'adt->stringmethodvirtualfield:'field->stringmethodvirtuallink:'logic->link(** {3 Global and Local Environment} *)methodenv:'env(** Returns a fresh copy of the current environment. *)methodset_env:'env->unit(** Set environment. *)methodlookup:'term->scope(** Term scope in the current environment. *)methodscope:'env->(unit->unit)->unit(** Calls the continuation in the provided environment.
Previous environment is restored after return. *)methodlocal:(unit->unit)->unit(** Calls the continuation in a local copy of the environment.
Previous environment is restored after return, but allocators
are left unchanged to enforce on-the-fly alpha-conversion. *)methodglobal:(unit->unit)->unit(** Calls the continuation in a fresh local environment.
Previous environment is restored after return. *)methodbind:'var->stringmethodfind:'var->string(** {3 Types} *)methodt_int:stringmethodt_real:stringmethodt_bool:stringmethodt_prop:stringmethodt_atomic:'tau->boolmethodpp_array:'tauprinter(** For [Z->a] arrays *)methodpp_farray:'tauprinter2(** For [k->a] arrays *)methodpp_tvar:intprinter(** Type variables. *)methodpp_datatype:'adt->'taulistprintermethodpp_tau:'tauprinter(** Without parentheses. *)methodpp_subtau:'tauprinter(** With parentheses if non-atomic. *)(** {3 Current Mode}
The mode represents the expected type for a
term to printed. A requirement for all term printers in the
engine is that current mode must be correctly set before call.
Each term printer is then responsible for setting appropriate
modes for its sub-terms.
*)methodmode:modemethodwith_mode:mode->(mode->unit)->unit(** Calls the continuation with given mode for sub-terms.
The englobing mode is passed to continuation and then restored. *)methodop_scope:amode->stringoption(** Optional scoping post-fix operator when entering arithmetic mode. *)(** {3 Primitives} *)methode_true:cmode->string(** ["true"] *)methode_false:cmode->string(** ["false"] *)methodpp_int:amode->'zprintermethodpp_real:Q.tprinter(** {3 Variables} *)methodpp_var:stringprinter(** {3 Calls}
These printers only applies to connective, operators and
functions that are morphisms {i w.r.t} current mode.
*)methodcallstyle:callstylemethodpp_fun:cmode->'logic->'termlistprintermethodpp_apply:cmode->'term->'termlistprinter(** {3 Arithmetics Operators} *)methodop_real_of_int:opmethodop_add:amode->opmethodop_sub:amode->opmethodop_mul:amode->opmethodop_div:amode->opmethodop_mod:amode->opmethodop_minus:amode->opmethodpp_times:formatter->'z->'term->unit(** Defaults to [self#op_minus] or [self#op_mul] *)(** {3 Comparison Operators} *)methodop_equal:cmode->opmethodop_noteq:cmode->opmethodop_eq:cmode->amode->opmethodop_neq:cmode->amode->opmethodop_lt:cmode->amode->opmethodop_leq:cmode->amode->opmethodpp_equal:'termprinter2methodpp_noteq:'termprinter2(** {3 Arrays} *)methodpp_array_cst:formatter->'tau->'term->unit(** Constant array ["[v...]"]. *)methodpp_array_get:formatter->'term->'term->unit(** Access ["a[k]"]. *)methodpp_array_set:formatter->'term->'term->'term->unit(** Update ["a[k <- v]"]. *)(** {3 Records} *)methodpp_get_field:formatter->'term->'field->unit(** Field access. *)methodpp_def_fields:('field*'term)listprinter(** Record construction. *)(** {3 Logical Connectives} *)methodop_not:cmode->opmethodop_and:cmode->opmethodop_or:cmode->opmethodop_imply:cmode->opmethodop_equiv:cmode->op(** {3 Conditionals} *)methodpp_not:'termprintermethodpp_imply:formatter->'termlist->'term->unitmethodpp_conditional:formatter->'term->'term->'term->unit(** {3 Binders} *)methodpp_forall:'tau->stringlistprintermethodpp_exists:'tau->stringlistprintermethodpp_lambda:(string*'tau)listprinter(** {3 Bindings} *)methodshared:'term->boolmethodshareable:'term->boolmethodsubterms:('term->unit)->'term->unitmethodpp_let:formatter->pmode->string->'term->unit(** {3 Terms} *)methodis_atomic:'term->bool(** Sub-terms that require parentheses.
Shared sub-terms are detected on behalf of this method. *)methodpp_flow:'termprinter(** Printer with shared sub-terms printed with their name and
without parentheses. *)methodpp_atom:'termprinter(** Printer with shared sub-terms printed with their name and
within parentheses for non-atomic expressions. Additional
scope terminates the expression when required (typically
for Coq). *)methodpp_repr:'termprinter(** Raw representation of a term, as it is. This is where you should hook
a printer to keep sharing, parentheses, and such. *)(** {3 Top Level} *)methodpp_term:'termprinter(** Prints in {i term} mode.
Default uses [self#pp_shared] with mode [Mterm] inside an [<hov>] box. *)methodpp_prop:'termprinter(** Prints in {i prop} mode.
Default uses [self#pp_shared] with mode [Mprop] inside an [<hv>] box. *)methodpp_expr:'tau->'termprinter(** Prints in {i term}, {i arithmetic} or {i prop} mode with
respect to provided type. *)methodpp_sort:'termprinter(** Prints in {i term}, {i arithmetic} or {i prop} mode with
respect to the sort of term. Boolean expression that also have a
property form are printed in [Mprop] mode. *)end