packages feed

phino-0.0.97: resources/dataization.yaml

# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
# Dataization 𝔻 β€” applied top-to-bottom, first matching clause wins. It is
# ternary, 𝔻(n, e, s): the second argument e is the global universe, the same
# expression that 𝕄 takes as its second argument (𝔻 forwards it to 𝕄), and the
# third argument s is the mutable state, threaded through and returned possibly
# changed. Only the 'fire' rule changes it, by firing an atom through 𝔼. The
# first argument is always a normal form: a non-NF expression matches no clause.
#
# 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
# 'd-result' (a premise bytes meta or a literal), provided 'when' holds and the
# ordered 'premises' reduce as stated. A premise binds its 'n-result'/'d-result'
# to one judgment β€” 𝔻 ('dataize'), 𝕄 ('morph'), 𝒩 ('normalize'), 𝔼 ('evaluate')
# or π’ž ('contextualize'). 'e-match' is the universe-argument matcher of
# 𝔻(n, e); it is always the e meta. The single bytes result is named Ξ΄; derived
# terms are 𝑛, 𝑛1, … in premise order, skipping the bare 𝑛 only when 'match'
# already binds it.
#
# The clauses are disjoint, so their relative order does not change behavior.
# 'norm' matches the bare meta 𝑛, which unifies with any expression, so it is
# guarded to fire only when 𝑛 is neither a formation ('not (formation 𝑛)',
# carving out 'delta', 'box', 'fire' and 'none') nor the termination βŠ₯
# ('not (𝑛 = βŠ₯)'). 𝔻 is partial: βŠ₯ (the terminator T) signals an error and
# lies outside its domain, so it deliberately matches no clause and dataization
# stops there β€” there is no 'end' rule mapping βŠ₯ to empty bytes (see #955).
# Without the guard 'norm' would behave correctly only by being declared last;
# with it the clauses no longer rely on their order.

- name: delta
  label: \Delta
  match: ⟦𝐡1, Ξ” ‍ Ξ΄, 𝐡2⟧
  e-match: 𝑒
  d-result: Ξ΄

- name: box
  match: ⟦𝐡1, Ο† ↦ 𝑒1, 𝐡2⟧
  e-match: 𝑒
  d-result: Ξ΄
  when:
    disjoint:
      - [Ξ”, Ξ»]
      - [𝐡1, 𝐡2]
  premises:
    - n-result: 𝑛
      contextualize:
        - 𝑒1
        - ⟦𝐡1, Ο† ↦ 𝑒1, 𝐡2⟧
    - n-result: 𝑛1
      normalize: 𝑛
    - d-result: Ξ΄
      dataize: 𝑛1

- name: fire
  match: ⟦𝐡1, Ξ» ‍ 𝑓, 𝐡2⟧
  e-match: 𝑒
  d-result: Ξ΄
  premises:
    - n-result: 𝑛
      evaluate:
        - ⟦𝐡1, Ξ» ‍ 𝑓, 𝐡2⟧
        - 𝑒
    - n-result: 𝑛1
      normalize: 𝑛
    - d-result: Ξ΄
      dataize: 𝑛1

- name: none
  match: ⟦𝐡⟧
  e-match: 𝑒
  d-result: Ξ΄
  when:
    disjoint:
      - [Ξ”, Ξ», Ο†]
      - [𝐡]
  premises:
    - d-result: Ξ΄
      dataize: βŠ₯

- name: norm
  match: 𝑛
  e-match: 𝑒
  d-result: Ξ΄
  when:
    and:
      - not:
          formation: 𝑛
      - not:
          eq:
            - 𝑛
            - βŠ₯
  premises:
    - n-result: 𝑛1
      morph: 𝑛
    - d-result: Ξ΄
      dataize: 𝑛1