Skip to content

Commit

Permalink
fix(AC): Also abstract non-AC arguments of AC symbols
Browse files Browse the repository at this point in the history
Alt-Ergo uses an abstraction mechanism for the arguments of AC symbols
to ensure termination of the induced rewrite ordering without resorting
to a recursive path ordering.

This is described in section 6 of [this paper][1], except that the
implementation doesn't do exactly what is described there -- in
particular, it only abstracts nested AC symbols, which is an issue when
an argument is not an AC symbol but a semantic value that contains
another AC symbol.

This patch changes the `abstract2` function in `ac.ml`, where this
abstraction mechanism is implemented, to also introduce abstracted
constants for non-constant terms.

Fixes #964

[1]: https://arxiv.org/abs/1207.3262
  • Loading branch information
bclement-ocp committed Nov 24, 2023
1 parent 5a0db4f commit b75802e
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib/reasoners/ac.ml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,16 @@ module Make (X : Sig.X) = struct
let abstract2 sy t r acc =
match X.ac_extract r with
| Some ac when Sy.equal sy ac.h -> r, acc
| None -> r, acc
| None -> (
if X.is_constant r then r, acc
else
match Expr.term_view t with
| { Expr.xs = []; bind = B_none; _ } -> r, acc
| { ty; _ } ->
let k = Expr.fresh_name ty in
let eq = Expr.mk_eq ~iff:false k t in
X.term_embed k, eq::acc
)
| Some _ -> match Expr.term_view t with
| { Expr.f = Sy.Name (hs, Sy.Ac, _); xs; ty; _ } ->
let aro_sy = Sy.name ("@" ^ (HS.view hs)) in
Expand Down
270 changes: 270 additions & 0 deletions tests/dune.inc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/issues/964.ae
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
logic ac u : int, int -> int
logic ac v : int, int -> int

goal g : v(0, 1) = u(-v(0, 1), 2)
2 changes: 2 additions & 0 deletions tests/issues/964.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

unknown

0 comments on commit b75802e

Please sign in to comment.