feat: decoders for LRA terms

This commit is contained in:
Simon Cruanes 2022-09-26 20:55:29 -04:00
parent 17ac25d314
commit dbe64f5975
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 39 additions and 17 deletions

View file

@ -141,23 +141,43 @@ let ops =
in in
{ Const.Ops.equal; hash; ser; pp } { Const.Ops.equal; hash; ser; pp }
(* TODO let const_decoders : Const.decoders =
let deser _tst = [
Ser_decode. ( "Qn",
[ ops,
( "Qn", Ser_decode.(
let* s = string in fun _ ->
let+ q = let* s = string in
unwrap_opt "expected rational number" let+ q =
(Sidekick_zarith.Rational.of_string s) unwrap_opt "expected rational number"
in (Sidekick_zarith.Rational.of_string s)
Const q ); in
( "Qp", Const q) );
let* s = string in ( "Qp",
let+ p = unwrap_opt "expected predicate" (Pred.of_string s) in ops,
Pred p ); Ser_decode.(
] fun _ ->
*) let* s = string in
let+ p = unwrap_opt "expected predicate" (Pred.of_string s) in
Pred p) );
( "Qo",
ops,
Ser_decode.(
fun _ ->
let* s = string in
let+ o = unwrap_opt "expected LRA operator" (Op.of_string s) in
Op o) );
( "Q*",
ops,
Ser_decode.(
fun _ ->
let* s = string in
let+ q =
unwrap_opt "expected rational number"
(Sidekick_zarith.Rational.of_string s)
in
Mult_by q) );
]
let real tst = Ty.real tst let real tst = Ty.real tst
let has_ty_real t = Ty.is_real (T.ty t) let has_ty_real t = Ty.is_real (T.ty t)

View file

@ -12,6 +12,8 @@ module Op : sig
include Sidekick_sigs.EQ_HASH_PRINT with type t := t include Sidekick_sigs.EQ_HASH_PRINT with type t := t
end end
val const_decoders : Const.decoders
module View : sig module View : sig
type ('num, 'a) lra_view = ('num, 'a) Sidekick_th_lra.lra_view = type ('num, 'a) lra_view = ('num, 'a) Sidekick_th_lra.lra_view =
| LRA_pred of Pred.t * 'a * 'a | LRA_pred of Pred.t * 'a * 'a