From ef7e56f4217ece19b1caf743e5b1db0d3f549226 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Fri, 11 Oct 2019 14:00:56 -0500 Subject: [PATCH] Check that logic is set when synth-fun command is encountered (#3384) --- src/parser/smt2/Smt2.g | 2 ++ src/parser/smt2/smt2.cpp | 1 - test/regress/CMakeLists.txt | 1 + test/regress/regress0/sygus/no-logic.sy | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/regress/regress0/sygus/no-logic.sy diff --git a/src/parser/smt2/Smt2.g b/src/parser/smt2/Smt2.g index dc57be11e..0cce030b0 100644 --- a/src/parser/smt2/Smt2.g +++ b/src/parser/smt2/Smt2.g @@ -585,6 +585,7 @@ sygusCommand returns [std::unique_ptr cmd] ( SYNTH_FUN_V1_TOK { isInv = false; } | SYNTH_INV_V1_TOK { isInv = true; range = EXPR_MANAGER->booleanType(); } ) + { PARSER_STATE->checkThatLogicIsSet(); } symbol[fun,CHECK_UNDECLARED,SYM_VARIABLE] LPAREN_TOK sortedVarList[sortedVarNames] RPAREN_TOK ( sortSymbol[range,CHECK_DECLARED] )? @@ -606,6 +607,7 @@ sygusCommand returns [std::unique_ptr cmd] ( SYNTH_FUN_TOK { isInv = false; } | SYNTH_INV_TOK { isInv = true; range = EXPR_MANAGER->booleanType(); } ) + { PARSER_STATE->checkThatLogicIsSet(); } symbol[fun,CHECK_UNDECLARED,SYM_VARIABLE] LPAREN_TOK sortedVarList[sortedVarNames] RPAREN_TOK ( sortSymbol[range,CHECK_DECLARED] )? diff --git a/src/parser/smt2/smt2.cpp b/src/parser/smt2/smt2.cpp index 47ac2a11b..f9942049a 100644 --- a/src/parser/smt2/smt2.cpp +++ b/src/parser/smt2/smt2.cpp @@ -662,7 +662,6 @@ Smt2::SynthFunFactory::SynthFunFactory( std::vector>& sortedVarNames) : d_smt2(smt2), d_fun(fun), d_isInv(isInv) { - smt2->checkThatLogicIsSet(); if (range.isNull()) { smt2->parseError("Must supply return type for synth-fun."); diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index 96de4bafc..8d69a1a69 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -909,6 +909,7 @@ set(regress_0_tests regress0/sygus/issue3356-syg-inf-usort.smt2 regress0/sygus/let-ringer.sy regress0/sygus/let-simp.sy + regress0/sygus/no-logic.sy regress0/sygus/no-syntax-test-bool.sy regress0/sygus/no-syntax-test.sy regress0/sygus/parity-AIG-d0.sy diff --git a/test/regress/regress0/sygus/no-logic.sy b/test/regress/regress0/sygus/no-logic.sy new file mode 100644 index 000000000..76584d265 --- /dev/null +++ b/test/regress/regress0/sygus/no-logic.sy @@ -0,0 +1,14 @@ +; COMMAND-LINE: --sygus-out=status --lang=sygus2 +; EXPECT-ERROR: no-logic.sy:7.10: No set-logic command was given before this point. +; EXPECT-ERROR: no-logic.sy:7.10: CVC4 will make all theories available. +; EXPECT-ERROR: no-logic.sy:7.10: Consider setting a stricter logic for (likely) better performance. +; EXPECT-ERROR: no-logic.sy:7.10: To suppress this warning in the future use (set-logic ALL). +; EXPECT: unsat +(synth-fun f ((x Int)) Int + ((Start Int)) + ( + (Start Int (x)) + ) +) + +(check-synth) -- 2.30.2