Ejemplo n.º 1
0
    def conclude(self, assumptions):
        from proveit.logic import InSet, NotEquals
        from proveit.numbers import (Rational, RationalNonZero, RationalPos,
                                     RationalNeg, RationalNonNeg, Less,
                                     greater, greater_eq, zero)

        # If we known the element is in Q, we may be able to
        # prove that is in RationalNonZero, RationalPos, RationalNeg, or
        # RationalNonNeg if we know its relation to zero.
        if (self.number_set != Rational
                and InSet(self.element, Rational).proven(assumptions)):
            if self.number_set == RationalNonZero:
                if NotEquals(self.element, zero).proven(assumptions):
                    from . import non_zero_rational_is_rational_non_zero
                    return non_zero_rational_is_rational_non_zero.instantiate(
                        {q: self.element}, assumptions=assumptions)
            if self.number_set == RationalPos:
                if greater(self.element, zero).proven(assumptions):
                    from . import positive_rational_is_rational_pos
                    return positive_rational_is_rational_pos.instantiate(
                        {q: self.element}, assumptions=assumptions)
            if self.number_set == RationalNeg:
                if Less(self.element, zero).proven():
                    from . import negative_rational_is_rational_neg
                    return negative_rational_is_rational_neg.instantiate(
                        {q: self.element}, assumptions=assumptions)
            if self.number_set == RationalNonNeg:
                if greater_eq(self.element, zero).proven():
                    from . import non_neg_rational_in_rational_neg
                    return non_neg_rational_in_rational_neg.instantiate(
                        {q: self.element}, assumptions=assumptions)

        # Resort to the default NumberMembership.conclude strategies.
        return NumberMembership.conclude(self, assumptions)
Ejemplo n.º 2
0
 def conclude(self, **defaults_config):
     from proveit.logic import NotEquals, InSet
     from proveit.numbers import zero
     if (InSet(self.element, Complex).proven()
             and NotEquals(self.element, zero).proven()):
         return self.conclude_as_last_resort()
     return NumberMembership.conclude(self)
Ejemplo n.º 3
0
 def conclude(self, **defaults_config):
     from proveit import ProofFailure
     from . import n_in_digits
     # if we know the element is 0-9, then we can show it is a digit
     try:
         return NumberMembership.conclude(self)
     except ProofFailure:
         return n_in_digits.instantiate({n: self.element})
Ejemplo n.º 4
0
 def conclude(self, assumptions=USE_DEFAULTS):
     from proveit import ProofFailure
     from . import n_in_digits
     # if we know the element is 0-9, then we can show it is a digit
     try:
         return NumberMembership.conclude(self, assumptions=assumptions)
     except ProofFailure:
         return n_in_digits.instantiate({n: self.element},
                                        assumptions=assumptions)
Ejemplo n.º 5
0
 def conclude(self, **defaults_config):
     if (InSet(self.element, Integer).proven()
             and NotEquals(self.element, zero).proven()):
         return self.conclude_as_last_resort()
     return NumberMembership.conclude(self)
Ejemplo n.º 6
0
 def __init__(self, element):
     NumberMembership.__init__(self, element, IntegerNonZero)
Ejemplo n.º 7
0
 def __init__(self, element, number_set):
     NumberMembership.__init__(self, element, number_set)
Ejemplo n.º 8
0
 def __init__(self, element):
     NumberMembership.__init__(self, element, RealNonZero)
Ejemplo n.º 9
0
 def conclude(self, **defaults_config):
     from proveit.numbers import zero, LessEq
     if (InSet(self.element, Real).proven() and
             LessEq(self.element, zero).proven()):
         return self.conclude_as_last_resort()
     return NumberMembership.conclude(self)
Ejemplo n.º 10
0
 def __init__(self, element):
     NumberMembership.__init__(self, element, RealPos)
Ejemplo n.º 11
0
 def __init__(self, element, domain):
     NumberMembership.__init__(self, element, domain)
     self.domain = domain
Ejemplo n.º 12
0
 def conclude(self, **defaults_config):
     from proveit.numbers import Rational, zero
     if (InSet(self.element, Rational).proven() and
             NotEquals(self.element, zero).proven()):
         return self.conclude_as_last_resort()
     return NumberMembership.conclude(self)
Ejemplo n.º 13
0
 def __init__(self, element):
     NumberMembership.__init__(self, element, ComplexNonZero)