phino-0.0.96: 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 'root' 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.
- 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: root
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: β₯