"""Create reasoning_engine
Generated by Phi-Octopus Eden
2025-11-07 13:48:33.178076
"""

```python
from typing import List, Dict


class ReasoningEngine:
    """
    A basic reasoning engine that solves limited reasoning sophistication problems.
    It can handle simple logic rules and apply them to a set of facts.

    Args:
        rules: A list of dictionaries defining the logical rules. Each rule is represented as {'if': condition, 'then': action}.
               The condition should be a string that can be evaluated with `eval`.
               The action is a function that will be called if the condition evaluates to True.
        facts: A dictionary representing the initial state of facts.

    Methods:
        update_facts(new_fact: Dict[str, bool]) -> None:
            Update the current state of facts based on new observations or updates.

        infer() -> List[Dict[str, str]]:
            Apply rules to the current facts and return a list of inferences made.
    """

    def __init__(self, rules: List[Dict], facts: Dict[str, bool]):
        self.rules = rules
        self.facts = facts

    def update_facts(self, new_fact: Dict[str, bool]) -> None:
        """
        Update the current state of facts based on new observations or updates.

        Args:
            new_fact: A dictionary where keys are fact names and values are boolean states.
        """
        for key, value in new_fact.items():
            self.facts[key] = value

    def infer(self) -> List[Dict[str, str]]:
        """
        Apply rules to the current facts and return a list of inferences made.

        Returns:
            A list of dictionaries where each dictionary contains 'if' (condition) and 'then' (action).
        """
        inferences = []
        for rule in self.rules:
            condition, action = rule['if'], rule['then']
            if eval(condition, {}, {**self.facts}):
                inference = {'if': condition, 'then': action}
                inferences.append(inference)
        return inferences


# Example usage
rules = [
    {'if': "'dog' in facts and facts['dog']", 'then': lambda: print("Barking sound")},
    {'if': "'cat' in facts and not facts['cat']", 'then': lambda: print("Meowing sound")}
]

initial_facts = {
    "dog": True,
    "cat": False
}

reasoning_engine = ReasoningEngine(rules, initial_facts)
print("Initial Facts:", reasoning_engine.facts)

# Update some facts
new_facts = {"cat": True}
reasoning_engine.update_facts(new_fact=new_facts)

inferences = reasoning_engine.infer()
print("\nInferences Made:")
for inference in inferences:
    print(inference)
```