packages feed

phino-0.0.131 / resources / morphing.yaml

# 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 𝑒0 meta, but a rule may# pin it to a literal (e.g. 'mg' fires only on 𝕄(Ξ¦, Ξ¦)). Every judgment here is# normal-form-valued (𝕄 'morph', 𝒩 'normalize', 𝔼 'evaluate' β€” 𝔼 normalizes its# atom's result internally), so premise results are named 𝑛1, 𝑛2, … in premise# order. The term a rule morphs is 𝑛0 and its universe 𝑒0, leaving that# numbering to the premises alone; the 𝑒-family stays reserved for the universe.# A meta the rule never reads back is written bare (see 'mad'): it matches# whatever stands in its place, binds nothing and cannot be referenced.## 'ml' and 'md' are kept mutually exclusive: 'md' fires only# when its head 𝑛0 is not a formation ('not (formation 𝑛0)'), 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 'π‘˜1' argument β€” absolute (xi-free) and in normal# form β€” and recurse by re-normalizing the application; 'mad'/'maad' take an# '𝑛1' 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: ⟦𝐡0⟧  e-match: 𝑒0  n-result: ⟦𝐡0⟧- name: ml  label: \lambda  match: '⟦𝐡1, Ξ» ‍ 𝑓0, 𝐡2⟧.𝜏0'  e-match: 𝑒0  n-result: 𝑛3  premises:    - n-result: 𝑛1      evaluate:        - '⟦𝐡1, Ξ» ‍ 𝑓0, 𝐡2⟧'        - 𝑒0    - n-result: 𝑛2      normalize: '𝑛1.𝜏0'    - n-result: 𝑛3      morph: 𝑛2- name: mphi  label: \varphi  match: ⟦𝐡0⟧.𝜏0  e-match: 𝑒0  n-result: 𝑛2  when:    and:      - in:          - Ο†          - 𝐡0      - not:          in:            - 𝜏0            - 𝐡0      - not:          in:            - Ξ»            - 𝐡0  premises:    - n-result: 𝑛1      normalize: ⟦𝐡0⟧.Ο†.𝜏0    - n-result: 𝑛2      morph: 𝑛1- name: md  match: '𝑛0.𝜏0'  e-match: 𝑒0  n-result: 𝑛3  when:    not:      formation: 𝑛0  premises:    - n-result: 𝑛1      morph: 𝑛0    - n-result: 𝑛2      normalize: '𝑛1.𝜏0'    - n-result: 𝑛3      morph: 𝑛2- name: ma  match: '𝑛0(𝜏0 ↦ π‘˜1)'  e-match: 𝑒0  n-result: 𝑛3  premises:    - n-result: 𝑛1      morph: 𝑛0    - n-result: 𝑛2      normalize: '𝑛1(𝜏0 ↦ π‘˜1)'    - n-result: 𝑛3      morph: 𝑛2- name: maa  match: '𝑛0(α𝑖0 ↦ π‘˜1)'  e-match: 𝑒0  n-result: 𝑛3  premises:    - n-result: 𝑛1      morph: 𝑛0    - n-result: 𝑛2      normalize: '𝑛1(α𝑖0 ↦ π‘˜1)'    - n-result: 𝑛3      morph: 𝑛2- name: mad  match: '𝑛(𝜏 ↦ 𝑛1)'  e-match: 𝑒0  n-result: 𝑛2  when:    not:      absolute: 𝑛1  premises:    - n-result: 𝑛2      morph: βŠ₯- name: maad  match: '𝑛(α𝑖 ↦ 𝑛1)'  e-match: 𝑒0  n-result: 𝑛2  when:    not:      absolute: 𝑛1  premises:    - n-result: 𝑛2      morph: βŠ₯- name: universe  label: \Phi  match: Ξ¦  e-match: 𝑒0  n-result: 𝑛2  when:    not:      eq:        - 𝑒0        - Ξ¦  premises:    - n-result: 𝑛1      normalize: 𝑒0    - n-result: 𝑛2      morph: 𝑛1- name: dead  match: βŠ₯  e-match: 𝑒0  n-result: βŠ₯- name: xi  match: ΞΎ  e-match: 𝑒0  n-result: 𝑛1  premises:    - n-result: 𝑛1      morph: βŠ₯- name: mg  match: Ξ¦  e-match: Ξ¦  n-result: 𝑛1  premises:    - n-result: 𝑛1      morph: βŠ₯