esolang

Entrance

Write down what a function gives, and the prover runs it backwards to find what it was given.

Hakerh400, 2020 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 8 known programs · Test method

Run it

Expected: (0, 0)

The idea

Hakerh400 made Entrance in 2020 and called it an advanced fully automatic theorem prover. A program is a list of function definitions. The input is one statement, and the output is that statement with every function call worked out.

Read the story

That sounds like a small functional language, and with f x = (x, x); the statement f 0 gives (0, 0). The twist is that a call may stand on the left side too. g f x = x; says that g takes whatever f gave and returns what f was given. So g (0, 0) asks the prover to find an x with f x = (0, 0), and the answer is 0. When no x fits, as for g (0, 1), there is no solution.

With that, inference rules become definitions and a proof becomes a search. The specification writes the Lukasiewicz axioms and modus ponens as three definitions of f, and g (5, 5) comes back as a full proof that 5 implies 5.

The machine

PartIs
123 "abc"A constant; constants are only equal to themselves
(a, b)A pair
xA variable, the same value everywhere in its definition
f xA call; g f x means g (f x)
f pattern = expression;One definition; a function may have many

The search is the prover's own business. This one works first on the call that the fewest definitions fit, tries definitions in order, and widens the number of choices it allows until a proof turns up. A variable that nothing pins down prints as 0, as in the proofs. When the search runs out without reaching its limit it says No solution exists; otherwise an unprovable statement runs until the step budget stops it.

Example

The statement goes in as input.

The statement goes in as input.

Expected: (3, 3)

The proof that 5 implies 5. Rule 10 is the first axiom, 20 the second and 30 modus ponens. This implementation finds the same five step proof the specification prints.

Expected: (30, ((10, (5, 0)), (30, ((10, (5, (0, 5))), (20, (5, ((0, 5), 5)))))))

The binary counter defines inc and gets dec for free as dec inc1 a = trim a;, the increment run backwards. It also finds the proof that equality commutes. The random bit gives 0 in this implementation, the path through the grid comes out shorter than the specification's, and the search for a permutation of digits does not finish within the step limit.

Patterns it teaches

  • Nondeterminism: the prover may return any proof, and a definition may have any number of answers.

Further

Declarative paradigm

Write your own in Run Convert a program from Entrance

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: entrance.

Command line

shib run entrance -e 'f x = (x, x);' --input 'f 0'
shib manual entrance

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/entrance.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org