GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/printer/tptp/tptp_printer.cpp Lines: 7 30 23.3 %
Date: 2021-08-14 Branches: 2 62 3.2 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters, Tim King
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
 * The pretty-printer interface for the TPTP output language.
14
 */
15
#include "printer/tptp/tptp_printer.h"
16
17
#include <iostream>
18
#include <string>
19
#include <typeinfo>
20
#include <vector>
21
22
#include "expr/node_manager.h"    // for VarNameAttr
23
#include "options/language.h"     // for LANG_AST
24
#include "options/smt_options.h"  // for unsat cores
25
#include "proof/unsat_core.h"
26
#include "smt/command.h"
27
#include "smt/node_command.h"
28
#include "smt/smt_engine.h"
29
30
using namespace std;
31
32
namespace cvc5 {
33
namespace printer {
34
namespace tptp {
35
36
1338
void TptpPrinter::toStream(std::ostream& out,
37
                           TNode n,
38
                           int toDepth,
39
                           size_t dag) const
40
{
41
1338
  n.toStream(out, toDepth, dag, language::output::LANG_SMTLIB_V2_6);
42
1338
}/* TptpPrinter::toStream() */
43
44
1973
void TptpPrinter::toStream(std::ostream& out, const CommandStatus* s) const
45
{
46
1973
  s->toStream(out, language::output::LANG_SMTLIB_V2_6);
47
1973
}/* TptpPrinter::toStream() */
48
49
void TptpPrinter::toStream(std::ostream& out, const smt::Model& m) const
50
{
51
  std::string statusName(m.isKnownSat() ? "FiniteModel"
52
                                        : "CandidateFiniteModel");
53
  out << "% SZS output start " << statusName << " for " << m.getInputName()
54
      << endl;
55
  this->Printer::toStreamUsing(language::output::LANG_SMTLIB_V2_6, out, m);
56
  out << "% SZS output end " << statusName << " for " << m.getInputName()
57
      << endl;
58
}
59
60
void TptpPrinter::toStreamModelSort(std::ostream& out,
61
                                    const smt::Model& m,
62
                                    TypeNode tn) const
63
{
64
  // shouldn't be called; only the non-Command* version above should be
65
  Unreachable();
66
}
67
68
void TptpPrinter::toStreamModelTerm(std::ostream& out,
69
                                    const smt::Model& m,
70
                                    Node n) const
71
{
72
  // shouldn't be called; only the non-Command* version above should be
73
  Unreachable();
74
}
75
76
void TptpPrinter::toStream(std::ostream& out, const UnsatCore& core) const
77
{
78
  out << "% SZS output start UnsatCore " << std::endl;
79
  if (core.useNames())
80
  {
81
    // use the names
82
    const std::vector<std::string>& cnames = core.getCoreNames();
83
    for (const std::string& cn : cnames)
84
    {
85
      out << cn << std::endl;
86
    }
87
  }
88
  else
89
  {
90
    // otherwise, use the formulas
91
    for (UnsatCore::const_iterator i = core.begin(); i != core.end(); ++i)
92
    {
93
      out << *i << endl;
94
    }
95
  }
96
  out << "% SZS output end UnsatCore " << std::endl;
97
}
98
99
}  // namespace tptp
100
}  // namespace printer
101
29340
}  // namespace cvc5