@@ -81,6 +81,8 @@ let check (type a) (module SAT : S with type t = a) env =
8181 with
8282 | I_dont_know | Sat -> ()
8383
84+ exception Wrong_model of Explanation. t
85+
8486(* Assert the last computed model in the environment [env].
8587
8688 @raise Unsat if the solver found a contradiction, which means the model
@@ -179,28 +181,30 @@ let get_value (type a) (module SAT : S with type t = a) env l =
179181 (* We have to check the satisfability of the new environment [env] in order
180182 to produce a new model. If this call raise [Unsat], the model is wrong
181183 and we cannot produce model terms for the expressions of [l]. *)
182- check (module SAT ) env;
183- let * mdl = SAT. get_model env in
184- let values =
185- List. map
186- (fun (v , name ) ->
187- match v, name with
188- | Some v , None -> v
189- | None , Some name ->
190- begin match get_value_in_model (module SAT ) env mdl name with
191- | Some v -> v
192- | None ->
193- (* The model generation has to produce a value for each
194- declared names. If some declared names are missing in the
195- model, it's a bug. *)
196- assert false
197- end
198- | _ ->
199- (* This case is excluded by the construction of the list [res]. *)
200- assert false
201- ) res
202- in
203- Some values
184+ try
185+ check (module SAT ) env;
186+ let * mdl = SAT. get_model env in
187+ let values =
188+ List. map
189+ (fun (v , name ) ->
190+ match v, name with
191+ | Some v , None -> v
192+ | None , Some name ->
193+ begin match get_value_in_model (module SAT ) env mdl name with
194+ | Some v -> v
195+ | None ->
196+ (* The model generation has to produce a value for each
197+ declared names. If some declared names are missing in the
198+ model, it's a bug. *)
199+ assert false
200+ end
201+ | _ ->
202+ (* This case is excluded by the construction of the list [res]. *)
203+ assert false
204+ ) res
205+ in
206+ Some values
207+ with Unsat ex -> raise_notrace (Wrong_model ex)
204208
205209let get_assignment (type a ) (module SAT : S with type t = a ) env =
206210 List. map
0 commit comments