Hilbert Shin
Logic programming for real systems: rules, facts, stratified negation, tabled resolution, modal operators, aggregation and abduction.
In use by every MLambda product
Hilbert Shin
Shin (ש) is the expert-system language of the family: logic programming in the line of Prolog and Datalog,
made for systems that must explain what they decide. Every inference in MLambda is a Shin rule. A service reads
what happened into facts, asks a Shin engine what follows, and formats the answer. The classification, the joins and
the conclusions are rules (:-), never if chains in code.
A theory
shin 1.0
engine pipeline
record KindIs { kind: String }
record Override { stage: String, on: String }
record KindStage { kind: String, stage: String }
record StageWanted { stage: String }
record Refused { subject: String, why: String }
facts
instance KindStage { kind: "app", stage: "tsadi" }
instance KindStage { kind: "app", stage: "ayin" }
rule pl_kind_stage(k: KindIs)
when k is KindIs { kind: d } and _s is KindStage { kind: d, stage: s } and not Override { stage: s, on: "false" }
then assert StageWanted { stage: s }
query pl_all_wanted (stage?: String) :- _x is StageWanted { stage: stage }
These lines come from pipeline.shin, the theory the Aleph compiler asks when it plans a test run. The compiler
asserts what it read (KindIs, the manifest’s Overrides) and runs the query. The theory, not the compiler,
decides which stages run and refuses a stage that cannot be turned off.
The engine
MLambda.Shin.Runtime is the engine:
- a persistent knowledge base, semi-naive forward chaining by strata;
- tabled SLD resolution with negation as failure, so recursive queries end;
- stratified negation, rewriting and truth maintenance;
- modal evaluation, aggregation and abduction (what would have to be true for a goal to hold).
MLambda.Shin.Compiler turns a .shin/.hs module into an Aleph module of runtime values
(Parse → Desugar → Analyze → Normalize → Emit), run as a generator, so rules compile with the program.
Shin checks Shin
The tools around the language are themselves written in Shin. The Aleph beside them only flattens a tree into facts:
- Analysis: the four families of Nielson, Nielson and Hankin’s Principles of Program Analysis (data flow, constraint-based 0-CFA, abstract interpretation, type and effect), applied to Shin and written in Shin.
- Lint: one
Diagfact per lint, derived by joins and stratified negation. - Semantic validator: binding, duplicates and well-formedness, as rules.
- Prettier: the canonical formatter.
Where it decides
- The Aleph compiler: platforms, pipelines, packages and commands.
- Every service: who may act, what a request is refused for, what an event sets off.
- Max: what an agent is owed, licensed, achieved or has broken.
- Turing: the books’ judgements of every backlog item.
- Quality and delivery: Ayin’s findings, Litush’s recipes, Katharsis’s flow and Arkhos’s plans.
- Mail: the guard’s evidence and its verdict on spam and phishing.