GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/ematching/relational_match_generator.h Lines: 1 1 100.0 %
Date: 2021-11-07 Branches: 0 0 0.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
 * Relational match generator class.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__QUANTIFIERS__RELATIONAL_MATCH_GENERATOR_H
19
#define CVC5__THEORY__QUANTIFIERS__RELATIONAL_MATCH_GENERATOR_H
20
21
#include "expr/node.h"
22
#include "theory/quantifiers/ematching/inst_match_generator.h"
23
24
namespace cvc5 {
25
namespace theory {
26
namespace quantifiers {
27
namespace inst {
28
29
/**
30
 * Match generator for relational triggers x ~ t where t is a ground term.
31
 * This match generator tries a small fixed set of terms based on the kind of
32
 * relation and the required polarity of the trigger in the quantified formula.
33
 *
34
 * For example, for quantified formula (forall ((x Int)) (=> (> x n) (P x))),
35
 * we have that (> x n) is a relational trigger with required polarity "true".
36
 * This generator will try the match `x -> n+1` only, where notice that n+1 is
37
 * the canonical term chosen to satisfy x>n. Canonical terms for arithmetic
38
 * relations (~ x n) are in set { n, n+1, n-1 }.
39
 *
40
 * If a relational trigger does not have a required polarity, then up to 2
41
 * terms are tried, a term that satisfies the relation, and one that does not.
42
 * If (>= x n) is a relational trigger with no polarity, then `x -> n` and
43
 * `x -> n-1` will be generated.
44
 *
45
 * Currently this class handles only equality between real or integer valued
46
 * terms, or inequalities (kind GEQ). It furthermore only considers ground terms
47
 * t for the right hand side of relations.
48
 */
49
20
class RelationalMatchGenerator : public InstMatchGenerator
50
{
51
 public:
52
  /**
53
   * @param tparent The parent trigger that this match generator belongs to
54
   * @param rtrigger The relational trigger
55
   * @param hasPol Whether the trigger has an entailed polarity
56
   * @param pol The entailed polarity of the relational trigger.
57
   */
58
  RelationalMatchGenerator(Trigger* tparent,
59
                           Node rtrigger,
60
                           bool hasPol,
61
                           bool pol);
62
63
  /** Reset */
64
  bool reset(Node eqc) override;
65
  /** Get the next match. */
66
  int getNextMatch(Node q, InstMatch& m) override;
67
68
 private:
69
  /** the variable */
70
  Node d_var;
71
  /** The index of the variable */
72
  int64_t d_vindex;
73
  /** the relation kind */
74
  Kind d_rel;
75
  /** the right hand side */
76
  Node d_rhs;
77
  /** whether we have a required polarity */
78
  bool d_hasPol;
79
  /** the required polarity, if it exists */
80
  bool d_pol;
81
  /**
82
   * The current number of terms we have generated since the last call to reset
83
   */
84
  size_t d_counter;
85
};
86
87
}  // namespace inst
88
}  // namespace quantifiers
89
}  // namespace theory
90
}  // namespace cvc5
91
92
#endif