[sledge] Change encoding of program var ids to preserve original order

Summary:
Negating the ids of program variables leads to inverting the order on
them. This is logically fine, the order is still a valid total order.
But it can lead to choosing younger variables as equality class
representatives over older variables, and thereby lead to more churn
as adding an equality is more likely to cause a change of
representative, and hence additional normalizing rewrites.

Reviewed By: jvillard

Differential Revision: D26451304

fbshipit-source-id: eb20d1901
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent 3af760ee40
commit e33c7f6ce0

@ -78,7 +78,8 @@ module Trm3 = struct
let pf fmt = pp_boxed fs fmt in
match trm with
| Var {id; name} -> (
if id < 0 then Trace.pp_styled `Bold "%%%s!%i" fs name (-id)
if id < 0 then
Trace.pp_styled `Bold "%%%s!%i" fs name (id + Int.max_int)
else
match strength trm with
| None -> Format.fprintf fs "%%%s_%i" name id
@ -168,7 +169,7 @@ module Var = struct
let program ?(name = "") ~id =
assert (id > 0) ;
make ~id:(-id) ~name
make ~id:(id - Int.max_int) ~name
let identified ~name ~id = make ~id ~name
let of_ v = v |> check invariant

Loading…
Cancel
Save