scieee Science in your language
[en] (orig)

PhaseBridge: A Strict Lossless Mapping Between Discrete Alphabets and Phase Space for Cognitive Systems

Abstract

PhaseBridge is an experimental open-source framework that defines a strict, lossless mapping between discrete alphabets (uintM) and continuous phase space (θ ∈ [0, 2π)). It provides a minimal and verifiable interchange format (PIF) that enables reversible round-trip conversion across data modalities such as time series and images. Unlike compression-oriented containers (Parquet, CBOR) or learned embeddings, PhaseBridge emphasizes reversibility, integrity, and a uniform diagnostic signal. Each mapping is guaranteed bit-exact under the declared alphabet when meta.note = "no_processing". Integrity is enforced via SHA-256 hashes, while κ-coherence (|⟨e^{iθ}⟩|) provides a simple, read-only measure of structural coherence. The framework includes:- A Python SDK and CLI tools (pb-encode, pb-decode, pb-validate, pb-kappa).- A formal JSON Schema for PIF v1, with optional MessagePack serialization.- Conformance tests, including property-based tests for round-trip correctness. Demonstrations include strict round-trip for synthetic time series and grayscale images, with hash and κ validation. The approach complements existing formats by providing a minimal representational substrate that can be embedded into wider analytic or multimodal pipelines. PhaseBridge is intended as a foundational layer for cognitive systems where strict invertibility, integrity checks, and cross-modality consistency are essential.

Read accessible full text

PhaseBridge: A Strict Lossless Mapping Between Discrete Alphabets and Phase Space for Cognitive Systems

