program API (in progress)

parent 6d7f26b2
......@@ -447,7 +447,7 @@ install_local: bin/why3ml
# Whyml (new API)
########
MLW_FILES = mlw_ty
MLW_FILES = mlw_ty mlw_expr
MLWMODULES = $(addprefix src/whyml/, $(MLW_FILES))
......
(**************************************************************************)
(* *)
(* Copyright (C) 2010-2011 *)
(* François Bobot *)
(* Jean-Christophe Filliâtre *)
(* Claude Marché *)
(* Andrei Paskevich *)
(* *)
(* This software is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Library General Public *)
(* License version 2.1, with the special exception on linking *)
(* described in file LICENSE. *)
(* *)
(* This software 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. *)
(* *)
(**************************************************************************)
open Why3
open Ident
open Ty
open Mlw_ty
(* program symbols *)
type psymbol = {
p_ident: ident;
p_tvs: Stv.t;
p_reg: Sreg.t;
p_vty: vty;
(* pv_ghost: bool; *)
}
let create_psymbol id tvars regs vty =
(* TODO? check that tvars/regs are in vty *)
{ p_ident = id_register id;
p_tvs = tvars;
p_reg = regs;
p_vty = vty; }
(**************************************************************************)
(* *)
(* Copyright (C) 2010-2011 *)
(* François Bobot *)
(* Jean-Christophe Filliâtre *)
(* Claude Marché *)
(* Andrei Paskevich *)
(* *)
(* This software is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Library General Public *)
(* License version 2.1, with the special exception on linking *)
(* described in file LICENSE. *)
(* *)
(* This software 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. *)
(* *)
(**************************************************************************)
open Why3
open Ident
open Ty
open Mlw_ty
(* program symbols *)
type psymbol = private {
p_ident: ident;
p_tvs: Stv.t;
p_reg: Sreg.t;
p_vty: vty;
(* pv_ghost: bool; *)
}
val create_psymbol: preid -> Stv.t -> Sreg.t -> vty -> psymbol
(* program expressions *)
(*
| Letrec of (psymbol * lambda) list * expr
| Let of pvsymbol * expr * expr
*)
This diff is collapsed.
......@@ -21,137 +21,136 @@ open Why3
open Stdlib
open Ident
open Ty
open Term
(** value types (w/o effects) *)
(** individual types (first-order types w/o effects) *)
type vtysymbol = private {
vts_pure : tysymbol;
vts_args : tvsymbol list;
vts_regs : region list;
vts_def : vty option;
type itysymbol = private {
its_pure : tysymbol;
its_args : tvsymbol list;
its_regs : region list;
its_def : ity option;
}
and vty = private {
vty_node : vty_node;
vty_tag : Hashweak.tag;
and ity = private {
ity_node : ity_node;
ity_tag : Hashweak.tag;
}
and vty_node = private
| Vtyvar of tvsymbol
| Vtypur of tysymbol * vty list
| Vtyapp of vtysymbol * vty list * region list
(* | Vtymod of tysymbol * vty *)
and ity_node = private
| Ityvar of tvsymbol
| Itypur of tysymbol * ity list
| Ityapp of itysymbol * ity list * region list
(* | Itymod of tysymbol * ity *)
and region = private {
reg_ty : vty;
reg_ity : ity;
reg_tag : Hashweak.tag;
}
module Mvts : Map.S with type key = vtysymbol
module Svts : Mvts.Set
module Hvts : Hashtbl.S with type key = vtysymbol
module Wvts : Hashweak.S with type key = vtysymbol
module Mits : Map.S with type key = itysymbol
module Sits : Mits.Set
module Hits : Hashtbl.S with type key = itysymbol
module Wits : Hashweak.S with type key = itysymbol
module Mvty : Map.S with type key = vty
module Svty : Mvty.Set
module Hvty : Hashtbl.S with type key = vty
module Wvty : Hashweak.S with type key = vty
module Mity : Map.S with type key = ity
module Sity : Mity.Set
module Hity : Hashtbl.S with type key = ity
module Wity : Hashweak.S with type key = ity
module Mreg : Map.S with type key = region
module Sreg : Mreg.Set
module Hreg : Hashtbl.S with type key = region
module Wreg : Hashweak.S with type key = region
val vts_equal : vtysymbol -> vtysymbol -> bool
val vty_equal : vty -> vty -> bool
val its_equal : itysymbol -> itysymbol -> bool
val ity_equal : ity -> ity -> bool
val vts_hash : vtysymbol -> int
val vty_hash : vty -> int
val its_hash : itysymbol -> int
val ity_hash : ity -> int
val reg_equal : region -> region -> bool
val reg_hash : region -> int
exception BadVtyArity of vtysymbol * int * int
exception BadRegArity of vtysymbol * int * int
exception BadItyArity of itysymbol * int * int
exception BadRegArity of itysymbol * int * int
exception DuplicateRegion of region
exception UnboundRegion of region
exception InvalidRegion of region
val create_region : vty -> region
val create_region : ity -> region
val create_vtysymbol :
preid -> tvsymbol list -> region list -> vty option -> vtysymbol
val create_itysymbol :
preid -> tvsymbol list -> region list -> ity option -> itysymbol
val vty_var : tvsymbol -> vty
val vty_pur : tysymbol -> vty list -> vty
val ity_var : tvsymbol -> ity
val ity_pur : tysymbol -> ity list -> ity
val vty_app : vtysymbol -> vty list -> region list -> vty
val ity_app : itysymbol -> ity list -> region list -> ity
(* erases all [Vtymod] *)
(* val vty_unmod : vty -> vty *)
(* erases all [Itymod] *)
(* val ity_unmod : ity -> ity *)
(* all aliases expanded, all regions removed *)
val ty_of_vty : vty -> ty
val ty_of_ity : ity -> ty
(* replaces every [Tyapp] with [Vtypur] *)
val vty_of_ty : ty -> vty
(* replaces every [Tyapp] with [Itypur] *)
val ity_of_ty : ty -> ity
(* generic traversal functions *)
val vty_map : (vty -> vty) -> vty -> vty
val vty_fold : ('a -> vty -> 'a) -> 'a -> vty -> 'a
val vty_all : (vty -> bool) -> vty -> bool
val vty_any : (vty -> bool) -> vty -> bool
val ity_map : (ity -> ity) -> ity -> ity
val ity_fold : ('a -> ity -> 'a) -> 'a -> ity -> 'a
val ity_all : (ity -> bool) -> ity -> bool
val ity_any : (ity -> bool) -> ity -> bool
(* traversal functions on type variables and regions *)
val vty_v_map :
(tvsymbol -> vty) -> (region -> region) -> vty -> vty
val ity_v_map :
(tvsymbol -> ity) -> (region -> region) -> ity -> ity
val vty_v_fold :
('a -> tvsymbol -> 'a) -> ('a -> region -> 'a) -> 'a -> vty -> 'a
val ity_v_fold :
('a -> tvsymbol -> 'a) -> ('a -> region -> 'a) -> 'a -> ity -> 'a
val vty_v_all : (tvsymbol -> bool) -> (region -> bool) -> vty -> bool
val vty_v_any : (tvsymbol -> bool) -> (region -> bool) -> vty -> bool
val ity_v_all : (tvsymbol -> bool) -> (region -> bool) -> ity -> bool
val ity_v_any : (tvsymbol -> bool) -> (region -> bool) -> ity -> bool
(** {3 symbol-wise map/fold} *)
(** visits every symbol of the type *)
(*
val vty_s_map : (vtysymbol -> vtysymbol) -> vty -> vty
val vty_s_fold : ('a -> vtysymbol -> 'a) -> 'a -> vty -> 'a
val vty_s_all : (vtysymbol -> bool) -> vty -> bool
val vty_s_any : (vtysymbol -> bool) -> vty -> bool
val ity_s_map : (itysymbol -> itysymbol) -> ity -> ity
val ity_s_fold : ('a -> itysymbol -> 'a) -> 'a -> ity -> 'a
val ity_s_all : (itysymbol -> bool) -> ity -> bool
val ity_s_any : (itysymbol -> bool) -> ity -> bool
*)
val vty_freevars : Stv.t -> vty -> Stv.t
val vty_closed : vty -> bool
val vty_pure: vty -> bool
val ity_freevars : Stv.t -> ity -> Stv.t
val ity_closed : ity -> bool
val ity_pure: ity -> bool
exception RegionMismatch of region * region
exception TypeMismatch of vty * vty
exception TypeMismatch of ity * ity
type vty_subst = private {
vty_subst_tv: vty Mtv.t;
vty_subst_reg: region Mreg.t;
type ity_subst = private {
ity_subst_tv: ity Mtv.t;
ity_subst_reg: region Mreg.t;
}
val vty_subst_empty: vty_subst
val ity_subst_empty: ity_subst
val vty_match : vty_subst -> vty -> vty -> vty_subst
val ity_match : ity_subst -> ity -> ity -> ity_subst
val vty_equal_check : vty -> vty -> unit
(*****
val ity_equal_check : ity -> ity -> unit
(** computation types (with effects) *)
(* exception symbols *)
type xsymbol = private {
xs_id : ident;
xs_vty: vty; (* closed and pure *)
xs_name : ident;
xs_ity: ity; (* closed and pure *)
}
val create_xsymbol: preid -> vty -> xsymbol
val create_xsymbol: preid -> ity -> xsymbol
module Mexn: Map.S with type key = xsymbol
module Sexn: Mexn.Set
......@@ -170,39 +169,36 @@ val eff_union: effect -> effect -> effect
val eff_read: region -> effect
val eff_write: region -> effect
val eff_raise: xsymbol -> effect
val eff_remove_raise: xsymbol -> effect -> effect
(* program symbols *)
type psymbol = private {
p_vs: vsymbol;
p_vty: vty;
p_ghost: bool;
p_mutable: region option;
(* program variables *)
type pvsymbol = private {
pv_vs: vsymbol;
pv_ity: ity;
pv_ghost: bool;
pv_mutable: region option;
}
val create_psymbol: ?mut:region -> ?ghost:bool -> vty -> psymbol
val create_pvsymbol: preid -> ?mut:region -> ?ghost:bool -> ity -> pvsymbol
(* expression types *)
type ety = private
| Evalue of psymbol
| Earrow of psymbol * cty
(* value types *)
type vty = private
| VTvalue of pvsymbol
| VTarrow of pvsymbol * cty
(* computation types *)
and cty = private {
c_pre: fmla;
c_ety: ety;
c_pre: term;
c_vty: vty;
c_eff: effect;
c_post: fmla;
c_post: term;
c_xpost: xpost;
}
and xpost = (psymbol * fmla) Xmap.t
and xpost = (pvsymbol * term) Mexn.t
(* smart constructors *)
val ety_value: psymbol -> ety
val ety_arrow: psymbol -> cty -> ety
val create_cty: ?pre:fmla -> ?post:post -> ?xpost:xpost -> ety -> effect -> cty
val vty_value: pvsymbol -> vty
val vty_arrow:
pvsymbol -> ?pre:term -> ?post:term -> ?xpost:xpost -> vty -> effect -> vty
****)
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