def __init__(self, operator, lhs, rhs): TransitiveRelation.__init__(self, operator, lhs, rhs) # The lower bound side of this inequality. # (regardless of the 'direction' style). self.lower = self.operands[0] # The upper bound side of this inequality. self.upper = self.operands[1]
def apply_transitivity(self, other, assumptions=USE_DEFAULTS): ''' apply_transitivity(Subset(A,B), SetEquiv(B,C)) returns Subset(A,C) ''' from proveit.logic import Equals, SetEquiv, SubsetEq if isinstance(other, Equals): return TransitiveRelation.apply_transitivity( self, other, assumptions) if isinstance(other, SetEquiv): # From set equivalence, derive the appropriate subset_eq # so we can use normal subset transitivity. if other.lhs == self.superset or other.rhs == self.subset: # EITHER (A subset B) and (B set_equiv C) # OR (A subset B) and (C set_equiv A) other_as_subset_eq = SubsetEq(*other.operands.entries) elif other.rhs == self.superset or other.lhs == self.subset: # EITHER (A subset B) and (C set_equiv B) # OR (A subset B) and (A set_equiv C) other_as_subset_eq = SubsetEq( *reversed(other.operands.entries)) else: raise ValueError("Unable to apply transitivity between %s " "and %s." % (self, other)) return self.apply_transitivity(other_as_subset_eq, assumptions)
def side_effects(self, judgment): ''' In addition to the TransitiveRelation side-effects, also attempt derive_relaxed (if applicable) and derive_reversed. ''' for side_effect in TransitiveRelation.side_effects(self, judgment): yield side_effect if hasattr(self, 'derive_relaxed'): yield self.derive_relaxed
def sideEffects(self, knownTruth): ''' In addition to the TransitiveRelation side-effects, also attempt deriveRelaxed (if applicable) and deriveReversed. ''' for sideEffect in TransitiveRelation.sideEffects(self, knownTruth): yield sideEffect if hasattr(self, 'deriveRelaxed'): yield self.deriveRelaxed yield self.deriveReversed
def side_effects(self, judgment): ''' In addition to the TransitiveRelation side-effects, also attempt derive_negated, derive_relaxed (if applicable), and derive_reversed. ''' for side_effect in TransitiveRelation.side_effects(self, judgment): yield side_effect # yield self.derive_negated # Needs to be implemented (again) if hasattr(self, 'derive_relaxed'): yield self.derive_relaxed
def __init__(self, operator, lhs, rhs): TransitiveRelation.__init__(self, operator, lhs, rhs)
def __init__(self, operator, lhs, rhs, *, styles): TransitiveRelation.__init__(self, operator, lhs, rhs, styles=styles) self.subset = self.operands[0] self.superset = self.operands[1]