Author: Fedotov, Anton; Efimov, Sergey; SynqraTech
Publisher: Zenodo
DOI: 10.5281/zenodo.17257115
Source: https://zenodo.org/records/17257115/files/PhaseBridge__Strict_Discrete_Phase_Mapping_as_a_Foundation_for_Cognitive_Systems.pdf
PhaseB idge: S ic Disc e e ↔Phase Mapping as a
Founda ion o Cogni i e Sys ems
An on Fedo o
Synq aTech
an i edo o[email p o ec ed]
ORCID: 0009-0004-2313-6530
Se gey E imo
Synq aTech
se.de.e imo[email p o ec ed]
Oc obe 3, 2025
Abs ac
Da a pipelines inc easingly span he e ogeneous modali ies ( ime se ies, images,
okens), s o age o ma s, and p ocessing s acks, which complica es eliable in e change
and alida ion ac oss sys ems. We p esen PhaseB idge, a minimal, s ic , and lossless
in e p e e ha maps disc e e symbols o a con inuous phase ep esen a ion and back,
enabling a uni o m in e change laye wi h e i iable ound- ip gua an ees. The co e
mapping is
n∈ {
0
, . . . , M −
1
} 7→ θ
= 2
πn/M
wi h nea es -g id decoding; phases
a e s o ed as IEEE-754 loa 64 and alida ed by a ligh weigh schema. We de ine he
Phase In e change Fo ma (PIF), p o ide a e e ence SDK and CLI, and in oduce a
cohe ence me ic
κ
as a ead-only diagnos ic signal a ailable uni o mly ac oss modali ies.
We demons a e easibili y on ime se ies and 8-bi images, and ou line a oadmap
o addi ional adap e s. The aim is no o eplace domain-speci ic encodings, bu o
o e a small, dependable co e ha suppo s s ic ound- ip, in eg i y checks, and
uni ied diagnos ics whe e a common ep esen a ional subs a e bene i s cogni i e and
da a-analysis wo k lows.
1 In oduc ion
Mode n da a sys ems ou inely in eg a e he e ogeneous sou ces—disc e e ime se ies, abula
eco ds, images, oken s eams—each ca ied by di e en on-wi e o ma s (e.g., CSV/J-
SON/Pa que ) and p ocessed by modali y-speci ic ooling. While hese o ma s se e
s o age and anspo well, hey do no by hemsel es p o ide a uni o m ep esen a ional
subs a e ha can suppo s ic ound- ip gua an ees, ligh weigh un ime alida ion,
and c oss-modal diagnos ics in a common space. As pipelines become mo e composi ional
and model-cen ic, he absence o such a subs a e in oduces ic ion: agile adap e s,
1
inconsis en seman ics, and di icul y e i ying ha ans o ma ions a e s ic ly e e sible
whe e equi ed.
This wo k. We in oduce PhaseB idge, a minimal lossless in e p e e ha maps be ween
a disc e e alphabe and a con inuous phase space. The co e mapping is de ined by a ixed
alphabe size M∈Nand
n∈ {0, . . . , M −1}←→θ=2π
Mn∈[0,2π),
wi h decoding by nea es g id poin ,
ˆn= oundM
2πθmod M, (2)
and phases s o ed in IEEE-754 loa 64 w apped o [0
,
2
π
). On op o his mapping, we
de ine a compac Phase In e change Fo ma (PIF) wi h a minimal schema (alphabe and
op ional me ada a), un ime alida ion, and an in eg i y hook ia SHA-256 o he o iginal
aw by e s eam. We u he expose a modali y-agnos ic diagnos ic signal— he ci cula
cohe ence me ic
κ
=
1
NPjeiθj∈
[0
,
1] (and i s windowed o m)—which can be compu ed
uni o mly ac oss modali ies wi hou al e ing da a.
Mo i a ion. The goal is a small, dependable co e ha can se e as a s able in e change
laye in cogni i e and da a-analysis wo k lows: s ic e e sibili y when needed; explici
sepa a ion o conce ns be ween con e sion and any subsequen p ocessing; and a simple,
uni o m diagnos ic a ailable e e ywhe e. This is concep ually akin o how UTF-8 p o ides
a iny, s ic co e o ex ual in e change: no a eplacemen o all domain encodings, bu
a common basis ha educes ic ion and ambigui y ac oss sys ems.
Scope. PhaseB idge a ge s se ings whe e (i) lossless ound- ip is a unc ional equi e-
men o he decla ed alphabe ; (ii) in eg i y e i ica ion and ligh weigh un ime alida ion
a e aluable; and (iii) a uni o m diagnos ic signal aids moni o ing and analysis. We
demons a e easibili y on ime se ies and 8-bi g ayscale images, and ou line adap e s
o addi ional modali ies. Domain-speci ic encodings and o ma s emain app op ia e o
hei espec i e asks; he p oposed laye complemen s hem by o e ing a s ic , e i iable
ep esen a ional b idge.
Con ibu ions.
•
A s ic , lossless disc e e
↔
phase mapping wi h nea es -g id decoding and loa 64
s o age, wi h discussion o nume ical conside a ions.
•
The Phase In e change Fo ma (PIF): a minimal schema, un ime alida ion, and
in eg i y checks ia hash_ aw.
2
•A e e ence SDK and CLI (encode/decode/ alida e/κ), plus con o mance es s.
•
Uni o m cohe ence diagnos ics (
κ
and windowed
κ
) applicable ac oss modali ies
wi hou modi ying da a.
•Case s udies on ime se ies and images, and a oadmap o addi ional adap e s.
2 Ma hema ical Founda ions
Alphabe and mapping. Fix an alphabe size
M∈N
,
M≥
2, and de ine he disc e e
alphabe AM={0,1,...,M −1}. The co e mapping is
:AM→[0,2π), (n) = θ=2π
Mn, (3)
wi h decoding by nea es g id poin on he uni o m la ice {2πk/M}M−1
k=0 :
g: [0,2π)→ AM, g(θ) = ˆn= oundM
2πθmod M. (4)
We also use he w ap ope a o
w ap2π
(
·
)mapping angles o [0
,
2
π
)by modulo 2
π
, wi h he
con en ion ha alues nume ically equal o 2πa e se o 0.
Lossless ound- ip (exac a i hme ic). In exac a i hme ic,
g
(
(
n
)) =
n
o all
n∈ AM
. Indeed,
(
n
) = 2
πn/M
is exac ly a la ice poin ; scaling by
M/
(2
π
)yields
n
, and
ounding o he nea es in ege e u ns n( ies do no occu ).
In a iances. Le ∆=2
π/M
be he la ice s ep. Fo any
k∈Z
,
w ap2π
(
θ
+
k
∆)
decodes o (
n
+
k
)
mod M
. Mo eo e , adding mul iples o 2
π
lea es decoding in a ian :
g(w ap2π(θ+ 2πℓ))=g(θ) o all ℓ∈Z.
2.1 Fini e-p ecision analysis (IEEE-754 loa 64)
In implemen a ion,
θ
is s o ed as IEEE-754 loa 64. We analyze co ec ness when
(3)
–
(4)
a e compu ed in bina y64 wi h ound- o-nea es .
We use he s anda d ounding model [
2
]: o a basic ope a ion
◦∈{
+
,−,×, /}
,
l
(
a◦b
)=(
a◦b
)(1 +
δ
)wi h
|δ| ≤ u
, whe e
u
= 2
−53 ≈
1
.
11
×
10
−16
is machine epsilon
(uni oundo ). Fo a sho sequence o
k
such ope a ions, he accumula ed ela i e e o is
bounded by γk=ku/(1 −ku).
3
Encoding e o . Compu e
˜
θ
=
l2π
Mn
. Fo 0
≤n≤M−
1,0
≤θ≤
2
π
. Assuming
(2π)is a ixed bina y64 cons an , and one mul iplica ion and one di ision,
|˜
θ−θ| ≤ γ2θ+| l(2π)−2π|n
M≤C u, (5)
o a modes cons an
C
(empi ically
C <
10 su ices on ypical compile s; he absolu e
e o is O(u)uni o mly because θ≤2π).
Decoding co ec ness condi ion. Le ∆=2
π/M
. Decoding by
(4)
is co ec p o ided
he absolu e e o a decode inpu is less han ∆/2:

