"""Create reasoning_engine
Generated by Phi-Octopus Eden
2025-11-07 21:13:49.688467
"""

```python
from typing import List, Optional


class ReasoningEngine:
    """
    A simple reasoning engine that solves a limited problem of evaluating mathematical expressions.
    The engine supports addition, subtraction, multiplication, and division operations.

    Example usage:
    >>> re = ReasoningEngine()
    >>> result = re.evaluate_expression("3 + 4 * 2")
    >>> print(result)
    11
    """

    def __init__(self):
        self._operators = {
            '+': lambda x, y: x + y,
            '-': lambda x, y: x - y,
            '*': lambda x, y: x * y,
            '/': lambda x, y: x / y if y != 0 else float('inf')
        }

    def evaluate_expression(self, expression: str) -> Optional[float]:
        """
        Evaluates a mathematical expression based on the provided string.

        :param expression: A string representing a mathematical expression (e.g., "3 + 4 * 2").
        :return: The result of the evaluated expression or float('inf') if division by zero occurs.
        """
        try:
            # Splitting the input into tokens
            tokens = self.tokenize_expression(expression)
            # Evaluating the expression using stack-based approach
            return self.evaluate_stack(tokens)
        except ZeroDivisionError:
            return float('inf')

    def tokenize_expression(self, expr: str) -> List[str]:
        """
        Tokenizes a mathematical expression into a list of numbers and operators.

        :param expr: The input mathematical expression.
        :return: A list containing tokens (numbers and operators).
        """
        import re
        return [x for x in re.findall(r'\d+|\+|-|/|\*', expr)]

    def evaluate_stack(self, tokens: List[str]) -> float:
        """
        Evaluates the tokenized expression using a stack-based approach.

        :param tokens: A list of tokens (numbers and operators).
        :return: The result of evaluating the input tokens.
        """
        num_stack = []
        op_stack = []

        for token in tokens:
            if token.isdigit():
                num_stack.append(int(token))
            elif token in self._operators:
                while (op_stack and
                       op_stack[-1] != '(' and
                       self.associativity(self.get_precedence(op_stack[-1])) >=
                       self.associativity(self.get_precedence(token))):
                    num2 = num_stack.pop()
                    num1 = num_stack.pop()
                    op = op_stack.pop()
                    result = self._operators[op](num1, num2)
                    num_stack.append(result)
                op_stack.append(token)
            elif token == '(':
                op_stack.append(token)
            elif token == ')':
                while op_stack[-1] != '(':
                    num2 = num_stack.pop()
                    num1 = num_stack.pop()
                    op = op_stack.pop()
                    result = self._operators[op](num1, num2)
                    num_stack.append(result)
                op_stack.pop()  # Remove the matching '('
        while op_stack:
            num2 = num_stack.pop()
            num1 = num_stack.pop()
            op = op_stack.pop()
            result = self._operators[op](num1, num2)
            num_stack.append(result)

        return num_stack[0]

    def get_precedence(self, operator: str) -> int:
        """
        Returns the precedence of an operator.

        :param operator: A string representing the mathematical operator.
        :return: An integer indicating the precedence level (1 for addition/subtraction,
                 2 for multiplication/division).
        """
        if operator in ('+', '-'):
            return 1
        elif operator in ('*', '/'):
            return 2

    def associativity(self, precedence: int) -> str:
        """
        Determines the associativity of an operator based on its precedence.

        :param precedence: An integer representing the precedence level.
        :return: A string 'left' or 'right', indicating left-to-right or right-to-left associativity.
        """
        return 'left' if precedence == 1 else 'right'


# Example usage
if __name__ == "__main__":
    re = ReasoningEngine()
    result = re.evaluate_expression("3 + 4 * 2")
    print(result)  # Output: 11
```