def scalar_one_elimination(self, **defaults_config): ''' Equivalence method that derives a simplification in which a single scalar multiplier of 1 is eliminated. For example, letting v denote a vector element of some VecSpace, then ScalarMult(one, v).scalar_one_elimination() would return |- ScalarMult(one, v) = v Will need to know that v is in VecSpaces(K) and that the multiplicative identity 1 is in the field K. This might require assumptions or pre-proving of a VecSpace that contains the vector appearing in the ScalarMult expression. ''' from proveit.numbers import one # from . import elim_one_left, elim_one_right from . import one_as_scalar_mult_id # The following seems silly -- if the scalar is not 1, just # return with no change instead? if self.scalar != one: raise ValueError( "For ScalarMult.scalar_one_elimination(), the scalar " "multiplier in {0} was expected to be 1 but instead " "was {1}.".format(self, self.scalar)) # obtain the instance params: # _K is the field; _V is the vector space over field _K; # and _v is the vector in _V being scaled _K, _v, _V = one_as_scalar_mult_id.all_instance_params() # isolate the vector portion _v_sub = self.scaled # Find a containing vector space V in the theorem. # This may fail! _V_sub = list(VecSpaces.yield_known_vec_spaces(_v_sub))[0] # Find a vec space field, hopefully one that contains the mult # identity 1. This may fail! _K_sub = list(VecSpaces.yield_known_fields(_V_sub))[0] # If we made it this far, can probably instantiate the theorem # (although it could still fail if 1 is not in the field _K_sub) return one_as_scalar_mult_id.instantiate({ _K: _K_sub, _v: _v_sub, _V: _V_sub })
def yield_known_hilbert_spaces(vec): ''' Given a vector expression, vec, yield any Hilbert spaces known to contain vec. ''' for vec_space in VecSpaces.yield_known_vec_spaces(vec, field=Complex): if vec_space in HilbertSpacesLiteral.known_spaces_memberships: # This vector space is already known to be an inner # product space. yield vec_space else: try: deduce_as_hilbert_space(vec_space) yield vec_space except NotImplementedError: # Not known you to prove 'vec_space' is an inner # product space. pass