0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

paizaでsympy その4

Posted at

概要

sympyが、魔法なので、paizaで、やってみた。
練習問題、やってみた。

問題

XとYの否定論理積 X NAND Y は,NOT(X AND Y)として定義される。X OR Y をNANDだけを使って表した論理式はどれか。
((X NAND Y) NAND X) NAND Y
(X NAND X) NAND (Y NAND Y)
(X NAND Y) NAND (X NAND Y)
X NAND (Y NAND (X NAND Y))

from sympy.abc import X, Y
from sympy.logic.boolalg import *
import sympy

print (sympy.simplify_logic(~(Y & ~(X & ~(X & Y)))))
print (sympy.simplify_logic(~(~(X & X) & ~(Y & Y))))
print (sympy.simplify_logic(~(~(X & Y) & ~(X & Y))))
print (sympy.simplify_logic(~(X & ~(Y & ~(X & Y)))))

結果

~Y
X | Y
X & Y
~X

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?