GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/fun_def_evaluator.h Lines: 2 2 100.0 %
Date: 2021-09-29 Branches: 1 2 50.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Techniques for evaluating terms with recursively defined functions.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__QUANTIFIERS_FUN_DEF_EVALUATOR_H
19
#define CVC5__QUANTIFIERS_FUN_DEF_EVALUATOR_H
20
21
#include <map>
22
#include <vector>
23
24
#include "expr/node.h"
25
#include "smt/env_obj.h"
26
27
namespace cvc5 {
28
namespace theory {
29
namespace quantifiers {
30
31
/**
32
 * Techniques for evaluating recursively defined functions.
33
 */
34
class FunDefEvaluator : protected EnvObj
35
{
36
 public:
37
  FunDefEvaluator(Env& env);
38
2382
  ~FunDefEvaluator() {}
39
  /**
40
   * Assert definition of a (recursive) function definition given by quantified
41
   * formula q.
42
   */
43
  void assertDefinition(Node q);
44
  /**
45
   * Simplify node based on the (recursive) function definitions known by this
46
   * class. If n cannot be simplified to a constant, then this method returns
47
   * null.
48
   */
49
  Node evaluateDefinitions(Node n) const;
50
  /**
51
   * Has a call to assertDefinition been made? If this returns false, then
52
   * the evaluate method is the same as calling the rewriter, and returning
53
   * false if the result is non-constant.
54
   */
55
  bool hasDefinitions() const;
56
57
  /** Get definitions */
58
  const std::vector<Node>& getDefinitions() const;
59
  /** Get definition for function symbol f, if it is cached by this class */
60
  Node getDefinitionFor(Node f) const;
61
62
 private:
63
  /** information cached per function definition */
64
66
  class FunDefInfo
65
  {
66
   public:
67
    /** the quantified formula */
68
    Node d_quant;
69
    /** the body */
70
    Node d_body;
71
    /** the formal argument list */
72
    std::vector<Node> d_args;
73
  };
74
  /** maps functions to the above information */
75
  std::map<Node, FunDefInfo> d_funDefMap;
76
  /** list of all definitions */
77
  std::vector<Node> d_funDefs;
78
};
79
80
}  // namespace quantifiers
81
}  // namespace theory
82
}  // namespace cvc5
83
84
#endif