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

```python
from typing import List, Dict


class ReasoningEngine:
    """
    A basic reasoning engine designed to solve problems with limited reasoning sophistication.
    """

    def __init__(self):
        self.knowledge_base = {}

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

        :param fact: The fact to be added as a string
        """
        if fact not in self.knowledge_base:
            self.knowledge_base[fact] = []

    def add_rule(self, rule: Dict[str, List[str]]) -> None:
        """
        Add a rule to the reasoning engine. A rule is represented by a dictionary where keys are facts and values are
        lists of facts that follow from those key facts.

        :param rule: The rule in the form of {key_fact: [followed_facts]}
        """
        for key, value in rule.items():
            if key not in self.knowledge_base:
                self.knowledge_base[key] = []
            for fact in value:
                if fact not in self.knowledge_base:
                    self.knowledge_base[fact] = []

    def infer(self, query: str) -> bool:
        """
        Attempt to infer the truth of a query based on the knowledge base and existing rules.

        :param query: The query to be inferred as a string
        :return: True if the query is inferred to be true, False otherwise
        """
        stack = [query]
        checked = set()
        
        while stack:
            current_fact = stack.pop()
            
            if current_fact in self.knowledge_base and current_fact not in checked:
                checked.add(current_fact)
                followed_facts = self.knowledge_base[current_fact]
                for fact in followed_facts:
                    if fact not in checked:
                        stack.append(fact)

        return query in checked


# Example usage
if __name__ == "__main__":
    reasoning_engine = ReasoningEngine()

    # Adding facts and rules to the engine
    reasoning_engine.add_fact("All humans are mortal")
    reasoning_engine.add_fact("Socrates is a human")
    reasoning_engine.add_rule({"All humans are mortal": ["Socrates is mortal"]})

    # Querying the engine
    query = "Socrates is mortal"
    result = reasoning_engine.infer(query)
    print(f"Is {query}? {'Yes' if result else 'No'}")

```

This example creates a simple reasoning engine capable of making inferences based on given facts and rules. It demonstrates adding basic facts and rules, and then inferring the truth value of a query.