Boolean Simplification - Q=A.B.(~B+C)+B.C+B - boolean-expression

I've been struggling with boolean simplification in class, and took it to practice some more at home. I found a list of questions, but they don't have any answers or workings. This one I'm stuck on, if you could answer clearly showing each step I'd much appreciate:
Q=A.B.(~B+C)+B.C+B
I tried looking for a calculator to give me the answer and then to work out how to get to that, but I'm lost
(I'm new to this)
Edit: ~B = NOT B

I've never done this, so I'm using this site to help me.
A.B.(B' + C) = A.(B.B' + B.C) = A.(0 + B.C) = A.(B.C)
So the expression is now A.(B.C) + B.C + B.
Not sure about this, but I'm guessing A.(B.C) + (B.C) = (A + 1).(B.C).
This equals A.(B.C).
So the expression is now A.(B.C) + B.
As A.(B + C) = B.(A.C), the expression is now B.(A.C) + B, which equals (B + 1).(A.C) = B.(A.C).
NOTE: This isn't complete yet, so please avoid downvoting as I'm not finished yet (posted this to help the OP understand the first part).

Let's be lazy and use sympy, a Python library for symbolic computation.
>>> from sympy import *
>>> from sympy.logic import simplify_logic
>>> a, b, c = symbols('a, b, c')
>>> expr = a & b & (~b | c) | b & c | b # A.B.(~B+C)+B.C+B
>>> simplify_logic(expr)
b
There are two ways to go about such a formula:
Applying simplifications,
Brute force
Let's look at brute force first. The following is a dense truth table (for a better looking table, look at Wα), enumerating all possible value for a, b and c, alongside the values of the expression.
a b c -- a & b & (~b | c) | b & c | b = Q
0 0 0 0 0 10 1 0 0 0 0 0 = 0
0 0 1 0 0 10 1 1 0 0 1 0 = 0
0 1 0 0 1 01 0 0 1 0 0 1 = 1
0 1 1 0 1 01 1 1 1 1 1 1 = 1
1 0 0 1 0 10 1 0 0 0 0 0 = 0
1 0 1 1 0 10 1 1 0 0 1 0 = 0
1 1 0 1 1 01 1 0 1 0 0 1 = 1
1 1 1 1 1 01 1 1 1 1 1 1 = 1
You can also think of the expression as a tree, which will depend on the precedence rules (e.g. usually AND binds stronger than OR, see also this question on math.se).
So the expression:
a & b & (~b | c) | b & c | b
is a disjunction of three terms:
a & b & (~b | c)
b & c
b
You can try to reason about the individual terms, knowing that only one has to be true (as this is a disjunction).
The last two will be true, if and only if b is true. For the first, this a bit harder to see, but if you look closely: you have now a conjunction (terms concatenated by AND): All of them must be true, for the whole expression to be true, so a and b must be true. Especially b must be true.
In summary: For the whole expression to be true, in all three top-level cases, b must be true (and it will be false, if b is false). So it simplifies to just b.
Explore more on Wolfram Alpha:
https://www.wolframalpha.com/input/?i=a+%26+b+%26+(~b+%7C+c)+%7C+b+%26+c+%7C+b

A.B.(~B+C) + B.C + B = A.B.~B + A.B.C + B.C + B ; Distribution
= A.B.C + B.C + B ; Because B.~B = 0
= B.C + B ; Because A.B.C <= B.C
= B ; Because B.C <= B

Related

Boolean Logic Simplification: AB+A'B'=?

I have some problem simplifying the equation AB+A'B'= ? Is there any straight forward answer like AB'+A'B = A^B ; (^)=XOR sign ?
It's the XNOR function, which typically doesn't occur often enough to warrant its own operator. It's the negation of XOR, though, which can be seen by applying De Morgan's law twice.
AB + A'B' = ((AB)'(A'B')')'
= ((A' + B')(A + B))'
= (A'A + B'A + A'B + B'B)'
= (0 + AB' + A'B + 0)'
= (AB' + A'B)'
= (A ^ B)'
or by simply comparing truth tables
A B A ^ B AB + A'B'
-------------------------
0 0 0 1
0 1 1 0
1 0 1 0
1 1 0 1
(Put another way, XNOR is equivalence for two arguments, so you can think of A XNOR B as an operator that converts comparison to a value. A XNOR B equals 1 if A == B is true, 0 if it is false.)

Matlab vector to its binary representation

I have a vector like A: 1 3 7 8
I would like to construct a binary vecor such as B (1 2 3 4 5 6 7 8)
(1 0 1 0 0 0 1 1)
You can use just indexing:
B = zeros(1, max(A));
B(A) = 1;
Or use sparse:
B = full(sparse(1, A, 1));
These approaches don't require arithmetical operations, and thus may be faster than previous answers.
How about:
binA = sum( de2bi(2.^(A-1)) , 1 )
binA =
1 0 1 0 0 0 1 1
You can first convert the vector to an integer (base 10),
d = sum(A(:).*(10.^[numel(A)-1: -1: 0])(:))
then convert d to binary using
b = de2bi(d)
You can then extract as many bits as you want from b

Assigning values to a matrix, Right Hand Side is a Function of the Index

I am trying to assign multiple values simultaneously to a matrix using MATLAB vectorization. In my code, I currently have something like:
y(1,:) = G(x(1:2,:))
y(2,:) = G(x(3:4,:))
and so on..
G is a function which involves relational operators with rows of the input argument as operands.
function g = G(x)
g = x(1,:) | x(2,:)
Is there a way to apply function G to the entire x-array without using a for-loop?
Thanks.
For this type of function it is indeed possible. Define your function so that it works with all rows at the same time:
G = #(x) x(1:2:end,:) | x(2:2:end,:)
and then:
y = G(x);
Example: let
x =
1 1 0 1 0
0 0 0 0 0
1 1 0 0 0
1 0 1 0 1
1 1 1 1 1
1 0 0 1 1
Then y = G(x) gives
y =
1 1 0 1 0
1 1 1 0 1
1 1 1 1 1

Basic identities of logical expressions and deriving logical expressions from truth table?

I was wondering what a basic identity of a logical expression is and how to get it. I looked on google but couldn't find anything about it.
Say, for example I have a logical expression ~(~(P ^ ~(P ^ Q)) ^ ~(Q ^ ~(P ^ Q)))
Below is the result I got from a truth table and I don't know what to do with it to get a basic identity.
0
1
1
0
As well, as that I have a truth table and I have no idea how to derive a logical expression from it.
P Q R F
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
When you have the truth table, creating a DNF formula is trivial. Take a look at where the assignment is true. Then you end you end up with (exclamation mark means negation)
(P & !Q & R) OR (P & Q & !R) OR (P & Q & R).

Combine two boolean equations to separate a boolean variables from others

I have 2 programs: X and Y.
X has two bitmaps A and C.
X calls Y.
Y has a bitMap B.
The code I need to execute in Y is
if AB == B && BC == C
//do some action Z
I want to combine on A and C using boolean operations such that I can pass a single bitMap to Y. This single bitmap can then do any boolean operation with B to return true / false and accordingly I can decide to do action Z.
There is no way to simplify by combining A and C.
Here is our truth table:
B A C Z
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
We can see from the truth table that when B = 0, we have Z = not C; when B = 1, we have Z = A.
Suppose for the sake of contradiction that we have a one-bit function Y = f(A, C) that "summarizes" A and C. We use B to choose whether the summary equals 'not C' versus 'A'. But this is clearly impossible, because a single bit cannot preserve enough information to be able to extract the value 'not C' and also the value 'A'.