From 21ee0f18c288d430d08c133f601173be25411187 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Tue, 22 Jun 2021 18:26:58 -0500 Subject: [PATCH] Avoid full normalization of lambdas in getValue (#6787) This ensures that we don't apply lambda rewriting, which involves array value normalization, to lambda terms returned by TheoryModel::getValue. This can significantly speed up our time to return function terms for getValue. --- src/theory/theory_model.cpp | 18 ++++++++++++++++-- test/regress/regress0/define-fun-model.smt2 | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/theory/theory_model.cpp b/src/theory/theory_model.cpp index 8eec7f911..3e902463c 100644 --- a/src/theory/theory_model.cpp +++ b/src/theory/theory_model.cpp @@ -142,8 +142,22 @@ Node TheoryModel::getValue(TNode n) const Debug("model-getvalue-debug") << "[model-getvalue] getValue : substitute " << n << " to " << nn << std::endl; //get value in model nn = getModelValue(nn); - if (nn.isNull()) return nn; - if(options::condenseFunctionValues() || nn.getKind() != kind::LAMBDA) { + if (nn.isNull()) + { + return nn; + } + else if (nn.getKind() == kind::LAMBDA) + { + if (options::condenseFunctionValues()) + { + // normalize the body. Do not normalize the entire node, which + // involves array normalization. + NodeManager* nm = NodeManager::currentNM(); + nn = nm->mkNode(kind::LAMBDA, nn[0], Rewriter::rewrite(nn[1])); + } + } + else + { //normalize nn = Rewriter::rewrite(nn); } diff --git a/test/regress/regress0/define-fun-model.smt2 b/test/regress/regress0/define-fun-model.smt2 index c6ca206fc..8f197cd04 100644 --- a/test/regress/regress0/define-fun-model.smt2 +++ b/test/regress/regress0/define-fun-model.smt2 @@ -1,8 +1,8 @@ -; SCRUBBER: sed -e 's/BOUND_VARIABLE_[0-9]*/BOUND_VARIABLE/' +; SCRUBBER: sed -e 's/BOUND_VARIABLE_[0-9]*/V/; s/_arg_[0-9]*/V/' ; EXPECT: sat ; EXPECT: (((f 4) 7)) -; EXPECT: ((g (lambda ((BOUND_VARIABLE Int)) 7))) -; EXPECT: ((f (lambda ((BOUND_VARIABLE Int)) 7))) +; EXPECT: ((g (lambda ((V Int)) 7))) +; EXPECT: ((f (lambda ((V Int)) 7))) (set-logic UFLIA) (set-option :produce-models true) (define-fun f ((x Int)) Int 7) -- 2.30.2