Does anybody know how to find the dual of the following (Boolean Algebra)? p*(q+r') - boolean

Does anybody know how to find the dual of the following (Boolean Algebra)?
p*(q+r')
Where * stands for AND, + stands for OR, and ' stands for NOT.
I have the following, but it is incorrect:
p + (qr')

not a and not b => not (a or b)
Here a = p', b = (q+r')' = (q'r). Hence p*(q+r') = (p'+q'r)'

Related

How do I create a simplified logic circuit of this given [(A’B’)’ + (A’+ B’)’]’ ? and What is the simplified Boolean expression?

I have to draw the simplified logic circuit of this given [(A’B’)’ + (A’+ B’)’]’ and also get the simplified boolean expression
From DeMorgan Theory
((A'B')' + (A'+ B')')'=(A+B + AB)'
(A+B + AB)' = (A+B)'. (AB)'
(A+B)'. (AB)' = (A'.B') .(A'+B')
assume
X=A' ,Y=B'
we can conclude that
(XY)(X+Y) is (XY)
as both (XY) and (X+Y) has to be 1 to produce 1 at output as seen from truth table of (XY)(X+Y) is (XY) is identical to XY
so as final result
((A'B')' + (A'+ B')')'=(A+B + AB)'
(A+B + AB)' = (A+B)'. (AB)'
(A+B)'. (AB)' = (A'.B') .(A'+B') = A'B'
before simplifying
after simplifying
comparing outputs to make sure
(A'B')' = A + B
Using DeMorgan's theorem (AB)' = A' + B'
(A'+B')' = AB
Again, using DeMorgan's theorem (A+B)' = A'B'
Therefore, now we have the expression:
(A+B + AB)'
Taking A+B as X and AB as Y
(X+Y)' = X'Y'
= (A+B)'·(AB)'
Now, creating a logic circuit is fairly simple for this expression, inputs A and B are fed to a NOR gate and NAND gate simultaneously whose outputs act as input to an AND gate

Matlab: replace specific argument that appears more than once

let's say I have s=g(1,2,0)+g(1,3,0)+u(1,3)+g(1,1,0) where g, u are functions; I want to replace all 3rd arguments of g to something I choose without going through my script and doing it manually.
x = ... % assign some value beforehand
s = g(1,2,x) + g(1,3,x) + u(1,3) + g(1,1,x)
What follows is an ugly hack and I don't recommend using it:
g = #(a,b,c) g(a,b,0)
This redefines g function in a way that executing after that:
s = g(1,2,5) + g(1,3,3) + u(1,3) + g(1,1,2)
actually executes:
s = g(1,2,0) + g(1,3,0) + u(1,3) + g(1,1,0)

In a recursive function, how does a series of returns get assembled back into a single result?

I'm trying to understand what's going on in this recursive function. It reverses a String, but I don't quite get how these separate return calls get assembled into one string at the end.
def reverse(string: String): String = {
if (string.length() == 0)
return string
return reverse(string.substring(1)) + string.charAt(0)
}
I've analysed the function by adding in print statement, and while I kind of understand how it works (conceptually), I don't understand, well... how it works.
For instance, I know that each cycle of recursion pushes things into the stack.
So, I would expect reverse("hello"), to become a stack of
o
l
l
e
h
But it must be more complex than that, as the recursive call is return reverse(string.substring(1)) + string.charAt(0). So is the stack actually
o,
l, o
l, lo
e, llo
H, ello
?
How does that get turned into the single string we expect?
The stack contains all local variables, as well as any temporary result in an expression where the recursion appears (though those are pushed on the stack even without recursion, because JVM is a stack machine) and, of course, the point where the code execution should resume on return.
In this case, the recursive call is the whole expression (that is, nothing is computed before reverse on the expression it appears). So the only thing besides the code pointer is string. At the deepest level of recursion, the stack will look like this:
level string
5 (empty string)
4 o
3 lo
2 llo
1 ello
0 hello
So when the call to level 5 returns, level 4 will finish computing the expression that reverse is a part of, reverse(string.substring(1)) + string.charAt(0). The value of reverse(string.substring(1)) is the empty string, and the value of string.charAt(0) is o (since the value of string on level 4 is o). The result is o, which is returned.
On level 3, it concatenates the return value from level 4 (o) with string.charAt(0) for string equal to lo, which is l, resulting in ol.
On level 2, it concatenates ol with l, giving oll.
Level 1 concatenates oll with e, returning olle.
Level 0, finally, concatenates olle with h, returning olleh to its caller.
On a final note, when a call is made, what is pushed into the stack is the return point for the code and the parameters. So hello is the parameter to reverse, which is pushed on the stack by reverse's caller.
Use the substitution model to work through the problem:
reverse("hello") =
(reverse("ello") + 'h') =
((reverse("llo") + 'e') + 'h') =
(((reverse("lo") + 'l') + 'e') + 'h') =
((((reverse("o") + 'l') + 'l') + 'e') + 'h') =
(((((reverse("") + 'o') + 'l') + 'l') + 'e') + 'h') =
((((("" + 'o') + 'l') + 'l') + 'e') + 'h') =
(((("o" + 'l') + 'l') + 'e') + 'h') =
((("ol" + 'l') + 'e') + 'h') =
(("oll" + 'e') + 'h') =
("olle" + 'h') =
"olleh"
Аdd a couple of tips on how to make your code better:
Don't use return in functions because function automaticaly return result of last evaluated line
String is a List of Char's, and you can replace string.substring(1) => string.tai, and string.charAt(0) => string.head
If you call immutable method, like length, size or etc you can omit the parentheses string.length() === string.length
That last version of your single line function:
def reverse(s: String): String = if (s.size == 0) s else reverse(s.tail) + s.head

how to solve this boolean algrbra expression

I would like help simplifying this boolean algebra expression:
B*C + ~A*~B + ~A*~C => A*B*C + ~A
I need to know the steps of how to simplify it to the ABC + ~A
'*' indicates "AND"
'+' indicates "OR"
"~A" indicates "A NOT"
Any help would be appreciated!
Thank you!
For a better view, i'll skip * for conjunction, and use ' for negation.
First you shall expand the 2 term disjunctions: Expand B*C , A'*B' and A'*C'
1) (A + A')BC + A'B'(C + C') + A'(B + B')C'
now distribute the parentheses.
2) ABC + A'BC + A'B'C + A'B'C' + A'BC' + A'B'C'
the fourth term and the last term are the same, A'B'C', so ignore one of them since p + p = p or you can expand the situation for your needs (might be needed for some situations) as in p+p+p+p+....+p = p
3) So now, lets try to search for common terms. See the 2nd term and 5th term, A'BC and A'BC'. Take common parenthesis, A'B(C+C') => A'B.
Do the same for 3rd term and the 4th term, A'B'C and A'B'C'. A'B'(C+C') => A'B' since X+X' = 1.
now we have:
ABC + A'B + A'B'
4) take common parenthesis again, 2nd and 3rd term: A'(B+B')
There you have ABC + A'
BC + A'B' + A'C' => ABC + A'

