con_closed.cpp
Go to the documentation of this file.
1 /** @file con_closed.cpp Conditionalclosedness */
2 
3 /*
4  * Implementation of the conditionally clossed algorithm
5  *
6  * Copyright (C) 2011 Tomas Masopust
7  *
8  */
9 
10 
11 #include "con_closed.h"
12 #include <vector>
13 
14 namespace faudes {
15 
16 bool IsConditionalClosed(const GeneratorVector& specVect, const Generator& pk, const GeneratorVector& genVect, const Generator& gk) {
17  FD_DF("Conditionalclosedness checking...");
18 
19  Idx i;
20 
21  // there must be the same number of parameters
22  if (specVect.Size() != genVect.Size()) {
23  std::stringstream errstr;
24  errstr << "The sizes of specVect and genVect are different.";
25  throw Exception("ConditionalClosedness", errstr.str(), 201);
26  }
27 
28  // the generators must be deterministic
29  for (i = 0; i < specVect.Size(); i++) {
30  if (specVect.At(i).IsDeterministic() == false) {
31  std::stringstream errstr;
32  errstr << "Generators of specVect must be deterministic, but there is a nondeterministic one";
33  throw Exception("ConditionalClosednes", errstr.str(), 201);
34  }
35  }
36 
37  if (pk.IsDeterministic() == false) {
38  std::stringstream errstr;
39  errstr << "Generator pk must be deterministic, but is nondeterministic";
40  throw Exception("ConditionalClosedness", errstr.str(), 201);
41  }
42 
43  for (i = 0; i < genVect.Size(); i++) {
44  if (genVect.At(i).IsDeterministic() == false) {
45  std::stringstream errstr;
46  errstr << "Generators of genVect must be deterministic, but there is a nondeterministic one";
47  throw Exception("ConditionalClosedness", errstr.str(), 201);
48  }
49  }
50 
51  if (gk.IsDeterministic() == false) {
52  std::stringstream errstr;
53  errstr << "Generator gk must be deterministic, but is nondeterministic";
54  throw Exception("ConditionalClosedness", errstr.str(), 201);
55  }
56 
57  // check if P_k(K) is Lm(G_k)-closed
58  if (IsRelativelyPrefixClosed(gk,pk) == false) {
59  return false;
60  }
61 
62  // check if P_{i+k}(K) is Lm(G_i)||P_k(K)-closed
63  for (i = 0; i < specVect.Size(); i++) {
64  Generator helpPlant;
65  Parallel(genVect.At(i),pk,helpPlant);
66  if (IsRelativelyPrefixClosed(helpPlant,specVect.At(i)) == false) {
67  return false;
68  }
69  }
70 
71  return true;
72 }
73 
74 
75 } // name space
76 
77 
78 
#define FD_DF(message)
Debug: optional report on user functions.
Faudes exception class.
virtual const T & At(const Position &pos) const
Access element.
Idx Size(void) const
Get size of vector.
Base class of all FAUDES generators.
bool IsDeterministic(void) const
Check if generator is deterministic.
Conditional Closedness.
bool IsConditionalClosed(const GeneratorVector &specVect, const Generator &pk, const GeneratorVector &genVect, const Generator &gk)
Conditionalclosedness Checking Algorithm.
Definition: con_closed.cpp:16
void Parallel(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Parallel composition.
bool IsRelativelyPrefixClosed(const Generator &rGenPlant, const Generator &rGenCand)
Test for relative prefix-closedness.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen