# Poly Commute Like Terms

```
import mathy_envs.envs.poly_commute_like_terms
```

## PolyCommuteLikeTerms¶

```
PolyCommuteLikeTerms(self, ops: Optional[List[str]] = None, kwargs: Any)
```

This task is intended to test the model's ability to identify like terms in a large string of unlike terms and its ability to use the commutative swap rule to reorder the expression bringing the like terms close together.

### max_moves_fn¶

```
PolyCommuteLikeTerms.max_moves_fn(
self,
problem: mathy_envs.types.MathyEnvProblem,
config: mathy_envs.types.MathyEnvProblemArgs,
) -> int
```

### rule¶

Distributive Property `ab + ac = a(b + c)`

The distributive property can be used to expand out expressions to allow for simplification, as well as to factor out common properties of terms.

**Factor out a common term**

This handles the `ab + ac`

conversion of the distributive property, which factors out a common term from the given two addition operands.

```
+ *
/ \ / \
/ \ / \
/ \ -> / \
* * a +
/ \ / \ / \
a b a c b c
```

### transition_fn¶

```
PolyCommuteLikeTerms.transition_fn(
self,
env_state: mathy_envs.state.MathyEnvState,
expression: mathy_core.expressions.MathExpression,
features: mathy_envs.state.MathyObservation,
) -> Optional[mathy_envs.time_step.TimeStep]
```