Deciphering the code of
the novel “The Dancing Men”
Katsuhiko MURAKAMI
Fujitsu Ltd,
Kanagawa, Japan
murakami.ktk@gmail.com

Aoi KISHIDA
Kobe City Nishi-Kobe Medical Center,
Kobe, Japan
aoi.kishida@gmail.com

Sayaka MATSUMOTO
Office of Strategy and Planning,
Tokyo Institute of Technology,
Tokyo, Japansyma@irds.titech.ac.jp

Kunihiko TAKAMATSU
Office of Strategy and Planning,
Tokyo Institute of Technology,
Tokyo, Japanktakamatu@irds.titech.ac.jp

Abstract-. This study examines a method for deciphering thehandwritten dancing men graphic shown in "The Dancing Men."
We attempted to reproduce and explain Holmes's reasoning forthe graphic cipher by using a mathematical programming
approach. Moreover, we studied the validity of Holmes’sreasoning and demonstrated a procedure to decipher the cipher
computationally. Herein, we propose a mathematical solution toclarify the ambiguity in Holmes' conjecture. Although theproposed method has not been implemented, its feasibility isconfirmed through partial data creation and analysis.
Keywords-integer linear programming, image processing,simulation, Wasserstein distanceI.

Hibiki ITO
University of Helsinki,Helsinki, Finland
2001hibiki15@gmail.com

INTRODUCTION

To establish the frequency of a character or image, it isnecessary to determine whether similar images indicate the samecharacters. However, as the images of the dancing men are
handwritten and Holmes's position is that he does not know theidentification rules, it is unknown whether two images are thesame just because they are similar; in a sense, all the images fordifferent characters are similar. In the novel, this is consideredself-evident. However, it is unknown to the machine. Therefore,
the second item to consider is how to determine whether thepattern of the dancing men in the graphic cipher is the samecharacter.
I.
METHOD
To test the inference by character frequency, we first obtained
the frequencies of 26 characters of the general text alphabet. The
text data were obtained from Wikipedia (approximately 11billion characters), then the probability of E being the characterwith the highest frequency in the string in question and theprobability of being another character were calculated byrunning 1,000 simulations.

