@@ -1093,18 +1093,19 @@ let reinit_cache () =
10931093(* ***************************************************************************)
10941094
10951095let model_repr_of_term t env mrepr =
1096- try ME. find t mrepr, mrepr
1097- with Not_found ->
1098- let mk = try ME. find t env.make with Not_found -> assert false in
1099- let rep, _ = try MapX. find mk env.repr with Not_found -> assert false in
1100- (* We call this function during the model generation only. At this time,
1101- we are sure that class representatives are constant semantic values, or
1102- uninterpreted names. *)
1103- match X. to_model_term rep with
1104- | Some v -> v, ME. add t v mrepr
1105- | None ->
1106- (* [X.to_model_term] cannot fail on constant semantic values. *)
1107- assert false
1096+ if E. is_model_term t then t, mrepr else
1097+ try ME. find t mrepr, mrepr
1098+ with Not_found ->
1099+ let mk = try ME. find t env.make with Not_found -> assert false in
1100+ let rep, _ = try MapX. find mk env.repr with Not_found -> assert false in
1101+ (* We call this function during the model generation only. At this time,
1102+ we are sure that class representatives are constant semantic values, or
1103+ uninterpreted names. *)
1104+ match X. to_model_term rep with
1105+ | Some v -> v, ME. add t v mrepr
1106+ | None ->
1107+ (* [X.to_model_term] cannot fail on constant semantic values. *)
1108+ assert false
11081109
11091110(* A map of expressions to terms, ordered by depth first, and then by
11101111 [Expr.compare] for expressions with same depth. This structure will
@@ -1152,25 +1153,11 @@ module Cache = struct
11521153 E.Table. add arrays_cache t values
11531154 | values ->
11541155 E.Table. replace values i v
1155-
1156- let get_abstract_for abstracts_cache env (t : E.t ) =
1157- let r, _ = find env t in
1158- match Shostak.HX. find abstracts_cache r with
1159- | exception Not_found ->
1160- let abstract = E. mk_abstract (E. type_info t) in
1161- Shostak.HX. add abstracts_cache r abstract;
1162- abstract
1163- | abstract -> abstract
11641156end
11651157
11661158type cache = {
11671159 array_selects : Expr .t E.Table .t E.Table .t ;
11681160 (* * Stores all the get accesses to array names. *)
1169-
1170- abstracts : Expr .t Shostak.HX .t ;
1171- (* * Stores all the abstract values generated. This cache is necessary
1172- to ensure we do not generate twice an abstract value for a given
1173- symbol. *)
11741161}
11751162
11761163let is_destructor = function
@@ -1189,9 +1176,8 @@ let is_destructor = function
11891176 Alt-Ergo cannot produces a constant value for them. This function creates
11901177 a new abstract value in this case. *)
11911178let compute_concrete_model_of_val cache =
1192- let store_array_select = Cache. store_array_get cache.array_selects
1193- and get_abstract_for = Cache. get_abstract_for cache.abstracts
1194- in fun env t ((mdl , mrepr ) as acc ) ->
1179+ let store_array_select = Cache. store_array_get cache.array_selects in
1180+ fun env t ((mdl , mrepr ) as acc ) ->
11951181 let { E. f; xs; ty; _ } = E. term_view t in
11961182 (* TODO: We have to filter out destructors here as we don't consider
11971183 pending destructors as solvable theory symbols of the ADT theory.
@@ -1217,41 +1203,23 @@ let compute_concrete_model_of_val cache =
12171203 in
12181204 let ret_rep, mrepr = model_repr_of_term t env mrepr in
12191205 match f, arg_vals, ty with
1220- | Sy. Name _ , [] , Ty. Tfarray _ ->
1221- begin
1222- match E.Table. find cache.array_selects t with
1223- | exception Not_found ->
1224- (* We have to add an abstract array in case there is no
1225- constraint on its values. *)
1226- E.Table. add cache.array_selects t (E.Table. create 17 );
1227- acc
1228- | _ -> acc
1229- end
1230-
12311206 | Sy. Op Sy. Set , _ , _ -> acc
12321207
12331208 | Sy. Op Sy. Get , [a; i], _ ->
12341209 begin
1210+ let a, mrepr = model_repr_of_term a env mrepr in
1211+ let i, mrepr = model_repr_of_term i env mrepr in
12351212 let E. { f = fa; _ } = E. term_view a in
12361213 match fa with
12371214 | Sy. Name _ ->
12381215 store_array_select a i ret_rep;
1239- acc
1216+ mdl, mrepr
12401217 | _ ->
12411218 acc
12421219 end
12431220
12441221 | Sy. Name { hs = id ; _ } , _ , _ ->
1245- let value =
1246- match ty with
1247- | Ty. Text _ ->
1248- (* We cannot produce a concrete value as the type is abstract.
1249- In this case, we produce an abstract value with the appropriate
1250- type. *)
1251- get_abstract_for env t
1252- | _ -> ret_rep
1253- in
1254- ModelMap. (add (id, arg_tys, ty) arg_vals value mdl), mrepr
1222+ ModelMap. (add (id, arg_tys, ty) arg_vals ret_rep mdl), mrepr
12551223
12561224 | _ ->
12571225 Printer. print_err
@@ -1262,8 +1230,7 @@ let compute_concrete_model_of_val cache =
12621230
12631231let extract_concrete_model cache =
12641232 let compute_concrete_model_of_val = compute_concrete_model_of_val cache in
1265- let get_abstract_for = Cache. get_abstract_for cache.abstracts
1266- in fun ~prop_model ~declared_ids env ->
1233+ fun ~prop_model ~declared_ids env ->
12671234 let terms, suspicious = terms env in
12681235 let model, mrepr =
12691236 MED. fold (fun t _mk acc -> compute_concrete_model_of_val env t acc)
@@ -1273,12 +1240,12 @@ let extract_concrete_model cache =
12731240 E.Table. fold (fun t vals mdl ->
12741241 (* We produce a fresh identifiant for abstract value in order to
12751242 prevent any capture. *)
1276- let abstract = get_abstract_for env t in
1243+ assert ( E. is_model_term t);
12771244 let ty = Expr. type_info t in
12781245 let arr_val =
12791246 E.Table. fold (fun i v arr_val ->
12801247 Expr.ArraysEx. store arr_val i v
1281- ) vals abstract
1248+ ) vals t
12821249 in
12831250 let id, is_user =
12841251 let Expr. { f; _ } = Expr. term_view t in
@@ -1309,8 +1276,5 @@ let extract_concrete_model cache =
13091276 { Models. propositional = prop_model; model; term_values = mrepr }
13101277
13111278let extract_concrete_model ~prop_model ~declared_ids =
1312- let cache : cache = {
1313- array_selects = E.Table. create 17 ;
1314- abstracts = Shostak.HX. create 17 ;
1315- }
1316- in fun env -> extract_concrete_model cache ~prop_model ~declared_ids env
1279+ let cache : cache = { array_selects = E.Table. create 17 } in
1280+ fun env -> extract_concrete_model cache ~prop_model ~declared_ids env
0 commit comments