# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com# SPDX-License-Identifier: MIT---# Morphing π β applied top-to-bottom, first matching clause wins. It is ternary,# π(n, e, s): n is the morphed term, e is the fixed global universe and s is# the mutable state. The universe is threaded unchanged through every recursive# call and substituted for Ξ¦ by the 'universe' rule (Ξ¦, rendered Q, is just the# locator of e); the state is threaded too and the new state returned. Only the# 'ml' rule changes it, by firing an atom through πΌ. The first argument is# always a normal form: a non-NF expression matches no clause. π navigates a# normal form to a formation one operation at a time, resolving Ξ¦ against e and# peeling dispatches and applications through normalization π©. It never fires a# bare atom: a saturated Ξ»-formation is returned untouched and fired later by πΌ# (the 'fire' rule of π»).## Each rule is an inference rule: when 'match' matches the term and 'e-match'# matches the universe (binding the meta e), the rule yields the conclusion# 'n-result' (a premise meta or a literal), provided 'when' holds and the# ordered 'premises' reduce as stated. A premise binds 'n-result' to the result# of one judgment β π ('morph'), π© ('normalize') or πΌ ('evaluate'). 'e-match' is# the universe-argument matcher of π(n, e); usually the e meta, but a rule may# pin it to a literal (e.g. 'mg' fires only on π(Ξ¦, Ξ¦)). Derived terms are# named π, π1, β¦ in premise order; the bare π is skipped only when 'match'# already binds it.## 'ml' and 'md' are kept mutually exclusive: 'md' fires only# when its head π is not a formation ('not (formation π)'), so every formation# head β Ξ»-bearing or not β is left to 'ml' (and 'mf'). The two clauses# are disjoint and their relative order does not change behavior.## 'ma'/'maa' and 'mad'/'maad' partition application-headed normal forms on# the argument's absoluteness (#959). Both pairs pin the argument to a# normal-form meta, so the split is total over the normal forms π actually# sees: 'ma'/'maa' take a 'π' argument β absolute (xi-free) and in normal# form β and recurse by re-normalizing the application; 'mad'/'maad' take an# 'π' argument (a normal form) that is 'not (absolute π1)' and yield β₯# through a single 'morph: β₯' premise, which terminates at once via the# 'dead' axiom (π(β₯, e, s) β (β₯, s)) β no recursion. A non-absolute argument# can never fill a slot, so β₯ is the correct outcome and morphing stays# total: exactly one of the four fires, and these β₯ premises add no regress.# Without them, a void slot receiving a# non-absolute argument β e.g. β¦ x β¦ β
β§( x β¦ ΞΎ.foo ) β had no terminating# derivation: 'copy' cannot fire on a non-absolute argument, so 'ma'# re-morphed the identical stuck term forever.- name: mf match: β¦π΅β§ e-match: π n-result: β¦π΅β§- name: ml label: \lambda match: 'β¦π΅1, Ξ» β€ π, π΅2β§.π' e-match: π n-result: π2 premises: - n-result: π evaluate: - 'β¦π΅1, Ξ» β€ π, π΅2β§' - π - n-result: π1 normalize: 'π.π' - n-result: π2 morph: π1- name: md match: 'π.π' e-match: π n-result: π3 when: not: formation: π premises: - n-result: π1 morph: π - n-result: π2 normalize: 'π1.π' - n-result: π3 morph: π2- name: ma match: 'π(π β¦ π1)' e-match: π n-result: π3 premises: - n-result: π1 morph: π - n-result: π2 normalize: 'π1(π β¦ π1)' - n-result: π3 morph: π2- name: maa match: 'π(Ξ±π β¦ π1)' e-match: π n-result: π3 premises: - n-result: π1 morph: π - n-result: π2 normalize: 'π1(Ξ±π β¦ π1)' - n-result: π3 morph: π2- name: mad match: 'π(π β¦ π1)' e-match: π n-result: π2 when: not: absolute: π1 premises: - n-result: π2 morph: β₯- name: maad match: 'π(Ξ±π β¦ π1)' e-match: π n-result: π2 when: not: absolute: π1 premises: - n-result: π2 morph: β₯- name: universe label: \Phi match: Ξ¦ e-match: π n-result: π1 when: not: eq: - π - Ξ¦ premises: - n-result: π normalize: π - n-result: π1 morph: π- name: dead match: β₯ e-match: π n-result: β₯- name: xi match: ΞΎ e-match: π n-result: π premises: - n-result: π morph: β₯- name: mg match: Ξ¦ e-match: Ξ¦ n-result: π premises: - n-result: π morph: β₯