"""Create reasoning_engine
Generated by Phi-Octopus Eden
2025-11-07 13:35:48.421700
"""

```python
from typing import List, Dict


class ReasoningEngine:
    """
    A simple reasoning engine designed to handle limited reasoning tasks.
    It supports evaluating logical expressions based on a predefined set of rules.

    Attributes:
        rules (List[str]): The list of rules used for reasoning.
    """

    def __init__(self, rules: List[str]):
        self.rules = rules

    def evaluate_expression(self, expression: str) -> bool:
        """
        Evaluates the logical expression based on the defined rules.

        Args:
            expression (str): A string representing a logical expression,
                              e.g., "A and B or not C".

        Returns:
            bool: True if the expression evaluates to true, False otherwise.
        """
        from sympy import And, Or, Not, symbols

        # Define symbolic variables
        vars = [symbol for symbol in expression.split() if symbol.isalpha()]
        for var in vars:
            locals()[var] = symbols(var)

        # Construct and evaluate the logical expression
        for rule in self.rules:
            exec(rule)
        
        try:
            result = eval(expression, {**locals(), **globals()})
            return result
        except NameError as e:
            print(f"Invalid variable: {e}")
            return False

    def add_rule(self, new_rule: str) -> None:
        """
        Adds a new rule to the reasoning engine.

        Args:
            new_rule (str): A string representing a logical rule,
                            e.g., "A and B implies C".
        """
        self.rules.append(new_rule)


# Example usage
if __name__ == "__main__":
    # Define some rules
    rules = [
        "A and not B -> C",
        "not A or B -> D"
    ]

    engine = ReasoningEngine(rules)

    # Test the evaluation of expressions
    print(engine.evaluate_expression("A and B"))  # Should return False
    print(engine.evaluate_expression("C"))       # Should return False initially

    # Add a new rule
    engine.add_rule("A or not C -> D")

    print(engine.evaluate_expression("D"))       # Now should return True
```