Skip to content

Commit a73ac9d

Browse files
committed
SMT2 parser: support more FloatingPoint theory functions
Adds support for comparison operations and unary minus.
1 parent 8831b62 commit a73ac9d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/solvers/smt2/smt2_parser.cpp

+53
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,25 @@ exprt smt2_parsert::binary(irep_idt id, const exprt::operandst &op)
394394
return binary_exprt(op[0], id, op[1], op[0].type());
395395
}
396396

397+
exprt smt2_parsert::function_application_ieee_float_eq(
398+
const exprt::operandst &op)
399+
{
400+
if(op.size() != 2)
401+
throw error() << "FloatingPoint equality takes two operands";
402+
403+
if(op[0].type().id() != ID_floatbv || op[1].type().id() != ID_floatbv)
404+
throw error() << "FloatingPoint equality takes FloatingPoint operands";
405+
406+
if(op[0].type() != op[1].type())
407+
{
408+
throw error() << "FloatingPoint equality takes FloatingPoint operands with "
409+
<< "matching sort, but got " << smt2_format(op[0].type())
410+
<< " vs " << smt2_format(op[1].type());
411+
}
412+
413+
return ieee_float_equal_exprt(op[0], op[1]);
414+
}
415+
397416
exprt smt2_parsert::function_application_ieee_float_op(
398417
const irep_idt &id,
399418
const exprt::operandst &op)
@@ -745,6 +764,16 @@ exprt smt2_parsert::function_application()
745764

746765
return unary_predicate_exprt(ID_isinf, op[0]);
747766
}
767+
else if(id == "fp.isNormal")
768+
{
769+
if(op.size() != 1)
770+
throw error("fp.isNormal takes one operand");
771+
772+
if(op[0].type().id() != ID_floatbv)
773+
throw error("fp.isNormal takes FloatingPoint operand");
774+
775+
return isnormal_exprt(op[0]);
776+
}
748777
else if(id == "fp")
749778
{
750779
return function_application_fp(op);
@@ -754,6 +783,30 @@ exprt smt2_parsert::function_application()
754783
{
755784
return function_application_ieee_float_op(id, op);
756785
}
786+
else if(id == "fp.eq")
787+
{
788+
return function_application_ieee_float_eq(op);
789+
}
790+
else if(id == "fp.leq")
791+
{
792+
return binary_predicate(ID_le, op);
793+
}
794+
else if(id == "fp.lt")
795+
{
796+
return binary_predicate(ID_lt, op);
797+
}
798+
else if(id == "fp.geq")
799+
{
800+
return binary_predicate(ID_ge, op);
801+
}
802+
else if(id == "fp.gt")
803+
{
804+
return binary_predicate(ID_gt, op);
805+
}
806+
else if(id == "fp.neg")
807+
{
808+
return unary(ID_unary_minus, op);
809+
}
757810
else
758811
{
759812
// rummage through id_map

src/solvers/smt2/smt2_parser.h

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class smt2_parsert
122122
exprt function_application_ieee_float_op(
123123
const irep_idt &,
124124
const exprt::operandst &);
125+
exprt function_application_ieee_float_eq(const exprt::operandst &);
125126
exprt function_application_fp(const exprt::operandst &);
126127
typet sort();
127128
exprt::operandst operands();

0 commit comments

Comments
 (0)