GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/strings/infer_info.h Lines: 2 2 100.0 %
Date: 2021-05-22 Branches: 4 8 50.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Mudathir Mohamed, Gereon Kremer
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
 * Inference information utility.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__STRINGS__INFER_INFO_H
19
#define CVC5__THEORY__STRINGS__INFER_INFO_H
20
21
#include <map>
22
#include <vector>
23
24
#include "expr/node.h"
25
#include "theory/inference_id.h"
26
#include "theory/theory_inference.h"
27
#include "util/safe_print.h"
28
29
namespace cvc5 {
30
namespace theory {
31
namespace strings {
32
33
/**
34
 * Length status, used for indicating the length constraints for Skolems
35
 * introduced by the theory of strings.
36
 */
37
enum LengthStatus
38
{
39
  // The length of the Skolem should not be constrained. This should be
40
  // used for Skolems whose length is already implied.
41
  LENGTH_IGNORE,
42
  // The length of the Skolem is not specified, and should be split on.
43
  LENGTH_SPLIT,
44
  // The length of the Skolem is exactly one.
45
  LENGTH_ONE,
46
  // The length of the Skolem is greater than or equal to one.
47
  LENGTH_GEQ_ONE
48
};
49
50
class InferenceManager;
51
52
/**
53
 * An inference. This is a class to track an unprocessed call to either
54
 * send a fact, lemma, or conflict that is waiting to be asserted to the
55
 * equality engine or sent on the output channel.
56
 *
57
 * For the sake of proofs, the premises in InferInfo have a particular
58
 * ordering for many of the core strings rules, which is expected by
59
 * InferProofCons for constructing proofs of F_CONST, F_UNIFY, N_CONST, etc.
60
 * which apply to a pair of string terms t and s. At a high level, the ordering
61
 * expected in d_ant is:
62
 * (1) (multiple) literals that explain why t and s have the same prefix/suffix,
63
 * (2) t = s,
64
 * (3) (optionally) a length constraint.
65
 * For example, say we have:
66
 *   { x ++ y ++ v1 = z ++ w ++ v2, x = z ++ u, u = "", len(y) = len(w) }
67
 * We can conclude y = w by the N_UNIFY rule from the left side. The premise
68
 * has the following form:
69
 * - (prefix up to y/w equal) x = z ++ u, u = "",
70
 * - (main equality) x ++ y ++ v1 = z ++ w ++ v2,
71
 * - (length constraint) len(y) = len(w).
72
 */
73
54667
class InferInfo : public TheoryInference
74
{
75
 public:
76
  InferInfo(InferenceId id);
77
132984
  ~InferInfo() {}
78
  /** Process lemma */
79
  TrustNode processLemma(LemmaProperty& p) override;
80
  /** Process internal fact */
81
  Node processFact(std::vector<Node>& exp, ProofGenerator*& pg) override;
82
  /** Pointer to the class used for processing this info */
83
  InferenceManager* d_sim;
84
  /** Whether it is the reverse form of the above id */
85
  bool d_idRev;
86
  /** The conclusion */
87
  Node d_conc;
88
  /**
89
   * The premise(s) of the inference, interpreted conjunctively. These are
90
   * literals that currently hold in the equality engine.
91
   */
92
  std::vector<Node> d_premises;
93
  /**
94
   * The "new literal" premise(s) of the inference, interpreted
95
   * conjunctively. These are literals that were needed to show the conclusion
96
   * but do not currently hold in the equality engine. These should be a subset
97
   * of d_ant. In other words, premises that are not explained are stored
98
   * in *both* d_ant and d_noExplain.
99
   */
100
  std::vector<Node> d_noExplain;
101
  /**
102
   * A list of new skolems introduced as a result of this inference. They
103
   * are mapped to by a length status, indicating the length constraint that
104
   * can be assumed for them.
105
   */
106
  std::map<LengthStatus, std::vector<Node> > d_skolems;
107
  /**  Is this infer info trivial? True if d_conc is true. */
108
  bool isTrivial() const;
109
  /**
110
   * Does this infer info correspond to a conflict? True if d_conc is false
111
   * and it has no new premises (d_noExplain).
112
   */
113
  bool isConflict() const;
114
  /**
115
   * Does this infer info correspond to a "fact". A fact is an inference whose
116
   * conclusion should be added as an equality or predicate to the equality
117
   * engine with no new external premises (d_noExplain).
118
   */
119
  bool isFact() const;
120
  /** Get premises */
121
  Node getPremises() const;
122
};
123
124
/**
125
 * Writes an inference info to a stream.
126
 *
127
 * @param out The stream to write to
128
 * @param ii The inference info to write to the stream
129
 * @return The stream
130
 */
131
std::ostream& operator<<(std::ostream& out, const InferInfo& ii);
132
133
}  // namespace strings
134
}  // namespace theory
135
}  // namespace cvc5
136
137
#endif /* CVC5__THEORY__STRINGS__INFER_INFO_H */