@@ -2860,19 +2860,41 @@ void smt2_convt::convert_plus(const plus_exprt &expr)
2860
2860
{
2861
2861
convert_expr (expr.op0 ());
2862
2862
}
2863
- else if (expr. operands (). size ()== 2 )
2863
+ else
2864
2864
{
2865
- if (expr.type ().id ()==ID_unsignedbv ||
2866
- expr.type ().id ()==ID_signedbv ||
2867
- expr.type ().id ()==ID_fixedbv)
2865
+ if (expr.type ().id ()==ID_rational ||
2866
+ expr.type ().id ()==ID_integer ||
2867
+ expr.type ().id ()==ID_real)
2868
+ {
2869
+ // these are multi-ary in SMT-LIB2
2870
+ out << " (+" ;
2871
+
2872
+ for (const auto &op : expr.operands ())
2873
+ {
2874
+ out << ' ' ;
2875
+ convert_expr (op);
2876
+ }
2877
+
2878
+ out << ' )' ;
2879
+ }
2880
+ else if (expr.type ().id ()==ID_unsignedbv ||
2881
+ expr.type ().id ()==ID_signedbv ||
2882
+ expr.type ().id ()==ID_fixedbv)
2868
2883
{
2869
2884
// These could be chained, i.e., need not be binary,
2870
2885
// but at least MathSat doesn't like that.
2871
- out << " (bvadd " ;
2872
- convert_expr (expr.op0 ());
2873
- out << " " ;
2874
- convert_expr (expr.op1 ());
2875
- out << " )" ;
2886
+ if (expr.operands ().size ()==2 )
2887
+ {
2888
+ out << " (bvadd " ;
2889
+ convert_expr (expr.op0 ());
2890
+ out << " " ;
2891
+ convert_expr (expr.op1 ());
2892
+ out << " )" ;
2893
+ }
2894
+ else
2895
+ {
2896
+ convert_plus (to_plus_expr (make_binary (expr)));
2897
+ }
2876
2898
}
2877
2899
else if (expr.type ().id ()==ID_floatbv)
2878
2900
{
@@ -2883,43 +2905,40 @@ void smt2_convt::convert_plus(const plus_exprt &expr)
2883
2905
}
2884
2906
else if (expr.type ().id ()==ID_pointer)
2885
2907
{
2886
- exprt p=expr.op0 (), i=expr.op1 ();
2908
+ if (expr.operands ().size ()==2 )
2909
+ {
2910
+ exprt p=expr.op0 (), i=expr.op1 ();
2887
2911
2888
- if (p.type ().id ()!=ID_pointer)
2889
- p.swap (i);
2912
+ if (p.type ().id ()!=ID_pointer)
2913
+ p.swap (i);
2890
2914
2891
- if (p.type ().id ()!=ID_pointer)
2892
- INVALIDEXPR (" unexpected mixture in pointer arithmetic" );
2915
+ if (p.type ().id ()!=ID_pointer)
2916
+ INVALIDEXPR (" unexpected mixture in pointer arithmetic" );
2893
2917
2894
- mp_integer element_size=
2895
- pointer_offset_size (expr.type ().subtype (), ns);
2896
- assert (element_size>0 );
2918
+ mp_integer element_size=
2919
+ pointer_offset_size (expr.type ().subtype (), ns);
2920
+ assert (element_size>0 );
2897
2921
2898
- out << " (bvadd " ;
2899
- convert_expr (p);
2900
- out << " " ;
2922
+ out << " (bvadd " ;
2923
+ convert_expr (p);
2924
+ out << " " ;
2901
2925
2902
- if (element_size>=2 )
2903
- {
2904
- out << " (bvmul " ;
2905
- convert_expr (i);
2906
- out << " (_ bv" << element_size
2907
- << " " << boolbv_width (expr.type ()) << " ))" ;
2926
+ if (element_size>=2 )
2927
+ {
2928
+ out << " (bvmul " ;
2929
+ convert_expr (i);
2930
+ out << " (_ bv" << element_size
2931
+ << " " << boolbv_width (expr.type ()) << " ))" ;
2932
+ }
2933
+ else
2934
+ convert_expr (i);
2935
+
2936
+ out << ' )' ;
2908
2937
}
2909
2938
else
2910
- convert_expr (i);
2911
-
2912
- out << " )" ;
2913
- }
2914
- else if (expr.type ().id ()==ID_rational ||
2915
- expr.type ().id ()==ID_integer ||
2916
- expr.type ().id ()==ID_real)
2917
- {
2918
- out << " (+ " ;
2919
- convert_expr (expr.op0 ());
2920
- out << " " ;
2921
- convert_expr (expr.op1 ());
2922
- out << " )" ;
2939
+ {
2940
+ convert_plus (to_plus_expr (make_binary (expr)));
2941
+ }
2923
2942
}
2924
2943
else if (expr.type ().id ()==ID_vector)
2925
2944
{
@@ -2963,10 +2982,6 @@ void smt2_convt::convert_plus(const plus_exprt &expr)
2963
2982
else
2964
2983
UNEXPECTEDCASE (" unsupported type for +: " +expr.type ().id_string ());
2965
2984
}
2966
- else
2967
- {
2968
- convert_plus (to_plus_expr (make_binary (expr)));
2969
- }
2970
2985
}
2971
2986
2972
2987
// / Converting a constant or symbolic rounding mode to SMT-LIB. Only called when
0 commit comments