Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Implementation of beta reduction node conversion 11 : : */ 12 : : 13 : : #include "expr/beta_reduce_converter.h" 14 : : 15 : : namespace cvc5::internal { 16 : : 17 : : /** convert node n as described above during post-order traversal */ 18 : 24 : Node BetaReduceNodeConverter::postConvert(Node n) 19 : : { 20 : 72 : if (n.getKind() == Kind::APPLY_UF 21 [ - + ][ - - ]: 24 : && n.getOperator().getKind() == Kind::LAMBDA) [ - + ][ - + ] [ - - ] 22 : : { 23 : 0 : Node lam = n.getOperator(); 24 : 0 : std::vector<Node> vars(lam[0].begin(), lam[0].end()); 25 : 0 : std::vector<Node> subs(n.begin(), n.end()); 26 : : // only reduce if arity is correct 27 [ - - ]: 0 : if (vars.size() == subs.size()) 28 : : { 29 : : return lam[1].substitute( 30 : 0 : vars.begin(), vars.end(), subs.begin(), subs.end()); 31 : : } 32 [ - - ][ - - ]: 0 : } [ - - ] 33 : 24 : return n; 34 : : } 35 : : 36 : : } // namespace cvc5::internal