Boolean algebra simplifcation [closed] - boolean

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm doing a past paper for my exam on Thursday, and I'm struggling with boolean algebra a bit.
One question asked me to simplify:
[(X + Y).(X + 'Y)]
I can simplify most of it. I got it down to
[X(1 + 'Y + Y)]
The mark scheme says this is equal to [X].
But I don't quite understand why - I guess it's because of the
['Y + Y]
but we're not using the '+' symbol to add them, so why is it like this?

Starting from X * (1 + 'Y + Y), note that 'Y + Y == 1 for any Y because either Y is 1 or else 'Y is, so Y + 'Y is 1 + 0 or 0 + 1, which in both cases equals 1.
That would make the function equivalent to X * (1 + 1), but we also know that 1 + 1 == 1 (true OR true is true) and also X * 1 == X (X AND true is X), so in the end you are left with just X.
Reference: Laws of Boolean algebra, also in a convenient 2-page PDF.

['Y + Y]
X + X' = 1 Now imagine picking one between a value and its opposite.
Since we are referring to Boolean logic, the only options are going to
be 0 or 1. Now see what is the output of the OR operation between 0
and its opposite, i.e. 1. Or see what 1 OR 0 yields. Both yield a 1,
which means that the output of an OR operation between a value and its
negative (opposite), is 1.
http://www.buzzle.com/articles/boolean-algebra-rules.html

In Boolean algebra, If A = 1, A' = 0 and A = true, A' = false. Also every AND operation is (.) and every or operation is (+).
Let me simplify the expression :
(X+Y)(X+'Y)
= XX + XY' + YX + YY'
= X + XY' + YX + 0 // since X.X = X & Y.Y'= 0
= X + XY' + XY // = X(1 + 'Y + Y)
= X + X(Y+Y')
= X + X(1) // Y+Y' = 1
= X + X
= X

Related

How to make the response of the solve function symbolic?

I am solving a fourth order equation in matlab using the solve function.My script looks like this:
syms m M I L Bp Bc g x
m = 0.127
M = 1.206
I = 0.001
L = 0.178
Bc = 5.4
Bp = 0.002
g = 9.8
eqn = ((m + M)*(I + m*L^2) - m^2*L^2)*x^4 + ((m + M)*Bp + (I + m*L^2)*Bc)*x^3 + ((m + M)*m*g*L + Bc*Bp)*x^2 + m*g*L*Bc*x == 0
S = solve(eqn, x)
In the answer, I should get 4 roots, but instead I get such strange expressions:
S =
0
root(z^3 + (34351166180215288*z^2)/7131724328013535 + (352922208800606144*z)/7131724328013535 + 1379250971773894912/7131724328013535, z, 1)
root(z^3 + (34351166180215288*z^2)/7131724328013535 + (352922208800606144*z)/7131724328013535 + 1379250971773894912/7131724328013535, z, 2)
root(z^3 + (34351166180215288*z^2)/7131724328013535 + (352922208800606144*z)/7131724328013535 + 1379250971773894912/7131724328013535, z, 3)
The first root, which is 0, is displayed clearly. Is it possible to make the other three roots appear as numbers as well? I looked for something about this in the documentation for the solve function, but did not find it.

Simplifying following Boolean Expression and verify using Karnaugh Map

I'm having trouble simplifying these two boolean expressions algebraically and proving them with a Karnaugh Map. How can I do this?
These are my two expressions:
1) (X * Y) + (X' * Y * Z')+ (Y * Z)
2) (X * Y') + Z + (X' + Y)+ (Y * Z)
I've tried going through it using the boolean theorems and laws to reduce them but I always come up with different answers. My answers usually comes up as this.
1) (Y * Z') + (X' * Y)
2) (X' * Y') + (X * Y' * Z')
I don't know if my K-Map is wrong, but I do need someone to help me understand how to solve this problem and the steps or laws I need to get the answer, so that I can master it. It is practice for exam, and I suck at boolean algebra. I appreciate it.
Let's start with the first expression:
E = XY + X'YZ' + YZ
The three terms have Y, then we can factor it out
E = Y(X + X'Z' + Z)
Now let's concentrate in the expression in parenthesis S = X + X'Z' + Z:
S = X + X'Z' + Z
= X + (X + Z)' + Z (De Morgan)
= (X + Z) + (X + Z)' (regrouping)
so, despite the fact that this still looks complex it has the form
S = p + p'
for p = X + Z, right? But p + p' = 1 (or true) no matter the value of p. Thus the expression S is 1 and we get
E = Y(X + X'Z' + Z) = YS = Y1 = Y
In other words, the first expression reduces to Y.
Notice also that it is not that hard to see why S = 1 without rewriting it. There are three cases: (a) If X is true, then certainly the expression is true. (b) If Z is true, the result is true also. (c) If none of X and Z are true then both are false and X'Z' is true. So, in each of these 3 cases at least one of the terms is true, hence their sum.
Let's now consider the second expression
F = XY' + Z + (X' + Y) + YZ
The first thing to note is that XY' is the opposite of (X' + Y):
(X' + Y) = (XY')' (De Morgan)
So,
F = XY' + (XY')' + Z + YZ
Again, regardless of the fact that XY' + (XY')' looks complicated, it is an expression of the form p + p'. But p + p' = 1 (it is always true) and therefore
F = 1 + Z + YZ = 1
no matter the values of Y and Z. So, the second expression is nothing but 1 (aka true).

