package syguslib-utils

  1. Overview
  2. Docs

This module contains definitions that mirror the SyGuS Language Standard Version 2.1, which can be found at https://sygus.org/assets/pdf/SyGuS-IF_2.1.pdf.

Types

val use_v1 : bool ref

Set to true in order to use SyGuS language v1.

type symbol = string

Symbols are just strings.

type attribute =
  1. | Attr of symbol
  2. | AttrVal of symbol * string
type literal =
  1. | LitNum of int
    (*

    A numeral literal, which is either the digit 0 or a non-empty sequence of digits that does not being with 0.

    *)
  2. | LitDec of float
    (*

    A decimal number literal, which is syntactically <numeral>.0*<numeral>.

    *)
  3. | LitBool of bool
    (*

    A boolean literal is either true or false.

    *)
  4. | LitHex of symbol
    (*

    A hexadecimal is written with #x followed by a non empty sequence of characters A-F and 0-9

    *)
  5. | LitBin of bool list
    (*

    A hexadecimal is written with #b followed by a non empty sequence of bits

    *)
  6. | LitString of symbol
    (*

    A string literal is any sequence of printable characters delimited by double quotes.

    *)

SyGuS literals.

type index =
  1. | INum of int
  2. | ISym of symbol
type identifier =
  1. | IdSimple of symbol
    (*

    A simple identifier is a symbol.

    *)
  2. | IdIndexed of symbol * index list
    (*

    An indexed identifier is (_ <symbol> <identifier>)

    *)
  3. | IdQual of symbol * sygus_sort
    (*

    A qualified identifier is (as <symbol> <sort>)

    *)

An identifier can be simple, indexed or qualified.

and sygus_sort =
  1. | SId of identifier
    (*

    A simple sort with an identifier.

    *)
  2. | SApp of identifier * sygus_sort list
    (*

    A sort applied to arguments.

    *)

A sort is either its id, or a sort applied to other sort (polymorphism)

type sygus_term =
  1. | SyId of identifier
  2. | SyLit of literal
    (*

    A literal.

    *)
  3. | SyApp of identifier * sygus_term list
    (*

    A function application.

    *)
  4. | SyExists of sorted_var list * sygus_term
    (*

    An existential quantifier.

    *)
  5. | SyForall of sorted_var list * sygus_term
    (*

    A universal quantifier.

    *)
  6. | SyLet of binding list * sygus_term
    (*

    A let-binding.

    *)

The type for sygus terms.

and sorted_var = symbol * sygus_sort
and binding = symbol * sygus_term
type feature =
  1. | FGrammar
  2. | FFwdDecls
  3. | FRecursion
  4. | FOracles
  5. | FWeights
type command =
  1. | CCheckSynth
    (*

    The (check-synth) command for synthesis.

    *)
  2. | CAssume of sygus_term
    (*

    The assume command.

    *)
  3. | CConstraint of sygus_term
    (*

    The constraint command to define a constraint with a term.

    *)
  4. | CChcConstraint of sorted_var list * sygus_term * sygus_term
    (*

    A command for specifying CHC constraints.

    *)
  5. | CDeclareVar of symbol * sygus_sort
    (*

    The declare command to declare a universally quantified variable.

    *)
  6. | CDeclareWeight of symbol * attribute list
    (*

    Declaration of weight attributes.

    *)
  7. | CInvConstraint of symbol * symbol * symbol * symbol
    (*

    The inv-constraint command to constraint an invariant.

    *)
  8. | CSetFeature of feature * bool
    (*

    The set-feature command.

    *)
  9. | CSynthFun of symbol * sorted_var list * sygus_sort * grammar_def option
    (*

    The synth-fun command to declare a function to synthesize. The grammar is optional.

    *)
  10. | CSynthInv of symbol * sorted_var list * grammar_def option
    (*

    The synth-inv command is a shortcut for synth-fun when the function to be synthesized returns a boolean. It is printed as synth-fun ... Bool if use_v1 is false.

    *)
  11. | COptimizeSynth of sygus_term list * attribute list
    (*

    Command for specifying optimization queries.

    *)
  12. | CDeclareDataType of symbol * dt_cons_dec list
    (*

    A datatype declaration with a name and constructor list.

    *)
  13. | CDeclareDataTypes of sygus_sort_decl list * dt_cons_dec list list
    (*

    A declaration for mutually recursive data types.

    *)
  14. | CDeclareSort of symbol * int
    (*

    A sort declaration

    *)
  15. | CDefineFun of symbol * sorted_var list * sygus_sort * sygus_term
    (*

    A function definition.

    *)
  16. | CDefineSort of symbol * sygus_sort
    (*

    A sort definition (renaming).

    *)
  17. | CSetInfo of symbol * literal
    (*

    Setting some solver option.

    *)
  18. | CSetLogic of symbol
    (*

    Setting the logic used.

    *)
  19. | CSetOption of symbol * literal
    (*

    Setting some solver option.

    *)
  20. | COracle of oracle_command
    (*

    All the oracle commands are grouped under COracle.

    *)