˜
θ−θ<∆
2=π
M.(6)
Since
|˜
θ−θ| ≤ Cu
and
π/M ≥π/
2
32 ≈
7
.
3
×
10
−10
o
M≤
2
32
, while
Cu ≲
10
−15
,
inequali y (6) holds wi h a ma gin exceeding 105 o all M≤232.
[Bina y64 co ec ness o
M≤
2
32
] Le
˜
θ
=
w ap2π l
(2
πn/M
)

be compu ed in IEEE-754
bina y64 wi h ound- o-nea es , and le decoding be
ˆn
=
ound
(
M˜
θ/
(2
π
))
mod M
compu ed
in bina y64. Then o all in ege s Mwi h 2≤M≤232 and o all n∈ {0, . . . , M −1},
ˆn=n.
P oo ske ch.
By he ounding model, he absolu e encoding e o
|˜
θ−θ|
is bounded by
Cu
o a small cons an
C
independen o
M
and
n
, since
θ≤
2
π
. The nea es -neighbo la ice
spacing is ∆ = 2
π/M
, so he mid-poin gap is ∆
/
2 =
π/M
. Fo
M≤
2
32
,
π/M ≫Cu
; hus
˜
θ
emains wi hin he Vo onoi cell o he ue la ice poin and ounding eco e s
n
. The
subsequen scaling by
M/
(2
π
)p ese es classi ica ion because i is mono one and compu ed
wi h compa able (smalle ) absolu e e o .
W apping con en ion. We implemen
w ap2π
(
˜
θ
) =
˜
θmod
(2
π
)and, o nume ical
s abili y, map alues nume ically equal o 2
π
(wi hin machine epsilon) o 0 o main ain he
hal -open in e al [0,2π).
2.2 Cohe ence me ic κ
Gi en phases {θj}N
j=1 ⊂[0,2π), de ine he (unweigh ed) ci cula cohe ence
κ=
1
N
N
X
j=1
eiθj
∈[0,1].(7)
4
Fo nonnega i e weigh s wj≥0wi h S=Pjwj>0, he weigh ed e sion is
κw=
1
S
N
X
j=1
wjeiθj
.(8)
We also conside a windowed e sion along an index axis (e.g., ime). Fo window size
W
and hop
H
, de ine windows
Wk
=
{
:
kH ≤ ≤kH
+
W−
1
}
o
k
= 0
, . . . , K −
1whe e
K=(N−W)/H+ 1, cen e s ck=kH + (W−1)/2, and
κ(k)=







