Adding Support for User Defined Datatypes and Logical Functions - #383
Conversation
|
From @AndreasLoow:
|
| type datatypes_tbl = (string, Datatype.t) Hashtbl.t | ||
| type t = { constructors : constructors_tbl; datatypes : datatypes_tbl } | ||
|
|
||
| let datatype_env : t option ref = ref None |
There was a problem hiding this comment.
Not a fan of global singletons 😛
There was a problem hiding this comment.
Yeah I remember this bit was super ugly! I didn't have time in my master's project to do the robust thing, and carry the env around everywhere.
Maybe after POPL deadline I'll get round to fixing this.
There was a problem hiding this comment.
I have a couple days to kill until my internship, I'm taking a look now :-)
|
That was a hell of a merge hahah |
|
waow it's passing tests |
Originally from #342; made a new PR so the branch can be under this repo.
Example of the type of specifications that these new features allow for can be found in
wisl/examples/SLL_adt.wisl.User Defined Datatypes
Added WISL support for user defined datatypes:
Added support for user defined datatypes in core Gillian:
Datatype_envto hold definitionsUser Defined Functions
Added WISL support for user defined functions:
Added support for user defined functions in core Gillian:
Function_envto hold definitionsNotes
General
'to differentiate it from function application in the parsing. This was mainly a quick fix, and I'm happy to take suggestions on other approaches!pure functiondenotes a logical function used in specifications, whereasfunctionrepresents a procedure.Movedsmt.mlintoengine/FOLogic/in order to avoid circular dependencies:smt.mlrequiresDatatype_env, from theenginemodule, butenginerequiressmt.ml.Datatype_envandFunction_envare mutable global references. This is for a couple of reasons. Firstly, unlike the typing environment, they aren't modified or copied or replaced during symbolic execution. They are initialised once and stay constant throughout. Secondly, it is too much of a pain to refactor every occurence ofgammato also carry around aDatatype_envand aFunction_env. There are some functions which even make gamma optional, however, the other two environments are always a necessity! I did try this approach but it proved to be too much work.Datatype_envandFunction_envare provided via effects and relevant handlers; seeProg_envunderGil_syntaxfor more.SMT Encoding
Datatype_envandFunction_envare assumed to be initialised.satwhen they should have beenunsat. As a result, we add additional assertions to ensure that expressions were in-fact constructed by the constructor corresponding to the destructor.