Fix case of higher-order + sygus inference (#3509)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Mon, 2 Dec 2019 17:15:16 +0000 (11:15 -0600)
committerGitHub <noreply@github.com>
Mon, 2 Dec 2019 17:15:16 +0000 (11:15 -0600)
src/preprocessing/passes/sygus_inference.cpp
test/regress/CMakeLists.txt
test/regress/regress1/sygus/issue3507.smt2 [new file with mode: 0644]

index 6708f3c3ab381a8d5a61f150ebe8533e71969eec..24484359a25c532ed2954124c3ff236b3be34410 100644 (file)
@@ -189,15 +189,16 @@ bool SygusInference::solveSygus(std::vector<Node>& assertions,
         if (cur.getKind() == APPLY_UF)
         {
           Node op = cur.getOperator();
-          if (std::find(free_functions.begin(), free_functions.end(), op)
-              == free_functions.end())
-          {
-            free_functions.push_back(op);
-          }
+          // visit the operator, which might not be a variable
+          visit.push_back(op);
         }
         else if (cur.isVar() && cur.getKind() != BOUND_VARIABLE)
         {
-          // a free variable is a 0-argument function to synthesize
+          // We are either in the case of a free first-order constant or a
+          // function in a higher-order context. We add to free_functions
+          // in either case. Note that a free constant that is not in a
+          // higher-order context is a 0-argument function-to-synthesize.
+          // We should not have traversed here before due to our visited cache.
           Assert(std::find(free_functions.begin(), free_functions.end(), cur)
                  == free_functions.end());
           free_functions.push_back(cur);
index da9679e2d249a8d2f5fdcce205dea8aa8308d889..946f54650544617767da631e2832cb394812e911 100644 (file)
@@ -1724,6 +1724,7 @@ set(regress_1_tests
   regress1/sygus/issue3320-quant.sy
   regress1/sygus/issue3461.sy
   regress1/sygus/issue3498.smt2
+  regress1/sygus/issue3507.smt2
   regress1/sygus/large-const-simp.sy
   regress1/sygus/let-bug-simp.sy
   regress1/sygus/list-head-x.sy
diff --git a/test/regress/regress1/sygus/issue3507.smt2 b/test/regress/regress1/sygus/issue3507.smt2
new file mode 100644 (file)
index 0000000..aca7a61
--- /dev/null
@@ -0,0 +1,8 @@
+; EXPECT: sat
+; COMMAND-LINE: --sygus-inference --uf-ho
+(set-logic ALL)
+(declare-fun f (Int) Bool)
+(declare-fun g (Int) Bool)
+(assert (and (distinct f g) (g 0)))
+(assert (exists ((x Int)) (f x)))
+(check-sat)