Playground Documentation Challenges Full Docs

Locks and Realizations

How do compares signatures, and what locks in realizations mean

Overview

When a call applies a theorem proved in a lock(), you supply realizations — search labels whose statements implement the lock's axioms in the calling context. The interpreter does not require these realizations to be plain unconditional proofs: each may itself sit inside if, for, or rule blocks, and may even cross other locks. What is required is that the realization's surrounding context — its signature — is no wider than the signature of the axiom it implements.

This page is an extended worked discussion of that rule. It builds up gradually, from the simplest case to nested locks and shared paths. The compact specification is on the do page.

The basic match: realization beside the call

The simplest case: the theorem uses one lock with one axiom; the caller proves the axiom's conclusion in plain scope, labels the result, and passes the label to the call. The realization's path is just ifs — no for, no lock.

Plain realization

The theorem's axiom AxiomPQ is registered inside L under if(P -> false). The realization AxiomAB sits under if(A -> false) in the caller. The substitution P -> A, Q -> B makes the two signatures match: same if, no extra for, no extra rules.

▶ Run

Realization may use less than the theorem allows

The realization's signature may be narrower than what the theorem assumed — fewer ifs, fewer for-atoms, fewer rules. This means the realization proved its conclusion under stricter conditions than necessary, which is always sound.

Realization narrower than theorem

The theorem assumed the axiom under if(P -> false), but the caller proves B -> true outright. This is fine: the realization is strictly stronger than the theorem required.

▶ Run

Realization may not exceed the theorem

What is not allowed is the realization adding anything to its signature that the theorem did not have. An extra if, an extra for-atom of some type, or an extra rule — any of these would let the realization invoke assumptions the theorem never sanctioned. The call rejects such cases.

Realization with an extra if - rejected

The call reports that the realization's extra if-condition B -> false is not in the theorem's signature for this axiom. The realization could be reading any kind of falsehood out of that assumption - that is not something the theorem ever agreed to.

▶ Run

Expected error: Axiom realization not found

Locks in the realization

A realization's path may cross lock() nodes. Each such lock contributes its own axioms to the realization's signature, and each of those axioms must be matched by an axiom of some lock on the theorem's path. The match for nested lock axioms is by equality of signature, not by containment — a lock axiom is what the realization provides, so it must be exactly as strong as the theorem expects, neither weaker nor stronger.

The grouping of locks does not matter. The realization may split one theorem lock into several locks of its own, or merge several into one — as long as the resulting multiset of nested lock axioms is contained in the theorem's.

Nested locks: signatures match

The theorem's two locks together carry two supporting axioms. The realization carries both in a single outer lock. Because a call matches by multiset of nested-lock axioms (not by lock-by-lock isomorphism), the regrouping is accepted.

▶ Run

Parameters above and below the lock

An axiom keeps the entire schema declared inside its lock. Its own parameters are universally bound; a theorem argument cannot specialize them. Parameters declared above the lock are instance parameters and receive the theorem substitution.

Parameters above and below the lock

The realization supplies the full schema inside L. The parameters a,c and condition c -> true are above L and are handled by the theorem application.

▶ Run

The position of the lock determines the contract; the common ancestor of the axiom and the proof result does not remove schema parameters.

Multiple axioms in one lock

If a lock has several axioms, a call requires a realization for each one written before the theorem — whether or not the theorem actually uses it. The lock is a contract: every axiom standing in the lock when the theorem was proved is a hypothesis under which it was proved, and every one must be discharged. Realizations may be supplied in any order; the call matches them by signature, not by position.

All axioms must be realized

A lock is a contract: every axiom standing in it when the theorem was proved must be discharged. Order does not matter.

▶ Run

An axiom written after the theorem

The text is read in order, and a theorem is proved under the conditions that stand when it is written. An axiom added to the lock after the theorem could not take part in its proof, so it is no obligation of the theorem: a call asks for no realization of it. Here T1 is proved before Ax is added to A, and is applied outside A without one.

An axiom written after the theorem is not required

T1 rests only on what stood in A when it was proved. Written before T1, Ax would have to be realized (it cannot be here).

▶ Run

do inside a realization

A realization may freely call other theorems. The result of a call is a plain statement delivered into the current scope; whatever locks lived inside the theorem applied by that nested call stay there, never appearing on the outer realization's path.

A call inside a realization

A call gives a regular statement; the theorem applied by the inner call does not affect the outer realization's signature.

▶ Run

Summary

A call checks realizations by comparing signatures. A signature is a structured account of everything between a statement's definition and where its label was declared: the multiset of for-atoms (per type), the multiset of if-conditions, the multiset of rule rules.

For each axiom the theorem requires:

  • The realization's signature must be contained in the axiom's signature — fewer or equal for-atoms per type (positional, prefix-matched), fewer or equal ifs, fewer or equal rules.
  • Parameters above the axiom's lock receive the theorem substitution. Its own parameters inside the lock remain part of the complete schema.
  • Nested locks on either side contribute their axioms; these are matched by equality of signature, in any grouping.

The single underlying principle: the realization must not be allowed to use anything the theorem did not. Everything else — order, grouping, narrowing — is just freedom to write the proof naturally.