Can I use algebra boolean to reduce the number of lines in my code?

I am recently studding computer science and I was introduced in algebra boolean. It seems that algebra bool is used to simplify logic gates in hardware in order to make the circuit design minimal and thus cheaper. Is there any similar way that you can use it to reduce the number of codes in your software in higher level like C++, c# or any other higher languages?

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given (PHP)

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given

Все статьи пересмотрел, не помогло. Первоначальный код такой:

$  row = mysqli_fetch_array($  result); 

Какой второй должен быть параметр чтобы ошибка ушла?

n-DNF boolean formula k satisfiability

Given an n variable boolean DNF formula and a number k, does this formula has satisfying input combination greater than k?. (0<=k<=2^n). Where input is infinite number of n tuples where repeating tuple is possible. For exampl. F(a,b) =ab + a’b. Input set is (11,00,11,01) and k=2. Answer is 3 here so decision says yes as 3>k. Can i define this problem in more formal way and prove that it is np/npc/ anything else. I am looking for suggestions specially for infinite number of tuples. I am aware of npc and reduction stuffs but need help to classify this problem properly.

Fatal error: Uncaught Error: Call to a member function fetchAll() on boolean in C:\xampp\htdocs\APNNAC\index.php:184 Stack trace: #0 {main} thrown in

            $  sql .= "ORDER BY `evento_id` LIMIT 2;";              $  sql .= "SELECT `evento_id`, `nombre_evento`, `fecha_evento`, `hora_evento`, `cat_evento`, `lugar`, `nombre_invitado`, `apellido_invitado` ";             $  sql .="FROM `eventos` ";             $  sql .= "INNER JOIN `categoria_evento` ";             $  sql .= "ON eventos.id_cat_evento=categoria_evento.id_categoria ";             $  sql .= "INNER JOIN `invitados` ";             $  sql .= "ON eventos.id_inv=invitados.invitado_id";             $  sql .= "AND eventos.id_cat_evento = 2 ";             $  sql .= "ORDER BY `evento_id` LIMIT 2;";              $  sql .= "SELECT `evento_id`, `nombre_evento`, `fecha_evento`, `hora_evento`, `cat_evento`, `lugar`, `nombre_invitado`, `apellido_invitado` ";             $  sql .="FROM `eventos` ";             $  sql .= "INNER JOIN `categoria_evento` ";             $  sql .= "ON eventos.id_cat_evento=categoria_evento.id_categoria ";             $  sql .= "INNER JOIN `invitados` ";             $  sql .= "ON eventos.id_inv=invitados.invitado_id";             $  sql .= "AND eventos.id_cat_evento = 3 ";             $  sql .= "ORDER BY `evento_id` LIMIT 2;";          } catch (Exception $  e) {             //throw $  th;             $  error = $  e->getMessage();         } ?>         <?php echo $  sql; ?>          <?php $  conn->multi_query($  sql); ?>          <?php          do {              # code...              $  resultado = $  conn->store_result();              $  row = $  resultado->fetchAll(MYSQLI_ASSOC); ?>               <?php $  i = 0; ?>               <?php foreach($  row as $  evento): ?>              <?php if($  i % 2 == 0) { ?>              <div id="<?php echo strtolower($  evento['cat_evento']) ?>" class="info-curso ocultar clearfix">              <?php } ?>               <div class="detalle-evento">                  <h3><?php echo utf8_encode($  evento['nombre_evento']) ?></h3>                  <p><i class="icon-clock-o"></i><?php echo $  evento['hora_evento']; ?></p>                  <p><i class="icon-calendar-check-o"></i><?php echo $  evento['fecha_evento']; ?></p>                  <p><i class="icon-map-marker"></i><?php echo $  evento['lugar']; ?></p>                  <p><i class="icon-user"></i><?php echo $  evento['nombre_invitado']?></p>              </div>                <?php if($  i % 2 == 1): ?>                <a href="ver_todos_eventos.php" class="button float-right">Ver todos</a>               </div>              <?php endif;?>              <?php $  i++; ?>             <?php endforeach; ?>             <?php $  resultado->free(); ?>         <?php } while ($  conn->more_results() && $  conn->next_result());?>     </div><!--contenedor--> 

How to “logically” solve boolean logic

I came across of one excellent book Elements of Computing Systems and in chapter 1 we need to implement the “primitive” logic gates (for example: Not, And, Or, Xor, Mux, etc) based on a Nand gate.

Up to now I’m just solving these boolean implementations by guessing all required gates which is so much time consuming. I’m not able to find any logic in the implementation.

I’m wondering if you have any method, tipp how to solve this.

Here is an example of the Mux requirements presented in the book

Mux requirement image example Mux requirement image example continue

How to “logical” solve boolean logic [on hold]

I came across of one excellent book Elements of Computing Systems and in chapter 1 we need to implement the “primitive” logic gates (for example: Not, And, Or, Xor, Mux, etc) based on a Nand gate.

Up to now I’m just solving these boolean implementations by guessing all required gates which is so much time consuming. I’m not able to find any logic in the implementation.

I’m wondering if you have any method, tipp how to solve this.

Here is an example of the Mux requirements presented in the book

Mux requirement image example Mux requirement image example continue

Proof: $U$ is an ultrafilter of a Boolean algebra $B$ if and only if for all $x$ in $U$ exactly one of $x$,$x^*$ belongs to $U$.

I have been stuck with this problem for a while now. I have a proof that letting $ U$ be an ultrafilter, exactly one of $ x,x^*$ belongs to $ U$ for all $ x$ in $ B$ , I did this by showing that both belong to $ U$ implies that $ U=B$ which cannot be the case, and if neither long to $ U$ then a contradiction can be derived by de-Morgan’s laws. However, I’m stuck with the reverse implication, I need to prove that:

“If $ U$ is a subset of a Boolean algebra $ B$ such that $ \forall x \in B$ , exactly one of $ x \in U$ and $ x^* \in U$ is true.

Is this even the case? Any help would be greatly appreciated, thanks in advance.