"""Create reasoning_engine
Generated by Phi-Octopus Eden
2025-11-07 09:06:58.821138
"""

```python
from typing import List, Dict


class KnowledgeBase:
    def __init__(self):
        self.knowledge = {}

    def add_fact(self, fact: str) -> None:
        """
        Adds a new fact to the knowledge base.
        
        :param fact: A string representing the new fact.
        """
        if fact not in self.knowledge:
            self.knowledge[fact] = []

    def retrieve_facts(self, query: str) -> List[str]:
        """
        Retrieves facts that match the given query from the knowledge base.

        :param query: The query to search for in the knowledge base.
        :return: A list of matching facts.
        """
        return [fact for fact in self.knowledge.keys() if query.lower() in fact.lower()]

    def get_all_facts(self) -> Dict[str, List]:
        """
        Returns all facts stored in the knowledge base.

        :return: A dictionary containing all facts and their associated statements.
        """
        return self.knowledge


class ReasoningEngine:
    def __init__(self):
        self.kb = KnowledgeBase()

    def add_fact(self, fact: str) -> None:
        """Adds a new fact to the knowledge base."""
        self.kb.add_fact(fact)

    def retrieve_facts(self, query: str) -> List[str]:
        """
        Searches for and retrieves facts that match the given query.
        
        :param query: The query string used to search the knowledge base.
        :return: A list of matching facts from the knowledge base.
        """
        return self.kb.retrieve_facts(query)

    def reason(self, statement: str) -> str:
        """
        Attempts to deduce a new fact based on existing facts and provided statements.

        :param statement: The input statement used for reasoning.
        :return: A string representing the inferred or related fact.
        """
        matching_facts = self.retrieve_facts(statement)
        if len(matching_facts) > 0:
            return f"Related facts: {', '.join(matching_facts)}"
        else:
            return "No relevant facts found."

    def update_kb(self, new_fact: str) -> None:
        """Updates the knowledge base with a newly inferred fact."""
        self.kb.add_fact(new_fact)
        print(f"Inferred and added to KB: {new_fact}")


# Example usage
engine = ReasoningEngine()
engine.add_fact("All dogs are mammals")
engine.add_fact("Dogs have four legs")

query1 = "dogs"
print(engine.retrieve_facts(query1))  # Retrieve facts about dogs

statement1 = "mammals"
print(engine.reason(statement1))      # Deduce related facts based on the statement

new_fact = "All cats are also mammals"
engine.update_kb(new_fact)
```