Note this also corrects a few inconsistencies in how the rewriter is invoked in fast / variable agnostic enumeration.
Notably, fast enumeration now leverages the term datatype sygus for rewriting, meaning it can evaluate recursive functions for enumerated terms.
help = "internally use shared selectors across multiple constructors"
[[option]]
- name = "sygusSymBreak"
+ name = "sygusSimpleSymBreak"
category = "regular"
- long = "sygus-sym-break"
- type = "bool"
- default = "true"
- help = "simple sygus symmetry breaking lemmas"
-
-[[option]]
- name = "sygusSymBreakAgg"
- category = "regular"
- long = "sygus-sym-break-agg"
- type = "bool"
- default = "true"
- help = "use aggressive checks for simple sygus symmetry breaking lemmas"
-
-[[option]]
- name = "sygusSymBreakDynamic"
- category = "regular"
- long = "sygus-sym-break-dynamic"
- type = "bool"
- default = "true"
- help = "dynamic sygus symmetry breaking lemmas"
+ long = "sygus-simple-sym-break=MODE"
+ type = "SygusSimpleSymBreakMode"
+ default = "AGG"
+ help = "if and how to apply simple symmetry breaking based on the grammar for smart enumeration"
+ help_mode = "Modes for applying simple symmetry breaking based on the grammar for smart enumeration."
+[[option.mode.NONE]]
+ name = "none"
+ help = "Do not apply simple symmetry breaking."
+[[option.mode.BASIC]]
+ name = "basic"
+ help = "Apply basic simple symmetry breaking."
+[[option.mode.AGG]]
+ name = "agg"
+ help = "Apply aggressive simple symmetry breaking."
+
+[[option]]
+ name = "sygusRewriter"
+ category = "regular"
+ long = "sygus-rewriter=MODE"
+ type = "SygusRewriterMode"
+ default = "EXTENDED"
+ help = "if and how to apply rewriting for sygus symmetry breaking"
+ help_mode = "Modes for applying rewriting for sygus symmetry breaking."
+[[option.mode.NONE]]
+ name = "none"
+ help = "Do not use the rewriter."
+[[option.mode.BASIC]]
+ name = "basic"
+ help = "Use the basic rewriter."
+[[option.mode.EXTENDED]]
+ name = "extended"
+ help = "Use the extended rewriter."
[[option]]
name = "sygusSymBreakPbe"
default = "false"
help = "enumerate a stream of solutions instead of terminating after the first one"
-[[option]]
- name = "sygusExtRew"
- category = "regular"
- long = "sygus-ext-rew"
- type = "bool"
- default = "true"
- help = "use extended rewriter for sygus"
-
[[option]]
name = "cegisSample"
category = "regular"
opts.quantifiers.sygusRewSynth = true;
// we should not use the extended rewriter, since we are interested
// in rewrites that are not in the main rewriter
- if (!opts.quantifiers.sygusExtRewWasSetByUser)
+ if (!opts.datatypes.sygusRewriterWasSetByUser)
{
- opts.quantifiers.sygusExtRew = false;
+ opts.datatypes.sygusRewriter = options::SygusRewriterMode::BASIC;
}
}
// Whether we must use "basic" sygus algorithms. A non-basic sygus algorithm
// if we are the "any constant" constructor, we do no symmetry breaking
// only do simple symmetry breaking up to depth 2
- bool doSymBreak = options().datatypes.sygusSymBreak;
+ bool doSymBreak = options().datatypes.sygusSimpleSymBreak
+ != options::SygusSimpleSymBreakMode::NONE;
if (isAnyConstant || depth > 2)
{
doSymBreak = false;
<< ", type=" << tn << std::endl;
Node bv = d_tds->sygusToBuiltin(cnv, tn);
Trace("sygus-sb-debug") << " ......builtin is " << bv << std::endl;
- Node bvr = extendedRewrite(bv);
+ Node bvr = d_tds->rewriteNode(bv);
Trace("sygus-sb-debug") << " ......search value rewrites to " << bvr << std::endl;
Trace("dt-sygus") << " * DT builtin : " << n << " -> " << bvr << std::endl;
unsigned sz = utils::getSygusTermSize(nv);
// register the search value ( prog -> progv ), this may invoke symmetry
// breaking
- if (!isExc && options().datatypes.sygusSymBreakDynamic)
+ if (!isExc
+ && options().datatypes.sygusRewriter
+ != options::SygusRewriterMode::NONE)
{
bool isVarAgnostic = d_tds->isVariableAgnosticEnumerator(prog);
// check that it is unique up to theory-specific rewriting and
{
d_first = false;
Node bultin_value = d_tds->sygusToBuiltin(d_value, d_value.getType());
- d_perm_values.insert(extendedRewrite(bultin_value));
+ d_perm_values.insert(d_tds->rewriteNode(bultin_value));
return d_value;
}
unsigned n_classes = d_perm_state_class.size();
bultin_perm_value = d_tds->sygusToBuiltin(perm_value, perm_value.getType());
Trace("synth-stream-concrete-debug")
<< " ......perm builtin is " << bultin_perm_value;
- if (options().datatypes.sygusSymBreakDynamic)
+ if (options().datatypes.sygusRewriter != options::SygusRewriterMode::NONE)
{
- bultin_perm_value = extendedRewrite(bultin_perm_value);
+ bultin_perm_value = d_tds->rewriteNode(bultin_perm_value);
Trace("synth-stream-concrete-debug")
<< " and rewrites to " << bultin_perm_value;
}
// construction (unless it's equiv to a constant, e.g. true / false)
Node builtin_comb_value =
d_tds->sygusToBuiltin(comb_value, comb_value.getType());
- if (options().datatypes.sygusSymBreakDynamic)
+ if (options().datatypes.sygusRewriter != options::SygusRewriterMode::NONE)
{
- builtin_comb_value = extendedRewrite(builtin_comb_value);
+ builtin_comb_value = d_tds->rewriteNode(builtin_comb_value);
}
if (Trace.isOn("synth-stream-concrete"))
{
|| options().quantifiers.sygusEnumMode
== options::SygusEnumMode::AUTO);
// create the enumerator callback
- if (options().datatypes.sygusSymBreakDynamic)
+ if (options().datatypes.sygusRewriter
+ != options::SygusRewriterMode::NONE)
{
std::ostream* out = nullptr;
if (options().quantifiers.sygusRewVerify)
out = options().base.out;
}
d_secd = std::make_unique<SygusEnumeratorCallbackDefault>(
- d_env, e, &d_stats, d_eec.get(), d_samplerRrV.get(), out);
+ d_env, e, d_tds, &d_stats, d_eec.get(), d_samplerRrV.get(), out);
}
// if sygus repair const is enabled, we enumerate terms with free
// variables as arguments to any-constant constructors
Trace("sygus-enum") << "SygusEnumerator::initialize " << e << std::endl;
d_enum = e;
// allocate the default callback
- if (d_sec == nullptr && options().datatypes.sygusSymBreakDynamic)
+ if (d_sec == nullptr
+ && options().datatypes.sygusRewriter != options::SygusRewriterMode::NONE)
{
- d_secd =
- std::make_unique<SygusEnumeratorCallbackDefault>(d_env, e, d_stats);
+ d_secd = std::make_unique<SygusEnumeratorCallbackDefault>(
+ d_env, e, d_tds, d_stats);
d_sec = d_secd.get();
}
d_etype = d_enum.getType();
#include "theory/datatypes/sygus_datatype_utils.h"
#include "theory/quantifiers/sygus/example_eval_cache.h"
#include "theory/quantifiers/sygus/sygus_stats.h"
+#include "theory/quantifiers/sygus/term_database_sygus.h"
#include "theory/quantifiers/sygus_sampler.h"
#include "theory/rewriter.h"
SygusEnumeratorCallback::SygusEnumeratorCallback(Env& env,
Node e,
+ TermDbSygus* tds,
SygusStatistics* s)
- : EnvObj(env), d_enum(e), d_stats(s)
+ : EnvObj(env), d_enum(e), d_tds(tds), d_stats(s)
{
d_tn = e.getType();
}
bool SygusEnumeratorCallback::addTerm(Node n, std::unordered_set<Node>& bterms)
{
Node bn = datatypes::utils::sygusToBuiltin(n);
- Node bnr = extendedRewrite(bn);
+ Node bnr = d_tds == nullptr ? extendedRewrite(bn) : d_tds->rewriteNode(bn);
if (d_stats != nullptr)
{
++(d_stats->d_enumTermsRewrite);
SygusEnumeratorCallbackDefault::SygusEnumeratorCallbackDefault(
Env& env,
Node e,
+ TermDbSygus* tds,
SygusStatistics* s,
ExampleEvalCache* eec,
SygusSampler* ssrv,
std::ostream* out)
- : SygusEnumeratorCallback(env, e, s),
+ : SygusEnumeratorCallback(env, e, tds, s),
d_eec(eec),
d_samplerRrV(ssrv),
d_out(out)
class ExampleEvalCache;
class SygusStatistics;
class SygusSampler;
+class TermDbSygus;
/**
* Base class for callbacks in the fast enumerator. This allows a user to
class SygusEnumeratorCallback : protected EnvObj
{
public:
- SygusEnumeratorCallback(Env& env, Node e, SygusStatistics* s = nullptr);
+ SygusEnumeratorCallback(Env& env,
+ Node e,
+ TermDbSygus* tds = nullptr,
+ SygusStatistics* s = nullptr);
virtual ~SygusEnumeratorCallback() {}
/**
* Add term, return true if the term should be considered in the enumeration.
Node d_enum;
/** The type of enum */
TypeNode d_tn;
+ /** Term database sygus */
+ TermDbSygus* d_tds;
/** pointer to the statistics */
SygusStatistics* d_stats;
};
public:
SygusEnumeratorCallbackDefault(Env& env,
Node e,
+ TermDbSygus* tds = nullptr,
SygusStatistics* s = nullptr,
ExampleEvalCache* eec = nullptr,
SygusSampler* ssrv = nullptr,
Node TermDbSygus::rewriteNode(Node n) const
{
Node res;
- if (options().quantifiers.sygusExtRew)
+ if (options().datatypes.sygusRewriter == options::SygusRewriterMode::EXTENDED)
{
res = extendedRewrite(n);
}
}
return true;
}
- if (!options().datatypes.sygusSymBreakAgg)
+ if (options().datatypes.sygusSimpleSymBreak
+ != options::SygusSimpleSymBreakMode::AGG)
{
return false;
}
-; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=1000 --sygus-abort-size=3 --sygus-rr-verify-abort --no-sygus-sym-break
+; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=1000 --sygus-abort-size=3 --sygus-rr-verify-abort --sygus-simple-sym-break=none
; EXPECT: (error "Maximum term size (3) for enumerative SyGuS exceeded.")
; SCRUBBER: grep -v -E '(\(define-fun|\(candidate-rewrite)'
; EXIT: 1
-; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=1000 --sygus-abort-size=1 --sygus-rr-verify-abort --no-sygus-sym-break
+; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=1000 --sygus-abort-size=1 --sygus-rr-verify-abort --sygus-simple-sym-break=none
; EXPECT: (error "Maximum term size (1) for enumerative SyGuS exceeded.")
; SCRUBBER: grep -v -E '(\(define-fun|\(candidate-rewrite)'
; EXIT: 1
-; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=1000 --sygus-abort-size=2 --sygus-rr-verify-abort --no-sygus-sym-break
+; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=1000 --sygus-abort-size=2 --sygus-rr-verify-abort --sygus-simple-sym-break=none
; COMMAND-LINE: --lang=sygus2 --sygus-rr-synth --sygus-samples=1000 --sygus-abort-size=2 --sygus-rr-verify-abort --sygus-rr-synth-check
; EXPECT: (error "Maximum term size (2) for enumerative SyGuS exceeded.")
; SCRUBBER: grep -v -E '(\(define-fun|\(candidate-rewrite|\(rewrite)'
-; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=0 --sygus-rr-synth-check --sygus-abort-size=1 --sygus-rr-verify-abort --no-sygus-sym-break --fp-exp
+; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=0 --sygus-rr-synth-check --sygus-abort-size=1 --sygus-rr-verify-abort --sygus-simple-sym-break=none --fp-exp
; EXPECT: (error "Maximum term size (1) for enumerative SyGuS exceeded.")
; SCRUBBER: grep -v -E '(\(define-fun|\(rewrite)'
; EXIT: 1
-; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=0 --sygus-rr-synth-check --sygus-abort-size=1 --sygus-rr-verify-abort --no-sygus-sym-break --fp-exp
+; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=0 --sygus-rr-synth-check --sygus-abort-size=1 --sygus-rr-verify-abort --sygus-simple-sym-break=none --fp-exp
; EXPECT: (error "Maximum term size (1) for enumerative SyGuS exceeded.")
; SCRUBBER: grep -v -E '(\(define-fun|\(rewrite)'
; EXIT: 1
-; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=1000 --sygus-abort-size=1 --sygus-rr-verify-abort --no-sygus-sym-break
+; COMMAND-LINE: --lang=sygus2 --sygus-rr --sygus-samples=1000 --sygus-abort-size=1 --sygus-rr-verify-abort --sygus-simple-sym-break=none
; EXPECT: (error "Maximum term size (1) for enumerative SyGuS exceeded.")
; SCRUBBER: grep -v -E '(\(define-fun|\(candidate-rewrite)'
; EXIT: 1
(set-logic ALL)
(set-option :sygus-inference true)
-(set-option :sygus-sym-break false)
+(set-option :sygus-simple-sym-break none)
(set-option :sygus-sym-break-lazy false)
(set-option :sygus-sym-break-rlv false)
(set-info :status sat)