|
|
@ -30,8 +30,14 @@ type normal (** kind for normal props, i.e. normalized *)
|
|
|
|
|
|
|
|
|
|
|
|
type exposed (** kind for exposed props *)
|
|
|
|
type exposed (** kind for exposed props *)
|
|
|
|
|
|
|
|
|
|
|
|
type pi = Sil.atom list
|
|
|
|
type pi = Sil.atom list [@@deriving compare]
|
|
|
|
type sigma = Sil.hpred list
|
|
|
|
type sigma = Sil.hpred list [@@deriving compare]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let equal_pi pi1 pi2 =
|
|
|
|
|
|
|
|
compare_pi pi1 pi2 = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let equal_sigma sigma1 sigma2 =
|
|
|
|
|
|
|
|
compare_sigma sigma1 sigma2 = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module Core : sig
|
|
|
|
module Core : sig
|
|
|
@ -44,7 +50,7 @@ module Core : sig
|
|
|
|
pi: pi; (** pure part *)
|
|
|
|
pi: pi; (** pure part *)
|
|
|
|
sigma_fp : sigma; (** abduced spatial part *)
|
|
|
|
sigma_fp : sigma; (** abduced spatial part *)
|
|
|
|
pi_fp: pi; (** abduced pure part *)
|
|
|
|
pi_fp: pi; (** abduced pure part *)
|
|
|
|
}
|
|
|
|
} [@@deriving compare]
|
|
|
|
|
|
|
|
|
|
|
|
(** Proposition [true /\ emp]. *)
|
|
|
|
(** Proposition [true /\ emp]. *)
|
|
|
|
val prop_emp : normal t
|
|
|
|
val prop_emp : normal t
|
|
|
@ -72,7 +78,7 @@ end = struct
|
|
|
|
pi: pi; (** pure part *)
|
|
|
|
pi: pi; (** pure part *)
|
|
|
|
sigma_fp : sigma; (** abduced spatial part *)
|
|
|
|
sigma_fp : sigma; (** abduced spatial part *)
|
|
|
|
pi_fp: pi; (** abduced pure part *)
|
|
|
|
pi_fp: pi; (** abduced pure part *)
|
|
|
|
}
|
|
|
|
} [@@deriving compare]
|
|
|
|
|
|
|
|
|
|
|
|
(** Proposition [true /\ emp]. *)
|
|
|
|
(** Proposition [true /\ emp]. *)
|
|
|
|
let prop_emp : normal t =
|
|
|
|
let prop_emp : normal t =
|
|
|
@ -104,47 +110,13 @@ include Core
|
|
|
|
|
|
|
|
|
|
|
|
(** {1 Functions for Comparison} *)
|
|
|
|
(** {1 Functions for Comparison} *)
|
|
|
|
|
|
|
|
|
|
|
|
(** Comparison between lists of equalities and disequalities. Lexicographical order. *)
|
|
|
|
|
|
|
|
let rec pi_compare pi1 pi2 =
|
|
|
|
|
|
|
|
if pi1 == pi2 then 0
|
|
|
|
|
|
|
|
else match (pi1, pi2) with
|
|
|
|
|
|
|
|
| ([],[]) -> 0
|
|
|
|
|
|
|
|
| ([], _:: _) -> - 1
|
|
|
|
|
|
|
|
| (_:: _,[]) -> 1
|
|
|
|
|
|
|
|
| (a1:: pi1', a2:: pi2') ->
|
|
|
|
|
|
|
|
let n = Sil.compare_atom a1 a2 in
|
|
|
|
|
|
|
|
if n <> 0 then n
|
|
|
|
|
|
|
|
else pi_compare pi1' pi2'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let pi_equal pi1 pi2 =
|
|
|
|
|
|
|
|
pi_compare pi1 pi2 = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(** Comparsion between lists of heap predicates. Lexicographical order. *)
|
|
|
|
|
|
|
|
let rec sigma_compare sigma1 sigma2 =
|
|
|
|
|
|
|
|
if sigma1 == sigma2 then 0
|
|
|
|
|
|
|
|
else match (sigma1, sigma2) with
|
|
|
|
|
|
|
|
| ([],[]) -> 0
|
|
|
|
|
|
|
|
| ([], _:: _) -> - 1
|
|
|
|
|
|
|
|
| (_:: _,[]) -> 1
|
|
|
|
|
|
|
|
| (h1:: sigma1', h2:: sigma2') ->
|
|
|
|
|
|
|
|
let n = Sil.compare_hpred h1 h2 in
|
|
|
|
|
|
|
|
if n <> 0 then n
|
|
|
|
|
|
|
|
else sigma_compare sigma1' sigma2'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let sigma_equal sigma1 sigma2 =
|
|
|
|
|
|
|
|
sigma_compare sigma1 sigma2 = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(** Comparison between propositions. Lexicographical order. *)
|
|
|
|
(** Comparison between propositions. Lexicographical order. *)
|
|
|
|
let prop_compare p1 p2 =
|
|
|
|
let compare_prop p1 p2 =
|
|
|
|
sigma_compare p1.sigma p2.sigma
|
|
|
|
compare (fun _ _ -> 0) p1 p2
|
|
|
|
|> next Sil.compare_subst p1.sub p2.sub
|
|
|
|
|
|
|
|
|> next pi_compare p1.pi p2.pi
|
|
|
|
|
|
|
|
|> next sigma_compare p1.sigma_fp p2.sigma_fp
|
|
|
|
|
|
|
|
|> next pi_compare p1.pi_fp p2.pi_fp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(** Check the equality of two propositions *)
|
|
|
|
(** Check the equality of two propositions *)
|
|
|
|
let prop_equal p1 p2 =
|
|
|
|
let equal_prop p1 p2 =
|
|
|
|
prop_compare p1 p2 = 0
|
|
|
|
compare_prop p1 p2 = 0
|
|
|
|
|
|
|
|
|
|
|
|
(** {1 Functions for Pretty Printing} *)
|
|
|
|
(** {1 Functions for Pretty Printing} *)
|
|
|
|
|
|
|
|
|
|
|
@ -1445,7 +1417,7 @@ module Normalize = struct
|
|
|
|
let sigma_normalize tenv sub sigma =
|
|
|
|
let sigma_normalize tenv sub sigma =
|
|
|
|
let sigma' =
|
|
|
|
let sigma' =
|
|
|
|
IList.stable_sort Sil.compare_hpred (IList.map (hpred_normalize tenv sub) sigma) in
|
|
|
|
IList.stable_sort Sil.compare_hpred (IList.map (hpred_normalize tenv sub) sigma) in
|
|
|
|
if sigma_equal sigma sigma' then sigma else sigma'
|
|
|
|
if equal_sigma sigma sigma' then sigma else sigma'
|
|
|
|
|
|
|
|
|
|
|
|
let pi_tighten_ineq tenv pi =
|
|
|
|
let pi_tighten_ineq tenv pi =
|
|
|
|
let ineq_list, nonineq_list = IList.partition atom_is_inequality pi in
|
|
|
|
let ineq_list, nonineq_list = IList.partition atom_is_inequality pi in
|
|
|
@ -1543,7 +1515,7 @@ module Normalize = struct
|
|
|
|
Sil.compare_atom
|
|
|
|
Sil.compare_atom
|
|
|
|
((IList.filter filter_useful_atom nonineq_list) @ ineq_list) in
|
|
|
|
((IList.filter filter_useful_atom nonineq_list) @ ineq_list) in
|
|
|
|
let pi'' = pi_sorted_remove_redundant pi' in
|
|
|
|
let pi'' = pi_sorted_remove_redundant pi' in
|
|
|
|
if pi_equal pi0 pi'' then pi0 else pi''
|
|
|
|
if equal_pi pi0 pi'' then pi0 else pi''
|
|
|
|
|
|
|
|
|
|
|
|
(** normalize the footprint part, and rename any primed vars
|
|
|
|
(** normalize the footprint part, and rename any primed vars
|
|
|
|
in the footprint with fresh footprint vars *)
|
|
|
|
in the footprint with fresh footprint vars *)
|
|
|
|