Introducing a Python-Based Reasoning Engine for Deterministic AI

In the age of large language models (LLMs), there’s a growing need for deterministic systems that enforce rules and constraints while reasoning about information. We’ve developed a Python-based reasoning and validation framework that bridges the gap between traditional rule-based logic and modern AI capabilities, inspired by frameworks like Pydantic.

This approach is designed for developers and non-technical experts alike, making it easy to build complex rule engines that translate natural language instructions into enforceable code. Our fine-tuned model automates the creation of rules while ensuring human oversight for quality and conflict detection. The result? Faster implementation of rule engines, reduced developer overhead, and flexible extensibility across domains.


The Framework at a Glance

Our system consists of five core components:

  1. Data Structure: The foundational representation of entities and their attributes.
  2. Rules: Constraints or logic that govern the system.
  3. Reasoning Framework: The engine that processes data against rules to derive outcomes.
  4. Agent: The mechanism that interacts with and manipulates the system.
  5. State Machine: A tracker of the system’s current and historical states.

To analogize, this framework operates like a game of chess:

  • The Data Structure is the chessboard and pieces.
  • The Rules define how each piece can move.
  • The Reasoning Framework is the player strategizing moves.
  • The Agent moves the pieces.
  • The State Machine records the state of the board after each turn.

Our framework supports two primary use cases:

  • Validation Engines: Stateless systems that validate data against rules.
  • Reasoning Engines: Stateful systems that navigate problems and make decisions.

Key Features and Benefits

  • Natural Language Rule Creation: Non-technical users can input rules as plain text, which are then converted into Python structures for developer approval.
  • Conflict Detection: Automatically flags contradictory rules during input, streamlining validation.
  • Extensibility Across Use Cases: From logistics to compliance, the framework adapts to diverse business scenarios.
  • Developer Efficiency: Cuts development time by 5x through automated rule generation and validation.

Case Studies

Validation Engine: Ensuring Compliance

A mining company needed to validate employee qualifications based on age, region, and role.

Example Data Structure:

jsonCopy code{  
  "employees": [  
    { "name": "Sarah", "age": 25, "role": "Manager", "documents": ["safe_handling_at_work", "heavy_lifting"] },  
    { "name": "John", "age": 17, "role": "Laborer", "documents": ["heavy_lifting"] }  
  ]  
}  

Rules:

jsonCopy code{  
  "rules": [  
    { "type": "min_age", "parameters": { "min_age": 18 } },  
    { "type": "dozer_operator", "parameters": { "document_type": "dozer_qualification" } }  
  ]  
}  

Outcome:
The system flagged violations, such as employees under 18 or missing required qualifications, ensuring compliance with organizational rules.


Reasoning Engine: Solving the River Crossing Puzzle

The classic river crossing puzzle demonstrates the engine’s reasoning capabilities.

Problem Setup:
A farmer must ferry a goat, a wolf, and a cabbage across a river, adhering to specific constraints (e.g., the goat cannot be left alone with the cabbage).

Steps:

  1. Define the entities (farmer, goat, wolf, cabbage).
  2. Translate constraints into rules.
  3. Use the reasoning engine to compute a solution.

Output:
The engine generated a solution in 0.0003 seconds, showcasing its efficiency in navigating complex logic.


Advanced Features: Dynamic Rule Expansion

The system supports real-time rule adjustments. For instance, adding a “wolf cannot be left with a chicken” constraint introduces a conflict. By extending rules (e.g., allowing the farmer to carry two items), the engine dynamically resolves previously unsolvable scenarios.

Sample Code Snippet:

pythonCopy codeclass CarryingCapacityRule(Rule):  
   def evaluate(self, state):  
       items_moved = sum(1 for item in ['wolf', 'goat', 'cabbage', 'chicken'] if getattr(state, item) == state.farmer)  
       return items_moved <= 2  

   def get_description(self):  
       return "Farmer can carry up to two items at a time"  

Result:
The adjusted engine solved the puzzle in three moves, down from seven, while maintaining rule integrity.


Collaborative UI for Rule Creation

Our user interface empowers domain experts to define rules without writing code. Developers validate these rules, which are then seamlessly integrated into the system.

Visual Workflow:

  • Input rules in natural language.
  • AI translates them into Python.
  • Developers validate and approve.
  • The system runs rules in real time.
Related Posts
Salesforce OEM AppExchange
Salesforce OEM AppExchange

Expanding its reach beyond CRM, Salesforce.com has launched a new service called AppExchange OEM Edition, aimed at non-CRM service providers. Read more

Salesforce Jigsaw
Salesforce Jigsaw

Salesforce.com, a prominent figure in cloud computing, has finalized a deal to acquire Jigsaw, a wiki-style business contact database, for Read more

Health Cloud Brings Healthcare Transformation
Health Cloud Brings Healthcare Transformation

Following swiftly after last week's successful launch of Financial Services Cloud, Salesforce has announced the second installment in its series Read more

Top Ten Reasons Why Tectonic Loves the Cloud
cloud computing

The Cloud is Good for Everyone - Why Tectonic loves the cloud You don’t need to worry about tracking licenses. Read more

author avatar
get-admin