A mailing list recently sent me a note saying: “The great 7th century Korean Master Ui-Sang condensed Mahayana Buddhist teachings into 210 Chinese characters arranged in a maze-like pattern, known as the Ocean Seal Samadhi”. Wow! I’ve never heard that before, intriguing. Since we’ve recently done so much math work with mazes, puzzles and word games, we might also sharpen this statement, by saying how Ui-Sang’s pattern really is not a maze for at least two distinct reasons.
At first, the poem was not easy to find, even though it is mentioned in a fairly recent Stanford article on "Korean Philosophy", which says alternatively: “Originally titled, Diagram of the Dharmadhātu of the One Vehicle of Hwaŏm (Hwaŏm ilsŭng pŏpgyedo 華嚴一乘法界圖), the Ocean Seal Diagram (Sāgaramudrā Maṇḍala), is arranged like a wavelike form, which symbolizes the Dharma Realm together with the Hwaŏm teaching of the “six marks” (yuksang): . . .” Indeed, the image included does look like water waves or whirlpools. However, this is only true to an extent. The hard edges and sharp corners make it look more like earth or space than water.
The almost-inconsequential shape of the poem makes most of what we will care about in this present memo. Whether or not the poem is meant to consist of 七言絕句 stanzas, the Huayen Lotus Society of Taipei have arranged this form in their division of the poem into phrases of seven characters, here transcribed:
In[]:=
ctext="法性圓融無二相,諸法不動本來寂。無名無相絶一切,證智所知非餘境。真性甚深極微妙,不守自性隨緣成。一中一切多中一,一即一切多即一。一微塵中含十方,一切塵中亦如是。無量遠劫即一念,一念即是無量劫。九世十世互相即,仍不雜亂隔別成。初發心時便正覺,生死涅槃常共和。理事冥然無分別,十佛普賢大人境。能仁海印三昧中,繁出如意不思議。雨寶益生滿虛空,衆生隨器得利益。是故行者還本際,叵息妄想必不得。無緣善巧捉如意,歸家隨分得資糧。以陀羅尼無盡寶,莊嚴法界寬寶殿。窮坐實際中道床,舊來不動名爲佛。";
There is some disagreement between the Chinese and Stanford, about the exact extracted form, whether there should be 30 lines or fewer. Someone with better language skills might be able to tell by scansion and rhyme scheme if the poem has any intrinsic line structure to it. This question matters less than it usually does, because the 210 characters cast into a 14x15 matrix. The matrix itself carries extra geometric information, which can be encoded as a compass path, here in compressed form:
In[]:=
kpath={​​{"W",6},{"S",5},{"E",4},{"N",1},{"W",3},​​{"N",3},{"E",4},{"S",1},{"W",3},{"S",1},​​{"E",3},{"S",3},{"W",6},{"N",13},{"E",5},​​{"S",5},{"W",3},{"N",3},{"E",1},{"S",2},​​{"E",1},{"N",3},{"W",3},{"S",5},{"E",5},​​{"N",6},{"E",8},{"S",5},{"W",6},{"N",3},​​{"E",4},{"S",1},{"W",3},{"S",1},{"E",4},​​{"N",3},{"W",6},{"S",5},{"E",7},{"S",1},​​{"W",6},{"S",5},{"E",5},{"N",3},{"W",3},​​{"S",1},{"E",2},{"S",1},{"W",3},{"N",3},​​{"E",5},{"S",5},{"W",7},{"N",5}​​};
The path has 54 turns when looping through on repeat:
In[]:=
Length@kpath
Out[]=
54
Of course, the looping is definitely part of the chanting practice. The condensed form expands and then accumulates into the geometric primitive, a list of coordinate pairs:
In[]:=
kline=With[{dir=Association[Thread[Rule[​​{"E","N","W","S"},​​ReIm[Exp[IPi/2#]]&/@Range[0,3]]]]},​​FoldList[Plus,{0,0},Catenate[​​Map[Table[dir[#[[1]]],#[[2]]]&,kpath]]]​​];
The line has exactly the same length as the character path:
In[]:=
SameQLength[kline],Length​​DeleteCasesCharacters[ctext],"\n"",""。"​​
Out[]=
True
To make PathGraph function correctly, we need to disambiguate the signs by their order of appearance. A straight linear indexing would be fine, but adding a counter reveals more about constituency:
In[]:=
cpathCounted=Module​​{rec=Association[],int},​​MapFunction[let,​​int=Lookup[rec,let,0];​​int=int+1;​​rec[let]=int;​​{let,int}​​],DeleteCasesCharacters[ctext],"\n"",""。"​​​​​​
Out[]=
法,1,性,1,圓,1,融,1,無,1,二,1,相,1,諸,1,法,2,不,1,動,1,本,1,來,1,寂,1,無,2,名,1,無,3,相,2,絶,1,一,1,切,1,證,1,智,1,所,1,知,1,非,1,餘,1,境,1,真,1,性,2,甚,1,深,1,極,1,微,1,妙,1,不,2,守,1,自,1,性,3,隨,1,緣,1,成,1,一,2,中,1,一,3,切,2,多,1,中,2,一,4,一,5,即,1,一,6,切,3,多,2,即,2,一,7,一,8,微,2,塵,1,中,3,含,1,十,1,方,1,一,9,切,4,塵,2,中,4,亦,1,如,1,是,1,無,4,量,1,遠,1,劫,1,即,3,一,10,念,1,一,11,念,2,即,4,是,2,無,5,量,2,劫,2,九,1,世,1,十,2,世,2,互,1,相,3,即,5,仍,1,不,3,雜,1,亂,1,隔,1,別,1,成,2,初,1,發,1,心,1,時,1,便,1,正,1,覺,1,生,1,死,1,涅,1,槃,1,常,1,共,1,和,1,理,1,事,1,冥,1,然,1,無,6,分,1,別,2,十,3,佛,1,普,1,賢,1,大,1,人,1,境,2,能,1,仁,1,海,1,印,1,三,1,昧,1,中,5,繁,1,出,1,如,2,意,1,不,4,思,1,議,1,雨,1,寶,1,益,1,生,2,滿,1,虛,1,空,1,衆,1,生,3,隨,2,器,1,得,1,利,1,益,2,是,3,故,1,行,1,者,1,還,1,本,2,際,1,叵,1,息,1,妄,1,想,1,必,1,不,5,得,2,無,7,緣,2,善,1,巧,1,捉,1,如,3,意,2,歸,1,家,1,隨,3,分,2,得,3,資,1,糧,1,以,1,陀,1,羅,1,尼,1,無,8,盡,1,寶,2,莊,1,嚴,1,法,3,界,1,寬,1,寶,3,殿,1,窮,1,坐,1,實,1,際,2,中,6,道,1,床,1,舊,1,來,2,不,6,動,2,名,2,爲,1,佛,2
For example, the most common non-trivial character is the space matrix itself, “無”, sometimes phonetically “wu”, and other times phonetically “mu”, occasionally meaning “Absence”:
In[]:=
Take[counts=ReverseSort[Map[Max,GroupBy[cpathCounted,First->Last]]],10]
Out[]=
一11,無8,中6,不6,即5,切4,得3,寶3,生3,是3
This is not surprising at all, considering our previous analysis of older Chinese source texts. Perhaps more surprising is the prominent placement of 中 (center), and the half-result found when counting 相 (mark):
In[]:=
counts["相"]
Out[]=
3
According to Stanford there should be six of these. Have some of them been darkened beyond the point of reading and writing? An interesting question, but again not our purpose here.
We’re next going to make a path graph, but not with the automatic embedding:
In[]:=
cpg=PathGraph[cpathCounted,DirectedEdges->True]
Out[]=
Instead, the historically-correct embedding is obtained by matching graph vertices to coordinate pairs of the geometric line:
In[]:=
ossg=Graph[cpg,VertexCoordinates->kline,​​PerformanceGoal->"Quality",​​VertexSize->2/3,VertexStyle->Directive[​​Opacity[0],EdgeForm[Opacity[0]]],​​VertexLabels->{x_:>Placed[​​Style[First[x],White,16],Center]},ImageSize->600,​​Background->Darker[Red,.6],EdgeStyle->Directive[LightGray,Opacity[.5]]​​]
Out[]=
This is a nice result, and a minimal form. When removing the directional arrows, we can capture the same path graph by adding walls:
At this point, the diagram begins to look more like a maze, but there is really no way to get lost: either you move in the forward or reverse direction along the cycle. With no erroneous cycles, no dead ends, and two disconnected components, this graph is lacking some key features that define what it means to be a maze.
One option is to take this pattern into 2.5 dimensions, as we had explored previously. If the walls are raised, and given descending stairs onto the ground level where the characters are inscribed, then we can probably get a decent maze, let’s try it.
First we find terminals of the walls:
Then we connect the terminals to the four nearest characters, and we’ve immediately created a states adjacency graph with many cycles to get lost in:
Can anyone take one of these topological graphs and make the geometric picture what the corresponding maze would look like in 2.5 dimensions? Or if no, does anyone have a better idea how to take the geometry of the Sāgaramudrā Maṇḍala and give it extra erroneous cycles and dead ends? If yes, please leave a comment below showing what your artistic process can do!

CITE THIS NOTEBOOK

Maze graphs from a Chinese-Korean text​
by Brad Klee​
Wolfram Community, STAFF PICKS, August 28, 2024
​https://community.wolfram.com/groups/-/m/t/3259584