SMTExpr GenLetExpression::ToSMT(TheoremProver* TP, const uint32* ParamMap, const vector<SMTExpr>& BaseExprs, vector<SMTExpr>& Assumptions) const { // Create new bindings, but push them AFTER the current vars have // been bound. These bindings should not be visible WHILE // the current bindings are being computed map<uint32, SMTExpr> NewBindingSMT(LetBindingSMTStack.back()); vector<SMTExpr> NewAssumptions; for (uint32 i = 0; i < NumBindings; ++i) { if (Bindings[i] != nullptr) { // Make the assumptions auto BindingAsSMT = Bindings[i]->ToSMT(TP, ParamMap, BaseExprs, Assumptions); auto CurVar = TP->CreateVarExpr((string)"LetVar_" + to_string(i) + "_" + to_string(FreshVarID++), BindingAsSMT.GetSort()); auto CurAssumption = TP->CreateEQExpr(CurVar, BindingAsSMT); NewAssumptions.push_back(CurAssumption); NewBindingSMT[i] = CurVar; } } // Now push the assumptions and SMTfy the expression itself LetBindingSMTStack.push_back(NewBindingSMT); Assumptions.insert(Assumptions.end(), NewAssumptions.begin(), NewAssumptions.end()); auto Retval = LetBoundExp->ToSMT(TP, ParamMap, BaseExprs, Assumptions); LetBindingSMTStack.pop_back(); return Retval; }
void SynthLib2ESolver::VisitLiteralGTerm(const LiteralGTerm* TheTerm) { auto Lit = TheTerm->GetLiteral(); auto const& LitString = Lit->GetLiteralString(); auto LitType = Lit->GetSort(); LitType->Accept(this); auto Type = SortStack.back(); SortStack.pop_back(); ProcessedGTermStack.push_back(SynthGrammar->MakeConstFromLiteral(LitString, Type)); }
void SynthLib2ESolver::VisitLiteralTerm(const LiteralTerm* TheTerm) { auto TheLit = TheTerm->GetLiteral(); TheLit->GetSort()->Accept(this); auto Type = SortStack.back(); SortStack.pop_back(); auto Val = Solver->CreateValue(Type, TheLit->GetLiteralString()); auto Exp = Solver->CreateExpression(Val); ProcessedTermStack.push_back(Exp); }
void SymtabBuilder::VisitNamedSortExpr(const NamedSortExpr* Sort) { // Check that the named sort actually resolves to something auto STE = TheSymbolTable->LookupSort(Sort->GetName()); if(STE == NULL || STE->GetKind() != STENTRY_SORT) { throw SynthLib2ParserException((string)"Sort name \"" + Sort->GetName() + "\" could not " + "be resolved to anything meaningful.\n" + Sort->GetLocation().ToString()); } auto SortE = STE->GetSort(); if (TheSymbolTable->ResolveSort(SortE) == NULL) { throw SynthLib2ParserException((string)"Sort name \"" + Sort->GetName() + "\" could not " + "be resolved to anything meaningful.\n" + Sort->GetLocation().ToString()); } // Do nothing otherwise return; }