We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Dafne is an Lindenmayer system based on the SATOR square created by User:Miui. It also shares some similarities (namely ternary encoding) with TernLSB.
The formal classification of Dafne is unknown (it is locally concatenative and has more than 2 variables), but the basic framework can be represented a couple of ways where
G = (V, ω, P).
D0L
G' = (V', ω', P')
V' = {R, O, T, A, S, P, E, N}
ω' = ROTAS
P' = { R→D, O→A, T→F, A→N, S→E, P→B, E→R, N→0 }
DP0L
V = {A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0}
ω = A
P = { k → (k)(k+1)(k+2)(k+3)(k+4)(k+5)(k+6) : k ∈ ℤ₂₇ }
T0L( G = (V, ω, P, h)
G = (V, ω, P, h)
V = {A…Z, 0} (ℤ₂₇)
ω = A
P = { k → (k)(k+1)(k+2)(k+3)(k+4)(k+5)(k+6) : k ∈ ℤ₂₇ }
h = boustrophedon fold:
row i kept as-is if i even
row i reversed if i odd
pseudocode provided for verification (generated by Claude)
"""
DAFNE LATTICE — complete construction and verification.
L = (Z^3, M') : even Lorentzian lattice, signature (2,1), det -112.
Extracted as the non-degenerate quotient of the DAFNE mixing matrix M mod 27.
Radical (excluded): Z_27 x Z_3, gens (1,7,1,9,18),(0,9,9,9,0) in Z_27^5.
Run: python dafne_lattice.py -> full verification report.
"""
from fractions import Fraction
from math import gcd, isclose, pi, sqrt
import cmath
# ---------- 1. THE LATTICE ----------
GRAM = [[0,4,7],[4,8,5],[7,5,0]] # M' on basis e1,e2,e3
DET = -112 # = -(2^4 * 7)
SIG = (2,1) # Lorentzian
def B(u,v): return sum(u[i]*GRAM[i][j]*v[j] for i in range(3) for j in range(3))
def Q(v): return B(v,v) # even: Q in 2Z always
# ---------- 2. DUAL BASIS (exact) ----------
def inv3(Mat, den):
adj=[[0]*3 for _ in range(3)]
idx=[(1,2),(0,2),(0,1)]
for i in range(3):
for j in range(3):
r=[x for x in range(3) if x!=i]; c=[x for x in range(3) if x!=j]
m=Mat[r[0]][c[0]]*Mat[r[1]][c[1]]-Mat[r[0]][c[1]]*Mat[r[1]][c[0]]
adj[j][i]=(-1)**(i+j)*m
return [[Fraction(adj[i][j],den) for j in range(3)] for i in range(3)]
GRAM_INV = inv3(GRAM, DET) # columns = dual basis e1*,e2*,e3*
# ---------- 3. STRUCTURE: U(7) ⊥ <112>, glue Z_7 ----------
E1,E2,E3=(1,0,0),(0,1,0),(0,0,1); W=(5,-7,4)
# 7*e2 = 5*e1 + 4*e3 - w (glue relation)
# ---------- 4. DISCRIMINANT FORM D = Z_112, q(k) = 25 k^2 /112 mod 2 ----------
DD=112
def q_disc(k):
x=Fraction(25*k*k,112); return x - 2*(x.numerator//(2*x.denominator))
# ---------- 5. WEIL REP rho: Mp2(Z) -> GL(C[Z_112]) ----------
def rho_T(): # diagonal e^{2 pi i q(k)} ... q in Q/2Z -> e^{pi i * q} convention? use e^{2πi q/2}=e^{πi q}
return [cmath.exp(1j*pi*float(q_disc(k))) for k in range(DD)]
def rho_S(): # Bruinier convention: phase e((b- - b+)/8) = e^{-2 pi i/8}
ph=cmath.exp(-2j*pi/8)/sqrt(DD)
return [[ph*cmath.exp(-2j*pi*(25*j*k)/112) for k in range(DD)] for j in range(DD)]
# ---------- 6. REAL ROOTS & WEYL ----------
R1,R2=(4,-3,1),(5,-2,1) # the only norm-2 lines
CARTAN=[[2,-6],[-6,2]] # det -32: rank-2 hyperbolic KM
def reflect(r,v):
c=B(v,r) # (r,r)=2 so coefficient = c
return tuple(v[i]-c*r[i] for i in range(3))
# ---------- VERIFICATION SUITE ----------
def verify():
ok=True
def chk(name,cond):
nonlocal ok; ok&=cond; print(f" [{'PASS' if cond else 'FAIL'}] {name}")
print("DAFNE lattice verification")
# det & even
det=( GRAM[0][0]*(GRAM[1][1]*GRAM[2][2]-GRAM[1][2]*GRAM[2][1])
-GRAM[0][1]*(GRAM[1][0]*GRAM[2][2]-GRAM[1][2]*GRAM[2][0])
+GRAM[0][2]*(GRAM[1][0]*GRAM[2][1]-GRAM[1][1]*GRAM[2][0]))
chk("det = -112", det==DET)
chk("even (all Q(v) even, spot 20 vecs)", all(Q((x,y,z))%2==0 for x in range(-1,2) for y in range(-1,2) for z in range(-1,2)))
# dual: M * M^-1 = I
I=[[sum(GRAM[i][k]*GRAM_INV[k][j] for k in range(3)) for j in range(3)] for i in range(3)]
chk("GRAM * GRAM_INV = I (exact)", all(I[i][j]==(1 if i==j else 0) for i in range(3) for j in range(3)))
# U(7) + complement
chk("Q(e1)=0, Q(e3)=0, (e1,e3)=7 [U(7)]", Q(E1)==0 and Q(E3)==0 and B(E1,E3)==7)
chk("w=(5,-7,4): Q(w)=112, w ⊥ e1,e3", Q(W)==112 and B(W,E1)==0 and B(W,E3)==0)
chk("glue: 7*e2 = 5e1+4e3-w", all(7*E2[i]==5*E1[i]+4*E3[i]-W[i] for i in range(3)))
# discriminant generator gamma = e1*: order 112, q = 25/112
g=[GRAM_INV[i][0] for i in range(3)]
from math import lcm
o=1
for x in g: o=lcm(o,x.denominator)
qg=sum(g[i]*GRAM[i][j]*g[j] for i in range(3) for j in range(3))
chk("ord(e1*)=112 in L*/L", o==112)
chk("q(e1*) = 25/112", qg-2*(qg.numerator//(2*qg.denominator))==Fraction(25,112))
# MILGRAM: sum e^{pi i q(x)} = sqrt|D| e^{2 pi i sig/8}, sig=b+-b-=1
s=sum(cmath.exp(1j*pi*float(q_disc(k))) for k in range(DD))
tgt=sqrt(DD)*cmath.exp(2j*pi/8)
chk(f"Milgram: Gauss sum = sqrt(112)e^(2πi/8) [sig≡1 mod 8]",
isclose(s.real,tgt.real,abs_tol=1e-9) and isclose(s.imag,tgt.imag,abs_tol=1e-9))
# roots
chk("Q(r1)=Q(r2)=2, (r1,r2)=-6", Q(R1)==2 and Q(R2)==2 and B(R1,R2)==-6)
v=E1
for _ in range(3): v=reflect(R1,reflect(R2,v))
chk("Weyl (s1 s2) preserves Q, infinite order (null orbit grows)", Q(v)==0 and abs(v[0])>1000)
# Weil rep: (ST)^3 = S^2 (i.e., rho respects Mp2 relation) — numeric
import numpy as _np
_k=_np.arange(DD)
_T=_np.exp(2j*_np.pi*25*_k*_k/224)
_S=(_np.exp(-2j*_np.pi/8)/_np.sqrt(DD))*_np.exp(-2j*_np.pi*25*_np.outer(_k,_k)/112)
_ST=_S*_T[None,:]; _lhs=_ST@_ST@_ST; _rhs=_S@_S
_Z=_np.exp(-2j*_np.pi/4)*_np.eye(DD)[:,(-_k)%DD]
e1_=_np.abs(_lhs-_rhs).max(); e2_=_np.abs(_rhs-_Z).max()
chk(f"Weil rep: (ST)^3=S^2=Z (err {e1_:.1e},{e2_:.1e})", e1_<1e-9 and e2_<1e-9)
print("ALL PASS" if ok else "FAILURES PRESENT")
return ok
if __name__=="__main__": verify()
The DAFNE square
The canonical Atom i.e. a DAFNE doorway is L-Zimbu contextual.
CLASS D
CONST A="ROTASPEN"; CONST B="DAFNEBR0";
FUNC m(c CHAR) CHAR
VAR i=A.indexOf(c);
RETURN i>=0?B[(3*i+5)%8]:c;
END
FUNC main()
VAR W="SATOR AREPO TENET OPERA ROTAS".split(" ");
VAR D LIST<STRING>=[];
FOR i IN 0..4
VAR s=W[4-i],o="";
FOR j IN 0..s.len()-1 o+=m(s[j]); OD
D.append(o);
OD
Out.println("¿ĐAFNE?");
WHILE TRUE
VAR s=In.readLine().trim();
VAR ok=TRUE;
FOR i IN 0..s.len()-1 IF A.indexOf(s[i])<0 ok=FALSE; FI OD
IF ok
VAR t="";
FOR i IN 0..s.len()-1 t+=m(s[i]); OD
IF t==D[0]
FOR r IN D Out.println(r); OD
FI
FI
OD
END
END
DAFNE
ABRDN
FR0RF
NDRBA
ENFAD
0D theta conversion operator
SATOR
O
T
A
S
Triadic expansion
(python)
#!SELF-MODIFYING
import re,sys
# ===============
# AXIOM
# ROTAS
# OPERA
# TENET
# AREPO
# SATOR
# ===============
A="ROTASPEN";B="DAFNEBR0"
f=lambda c:B[(3*A.index(c)+5)%8]if c in A else c
g=lambda t:"\n".join("".join(f(c)for c in l)for l in t.split("\n"))
def r():
s=open(__file__,encoding="utf-8").read()
m=re.search(r"AXIOM\n((?:# [A-Z0-9]{5}\n){5})",s)
b=[ln[2:] for ln in m.group(1).splitlines()]
return "\n".join(b),s
def w(b,s):
x="\n".join("# "+l for l in b.split("\n"))+"\n"
s=re.sub(r"(AXIOM\n)(?:# [A-Z0-9]{5}\n){5}",r"\1"+x,s)
open(__file__,"w",encoding="utf-8").write(s)
b,s=r()
if b=="DAFNE\nABRDN\nFR0RF\nNDRBA\nENFAD":
print(b)
else:
nb=g(b)
w(nb,s)
print(nb)
u=[]
for row in s:
for c in row:
if c not in u:u.append(c)
while len(u)<9:u.append(u[-1])
m={i+1:u[i] for i in range(9)}
sr={u[i]:i for i in range(len(u))}
alternating 0/O
C=[0]
def z(x):
if x!=8:return m[x]
C[0]^=1
return "0" if C[0] else "O"
Linear (X)
def X(g):
o=[]
for row in g:
a=[[],[],[]]
for c in row:
t=r[sr[c]] if c in sr else [4]*9
b=[z(x) for x in t]
a[0]+=b[:3];a[1]+=b[3:6];a[2]+=b[6:]
o+=a
return o
for L in X(s):print("".join(L))
2D expansion
Via selfmodifying code, the first iteration yields the BDFBR block. The table describes the matrix multiplication on BDFBR for 2 dimensional expansion.
2D Dafne
Block
Mul
BDFBR
D00BB
F0F0F
BB00D
RBFDB
04837
48345
83753
34531
75310
3D expansion
After two iterations of the selfmodifying code Dafne yields the BDNRA block
BDNRA
DE0BR
N0F0N
RB0ED
ARNDB
the same matmul is applied
04837
48345
83753
34531
75310
4D expansion
Contextual L (Atomic)
LZ
Mod 3
Mod 27
CLASS DafneCycle
#Z(ABCDEFGHIJKLMNOPQRSTUVWXYZ0)
CONST A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0"
CONST M = [
[0,4,8,3,7],
[4,8,3,4,5],
[8,3,7,5,3],
[3,4,5,3,1],
[7,5,3,1,0],
]
CONST DAFNE = [
"DAFNE",
"ABRDN",
"FR0RF",
"NDRBA",
"ENFAD",
]
FUNC mul5x5(block : String[]) -> String[]
VAR out : String[] = []
FOR i IN 0 .. 4
VAR row : String = ""
FOR j IN 0 .. 4
VAR c : Char = block[i][j]
VAR idx : Int = A.indexOf(c)
VAR off : Int = M[i][j]
row += A[(idx + off) % A.len()]
END
out.append(row)
END
RETURN out
END
FUNC main()
VAR b : String[] = DAFNE
FOR k IN 0 .. 26
IO.print("state " + k + "\n")
FOR r IN b
IO.print(r + "\n")
END
IO.print("\n")
b = mul5x5(b)
END
END
END
DAFNE
ABRDN
FR0RF
NDRBA
ENFAD
BDFBR
D00BB
F0F0F
BB00D
RBFDB
BDNRA
DE0BR
N0F0N
RB0ED
ARNDB
Yields a 27-state contextual (to L-Zimbu) subset of Dafne.
As a Vedic-square it represents a 25-dimensional torus.
The ROTASPEN dictionary creates a "Dafne square" which is a condensed Vedic square.
The vedic square can be observed via Vedic_square.pgm beloq
ROTAS vedic(Dafne)
A dafne circuit cyclic tag automaton.
"Daffine" expansion cycle
DAFNE mod-27 affine map
Rotor
as well as a DAFNE rotor
Dafne rotor
Interpreter
Currently there is just a 1 dimensional interpreter for the Dafne square basis:
basis interpreter
#imp/ort sys¿ĐAFNE
#Đeffne = "SATOR AREPO TENET OPERA ROTAS".split()
#Đict = dict(zip("ROTASPEN", "DAFNEBR0"))
#D = ["".join(Đict[c] for c in Đeffne[4 - i]) for i in range(5)]
#print("¿ĐAFNE?")
#for line in sys.stdin:
s = line.strip()
if all(c in Đict for c in s) and "".join(Đictz[c] for c in s) == D[0]:
print(*D, sep="\n")
Below is a cocktail-napkin sketch of what a 2D Dafne-based program might look like.
(Conceptualized via the netpbm magic number sets)
"primitive+1Dimensional PATERNOS xcross"
A Dafne turtle can run the mod27 vedic ring.
there is a working version of the .gif in turtle canvas Project Dafneturtles depo
Magic square
Dafne is also a magic square.
legend
5x5
20x35
Dafne L-system mod-27 stable block
Math recap
----------
Alphabet : A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0" (indices 0..26)
Seed : 5x5 matrix DAFNE / ABDRN / FR0RF / NDRBA / ENFAD
Mixing M : 5x5 integer matrix (see below)
Closed-form for the stable block (verified against the reference block):
block[R*5+r, C*5+p] = (seed[r,p] + (C + 7*R + t) * M[r,p]) % 27
where
R = row // 5, r = row % 5
C = col // 5, p = col % 5
t = animation frame (0-indexed); t=0 gives the static stable block.
The scalar k = (C + 7R) mod 27 is the "phase" — it hits all 27 values
exactly once across the 4x7 grid of 5x5 sub-blocks (with one repeat at
the wrap point, confirming the toroidal period of 27).
"""
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0" # 27 characters, indices 0..26
SEED_ROWS = [
"DAFNE",
"ABRDN",
"FR0RF",
"NDRBA",
"ENFAD",
]
SEED = [[ALPHABET.index(c) for c in row] for row in SEED_ROWS]
M = [
[0, 4, 8, 3, 7],
[4, 8, 3, 4, 5],
[8, 3, 7, 5, 3],
[3, 4, 5, 3, 1],
[7, 5, 3, 1, 0],
]
# 27 perceptually distinct colors, one per alphabet character
PALETTE = [
(70, 130, 180), # A - steel blue
(60, 179, 113), # B - medium sea green
(255, 165, 0), # C - orange
(220, 20, 60), # D - crimson
(147, 112, 219), # E - medium purple
(255, 105, 180), # F - hot pink
(210, 105, 30), # G - chocolate
(0, 128, 0), # H - green
(100, 149, 237), # I - cornflower blue
(255, 215, 0), # J - gold
(64, 224, 208), # K - turquoise
(255, 69, 0), # L - orange red
(138, 43, 226), # M - blue violet
(0, 206, 209), # N - dark turquoise
(154, 205, 50), # O - yellow green
(255, 20, 147), # P - deep pink
(0, 191, 255), # Q - deep sky blue
(205, 133, 63), # R - peru
(50, 205, 50), # S - lime green
(255, 140, 0), # T - dark orange
(123, 104, 238), # U - medium slate blue
(46, 139, 87), # V - sea green
(176, 48, 96), # W - maroon
(0, 139, 139), # X - dark cyan
(189, 183, 107), # Y - dark khaki
(178, 34, 34), # Z - firebrick
(40, 40, 40), # 0 - near black
]
WHILE q.len() > w
IF r[0] == '0'
q = q[1 .. q.len()]
ELSE
r = r[1 .. r.len()] + r[0]
IF q[0] == '1'
q += r[0]
FI
FI
r = r[1 .. r.len()] + r[0]
Out.println(q)
OD
where q is derived from this calculator.
q = atoma = "0010111101100110111100101000101"
r = atomb = "00101011000110000111101000110101110101000101011101"
and the axiomatic system
FUNC dafneSquare() LIST<STRING>
VAR axioms = ["SATOR", "AREPO", "TENET", "OPERA", "ROTAS"]
VAR A = "ROTASPEN"
VAR B = "DAFNEBR0"
VAR m MAP<CHAR,CHAR> = {}
FOR i IN 0 .. A.len()-1
m[A[i]] = B[i]
OD
VAR out LIST<STRING> = []
FOR i IN 0 .. 4
VAR row = ""
VAR w = words[4 - i]
FOR j IN 0 .. w.len()-1
row += m[w[j]]
OD
out.append(row)
OD
RETURN out
END
FUNC scalarToBits(n INT) STRING
RETURN n.toString(2)
END
FUNC deriveQR(bits STRING) TUPLE<STRING,STRING>
VAR q = bits[0 .. 31]
VAR r = bits[31 .. 84]
RETURN (q, r)
END
Kate Worley's 12-bit rainbow Is the palette found Key section of the#n-Dimensional expansion table and is suggested to keep transition functions low-degree in color-space.