Connect++ 0.4.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
Lemmata Class Reference

Representation of the lemma list. More...

#include <Lemmata.hpp>

Collaboration diagram for Lemmata:

Public Member Functions

 Lemmata ()
 You should not need any more complicated constructor.
 
void push_back (const Literal &)
 Self-explanatory.
 
void clear ()
 Self-explanatory.
 
void find_all_lemmata (vector< InferenceItem > &, Clause &)
 Find all lemmata that are applicable, given a Clause.
 
void find_initial_lemmata (vector< InferenceItem > &, Clause &)
 Find all lemmata that are applicable, but only for the initial Literal in a Clause.
 
string to_string (bool=false) const
 Convert to a string.
 
string make_LaTeX (bool=false) const
 

Private Attributes

vector< Literalls
 Lemmata list as appearing in the connection calculus.
 
size_t len
 

Friends

ostream & operator<< (ostream &, const Lemmata &)
 

Detailed Description

Representation of the lemma list.

This is mostly straightforward is it is just a vector of Literals.

However it does have two critical methods: find_all_lemmata and find_initial_lemmata. You should probably read the documentation for these.

Definition at line 49 of file Lemmata.hpp.

Constructor & Destructor Documentation

◆ Lemmata()

Lemmata::Lemmata ( )
inline

You should not need any more complicated constructor.

Definition at line 60 of file Lemmata.hpp.

60: ls(), len(0) {}
vector< Literal > ls
Lemmata list as appearing in the connection calculus.
Definition Lemmata.hpp:54

Member Function Documentation

◆ clear()

void Lemmata::clear ( )
inline

Self-explanatory.

Definition at line 70 of file Lemmata.hpp.

70{ ls.clear(); len = 0; }

◆ find_all_lemmata()

void Lemmata::find_all_lemmata ( vector< InferenceItem > & inf,
Clause & c )

Find all lemmata that are applicable, given a Clause.

The connection calculus allows this, but there is a question of how you implement it. I suspect, but am not 100% certain, that leanCop only looks at the first Literal in the Clause, whereas this looks at all Literals in the Clause. For the (suspected) leanCop behavious use find_initial_lemmata.

In Connect++ the parameter params::all_lemmata controls this and is false by default.

Parameters
infReference to a vector of InferenceItem
cReference to a Clause

Definition at line 56 of file Lemmata.cpp.

56 {
57 if (len == 0)
58 return;
59 if (c.size() == 0) {
60 cerr << "You shouldn't be looking for lemmata with an empty clause" << endl;
61 return;
62 }
63 size_t i = 0;
64 for (const Literal& lit1 : c) {
65 size_t lemmata_index = 0;
66 for (Literal& lit2 : ls) {
67 if (lit1.subbed_equal(&lit2)) {
68 inf.push_back(InferenceItem(InferenceItemType::Lemma,
69 lit1,
70 i,
71 lemmata_index));
72 // If you've found a way of applying the rule them it
73 // doesn't make any sense to continue.
74 break;
75 }
76 lemmata_index++;
77 }
78 i++;
79 }
80}
size_t size() const
Straightforward get method.
Definition Clause.hpp:78
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of argume...
Definition Literal.hpp:50
Full representation of inferences, beyond just the name.

◆ find_initial_lemmata()

void Lemmata::find_initial_lemmata ( vector< InferenceItem > & inf,
Clause & c )

Find all lemmata that are applicable, but only for the initial Literal in a Clause.

See also the documentation for find_all_lemmata.

Parameters
infReference to a vector of InferenceItem
cReference to a Clause

Definition at line 33 of file Lemmata.cpp.

33 {
34 if (len == 0)
35 return;
36 if (c.size() == 0) {
37 cerr << "You shouldn't be looking for lemmata with an empty clause" << endl;
38 return;
39 }
40 size_t lemmata_index = 0;
41 const Literal& lit1 = c[0];
42 for (Literal& lit2 : ls) {
43 if (lit1.subbed_equal(&lit2)) {
44 inf.push_back(InferenceItem(InferenceItemType::Lemma,
45 lit1,
46 0,
47 lemmata_index));
48 // If you've found a way of applying the rule them it
49 // doesn't make any sense to continue.
50 return;
51 }
52 lemmata_index++;
53 }
54}
bool subbed_equal(Literal *) const
Equality, taking account of substitutions.
Definition Literal.cpp:126

◆ make_LaTeX()

string Lemmata::make_LaTeX ( bool subbed = false) const

Convert to a LaTeX representation.

Parameters
subbedImplement substitutions if true.

Definition at line 94 of file Lemmata.cpp.

94 {
95 commas::comma com(ls.size());
96 string s ("\\textcolor{cyan}{[ }");
97 for (const Literal& l : ls) {
98 s += l.make_LaTeX(subbed);
99 s += com();
100 }
101 s += "\\textcolor{cyan}{]}";
102 return s;
103}
Simple function object for putting commas in lists.

◆ push_back()

void Lemmata::push_back ( const Literal & l)

Self-explanatory.

Parameters
lReference to Literal to add

Definition at line 28 of file Lemmata.cpp.

28 {
29 ls.push_back(l);
30 len++;
31}

◆ to_string()

string Lemmata::to_string ( bool subbed = false) const

Convert to a string.

Parameters
subbedImplement substitutions if true.

Definition at line 82 of file Lemmata.cpp.

82 {
83 commas::comma com(ls.size());
84 string result;
85 result += "[ ";
86 for (const Literal& l : ls) {
87 result += l.to_string(subbed);
88 result += com();
89 }
90 result += " ]";
91 return result;
92}

Friends And Related Symbol Documentation

◆ operator<<

ostream & operator<< ( ostream & out,
const Lemmata & l )
friend

Definition at line 105 of file Lemmata.cpp.

105 {
106 out << "Lemmata:" << endl;
107 out << "--------" << endl;
108 out << l.to_string();
109 return out;
110}
string to_string(bool=false) const
Convert to a string.
Definition Lemmata.cpp:82

Member Data Documentation

◆ len

size_t Lemmata::len
private

Definition at line 55 of file Lemmata.hpp.

◆ ls

vector<Literal> Lemmata::ls
private

Lemmata list as appearing in the connection calculus.

Definition at line 54 of file Lemmata.hpp.


The documentation for this class was generated from the following files: