Esempio n. 1
0
    def association(self, start_idx, length, *, field=None, 
                    **defaults_config):
        '''
        Given vector operands, or all CartExp operands, deduce that
        this expression is equal to a form in which operands in the
        range [start_idx, start_idx+length) are grouped together.
        For example, calling
        (a ⊗ b ⊗ ... ⊗ y ⊗ z).association(l, m-l+1)
        would return
        |- (a ⊗ b ⊗ ... ⊗ y ⊗ z) = 
            (a ⊗ b ... ⊗ (l ⊗ ... ⊗ m) ⊗ ... ⊗ y ⊗ z)
        Or calling (R3 ⊗ R3 ⊗ R3).associate(1, 2) would return
        |- (R3 ⊗ R3 ⊗ R3) = (R3 ⊗ (R3 ⊗ R3))
        
        For this to work in the vectors case, the vector operands must
        be known to be in vector spaces of a common field.  If the
        field is not specified, then VecSpaces.default_field is used.
        For this to work in the case of CartExp operands, all operands
        must be (recursively) CartExps and each must be known to be
        a vector space.
        '''
        # ORIGINAL BELOW before augmenting for CartExp cases
        # from . import tensor_prod_association
        # _V = VecSpaces.known_vec_space(self, field=field)
        # _K = VecSpaces.known_field(_V)
        # eq = apply_association_thm(
        #     self, start_idx, length, tensor_prod_association,
        #     repl_map_extras={K:_K, V:_V}).derive_consequent()
        # return eq.with_wrapping_at()

        if not TensorProd.all_ops_are_cart_exp(self):
            from . import tensor_prod_association
            _V = VecSpaces.known_vec_space(self, field=field)
            _K = VecSpaces.known_field(_V)
            eq = apply_association_thm(
                self, start_idx, length, tensor_prod_association,
                repl_map_extras={K:_K, V:_V}).derive_consequent()
            return eq.with_wrapping_at()
        else:
            from . import tensor_prod_vec_space_association
            if field is None:
                _K = VecSpaces.known_field(self.operands[0])
            else:
                _K = field
            eq = apply_association_thm(
                self, start_idx, length, tensor_prod_vec_space_association,
                repl_map_extras={K:_K})
            return eq.with_wrapping_at()
Esempio n. 2
0
 def association(self, startIdx, length, assumptions=USE_DEFAULTS):
     '''
     Given Boolean operands, deduce that this expression is equal to a form in which operands in the
     range [startIdx, startIdx+length) are grouped together.
     For example, (A and B and ... and Y and Z) = (A and B ... and (L and ... and M) and ... and Y and Z)
     '''
     from ._theorems_ import association
     return apply_association_thm(self, startIdx, length, association, assumptions)
Esempio n. 3
0
 def association(self, startIdx, length, assumptions=USE_DEFAULTS):
     '''
     Given numerical operands, deduce that this expression is equal to a form in which operands in the
     range [startIdx, startIdx+length) are grouped together.
     For example, (a + b + ... + y + z) = (a + b ... + (l + ... + m) + ... + y + z)
     '''
     from ._theorems_ import association
     return apply_association_thm(self, startIdx, length, association, assumptions)
Esempio n. 4
0
 def association(self, start_idx, length, **defaults_config):
     '''
     Given Boolean operands, deduce that this expression is equal to a form in which operands in the
     range [start_idx, start_idx+length) are grouped together.
     For example, (A or B or ... or Y or Z) = (A or B ... or (L or ... or M) or ... or Y or Z)
     '''
     from . import association
     return apply_association_thm(self, start_idx, length, association)
Esempio n. 5
0
 def associate(self, startIdx, length, assumptions=USE_DEFAULTS):
     '''
     From self, derive and return a form in which operands in the
     range [startIdx, startIdx+length) are grouped together.
     For example, from (A and B and ... and Y and Z) derive
     (A and B ... and (L and ... and M) and ... and Y and Z).
     '''
     from ._theorems_ import associate
     return apply_association_thm(self, startIdx, length, associate, assumptions)
Esempio n. 6
0
 def associate(self, start_idx, length, **defaults_config):
     '''
     From self, derive and return a form in which operands in the
     range [start_idx, start_idx+length) are grouped together.
     For example, from (A or B or ... or Y or Z) derive
     (A or B ... or (L or ... or M) or ... or Y or Z).
     '''
     from . import associate
     return apply_association_thm(self, start_idx, length, associate)
Esempio n. 7
0
 def associate(self, start_idx, length, **defaults_config):
     '''
     From self, derive and return a form in which operands in the
     range [start_idx, start_idx+length) are grouped together.
     For example, from (A and B and ... and Y and Z) derive
     (A and B ... and (L and ... and M) and ... and Y and Z).
     '''
     from . import associate
     return apply_association_thm(self, start_idx, length, associate)
Esempio n. 8
0
 def association(self, start_idx, length, **defaults_config):
     '''
     Given a valid Qmult operation (valid sequence of bras, kets,
     and/or quantum operations), deduce that this expression is equal 
     to a form in which operands in the
     range [start_idx, start_idx+length) are grouped together.
     For example, (A B ... Y Z) = (A B ... (L ... M) ... Y Z).
     '''
     from . import qmult_association
     eq = apply_association_thm(self, start_idx, length, qmult_association)
     return eq.with_wrapping_at()