module Ptree:sig..end
The module provides datatypes for WhyML parse trees.
These datatypes are produced by the WhyML parser module Parser.
They can be alternatively produced via OCaml code, and processed later
on by typing module Typing. See also Section 4.9. "ML Programs"
of the documentation.
type attr =
| |
ATstr of |
| |
ATpos of |
attributes, with a specific case for a source location
type ident = {
|
id_str : |
|
id_ats : |
|
id_loc : |
}
identifiers, with attributes and a source location
type qualid =
| |
Qident of |
| |
Qdot of |
qualified identifiers
type pty =
| |
PTtyvar of |
(* | type variable | *) |
| |
PTtyapp of |
(* | type constructor, possibly with arguments, e.g., | *) |
| |
PTtuple of |
(* | tuples, e.g., | *) |
| |
PTref of |
(* | reference type, e.g., | *) |
| |
PTarrow of |
(* | arrow type, e.g., | *) |
| |
PTscope of |
(* | opening scope locally, e.g., | *) |
| |
PTparen of |
(* | parenthesised type | *) |
| |
PTpure of |
(* | purify a type | *) |
type expressions
"ghost" modifier
typeghost =bool
type pattern = {
|
pat_desc : |
|
pat_loc : |
}
Patterns, equipped with a source location
type pat_desc =
| |
Pwild |
(* | wildcard, that is "_" | *) |
| |
Pvar of |
(* | variable as a pattern | *) |
| |
Papp of |
(* | constructor pattern, e.g., | *) |
| |
Prec of |
(* | record pattern | *) |
| |
Ptuple of |
(* | tuple pattern | *) |
| |
Pas of |
(* | as-pattern, e.g., | *) |
| |
Por of |
(* | or-pattern | *) |
| |
Pcast of |
(* | type cast | *) |
| |
Pscope of |
(* | open scope locally | *) |
| |
Pparen of |
(* | parenthesised pattern | *) |
| |
Pghost of |
(* | explicitly ghost pattern | *) |
typebinder =Loc.position * ident option * ghost * pty option
typeparam =Loc.position * ident option * ghost * pty
parameter as 4-uple (loc,id,ghost,type) to represent
"ghost? id? : type".
type term = {
|
term_desc : |
|
term_loc : |
}
Terms, equipped with a source location
type term_desc =
| |
Ttrue |
(* | the true proposition | *) |
| |
Tfalse |
(* | the false proposition | *) |
| |
Tconst of |
(* | constant literals | *) |
| |
Tident of |
(* | identifiers | *) |
| |
Tasref of |
(* | identifier as reference, e.g., | *) |
| |
Tidapp of |
(* | (first-order) application of a logic identifier to a list of terms | *) |
| |
Tapply of |
(* | curried application, of a term to a term | *) |
| |
Tinfix of |
(* | application of a binary operation in an infix fashion, allowing chaining.
For example, | *) |
| |
Tinnfix of |
(* | application of a binary operation in an infix style, but without chaining | *) |
| |
Tbinop of |
(* | application of a binary logic connective, in an infix fashion, allowing
chaining. For example, | *) |
| |
Tbinnop of |
(* | application of a binary logic connective, but without chaining | *) |
| |
Tnot of |
(* | logic negation | *) |
| |
Tif of |
(* | if-expression | *) |
| |
Tquant of |
(* | quantified formulas. The third argument is a list of triggers. | *) |
| |
Teps of |
(* |
| *) |
| |
Tattr of |
(* | term annotated with an attribute | *) |
| |
Tlet of |
(* | let-expression | *) |
| |
Tcase of |
(* | pattern-matching | *) |
| |
Tcast of |
(* | type casting | *) |
| |
Ttuple of |
(* | tuples | *) |
| |
Trecord of |
(* | record expressions | *) |
| |
Tupdate of |
(* | record update expression | *) |
| |
Tscope of |
(* | local scope | *) |
| |
Tat of |
(* | "at" modifier. The "old" modifier is a particular case with
the identifier | *) |
typeinvariant =term list
typevariant =(term * qualid option) list
Variant for both loops and recursive functions. The option identifier is an optional ordering predicate
typepre =term
Precondition
typepost =Loc.position * (pattern * term) list
Normal postconditions
typexpost =Loc.position * (qualid * (pattern * term) option) list
Exceptional postconditions
type spec = {
|
sp_pre : |
(* | preconditions | *) |
|
sp_post : |
(* | normal postconditions | *) |
|
sp_xpost : |
(* | exceptional postconditions | *) |
|
sp_reads : |
(* | "reads" clause | *) |
|
sp_writes : |
(* | "writes" clause | *) |
|
sp_alias : |
(* | "alias" clause | *) |
|
sp_variant : |
(* | variant for recursive functions | *) |
|
sp_checkrw : |
(* | should the reads and writes clauses be checked against the given body? | *) |
|
sp_diverge : |
(* | may the function diverge? | *) |
|
sp_partial : |
(* | is the function partial? | *) |
}
Contract
type expr = {
|
expr_desc : |
|
expr_loc : |
}
Expressions, equipped with a source location
type expr_desc =
| |
Eref |
(* | built-in operator | *) |
| |
Etrue |
(* | Boolean literal | *) |
| |
Efalse |
(* | Boolean literal | *) |
| |
Econst of |
(* | Constant literals | *) |
| |
Eident of |
(* | Variable identifier | *) |
| |
Easref of |
(* | identifier as reference, e.g., | *) |
| |
Eidapp of |
(* | Uncurried application of a function identifier to a list of arguments | *) |
| |
Eapply of |
(* | Curried application | *) |
| |
Einfix of |
(* | application of a binary function identifier, in an infix fashion, allowing
chaining, e.g., | *) |
| |
Einnfix of |
(* | application of a binary function, but without chaining | *) |
| |
Elet of |
(* |
| *) |
| |
Erec of |
(* | Local definition of function(s), possibly mutually recursive | *) |
| |
Efun of |
(* | Anonymous function | *) |
| |
Eany of |
(* | "any params : ty <spec>": abstract expression with a specification, generating a VC for existence | *) |
| |
Etuple of |
(* | Tuple of expressions | *) |
| |
Erecord of |
(* | Record expression, e.g., | *) |
| |
Eupdate of |
(* | Record update, e.g., | *) |
| |
Eassign of |
(* | Assignment, of a mutable variable (no qualid given) or of a record field (qualid
given). Assignments are possibly in parallel, e.g., | *) |
| |
Esequence of |
(* | Sequence of two expressions, the first one being supposed of type unit | *) |
| |
Eif of |
(* |
| *) |
| |
Ewhile of |
(* |
| *) |
| |
Eand of |
(* | lazy conjunction | *) |
| |
Eor of |
(* | lazy disjunction | *) |
| |
Enot of |
(* | Boolean negation | *) |
| |
Ematch of |
(* | match expression, including both regular patterns and exception patterns (those lists cannot be both empty) | *) |
| |
Eabsurd |
(* |
| *) |
| |
Epure of |
(* | turns a logical term into a pure expression, e.g., | *) |
| |
Eidpur of |
(* | promotes a logic symbol in programs, e.g., | *) |
| |
Eraise of |
(* | raise an exception, possibly with an argument | *) |
| |
Eexn of |
(* | local declaration of an exception, e.g., | *) |
| |
Eoptexn of |
(* | local declaration of an exception, implicitly captured. Used by Why3 for handling
| *) |
| |
Efor of |
(* | "for" loops | *) |
| |
Eassert of |
(* |
| *) |
| |
Escope of |
(* | open scope locally, e.g., | *) |
| |
Elabel of |
(* | introduction of a label, e.g., | *) |
| |
Ecast of |
(* | cast an expression to a given type, e.g., | *) |
| |
Eghost of |
(* | forces an expression to be ghost, e.g., | *) |
| |
Eattr of |
(* | attach an attribute to an expression | *) |
Expression kinds
typereg_branch =pattern * expr
A regular match branch
typeexn_branch =qualid * pattern option * expr
An exception match branch
typefundef =ident * ghost * Expr.rs_kind * binder list *
pty option * pattern * Ity.mask * spec * expr
Local function definition
type field = {
|
f_loc : |
|
f_ident : |
|
f_pty : |
|
f_mutable : |
|
f_ghost : |
}
record fields
type type_def =
| |
TDalias of |
(* | alias type | *) |
| |
TDalgebraic of |
(* | algebraic type | *) |
| |
TDrecord of |
(* | record type | *) |
| |
TDrange of |
(* | integer type in given range | *) |
| |
TDfloat of |
(* | floating-point type with given exponent and precision | *) |
Type definition body
type visibility =
| |
Public |
|||
| |
Private |
|||
| |
Abstract |
(* | = Private + ghost fields | *) |
type type_decl = {
|
td_loc : |
|||
|
td_ident : |
|||
|
td_params : |
|||
|
td_vis : |
(* | visibility, for records only | *) |
|
td_mut : |
(* | mutability, for records or abstract types | *) |
|
td_inv : |
(* | invariant, for records only | *) |
|
td_wit : |
(* | witness for the invariant | *) |
|
td_def : |
}
type logic_decl = {
|
ld_loc : |
|
ld_ident : |
|
ld_params : |
|
ld_type : |
|
ld_def : |
}
A single declaration of a function or predicate
type ind_decl = {
|
in_loc : |
|
in_ident : |
|
in_params : |
|
in_def : |
}
A single declaration of an inductive predicate
type metarg =
| |
Mty of |
| |
Mfs of |
| |
Mps of |
| |
Max of |
| |
Mlm of |
| |
Mgl of |
| |
Mval of |
| |
Mstr of |
| |
Mint of |
Arguments of "meta" declarations
type clone_subst =
| |
CStsym of |
| |
CSfsym of |
| |
CSpsym of |
| |
CSvsym of |
| |
CSxsym of |
| |
CSprop of |
| |
CSaxiom of |
| |
CSlemma of |
| |
CSgoal of |
The possible "clone" substitution elements
type decl =
| |
Dtype of |
(* | Type declaration | *) |
| |
Dlogic of |
(* | Collection of "function"s and "predicate"s, mutually recursively declared | *) |
| |
Dind of |
(* | An inductive or co-inductive predicate | *) |
| |
Dprop of |
(* | Propositions: "lemma" or "goal" or "axiom" | *) |
| |
Dlet of |
(* | Global program variable or function | *) |
| |
Drec of |
(* | set of program functions, defined mutually recursively | *) |
| |
Dexn of |
(* | Declaration of global exceptions | *) |
| |
Dmeta of |
(* | Declaration of a "meta" | *) |
| |
Dcloneexport of |
(* | "clone export" | *) |
| |
Duseexport of |
(* | "use export" | *) |
| |
Dcloneimport of |
(* | "clone import ... as ..." | *) |
| |
Duseimport of |
(* | "use import ... as ..." | *) |
| |
Dimport of |
(* | "import" | *) |
| |
Dscope of |
(* | "scope" | *) |
top-level declarations
val sexp_of_mlw_file : 'a -> 'b
val mlw_file_of_sexp : 'a -> 'b
type mlw_file =
| |
Modules of |
(* | a list of modules containing lists of declarations | *) |
| |
Decls of |
(* | a list of declarations outside any module | *) |