@@ -57,6 +57,13 @@ let symbol_aux fmt s =
57
57
| Unprintable ->
58
58
_cannot_print " symbol \" %s\" cannot be printed due to lexical constraints" s
59
59
60
+ let index fmt s =
61
+ if Misc. lex_string Lexer. check_num s then
62
+ Format. pp_print_string fmt s
63
+ else
64
+ symbol_aux fmt s
65
+
66
+
60
67
let symbol fmt name =
61
68
match (name : Dolmen_std.Name.t ) with
62
69
| Simple s ->
@@ -66,7 +73,7 @@ let symbol fmt name =
66
73
| Indexed { basename; indexes; } ->
67
74
let pp_sep fmt () = Format. fprintf fmt " " in
68
75
Format. fprintf fmt " (_ %a %a)"
69
- symbol_aux basename (Format. pp_print_list ~pp_sep symbol_aux ) indexes
76
+ symbol_aux basename (Format. pp_print_list ~pp_sep index ) indexes
70
77
| Qualified _ ->
71
78
_cannot_print " qualified identifier: %a" Dolmen_std.Name. print name
72
79
@@ -410,6 +417,7 @@ module Make
410
417
in
411
418
412
419
(* small shorthand *)
420
+ let int = string_of_int in
413
421
let p ?omit_to_real ns name =
414
422
aux ?omit_to_real (Dolmen_std.Id. create ns name) args
415
423
in
@@ -504,7 +512,7 @@ module Make
504
512
end
505
513
506
514
(* Bitvectors *)
507
- | B. Bitvec s -> p (Value Binary ) (N. simple s ) (* TODO: see if we can recover hex form ? *)
515
+ | B. Bitvec s -> p (Value Binary ) (N. simple ( " #b " ^ s) ) (* TODO: see if we can recover hex form ? *)
508
516
| B. Bitv_not _ -> simple " bvnot"
509
517
| B. Bitv_and _ -> simple " bvand"
510
518
| B. Bitv_or _ -> simple " bvor"
@@ -528,6 +536,66 @@ module Make
528
536
| B. Bitv_ugt _ -> simple " bvugt"
529
537
| B. Bitv_uge _ -> simple " bvuge"
530
538
| B. Bitv_slt _ -> simple " bvslt"
539
+ | B. Bitv_sle _ -> simple " bvsle"
540
+ | B. Bitv_sgt _ -> simple " bvsgt"
541
+ | B. Bitv_sge _ -> simple " bvsge"
542
+ | B. Bitv_concat _ -> simple " concat"
543
+ | B. Bitv_repeat { n = _ ; k; } -> p Term (N. indexed " repeat" [int k])
544
+ | B. Bitv_zero_extend { n = _ ; k; } -> p Term (N. indexed " zero_extend" [int k])
545
+ | B. Bitv_sign_extend { n = _ ; k; } -> p Term (N. indexed " sign_extend" [int k])
546
+ | B. Bitv_rotate_right { n = _ ; i; } -> p Term (N. indexed " rotate_right" [int i])
547
+ | B. Bitv_rotate_left { n = _ ; i; } -> p Term (N. indexed " rotate_left" [int i])
548
+ | B. Bitv_extract { n = _ ; i; j; } -> p Term (N. indexed " extract" [int i; int j])
549
+
550
+ (* bvconv extension
551
+ TODO: use a flag to enable extensions such as this one ? *)
552
+ | B. Bitv_to_nat { n = _ ; } -> simple " bv2nat"
553
+ | B. Bitv_of_int { n } -> p Term (N. indexed " int2bv" [int n])
554
+
555
+ (* Floats *)
556
+ | B. Fp _ -> simple " fp"
557
+ | B. RoundNearestTiesToEven -> simple " RNE"
558
+ | B. RoundNearestTiesToAway -> simple " RNA"
559
+ | B. RoundTowardPositive -> simple " RTP"
560
+ | B. RoundTowardNegative -> simple " RTN"
561
+ | B. RoundTowardZero -> simple " RTZ"
562
+ | B. Fp_abs _ -> simple " fp.abs"
563
+ | B. Fp_neg _ -> simple " fp.neg"
564
+ | B. Fp_add _ -> simple " fp.add"
565
+ | B. Fp_sub _ -> simple " fp.sub"
566
+ | B. Fp_mul _ -> simple " fp.mul"
567
+ | B. Fp_div _ -> simple " fp.div"
568
+ | B. Fp_fma _ -> simple " fp.fma"
569
+ | B. Fp_sqrt _ -> simple " fp.sqrt"
570
+ | B. Fp_rem _ -> simple " fp.rem"
571
+ | B. Fp_roundToIntegral _ -> simple " fp.roundToInegral"
572
+ | B. Fp_min _ -> simple " fp.min"
573
+ | B. Fp_max _ -> simple " fp.max"
574
+ | B. Fp_leq _ -> simple " fp.leq"
575
+ | B. Fp_lt _ -> simple " fp.lt"
576
+ | B. Fp_geq _ -> simple " fp.geq"
577
+ | B. Fp_gt _ -> simple " fp.gt"
578
+ | B. Fp_eq _ -> simple " fp.eq"
579
+ | B. Fp_isNormal _ -> simple " fp.isNormal"
580
+ | B. Fp_isSubnormal _ -> simple " fp.isSubnormal"
581
+ | B. Fp_isZero _ -> simple " fp.isZero"
582
+ | B. Fp_isInfinite _ -> simple " fp.isInfinite"
583
+ | B. Fp_isNaN _ -> simple " fp.isNan"
584
+ | B. Fp_isNegative _ -> simple " fp.isNegative"
585
+ | B. Fp_isPositive _ -> simple " fp.isPositive"
586
+ | B. To_real _ -> simple " fp.to_real"
587
+ | B. Plus_infinity (e , s ) -> p Term (N. indexed " +oo" [int e; int s])
588
+ | B. Minus_infinity (e , s ) -> p Term (N. indexed " -oo" [int e; int s])
589
+ | B. Plus_zero (e , s ) -> p Term (N. indexed " +zero" [int e; int s])
590
+ | B. Minus_zero (e , s ) -> p Term (N. indexed " -zero" [int e; int s])
591
+ | B. NaN (e , s ) -> p Term (N. indexed " NaN" [int e; int s])
592
+ | B. Ieee_format_to_fp (e , s ) -> p Term (N. indexed " to_fp" [int e; int s])
593
+ | B. Fp_to_fp (_ , _ , e , s ) -> p Term (N. indexed " to_fp" [int e; int s])
594
+ | B. Real_to_fp (e , s ) -> p Term (N. indexed " to_fp" [int e; int s])
595
+ | B. Sbv_to_fp (_ , e , s ) -> p Term (N. indexed " to_fp" [int e; int s])
596
+ | B. Ubv_to_fp (_ , e , s ) -> p Term (N. indexed " to_fp_unsigned" [int e; int s])
597
+ | B. To_ubv (_ , _ , m ) -> p Term (N. indexed " fp.to_ubv" [int m])
598
+ | B. To_sbv (_ , _ , m ) -> p Term (N. indexed " fp.to_sbv" [int m])
531
599
532
600
(* fallback *)
533
601
| _ -> _cannot_print " unknown term builtin"
@@ -624,7 +692,7 @@ module Make
624
692
let datatype_dec env fmt (_ , vars , cases ) =
625
693
match vars with
626
694
| [] ->
627
- Format. fprintf fmt " @[<v 1>(%a)@]" (list constructor_dec env) cases
695
+ Format. fprintf fmt " @[<hv 1>(%a)@]" (list constructor_dec env) cases
628
696
| _ ->
629
697
let env = List. fold_left Env.Ty_var. bind env vars in
630
698
Format. fprintf fmt " (par (%a)@ @[<v 1>(%a))@]"
@@ -720,7 +788,7 @@ module Make
720
788
Format. fprintf fmt " (declare-sort %a %d)" (symbol env) name n
721
789
722
790
let declare_datatype env fmt ((c , _ , _ ) as dec ) =
723
- Format. fprintf fmt " @[<hov 2>(declare-datatype %a@ %a)@]"
791
+ Format. fprintf fmt " @[<hv 2>(declare-datatype %a@ %a)@]"
724
792
(ty_cst env) c
725
793
(datatype_dec env) dec
726
794
@@ -758,7 +826,7 @@ module Make
758
826
759
827
let define_fun_aux ~recursive env fmt (f , params , body ) =
760
828
let env = List. fold_left Env.Term_var. bind env params in
761
- Format. fprintf fmt " @[<hv 2>(@[<hov 1>%s %a@ (%a) %a@]@ %a )@]"
829
+ Format. fprintf fmt " @[<hv 2>(@[<hov 1>%s %a@ (%a) %a@]@ @[<hov>%a@] )@]"
762
830
(if recursive then " define-fun-rec" else " define-fun" )
763
831
(term_cst env) f
764
832
(list sorted_var env) params
0 commit comments