package dolmen

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file ast.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240

(* This file is free software, part of dolmen. See file "LICENSE" for more information. *)

(** AST requirement for the Smtlib format.
    The smtlib format is widely used among SMT solvers, and is the language
    of the smtlib benchmark library. Terms are expressed as s-expressions,
    and top-level directives include everything needed to use a prover
    in an interactive loop (so it includes directive for getting and setting options,
    getting information about the solver's internal model, etc...) *)

module type Extension = sig

  type location
  (** The type of locations. *)

  type term
  (** The type of terms *)

  type statement
  (** The type of statements *)

  val statement : string -> (?loc:location -> term list -> statement) option
  (** Called on statements of the form `(<id> <term>)` where `<id>` is
      not the name of a statement in the official smtlib specification. *)

end

module type Id = sig

  type t
  (** The type of identifiers *)

  type namespace
  (** Namespace for identifiers *)

  val sort : namespace
  val term : namespace
  val attr : namespace
  (** The namespace for sorts (also called typee), terms
      and attributes, respectively. *)

  val mk : namespace -> string -> t
  (** Make an identifier from a name and namespace. *)

  val indexed : namespace -> string -> string list -> t
  (** Create an indexed identifier. *)

end

module type Term = sig

  type t
  (** The type of terms. *)

  type id
  (** The type of identifiers for constants. *)

  type location
  (** The type of locations. *)

  val const   : ?loc:location -> id -> t
  (** Constants, i.e non predefined symbols. This includes both constants
      defined by theories, defined locally in a problem, and also quantified variables. *)

  val str     : ?loc:location -> string -> t
  (** Quoted strings. According to the smtlib manual, these can be interpreted as
      either string literals (when the String theory is used), or simply constants *)

  val int     : ?loc:location -> string -> t
  val real    : ?loc:location -> string -> t
  val hexa    : ?loc:location -> string -> t
  val binary  : ?loc:location -> string -> t
  (** Constants lexically recognised as numbers in different formats. According to the smtlib
      manual, these should not always be interpreted as numbers since their interpretation
      is actually dependent on the theory set by the problem. *)

  val colon   : ?loc:location -> t -> t -> t
  (** Juxtaposition of terms, used to annotate terms with their type. *)

  val apply   : ?loc:location -> t -> t list -> t
  (** Application. *)

  val letand   : ?loc:location -> t list -> t -> t
  (** Local parrallel bindings. The bindings are a list of terms built using
      the [colon] function. *)

  val par : ?loc:location -> t list -> t -> t
  (** universal quantification by type variables. *)

  val forall  : ?loc:location -> t list -> t -> t
  (** Universal quantification. *)

  val exists  : ?loc:location -> t list -> t -> t
  (** Existencial quantification. *)

  val match_ : ?loc:location -> t -> (t * t) list -> t
  (** Pattern matching. The first term is the term to match,
      and each tuple in the list is a match case, which is a pair
      of a pattern and a match branch. *)

  val sexpr   : ?loc:location -> t list -> t
  (** S-expressions. Used in smtlib's annotations, *)

  val annot   : ?loc:location -> t -> t list -> t
  (** Attach a list of attributes (also called annotations) to a term. As written
      in the smtlib manual, "Term attributes have no logical meaning --
      semantically, [attr t l] is equivalent to [t]" *)

end
(** Implementation requirements for Smtlib terms. *)

module type Statement = sig

  type t
  (** The type of statements. *)

  type id
  (** The type of identifiers. *)

  type term
  (** The type of terms. *)

  type location
  (** The type of locations. *)

  (** (Re)starting and terminating *)

  val reset : ?loc:location -> unit -> t
  (** Full reset of the prover state. *)

  val set_logic : ?loc:location -> string -> t
  (** Set the problem logic. *)

  val set_option : ?loc:location -> term -> t
  (** Set the value of a prover option. *)

  val exit : ?loc:location -> unit -> t
  (** Exit the interactive loop. *)


  (** Modifying the assertion stack *)

  val push : ?loc:location -> int -> t
  (** Push the given number of new level on the stack of assertions. *)

  val pop : ?loc:location -> int -> t
  (** Pop the given number of level on the stack of assertions. *)

  val reset_assertions : ?loc:location -> unit -> t
  (** Reset assumed assertions. *)


  (** Introducing new symbols *)

  val type_decl : ?loc:location -> id -> int -> t
  (** Declares a new type constructor with given arity. *)

  val type_def  : ?loc:location -> id -> id list -> term -> t
  (** Defines an alias for types. [type_def f args body] is such that
      later occurences of [f] applied to a list of arguments [l] should
      be replaced by [body] where the [args] have been substituted by
      their value in [l]. *)

  val datatypes : ?loc:location -> (id * term list * (id * term list) list) list -> t
  (** Inductive type definitions. *)

  val fun_decl  : ?loc:location -> id -> term list -> term list -> term -> t
  (** Declares a new term symbol, and its type. [fun_decl f ty_args args ret]
      declares [f] as a new function symbol which takes arguments of types
      described in [args], and with return type [ret]. *)

  val fun_def   : ?loc:location -> id -> term list -> term list -> term -> term -> t
  (** Defines a new function. [fun_def f ty_args args ret body] is such that
      applications of [f] are equal to [body] (module substitution of the arguments),
      which should be of type [ret]. *)

  val funs_def_rec : ?loc:location -> (id * term list * term list * term * term) list -> t
  (** Declare a list of mutually recursive functions. *)


  (** Asserting and inspecting formulas *)

  val assert_ : ?loc:location -> term -> t
  (** Add a proposition to the current set of assertions. *)

  val get_assertions : ?loc:location -> unit -> t
  (** Return the current set of assertions. *)


  (** Checking for satisfiablity *)

  val check_sat : ?loc:location -> term list -> t
  (** Solve the current set of assertions for satisfiability,
      under the local assumptions specified. *)

  (** Models *)

  val get_model : ?loc:location -> unit -> t
  (** Return the model found. *)

  val get_value : ?loc:location -> term list -> t
  (** Return the value of the given terms in the current model of the solver. *)

  val get_assignment : ?loc:location -> unit -> t
  (** Return the values of asserted propositions which have been labelled using
      the ":named" attribute. *)

  (** Proofs *)

  val get_proof : ?loc:location -> unit -> t
  (** Return the proof of the lastest [check_sat] if it returned unsat, else
      is undefined. *)

  val get_unsat_core : ?loc:location -> unit -> t
  (** Return the unsat core of the latest [check_sat] if it returned unsat,
      else is undefined. *)

  val get_unsat_assumptions : ?loc:location -> unit -> t
  (** Return a list of local assumptions (as givne in {!check_sat},
      that is enough to deduce unsat. *)

  (** Inspecting settings *)

  val get_info : ?loc:location -> string -> t
  (** Get information (see smtlib manual). *)

  val get_option : ?loc:location -> string -> t
  (** Get the value of a prover option. *)

  (** Scripts commands *)

  val echo : ?loc:location -> string -> t
  (** Print back as-is, including the double quotes. *)

  val set_info : ?loc:location -> term -> t
  (** Set information (see smtlib manual). *)

end
(** implementation requirement for smtlib statements. *)

OCaml

Innovation. Community. Security.