2017年9月21日木曜日

学習環境

集合・位相入門 (松坂 和夫(著)、岩波書店)の第1章(集合と写像)、2(集合間の演算)、練習問題4を取り組んでみる。


    1. A( BC ) =A ( BC ) c =A( B c C c ) =A B c C c ( AB )( AC ) =( A B c )( A C c ) =A B c A C c =A B c C c

    2. A( BC ) =A ( BC ) c =A( B c C c ) =( A B c )( A C c ) ( AB )( AC ) =( A B c )( A C c )

    3. ( AB )C =( AB ) C c =( A C c )( B C c ) =( AC )( BC )

    4. ( AB )C =( AB ) C c =AB C c ( AC )( BC ) =( A C c )( B C c ) =A C c B C c =AB C c

    5. A( BC ) =A( B C c ) =AB C c ( AB )( AC ) =( AB ) ( AC ) c =( AB )( A c C c ) =( ( AB ) A c )( ( AB ) C c ) =( AB A c )( AB C c ) =ϕ( AB C c ) =AB C c

コード(Emacs)

Python 3

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from matplotlib_venn import venn3_unweighted
import matplotlib.pyplot as plt

from sympy import pprint, FiniteSet, Interval

print('4.')

X = FiniteSet(*range(7))
A = FiniteSet(*range(5))
B = FiniteSet(*range(1, 6))
C = FiniteSet(*range(2, 7))
for X0 in [X, A, B, C]:
    pprint(X0)

XS = [(A - (B | C), (A - B) & (A - C)),
      (A - (B & C), (A - B) | (A - C)),
      ((A | B) - C, (A - C) | (B - C)),
      ((A & B) - C, (A - C) & (B - C)),
      (A & (B - C), (A & B) - (A & C))]

for i, (L, R) in enumerate(XS):
    print(f'({chr(ord("a") + i)})')
    for X in [L, R]:
        pprint(X)
    print(L == R)
    print()

venn3_unweighted(subsets=(A, B, C))
plt.savefig('sample4.svg')

入出力結果(Terminal, Jupyter(IPython))

$ ./sample4.py
4.
{0, 1, 2, 3, 4, 5, 6}
{0, 1, 2, 3, 4}
{1, 2, 3, 4, 5}
{2, 3, 4, 5, 6}
(a)
{0}
{0}
True

(b)
{0, 1}
{0, 1}
True

(c)
{0, 1}
{0, 1}
True

(d)
{1}
{1}
True

(e)
{1}
{1}
True

$

0 コメント:

コメントを投稿