The SyGuS commands

and oracle_command =
  1. | OAssume of sorted_var list * sorted_var list * sygus_term * symbol
    (*

    Asert an oracle assumption.

    *)
  2. | OConstraint of sorted_var list * sorted_var list * sygus_term * symbol
    (*

    Assert and oracle constraint.

    *)
  3. | ODeclareFun of symbol * sygus_sort list * sygus_sort * symbol
    (*

    Declare an oracle functional symbol.

    *)
  4. | OConstraintIO of symbol * symbol
    (*

    Declare an input-output oracle.

    *)
  5. | OConstraintCex of symbol * symbol
    (*

    Declare a counterexample witness oracle.

    *)
  6. | OConstraintMem of symbol * symbol
    (*

    Declare a membership-query oracle.

    *)
  7. | OConstraintPosw of symbol * symbol
    (*

    Declare a positive witness oracle.

    *)
  8. | OConstraintNegw of symbol * symbol
    (*

    Declare a negative witness oracle.

    *)
  9. | OCorrectness of symbol * symbol
    (*

    Declare a correctness oracle.

    *)
  10. | OCorrectnessCex of symbol * symbol
    (*

    Declare a correctness oracle with counterexamples.

    *)

A different type is used to separate the oracle commands.

and sygus_sort_decl = symbol * int

A sort declaration is a name with an integer index.

and dt_cons_dec = symbol * sorted_var list

A datatype constructor with a name and named arguments.

and grammar_def = (sorted_var * grouped_rule_list) list

A grammar definition is a list of non-terminals together with their production rule. In SyGuS v2, the definition is printed by first declaring the non-terminals and then printing the rules. The first symbol is always assumed to be the start symbol.

and grouped_rule_list = sygus_gsterm list
and sygus_gsterm =
  1. | GConstant of sygus_sort
    (*

    A constant stands for any constant of a given sort.

    *)
  2. | GTerm of sygus_term
    (*

    A grammar term stands for a SyGuS term, which may contain non-terminals of the grammar.

    *)
  3. | GVar of sygus_sort
    (*

    A grammar var stands for any variable of a given sort.

    *)

A grammar term in SyGuS.

type program = command list

A program in SyGuS is a list of commands.

val special_chars : char list

The special characters that may not be used as identifiers (symbols).

val reserved_words : symbol list

A list of reserved symbols, that may not be used as symbols.

val digits : char list
val valid_ident : symbol -> bool

Returns true if the string is a valid identifier in SyGuS.

val has_standard_extension : string -> bool

Checks that a filename has the standard extension (.sl)

val char_to_bool : char -> bool

Solver specific types.

type solver_response =
  1. | RSuccess of (symbol * sorted_var list * sygus_sort * sygus_term) list
    (*

    A successful response comes with a list of implementations for the functions to synthesize.

    *)
  2. | RInfeasible
    (*

    A response indicating that the problem has no solution.

    *)
  3. | RFail
    (*

    A response indicating that the solver failed.

    *)
  4. | RUnknown
    (*

    A response indicating that the solver could not find a solution, with no guarantee about the feasibility of the problem.

    *)

The types of responses a solver can give.

val is_sat : solver_response -> bool

Returns true is the solver response is successful.

val is_failed : solver_response -> bool

Returns true if the solver response indicates failure.

val is_infeasible : solver_response -> bool

Returns true if the solver response indicates the problem is is infeasible

OCaml

Innovation. Community. Security.