paizaでsympy その3
概要
sympyが、魔法なので、paizaで、やってみた。
練習問題、やってみた。
問題
~((AUB)n(~AU~B)) と等価な集合はどれか。ここで,Uは和集合,nは積集合,~xはxの補集合を表す。
(~AUB)∩(AU~B)
(~AU~B)∩(AUB)
(~A∩B)U(A∩~B)
(~A∩~B)∩(AUB)
from sympy.abc import A, B
from sympy.logic.boolalg import *
import sympy
print (~((A | B) & (~A | ~B)) == (~A | B) & (A | ~B))
print (~((A | B) & (~A | ~B)) == (~A | ~B) & (A | B))
print (~((A | B) & (~A | ~B)) == (~A & B) | (A & ~B))
print (~((A | B) & (~A | ~B)) == (~A & ~B) & (A | B))
結果
from sympy.abc import A, B
from sympy.logic.boolalg import *
import sympy
print (~((A | B) & (~A | ~B)) == (~A | B) & (A | ~B))
print (~((A | B) & (~A | ~B)) == (~A | ~B) & (A | B))
print (~((A | B) & (~A | ~B)) == (~A & B) | (A & ~B))
print (~((A | B) & (~A | ~B)) == (~A & ~B) & (A | B))
おかしい、すべて、FALSE
False
False
False
False
simplify_logicを使う。
from sympy.abc import A, B
from sympy.logic.boolalg import *
import sympy
print (sympy.simplify_logic(Equivalent(Not(And(Or(A, B), Or(~A, ~B))) == (~A | B) & (A | ~B))))
print (sympy.simplify_logic(Equivalent(~((A | B) & (~A | ~B)) == (~A | B) & (A | ~B))))
結果
True
True
from sympy.abc import A, B
from sympy.logic.boolalg import *
import sympy
print (sympy.simplify_logic(Equivalent(Not(And(Or(A, B), Or(~A, ~B))) == (~A | B) & (A | ~B))))
print (sympy.simplify_logic(Equivalent(~((A | B) & (~A | ~B)) == (~A | B) & (A | ~B))))
True
True
以上。
Author And Source
この問題について(paizaでsympy その3), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/bcaf45c4a445296f9668著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .