Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  test-obvinf.cpp

  Sprache: C
 

// libsemigroups - C++ library for semigroups and monoids
// Copyright (C) 2020 Reinis Cirpons
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

// TODO(later):
// 1. add more tests

#include <iostream>

#include "libsemigroups/obvinf.hpp"

#include "catch.hpp"  // for REQUIRE, REQUIRE_THROWS_AS, REQUI...
#include "test-main.hpp"

namespace libsemigroups {
  // TODO(v2): uncomment these tests or remove them
  /*LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "001",
                          "Multiple rule additions",
                          "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(3);
    std::vector<std::string>                       v
        = {"aababbaccabbc", "a", "aaabbbbaaabbbbacbbb", "bb"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
    v = {"cc", "bababab"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
    v = {"bbbaaaaabbbaaaaabbbaaaaabbbcccbbbbbbbbb",
         "bcbab",
         "aaababaabbbccc",
         "aa",
         "",
         "aaaaaaabbbbbbbbbc"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
    v = {"a", "aa"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(!ioi.result());
    v = {"b", "bbaa", "caa", "ccbbbaa"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(!ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE(
      "ObviouslyInfinite",
      "002",
      "A power of the generator 'b' does not occur on its own in any relation",
      "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(2);
    std::vector<std::string>                       v = {"ab", "a", "aba", "ba"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE(
      "ObviouslyInfinite",
      "003",
      "Preserves the number of occurrences of the generator 'a'",
      "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(2);
    std::vector<std::string> v = {"aba", "aa", "bb", "b", "abab", "abbba"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "004",
                          "Less relations than generators",
                          "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(3);
    std::vector<std::string>                       v = {"aba", "bc", "ca", "b"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "005",
                          "Relations preserve length",
                          "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(3);
    std::vector<std::string>                       v
        = {"aaa", "bbc", "cccc", "bcba", "bb", "cb", "cba", "bbc"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "006",
                          "Matrix has non empty kernel",
                          "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(2);
    std::vector<std::string> v = {"aa", "bba", "bbaa", "bbbbbb"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "007",
                          "Free product of trivial semigroups",
                          "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(2);
    std::vector<std::string>                       v = {"a", "aa", "b", "bb"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "008",
                          "Another free product",
                          "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(5);
    std::vector<std::string>                       v
        = {"a", "aa", "b", "bb", "abe", "eee", "dc", "c", "cc", "ddd"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "009",
                          "Infinite but not obviously so",
                          "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(2);
    std::vector<std::string>                       v = {"a", "abb", "b", "baa"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(!ioi.result());
    // Currently the test does not pass, but the semigroup
    // is infinite! Contains (ab)^n for all n.
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "010",
                          "Finite semigroup",
                          "[quick]") {
    detail::IsObviouslyInfinite<char, std::string> ioi(3);
    std::vector<std::string>                       v
        = {"a", "aa", "b", "bb", "", "cc", "ac", "cb", "abab", "ab"};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(!ioi.result());
    // This is a presentation for a finite semigroup so
    // we should never detect it as obviously infinite
  }*/


  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "011",
                          "Multiple rule additions",
                          "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(3);
    std::vector<word_type>      v
        = {{0010110220112},
           {0},
           {0001111000111102111},
           {11}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
    v = {{22}, {1010101}};
    ioi.add_rules(v.cbegin(), v.cend());
#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
    REQUIRE(ioi.result());
#else
    REQUIRE(!ioi.result());
#endif

    v = {{11100000111000001110,
          0000111222111111111},
         {12101},
         {00010100111222},
         {00},
         {},
         {00000001111111112}};
    ioi.add_rules(v.cbegin(), v.cend());
#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
    REQUIRE(ioi.result());
#else
    REQUIRE(!ioi.result());
#endif
    v = {{0}, {00}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(!ioi.result());
    v = {{1}, {1100}, {200}, {2211100}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(!ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE(
      "ObviouslyInfinite",
      "012",
      "A power of the generator 'b' does not occur on its own in any relation",
      "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(2);
    std::vector<word_type>      v = {{01}, {0}, {010}, {10}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE(
      "ObviouslyInfinite",
      "013",
      "Preserves the number of occurrences of the generator 'a'",
      "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(2);
    std::vector<word_type>      v
        = {{010}, {00}, {11}, {1}, {0101}, {01110}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "014",
                          "Less relations than generators",
                          "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(3);
    std::vector<word_type>      v = {{010}, {12}, {20}, {1}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "015",
                          "Relations preserve length",
                          "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(3);
    std::vector<word_type>      v = {{000},
                                     {112},
                                     {2222},
                                     {1210},
                                     {11},
                                     {21},
                                     {210},
                                     {112}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "016",
                          "Matrix has non empty kernel",
                          "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(2);
    std::vector<word_type>      v
        = {{00}, {110}, {1100}, {111111}};
    ioi.add_rules(v.cbegin(), v.cend());
#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
    REQUIRE(ioi.result());
#else
    REQUIRE(!ioi.result());
#endif
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "017",
                          "Free product of trivial semigroups",
                          "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(2);
    std::vector<word_type>      v = {{0}, {00}, {1}, {11}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "018",
                          "Another free product",
                          "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(5);
    std::vector<word_type>      v = {{0},
                                     {00},
                                     {1},
                                     {11},
                                     {014},
                                     {444},
                                     {32},
                                     {2},
                                     {22},
                                     {333}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(ioi.result());
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "019",
                          "Infinite but not obviously so",
                          "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(2);
    std::vector<word_type>      v = {{0}, {011}, {1}, {100}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(!ioi.result());
    // Currently the test does not pass, but the semigroup
    // is infinite! Contains (ab)^n for all n.
  }

  LIBSEMIGROUPS_TEST_CASE("ObviouslyInfinite",
                          "020",
                          "Finite semigroup",
                          "[quick][integer-alphabet]") {
    detail::IsObviouslyInfinite ioi(3);
    std::vector<word_type>      v = {{0},
                                     {00},
                                     {1},
                                     {11},
                                     {},
                                     {22},
                                     {02},
                                     {21},
                                     {0101},
                                     {01}};
    ioi.add_rules(v.cbegin(), v.cend());
    REQUIRE(!ioi.result());
    // This is a presentation for a finite semigroup so
    // we should never detect it as obviously infinite
  }
}  // namespace libsemigroups

Messung V0.5 in Prozent
C=89 H=92 G=90

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-06-17) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik