GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/proof_options.cpp Lines: 6 99 6.1 %
Date: 2021-09-07 Branches: 5 95 5.3 %

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/proof_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, ProofCheckMode mode)
29
{
30
  switch(mode) {
31
    case ProofCheckMode::LAZY:
32
      return os << "ProofCheckMode::LAZY";
33
    case ProofCheckMode::EAGER_SIMPLE:
34
      return os << "ProofCheckMode::EAGER_SIMPLE";
35
    case ProofCheckMode::EAGER:
36
      return os << "ProofCheckMode::EAGER";
37
    case ProofCheckMode::NONE:
38
      return os << "ProofCheckMode::NONE";
39
    default:
40
      Unreachable();
41
  }
42
  return os;
43
}
44
2
ProofCheckMode stringToProofCheckMode(const std::string& optarg)
45
{
46
2
  if (optarg == "lazy")
47
  {
48
    return ProofCheckMode::LAZY;
49
  }
50
2
  else if (optarg == "eager-simple")
51
  {
52
    return ProofCheckMode::EAGER_SIMPLE;
53
  }
54
2
  else if (optarg == "eager")
55
  {
56
2
    return ProofCheckMode::EAGER;
57
  }
58
  else if (optarg == "none")
59
  {
60
    return ProofCheckMode::NONE;
61
  }
62
  else if (optarg == "help")
63
  {
64
    std::cerr << "Proof checking modes.\n"
65
         "Available modes for --proof-check are:\n"
66
         "+ lazy (default)\n"
67
         "  check rule applications only during final proof construction\n"
68
         "+ eager-simple\n"
69
         "  check rule applications during construction\n"
70
         "+ eager\n"
71
         "  check rule applications and proofs from generators eagerly for local debugging\n"
72
         "+ none\n"
73
         "  do not check rule applications\n";
74
    std::exit(1);
75
  }
76
  throw OptionException(std::string("unknown option for --proof-check: `") +
77
                        optarg + "'.  Try --proof-check=help.");
78
}
79
std::ostream& operator<<(std::ostream& os, ProofFormatMode mode)
80
{
81
  switch(mode) {
82
    case ProofFormatMode::DOT:
83
      return os << "ProofFormatMode::DOT";
84
    case ProofFormatMode::TPTP:
85
      return os << "ProofFormatMode::TPTP";
86
    case ProofFormatMode::VERIT:
87
      return os << "ProofFormatMode::VERIT";
88
    case ProofFormatMode::NONE:
89
      return os << "ProofFormatMode::NONE";
90
    default:
91
      Unreachable();
92
  }
93
  return os;
94
}
95
ProofFormatMode stringToProofFormatMode(const std::string& optarg)
96
{
97
  if (optarg == "dot")
98
  {
99
    return ProofFormatMode::DOT;
100
  }
101
  else if (optarg == "tptp")
102
  {
103
    return ProofFormatMode::TPTP;
104
  }
105
  else if (optarg == "verit")
106
  {
107
    return ProofFormatMode::VERIT;
108
  }
109
  else if (optarg == "none")
110
  {
111
    return ProofFormatMode::NONE;
112
  }
113
  else if (optarg == "help")
114
  {
115
    std::cerr << "Proof format modes.\n"
116
         "Available modes for --proof-format-mode are:\n"
117
         "+ dot\n"
118
         "  Output DOT proof\n"
119
         "+ tptp\n"
120
         "  Output TPTP proof (work in progress)\n"
121
         "+ verit\n"
122
         "  Output veriT proof\n"
123
         "+ none (default)\n"
124
         "  Do not translate proof output\n";
125
    std::exit(1);
126
  }
127
  throw OptionException(std::string("unknown option for --proof-format-mode: `") +
128
                        optarg + "'.  Try --proof-format-mode=help.");
129
}
130
std::ostream& operator<<(std::ostream& os, ProofGranularityMode mode)
131
{
132
  switch(mode) {
133
    case ProofGranularityMode::REWRITE:
134
      return os << "ProofGranularityMode::REWRITE";
135
    case ProofGranularityMode::DSL_REWRITE:
136
      return os << "ProofGranularityMode::DSL_REWRITE";
137
    case ProofGranularityMode::OFF:
138
      return os << "ProofGranularityMode::OFF";
139
    case ProofGranularityMode::THEORY_REWRITE:
140
      return os << "ProofGranularityMode::THEORY_REWRITE";
141
    default:
142
      Unreachable();
143
  }
144
  return os;
145
}
146
ProofGranularityMode stringToProofGranularityMode(const std::string& optarg)
147
{
148
  if (optarg == "rewrite")
149
  {
150
    return ProofGranularityMode::REWRITE;
151
  }
152
  else if (optarg == "dsl-rewrite")
153
  {
154
    return ProofGranularityMode::DSL_REWRITE;
155
  }
156
  else if (optarg == "off")
157
  {
158
    return ProofGranularityMode::OFF;
159
  }
160
  else if (optarg == "theory-rewrite")
161
  {
162
    return ProofGranularityMode::THEORY_REWRITE;
163
  }
164
  else if (optarg == "help")
165
  {
166
    std::cerr << "Modes for proof granularity.\n"
167
         "Available modes for --proof-granularity are:\n"
168
         "+ rewrite\n"
169
         "  Allow rewrite or substitution steps, expand macros.\n"
170
         "+ dsl-rewrite\n"
171
         "  Allow DSL rewrites and evaluation steps, expand macros, rewrite, substitution,\n"
172
         "  and theory rewrite steps.\n"
173
         "+ off\n"
174
         "  Do not improve the granularity of proofs.\n"
175
         "+ theory-rewrite (default)\n"
176
         "  Allow theory rewrite steps, expand macros, rewrite and substitution steps.\n";
177
    std::exit(1);
178
  }
179
  throw OptionException(std::string("unknown option for --proof-granularity: `") +
180
                        optarg + "'.  Try --proof-granularity=help.");
181
}
182
183
namespace proof
184
{
185
// clang-format off
186
void setDefaultProofCheck(Options& opts, ProofCheckMode value)
187
{
188
    if (!opts.proof.proofCheckWasSetByUser) {
189
        opts.proof.proofCheck = value;
190
    }
191
}
192
void setDefaultProofFormatMode(Options& opts, ProofFormatMode value)
193
{
194
    if (!opts.proof.proofFormatModeWasSetByUser) {
195
        opts.proof.proofFormatMode = value;
196
    }
197
}
198
void setDefaultProofGranularityMode(Options& opts, ProofGranularityMode value)
199
{
200
    if (!opts.proof.proofGranularityModeWasSetByUser) {
201
        opts.proof.proofGranularityMode = value;
202
    }
203
}
204
void setDefaultProofPedantic(Options& opts, uint64_t value)
205
{
206
    if (!opts.proof.proofPedanticWasSetByUser) {
207
        opts.proof.proofPedantic = value;
208
    }
209
}
210
void setDefaultProofPrintConclusion(Options& opts, bool value)
211
{
212
    if (!opts.proof.proofPrintConclusionWasSetByUser) {
213
        opts.proof.proofPrintConclusion = value;
214
    }
215
}
216
// clang-format on
217
}
218
219
29502
}  // namespace cvc5::options
220
// clang-format on