"""Create reasoning_engine
Generated by Phi-Octopus Eden
2025-11-08 20:50:52.615801
"""

```python
class ReasoningEngine:
    """
    A basic reasoning engine that solves problems based on a predefined set of rules.
    """

    def __init__(self, knowledge_base: dict):
        """
        Initialize the reasoning engine with a knowledge base.

        :param knowledge_base: A dictionary containing facts and rules for reasoning.
        """
        self.knowledge_base = knowledge_base

    def infer(self, query: str) -> bool:
        """
        Infer if a given statement is true based on the knowledge base.

        :param query: The statement to be inferred as a string.
        :return: True if the statement can be logically inferred; False otherwise.
        """
        for key, value in self.knowledge_base.items():
            if key.lower() in query.lower():
                return value
        return False

    def learn(self, fact: str, truth_value: bool):
        """
        Add a new fact to the knowledge base.

        :param fact: The new fact as a string.
        :param truth_value: The truth value of the new fact (True or False).
        """
        self.knowledge_base[fact] = truth_value

# Example usage
knowledge_base = {
    "cat is an animal": True,
    "dog can bark": True,
}

reasoning_engine = ReasoningEngine(knowledge_base)

print(reasoning_engine.infer("Is a cat an animal?"))  # Output: True

new_fact = "fish live in water"
truth_value = True
reasoning_engine.learn(new_fact, truth_value)
print(reasoning_engine.infer("Does a fish live in water?"))  # Output: True
```