Exemple #1
0
 def compute_norm(self, field=None, **defaults_config):
     '''
     Proves ‖a ⊗ b ⊗ ... ⊗ y ⊗ z‖ = ‖a‖·‖b‖·...·‖y‖·‖z‖.
     '''
     from proveit.logic import EvaluationError
     from . import norm_of_tensor_prod, norm_preserving_tensor_prod
     _a = self.operands
     _i = _a.num_elements()
     _K = VecSpaces.get_field(field)
     vec_spaces = VecSpaces.known_vec_spaces(self.operands, field=_K)
     
     # See if all of the operand normalizations evaluate to one.
     all_norm_one = True
     try:
         for operand in self.operands:
             if isinstance(operand, ExprRange):
                 with defaults.temporary() as tmp_defaults:
                     tmp_defaults.assumptions = defaults.assumptions + (
                             operand.parameter_condition(),)
                     body_norm = operand.body.compute_norm()
                     if body_norm.rhs.evaluated() != one:
                         all_norm_one = False
                         break
             else:
                 if operand.compute_norm().rhs.evaluated() != one:
                     all_norm_one = False
                     break
     except (EvaluationError, NotImplementedError):
         all_norm_one = False
         pass
     if all_norm_one:
         thm = norm_preserving_tensor_prod
     else:
         thm = norm_of_tensor_prod
     return thm.instantiate({K: _K, i: _i, V: vec_spaces, a: _a})            
Exemple #2
0
 def deduce_in_vec_space(self, vec_space=None, *, field,
                         **defaults_config):
     '''
     Deduce that the tensor product of vectors is in a vector space
     which is the tensor product of corresponding vectors spaces.
     '''
     from . import tensor_prod_is_in_tensor_prod_space
     _a = self.operands
     _i = _a.num_elements()
     _K = VecSpaces.get_field(field)
     vec_spaces = VecSpaces.known_vec_spaces(self.operands, field=_K)
     membership = tensor_prod_is_in_tensor_prod_space.instantiate(
             {K: _K, i: _i, V: vec_spaces, a: _a})      
     if vec_space is not None and membership.domain != vec_space:
         sub_rel = SubsetEq(membership.domain, vec_space)
         return sub_rel.derive_superset_membership(self)
     return membership