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 その3

Last updated at Posted at 2019-01-25

概要

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))

結果

おかしい、すべて、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

以上。

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?