@ -108,6 +108,8 @@ let _Update rcd idx elt = Update {rcd; idx; elt}
let _ Tuple es = Tuple es
let _ Project ary idx tup = Project { ary ; idx ; tup }
let _ Apply f a = Apply ( f , a )
let zero = Z Z . zero
let one = Z Z . one
(*
* ( Uninterpreted ) Predicate Symbols
@ -187,12 +189,25 @@ end = struct
| UNegLit of Predsym . t * trm
[ @@ deriving compare , equal , sexp ]
(* * Some normalization is necessary for [embed_into_fml] ( defined below )
to be left inverse to [ embed_into_cnd ] . Essentially
[ 0 ≠ ( p ? 1 : 0 ) ] needs to normalize to [ p ] , by way of
[ 0 ≠ ( p ? 1 : 0 ) ] = = > [ ( p ? 0 ≠ 1 : 0 ≠ 0 ) ] = = > [ ( p ? tt : ff ) ]
= = > [ p ] . * )
let _ Tt = Tt
let _ Ff = Ff
let _ Eq x y = Eq ( x , y )
let _ Dq x y = Dq ( x , y )
let _ Eq0 x = Eq0 x
let _ Dq0 x = Dq0 x
let _ Dq0 = function
(* 0 ≠ 0 ==> ff *)
| Z _ as z when z = = zero -> Ff
(* 0 ≠ N ==> tt for N ≢ 0 *)
| Z _ -> Tt
| t -> Dq0 t
let _ Gt0 x = Gt0 x
let _ Ge0 x = Ge0 x
let _ Lt0 x = Lt0 x
@ -201,7 +216,13 @@ end = struct
let _ Or p q = Or ( p , q )
let _ Iff p q = Iff ( p , q )
let _ Xor p q = Xor ( p , q )
let _ Cond cnd pos neg = Cond { cnd ; pos ; neg }
let _ Cond cnd pos neg =
match ( pos , neg ) with
(* ( p ? tt : ff ) ==> p *)
| Tt , Ff -> cnd
| _ -> Cond { cnd ; pos ; neg }
let _ UPosLit p x = UPosLit ( p , x )
let _ UNegLit p x = UNegLit ( p , x )
end
@ -676,9 +697,6 @@ let map_vars ~f = function
* and formulas stratified below conditional terms and then expressions .
* )
let zero = Z Z . zero
let one = Z Z . one
(* * Map a unary function on terms over the leaves of a conditional term,
rebuilding the tree of conditionals with the supplied ite construction
function . * )
@ -723,26 +741,7 @@ let project_out_fml : cnd -> fml option = function
[ 0 ≠ x ] holds . * )
let embed_into_fml : exp -> fml = function
| ` Fml fml -> fml
| # cnd as c ->
(* Some normalization is necessary for [embed_into_fml] to be left
inverse to [ embed_into_cnd ] . Essentially [ 0 ≠ ( p ? 1 : 0 ) ] needs to
normalize to [ p ] , by way of [ 0 ≠ ( p ? 1 : 0 ) ] = = > [ ( p ? 0 ≠ 1 : 0 ≠
0 ) ] = = > [ ( p ? tt : ff ) ] = = > [ p ] . * )
let dq0 : trm -> fml = function
(* 0 ≠ 0 ==> ff *)
| Z _ as z when z = = zero -> _ Ff
(* 0 ≠ N ==> tt for N≠0 *)
| Z _ -> _ Tt
| t -> _ Dq zero t
in
let cond : fml -> fml -> fml -> fml =
fun cnd pos neg ->
match ( pos , neg ) with
(* ( p ? tt : ff ) ==> p *)
| Tt , Ff -> cnd
| _ -> _ Cond cnd pos neg
in
map_cnd cond dq0 c
| # cnd as c -> map_cnd _ Cond _ Dq0 c
(* * Construct a conditional term, or formula if possible precisely. *)
let ite : fml -> exp -> exp -> exp =