package libsail
Module Libsail.Type_envSource
Linearize cases involving power where we would otherwise require the SMT solver to use non-linear arithmetic.
Set the modules in the environment. Note that calling this twice on an environment with different arguments will invalidate all module identifiers!
Start typechecking within a module context. The module id must be a valid module created via the set_modules call, otherwise we will fail with an internal error.
End the current module context, returning us to type-checking in the global scope.
This is the same as end_module and open_all_modules, except it returns the module state so it can be restored with restore_scope.
val add_val_spec :
?in_module:Project.mod_id ->
?already_bound:bool ->
?ignore_duplicate:bool ->
Ast.id ->
(Ast.typquant * Ast.typ) ->
t ->
tAdd a function type (val spec) to the global typing environment.
If already_bound = true, we can add a val_spec for something that is already bound as a global identifier in the typing environment. This is used for union constructors.
For legacy reasons, function declarations can be duplicated. This will typically produce a warning. If ignore_duplicate is true, this warning is supressed.
val update_val_spec :
?in_module:Project.mod_id ->
Ast.id ->
(Ast.typquant * Ast.typ) ->
t ->
tval add_outcome :
Ast.id ->
(Ast.typquant * Ast.typ * Ast.typquant * Ast.id list * t) ->
t ->
tval get_outcome :
Ast.l ->
Ast.id ->
t ->
Ast.typquant * Ast.typ * Ast.typquant * Ast.id list * tFor a user-defined type identifier we can control whether it is allowed to be created with the undefined literal in Sail
val add_variant :
?is_newtype:bool ->
Ast.id ->
(Ast.typquant * Ast.type_union list) ->
t ->
tval add_record :
Ast.id ->
Ast.typquant ->
((Ast.id * Ast.typ) * unit Ast.def_annot) list ->
t ->
tSome of the code in the environment needs to use the smt solver, which is defined below. To break the circularity this would cause (as the prove code depends on the environment), we add a reference to the prover to the initial environment.
This should not be used outside the type checker, as initial_env sets up a correct initial environment.