GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/theory_options.cpp Lines: 11 75 14.7 %
Date: 2021-09-10 Branches: 8 76 10.5 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Mathias Preiner, Aina Niemetz
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
 * Option template for option modules.
14
 *
15
 * For each <module>_options.toml configuration file, mkoptions.py
16
 * expands this template and generates a <module>_options.cpp file.
17
 */
18
#include "options/theory_options.h"
19
20
#include <iostream>
21
22
#include "base/check.h"
23
#include "options/option_exception.h"
24
25
// clang-format off
26
namespace cvc5::options {
27
28
std::ostream& operator<<(std::ostream& os, EqEngineMode mode)
29
{
30
  switch(mode) {
31
    case EqEngineMode::DISTRIBUTED:
32
      return os << "EqEngineMode::DISTRIBUTED";
33
    case EqEngineMode::CENTRAL:
34
      return os << "EqEngineMode::CENTRAL";
35
    default:
36
      Unreachable();
37
  }
38
  return os;
39
}
40
56
EqEngineMode stringToEqEngineMode(const std::string& optarg)
41
{
42
56
  if (optarg == "distributed")
43
  {
44
28
    return EqEngineMode::DISTRIBUTED;
45
  }
46
28
  else if (optarg == "central")
47
  {
48
28
    return EqEngineMode::CENTRAL;
49
  }
50
  else if (optarg == "help")
51
  {
52
    std::cerr << "Defines mode for managing equalities across theory solvers.\n"
53
         "Available modes for --ee-mode are:\n"
54
         "+ distributed (default)\n"
55
         "  Each theory maintains its own equality engine.\n"
56
         "+ central\n"
57
         "  All applicable theories use the central equality engine.\n";
58
    std::exit(1);
59
  }
60
  throw OptionException(std::string("unknown option for --ee-mode: `") +
61
                        optarg + "'.  Try --ee-mode=help.");
62
}
63
std::ostream& operator<<(std::ostream& os, TcMode mode)
64
{
65
  switch(mode) {
66
    case TcMode::CARE_GRAPH:
67
      return os << "TcMode::CARE_GRAPH";
68
    default:
69
      Unreachable();
70
  }
71
  return os;
72
}
73
TcMode stringToTcMode(const std::string& optarg)
74
{
75
  if (optarg == "care-graph")
76
  {
77
    return TcMode::CARE_GRAPH;
78
  }
79
  else if (optarg == "help")
80
  {
81
    std::cerr << "Defines mode for theory combination.\n"
82
         "Available modes for --tc-mode are:\n"
83
         "+ care-graph (default)\n"
84
         "  Use care graphs for theory combination.\n";
85
    std::exit(1);
86
  }
87
  throw OptionException(std::string("unknown option for --tc-mode: `") +
88
                        optarg + "'.  Try --tc-mode=help.");
89
}
90
std::ostream& operator<<(std::ostream& os, TheoryOfMode mode)
91
{
92
  switch(mode) {
93
    case TheoryOfMode::THEORY_OF_TYPE_BASED:
94
      return os << "TheoryOfMode::THEORY_OF_TYPE_BASED";
95
    case TheoryOfMode::THEORY_OF_TERM_BASED:
96
      return os << "TheoryOfMode::THEORY_OF_TERM_BASED";
97
    default:
98
      Unreachable();
99
  }
100
  return os;
101
}
102
5
TheoryOfMode stringToTheoryOfMode(const std::string& optarg)
103
{
104
5
  if (optarg == "type")
105
  {
106
3
    return TheoryOfMode::THEORY_OF_TYPE_BASED;
107
  }
108
2
  else if (optarg == "term")
109
  {
110
2
    return TheoryOfMode::THEORY_OF_TERM_BASED;
111
  }
112
  else if (optarg == "help")
113
  {
114
    std::cerr << "Defines how we associate theories with terms.\n"
115
         "Available modes for --theoryof-mode are:\n"
116
         "+ type (default)\n"
117
         "  Type variables, constants and equalities by type.\n"
118
         "+ term\n"
119
         "  Type variables as uninterpreted, type constants by theory, equalities by the\n"
120
         "  parametric theory.\n";
121
    std::exit(1);
122
  }
123
  throw OptionException(std::string("unknown option for --theoryof-mode: `") +
124
                        optarg + "'.  Try --theoryof-mode=help.");
125
}
126
127
namespace theory
128
{
129
// clang-format off
130
void setDefaultAssignFunctionValues(Options& opts, bool value)
131
{
132
    if (!opts.theory.assignFunctionValuesWasSetByUser) {
133
        opts.theory.assignFunctionValues = value;
134
    }
135
}
136
void setDefaultCondenseFunctionValues(Options& opts, bool value)
137
{
138
    if (!opts.theory.condenseFunctionValuesWasSetByUser) {
139
        opts.theory.condenseFunctionValues = value;
140
    }
141
}
142
void setDefaultEeMode(Options& opts, EqEngineMode value)
143
{
144
    if (!opts.theory.eeModeWasSetByUser) {
145
        opts.theory.eeMode = value;
146
    }
147
}
148
void setDefaultRelevanceFilter(Options& opts, bool value)
149
{
150
    if (!opts.theory.relevanceFilterWasSetByUser) {
151
        opts.theory.relevanceFilter = value;
152
    }
153
}
154
void setDefaultTcMode(Options& opts, TcMode value)
155
{
156
    if (!opts.theory.tcModeWasSetByUser) {
157
        opts.theory.tcMode = value;
158
    }
159
}
160
void setDefaultTheoryOfMode(Options& opts, TheoryOfMode value)
161
{
162
    if (!opts.theory.theoryOfModeWasSetByUser) {
163
        opts.theory.theoryOfMode = value;
164
    }
165
}
166
// clang-format on
167
}
168
169
29502
}  // namespace cvc5::options
170
// clang-format on