Towards v1 -> v2 sygus conversion.
This makes several fixes and improvements related to printing sygus commands:
(1) The logic is extended with LIA, DT, UF internally during setDefaults instead of during parsing. This is the correct place for this extension of the logic since it should be applied regardless of the parser. 5 existing logic bugs were discovered as a result of this in regressions, which are fixed by this PR.
(2) Ensures that terms in sygus grammars are printed without letification, since this is prohibited in sygus. Notice the formulas printed by constraints need to be letified (otherwise we can't convert large lustre benchmarks). Thus, the letification threshold should determine this but always be overridden for grammar terms.
(3) Ensures final options are set for all sygus-specific commands, which follows the standards prescribed by sygus v2 (all set-* commands come before other commands).
warning("Logics in sygus are assumed to contain quantifiers.");
warning("Omit QF_ from the logic to avoid this warning.");
}
- // get unlocked copy, modify, copy and relock
- LogicInfo log(d_logic.getUnlockedCopy());
- // enable everything needed for sygus
- log.enableSygus();
- d_logic = log;
- d_logic.lock();
}
// Core theory belongs to every logic
void Printer::toStreamSygus(std::ostream& out, TNode n) const
{
// no sygus-specific printing associated with this printer,
- // just print the original term
- toStream(out, n, -1, false, 1);
+ // just print the original term, without letification (the fifth argument is
+ // set to 0).
+ toStream(out, n, -1, false, 0);
}
void Printer::toStream(std::ostream& out, const Model& m) const
{
out << "(";
}
- out << dt[cIndex].getSygusOp();
+ // print operator without letification (the fifth argument is set to 0).
+ toStream(out, dt[cIndex].getSygusOp(), -1, false, 0);
if (n.getNumChildren() > 0)
{
for (Node nc : n)
}
}
Node p = n.getAttribute(theory::SygusPrintProxyAttribute());
- if (!p.isNull())
+ if (p.isNull())
{
- out << p;
- }
- else
- {
- // cannot convert term to analog, print original
- out << n;
+ p = n;
}
+ // cannot convert term to analog, print original, without letification.
+ toStream(out, p, -1, false, 0);
}
static void toStream(std::ostream& out, const AssertCommand* c)
sbody =
sbody.substitute(vars.begin(), vars.end(), subs.begin(), subs.end());
+ // print to stream without letification
std::stringstream body_out;
- body_out << sbody;
+ p->toStream(body_out, sbody, -1, false, 0);
// do string substitution
Assert(e.getNumChildren() == d_args.size());
{
// since we are trying to recast as sygus, we assume the input is sygus
is_sygus = true;
- // we change the logic to incorporate sygus immediately
- d_logic = d_logic.getUnlockedCopy();
- d_logic.enableSygus();
- d_logic.lock();
}
}
+ // We now know whether the input is sygus. Update the logic to incorporate
+ // the theories we need internally for handling sygus problems.
+ if (is_sygus)
+ {
+ d_logic = d_logic.getUnlockedCopy();
+ d_logic.enableSygus();
+ d_logic.lock();
+ }
+
// sygus core connective requires unsat cores
if (options::sygusCoreConnective())
{
void SmtEngine::declareSygusVar(const std::string& id, Expr var, Type type)
{
+ SmtScope smts(this);
+ finalOptionsAreSet();
d_private->d_sygusVars.push_back(Node::fromExpr(var));
Trace("smt") << "SmtEngine::declareSygusVar: " << var << "\n";
Dump("raw-benchmark") << DeclareSygusVarCommand(id, var, type);
void SmtEngine::declareSygusPrimedVar(const std::string& id, Type type)
{
+ SmtScope smts(this);
+ finalOptionsAreSet();
// do nothing (the command is spurious)
Trace("smt") << "SmtEngine::declareSygusPrimedVar: " << id << "\n";
// don't need to set that the conjecture is stale
Expr var,
Type type)
{
+ SmtScope smts(this);
+ finalOptionsAreSet();
d_private->d_sygusVars.push_back(Node::fromExpr(var));
Trace("smt") << "SmtEngine::declareSygusFunctionVar: " << var << "\n";
Dump("raw-benchmark") << DeclareSygusVarCommand(id, var, type);
void SmtEngine::assertSygusConstraint(Expr constraint)
{
SmtScope smts(this);
+ finalOptionsAreSet();
d_private->d_sygusConstraints.push_back(constraint);
Trace("smt") << "SmtEngine::assertSygusConstrant: " << constraint << "\n";
const Expr& post)
{
SmtScope smts(this);
+ finalOptionsAreSet();
// build invariant constraint
// get variables (regular and their respective primed versions)
-; COMMAND-LINE: --sygus-out=status
+; COMMAND-LINE: --sygus-out=status --uf-ho
; EXPECT: unsat
-(set-logic LIA)
+(set-logic UFLIA)
(declare-fun uf (Int) Int)
; EXPECT: unsat
; COMMAND-LINE: --sygus-out=status
-(set-logic SAT)
+(set-logic LIA)
(synth-fun f () Bool)
(synth-fun g () Bool)
(synth-fun h () Bool)
; EXPECT: unsat
; COMMAND-LINE: --sygus-out=status --sygus-unif-pi=complete
-(set-logic SAT)
+(set-logic LIA)
(synth-fun u ((x Int)) Int)
(synth-fun f () Bool)
(synth-fun g () Bool)
; EXPECT: unsat
-; COMMAND-LINE: --sygus-out=status
-(set-logic LIA)
+; COMMAND-LINE: --sygus-out=status --uf-ho
+(set-logic UFLIA)
(declare-fun uf ( Int ) Int)
(synth-fun f ((x Int) (y Int)) Bool
((Start Bool (true false
; EXPECT: unsat
; COMMAND-LINE: --sygus-out=status
-(set-logic SLIA)
+(set-logic DTSLIA)
(declare-datatype DT ((A (a Int)) (B (b String)) (JSBool (jsBool Bool))))
(define-fun isA ((i DT)) Bool ((_ is A) i) )