Can someone explain the simplification of this boolean algebra equation?

I think I missed reading a theorem or postulate or something..
The equation is: wy + wxz + xyz
According to my professor, the simplification is (which she didn't explain how):
wy + xz(w'y + wy')
= wy + xz (w XOR y)
Where did that (w'y + wy') came from??
I tried to calculate it but so far I only got: (w+x)(w+y)(w+z)(x+y)(y+z)
In a Boolean expression + is XOR and * is AND. This is the same as identifying true with 1 and false with 0, with the only special convention that 1 + 1 = 0 (or 2 = 0 if you wish.)
With these definitions both + and * are commutative, i.e., a + b = b + a and a * b = b * a. In addition, the distributive law is also valid a * (b + c) = a * b + a * c. Note also that the * operator is usually implicit in the sense that we write ab instead of a * b.
Applying these properties to the expression wy + wxz + xyz, there are some few obvious transformations you can do:
wy + wxz + yxz (commute x with y)
wy + (w + y)xz (prev plus distribute xz)
wy + xz(w + y) (prev plus commute (w + y) with xz
Note that the last one is wy + xz(w XOR y) because + is nothing but XOR.
ADDENDUM
Regarding the expression of your professor, let's recall that a' = 1 - a by definition. So
w'y + wy' = (1 - w)y + w(1 - y) - def
= y - wy + w - wy - distribute
= y + w - simplify (a + a = 0 always)
= w + y - commute
which shows that s/he was right.

Hash collision H(x)=H(y) with x!=y, does that also mean H(x+z)=H(y+z) for random z?

Suppose H is some hash function (such as MD5 or SHA256 or whatever) and I have a collision for this hash: two different pieces of data x and y, that have the same hash.
In other words x≠y but H(x)=H(y).
Now if I concatenate some random data z, will H(x+z) be the same as H(y+z) ?
The idea is: x and y being a collision may imply that they happen to bring the H function in the same state (thus resulting in the same hash). From that point on, it doesn't matter what other data we append, their hashes will remain equal.
I tested the above for this MD5 collision and it seemed to work there. But I don't know if this is true in general?
This particular technique is called a length extension attack. Whether or not a hash function is vulnerable obviously depends on the particular hash function. Hash functions based on the Merkle–Damgård construction, such as MD5 and SHA-1, are vulnerable. SHA-3 is not vulnerable, and HMAC constructions are also not vulnerable.
Depends on the has function. Since hash functions are not homomorphic (that is, where: f(x) = f(y) implies x = y), it does not follow that f(x + z) and f(y + z) will map to the same item. Consider a counter example:
Given the hash function
f(x) = (x * 3) + 1 mod 6
then f(2) = 1 and f(6) = 1. Let z = 1. Then:
f(2 + z) = 4 and f(6 + z) = 1
thus f(2) = f(6) but f(2 + z) ≠ f(6 + z).
However, if the hash function were homomorphic, then by definition of homomorphism:
f(p + q) = f(p) + f(q)
and therefore:
f(x + z) = f(x) + f(z)
f(y + z) = f(y) + f(z)
which but since f(x) = f(y) as you initially stated:
f(x) + f(z) = f(y) + f(z)
and so their hashes would be the same.
(Please be indulgent, it's my first answer :D)
Not necessarily:
Consider the following data (as lists of numbers)
x = [8 0 4]
y = [8 1 0]
z = [5]
and the hashing function:
H([a b c]) = a + b*c
H([a b c d]) = H([b c d]) + H([a b c])
Then, a collision for x and y occurs:
H(x) = H([8 0 4]) = 8 + 0*4 = 8
H(y) = H([8 1 0]) = 8 + 1*0 = 8
But when appending data, the hashes aren't equal:
H(z + x) = H([5 8 0 4]) = H([5 0 8]) + H([8 0 4]) = 5 + 8 = 13
H(z + y) = H([5 8 1 0]) = H([5 8 1]) + H([8 1 0]) = 13 + 8 = 21

(a mod 2*x)-(a mod x) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to find the possible values of this expression.
(a mod 2*x)-(a mod x)
I suspect they might be 0 or x, but I'm really not sure. I can't seem to be able to write down a proper argument.
You are correct that the possible values are 0 and x, assuming that both a and x are positive. The logic is as follows.
Let a have the form
a = p*x + b
Then it is easy to see that a mod x = b.
For a mod 2*x, if p = 2*r (p is even) then
a = 2*r*x + b = (2*x)*r + b
so that a mod 2*x = b and p = 2*r + 1 (p is odd) then
a = (2*r + 1)*x + b = 2*r*x + x + b = (2*x)*r + x + b
so that a mod 2*x = x + b. Combining these results, the difference is either b - b = 0 (when p is even) or (x + b) - b = x (when p is odd).