1
|Wk|P ∈Wkeiθ ,unweigh ed,
P ∈Wkw eiθ
P ∈Wkw 
,weigh ed (i wa ailable).(9)
I W > N, we de ine a single window W0={0, . . . , N −1}.
3 Phase In e change Fo ma (PIF)
PIF is a compac , minimally cons ained objec desc ibing he phase ep esen a ion and i s
decoding con ex . We model a PIF eco d as a uple
p= (schema, θ, amp,me a),
whe e
θ∈RN
(s o ed as loa 64),
amp ∈ {scala a≥
0
}∪RN
≥0
(op ional weigh ing), and he
emaining ields a e JSON objec s wi h he ollowing seman ics.
3.1 Schema
The schema objec decla es a leas he alphabe :
•schema.alphabe . ype "uin " ( equi ed).
•schema.alphabe .M in ege , 2≤M≤232 ( equi ed).
Op ional, non-no ma i e ields may be included o downs eam use (do no a ec
lossless con e sion), e.g.,
•schema.sampling. s numbe , >0(sampling equency).
•schema.image.{heigh ,wid h,mode} o image-shaped da a.
PIF 1 co e ea s unspeci ied ields as opaque; p oduce s may include addi ional
me ada a ha does no al e he con e sion seman ics.
5

3.2 Nume ic ep esen a ion
•
Phases
θ
: s o ed as IEEE-754 loa 64, w apped o [0
,
2
π
), wi h he w apping con en-
ion o §2.1.
•
Ampli ude
amp
: ei he a nonnega i e scala (in e p e ed as unweigh ed) o a non-
nega i e a ay o leng h N(used as weigh s o κw).
3.3 Me a and in eg i y
The me a objec includes:
•me a.no e s ing, ma ching "no_p ocessing" o "p ocessed:<ops>" ( equi ed).
•me a.hash_ aw
op ional s ing o he o m
"sha256:<64 hex>"
: he SHA-256 o
he o iginal aw by e s eam (e.g., he disc e e inpu a ay).
•me a.codec op ional s ing naming he codec (e.g., S1_phase_code_M256).
•me a.codec_hash
op ional s ing
"sha256:<64 hex>"
iden i ying he codec payload.
When
me a.no e
is
"no_p ocessing"
, he ound- ip in a ian mus hold o he
decla ed M:
decode(encode(x))=x(bi -exac o he alphabe ).
Consume s can e i y in eg i y by decoding o
x
and compa ing
me a.hash_ aw
o
sha256
(
x.by es
).
3.4 Se ializa ion and alida ion
No ma i e on-wi e o ma . PIF 1 uses JSON as he no ma i e on-wi e ep esen a ion
(numbe s as JSON numbe s co esponding o loa 64 in implemen a ions). A MessagePack
ep esen a ion may be p o ided as an op ional, by e-compac mi o ; i mus be seman ically
equi alen o he JSON o m.
Valida ion. Valida ion p oceeds in wo laye s:
1.
Schema check (op ional bu ecommended): JSON Schema alida ion o he doc-
umen shape and basic cons ain s (e.g.,
alphabe . ype="uin "
, bounds on
M
,
nonnega i i y o amp).
2.
Run ime check: load in o a PIF objec wi h s ic checks on nume ic in a ian s
( loa 64 phases w apped o [0,2π), ma ching leng hs o θand a ay amp, e c.).
I me a.hash_ aw is p esen , consume s should e i y i a e decode.
6
De e minism. Gi en ixed
schema.alphabe .M
and
me a.no e="no_p ocessing"
, he
encode/decode ope a ions a e de e minis ic; by Lemma 2.1, bina y64 compu a ions eco e
he o iginal symbols o all M≤232.
4 Implemen a ion
We elease a e e ence implemen a ion a :
h ps://gi hub.com/synq a ech/phaseb idge
The eposi o y p o ides a Py hon SDK, CLI ools, schemas, examples, and con o mance
es s.
4.1 SDK (Py hon)
The SDK exposes he s ic disc e e↔phase codec and co e u ili ies:
•S1PhaseCodec: lossless mapping n↔θwi h nea es -g id decoding; loa 64 s o age.
•PIF: a da aclass o Phase In e change Fo ma eco ds wi h un ime alida ion.
•kappa_ imese ies,kappa_ imese ies_windowed: cohe ence me ics (§2.2).
•U ili ies: SHA-256 helpe s (hash_ aw), d ype selec ion, phase w apping.
A minimal usage example:
om phaseb idge.codec_s1 impo S1PhaseCodec
om phaseb idge.pi impo PIF
om phaseb idge.kappa impo kappa_ imese ies
codec = S1PhaseCodec(M=256)
x = ... # uin a ay in [0..M-1]
schema = {"alphabe ": {" ype": "uin ", "M": 256}}
p = codec.encode(x, schema) # -> PIF ( he a loa 64)
x_ ec = codec.decode(p) # -> o iginal symbols (lossless)
k = kappa_ imese ies(p) # -> cohe ence in [0,1]
4.2 CLI ools
Command-line u ili ies suppo encode/decode/ alida e and diagnos ics:
•pb-encode: aw (bin/cs /npy)→PIF (json/msgpack).
7
•pb-decode: PIF → aw (bin/cs /npy).
•pb- alida e
: schema/ un ime alida ion, decode, hash checks; op ional aw compa -
ison.
•pb-kappa: compu e global o windowed κ.
Example:
# Encode CSV(uin ) -> PIF(JSON)
pb-encode --in se ies.cs --in- m cs --d ype uin 8 --M 256 > se ies.pi .json
# Valida e + compa e wi h aw
pb- alida e --in se ies.pi .json -- aw se ies.cs --in- m cs --d ype uin 8 -- epo json
# (windowed)
pb-kappa --in se ies.pi .json --win 256 --hop 128 -- m cs > kappa_windowed.cs
4.3 Tes ing and con o mance
The es sui e co e s:
•S ic ound- ip in a ian s o decla ed alphabe s (§2).
•κbounds and windowed p o iling on syn he ic signals.
•Schema/ un ime alida ion (PIF loading, w apping, ype checks).
•P ope y-based es s (Hypo hesis) ac oss Mand andom a ays.
Tes s can be ep oduced ia
py es
; p ope y-based es s a e enabled when
hypo hesis
is
ins alled.
5 Expe imen s and Case S udies
We p esen h ee compac case s udies illus a ing lossless ound- ip, in eg i y checks, and
uni o m diagnos ics ac oss modali ies. Rep oduc ion sc ip s a e p o ided in
examples/
and
no ebooks in demo/.
5.1 Time se ies ound- ip and windowed cohe ence
We syn hesize a disc e e ime se ies in [0
, M −
1], encode o PIF, decode o CSV, and e i y
bi -exac equali y and
hash_ aw
consis ency. We also compu e windowed
κ
o illus a e
cohe ence as a simple heal h indica o .
8
Figu e 1: Disc e e (quan ized) ime se ies used in he ound- ip expe imen . Le : signal
o e iew; Righ : zoomed segmen .
9
Re e ences
[1] K. V. Ma dia and P. E. Jupp. Di ec ional S a is ics. Wiley, 2000.
[2]
N. J. Higham. Accu acy and S abili y o Nume ical Algo i hms. SIAM, 2nd edi ion,
2002.
[3]
J.-P. Lachaux, E. Rod iguez, J. Ma ine ie, and F. J. Va ela. Measu ing phase synch ony
in b ain signals. Human B ain Mapping, 8(4):194–208, 1999.
[4] N. I. Fishe . S a is ical Analysis o Ci cula Da a. Camb idge Uni e si y P ess, 1995.
[5]
T. B ay. The Ja aSc ip Objec No a ion (JSON) Da a In e change Fo ma . RFC
8259, IETF, 2017. h ps://www. c-edi o .o g/ c/ c8259
[6]
F. Ye geau. UTF-8, a ans o ma ion o ma o ISO 10646. RFC 3629, IETF, 2003.
h ps://www. c-edi o .o g/ c/ c3629
[7]
Apache Pa que . Columna s o age o ma (p ojec documen a ion).
h ps://pa que .
apache.o g/ (accessed 2025).
[8]
K. Claessen and J. Hughes. QuickCheck: A ligh weigh ool o andom es ing o
Haskell p og ams. In P oc. ICFP, pages 268–279. ACM, 2000.
16