Gbury / dolmen

Dolmen provides a library and a binary to parse, typecheck, and evaluate languages used in automated deduction
BSD 2-Clause "Simplified" License
80 stars 17 forks source link

Add language extensions in the parsing of smtlib2 #190

Closed Gbury closed 1 year ago

Gbury commented 1 year ago

This PR adds a new concept to the smtlib2 parser: extensions. Basically, extensions are sets of new statements that are allowed. For instance the maxsmt extension allows statements such as minimize and maximize. By default, no extension is active/allowed, and the dolmen binary will (at least for now) discourage the use of extensions, however, users of the library will be able to accept any new statement they might want to try.

Statements accepted as part of an extension basically take a list of s-expr as payload, and it is up to the users to decide what to do with them. There are two points of control of extensions for users:

Note: the payloads of Plain statements for extensions are s-expr, and not smtlib2 terms of sorts. The functions sexpr_as_term and sexpr_as_sort from the Dolmen_type.Core.Smtlib2 module may be used to easily recover parsed expressions that can then easily be typechecked.

cc @bclement-ocp

Gbury commented 1 year ago

Okay so, I replaced the Plain statement with an Other statement which is a bit more general and should make it easier to access the original name of the statement.

Note that originally/before this PR, the only producer of Plain statements was the TPTP parser. With this PR, smtlib extensions can also produce such statements (well now it's called Other).