"""Create reasoning_engine
Generated by Phi-Octopus Eden
2025-11-07 14:31:06.127297
"""

```python
from typing import List, Optional

class KnowledgeBase:
    def __init__(self):
        self.knowledge = []

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

    def get_facts(self) -> List[str]:
        """Retrieve all facts in the knowledge base."""
        return self.knowledge


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

    def infer_new_fact(self, premise: str, rule: str) -> Optional[str]:
        """
        Infer a new fact based on a given premise and inference rule.

        Args:
            premise (str): A statement representing the known facts.
            rule (str): The logical rule used to infer new facts from the premises.

        Returns:
            Optional[str]: The inferred fact if the inference is valid, otherwise None.
        """
        # Simple rule evaluation logic
        if "and" in rule and all(part in premise for part in rule.split(" and ")):
            return f"{premise} {rule.split(' and ')[-1]}"
        elif "if...then..." in rule:
            condition, consequence = rule.replace("if ", "").replace(" then", "").split("...then")
            if condition in premise:
                return consequence
        # More complex inference logic could be implemented here

        return None


# Example usage
if __name__ == "__main__":
    kb = KnowledgeBase()
    kb.add_fact("All birds can fly.")
    kb.add_fact("Penguins are birds.")

    engine = ReasoningEngine(kb)
    
    inferred_fact = engine.infer_new_fact(
        premise="Penguins are birds.",
        rule="if...then...All birds can fly...then Penguins can fly."
    )

    print(inferred_fact)  # Output: "Penguins can fly." if the inference is valid.
```