[sledge] Use fresh var for length when extracting from a variable

Summary:
When solving equations such as `α[o,l) = β`, the memory theory solver
computes a term to represent the length of α. This fails if α is a
variable (which might itself be equal to a sized term elsewhere in the
formula). This diff fixes such failures by generating a fresh variable
for the length in such situations.

Reviewed By: ngorogiannis

Differential Revision: D27564871

fbshipit-source-id: e5e066b77
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent d5cc42a7fd
commit 6b32a003df

@ -135,12 +135,12 @@ let solve_extract a o l b s =
[%trace]
~call:(fun {pf} ->
pf "@ %a = %a" Trm.pp (Trm.extract ~seq:a ~off:o ~len:l) Trm.pp b )
~retn:(fun {pf} -> pf "%a" pp)
~retn:(fun {pf} -> pf "%a" (Option.pp "%a" pp))
@@ fun () ->
match fresh "c" s with
| None -> s
| Some (c, s) ->
let n = Trm.seq_size_exn a in
let* c, s = fresh "c" s in
let+ n, s =
match Trm.seq_size a with Some n -> Some (n, s) | None -> fresh "n" s
in
let n_c = Trm.sized ~siz:n ~seq:c in
let o_l = Trm.add o l in
let n_o_l = Trm.sub n o_l in
@ -221,7 +221,8 @@ let solve d e s =
(* v = α[o,l) ==> α[o,l) ↦ ⟨l,v⟩ when v ∈ fv(α[o,l)) *)
add_solved ~var:e ~rep:(Trm.sized ~siz:l ~seq:v) s
(* α[o,l) = β ==> … ∧ α = _^β^_ *)
| Some (Extract {seq= a; off= o; len= l}, e) -> solve_extract a o l e s
| Some (Extract {seq= a; off= o; len= l}, e) ->
Option.value (solve_extract a o l e s) ~default:s
(*
* Sized
*)

Loading…
Cancel
Save