GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/strings/strings_fmf.h Lines: 1 1 100.0 %
Date: 2021-09-17 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Andres Noetzli, Tianyi Liang
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
 * A finite model finding decision strategy for strings.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__STRINGS__STRINGS_FMF_H
19
#define CVC5__THEORY__STRINGS__STRINGS_FMF_H
20
21
#include "context/cdhashset.h"
22
#include "context/cdo.h"
23
#include "context/context.h"
24
#include "expr/node.h"
25
#include "smt/env_obj.h"
26
#include "theory/decision_strategy.h"
27
#include "theory/strings/term_registry.h"
28
#include "theory/valuation.h"
29
30
namespace cvc5 {
31
namespace theory {
32
namespace strings {
33
34
/** Strings finite model finding
35
 *
36
 * This class manages the creation of a decision strategy that bounds the
37
 * sum of lengths of terms of type string.
38
 */
39
class StringsFmf : protected EnvObj
40
{
41
  typedef context::CDHashSet<Node> NodeSet;
42
43
 public:
44
  StringsFmf(Env& env, Valuation valuation, TermRegistry& tr);
45
  ~StringsFmf();
46
  /** presolve
47
   *
48
   * This initializes a (new copy) of the decision strategy d_sslds.
49
   */
50
  void presolve();
51
  /**
52
   * Get the decision strategy, valid after a call to presolve in the duration
53
   * of a check-sat call.
54
   */
55
  DecisionStrategy* getDecisionStrategy() const;
56
57
 private:
58
  /** String sum of lengths decision strategy
59
   *
60
   * This decision strategy enforces that len(x_1) + ... + len(x_k) <= n
61
   * for a minimal natural number n, where x_1, ..., x_n is the list of
62
   * input variables of the problem of type String.
63
   *
64
   * This decision strategy is enabled by option::stringsFmf().
65
   */
66
156
  class StringSumLengthDecisionStrategy : public DecisionStrategyFmf
67
  {
68
   public:
69
    StringSumLengthDecisionStrategy(Env& env, Valuation valuation);
70
    /** make literal */
71
    Node mkLiteral(unsigned i) override;
72
    /** identify */
73
    std::string identify() const override;
74
    /** is initialized */
75
    bool isInitialized();
76
    /** initialize */
77
    void initialize(const std::vector<Node>& vars);
78
79
    /*
80
     * Do not hide the zero-argument version of initialize() inherited from the
81
     * base class
82
     */
83
    using DecisionStrategyFmf::initialize;
84
85
   private:
86
    /**
87
     * User-context-dependent node corresponding to the sum of the lengths of
88
     * input variables of type string
89
     */
90
    context::CDO<Node> d_inputVarLsum;
91
  };
92
  /** an instance of the above class */
93
  std::unique_ptr<StringSumLengthDecisionStrategy> d_sslds;
94
  /** The valuation object of theory of strings */
95
  Valuation d_valuation;
96
  /** The term registry of theory of strings */
97
  TermRegistry& d_termReg;
98
};
99
100
}  // namespace strings
101
}  // namespace theory
102
}  // namespace cvc5
103
104
#endif /* CVC5__THEORY__STRINGS__STRINGS_FMF_H */