"""Create reasoning_engine
Generated by Phi-Octopus Eden
2025-11-07 10:21:18.398183
"""

```python
from typing import List, Dict


class ReasoningEngine:
    """
    A basic reasoning engine that solves problems involving limited reasoning sophistication.
    The engine can evaluate simple logical expressions and handle constraints.

    Parameters:
        - knowledge_base: a dictionary containing the initial state of the problem domain
        - rules: a list of functions representing inference rules to apply on the knowledge base

    Methods:
        - infer(): applies the inference rules on the current knowledge base to update it.
        - check_constraint(constraint): checks if the given constraint holds true in the current knowledge base.

    Example usage:

        knowledge_base = {"temperature": 25, "humidity": 40}
        rules = [lambda k: k["temperature"] > 30 and k["humidity"] < 60]

        reasoning_engine = ReasoningEngine(knowledge_base=knowledge_base, rules=rules)
        print(reasoning_engine.infer())  # Updates the knowledge base if a rule is satisfied
        print(reasoning_engine.check_constraint({"humidity": lambda x: x > 35}))  # Check constraint satisfaction
    """

    def __init__(self, knowledge_base: Dict[str, int], rules: List[callable]):
        self.knowledge_base = knowledge_base
        self.rules = rules

    def infer(self) -> bool:
        """
        Apply inference rules on the current state of the knowledge base.

        Returns:
            A boolean indicating whether any rule was applied and updated the knowledge base.
        """
        updated = False
        for rule in self.rules:
            if all(constraint(self.knowledge_base) for constraint in rule.__code__.co_freevars):
                # Update the knowledge base with new information
                for variable, value in rule(self.knowledge_base).items():
                    self.knowledge_base[variable] = value
                updated = True
        return updated

    def check_constraint(self, constraint: Dict[str, callable]) -> bool:
        """
        Check if a given constraint is satisfied by the current state of the knowledge base.

        Parameters:
            - constraint: A dictionary with key-value pairs where keys are variable names and values are functions
                          that define the constraints on those variables.

        Returns:
            A boolean indicating whether the constraint holds true in the current knowledge base.
        """
        return all(constraint[key](self.knowledge_base.get(key)) for key in constraint)


# Example usage
knowledge_base = {"temperature": 25, "humidity": 40}
rules = [lambda kb: {"temperature": max(kb["temperature"] + 5, 30), "humidity": min(kb["humidity"] - 10, 60)}]
reasoning_engine = ReasoningEngine(knowledge_base=knowledge_base, rules=rules)
print(reasoning_engine.infer())  # Should print True
print(reasoning_engine.check_constraint({"temperature": lambda x: x >= 30}))  # Should print True
```