@ -69,7 +69,6 @@ and T : sig
| Add of qset
| Mul of qset
| Label of { parent : string ; name : string }
| Float of { data : string }
| Integer of { data : Z . t }
| Rational of { data : Q . t }
| RecRecord of int
@ -92,7 +91,6 @@ end = struct
| Add of qset
| Mul of qset
| Label of { parent : string ; name : string }
| Float of { data : string }
| Integer of { data : Z . t }
| Rational of { data : Q . t }
| RecRecord of int
@ -260,7 +258,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
| Float { data } -> pf " %s " 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
@ -358,7 +355,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 float data = Float { data } | > check invariant
let label ~ parent ~ name = Label { parent ; name } | > check invariant
(* type conversions *)
@ -1044,7 +1040,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 _ | Float _ | Integer _ | Rational _ | RecRecord _ -> e
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> e
let fold_map e ~ init ~ f =
let s = ref init in
@ -1099,7 +1095,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 _ | Float _ | Integer _ | Rational _ | RecRecord _ -> ()
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> ()
let exists e ~ f =
match e with
@ -1110,8 +1106,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 _ | Float _ | Integer _ | Rational _ | RecRecord _ ->
false
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> false
let for_all e ~ f =
match e with
@ -1122,7 +1117,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 _ | Float _ | Integer _ | Rational _ | RecRecord _ -> true
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> true
let fold e ~ init : s ~ f =
match e with
@ -1133,7 +1128,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 _ | Float _ | Integer _ | Rational _ | RecRecord _ -> s
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> s
let rec iter_terms e ~ f =
( match e with
@ -1150,8 +1145,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 _ | Float _ | Integer _ | Rational _ | RecRecord _ -> ()
) ;
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> () ) ;
f e
let rec fold_terms e ~ init : s ~ f =
@ -1167,7 +1161,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 _ | Float _ | Integer _ | Rational _ | RecRecord _ -> s
| Var _ | Label _ | Integer _ | Rational _ | RecRecord _ -> s
in
f s e
@ -1190,7 +1184,7 @@ let is_false = function Integer {data} -> Z.is_false data | _ -> false
let rec is_constant = function
| Var _ -> false
| Label _ | Float _ | Integer _ | Rational _ -> true
| Label _ | Integer _ | Rational _ -> true
| a -> for_all ~ f : is_constant a
let rec height = function
@ -1204,7 +1198,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 _ | Float _ | Integer _ | Rational _ | RecRecord _ -> 0
| Label _ | Integer _ | Rational _ | RecRecord _ -> 0
(* * Solve *)