Questions tagged [boolean-algebra]

Anything related to Boolean algebra and its application to computer programs. Boolean algebra is a mathematical theory that allows the representation of truth values `true` and `false` using the logic values `1` and `0` and to perform logic operations on them using algebraic notation.

Anything related to Boolean algebra and its application to computer programs. Boolean algebra is a mathematical theory that allows the representation of truth values true and false using the logic values 1 and 0 and to perform logic operations on them using algebraic notation.

See Wikipedia page on Boolean algebra.

125 questions
8
votes
2 answers

Is there a known algorithm for simplifying a boolean expression with number comparisons?

For example, if I have the expression (A > 5) && (A == 6), that expression can be simplified to just (A == 6), and still have the same behavior for A ∈ ℤ. I also need it to work with multiple variables, so for instance ((B > 2) && (C == 2)) || ((B >…
7
votes
1 answer

Why does Java Boolean implement Comparable?

In Java, operators <, >, >= and <= are not defined for the primitive boolean type. However, the corresponding wrapper class Boolean implements Comparable. That is: true > false is an error, but Boolean.TRUE.compareTo(Boolean.FALSE) > 0 is fine. How…
4
votes
1 answer

Simplify three way comparison a < b < c || b < c < a || c < a < b;

Is there a shorter way to compute this boolean expression? a < b < c || b < c < a || c < a < b In JavaScript this would be: a < b && b < c || b < c && c < a || c < a && a < b Is there some useful maths or boolean algebra trick which would make this…
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
4
votes
2 answers

What is a good data structure for processing boolean algebra equations?

I'm creating a program that will calculate the truth values for a boolean algebra equation. I need to find a good data structure that will be able to correctly process the order of operations of an equation involving AND, OR, NOT, and parentheses as…
3
votes
1 answer

Ways of using(assigning) variables in Sage

I need to test an n-variable Boolean Function f = f(x0,...,xn-1). I need to fix x0, then run some tests for the g1 = f(x1,...,xn-1), then fix x1 and so on. The problem is that I don't really understand how to do it with Sage. At first, I tried to…
3
votes
3 answers

How to convert cond statements that produces a boolean value into an expression involving only not, and and or

I am learning about racket/scheme and came across an online resource that said, if a function written using a cond gives true or false, it can be rewritten using only not, and, and or. I have worked out some simple examples where I was able to to…
3
votes
2 answers

How to tell if there is fault in the truth table?

In my digital design and computer architecture class.Our teacher gave a truth table for which we had to construct a K-map and minimize it to find the boolean expression But some of the students quickly identified that there were mistakes in the…
3
votes
1 answer

Bitwise operation with TSQL like rotation, selective bit inversion

How to do bitwise operation with TSQL. I want to shift 1 bit towards left position. the extreme left bit should become extreme right bit as well. Eg1: Declare @a tinyint = 15 --Which is equal to 0000 1111 I need the result to be 30 --Which is equal…
2
votes
1 answer

CNF by truth table

I have a boolean function that is presented by truth table. In total it is 10 variables and I'd like to get CNF with a reasonable length (not necessary the shortest, but short enough). How can I do it? Python script or any public available software…
knst
  • 523
  • 2
  • 16
2
votes
1 answer

Backus–Naur form with boolean algebra. Problem with brackets and parse tree

boolean algebra I want to write those boolean expression in Backus-Naur-Form. What I have got is: < variable > ::= < signal > | < operator> | < bracket >< variable> < signal> ::=

| | | < operator> ::= | | |…

hi_there
  • 41
  • 4
2
votes
1 answer

Transitivity, or How To Chain Generic Implicits in Scala

I'm attempting to extend the functionality described in this excellent article by Miles Sabin: Unboxed Union Types to support n-ary type unions, e.g.: def if[T](t: T)(implicit ev: T <<: (Int | String | Symbol | Double)): String = ??? I've modified…
2
votes
1 answer

How can I get `True` from `[1, 1, 0, 0, 0] == [0, 0, 1, 1, 0]` in Python?

Example: I have a solution list a: a = [1, 1, 0, 0, 0] and input lists bs: b1 = [1, 1, 0, 0, 0] b2 = [0, 1, 1, 0, 0] b3 = [0, 0, 1, 1, 0] ... bn = [1, 0, 0, 0, 1] If I compare a to either b1, b2, ..., bn, I expected to get True value from the…
fronthem
  • 4,011
  • 8
  • 34
  • 55
2
votes
1 answer

Matlab program for calculate logical circuit outputs

I had to calculate every output on this logical circuit, and i dont have any experience with electronic. So, i searched for the meaning of the symbols and i build my program on Matlab. Somebody can look and help me if i did it wrong or pointing a…
2
votes
1 answer

Java/Demorgan's Law/Boolean Algebra/Random Dice/

I need some help getting this code to work. I need to be able to Write a program that counts how many times three six-sided dice must be rolled until the values showing are all different. Instructions: Write a driver that generates 10 output…
user5129558
2
votes
1 answer

Logical Boolean Negation Operator Precedence and Association

here's my first question(s) on StackOverflow, and as such I imagine it has been asked here before, but everything I type into the search bar gives me different questions. (Or sometimes "no" results at all!) I am learning on w3Schools, but I saw this…
1
2 3
8 9