Example #1
0
 /**
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     $tmp_vector = array_reverse(array_map(function ($val) {
         return ($val + 1) % 2;
     }, $table->getVector()));
     return $tmp_vector == $table->getVector() || (new CClass())->belongs($table);
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     $vector = $table->getVector();
     $count_vector = count($vector);
     $truth_table = $table->getTruthTable();
     $count_line = count($truth_table[0]);
     $sets = [];
     for ($i = 0; $i < $count_vector; $i++) {
         if ($vector[$i] == 1) {
             array_push($sets, $i);
         }
     }
     $sets_count = count($sets);
     if ($sets_count < 2) {
         return false;
     }
     for ($i = 0; $i < $count_line; $i++) {
         $k = 0;
         for ($j = 0; $j < $sets_count; $j++) {
             if ($truth_table[$sets[$j]][$i] == 1) {
                 $k++;
             }
         }
         if ($k > 1) {
             return true;
         }
     }
     return false;
 }
Example #3
0
 /**
  * Examples: xy, 0, 1
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     $sknf = 0;
     $vector = $table->getVector();
     $count = count($vector);
     for ($i = 0; $i < $count; $i++) {
         if ($vector[$i] == 0) {
             $sknf++;
         }
     }
     return $sknf != 1;
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     $values = [];
     $truth_table = $table->getTruthTable();
     $vector = $table->getVector();
     $count_vector = count($vector);
     $count_line = count($truth_table[0]);
     for ($i = 0; $i < $count_vector; $i++) {
         $line_values = [];
         array_push($line_values, '0');
         for ($t = 0; $t < $count_line; $t++) {
             for ($j = 0; $j < $count_line; $j++) {
                 if ($truth_table[$i][$j] == '1') {
                     $k = $j + 1;
                     $tmp_key = (string) $k;
                     while (strlen($tmp_key) != $t + 1 && $k != $count_line) {
                         if ($truth_table[$i][$k] == '1') {
                             $tmp_key .= $k + 1;
                         }
                         $k++;
                     }
                     if (!in_array($tmp_key, $line_values)) {
                         array_push($line_values, $tmp_key);
                     }
                 }
             }
         }
         $find_key = '0';
         $find_val = 0;
         $tmp_val = 0;
         foreach ($line_values as $value) {
             if (!array_key_exists($value, $values)) {
                 $find_key = $value;
             } else {
                 $tmp_val += (int) $values[$value];
             }
         }
         if ($tmp_val % 2 != (int) $vector[$i]) {
             $find_val = 1;
         }
         $values[$find_key] = $find_val;
     }
     foreach ($values as $key => $value) {
         if ($key > 10 && $value == 1) {
             return false;
         }
     }
     return true;
 }
Example #5
0
 /**
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     $vector = $table->getVector();
     $count_vector = count($vector);
     $nulls = 0;
     $ones = 0;
     for ($i = 0; $i < $count_vector; $i++) {
         if ($vector[$i] == 0) {
             $nulls++;
         } else {
             $ones++;
         }
     }
     return $nulls == $count_vector || $ones == $count_vector;
 }
Example #6
0
 /**
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     $vector = $table->getVector();
     $count = count($vector);
     for ($i = 0; $i < $count; $i++) {
         if ($vector[$i] == 1) {
             for ($j = $i + 1; $j < $count; $j++) {
                 if ($vector[$j] == 0) {
                     return false;
                 }
             }
             return true;
         }
     }
     return true;
 }
 /**
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     $vector = $table->getVector();
     $count_vector = count($vector);
     $truth_table = $table->getTruthTable();
     $count_line = count($truth_table[0]);
     for ($i = 0; $i < $count_line; $i++) {
         $k = 0;
         for ($j = 0; $j < $count_vector; $j++) {
             if ($vector[$j] <= $truth_table[$j][$i]) {
                 $k++;
             }
         }
         if ($k == $count_vector) {
             return true;
         }
     }
     return false;
 }
Example #8
0
 /**
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     return array_pop($table->getVector()) == 1 ? true : false;
 }
Example #9
0
 /**
  * @inheritdoc
  */
 public function belongs(Table $table)
 {
     return array_shift($table->getVector()) == 0 ? true : false;
 }