UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
UQRule.h
1 /***************************************************************************
2  * Copyright (C) 2014 by Jan Stückrath <jan.stueckrath@uni-due.de> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
18  ***************************************************************************/
19 
20 #ifndef UQRULE_H_
21 #define UQRULE_H_
22 
23 #include "UQRuleInstance.h"
24 #include "Rule.h"
25 
26 namespace uncover {
27  namespace graphs {
28 
39 
40  public:
41 
46  typedef pair<AnonRule,Mapping> Quantification;
47 
52  UQRule(Rule const& mainRule);
53 
62  UQRule(string name = "",
63  AnonHypergraph_sp left = make_shared<AnonHypergraph>(),
64  AnonHypergraph_sp right = make_shared<AnonHypergraph>(),
65  Mapping const& match = Mapping());
66 
70  virtual ~UQRule();
71 
76  IDType getID() const;
77 
82  string getName() const;
83 
88  Rule& getMainRule();
89 
94  Rule const& getMainRule() const;
95 
106  void addQuantification(AnonRule const& rule, Mapping const& match);
107 
114  void addQuantification(Quantification const& quantification);
115 
120  size_t getQuantCount() const;
121 
126  vector<Quantification>& getQuantifications();
127 
132  vector<Quantification> const& getQuantifications() const;
133 
150  vector<unsigned int> const& quantities,
151  vector<unordered_set<IDType>>* genLeft = nullptr,
152  vector<unordered_set<IDType>>* genRight = nullptr) const;
153 
160 
173  vector<unordered_set<IDType>>* genLeft = nullptr,
174  vector<unordered_set<IDType>>* genRight = nullptr) const;
175 
190  UQRuleInstance_csp rule,
191  size_t quantID,
192  vector<unordered_set<IDType>>* genLeft = nullptr,
193  vector<unordered_set<IDType>>* genRight = nullptr) const;
194 
195  virtual void streamTo(std::ostream& ost) const override;
196 
197  private:
198 
210  void extendRuleByUQ(
211  UQRuleInstance& rule,
212  size_t quantID,
213  vector<unordered_set<IDType>>* genLeft,
214  vector<unordered_set<IDType>>* genRight) const;
215 
226  bool checkVertices(
227  AnonHypergraph_csp graph,
228  IDType const& edgeID,
229  Mapping const& vmap,
230  vector<IDType>& vertices) const;
231 
236 
241  vector<Quantification> quantifications;
242 
248  unordered_set<IDType> leftUQVertices;
249 
254  unordered_set<IDType> rightUQVertices;
255 
256  };
257 
261  typedef shared_ptr<UQRule> UQRule_sp;
262 
266  typedef shared_ptr<UQRule const> UQRule_csp;
267 
268  } /* namespace graphs */
269 } /* namespace uncover */
270 
271 #endif /* UQRULE_H_ */
Rule mainRule
Stores the main rule of this UQRule.
Definition: UQRule.h:235
shared_ptr< AnonHypergraph > AnonHypergraph_sp
Alias of a shared pointer to an AnonHypergraph.
Definition: AnonHypergraph.h:415
Streamable provides a streaming function which must be implemented by any deriving class...
Definition: Streamable.h:31
UQRuleInstance_sp extendInstance(UQRuleInstance_csp rule, size_t quantID, vector< unordered_set< IDType >> *genLeft=nullptr, vector< unordered_set< IDType >> *genRight=nullptr) const
Generates and returns a new instantiation of this UQRule by copying the given instance and adding the...
Definition: UQRule.cpp:154
UQRule(Rule const &mainRule)
Generates a UQRule without any Quantifications using the given rule as the main rule.
Definition: UQRule.cpp:31
unordered_set< IDType > leftUQVertices
Every universally quantified vertex in the main rules left-hand side is stored in this set...
Definition: UQRule.h:248
UQRuleInstance_sp createZeroInstance() const
Generates and returns the instantiation of this UQRule where no Quantification is added...
Definition: UQRule.cpp:137
shared_ptr< const AnonHypergraph > AnonHypergraph_csp
Alias of a shared pointer to a constant AnonHypergraph.
Definition: AnonHypergraph.h:420
shared_ptr< UQRule const > UQRule_csp
Alias for a shared pointer to a constant UQRule.
Definition: UQRule.h:266
UQRuleInstance_sp createInstance(vector< unsigned int > const &quantities, vector< unordered_set< IDType >> *genLeft=nullptr, vector< unordered_set< IDType >> *genRight=nullptr) const
Generates and returns the instantiation of this UQRule where each Quantification is added as often sp...
Definition: UQRule.cpp:100
bool checkVertices(AnonHypergraph_csp graph, IDType const &edgeID, Mapping const &vmap, vector< IDType > &vertices) const
Checks if all vertices incident to the given edge (given as edge ID) of the given graph have an image...
Definition: UQRule.cpp:287
Represents the data structure for a rule including a unique identifier.
Definition: Rule.h:38
This is the data structure representing a morphism mapping from a graph to another graph...
Definition: Mapping.h:36
vector< Quantification > quantifications
Stores the Quantifications of this UQRule, which will later be indexed by their position in this vect...
Definition: UQRule.h:241
shared_ptr< UQRuleInstance > UQRuleInstance_sp
Alias of a shared pointer to a UQRuleIstance.
Definition: UQRuleInstance.h:139
size_t getQuantCount() const
Returns the number of Quantifications of this UQRule.
Definition: UQRule.cpp:88
AnonRule serves as a data structure of a rule object.
Definition: AnonRule.h:39
pair< AnonRule, Mapping > Quantification
A Quantification consists of a rule and a Mapping from the main rules left-hand side to the Quantific...
Definition: UQRule.h:46
UQRuleInstance_sp createOneInstance(vector< unordered_set< IDType >> *genLeft=nullptr, vector< unordered_set< IDType >> *genRight=nullptr) const
Generates and returns the instantiation of this UQRule where each Quantification is added exactly onc...
Definition: UQRule.cpp:141
string getName() const
Returns the name of this UQRule.
Definition: UQRule.cpp:52
virtual void streamTo(std::ostream &ost) const override
Streams as string representation of this Streamable object to the given ostream.
Definition: UQRule.cpp:305
IDType getID() const
Returns the ID of this UQRule.
Definition: UQRule.cpp:48
shared_ptr< UQRule > UQRule_sp
Alias for a shared pointer to a UQRule.
Definition: UQRule.h:261
vector< Quantification > & getQuantifications()
Returns a reference to the vector storing the Quantifications of this UQRule.
Definition: UQRule.cpp:92
void extendRuleByUQ(UQRuleInstance &rule, size_t quantID, vector< unordered_set< IDType >> *genLeft, vector< unordered_set< IDType >> *genRight) const
Generates a new instantiation of this UQRule by adding the Quantification with the given index to the...
Definition: UQRule.cpp:186
Rule & getMainRule()
Returns a reference to the main rule encapsulated by this UQRule.
Definition: UQRule.cpp:56
unordered_set< IDType > rightUQVertices
For all universally quantified vertices this set stores their image in the main rules right-hand side...
Definition: UQRule.h:254
virtual ~UQRule()
Destroys this UQRule.
Definition: UQRule.cpp:46
void addQuantification(AnonRule const &rule, Mapping const &match)
Adds a Quantification to this UQRule consisting of the given AnonRule and Mapping.
Definition: UQRule.cpp:64
This class serves as data structure of a universally quantified rule.
Definition: UQRule.h:38
The UQRuleInstance is a rule which is generated when UQRules are instantiated.
Definition: UQRuleInstance.h:35
unsigned int IDType
IDType is an (unsigned) integer specifically used as an Identifier of graphs, elements of graphs or a...
Definition: globals.h:53
shared_ptr< UQRuleInstance const > UQRuleInstance_csp
Alias of a shared pointer to a constant UQRuleInstance.
Definition: UQRuleInstance.h:144