GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/ematching/inst_strategy_e_matching.h Lines: 3 3 100.0 %
Date: 2021-05-24 Branches: 10 14 71.4 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters, 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
 * E-matching instantiation strategies.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__INST_STRATEGY_E_MATCHING_H
19
#define CVC5__INST_STRATEGY_E_MATCHING_H
20
21
#include "theory/quantifiers/ematching/inst_strategy.h"
22
#include "theory/quantifiers/ematching/trigger.h"
23
#include "theory/quantifiers/quant_relevance.h"
24
25
namespace cvc5 {
26
namespace theory {
27
namespace quantifiers {
28
29
/**
30
 * This class is responsible for instantiating quantifiers based on
31
 * automatically generated triggers. It selects pattern terms, generates
32
 * and manages triggers, and uses a strategy for processing them.
33
 */
34
class InstStrategyAutoGenTriggers : public InstStrategy
35
{
36
 public:
37
  enum
38
  {
39
    RELEVANCE_NONE,
40
    RELEVANCE_DEFAULT,
41
  };
42
43
 private:
44
  /** trigger generation strategy */
45
  options::TriggerSelMode d_tr_strategy;
46
  /** regeneration */
47
  bool d_regenerate;
48
  int d_regenerate_frequency;
49
  /** (single,multi) triggers for each quantifier */
50
  std::map<Node, std::map<inst::Trigger*, bool> > d_auto_gen_trigger[2];
51
  std::map<Node, int> d_counter;
52
  /** single, multi triggers for each quantifier */
53
  std::map<Node, std::vector<Node> > d_patTerms[2];
54
  std::map<Node, std::map<Node, bool> > d_patReqPol;
55
  /** information about triggers */
56
  std::map<Node, bool> d_is_single_trigger;
57
  std::map<Node, bool> d_single_trigger_gen;
58
  std::map<Node, bool> d_made_multi_trigger;
59
  // processed trigger this round
60
  std::map<Node, std::map<inst::Trigger*, bool> > d_processed_trigger;
61
  // instantiation no patterns
62
  std::map<Node, std::vector<Node> > d_user_no_gen;
63
  // number of trigger variables per quantifier
64
  std::map<Node, unsigned> d_num_trigger_vars;
65
  std::map<Node, Node> d_vc_partition[2];
66
  std::map<Node, Node> d_pat_to_mpat;
67
68
 private:
69
  /** process functions */
70
  void processResetInstantiationRound(Theory::Effort effort) override;
71
  /** Process */
72
  InstStrategyStatus process(Node q, Theory::Effort effort, int e) override;
73
  /**
74
   * Generate triggers for quantified formula q.
75
   */
76
  void generateTriggers(Node q);
77
  /**
78
   * Generate pattern terms for quantified formula q.
79
   */
80
  bool generatePatternTerms(Node q);
81
  void addPatternToPool(Node q, Node pat, unsigned num_fv, Node mpat);
82
  void addTrigger(inst::Trigger* tr, Node f);
83
  /** has user patterns */
84
  bool hasUserPatterns(Node q);
85
  /** has user patterns */
86
  std::map<Node, bool> d_hasUserPatterns;
87
88
 public:
89
  InstStrategyAutoGenTriggers(inst::TriggerDatabase& td,
90
                              QuantifiersState& qs,
91
                              QuantifiersInferenceManager& qim,
92
                              QuantifiersRegistry& qr,
93
                              TermRegistry& tr,
94
                              QuantRelevance* qrlv);
95
12310
  ~InstStrategyAutoGenTriggers() {}
96
97
  /** get auto-generated trigger */
98
  inst::Trigger* getAutoGenTrigger(Node q);
99
  /** identify */
100
84054
  std::string identify() const override
101
  {
102
84054
    return std::string("AutoGenTriggers");
103
  }
104
  /** add pattern */
105
  void addUserNoPattern(Node q, Node pat);
106
107
 private:
108
  /**
109
   * Pointer to the module that computes relevance of quantifiers, which is
110
   * owned by the instantiation engine that owns this class.
111
   */
112
  QuantRelevance* d_quant_rel;
113
}; /* class InstStrategyAutoGenTriggers */
114
}
115
}  // namespace theory
116
}  // namespace cvc5
117
118
#endif