a = b & c=>a = (b ^ ~c) & b
a = b | c=>a = (b & c) | (b ^ c)
a = a ^ b=>a = (~a & b) | (a & ~b)
知识点:命题逻辑 - > 等值演算
下文中nand应修改为nor!
万用门其实就是数字电路中的与非门,一般是用Nand表示。
Nand(a,b) = ~a & ~b
Not(a) = ~a = ~a & ~a = Nand(a,a)
Or(a,b) = a | b = ~(~a & ~b) = Nand(Nand(a,b),Nand(a,b))
And(a,b) = a & b = ~~a & ~~b = Nand(Nand(a,a),Nand(b,b))
Xor(a,b) = (~a & b) | (a & ~b) = (0 | (a & ~b)) | (0 | (b & ~a)) = (a & (~a | ~b)) | (b & (~a | ~b)) = (~a | ~b) & (a | b) = ~(a & b) | ~(~a & ~b) = Nand(And(a,b),Nand(a,b)) = Nand(Nand(Nand(a,a),Nand(b,b)),Nand(a,b))
-a = ~a + 1
a - b = ~(a - b) + 1 = ~(a - b - 1) = ~(~a + 1 - 1 + b) = ~(~a + b)
减法公式的证明只能说是“自我安慰”,因为我不清楚如何证明其EFLAGS的得到过程。
OLLVM的指令替代混淆:
a = b & c=>a = (b ^ ~c) & b
证明过程:
Nand(a,b) = ~a & ~b
Not(a) = ~a = ~a & ~a = Nand(a,a)
Or(a,b) = a | b = ~(~a & ~b) = Nand(Nand(a,b),Nand(a,b))
And(a,b) = a & b = ~~a & ~~b = Nand(Nand(a,a),Nand(b,b))
Xor(a,b) = (~a & b) | (a & ~b) = (0 | (a & ~b)) | (0 | (b & ~a)) = (a & (~a | ~b)) | (b & (~a | ~b)) = (~a | ~b) & (a | b) = ~(a & b) | ~(~a & ~b) = Nand(And(a,b),Nand(a,b)) = Nand(Nand(Nand(a,a),Nand(b,b)),Nand(a,b))
-a = ~a + 1
a - b = ~(a - b) + 1 = ~(a - b - 1) = ~(~a + 1 - 1 + b) = ~(~a + b)
减法公式的证明只能说是“自我安慰”,因为我不清楚如何证明其EFLAGS的得到过程。
Nand(a,b) = ~a & ~b
Not(a) = ~a = ~a & ~a = Nand(a,a)
Or(a,b) = a | b = ~(~a & ~b) = Nand(Nand(a,b),Nand(a,b))
And(a,b) = a & b = ~~a & ~~b = Nand(Nand(a,a),Nand(b,b))
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
最后于 2019-2-22 22:20
被天水姜伯约编辑
,原因: