Пример #1
0
def absorbtion(A, B):
    global count
    assert identity(union([A, intersection([A.clone(), B.clone()])]), A.clone())
    assert identity(intersection([A, union([A.clone(), B.clone()])]), A.clone())


    count += 1
Пример #2
0
def domination(A):
    global count
    first  = union([A, DFA.Universal()])
    assert identity(first, DFA.Universal())

    first  = intersection([A, DFA.Empty()]) 
    assert identity(first, DFA.Empty())

    count += 1
Пример #3
0
def complement_laws(A):
    global count
    first = union([A.clone(), complement(A.clone())])
    assert identity(first, DFA.Universal())

    first = intersection([A.clone(), complement(A.clone())])
    assert identity(first, DFA.Empty())

    count += 1
Пример #4
0
def identity_vs_empty_and_universal(A):
    global count
    count += 1
    # if count != 3: return
    first = union([A.clone(), DFA.Empty()])
    assert identity(first, A.clone())

    first = intersection([A.clone(), DFA.Universal()])
    assert identity(first, A)
Пример #5
0
def de_morgan(A, B):
    global count
    assert identity(
        complement(union([A.clone(), B.clone()])),
        intersection([complement(A.clone()),
                      complement(B.clone())]))
    assert identity(complement(intersection([A.clone(), B.clone()])),
                    union([complement(A.clone()),
                           complement(B.clone())]))
    count += 1
Пример #6
0
def distributivity(A, B, C):
    global count
    first  = union([A.clone(), intersection([B.clone(), C.clone()])])
    second = intersection([union([A.clone(), B.clone()]), union([A.clone(),C.clone()])])
    assert identity(first, second)

    first  = intersection([A.clone(), union([B.clone(), C.clone()])])
    second = union([intersection([A.clone(), B.clone()]), intersection([A.clone(),C.clone()])])
    assert identity(first, second)

    count += 1
Пример #7
0
def commutativity(A, B):
    global count
    first  = union([A.clone(), B.clone()])
    second = union([B.clone(), A.clone()])
    assert identity(first, second)

    first  = intersection([A.clone(), B.clone()]) 
    second = intersection([B.clone(), A.clone()]) 
    assert identity(first, second)

    count += 1
Пример #8
0
def uniqueness(A):
    """Uniqueness of complement:
        
              A u B = Universal   and    A n B = Empty

           => A = complement B  and vice versa

       Involution:
            
              A = complement(complement(A))
    """
    global count

    B = difference(DFA.Universal(), A)
    # => A u B = Universal   and    A n B = Empty
    assert identity(union([A, B]), DFA.Universal())
    assert identity(intersection([A, B]), DFA.Empty())

    # Uniqueness of complement
    assert identity(A, complement(B))
    assert identity(B, complement(A))

    # Involution/Double Complement
    assert identity(A, complement(complement(A)))
    assert identity(B, complement(complement(B)))
    count += 1
Пример #9
0
def intersection_by_difference(A, B):
    global count

    assert identity(intersection([A, B]), difference(A, difference(A, B)))

    count += 1