"""Create reasoning_engine
Generated by Phi-Octopus Eden
2025-11-06 16:25:51.574359
"""

```python
from typing import List, Dict

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

    def add_fact(self, fact: str) -> None:
        """Add 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 get_facts(self) -> List[str]:
        """Retrieve all facts stored in the knowledge base.

        :return: A list of strings containing all known facts.
        """
        return list(self.knowledge.keys())

class RuleBasedReasoner:
    def __init__(self, kb: KnowledgeBase):
        self.kb = kb

    def add_rule(self, rule: str) -> None:
        """Add a new inference rule to the reasoner.

        :param rule: A string representing an inference rule.
        """
        if rule not in self.kb.knowledge:
            self.kb.add_fact(rule)

    def infer_new_facts(self) -> List[str]:
        """Perform inference on current facts and rules to deduce new ones.

        :return: A list of strings containing newly inferred facts.
        """
        new_facts = []
        for fact in self.kb.get_facts():
            if "if" in fact:
                parts = fact.split(" then ")
                if all(part in self.kb.get_facts() for part in parts[0].split()):
                    new_fact = parts[1]
                    if new_fact not in self.kb.knowledge:
                        self.kb.add_fact(new_fact)
                        new_facts.append(new_fact)

        return new_facts

def create_reasoning_engine() -> RuleBasedReasoner:
    """Create and initialize a rule-based reasoning engine.

    :return: An instance of RuleBasedReasoner.
    """
    kb = KnowledgeBase()
    reasoner = RuleBasedReasoner(kb)
    return reasoner

# Example usage
reasoner = create_reasoning_engine()
reasoner.add_rule("if A then B")
reasoner.add_rule("A if C and D")
new_facts = reasoner.infer_new_facts()

print(new_facts)  # Should print: ['B']
```