Simplifying Boolean Expressions with DeMorgan’s law

I need help simplifying the following Boolean expressions using DeMorgan’s law:
a) [ (AB)' + (CD)' ]'
and
b) [(X+Y)' + (X+Y') ]'
Please show some steps so I can do the other ones myself
a)
First step is the outermost negation: distribute it.
((AB)')'*((CD)')'
You see we have double negations which means the expression itself. (p')' = p
therefore
ABCD
[ (AB)' + (CD)' ]' --> ABCD
b)
Distribute the outermost negation:
((X+Y)')'(X+Y')'
get rid of the double negation:
(X+Y)(X+Y')'
again, distribute the negation (the one at the outer part of the expression):
(X+Y)(X'Y)
When you distribute (X+Y), we get
XX'Y + YX'Y
Since there is XX' in the first part of disjunction, the expression XX'Y equals to 0 (False).
Multiple instances of the same thing in an expression is the same thing itself. ppp = p.
Therefore:
0 + YX' --> YX'
[ (X+Y)' + (X+Y') ]' --> YX'
Im sorry for non-formal language:) hope it helps.
Steps are included:
a: [ (AB)' + (CD)' ]' = (AB)'' * (CD)'' = (AB) * (CD) = ABCD
b: [ (X+Y)' + (X+Y') ]' = (X+Y)'' * (X+Y')' = (X+Y) * (X'*Y) .. Simplifying this further relies on the distributive property.