@ -68,7 +68,6 @@ and T : sig
| Or of set
| Add of qset
| Mul of qset
| Label of { parent : string ; name : string }
| Integer of { data : Z . t }
| Rational of { data : Q . t }
| RecRecord of int
@ -90,7 +89,6 @@ end = struct
| Or of set
| Add of qset
| Mul of qset
| Label of { parent : string ; name : string }
| Integer of { data : Z . t }
| Rational of { data : Q . t }
| RecRecord of int
@ -258,7 +256,6 @@ let rec ppx strength fs term =
| Var _ as v -> Var . ppx strength fs ( Var . of_ v )
| Integer { data } -> Trace . pp_styled ` Magenta " %a " fs Z . pp data
| Rational { data } -> Trace . pp_styled ` Magenta " %a " fs Q . pp data
| Label { name } -> pf " %s " name
| Ap1 ( Signed { bits } , arg ) -> pf " ((s%i)@ %a) " bits pp arg
| Ap1 ( Unsigned { bits } , arg ) -> pf " ((u%i)@ %a) " bits pp arg
| Ap1 ( Convert { src ; dst } , arg ) ->
@ -355,7 +352,6 @@ let minus_one = integer Z.minus_one
let bool b = integer ( Z . of_bool b )
let true _ = bool true
let false _ = bool false
let label ~ parent ~ name = Label { parent ; name } | > check invariant
(* type conversions *)
@ -1040,7 +1036,7 @@ let map e ~f =
| Apply ( sym , xs ) -> mapN ( simp_apply sym ) ~ f xs
| PosLit ( sym , xs ) -> mapN ( simp_poslit sym ) ~ f xs
| NegLit ( sym , xs ) -> mapN ( simp_neglit sym ) ~ f xs
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> e
| Var _ | Integer _ | Rational _ | RecRecord _ -> e
let fold_map e ~ init ~ f =
let s = ref init in
@ -1095,7 +1091,7 @@ let iter e ~f =
IArray . iter ~ f xs
| And args | Or args -> Set . iter ~ f args
| Add args | Mul args -> Qset . iter ~ f : ( fun arg _ -> f arg ) args
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> ()
| Var _ | Integer _ | Rational _ | RecRecord _ -> ()
let exists e ~ f =
match e with
@ -1106,7 +1102,7 @@ let exists e ~f =
IArray . exists ~ f xs
| And args | Or args -> Set . exists ~ f args
| Add args | Mul args -> Qset . exists ~ f : ( fun arg _ -> f arg ) args
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> false
| Var _ | Integer _ | Rational _ | RecRecord _ -> false
let for_all e ~ f =
match e with
@ -1117,7 +1113,7 @@ let for_all e ~f =
IArray . for_all ~ f xs
| And args | Or args -> Set . for_all ~ f args
| Add args | Mul args -> Qset . for_all ~ f : ( fun arg _ -> f arg ) args
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> true
| Var _ | Integer _ | Rational _ | RecRecord _ -> true
let fold e ~ init : s ~ f =
match e with
@ -1128,7 +1124,7 @@ let fold e ~init:s ~f =
IArray . fold ~ f : ( fun s x -> f x s ) xs ~ init : s
| And args | Or args -> Set . fold ~ f : ( fun s e -> f e s ) args ~ init : s
| Add args | Mul args -> Qset . fold ~ f : ( fun e _ s -> f e s ) args ~ init : s
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> s
| Var _ | Integer _ | Rational _ | RecRecord _ -> s
let rec iter_terms e ~ f =
( match e with
@ -1145,7 +1141,7 @@ let rec iter_terms e ~f =
| And args | Or args -> Set . iter args ~ f : ( iter_terms ~ f )
| Add args | Mul args ->
Qset . iter args ~ f : ( fun arg _ -> iter_terms ~ f arg )
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> () ) ;
| Var _ | Integer _ | Rational _ | RecRecord _ -> () ) ;
f e
let rec fold_terms e ~ init : s ~ f =
@ -1161,7 +1157,7 @@ let rec fold_terms e ~init:s ~f =
Set . fold args ~ init : s ~ f : ( fun s x -> fold_terms f x s )
| Add args | Mul args ->
Qset . fold args ~ init : s ~ f : ( fun arg _ s -> fold_terms f arg s )
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> s
| Var _ | Integer _ | Rational _ | RecRecord _ -> s
in
f s e
@ -1184,7 +1180,7 @@ let is_false = function Integer {data} -> Z.is_false data | _ -> false
let rec is_constant = function
| Var _ -> false
| Label _ | Integer _ | Rational _ -> true
| Integer _ | Rational _ -> true
| a -> for_all ~ f : is_constant a
let rec height = function
@ -1198,7 +1194,7 @@ let rec height = function
1 + Set . fold bs ~ init : 0 ~ f : ( fun m a -> max m ( height a ) )
| Add qs | Mul qs ->
1 + Qset . fold qs ~ init : 0 ~ f : ( fun a _ m -> max m ( height a ) )
| Label _ | Integer _ | Rational _ | RecRecord _ -> 0
| Integer _ | Rational _ | RecRecord _ -> 0
(* * Solve *)