Check that logic is set when synth-fun command is encountered (#3384)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Fri, 11 Oct 2019 19:00:56 +0000 (14:00 -0500)
committerGitHub <noreply@github.com>
Fri, 11 Oct 2019 19:00:56 +0000 (14:00 -0500)
src/parser/smt2/Smt2.g
src/parser/smt2/smt2.cpp
test/regress/CMakeLists.txt
test/regress/regress0/sygus/no-logic.sy [new file with mode: 0644]

index dc57be11e446d727e83209c259e5e55e5c06180a..0cce030b0b7cef626394854a8339e23da692f1e4 100644 (file)
@@ -585,6 +585,7 @@ sygusCommand returns [std::unique_ptr<CVC4::Command> 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<CVC4::Command> 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] )?
index 47ac2a11bf3cc5f9fba1652b11d33078d2c72e50..f9942049a78d460f04d2c0599aa1aed0f045c1dc 100644 (file)
@@ -662,7 +662,6 @@ Smt2::SynthFunFactory::SynthFunFactory(
     std::vector<std::pair<std::string, CVC4::Type>>& sortedVarNames)
     : d_smt2(smt2), d_fun(fun), d_isInv(isInv)
 {
-  smt2->checkThatLogicIsSet();
   if (range.isNull())
   {
     smt2->parseError("Must supply return type for synth-fun.");
index 96de4bafc92496c6dbf444a93af395190343b8d9..8d69a1a69477715935bd2a9e6cb3279756c3957d 100644 (file)
@@ -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 (file)
index 0000000..76584d2
--- /dev/null
@@ -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)