Commit 58586dac authored by Andrei Paskevich's avatar Andrei Paskevich

Expr: rename 'psymbol' to 'rsymbol' (routine)

1. We really need to distinguish first-class functions (mappings),
pure logical functions (functions and predicates), and program
functions (routines).

2. The ps_ prefix is already used for predicate symbols.

3. 'psymbol' and 'pvsymbol' are too similar.
parent f202ddd0
This diff is collapsed.
......@@ -42,7 +42,7 @@ type dpattern = private {
type dpattern_node =
| DPwild
| DPvar of preid
| DPapp of psymbol * dpattern list
| DPapp of rsymbol * dpattern list
| DPor of dpattern * dpattern
| DPas of dpattern * preid
| DPcast of dpattern * ity
......@@ -94,8 +94,8 @@ type dexpr = private {
and dexpr_node =
| DEvar of string * dvty
| DEgpvar of pvsymbol
| DEgpsym of psymbol
| DEpv of pvsymbol
| DErs of rsymbol
| DEconst of Number.constant
| DEapp of dexpr * dexpr list
| DEfun of dbinder list * dspec later * dexpr
......@@ -105,7 +105,7 @@ and dexpr_node =
| DElazy of lazy_op * dexpr * dexpr
| DEif of dexpr * dexpr * dexpr
| DEcase of dexpr * (dpattern * dexpr) list
| DEassign of (dexpr * psymbol * dexpr) list
| DEassign of (dexpr * rsymbol * dexpr) list
| DEwhile of dexpr * (dinvariant * variant list) later * dexpr
| DEfor of preid * dexpr * for_direction * dexpr * dinvariant later * dexpr
| DEtry of dexpr * (xsymbol * dpattern * dexpr) list
......@@ -122,14 +122,14 @@ and dexpr_node =
| DEuloc of dexpr * Loc.position
| DElabel of dexpr * Slab.t
and dlet_defn = preid * ghost * ps_kind * dexpr
and dlet_defn = preid * ghost * rs_kind * dexpr
and drec_defn = private { fds : dfun_defn list }
and dfun_defn = preid * ghost * ps_kind *
and dfun_defn = preid * ghost * rs_kind *
dbinder list * (dspec * variant list) later * dexpr
type dval_decl = preid * ghost * ps_kind * dtype_v
type dval_decl = preid * ghost * rs_kind * dtype_v
(** Environment *)
......@@ -155,7 +155,7 @@ val dpattern : ?loc:Loc.position -> dpattern_node -> dpattern
val dexpr : ?loc:Loc.position -> dexpr_node -> dexpr
type pre_fun_defn = preid * ghost * ps_kind *
type pre_fun_defn = preid * ghost * rs_kind *
dbinder list * dity * (denv -> (dspec * variant list) later * dexpr)
val drec_defn : denv -> pre_fun_defn list -> denv * drec_defn
......
This diff is collapsed.
......@@ -14,53 +14,53 @@ open Ident
open Term
open Ity
(** {2 Program symbols} *)
type psymbol = private {
ps_name : ident;
ps_cty : cty;
ps_ghost : bool;
ps_logic : ps_logic;
ps_field : pvsymbol option;
(** {2 Routine symbols} *)
type rsymbol = private {
rs_name : ident;
rs_cty : cty;
rs_ghost : bool;
rs_logic : rs_logic;
rs_field : pvsymbol option;
}
and ps_logic =
| PLnone (* non-pure symbol *)
| PLpv of pvsymbol (* local let-function *)
| PLls of lsymbol (* top-level let-function or let-predicate *)
| PLlemma (* top-level or local let-lemma *)
module Mps : Extmap.S with type key = psymbol
module Sps : Extset.S with module M = Mps
module Hps : Exthtbl.S with type key = psymbol
module Wps : Weakhtbl.S with type key = psymbol
val ps_compare : psymbol -> psymbol -> int
val ps_equal : psymbol -> psymbol -> bool
val ps_hash : psymbol -> int
type ps_kind =
| PKnone (* non-pure symbol *)
| PKpv of pvsymbol (* local let-function *)
| PKlocal (* new local let-function *)
| PKfunc of int (* new top-level let-function or constructor *)
| PKpred (* new top-level let-predicate *)
| PKlemma (* top-level or local let-lemma *)
val create_psymbol : preid -> ?ghost:bool -> ?kind:ps_kind -> cty -> psymbol
(** If [?kind] is supplied and is not [PKnone], then [cty]
and rs_logic =
| RLnone (* non-pure symbol *)
| RLpv of pvsymbol (* local let-function *)
| RLls of lsymbol (* top-level let-function or let-predicate *)
| RLlemma (* top-level or local let-lemma *)
module Mrs : Extmap.S with type key = rsymbol
module Srs : Extset.S with module M = Mrs
module Hrs : Exthtbl.S with type key = rsymbol
module Wrs : Weakhtbl.S with type key = rsymbol
val rs_compare : rsymbol -> rsymbol -> int
val rs_equal : rsymbol -> rsymbol -> bool
val rs_hash : rsymbol -> int
type rs_kind =
| RKnone (* non-pure symbol *)
| RKpv of pvsymbol (* local let-function *)
| RKlocal (* new local let-function *)
| RKfunc of int (* new top-level let-function or constructor *)
| RKpred (* new top-level let-predicate *)
| RKlemma (* top-level or local let-lemma *)
val create_rsymbol : preid -> ?ghost:bool -> ?kind:rs_kind -> cty -> rsymbol
(** If [?kind] is supplied and is not [RKnone], then [cty]
must have no effects except for resets which are ignored.
If [?kind] is [PKnone] or [PKlemma], external mutable reads
If [?kind] is [RKnone] or [RKlemma], external mutable reads
are allowed, otherwise [cty.cty_freeze.isb_reg] must be empty.
If [?kind] is [PKlocal], the type variables in [cty] are frozen
but regions are instantiable. If [?kind] is [PKpred] the result
type must be [ity_bool]. If [?kind] is [PKlemma] and the result
If [?kind] is [RKlocal], the type variables in [cty] are frozen
but regions are instantiable. If [?kind] is [RKpred] the result
type must be [ity_bool]. If [?kind] is [RKlemma] and the result
type is not [ity_unit], an existential premise is generated. *)
val create_field : preid -> itysymbol -> pvsymbol -> psymbol
val create_field : preid -> itysymbol -> pvsymbol -> rsymbol
val restore_ps : lsymbol -> psymbol
(** raises [Not_found] if the argument is not a [ps_logic] *)
val restore_rs : lsymbol -> rsymbol
(** raises [Not_found] if the argument is not a [rs_logic] *)
(** {2 Program patterns} *)
......@@ -73,11 +73,11 @@ type prog_pattern = private {
type pre_pattern =
| PPwild
| PPvar of preid
| PPapp of psymbol * pre_pattern list
| PPapp of rsymbol * pre_pattern list
| PPor of pre_pattern * pre_pattern
| PPas of pre_pattern * preid
exception ConstructorExpected of psymbol
exception ConstructorExpected of rsymbol
val create_prog_pattern :
pre_pattern -> ?ghost:bool -> ity -> pvsymbol Mstr.t * prog_pattern
......@@ -96,7 +96,7 @@ type invariant = term
type variant = term * lsymbol option (** tau * (tau -> tau -> prop) *)
type assign = pvsymbol * psymbol * pvsymbol (* region * field * value *)
type assign = pvsymbol * rsymbol * pvsymbol (* region * field * value *)
type vty =
| VtyI of ity
......@@ -104,7 +104,7 @@ type vty =
type val_decl =
| ValV of pvsymbol
| ValS of psymbol
| ValS of rsymbol
type expr = private {
e_node : expr_node;
......@@ -117,7 +117,7 @@ type expr = private {
and expr_node = private
| Evar of pvsymbol
| Esym of psymbol
| Esym of rsymbol
| Econst of Number.constant
| Eapp of expr * pvsymbol list * cty
| Efun of expr
......@@ -151,8 +151,8 @@ and rec_defn = private {
}
and fun_defn = {
fun_sym : psymbol; (* exported symbol *)
fun_rsym : psymbol; (* internal symbol *)
fun_sym : rsymbol; (* exported symbol *)
fun_rsym : rsymbol; (* internal symbol *)
fun_expr : expr; (* Efun *)
fun_varl : variant list;
}
......@@ -178,7 +178,7 @@ val proxy_label : label
(** {2 Smart constructors} *)
val e_var : pvsymbol -> expr
val e_sym : psymbol -> expr
val e_sym : rsymbol -> expr
val e_const : Number.constant -> expr
val e_nat_const : int -> expr
......@@ -189,11 +189,11 @@ val create_let_defn :
val create_let_defn_pv :
preid -> ?ghost:bool -> expr -> let_defn * pvsymbol
val create_let_defn_ps :
preid -> ?ghost:bool -> ?kind:ps_kind -> expr -> let_defn * psymbol
val create_let_defn_rs :
preid -> ?ghost:bool -> ?kind:rs_kind -> expr -> let_defn * rsymbol
val create_rec_defn :
(psymbol * expr (* Efun *) * variant list * ps_kind) list -> rec_defn
(rsymbol * expr (* Efun *) * variant list * rs_kind) list -> rec_defn
val e_fun :
pvsymbol list -> pre list -> post list -> post list Mexn.t -> expr -> expr
......@@ -203,7 +203,7 @@ val e_rec : rec_defn -> expr -> expr
val e_app : expr -> expr list -> ity list -> ity -> expr
val e_assign : (expr * psymbol * expr) list -> expr
val e_assign : (expr * rsymbol * expr) list -> expr
val e_ghost : expr -> expr
val e_ghostify : expr -> expr
......@@ -235,29 +235,29 @@ val e_any : cty -> expr
(** {2 Built-in symbols} *)
val ps_bool_true : psymbol
val ps_bool_false : psymbol
val rs_bool_true : rsymbol
val rs_bool_false : rsymbol
val e_bool_true : expr
val e_bool_false : expr
val ps_tuple : int -> psymbol
val rs_tuple : int -> rsymbol
val e_tuple : expr list -> expr
val ps_void : psymbol
val rs_void : rsymbol
val e_void : expr
val is_ps_tuple : psymbol -> bool
val is_rs_tuple : rsymbol -> bool
val ps_func_app : psymbol
val rs_func_app : rsymbol
val e_func_app : expr -> expr -> expr
val e_func_app_l : expr -> expr list -> expr
(** {2 Pretty-printing} *)
val forget_ps : psymbol -> unit (* flush id_unique for a program symbol *)
val forget_rs : rsymbol -> unit (* flush id_unique for a program symbol *)
val print_ps : Format.formatter -> psymbol -> unit (* program symbol *)
val print_rs : Format.formatter -> rsymbol -> unit (* program symbol *)
val print_expr : Format.formatter -> expr -> unit (* expression *)
val print_val_decl : Format.formatter -> val_decl -> unit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment