Can I Make NOT Using OR and AND? - logic

I know i can invert X using NOT.
NOT x = x'
But, can i invert X just with OR & AND ?
Example
Given this function
F = W'.Y.Z' + V.W'.Z'
Can i make a circuit just with OR & AND ?
Thanks

It is not possible to make NOT out of AND and OR. The first obvious reason is that NOT takes only one argument, while both AND and OR take two. Even if you feed the same variable twice to the AND/OR gates, they will not invert its value
OTOH, you can define AND in terms of OR+NOT and you can define OR in terms of AND+NOT
x AND y = NOT((NOT x) OR (NOT y))
x OR y = NOT((NOT x) AND (NOT y))

You can't get NOT from OR and AND. Proof:
With a 0 input, OR and AND will both be 0. There will be no 1 anywhere in the system. With a 1 input, OR and AND will both be 1. There will be no 0 anywhere.
This is why NAND and NOR chips are popular for small/hobby electronics, since they can make any other logic combination.

No, you can't get NOT with just combinations of ANDs and ORs.

Related

How can I bind the same variables together in prolog

So, I'm relatively new to prolog and was wondering if it is possible to bind 2 variables together in a matrix and would they update simultaneously.
For example, I have this
X = [[_,_], [_,_]].
X = [[_23838, _23844], [_23856, _23862]].
But, I was wondering is it possible to do something like this, almost unifying the diagonal elements in the matrix
X = [[_,_], [_,_]].
X = [[_23838, _23844], [_23856, _23838]].
Assuming the above is possible if _23838 was later bound then would they be the same value?
For example
X = [[5,_], [_,5]].
X = [[5, _23844], [_23856, 5]].
Yes you can.
Just name the variables instead of using the don't care name (aka. "the anonymous variable"), i.e. _:
X = [[A,B], [C,A]].
This expresses the constraint that the value at (1,1) must be the same as the value at (2,2).
You can also start off with "all variables different" and later force them to be equal by unification:
X = [[A,B], [C,D]], A=D
Conversely, you can state that you do not want to see equality in a result (all proofs that can only continue by making A and B equal will fail after dif/2):
X = [[A,B], [C,D]], dif(A,B).
dif/2 is of some interest.

lambda calculus example quenstion

(λy.x z)c
I think a answer about this problem is x z.
If it is correct, why (λy.x z)c = x c is incorrect?
In this case, I refer to (λy.x z) = (λy.x)z = x. So I calculate it in the parenthesis first.
(λy.x z) c is not a problem, it is a λ-term.
You refer to λy.x z = (λy.x) z but there is no way to move the parentheses, otherwise it would mean they were useless.
λy. x z
Means the function which takes y as argument and returns x applied to z.
While (λy.x) z means the function which takes y as argument and returns x, the whole thing applied to z. Why would those two things be the same?
(They are not.)

Using AND or OR logic gates to construct a 4-variable function

I'm a software developer, and I'm trying to model a function using only AND or OR gates. I remember having similar subjects in my undergraduates, but I don't recall it. f(x,y,z,w) is a function of four variables, and gets True when AT LEAST two of the variables gets true. How can I visually construct it using only AND or OR gates?
UPDATE: I think f= xy+xz+xw+yz+yw+zw if I'm correct!
The following expression is logically what you want:
(xy) + (xz) + (xw) + (yz) + (yw) + (zw)
x (y + z + w) + y (z + w) + (zw)
Note that you don't need to check for cases of three or four TRUE values, because they are already included in the check for two TRUE values.
I represent AND gates with scalar multiplication, and OR gates using the addition operator (+). Note that when you wire up the actual circuit you might even be able to simplify even more than I have by reusing pieces (e.g. z + w).

Calculating product by addition

This is an algorithm question that I've been struggling with. I figured I could get some insight here. I need to make the following function in Haskell:
Declare the type and define a function that takes two numbers as input and finds their product by addition. That is, add the first number, as many times as second number, to itself.
My problem is that this is basically just multiplying two numbers together, but it says that I need to do it with addition. Does anyone have any clue on how to do this?
This is all I can come up with (it's not right): (x + x) * y
Thank you
if a is the first number and b the second
sum $ take a $ cycle [b]
should do ot
mult (x, y):
sum = 0
for 1 to y:
sum = sum + x
return sum
This is just the algorithm. I do not know Haskell. So the lambda expression in the other answer may be more appropriate. Also, I use an intermediate variable.
PS: forget the previous embarrassing recursive algorithm
Work it out by induction.
We know the answer to one simple (the simplest) problem: multiplying anything by 0 yields 0. So we write:
mul x 0 = 0
Now, the inductive step: we can build a solution to a bigger problem, if we know a solution to the smaller problem; that way we can always reduce any big problem to the smallest problem, for which we know the solution. So, for any y, the solution for y+1 can be found by adding x to the solution for y: mul x (y+1) = x + (mul x y). In Haskell we can't write (y+1) on the left hand side, so we write equivalently:
mul x y = x + (mul x (y-1))
This function will keep adding x until y is zero.
Try this also
multiply::(Num a,Eq a) => a -> a -> a
multiply a 0 = 0
multiply a b = a + multiply a (b - 1)
main = print $ multiply 5 7

Obtain x as result for Re[x] in mathematica

I'm trying to obtain the real part of the result of an operation which involves an undefined variable (let's say x).
How can I have Mathematica return x when I execute Re[x] if I know that x will never be a complex number? I think this involves telling Mathematica that x is a real, but I don't know how.
In my case the expression for which I want the real part is more complicated than a simple variable, but the concept will remain the same.
Some examples:
INPUT OUTPUT DESIRED RESULT
----- ------ --------------
Re[x] Re[x] x
Re[1] 1 1
Re[Sin[x]] Re[Sin[x]] Sin[x]
Re[1+x+I] 1 + Re[x] 1+x
Re[1 + x*I] 1-Im[x] 1
You can use for example the input Simplify[Re[x], x \[Element] Reals] which will give x as output.
Use ComplexExpand. It assumes that the variables are real unless you indicate otherwise. For example:
In[76]:= ComplexExpand[Re[x]]
Out[76]= x
In[77]:= ComplexExpand[Re[Sin[x]]]
Out[77]= Sin[x]
In[78]:= ComplexExpand[Re[1+x+I]]
Out[78]= 1+x
Two more possibilities:
Assuming[x \[Element] Reals, Refine[Re[x]]]
Refine[Re[x], x \[Element] Reals]
Both return x.
It can at times be useful to define UpValues for a symbol. This is far from robust, but it nevertheless can handle a number of cases.
Re[x] ^= x;
Im[x] ^= 0;
Re[x]
Re[1]
Re[1 + x + I]
Re[1 + x*I]
x
1
1 + x
1
Re[Sin[x]] does not evaluate as you desire, but one of the transformations used by FullSimplify does place it in a form that triggers Re[x]:
Re[Sin[x]] // FullSimplify
Sin[x]

Resources