Shunyaya Symbolic Mathematics — Piecewise & indicator family (2.35)

Abstract
We lift indicator-style functions—sgn, Heaviside H, ramp/ReLU, and clip—to symbolic numerals (m, a). Each operator selects among branches; we make branch choice on the magnitude and carry the alignment from the selected source (input or constant), with explicit and reproducible tie policies. Under collapse phi(m,a) = m, all formulas reduce to their classical counterparts.


Alignment policy for selectors (default)

When a piecewise function selects a branch:

result = selected_argument
alignment(result) = alignment(selected_argument)

  • If a constant is selected (e.g., 0 or 1), its default alignment is +1 unless you explicitly tag it.
  • This “carry-from-source” rule tracks whether the output came from a saturated constant (stable) or from the input (inherits input stability).

Tie-breaking at thresholds (manifest knobs).
At points where branches meet (e.g., m = 0), choose one of:

selector_tie = "prefer_constant"   # default for clamp/clip boundaries
selector_tie = "prefer_input"      # keep input branch on ties
selector_tie = "alignment_sign"    # choose upper branch if a >= 0 else lower

For Heaviside at 0, you may also choose:

heaviside_zero = "half" | "right" | "left" | "alignment_sign"

Document choices on the page.


Sign function (sgn)

Classical:

sgn(m) = -1  if m < 0
         0   if m = 0
         +1  if m > 0

Symbolic lift (selector-carry):

sgn*(m, a) =
  ( -1 , +1 )   if m < 0
  (  0 , +1 )   if m = 0       # canonical zero
  ( +1 , +1 )   if m > 0

  • We use constants with +1 alignment by default for the outputs -1, 0, +1.
  • Alternative (manifest): sgn_alignment = "carry_input" to output (±1, a) for m ≠ 0.

Equivalences (with tie caveats):

H(m) = ( 1 + sgn(m) ) / 2
sgn(m) = 2*H(m) - 1

If H(0)=1/2 these equivalences hold pointwise; with other H(0) policies they hold away from m=0.


Heaviside step H

Classical (principal options at m=0):

H(m) = 0       if m < 0
       1/2     if m = 0      # "half-maximum" convention (default here)
       1       if m > 0

Symbolic lift (selector-carry):

H*(m, a) =
  ( 0   , +1 )                 if m < 0
  ( 1/2 , +1 )                 if m = 0     # default; see manifest
  ( 1   , +1 )                 if m > 0

Manifest knobs:

heaviside_zero = "half" (default) | "right" (1) | "left" (0) | "alignment_sign"

If "alignment_sign", define H*(0,a) = (1, +1) if a >= 0, else (0, +1).


Ramp / ReLU

Classical:

ramp(m) = max(m, 0)
ReLU(m) = max(m, 0)           # same function

Symbolic lift (selector-carry):

ramp*(m, a) =
  ( m , a )    if m > 0
  ( 0 , +1 )   if m <= 0      # tie handled by selector_tie; default prefers constant at m = 0

Equivalent forms (for magnitude):

ramp(m) = (m + |m|) / 2
ramp(m) = m * H(m)

Tie behavior follows your H(0) and selector_tie policies.


Clip (saturation)

Classical (clip(m; L, U) with L <= U):

clip(m) = min( max(m, L), U )

Symbolic lift (selector-carry):

clip*(m, a; L, U) =
  ( L , +1 )   if m < L         # select lower bound constant
  ( m , a )    if L <= m <= U   # pass-through
  ( U , +1 )   if m > U         # select upper bound constant

Tie at boundaries (m = L or m = U):
Default selector_tie = "prefer_constant" keeps (L,+1) or (U,+1); declare otherwise if you want pass-through on equality.


Min/Max equivalences (magnitude channel)

For re-use in proofs and code:

min(m1, m2) = (m1 + m2 - |m1 - m2|) / 2
max(m1, m2) = (m1 + m2 + |m1 - m2|) / 2
clip(m; L, U) = min( max(m, L), U )
ramp(m)       = max(m, 0)

Alignment follows the selected source (carry-from-source). For min/max of symbolic numerals (x1, a1), (x2, a2), select by comparing magnitudes and carry the winning alignment (a1 or a2); on ties, use the symbolic preorder (S_beta) or a stated selector_tie.


Collapse, order, and monotonicity

  • Collapse: phi( f*(m,a) ) = f(m) for f in {sgn, H, ramp, clip} given the chosen H(0) and tie policies.
  • Order: ramp and clip are monotone nondecreasing in m (for fixed bounds); selection by magnitude preserves order on each branch.
  • Stability semantics: Saturation (clip) yields constants with +1 alignment unless otherwise tagged—explicitly signaling that the output is bound-limited rather than input-driven.

Worked examples

A) Heaviside with default half-maximum at 0.

H*((-2.0, -0.3)) = (0  , +1)
H*(( 0.0, +0.9)) = (1/2, +1)    # heaviside_zero = "half"
H*((+3.1, +0.2)) = (1  , +1)

B) Ramp with selector-carry and boundary tie.

ramp*((-0.1, -0.6)) = (0   , +1)
ramp*(( 0.0, +0.7)) = (0   , +1)   # selector_tie = "prefer_constant"
ramp*(( 2.5, +0.4)) = (2.5 , +0.4)

C) Clip with input inside and outside bounds.

clip*((-5, 0.2); L=-1, U=2)  = ( -1 , +1 )     # saturated at lower bound
clip*(( 0, 0.5);  L=-1, U=2)  = (  0 , 0.5 )   # pass-through
clip*(( 5, 0.9);  L=-1, U=2)  = (  2 , +1 )    # saturated at upper bound

D) Alternative tie via alignment_sign (manifest choice).

heaviside_zero = "alignment_sign"
H*((0, +0.3)) = (1, +1)     ;    H*((0, -0.8)) = (0, +1)

This makes threshold decisions auditably depend on the input alignment.


Implementation notes (manifest)

  • selector_alignment = "carry_from_source" (default) | "carry_input_always" | "constant_plus_one"
  • selector_tie = "prefer_constant" (default) | "prefer_input" | "alignment_sign"
  • heaviside_zero = "half" (default) | "right" | "left" | "alignment_sign"
  • constant_alignment = +1 unless explicitly tagged
  • Zero canonicalization: any output with magnitude 0(0, +1)
  • Document numeric types for bounds (L, U) and whether they are symbolic (L, a_L) (rare) or classical ((L, +1) default).

Takeaway

Piecewise and indicator functions behave as selectors: magnitude decides the branch, alignment comes from the chosen source. Clear tie policies make threshold behavior reproducible. Saturation exposes stability explicitly (constants report with +1), and all constructions collapse to the classical forms when a = +1.


Navigation
Previous → Hyperbolic & inverse hyperbolic (2.34)
Next → Rounding operators (2.36)


Disclaimer
Observation only. Results reproduce mathematically; domain claims require independent peer review. Defaults: mult_mode = M2, clamp_eps = 1e-6, |a| < 1. All formulas are presented in plain text. Collapse uses phi(m,a) = m.