from quex.engine.state_machine.core import DFA
from quex.engine.state_machine.algebra.TESTS.helper import test2, union, \
                                                           intersection, \
                                                           identity, \
                                                           complement, \
                                                           add_more_DFAs

if "--hwut-info" in sys.argv:
    print "Complement: DeMorgan's Law;"
    print "HAPPY: [0-9]+;"
    sys.exit()

count = 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


test2(de_morgan)

print "<terminated: %i>" % count
Exemple #2
0
import os
import sys
sys.path.insert(0, os.environ["QUEX_PATH"])
from quex.engine.state_machine.core import DFA
from quex.engine.state_machine.algebra.TESTS.helper import test2, union, \
                                                           intersection, \
                                                           identity, \
                                                           difference, \
                                                           add_more_DFAs

if "--hwut-info" in sys.argv:
    print "Intersection by Difference;"
    print "HAPPY: [0-9]+;"
    sys.exit()

count = 0


def intersection_by_difference(A, B):
    global count

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

    count += 1


test2(intersection_by_difference)

print "<terminated: %i>" % count
Exemple #3
0
import sys
sys.path.insert(0, os.environ["QUEX_PATH"])
from quex.engine.state_machine.core                 import DFA
from quex.engine.state_machine.algebra.TESTS.helper import test2, union, \
                                                           intersection, \
                                                           identity, \
                                                           add_more_DFAs

if "--hwut-info" in sys.argv:
    print "Commutativity;"
    print "HAPPY: [0-9]+;"
    sys.exit()

count = 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

test2(commutativity)

print "<terminated: %i>" % count
Exemple #4
0
                                                           intersection, \
                                                           complement, \
                                                           identity, \
                                                           superset, \
                                                           sample_DFAs
import sys

if "--hwut-info" in sys.argv:
    print "Existence: Joins and Meets;"
    print "HAPPY: [0-9]+;"
    sys.exit()

count = 0


def join_and_meets(A, B):
    global count
    Join = union([A.clone(), B.clone()])
    assert superset(Join.clone(), A.clone())
    assert superset(Join.clone(), B.clone())

    Meet = intersection([A.clone(), B.clone()])
    assert superset(A.clone(), Meet.clone())
    assert superset(B.clone(), Meet.clone())
    count += 1


test2(join_and_meets)

print "<terminated: %i>" % count
Exemple #5
0
import os
import sys
sys.path.insert(0, os.environ["QUEX_PATH"])
from quex.engine.state_machine.core                 import DFA
from quex.engine.state_machine.algebra.TESTS.helper import test2, union, \
                                                           intersection, \
                                                           identity, \
                                                           add_more_DFAs

if "--hwut-info" in sys.argv:
    print "Absorbtion;"
    print "HAPPY: [0-9]+;"
    sys.exit()

count = 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

test2(absorbtion)

print "<terminated: %i>" % count