// Package tao encodes the Tao Te Ching as a ternary state system. // // The 81 chapters form a 3⁴ state space across four axes: // // Axis 0: Form — 形 xíng (empty / becoming / manifest) // Axis 1: Function — 用 yòng (passive / adaptive / active) // Axis 2: Meaning — 意 yì (implicit / emergent / explicit) // Axis 3: Bond — 結 jié (dissolved / forming / crystallized) // // Each axis has three values (0, 1, 2), giving 3⁴ = 81 positions. // The ternary encoding extends the binary I Ching with a middle // ground — the "becoming" state between yin and yang. package tao // Trit is a ternary digit: 0, 1, or 2. type Trit uint8 const ( Yin Trit = 0 // 陰 — receptive, empty, passive Becoming Trit = 1 // 化 — transitional, becoming, adaptive Yang Trit = 2 // 陽 — creative, manifest, active ) // Axis identifies one of the four ternary dimensions. type Axis uint8 const ( AxisForm Axis = 0 // 形 xíng — structural manifestation AxisFunction Axis = 1 // 用 yòng — operational mode AxisMeaning Axis = 2 // 意 yì — semantic clarity AxisBond Axis = 3 // 結 jié — attachment strength ) // Position is a point in the 81-state ternary space. // Encoded as form + 3*function + 9*meaning + 27*bond. type Position uint8 // Encode computes the position from four trits. func Encode(form, function, meaning, bond Trit) Position { return Position(form) + Position(function)*3 + Position(meaning)*9 + Position(bond)*27 } // Decode unpacks a position into its four trits. func (p Position) Decode() (form, function, meaning, bond Trit) { v := uint8(p) form = Trit(v % 3) v /= 3 function = Trit(v % 3) v /= 3 meaning = Trit(v % 3) v /= 3 bond = Trit(v % 3) return } // Trit returns the value along one axis. func (p Position) Trit(axis Axis) Trit { return Trit((uint8(p) / pow3(uint8(axis))) % 3) } // Set returns a new position with the given axis set to the given trit. func (p Position) Set(axis Axis, t Trit) Position { f, fn, m, b := p.Decode() switch axis { case AxisForm: f = t case AxisFunction: fn = t case AxisMeaning: m = t case AxisBond: b = t } return Encode(f, fn, m, b) } // Advance moves one axis one step: 0→1, 1→2, 2→0 (cyclic). func (p Position) Advance(axis Axis) Position { t := (p.Trit(axis) + 1) % 3 return p.Set(axis, t) } // Retreat moves one axis back one step: 0→2, 1→0, 2→1 (cyclic). func (p Position) Retreat(axis Axis) Position { t := (p.Trit(axis) + 2) % 3 return p.Set(axis, t) } func pow3(n uint8) uint8 { r := uint8(1) for i := uint8(0); i < n; i++ { r *= 3 } return r } // Chapter holds one of the 81 chapters of the Tao Te Ching. type Chapter struct { Number int // 1-81 (King Wen traditional order) Position Position // ternary encoding (0-80) Chinese string // original Chinese text Translation string // fresh English translation } // Chapters returns all 81 chapters with Chinese text and fresh translation. func Chapters() [81]Chapter { return chapters } // ChapterAt returns the chapter at the given ternary position. func ChapterAt(p Position) Chapter { if p > 80 { return Chapter{} } return chapters[p] }