25#include "ProofPrinter.hpp"
27void show_internal_proof(
const ProofType& proof) {
29 for (
const ProofLine& line : proof) {
30 cout <<
"Proof step " << i <<
": ";
31 cout << line.first <<
" (";
32 for (
size_t n : line.second) {
41 string s(
"{\\begin{aligned}");
43 s += (item_p->
c).
make_LaTeX(params::sub_LaTeX_proof);
45 s += (item_p->
p).
make_LaTeX(params::sub_LaTeX_proof);
47 s += (item_p->
l).
make_LaTeX(params::sub_LaTeX_proof);
48 s +=
"\\end{aligned}}";
54 string axiom_s(
"\\prfbyaxiom{Axiom}");
58 case StackItemType::Start:
62 case StackItemType::Lemmata:
63 s +=
"\\prftree[r]{Lem}{";
64 if ((item_p->
c).size() == 0)
71 case StackItemType::Reduction:
72 s +=
"\\prftree[r,l]{Red}{$";
75 if ((item_p->
c).size() == 0)
82 case StackItemType::LeftBranch:
83 s +=
"\\prftree[r,l]{Ext[";
88 if ((item_p->
c).size() == 0)
98 right_item_p = item_p + 1;
104 case StackItemType::RightBranch:
105 if ((item_p->
c).size() == 0)
112 cerr <<
"Something is really wrong..." << endl;
119 const path& path_to_input_file,
120 const string& matrix_as_latex)
const {
121 string s(
"\\documentclass[10pt]{article}\n");
122 s +=
"\\usepackage{libertine}\n";
123 s +=
"\\usepackage{amsmath,amsfonts,amssymb}\n";
124 s +=
"\\usepackage{prftree}\n";
125 s +=
"\\usepackage{color}\n";
126 s +=
"\\usepackage{forest}\n";
127 s +=
"\\usepackage[paperwidth = ";
128 s += params::latex_height;
129 s +=
",paperheight = ";
130 s += params::latex_width;
131 s +=
",landscape]{geometry}\n\n";
132 s +=
"\\begin{document}\n";
135 s +=
"\\noindent\\begin{LARGE}\\textsc{Connect++}\\end{LARGE} \\\\ \n\n";
136 s +=
"\\noindent Attempting to prove problem from file: ";
138 s += latex_escape_characters(path_to_input_file.filename());
140 if (params::latex_include_matrix) {
141 s +=
"\\noindent Problem has matrix: \n\n";
142 s += matrix_as_latex;
145 s +=
"\\noindent\\textsc{Proof}: \\\\ \n\n";
147 if (params::latex_tiny_proof)
148 s +=
"\\begin{tiny}\n";
154 if (params::latex_tiny_proof)
155 s +=
"\\end{tiny}\n";
157 s +=
"\n\n \\end{document}\n";
162 const path& path_to_input_file,
163 const string& matrix_as_latex) {
164 std::ofstream file(path_to_file);
166 if (!params::latex_body_only) {
181 file <<
"\\prftree[r]{Start}{";
183 file <<
"}{\\epsilon, \\textcolor{magenta}{M}, \\epsilon, \\epsilon}\n";
187 if (!params::latex_body_only)
194 const path& path_to_input_file,
195 const string& matrix_as_latex,
200 std::ofstream file(path_to_file);
202 if (!params::latex_body_only) {
214 file << proof.make_LaTeX();
217 if (!params::latex_body_only)
224 const path& problem_path,
229 std::ofstream file(path_to_file);
236 file << proof.make_Graphviz(problem_path);
242 std::ofstream file(path_to_file);
243 file <<
"proof_stack([" << std::endl;
244 size_t s =
p->
size() - 1;
246 for (
size_t si_index = 0; si_index <
p->
size(); si_index++) {
249 case StackItemType::Start:
254 case StackItemType::Axiom:
257 case StackItemType::Reduction:
258 file <<
"reduction(";
264 case StackItemType::LeftBranch:
265 file <<
"left_branch(";
272 file << std::to_string(si.
depth);
275 case StackItemType::RightBranch:
276 file <<
"right_branch(";
277 file << std::to_string(si.
depth);
280 case StackItemType::Lemmata:
288 cerr <<
"Something is really wrong..." << endl;
296 file <<
"])." << std::endl;
301 cout <<
"proof_stack([" << std::endl;
302 size_t s =
p->
size() - 1;
304 for (
size_t si_index = 0; si_index <
p->
size(); si_index++) {
307 case StackItemType::Start:
312 case StackItemType::Axiom:
315 case StackItemType::Reduction:
316 cout <<
"reduction(";
322 case StackItemType::LeftBranch:
323 cout <<
"left_branch(";
330 cout << std::to_string(si.
depth);
333 case StackItemType::RightBranch:
334 cout <<
"right_branch(";
335 cout << std::to_string(si.
depth);
338 case StackItemType::Lemmata:
346 cerr <<
"Something is really wrong..." << endl;
354 cout <<
"])." << std::endl;
361 return pair<string, unordered_set<string>>(proof.make_tptp(),
362 proof.get_clauses_used_in_proof());
366 vector<pair<string, vector<size_t>>> out;
368 size_t s =
p->
size() - 1;
370 pair<string, vector<size_t>> next_out;
371 for (
size_t si_index = 0; si_index <
p->
size(); si_index++) {
373 next_out.second.clear();
375 case StackItemType::Start:
376 next_out.first =
"start";
378 out.push_back(next_out);
380 case StackItemType::Axiom:
381 next_out.first =
"axiom";
382 out.push_back(next_out);
384 case StackItemType::Reduction:
385 next_out.first =
"reduction";
388 out.push_back(next_out);
390 case StackItemType::LeftBranch:
391 next_out.first =
"left_branch";
395 next_out.second.push_back(si.
depth);
396 out.push_back(next_out);
398 case StackItemType::RightBranch:
399 next_out.first =
"right_branch";
400 next_out.second.push_back(si.
depth);
401 out.push_back(next_out);
403 case StackItemType::Lemmata:
404 next_out.first =
"lemmata";
407 out.push_back(next_out);
410 cerr <<
"Something is really wrong..." << endl;
Representation of the Matrix within a proof.
string make_LaTeX_start(const path &, const path &, const string &) const
The beginning and end of output LaTeX files are the same for all formats.
pair< string, unordered_set< string > > make_tptp(Matrix *, VariableIndex *, TermIndex *)
Show the proof in a TPTP-friendly format.
void make_graphviz_connection_tableau(const path &, const path &, Matrix *, VariableIndex *, TermIndex *)
Convert to LaTeX in the connection tableau calculus and store in the specified file.
string make_LaTeX_state(StackItem *) const
Helper for producing LaTeX output.
void make_Prolog(const path &)
Convert to a form suitable for use by the Prolog proof checker and write to a file.
string make_LaTeX_subtree(StackItem *) const
Helper for producing LaTeX output.
Stack * p
Pointer to the output of StackProver.
void make_LaTeX(const path &, const path &, const string &)
Convert to LaTeX and store in the specified file.
void show_Prolog()
Show the proof in Prolog format.
vector< pair< string, vector< size_t > > > make_internal() const
Make a simple data structure representing the proof stack.
void make_LaTeX_connection_tableau(const path &, const path &, const string &, Matrix *, VariableIndex *, TermIndex *)
Convert to LaTeX in the connection tableau calculus and store in the specified file.
string make_LaTeX_end() const
The beginning and end of output LaTeX files are the same for all formats.
size_t size() const
Exact analogue of the same function for vector<>.
Class for representing a tableau proof in a format that allows extraction of TPTP-format proofs,...
Look after terms, using hash consing to avoid storing copies of terms.
Storage of named variables, and management of new, anonymous and unique variables.
LitNum Lindex
The index of the literal within the clause being used.
size_t index_in_lemmata
For certification, you want to know which element of the lemmata list was used when the Lemma rule wa...
size_t index_in_path
The index in the path of the literal being used.
LitNum Lprime
The index of the literal in C_2 being used.
ClauseNum C_2
For extensions, the number of the clause for which a fresh copy is being made.
Stack items: each contains its own material for generating possible next inferences.
SimplePath p
Each node in the proof tree is a tuple of clause, matrix, path, lemmata: this is the path.
Substitution sub
Some nodes in the proof tree have an associated substitution.
uint32_t depth
How deep in the proof tree are we?
InferenceItem this_action
Action that got you to this clause, path etc.
Lemmata l
Each node in the proof tree is a tuple of clause, matrix, path, lemmas: this is the lemmas.
Clause c
Each node in the proof tree is a tuple of clause, matrix, path, lemmata: this is the clause.
StackItemType item_type
What type of StackItem is this?