Skip to content

Commit

Permalink
Revert "Propagate context in Adt_rel"
Browse files Browse the repository at this point in the history
This reverts commit 4fb7fff.
  • Loading branch information
Halbaroth committed Feb 14, 2025
1 parent 4fb7fff commit 08259f1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/lib/reasoners/adt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ module Shostak (X : ALIEN) = struct
let ctx =
(* If [t] is a record constructor term of the form
{ x1 = t1; ...; xn = t2 }
we generate the equations
we generate the equation
t.x1 = t1, ..., t.xn = tn
and store them in the context returned by `X.make`. *)
match cases with
Expand Down
40 changes: 10 additions & 30 deletions src/lib/reasoners/adt_rel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -482,21 +482,8 @@ let build_constr_eq r c =
CC(X) via [Ccx.add_term]. Since .ki are fresh terms, adding these
facts could not contribute to any meaningful reasoning. *)
let r', _ctx = X.make cons in
let eqs = [Shostak.L.(view @@ mk_eq r r')] in
let eqs =
match cases with
| [{ destrs; _ }] ->
List.fold_left2
(fun eqs x (d, d_ty) ->
let access, _ =
X.make @@ E.mk_term (Sy.destruct d) [cons] d_ty
in
let tx, _ = X.make x in
Shostak.L.(view @@ mk_eq tx access) :: eqs
) eqs xs destrs
| _ -> eqs
in
Some (eqs, cons)
let eq = Shostak.L.(view @@ mk_eq r r') in
Some (eq, cons)

| _ -> assert false
end
Expand All @@ -515,12 +502,9 @@ let propagate_domains new_terms domains =
match Domain.as_singleton d with
| Some (c, ex) ->
begin match build_constr_eq rr c with
| Some (eqs, cons) ->
| Some (eq, cons) ->
let new_terms = SE.add cons new_terms in
let eqs =
List.map (fun eq -> (Literal.LSem eq, ex, Th_util.Other)) eqs
in
eqs, new_terms
(Literal.LSem eq, ex, Th_util.Other) :: eqs, new_terms
| None ->
eqs, new_terms
end
Expand Down Expand Up @@ -653,17 +637,16 @@ let pick_domain ~for_model uf =

let split_domain ~for_model env uf =
let* cd, r, c = pick_domain ~for_model uf in
if for_model || can_split env (Numbers.Q.from_int cd) then (
(* assert for_model; None) *)
let eqs, _ = Option.get @@ build_constr_eq r c in
Some eqs)
if for_model || can_split env (Numbers.Q.from_int cd) then
let eq, _ = Option.get @@ build_constr_eq r c in
Some eq
else
None

let next_case_split ~for_model env uf =
match split_delayed_destructor env with
| None -> split_domain ~for_model env uf
| Some eq -> Some [eq]
| r -> r

let case_split env uf ~for_model =
if Options.get_disable_adts () then
Expand All @@ -677,11 +660,8 @@ let case_split env uf ~for_model =
(Uf.GlobalDomains.find (module Domains) (Uf.domains uf)));
Log.debug
(fun k -> k "assume by case splitting:@ %a"
Fmt.(braces @@ list ~sep:comma (Xliteral.print_view X.print)) cs);
let eqs =
List.map (fun eq -> eq, true, Th_util.CS (Th_util.Th_adt, two)) cs
in
eqs
(Xliteral.print_view X.print) cs);
[ cs, true, Th_util.CS (Th_util.Th_adt, two)]
| None ->
Log.debug (fun k -> k "no case split done");
[]
Expand Down
33 changes: 31 additions & 2 deletions src/lib/reasoners/matching.ml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,22 @@ module Make (X : Arg) : S with type theory = X.t = struct
in
if info.term_age > age_limite () then env else add_rec env t

(* let add_term info t env =
match E.type_info t with
| Tadt (name, args) as ty -> (
match Ty.type_body name args with
| [{ constr; destrs }] ->
let xs =
List.map
(fun (d, ty) ->
E.mk_term Sy.(Op (Destruct d)) [t] ty
) destrs
in
let c = E.mk_constr constr xs ty in
add_term info c env
| _ -> add_term info t env)
| _ -> add_term info t env
*)
let add_trigger p env = { env with pats = p :: env.pats }

let all_terms
Expand Down Expand Up @@ -367,6 +383,15 @@ module Make (X : Arg) : S with type theory = X.t = struct
else if E.is_ground p1 then [minus_of_plus t p1 ty] else []
| _ -> []

let xs_module_records t name args =
let l = Ty.type_body name args in
match l with
(* | [{ destrs; _ }] ->
List.map
(fun (d, ty) ->
E.mk_term Sy.(Op (Destruct d)) [t] ty) destrs *)
| _ -> []

let rec match_term mconf env tbox
({ sty = s_ty; gen = g; goal = b; _ } as sg : Matching_types.gsubst)
pat t =
Expand Down Expand Up @@ -405,9 +430,13 @@ module Make (X : Arg) : S with type theory = X.t = struct
let cl =
E.Set.fold
(fun t l ->
let { E.f = f; xs = xs; _ } = E.term_view t in
let { E.f = f; xs = xs; ty; _ } = E.term_view t in
if Symbols.compare f_pat f = 0 then xs :: l
else l
else (
match f_pat, ty with
| Sy.(Op Constr _), Ty.Tadt (name, args) ->
(xs_module_records t name args) :: l
| _ -> l)
) cl []
in
let cl = filter_classes mconf cl tbox in
Expand Down

0 comments on commit 08259f1

Please sign in to comment.