# Path: systemVariables.py
# def     fuzzyEquals(A, B):
#     """
#     true if A = B to within the current comparison tolerance
#     """
#     return operator.le(math.fabs(operator.sub(A, B)),
#                        operator.mul(_CT.python(), max(math.fabs(A), math.fabs(B))))
# 
# def     fuzzyInteger(B):
#     """
#     B but, if B is within comparison toleranace of an integer, the integer
#     """
#     if isinstance(B, int):
#         return B
# 
#     if B > 0:
#         I = int(B+0.5)
#     elif B < 0:
#         I = int(B-0.5)
#     else:
#         I = 0
# 
#     if fuzzyEquals(I, B):
#         return I
# 
#     return B
# 
# def     confirmBoolean(B):
#     """
#     the Boolean-domain value of B (if within comparison tolerance - else throw DOMAIN ERROR)
#     """
#     try:
#         B = fuzzyInteger(B)
# 
#         if B == 0:
#             return 0
#         if B == 1:
#             return 1
#     except TypeError:
#         pass
# 
#     assertError("DOMAIN ERROR")
# 
# def     confirmInteger(B):
#     """
#     the integer-domain value of B (if within comparison tolerance - else throw DOMAIN ERROR)
#     """
#     try:
#         B = fuzzyInteger(B)
# 
#         if isinstance(B, int):
#             return B
#     except TypeError:
#         pass
# 
#     assertError("DOMAIN ERROR")
# 
# Path: aplError.py
# class   aplException(Exception):
#     """
#     A simple APL Exception Class
#     """
#     def __init__(self, message, expr=None):
#         Exception.__init__(self)
#         self.message = message
#         self.expr = expr
# 
# def     assertError(message):
#     """
#     raise an exception so aborting the current operation
#     """
#     raise aplException(message)


import operator
import math
import random
import mpmath
from systemVariables import fuzzyEquals, fuzzyInteger, confirmBoolean, confirmInteger
from aplError import aplException, assertError
def     _highestCommonFactor(A, B):
    """
    Highest Common Factor by the Euclid method

    Note: math.gcd() is Python 3.5 and later
    """
    if B == 0:
        return abs(A)

    return _highestCommonFactor(B, A % B)

# --------------

def     orGCD(A, B):
    """
    A ∨ B
    """
    try:
        return int(confirmBoolean(A) + confirmBoolean(B) != 0)
    except aplException:
        return _highestCommonFactor(A, B)

# --------------

def     andLCM(A, B):
    """
    A ∧ B
    """
    try:
        return int(confirmBoolean(A) + confirmBoolean(B) == 2)

# Path: systemVariables.py
# def     fuzzyEquals(A, B):
#     """
#     true if A = B to within the current comparison tolerance
#     """
#     return operator.le(math.fabs(operator.sub(A, B)),
#                        operator.mul(_CT.python(), max(math.fabs(A), math.fabs(B))))
# 
# def     fuzzyInteger(B):
#     """
#     B but, if B is within comparison toleranace of an integer, the integer
#     """
#     if isinstance(B, int):
#         return B
# 
#     if B > 0:
#         I = int(B+0.5)
#     elif B < 0:
#         I = int(B-0.5)
#     else:
#         I = 0
# 
#     if fuzzyEquals(I, B):
#         return I
# 
#     return B
# 
# def     confirmBoolean(B):
#     """
#     the Boolean-domain value of B (if within comparison tolerance - else throw DOMAIN ERROR)
#     """
#     try:
#         B = fuzzyInteger(B)
# 
#         if B == 0:
#             return 0
#         if B == 1:
#             return 1
#     except TypeError:
#         pass
# 
#     assertError("DOMAIN ERROR")
# 
# def     confirmInteger(B):
#     """
#     the integer-domain value of B (if within comparison tolerance - else throw DOMAIN ERROR)
#     """
#     try:
#         B = fuzzyInteger(B)
# 
#         if isinstance(B, int):
#             return B
#     except TypeError:
#         pass
# 
#     assertError("DOMAIN ERROR")
# 
# Path: aplError.py
# class   aplException(Exception):
#     """
#     A simple APL Exception Class
#     """
#     def __init__(self, message, expr=None):
#         Exception.__init__(self)
#         self.message = message
#         self.expr = expr
# 
# def     assertError(message):
#     """
#     raise an exception so aborting the current operation
#     """
#     raise aplException(message)


# Path: dyadicFunctions.py
import operator
import math
import random
import mpmath
from systemVariables import fuzzyEquals, fuzzyInteger, confirmBoolean, confirmInteger
from aplError import aplException, assertError

def     _highestCommonFactor(A, B):
    """
    Highest Common Factor by the Euclid method

    Note: math.gcd() is Python 3.5 and later
    """
    if B == 0:
        return abs(A)

    return _highestCommonFactor(B, A % B)

# --------------

def     orGCD(A, B):
    """
    A ∨ B
    """
    try:
        return int(confirmBoolean(A) + confirmBoolean(B) != 0)
    except aplException:
        return _highestCommonFactor(A, B)

# --------------

def     andLCM(A, B):
    """
    A ∧ B
    """
    try:
        return int(confirmBoolean(A) + confirmBoolean(B) == 2)

    except aplException: