This makes `--sygus-inference` a no-op for inputs where there is a free function whose sort cannot be handled in a sygus grammar.
It also fixes an issue where skolem variables were not being treated as functions-to-synthesize.
Fixes #3250 and fixes #3356.
#include "smt/smt_statistics_registry.h"
#include "theory/quantifiers/quantifiers_attributes.h"
#include "theory/quantifiers/quantifiers_rewriter.h"
+#include "theory/quantifiers/sygus/sygus_grammar_cons.h"
using namespace std;
using namespace CVC4::kind;
free_functions.push_back(op);
}
}
- else if (cur.getKind() == VARIABLE)
+ else if (cur.isVar() && cur.getKind() != BOUND_VARIABLE)
{
// a free variable is a 0-argument function to synthesize
Assert(std::find(free_functions.begin(), free_functions.end(), cur)
return false;
}
+ // Ensure the type of all free functions is handled by the sygus grammar
+ // constructor utility.
+ bool typeSuccess = true;
+ for (const Node& f : free_functions)
+ {
+ TypeNode tn = f.getType();
+ if (!theory::quantifiers::CegGrammarConstructor::isHandledType(tn))
+ {
+ Trace("sygus-infer") << "...fail: unhandled type " << tn << std::endl;
+ typeSuccess = false;
+ break;
+ }
+ }
+ if (!typeSuccess)
+ {
+ return false;
+ }
+
Assert(!processed_assertions.empty());
// conjunction of the assertions
Trace("sygus-infer") << "Construct body..." << std::endl;
}
}
+bool CegGrammarConstructor::isHandledType(TypeNode t)
+{
+ std::vector<TypeNode> types;
+ collectSygusGrammarTypesFor(t, types);
+ for (const TypeNode& tn : types)
+ {
+ if (tn.isSort() || tn.isFloatingPoint())
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
void CegGrammarConstructor::mkSygusDefaultGrammar(
TypeNode range,
Node bvl,
* sygus grammar, add them to vector ops.
*/
static void mkSygusConstantsForType(TypeNode type, std::vector<Node>& ops);
+ /** Is it possible to construct a default grammar for type t? */
+ static bool isHandledType(TypeNode t);
/**
* Convert node n based on deep embedding, see Section 4 of Reynolds et al
* CAV 2015.
regress0/sygus/dt-sel-parse1.sy
regress0/sygus/hd-05-d1-prog-nogrammar.sy
regress0/sygus/inv-different-var-order.sy
+ regress0/sygus/issue3356-syg-inf-usort.smt2
regress0/sygus/let-ringer.sy
regress0/sygus/let-simp.sy
regress0/sygus/no-syntax-test-bool.sy
regress1/quantifiers/is-even.smt2
regress1/quantifiers/isaplanner-goal20.smt2
regress1/quantifiers/issue2970-string-var-elim.smt2
+ regress1/quantifiers/issue3250-syg-inf-q.smt2
regress1/quantifiers/issue3317.smt2
regress1/quantifiers/issue993.smt2
regress1/quantifiers/javafe.ast.StmtVec.009.smt2
--- /dev/null
+; COMMAND-LINE: --sygus-inference
+; EXPECT: sat
+(set-logic ALL)
+(declare-sort S 1)
+(define-sort SB () (S Bool))
+(declare-fun A () (S Bool))
+(declare-fun B () SB)
+(assert (= A B))
+; do not do sygus inference due to uninterpreted sorts
+(check-sat)
+(exit)
--- /dev/null
+(set-logic ALL)
+(set-info :status unsat)
+(declare-fun a () Real)
+(assert
+ (and
+ (and
+ (exists ((?b Real)) (forall ((?c Real)) (exists ((?d Real))
+ (or (and (and (and (and (< (+ (+ (+ 0 (* 68.0 ?c)) 0) (* 33.0 a)) 0.0) (<= 0 2.0))
+ (or (<= 0 (+ (* (+ (* 55.0 ?d) 0) (* 49.0 ?b)) 0))))))))))
+ )
+ )
+)
+
+(check-sat)