A Formal Model and Interactive Visualization of miniKanren Search Semantics


Details
Mechanized executable semantics are a valuable tool for implementers and users alike to better understand their programs' behavior. The need is particulary acute in the context of novel logic programming languages with complex search strategies. Few such tools exist for logic-based programming languages however, and existing work only models languages' search behavior at a somewhat coarse-grained level. In this work, we present the first small-step semantics for a logic language that models interleaving search at the level of individual goal execution. The model is implemented in PLT Redex, a Racket-based semantics workbench, and allows users to step through the language's execution at a sub-interleave level.
We also present a visualization tool implemented through interactive JS in the browser with our miniKanren Redex model at its core. This visualizer allows users to input their own miniKanren programs as Racket source code; these programs are transpiled to the language of our model. At each step, users can easily see the evaluation context of their programs, trace goals both to and from the source code and the search tree visualization, and readily understand the history of the computation that led parts of the current state to arise. This not only enables better performance analysis and a unique, visual way of debugging but also allows novice miniKanren programmers to more readily understand the semantics and structure underlying the miniKanren search evolution.

A Formal Model and Interactive Visualization of miniKanren Search Semantics