From 74ca9f79b0285a1139c217fbd6f3937ed66ac885 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Mon, 2 Dec 2019 11:15:16 -0600 Subject: [PATCH] Fix case of higher-order + sygus inference (#3509) --- src/preprocessing/passes/sygus_inference.cpp | 13 +++++++------ test/regress/CMakeLists.txt | 1 + test/regress/regress1/sygus/issue3507.smt2 | 8 ++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 test/regress/regress1/sygus/issue3507.smt2 diff --git a/src/preprocessing/passes/sygus_inference.cpp b/src/preprocessing/passes/sygus_inference.cpp index 6708f3c3a..24484359a 100644 --- a/src/preprocessing/passes/sygus_inference.cpp +++ b/src/preprocessing/passes/sygus_inference.cpp @@ -189,15 +189,16 @@ bool SygusInference::solveSygus(std::vector& 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); diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index da9679e2d..946f54650 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -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 index 000000000..aca7a61b0 --- /dev/null +++ b/test/regress/regress1/sygus/issue3507.smt2 @@ -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) -- 2.30.2