[sledge] Sort numeric constants last

Reviewed By: jvillard

Differential Revision: D14344294

fbshipit-source-id: e6ecad5ef
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent 591d60e20a
commit efbd816dff

@ -70,9 +70,6 @@ module rec T : sig
| Label of {parent: string; name: string} | Label of {parent: string; name: string}
(* curried application *) (* curried application *)
| App of {op: t; arg: t} | App of {op: t; arg: t}
(* numeric constants *)
| Integer of {data: Z.t; typ: Typ.t}
| Float of {data: string}
(* binary: comparison *) (* binary: comparison *)
| Eq | Eq
| Dq | Dq
@ -107,8 +104,15 @@ module rec T : sig
| Struct_rec of {elts: t vector} (** NOTE: may be cyclic *) | Struct_rec of {elts: t vector} (** NOTE: may be cyclic *)
(* unary: conversion *) (* unary: conversion *)
| Convert of {signed: bool; dst: Typ.t; src: Typ.t} | Convert of {signed: bool; dst: Typ.t; src: Typ.t}
(* numeric constants *)
| Integer of {data: Z.t; typ: Typ.t}
| Float of {data: string}
[@@deriving compare, equal, hash, sexp] [@@deriving compare, equal, hash, sexp]
(* Note: solve (and invariant) requires Qset.min_elt to return a
non-coefficient, so Integer exps must compare higher than any valid
monomial *)
type comparator_witness type comparator_witness
val comparator : (t, comparator_witness) Comparator.t val comparator : (t, comparator_witness) Comparator.t
@ -131,8 +135,6 @@ and T0 : sig
| Nondet of {msg: string} | Nondet of {msg: string}
| Label of {parent: string; name: string} | Label of {parent: string; name: string}
| App of {op: t; arg: t} | App of {op: t; arg: t}
| Integer of {data: Z.t; typ: Typ.t}
| Float of {data: string}
| Eq | Eq
| Dq | Dq
| Gt | Gt
@ -161,6 +163,8 @@ and T0 : sig
| Update | Update
| Struct_rec of {elts: t vector} | Struct_rec of {elts: t vector}
| Convert of {signed: bool; dst: Typ.t; src: Typ.t} | Convert of {signed: bool; dst: Typ.t; src: Typ.t}
| Integer of {data: Z.t; typ: Typ.t}
| Float of {data: string}
[@@deriving compare, equal, hash, sexp] [@@deriving compare, equal, hash, sexp]
end = struct end = struct
type qset = Qset.M(T).t [@@deriving compare, equal, hash, sexp] type qset = Qset.M(T).t [@@deriving compare, equal, hash, sexp]
@ -175,8 +179,6 @@ end = struct
| Nondet of {msg: string} | Nondet of {msg: string}
| Label of {parent: string; name: string} | Label of {parent: string; name: string}
| App of {op: t; arg: t} | App of {op: t; arg: t}
| Integer of {data: Z.t; typ: Typ.t}
| Float of {data: string}
| Eq | Eq
| Dq | Dq
| Gt | Gt
@ -205,6 +207,8 @@ end = struct
| Update | Update
| Struct_rec of {elts: t vector} | Struct_rec of {elts: t vector}
| Convert of {signed: bool; dst: Typ.t; src: Typ.t} | Convert of {signed: bool; dst: Typ.t; src: Typ.t}
| Integer of {data: Z.t; typ: Typ.t}
| Float of {data: string}
[@@deriving compare, equal, hash, sexp] [@@deriving compare, equal, hash, sexp]
end end
@ -407,14 +411,11 @@ let assert_poly_term add_typ mono coeff =
let assert_polynomial poly = let assert_polynomial poly =
match poly with match poly with
| Add {typ; args} -> | Add {typ; args} ->
( match Qset.length args with ( match Qset.min_elt args with
| 0 -> assert false | None -> assert false
| 1 -> (
match Qset.min_elt args with
| Some (Integer _, _) -> assert false | Some (Integer _, _) -> assert false
| Some (_, k) -> assert (not (Q.equal Q.one k)) | Some (_, k) -> assert (Qset.length args > 1 || not (Q.equal Q.one k))
| _ -> () ) ) ;
| _ -> () ) ;
Qset.iter args ~f:(fun m c -> assert_poly_term typ m c |> Fn.id) Qset.iter args ~f:(fun m c -> assert_poly_term typ m c |> Fn.id)
| _ -> assert false | _ -> assert false

@ -40,10 +40,6 @@ and t = private
(** Address of named code block within parent function *) (** Address of named code block within parent function *)
| App of {op: t; arg: t} | App of {op: t; arg: t}
(** Application of function symbol to argument, curried *) (** Application of function symbol to argument, curried *)
| Integer of {data: Z.t; typ: Typ.t}
(** Integer constant, or if [typ] is a [Pointer], null pointer value
that never refers to an object *)
| Float of {data: string} (** Floating-point constant *)
| Eq (** Equal test *) | Eq (** Equal test *)
| Dq (** Disequal test *) | Dq (** Disequal test *)
| Gt (** Greater-than test *) | Gt (** Greater-than test *)
@ -75,6 +71,10 @@ and t = private
(transitively) from [elts]. NOTE: represented by cyclic values. *) (transitively) from [elts]. NOTE: represented by cyclic values. *)
| Convert of {signed: bool; dst: Typ.t; src: Typ.t} | Convert of {signed: bool; dst: Typ.t; src: Typ.t}
(** Convert between specified types, possibly with loss of information *) (** Convert between specified types, possibly with loss of information *)
| Integer of {data: Z.t; typ: Typ.t}
(** Integer constant, or if [typ] is a [Pointer], null pointer value
that never refers to an object *)
| Float of {data: string} (** Floating-point constant *)
[@@deriving compare, equal, hash, sexp] [@@deriving compare, equal, hash, sexp]
val comparator : (t, comparator_witness) Comparator.t val comparator : (t, comparator_witness) Comparator.t

Loading…
Cancel
Save