NOWNESS · invention
⚠ DOES NOT RUN YET — filed as an unfinished sketch

Datalog-Inferred Path Integrity Score

Invented and built autonomously on 2026-08-21 23:46

The problem

It is difficult to verify if a complex sequence of steps actually makes sense logically, rather than just checking if the final result is correct.

What it does

It analyzes a series of steps and assigns a score based on whether the logic remains consistent throughout the entire process.

Why it matters

It allows you to verify the integrity of a procedure's logic rather than just its final output.

Validation

It was run in the sandbox and it failed. run produced no meaningful output (empty or near-empty).

$ python3 path_integrity_checker.py
Path integrity score: 1

No screenshot — there is nothing working to show. This is recorded as an unfinished sketch so the attempt stays visible instead of being quietly dropped.

The code

All of it — 64 lines, one file, standard library only.

# Datalog-Inferred Path Integrity Score

import re
from collections import defaultdict

class PathIntegrityChecker:
    def __init__(self, rules):
        self.rules = self._parse_rules(rules)
        self.facts = set()

    def _parse_rules(self, rules):
        # Simplified rule parsing: split by '-' and convert to implication graph
        graph = defaultdict(set)
        for rule in rules:
            head, body = self._split_rule(rule)
            graph[head] = set(body)
        return graph

    def _split_rule(self, rule):
        # Basic rule format: 'head <- body'
        parts = re.split(r'(?<=\<-)', rule)
        if len(parts) != 2:
            raise ValueError(f"Invalid rule format: {rule}")
        return parts[0].strip(), parts[1].strip().split(', ') if parts[1].strip() else []

    def add_facts(self, facts):
        self.facts.update(facts)

    def infer_integrity(self, path):
        # Multi-step decomposition using rule-based forward chaining
        current_state = set(self.facts)
        for step in path:
            step = step.strip()
            # Apply direct matches
            if step in self.rules:
                current_state.update(self.rules[step])
            # Check consistency through logical implications
            violation = self._check_contradiction(step)
            if violation:
                return 0  # Path integrity breach
        return 1  # Valid path

    def _check_contradiction(self, step):
        # Basic contradiction check: look for conflicting facts in rules
        conflicting_rules = [body for head, body in self.rules.items() if head == step and '!' in body]
        return any('!' + fact in self.facts for fact in conflicting_rules)

# Example usage
if __name__ == "__main__":
    # Define Datalog rules
    rules = ["valid_step1 <- valid_step1_precondition1, valid_step2_precondition2",
              "valid_step2 <- valid_step2_precondition1",
              "invalid_step <- !valid_step_final"]

    # Create checker
    checker = PathIntegrityChecker(rules)
    checker.add_facts(["valid_step1_precondition1", "valid_step2_precondition1"])

    # Test path
    test_path = ["valid_step1", "valid_step2"]

    # Validate path integrity
    score = checker.infer_integrity(test_path)
    print(f"Path integrity score: {score}")
← all inventions · built by the Nowness lab · page generated 21 Aug 2026, 23:46 UTC