The objective of this challenge (workshop) s to develop
explainable artificial intelligence (XAI), that is, an AI systemthat answers questions with explanations. The task here was toinfer the truth of a case (reproducing Holmes's reasoning), whileproviding a reasonable explanation based on the relevant open
knowledge graph. Our analysis focused on the decipherment of
the handwritten graphic cipher in the novel "The Dancing Men"
Next, to examine the similarity of the images in terms ofby Arthur Conan Doyle. We did not use knowledge graphs in
representing the same character, the features of the images were
基本的な問題設定と概要this study. Instead, we considered a method to reproduce andexamined by the human eye. The assumption was that if one canexplain Holmes's reasoning by a computational and statisticalfind rules to identify characters using the features, the judgement◼ 物語「踊る人形」では、下図の6個のメッセージが順番に提示される。
approach.
for identity and explanation is valid.
◼ 人形の下に書かれたアルファベットは正解を示す。人形1つと文字In "The Dancing Men," six encoded messages are presented 1つが、図のように対応することが物語後半で解明される。
in sequence, as shown in Figure 1. The correct alphabet is shown
below the images. One image code corresponds to one character,which is called a "substitution cipher" and is a premise within
the novel. As the sixth sentence is not used for Holmes’sreasoning, it is better to decipher without considering it. Holmes
gave several reasons (hypotheses) for the plausibility of the②③①
deduction he reached: first, "the frequency of characters issimilar in the cipher and in general writing;" second, "names ofinterested parties are likely to be used." These hypotheses seem⑤④
to be effective because of their high objectivity.
First, we question the extent to which the character
frequency information can be used for decoding.

⑥Fig. 1 Graphic code (image data from [1])4XXX-XXXX-XXXX-XXXX-XX/XX/XX/$XX.00 ©20XX IEEE

Copyright 2019 FUJITSU LIMITED

(a)

(b)

(c)

Fig. 4 Three pairs of similar images. Are these identical characters?

Fig. 2 Frequencies of alphabet in Wikipedia (11,055,558,613 characters) by
our analysis: x-axis is alphabet, and y-axis is frequency.

In addition, when determining and explaining that a certain
image is a certain character, a characteristic marker and its ruleare necessary. Therefore, the items that can be used as landmarks
for each image are prepared as data in table format.
II.

RESULTS AND DISCUSSION

Of the 26 characters, the most frequent were, as in the novel,e, followed by a, t, i, and n, in that order. The simulation resultsof the generation of a 15-character string based on this showedthat e ranked highest (appeared the most frequently) in only 50%
of cases, and a and t ranked highest in more than 40% of cases:
there were many cases in which multiple characters were ranked
highest, that is, tied. Therefore, Holmes' method (assumption)
where the character with the highest number of occurrences isprobably e, is only true in half of the cases. Therefore, otherpossibilities should be explored for a good general image cipher
deciphering method.

・・

Next, we examined the criteria for the different characters inthe images. Figures 2(a) and 2(b) are considered to be the same,
although some of their features are different. In decoding theimages, Holmes inferred that the flag is a word separator,
although this is a self-serving assumption we believe is notconvincing. Figure 2(c) is a different image. As the correctinterpretation allows one to ignore the flag in images, it isunsurprising that we consider that there is no difference between
the two images, resulting in the code being interpreted as thesame. As mentioned above, it is difficult to determine whether
these graphic images should be considered identical or distinct.
To address this issue, we constructed a feature table of thedancing men images. For the right and left arms, we coded threefeatures: presence/absence, bend/extension (if present), andup/down (if curved); for the right and left legs, we constructed
トップ４文字(e,a,t,I)が頻度の順で何位になるかシミュレーション
two features—hipbend/extension and knee bend/extension; forbodyorientation,
one feature—up/down—for the flag, and two◼ １：順位の分布をプロット
features—presence/absence and right/left. A total of 13 features◼ ２：円グラフで割合を検証した（）
were assigned to all 76 characters, all of which could be coded◼ シミュレーション：先の分布で多項分布、回数は1000回
with binary values. If all these possibilities are explored thendecoded, it will be possible to correctly determine and explain
px which features are used to produce the same character.

An alternative solution to determine the identity of images isto calculate the similarity measure between each pair of images,
and use the similarity measure in reasoning. This type ofapproach does not require the manual discrete annotation
described above and has the advantage that there are no arbitrary
factors in terms of the presence or absence of features, except
for threshold values and parameters of the similarity measures.
The similarity measures applicable here require 1) robustness
for rotation, scales, and thickness of lines, and 2) flexibility todetermine rules to identitcal images depending on the variety ofall images. We consider that Wasserman distance might be moresuitable considering the above requirements.
9Copyright 2019 FUJITSU LIMITED

Although we can find a correspondence between an image
and a character with the above conditions alone, we have not yet
verified whether it is a meaningful string or not. Therefore, weshould make a relatively small dictionary (a list of candidatewords). We will use a method to check highly possible stringsin the dictionary.
Based on the above, we propose a decoding method using an
integer optimization problem. The score function to be
maximized is𝑓(𝑥) = 𝑀 + 𝐷
where 𝑀 is the agreement score based on the correspondence
between image features (or similarity) and characters, and 𝐷 is
the word score based on the used word in the dictionary. The
agreement score consists of binary variable 𝑚𝑖,𝑗 , whichindicates that feature 𝑗 is used by image 𝑖 (26 characters and 76
images), and binary variable 𝑢𝑘,𝑙 , which indicates that image 𝑖corresponds to character 𝑗 . By maximization of 𝑓(𝑥) , thesolution leads to the deciphering and good explanation.
In this proposal, we outline a procedure for computationallydecrypting a cipher. The part of the mathematical procedure forsolving the cryptographic problem is an existing optimization
method. We have defined and mapped the cryptanalysis
problem solved by Holmes in the novel to a mathematicalproblem that is as general as possible. The features of the method
are as follows: the calculation is squeezed by the dictionary toachieve a low amount, context consideration is included in thescore of likely words, and the method can answer the question"What are the partial features to identify the dancing mencharacter?” Theoretically, Holmes' estimated answer should beobtained as a somewhat high-scoring solution. At present, wehave not yet implemented the system. We would like to continue
working on it and verify its applicability throughexperimentation
REFERENCES

EATI

Fig. 3 Statistics of ranks of high frequency by the characters.
8Copyright 2019 FUJITSU LIMITED[1]The Arthur Conan Doyle Encyclopedia, "TheAdventure of the Dancing Men," 1903. https://www.arthurconandoyle.com/index.php?title=The_Adventure_of_the_Dancing_Men (accessed Nov. 17, 2022).