GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/quant_util.h Lines: 5 7 71.4 %
Date: 2021-09-07 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Mathias Preiner
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
 * quantifier util
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__QUANT_UTIL_H
19
#define CVC5__THEORY__QUANT_UTIL_H
20
21
#include <iostream>
22
#include <map>
23
#include <vector>
24
25
#include "expr/node.h"
26
#include "theory/incomplete_id.h"
27
#include "theory/theory.h"
28
29
namespace cvc5 {
30
namespace theory {
31
32
/** Quantifiers utility
33
 *
34
 * This is a lightweight version of a quantifiers module that does not implement
35
 * methods for checking satisfiability.
36
 */
37
class QuantifiersUtil {
38
public:
39
49732
  QuantifiersUtil(){}
40
49717
  virtual ~QuantifiersUtil(){}
41
  /**  Called at the beginning of check-sat call. */
42
32934
  virtual void presolve() {}
43
  /* reset
44
   * Called at the beginning of an instantiation round
45
   * Returns false if the reset failed. When reset fails, the utility should
46
   * have added a lemma via a call to d_qim.addPendingLemma.
47
   */
48
  virtual bool reset(Theory::Effort e) { return true; }
49
  /* Called for new quantifiers */
50
  virtual void registerQuantifier(Node q) {}
51
  /** Identify this module (for debugging, dynamic configuration, etc..) */
52
  virtual std::string identify() const = 0;
53
  /** Check complete?
54
   *
55
   * Returns false if the utility's reasoning was globally incomplete
56
   * (e.g. "sat" must be replaced with "incomplete"). If this method returns
57
   * false, it should update incId to the reason for incompleteness.
58
   */
59
10922
  virtual bool checkComplete(IncompleteId& incId) { return true; }
60
};
61
62
class QuantPhaseReq
63
{
64
private:
65
  /** helper functions compute phase requirements */
66
  void computePhaseReqs( Node n, bool polarity, std::map< Node, int >& phaseReqs );
67
public:
68
  QuantPhaseReq(){}
69
  QuantPhaseReq( Node n, bool computeEq = false );
70
112466
  ~QuantPhaseReq(){}
71
  void initialize( Node n, bool computeEq );
72
  /** is phase required */
73
  bool isPhaseReq( Node lit ) { return d_phase_reqs.find( lit )!=d_phase_reqs.end(); }
74
  /** get phase requirement */
75
  bool getPhaseReq( Node lit ) { return d_phase_reqs.find( lit )==d_phase_reqs.end() ? false : d_phase_reqs[ lit ]; }
76
  /** phase requirements for each quantifier for each instantiation literal */
77
  std::map< Node, bool > d_phase_reqs;
78
  std::map< Node, bool > d_phase_reqs_equality;
79
  std::map< Node, Node > d_phase_reqs_equality_term;
80
81
  static void getPolarity( Node n, int child, bool hasPol, bool pol, bool& newHasPol, bool& newPol );
82
  static void getEntailPolarity( Node n, int child, bool hasPol, bool pol, bool& newHasPol, bool& newPol );
83
};
84
85
}
86
}  // namespace cvc5
87
88
#endif /* CVC5__THEORY__QUANT_UTIL_H */