comparison docs/spec/spec.tex @ 547:5a248cedd3e9

Add the latex sources to the AudioDB spec document
author mas02md
date Wed, 11 Feb 2009 10:42:23 +0000
parents
children dfeb5ef768da
comparison
equal deleted inserted replaced
537:5da228727a2d 547:5a248cedd3e9
1 \documentclass[11pt]{article}
2 \usepackage{oz,times}
3
4 \usepackage{tikz}
5 \usetikzlibrary{arrows}
6 \usetikzlibrary{calc}
7
8 \title{A Formal Framework for Content-based Retrieval}
9 \author{Mark d'Inverno and Christophe Rhodes}
10
11
12 \begin{document}
13 \maketitle
14
15
16 %%\begin{gendef}[X]
17 %% concat : (\seq (\seq X)) \fun (\seq X)
18 %%\where
19 %% \forall xs : \seq X; xss : \seq (\seq X) @ \\
20 %%\t2 concat~ ((\langle xs \rangle) \cat xss) = xs \cat
21 %%(concat~xss)
22 %%\end{gendef}
23
24 %% \begin{gendef}[X]
25 %% nfront : \nat \fun (\seq X) \fun \seq (\seq X) \\
26 %% \where
27 %% \forall n : \nat ; xs : \seq X @ \\
28 %% n > \# xs \implies nfront ~n~xs = \langle \rangle \land \\
29 %% n \leq \# xs \implies nfront~n~xs = \\
30 %% \t2 (\langle (0 \upto n-1) \dres xs \rangle) \cat (nfront~n~(tail~xs))
31 %% \end{gendef}
32
33 \section{The System Instance}
34
35 \newcommand{\mylet}{\methrel{\sf Let}}
36 \newcommand{\FV}{\mathrel{~FV}}
37 \newcommand{\V}{\mathrel{~FV^{d}}}
38 \newcommand{\U}{\mathrel{~FV^{1}}}
39 \newcommand{\R}{\mathrel{~R}}
40
41 \newcommand{\mylog}{\mathrel{ln}}
42
43 \begin{enumerate}
44
45 \item \textsf{Track} - original media.
46
47 We define the set of all such tracks.
48
49 \begin{flushright}
50 \begin{tikzpicture}
51 \input track.tikz
52 \end{tikzpicture}
53 \end{flushright}
54
55 \begin{zed}
56 [Track]
57 \end{zed}
58
59 %% \begin{zed}
60 %%\R == \nat
61 %% \end{zed}
62
63 %% \begin{axdef}
64 %% \mylog : \R \fun \R
65 %% \end{axdef}
66
67
68
69
70 % For every track it is possible to determine the lenth.
71
72 % \begin{axdef}
73 % lenth : Track \fun Time
74 % \end{axdef}
75
76 % For every track it is possible to determine the lenth.
77
78 % \begin{axdef}
79 % lenth : Track \fun Time
80 % \end{axdef}
81
82 \item \textsf{Catalogue} - a non-empty list of tracks.
83
84 % A catalogue is typically generated for a specific \emph{use case}.
85
86 \begin{flushright}
87 \begin{tikzpicture}
88 \draw (-3,-3) rectangle (3,3);
89 \foreach \y/\xscale in {2/1,1/1.02,0/0.87,-1/0.95} {
90 \begin{scope}[yshift=\y cm]
91 \begin{scope}[xscale=\xscale]
92 \input track.tikz
93 \end{scope}
94 \end{scope}
95 }
96 \draw node at (0,-2) {\vdots};
97 \end{tikzpicture}
98 \end{flushright}
99
100 \begin{zed}
101 Catalogue == \seq_1 Track
102 \end{zed}
103
104 \item \textsf{Collection} - a set of catalogues where each track in each catalogue is associated with a unique name.
105
106 In a collection, each track has a unique \textsf{TrackName}. We define the injective function $name$ to do this.
107
108 \begin{zed}
109 [TrackName]
110 \end{zed}
111
112 \begin{schema}{Collection}
113 collection : \power Catalogue \\
114 tracks : \power Track \\
115 name : Track \inj TrackName
116 \where
117 tracks = \{ cat : collection; t : Track | t \in (\ran cat) @ t \} \\
118 \dom name = tracks
119 \end{schema}
120
121
122
123
124 \item \textsf{Time} - the set of non-negative reals.
125
126
127 \begin{zed}
128 Time == \R
129 \end{zed}
130
131
132
133
134
135 \item \textsf{Interval} - defined as a continuous set of real numbers, represented as an ordered pair of reals with the second of the pair strictly greater.
136
137 \begin{flushright}
138 \begin{tikzpicture}[>=stealth]
139 \draw (0,0.8) rectangle (0.4,1);
140 \fill (0.2,0.9) ellipse (0.05);
141 \draw[->] (0.2,0.9) -- (0.1,0.2);
142 \draw[->] (0.2,0.9) -- (0.55,0.2);
143 \draw[very thick] (0.1,0.2) -- (0.55,0.2);
144 \draw[o->] (-0.5,0.2) -- (1,0.2) node[anchor=north west] {\small $\mathbb{R}$};
145 \end{tikzpicture}
146 \end{flushright}
147
148 \begin{zed}
149 Interval == \{ t_1, t_2 : Time | t_2 > t_1 @ (t_1, t_2) \}
150 \end{zed}
151
152 \item \textsf{Interval Index} - list of intervals such that the start of each successive interval strictly increases. Intervals may be overlapping.
153
154 The predicate below states that for any consecutive intervals in an interval index $i_j$ and $i_{j+1}$, that $i_j$ starts before $i_{j+1}$.
155
156 \begin{flushright}
157 \begin{tikzpicture}[>=stealth]
158 \draw (0,0.8) rectangle (1.6,1);
159 \draw (0.4,0.8) -- (0.4,1);
160 \draw (0.8,0.8) -- (0.8,1);
161 \draw (1.2,0.8) -- (1.2,1);
162 \fill (0.2,0.9) ellipse (0.05);
163 \fill (0.6,0.9) ellipse (0.05);
164 \fill (1.0,0.9) ellipse (0.05);
165 \fill (1.4,0.9) ellipse (0.05);
166 \draw[->] (0.2,0.9) -- (0.1,0.2);
167 \draw[->] (0.2,0.9) -- (0.55,0.2);
168 \draw[->] (0.6,0.9) -- (0.55,0.2);
169 \draw[->] (0.6,0.9) -- (0.7,0.2);
170 \draw[->] (1.0,0.9) -- (0.9,0.2);
171 \draw[->] (1.0,0.9) -- (1.3,0.2);
172 \draw[->] (1.4,0.9) -- (1.2,0.2);
173 \draw[->] (1.4,0.9) -- (1.5,0.2);
174 \draw[o->] (-0.5,0.2) -- (2,0.2) node[anchor=north west] {\small $\mathbb{R}$};
175 \end{tikzpicture}
176 \end{flushright}
177
178 \begin{zed}
179 IntervalIndex == \iseq Interval \\ \\ \\
180 \end{zed}
181
182 \[ \forall i : IntervalIndex; i_j, i_{j+1} : Interval @ \\
183 \t3 \langle i_j, i_{j+1} \rangle \inseq i \implies first~ i_j \leq first ~ i_{j+1}
184 \]
185
186 \item \textsf{Continuous Interval Index - CII} - there are no consecutive intervals $i_j$ and $i_{j+1}$ in the index where the second element of $i_j$ is strictly less than the first element of $i_{j+1}$.
187
188 \begin{flushright}
189 \begin{tikzpicture}[>=stealth]
190 \draw (0,0.8) rectangle (1.6,1);
191 \draw (0.4,0.8) -- (0.4,1);
192 \draw (0.8,0.8) -- (0.8,1);
193 \draw (1.2,0.8) -- (1.2,1);
194 \fill (0.2,0.9) ellipse (0.05);
195 \fill (0.6,0.9) ellipse (0.05);
196 \fill (1.0,0.9) ellipse (0.05);
197 \fill (1.4,0.9) ellipse (0.05);
198 \draw[->] (0.2,0.9) -- (0.1,0.2);
199 \draw[->] (0.2,0.9) -- (0.55,0.2);
200 \draw[->] (0.6,0.9) -- (0.55,0.2);
201 \draw[->] (0.6,0.9) -- (0.9,0.2);
202 \draw[->] (1.0,0.9) -- (0.7,0.2);
203 \draw[->] (1.0,0.9) -- (1.3,0.2);
204 \draw[->] (1.4,0.9) -- (1.2,0.2);
205 \draw[->] (1.4,0.9) -- (1.5,0.2);
206 \draw[o->] (-0.5,0.2) -- (2,0.2) node[anchor=north west] {\small $\mathbb{R}$};
207 \end{tikzpicture}
208 \end{flushright}
209
210 %% \begin{zed}
211 %% ContinuousIntervalIndex == IntervalIndex
212 %% \end{zed}
213
214 %%unchecked
215 \begin{zed}
216 ContinuousIntervalIndex == \\
217 \t1 \{ ii : IntervalIndex; i_j,
218 i_{j+1}: Interval | \\
219 \t3 \langle i_j, i_{j+1} \rangle \inseq ii \implies second ~ i_j \geq first ~ i_{j+1}@ ii \}
220 \end{zed}
221
222
223 \item A \textsf{Duration} is an amount of time.
224
225 \begin{zed}
226 Duration == Time
227 \end{zed}
228
229 \item The \textsf{Track Duration} is the duration of a track. It is the difference between the \emph{end} time and \emph{start} time of the track.
230
231 \begin{axdef}
232 trackduration : Track \fun Duration
233 \end{axdef}
234
235 \item \textsf{Interval Duration} is the duration of an interval. It is calculated by subtracting the first element of the interval from the second element.
236
237 \begin{axdef}
238 intervalduration : Interval \fun Duration
239 \where
240 \forall i : Interval @ intervalduration ~ i = second ~ i - first ~ i
241 \end{axdef}
242
243
244 \item \textsf{Index Duration} is the duration of a Continuous Interval Index. It is calculated by subtracting the first element of the first interval from the second element of the last interval.
245
246
247 \begin{axdef}
248 indexduration : ContinuousIntervalIndex \fun Time
249 \where
250 \forall cii : ContinuousIntervalIndex @ \\
251 \t1 indexduration~cii = second (last~cii) - first (head~cii)
252 \end{axdef}
253
254 \item \textsf{Segmenter} - a process which computes an interval index for any track, represented as a function which maps any track to an interval index.
255
256 \begin{flushright}
257 \begin{tikzpicture}
258 \input interval-index.tikz
259 \input segmented-track.tikz
260 \end{tikzpicture}
261 \end{flushright}
262
263 \begin{zed}
264 Segmenter == Track \fun IntervalIndex \\
265 \end{zed}
266
267 \item The \textsf{Length} of an interval index is the number of intervals contained within it.
268
269 \begin{axdef}
270 length : IntervalIndex \fun \nat
271 \where
272 \forall ii : IntervalIndex @ length~ii = \# ii
273 \end{axdef}
274
275 % \section{Features}
276
277 \item \textsf{Feature Name} - a name describing a feature.
278
279 \begin{zed}
280 [FeatureName]
281 \end{zed}
282
283 \item \textsf{Dimension} - a natural number.
284
285 \begin{zed}
286 Dimension == \nat
287 \end{zed}
288
289 \item \textsf{Feature Kind} - a feature name and associated set of parameters.
290
291 \begin{zed}
292 [Const, Var]
293 \end{zed}
294
295 We define the binding type as the set of functions between variables and constants.
296
297 \begin{zed}
298 Binding == \power (Var \cross Const)
299 \end{zed}
300
301 Every feature kind has a dimension (not necessarily fixed).
302
303 \begin{schema}{FeatureKind}
304 name : FeatureName \\
305 parameters : \power Var \\
306 dparameters : \power Var \\
307 binding : Binding \\
308 ddimension : Binding \pfun \nat \\
309 fdimension : Dimension \\
310 \where
311 dparameters \subseteq parameters \\
312 \forall b : Binding | b \in (\dom ddimension) @ dparameters \subseteq (\dom b)
313 \end{schema}
314
315 \item A \textsf{Feature} - sometimes referred to as a Fully Qualified Feature - is a feature kind with all parameters bound.
316
317 \item \textsf{Feature Dimension} - every feature has a fixed dimension.
318
319 \begin{schema}{Feature}
320 FeatureKind \\
321 \where
322 \dom binding = parameters \\
323 fdimension = ddimension~binding
324 \end{schema}
325
326 \item \textsf{Unit Feature} - any feature with a dimension of 1.
327
328 \begin{schema}{UnitFeature}
329 Feature \\
330 \where
331 fdimension = 1
332 \end{schema}
333
334 \item \textsf{Feature Vector} - a non-empty sequence of real numbers.
335
336 \begin{zed}
337 \FV == \seq_1 \R
338 \end{zed}
339
340 % DEFINE ALL FEATURE VECTORS HERE
341
342 %% \begin{zed}
343 %% \V == \FV \\
344 %% \U == \FV
345 %% \end{zed}
346
347 \newcommand{\Vdsl}{\mathrel{~FV^{d * sl}}}
348
349 %% \begin{zed}
350 %% \Vdsl == \FV
351 %% \end{zed}
352
353 \newcommand{\Vd}{\mathrel{~FV^{d}}}
354
355 %% \begin{zed}
356 %% \Vd == \FV
357 %% \end{zed}
358
359 \newcommand{\Z}{\mathrel{~FV^{1}}}
360
361 %% \begin{zed}
362 %% \Z == \FV
363 %% \end{zed}
364
365 \newcommand{\Vsl}{\mathrel{~FV^{sl}}}
366
367 %% \begin{zed}
368 %% \Vsl == \FV
369 %% \end{zed}
370
371
372 \item \textsf{Feature Vector Dimension} - the length of a feature vector.
373
374 \begin{axdef}
375 dimension : \FV \fun \nat
376 \where
377 \forall fv : \FV @ dimension~fv = \# fv
378 \end{axdef}
379
380 \item \textsf{Unit Vector} - any feature vector with a dimension of 1.
381
382 \begin{zed}
383 UnitVector == \{ fv : \FV | dimension~fv = 1 \}
384 \end{zed}
385
386 \item \textsf{Extractor} - a process which computes a feature vector of fixed dimension for any interval of any track, represented formally as a function that takes a track and an interval and returns a feature vector.
387
388 \begin{zed}
389 Extractor == Track \fun Interval \fun \FV
390 \end{zed}
391
392 \item \textsf{Unit Extractor} - a subclass of Extractor where the feature vector dimension is equal to 1.
393
394 \begin{zed}
395 UnitExtractor == \\
396 \t1 \{ e : Extractor | \forall t : Track; i : Interval @ dimension (e~t~i) = 1 \}
397 \end{zed}
398
399 \item \textsf{Bel Unit Extractor} - a subclass of Unit Extractor where the function outputs on the bel scale (between minus infinity and zero).
400
401 \begin{zed}
402 BelUnitExtractor == UnitExtractor
403 \end{zed}
404
405 \item \textsf{Feature Extractors} - the set of all extractors associated with a feature.
406
407 As this data structure can be updated over time - by adding and removing new features, and adding and removing extractors for a feature as new ones arise and old ones are not used - we use a schema. The predicate states that the feature vector dimension computed by an extractor must be equal to the associated feature dimension. Every feature has a unique associated unit feature and every extractor has a unique associated unit extractor. Once a user defines a feature, and one its associated extractors, the unit feature and extractor are generated automatically.
408
409 \begin{schema}{FeatureExtractors}
410 featureextractors : Feature \pfun (\power Extractor) \\
411 features : \power Feature \\
412 extractors : \power Extractor \\
413 \where
414 \dom featureextractors = features \\
415 \bigcup (\ran featureextractors) = extractors \\
416 \forall f : Feature ; e : Extractor ; t : Track; i : Interval \\
417 \t1 @ e \in featureextractors(f) \implies \\
418 \t2 f.fdimension = dimension (e~ t ~ i) \\
419 \end{schema}
420
421 The range of the real contained in the bel unit vector is less than 0.
422
423 \begin{zed}
424 \forall t : Track; int : Interval; ux : BelUnitExtractor @ \\
425 \t5 head (ux~t~int) \leq 0
426 \end{zed}
427
428 \item \textsf{Track Feature Vectors} - given a segmenter and an extractor the sequence of feature vectors for each interval of the track
429
430 \begin{flushright}
431 \begin{tikzpicture}
432 \input track-feature-vectors.tikz
433 \end{tikzpicture}
434 \end{flushright}
435
436 The function $extract$ applies an extractor to each interval of a track to return a list of feature vectors. This requires the generic function map, which takes a function and applies it to every element of a list. A definition can be found in the appendix.
437
438 %%\begin{gendef}[X,Y]
439 %% map : (X \fun Y) \fun (\seq X) \fun (\seq Y) \\
440 %%\where
441 %% \forall f : X \fun Y; x : X; xs,ys : \seq X @ \\
442 %%\t1 map~f~\langle \rangle = \langle \rangle \land \\
443 %%\t1 map~f~(xs \cat ys) = map~f~xs \cat map~f~ys
444 %%\end{gendef}
445
446 \begin{axdef}
447 extract : Segmenter \fun Extractor \fun Track \fun \seq \FV
448 \where
449 \forall seg : Segmenter; fx : Extractor; t : Track @ \\
450 \t5 extract~seg~fx~t = map ~ (fx~t) (seg~t)
451 \end{axdef}
452
453
454 \item \textsf{Track Unit Vectors} - defined as above but specifically for unit extractors
455
456 \begin{flushright}
457 \begin{tikzpicture}
458 \input interval-index.tikz
459 \input segmented-track.tikz
460 % \foreach \x in {-2.5,-2,-1.4,-0.5,0,0.8,1.3,1.8} {
461 % \begin{scope}[xshift=\x cm,yshift=-0.4 cm]
462 \foreach \x in {-1.8,-1.4,...,1.1} {
463 \begin{scope}[xshift=\x cm,yshift=1.1 cm]
464 \draw (-0.1,0) rectangle (0.1,0.2);
465 \end{scope}
466 }
467 \begin{scope}[yshift=1.1 cm]
468 \draw[|-|,>=stealth] (-2.3,0) -- (-2.3,0.2);
469 \draw node[anchor=south east] at (-2.4,0.1) {\small $d=1$};
470 \end{scope}
471 \end{tikzpicture}
472 \end{flushright}
473
474 \item \textsf{Catalogue Feature Vectors} - a sequence of track feature vectors for each track in the target instance ($catfeatures$)
475
476 \item \textsf{Catalogue Unit Vectors} - a sequence of track unit vectors for each track in the target instance ($catunits$)
477
478 \item \textsf{Instance} - a catalogue, segmenter, feature, extractor, unit feature, unit extractor, dimension, catalogue feature vectors,
479
480 % \emph{In our usage (see \textsf{Absolute} \and \textsf{Relative} in section \ref{s:refining}), we require certain semantics of the \textsf{Unit Feature} (and so of the values returned by its \textit{Unit Extractors}. Specifically, the values returned must be interpretable on a logarithmic scale in Bels, with the maximum possible value being the reference threshold at 0B.}
481
482 \begin{schema}{Instance}
483 cat : Catalogue \\
484 % tracks : \power Track \\
485 seg : Segmenter \\
486 f : Feature \\
487 x : Extractor \\
488 uf : UnitFeature \\
489 ux : UnitExtractor \\
490 d : Dimension \\
491 catfeatures : \seq ~ ( \seq \V) \\
492 catunits : \seq ~ (\seq \U)
493 \where
494 d = f.fdimension \\
495 catfeatures = map ~ (extract~seg~x) ~ cat \\
496 catunits = map ~ (extract~seg~ux) ~ cat \\
497 \end{schema}
498
499 \item \textsf{System Instances} - the set of System instances.
500
501 Note that every instance must contain a catalogue in the music collection but not all catalogues in the collection will be part of an instance.
502
503 \begin{schema}{SystemInstances}
504 Collection \\
505 instances : \power Instance
506 \where
507 \{ i : instances @ i.cat \} \subseteq collection
508 \end{schema}
509
510 \section{Search}
511
512 \item \textsf{Search Vectors}
513
514 Searching takes place using concatenations of feature vectors to build \emph{search} vectors. For a particular query all search vectors will have a fixed length equal to some multiple (which we will refer to as $sl$) of the dimension of the orignal feature vectors ($d$).
515
516 In the schema below, the function $makesearchvs$ takes a natual number $sl$ and a sequence of feature vectors (associated with a track) to create a sequence of search vectors. The first element of the returned sequence is the concatenation of the first $sl$ feature vectors, the second element is also the concatenation the next $sl$ feature vectors but starting from the second element, and so on until all such sequences are formed. It should be clear that if the original sequence contains $n$ feature vectors then the output will contain $n-sl+1$ vectors.
517
518 \begin{flushright}
519 \begin{tikzpicture}[>=stealth]
520 \begin{scope}[xshift=-6 cm]
521 \input track-feature-vectors.tikz
522 \begin{scope}[yshift=1.1 cm]
523 \begin{scope}[yshift=1.1 cm,xshift=-1.8cm]
524 \input fv1.tikz
525 \draw (-0.1,0) rectangle (0.1,1);
526 \draw (-0.1,0.2) -- (0.1,0.2);
527 \draw (-0.1,0.4) -- (0.1,0.4);
528 \draw (-0.1,0.6) -- (0.1,0.6);
529 \draw (-0.1,0.8) -- (0.1,0.8);
530 \end{scope}
531 \begin{scope}[yshift=2.2 cm,xshift=-1.8cm]
532 \input fv2.tikz
533 \draw (-0.1,0) rectangle (0.1,1);
534 \draw (-0.1,0.2) -- (0.1,0.2);
535 \draw (-0.1,0.4) -- (0.1,0.4);
536 \draw (-0.1,0.6) -- (0.1,0.6);
537 \draw (-0.1,0.8) -- (0.1,0.8);
538 \end{scope}
539 \draw[->] (-1.4,1) arc(0:90:0.4 and 0.6);
540 \draw[->] (-1.0,1) arc(0:90:0.8 and 1.7);
541 \draw[->] (-1.0,1) arc(0:90:0.4 and 0.6);
542 \draw[->] (-0.6,1) arc(0:90:0.8 and 1.7);
543 \end{scope}
544 \end{scope}
545 \input interval-index.tikz
546 \input segmented-track.tikz
547 % \foreach \x in {-2.5,-2,-1.4,-0.5,0,0.8,1.3,1.8} {
548 % \begin{scope}[xshift=\x cm,yshift=-0.4 cm]
549 \foreach \x/\f in {-1.8/fv0,-1.4/fv1,-1.0/fv2,-0.6/fv3,-0.2/fv4,0.2/fv5,0.6/fv6,1.0/fv7} {
550 \begin{scope}[yshift=1.1 cm,xshift=\x cm]
551 \input \f.tikz
552 \end{scope}
553 }
554 \foreach \x/\f in {-1.8/fv1,-1.4/fv2,-1.0/fv3,-0.6/fv4,-0.2/fv5,0.2/fv6,0.6/fv7} {
555 \begin{scope}[yshift=2.1 cm,xshift=\x cm]
556 \input \f.tikz
557 \end{scope}
558 }
559 \foreach \x/\f in {-1.8/fv2,-1.4/fv3,-1.0/fv4,-0.6/fv5,-0.2/fv6,0.2/fv7} {
560 \begin{scope}[yshift=3.1 cm,xshift=\x cm]
561 \input \f.tikz
562 \end{scope}
563 }
564 \foreach \x in {-1.8,-1.4,...,0.3} {
565 \begin{scope}[xshift=\x cm,yshift=1.1 cm]
566 \draw (-0.1,0) rectangle (0.1,3);
567 \foreach \y in {0.2,0.4,...,2.9} {
568 \draw (-0.1,\y) -- (0.1,\y);
569 }
570 \end{scope}
571 }
572 \begin{scope}[yshift=1.1 cm]
573 \draw[<->,>=stealth] (-2.1,0) -- (-2.1,3);
574 \draw node[anchor=east] at (-2.3,1.5) {$d \times sl$};
575 \end{scope}
576 \begin{scope}[yshift=1.1 cm]
577 \draw[<->,>=stealth] (-2,3.2) -- (0.4,3.2);
578 \draw node at (-0.8,3.6) {$n - sl + 1$};
579 \end{scope}
580 \begin{scope}[xshift=0.6 cm,yshift=1.1 cm]
581 \draw (-0.1,0) rectangle (0.1,2);
582 \foreach \y in {0.2,0.4,...,1.9} {
583 \draw (-0.1,\y) -- (0.1,\y);
584 }
585 \draw[dashed] (-0.1,0) -- (-0.3,1);
586 \draw[dashed] (-0.1,1) -- (-0.3,2);
587 \draw[dashed] (-0.1,2) -- (-0.3,3);
588 \end{scope}
589 \begin{scope}[xshift=1.0 cm,yshift=1.1 cm]
590 \draw (-0.1,0) rectangle (0.1,1);
591 \foreach \y in {0.2,0.4,...,0.9} {
592 \draw (-0.1,\y) -- (0.1,\y);
593 }
594 \draw[dashed] (-0.1,0) -- (-0.3,1);
595 \draw[dashed] (-0.1,1) -- (-0.3,2);
596 \end{scope}
597 \foreach \x in {-1.4,-1.0,...,0.3} {
598 \begin{scope}[xshift=\x cm,yshift=1.1 cm]
599 \draw[dashed] (-0.1,0) -- (-0.3,1);
600 \draw[dashed] (-0.1,1) -- (-0.3,2);
601 \draw[dashed] (-0.1,2) -- (-0.3,3);
602 \end{scope}
603 }
604 \end{tikzpicture}
605 \end{flushright}
606
607 \begin{axdef}
608 makesearchvs : \nat \fun \seq \Vd \fun \seq \Vdsl
609 \where
610 \forall xs : \seq \FV ; sl : \nat @ \\
611 \t1 sl > \# xs \implies makesearchvs~sl~xs = \langle \rangle \land \\
612 \t1 sl \leq \# xs \implies makesearchvs~sl~xs = \\
613 \t2 concat (\langle (0 \upto sl-1) \dres xs \rangle) \cat makesearchvs~sl (tail~xs)
614 \end{axdef}
615
616 \subsection{Identifying Source and Target}
617
618 A search vector is made from a source (sequence) and used to match against a user-defined target (instance).
619
620 \item \textsf{Source} - a track identified by the user in order to define a search.
621
622 \item \textsf{Target} - the instance used to match the source against.
623
624 \begin{schema}{IdentifySourceTarget}
625 source? : Track \\
626 tgt? : Instance \\
627 SystemInstances
628 \where
629 source? \in tracks \\
630 tgt? \in instances
631 \end{schema}
632
633 In addition the user can define the part of the source track to be used in the query. This is known as a sequence. A user defines the sequence by specifying the start and end points of the sequence index. (Note that there is an underlying assumption that the segmenter of the target returns a continuous interval index when applied to the source.)
634
635 \item \textsf{Track Part} - a continuous sub-section of a track.
636
637 \begin{zed}
638 TrackPart == Track
639 \end{zed}
640
641 \item \textsf{Sequence} - the track part required for the search.
642
643 \item \textsf{Sequence Index} - a continuous interval index that defines the sequence.
644
645 \item \textsf{Sequence Length} - the number of intervals in the sequence index.
646
647 \begin{schema}{IdentifySequence}
648 IdentifySourceTarget \\
649 start?, end? : \nat \\
650 seqindex : ContinuousIntervalIndex \\
651 sl : \nat \\
652 sequence : TrackPart
653 \where
654 start? \in \dom (tgt?.seg (source?)) \\
655 end? \in \dom (tgt?.seg (source?)) \\
656 seqindex = (start? \upto end?) \dres (tgt?.seg~source?) \\
657 sl = end? - start? \\
658 \end{schema}
659
660 \subsection{Source Search and Feature Vectors}
661
662 \item The \textsf{Source Feature Vectors} are the set of feature vectors of the sequence.
663
664 \item The \textsf{Source Unit Vectors} are the set of unit vectors of the sequence.
665
666 \begin{schema}{SourceFeatureVectors}
667 IdentifySequence \\
668 sourcefeatures : \seq \V \\
669 sourceunits : \seq \U \\
670 \where
671 sourcefeatures = extract ~tgt?.seg~tgt?.x~sequence \\
672 sourceunits = extract ~ tgt?.seg~tgt?.ux~sequence \\
673 \end{schema}
674
675 \item \textsf{Source Search Vector} - the concatenation of the feature vectors of the source sequence.
676
677 \item \textsf{Source Unit Search Vector} - the concatenation of the unit vectors of the source sequence.
678
679 \begin{schema}{SourceSearchVectors}
680 SourceFeatureVectors \\
681 sourcesearch : \Vdsl \\
682 sourcesearchunits : \Vsl \\
683 \where
684 sourcesearch = (head~(makesearchvs~sl~sourcefeatures)) \\
685 sourcesearchunits = (head~(makesearchvs~sl~sourcefeatures)) \\
686 \end{schema}
687
688 \subsection{Target Search Vectors}
689
690 \item \textsf{Target Search Vectors}
691
692 We can define these in exactly the same way as for the source, but as we now have a sequence of sequences of search vectors we have to use the map function to apply the $makesearchveors$ to each list
693
694 \begin{schema}{TargetSearchVectors}
695 IdentifySourceTarget \\
696 IdentifySequence\\
697 targetsearchvs : \seq (\seq \Vdsl) \\
698 targetunitsearchvs : \seq (\seq \Vsl) \\
699 \where
700 targetsearchvs = \\
701 \t1 map ~ (makesearchvs ~ sl) ~ tgt?.catfeatures \\
702 targetunitsearchvs = \\
703 \t1 map ~ (makesearchvs ~ sl) ~ tgt?.catfeatures \\
704 \end{schema}
705
706 \item \textsf{Hopped Search Vectors}
707
708 Rather then generating all possible search vectors we may wish to general vectors starting at equally distanced intervals in the interval index of the tracks in an instance. Re refer to the size of this interval as $hop$.
709
710
711 \begin{axdef}
712 makehopsearchvs : \nat \fun \nat \fun \seq \Vd \fun \seq \Vdsl
713 \where
714 \forall xs : \seq \FV ; sl : \nat ; hop : \nat @ \\
715 \t1 sl > \# xs \implies makehopsearchvs~sl~hop~xs = \langle \rangle \land \\
716 \t1 sl \leq \# xs \implies makehopsearchvs~sl~hop~xs = \\
717 \t2 concat (\langle (0 \upto sl-1) \dres xs \rangle) \cat \\
718 \t2 makehopsearchvs~sl~hop~ ((0 \upto (hop -1)) \ndres xs)
719 \end{axdef}
720
721 This enables us to define a hop size when generating target search vectors
722
723 \begin{schema}{TargetSearchHopVectors}
724 hop? : \nat \\
725 TargetSearchVectors \\
726 targethopsearchvs : \seq (\seq \Vdsl) \\
727 targethopunitsearchvs : \seq (\seq \Vsl) \\
728 \where
729 targethopsearchvs = \\
730 \t1 map ~ (makehopsearchvs ~sl ~ hop?) ~ tgt?.catfeatures \\
731 targethopunitsearchvs = \\
732 \t1 map ~ (makehopsearchvs ~ sl ~ hop?) ~ tgt?.catfeatures \\
733 \end{schema}
734
735 \end{enumerate}
736
737
738 \section{Distance, Power and Duration}
739
740 \subsection{Distance of Source Search Vector from Target Search Vector}
741
742 We define the scalar product and distance between vectors of equal dimension.
743
744 \begin{axdef}
745 scalarproduct : \V \fun \V \fun \R \\
746 distance : \V \fun \V \fun \R \\
747 \end{axdef}
748
749 \begin{zed}
750 \forall v_1, v_2 : \V @ distance~v_1~v_2 = 2 - scalarproduct~v_1~v_2
751 \end{zed}
752
753 Then we can define a variable which maintains a list of all distances between the source search vector and the target search vectors.
754
755 \begin{schema}{Distances}
756 distances : \seq (\seq \R) \\
757 SourceSearchVectors \\
758 TargetSearchVectors \\
759 \where
760 distances = map (map (distance~sourcesearch)) targetsearchvs
761 \end{schema}
762
763 \subsection{Average `power' of a search feature vector}
764
765 For each Search Feature Vector in the target, we take the associated unit values and take the arithmetic mean.
766
767 \begin{axdef}
768 average : \V \fun \R
769 \end{axdef}
770
771 \begin{schema}{Powers}
772 targetpowers : \seq (\seq \R) \\
773 sourcepower : \R \\
774 SourceSearchVectors \\
775 TargetSearchVectors \\
776 \where
777 targetpowers = map~(map ~ average) ~ targetsearchvs\\
778 sourcepower = head (map~average ~ sourceunits)
779 \end{schema}
780
781 \subsection{Duration of a search feature vector}
782
783 Calculate the duration of the sequence for each search vector. (Made from the concatenation of feature vectors each associated with an interval. Add the intervals together to get the duration of the search vector.)
784
785 \begin{schema}{Durations}
786 targetdurations : \seq (\seq \R) \\
787 sourceduration : \R \\
788 TargetSearchVectors \\
789 SourceSearchVectors \\
790 \end{schema}
791
792 \subsection{Compiled Data}
793
794 The we have a set of compiled data as follows.
795
796 \begin{schema}{CompiledData}
797 Distances \\
798 Powers \\
799 Durations \\
800 \end{schema}
801
802 \section{Refining a Search}
803 \label{s:refining}
804
805 System will first return the index of the track which gives the smallest distance from the source sequence search vector. Suppose this is at (3,4) in the list of lists. This signifies that the closest match is the 3rd track in the catalogue starting at the 4th interval. There are ways of refining the query.
806
807 \begin{enumerate}
808
809 \item \textsf{Key List} - specify specific tracks within a catalogue to search over.
810
811 \item \textsf{Radius} - reject distances which are greater than a given real number radius.
812
813 \item \textsf{Absolute} - reject any target search vectors where the `power' average is less than a specific absolute value.
814
815 \item \textsf{Relative} - reject any target search vectors where the `power' average is not within + or - a relative value.
816
817 \item \textsf{Duration Ratio} - remove any search vectors whose total interval (duration) is sufficiently different from the duration of the source.
818
819 \item \textsf{Hop Size} - Rather than making search vectors which start with the first feature vectors and then the second feature vector and so on, make sparser search vectors by starting with fv at 1, then fv at $1 + h$, then fv at $1 + 2h$ and so on where h is the hop size.
820
821 \end{enumerate}
822
823 We specify what happens when values are given for any of these parameters.
824
825 First, we specify a single output as signifiying a track, a starting interval, a distance, a power and a duration
826
827 \begin{schema}{Output}
828 track : Track \\
829 index : \nat \\
830 distance : \R \\
831 duration : \R \\
832 power : \R \\
833 \end{schema}
834
835 The System outputs are a sequence of such outputs ordered according to distance. We define a new variable which specifies the modified output that the user can make.
836
837 \begin{schema}{SystemOutput}
838 CompiledData \\
839 output! : \seq Output \\
840 modifiedoutput! : \seq Output
841 \where
842 \forall o_1, o_2 : Output @ \langle o_1, o_2 \rangle \inseq output! \\
843 \t3 \implies o_1.distance \leq o_2.distance
844 \end{schema}
845
846 \begin{enumerate}
847
848 \item Keylist
849
850 \begin{schema}{KeyList}
851 SystemOutput \\
852 k? : \power Track
853 \where
854 modifiedoutput! = output! \filter \{ o : Output | o.track \in k? \}
855 \end{schema}
856
857 \item Radius
858
859 The system removes any elements which have a distance greater than the radius.
860
861 \begin{schema}{Radius}
862 SystemOutput \\
863 r? : \R \\
864 \where
865 modifiedoutput! = \\
866 \t1 output! \filter \{ o : Output | o.distance \leq r? \}
867 \end{schema}
868
869 \item Absolute
870
871 \begin{schema}{Absolute}
872 SystemOutput \\
873 a? : \R \\
874 \where
875 modifiedoutput! = \\
876 \t1 output! \filter \{ o : Output | o.power \geq a? \}
877 \end{schema}
878
879 \item Relative
880
881 %% \begin{axdef}
882 %% abs : \R \fun \R
883 %% \end{axdef}
884
885
886 \begin{schema}{Relative}
887 SystemOutput \\
888 rel? : \R \\
889 \where
890 modifiedoutput! = \\
891 \t1 output! \filter \{ o : Output | abs (o.power - sourcepower) \leq rel? \}
892 \end{schema}
893
894 \item Duration Ratio
895
896 %%unchecked
897 \begin{schema}{DurationRatio}
898 SystemOutput \\
899 d? : \R \\
900 \where
901 modifiedoutput! = \\
902 \t1 output! \filter \{ o : Output | \exp ^ {abs \ln (\frac{o.duration}{sourceduration})} \leq d? \}
903 \end{schema}
904
905 \item Hop Size
906
907 \begin{schema}{Hop}
908 hop? : \nat \\
909 SystemOutput \\
910 TargetSearchHopVectors \\
911 \end{schema}
912
913 \end{enumerate}
914
915 \section{Setting Thresholds}
916
917 \subsection{For an Instance}
918
919 \begin{enumerate}
920 \item Guess several lengths based on understanding of the instance (beat, bar, phrase, section). ($sl$)
921 \item Generate all sequences of length ($sl$) from the tracks in the instance
922 \item Select pairs of sequences of length ($sl$) which may or may not be from the same track randomly from the instance, compute distance between these pairs, and repeat a fixed number of times.
923 \item Tabulate distances
924 \item Scary maths
925 \item Obtain a global threshold
926 \item Set the radius threshold equal to this value
927 \end{enumerate}
928
929 \subsection{For a Source Sequence and a Target Instance (I)}
930
931 \begin{enumerate}
932 \item Take the length of the source sequence ($sl$)
933 \item Generate all sequences of length ($sl$) from the tracks in the instance
934 \item Select a sequence randomly, calculate the distance form the source sequence, and repeat a fixed number of times.
935 \item Tabulate distances
936 \item Scary maths
937 \item Obtain a threshold for this sequence/instance pair
938 \item Set the radius threshold equal to this value
939 \end{enumerate}
940
941 \subsection{For a Source Track and a Target Instance (II)}
942
943 \begin{enumerate}
944 \item Choose a length $sl$ which is less than the track length
945 \item Generate all sequences of length ($sl$) from the tracks in the instance
946 \item Generate all sequences of length ($sl$) from the source sequence
947 \item Select one of these source sequences randomly and one of the sequences from one of the tracks in the instance randomly, calculate the distance form the source sequence, and repeat a fixed number of times.
948 \item Tabulate distances
949 \item Scary maths
950 \item Obtain a threshold for this track/instance pair
951 \item Set the radius threshold equal to this value
952 \end{enumerate}
953
954 \appendix
955 \section{Auxillary Definitions}
956
957 \subsection{The function $map$}
958
959 This requires need the generic function map, which takes a function and applies it to every element of a list.
960
961 %%unchecked
962 \begin{gendef}[X,Y]
963 map : (X \fun Y) \fun (\seq X) \fun (\seq Y) \\
964 \where
965 \forall f : X \fun Y; x : X; xs,ys : \seq X @ \\
966 \t1 map~f~\langle \rangle = \langle \rangle \land \\
967 \t1 map~f~(xs \cat ys) = map~f~xs \cat map~f~ys
968 \end{gendef}
969
970
971 \subsection{The function $concat$}
972
973 We can do this by making use of the following generic function that takes a list of lists of lists, and concatenates each of the lists together.
974
975 %%unchecked
976 \begin{gendef}[X]
977 concat : (\seq (\seq X)) \fun (\seq X)
978 \where
979 \forall xs : \seq X; xss : \seq (\seq X) @ \\
980 \t2 concat~ ((\langle xs \rangle) \cat xss) = xs \cat
981 (concat~xss)
982 \end{gendef}
983
984 \section{Probabilty of chosing a track}
985
986 The longer the track in a target the more sequences it will contain with the same number of intervals with length ($sl$). Therefore the probability of selecting a track is weighted. Once a track has been selected then a sequence within the track is chosen uniformly.
987
988 %% \begin{axdef}
989 %% sum : \power \R \fun \R
990 %% \end{axdef}
991
992 %% \begin{axdef}
993 %% pairmax : \R \cross \R \fun \R
994 %% \end{axdef}
995
996 %%unchecked
997 \begin{schema}{CalculateProbabilities}
998 i : Instance \\
999 sl : \nat \\
1000 allslsequences : \nat \\
1001 SystemInstances \\
1002 prob : Track \fun \R \also
1003 \where
1004 allslsequences = \\
1005 \t1 sum \{ t : Track @ pairmax ( (length (i.seg~t) - sl + 1), 0 ) \} \also
1006 \forall t : Track @ prob~t = \frac{length (i.seg~t) - sl + 1}{ allslsequences}
1007 \end{schema}
1008
1009 This uses a function $subsequences$ which takes a sequence of elements $s$ and a natural number $n$ and returns the number of contiguous sequences of length $n$ and a function $sumseq$ which sums the elements in a list.
1010
1011 \section{Examples illustrating functions}
1012
1013 \subsection{Track Extract}
1014
1015 Given a segmenter, an extractor, and a track, the function $extract$ returns a list of feature vectors for that track. Each feature vector has equal dimension, and each vector corresponds to the equivalent interval in the interval index. As an example, if the feature vectors have dimension $d$, and if there are $m$ intervals defined by the segmenter, and if we adopt the convention that $\V$ represents a vector of length d, this function would return something with the following form:
1016
1017 \[ \langle V_{1}^{d}, V_{2}^{d} \dots V_{m}^{d} \rangle \]
1018
1019 When we apply this function to every track in a catalogue (which is a list of tracks) we simply determine a list of such lists. If there are $n$ tracks in a catalogue then our data would look something like the following.
1020
1021 \[ catfeatures = \langle ~~ \langle V_{11}^{d}, V_{12}^{d} \dots V_{1m_{1}}^{d} \rangle \\
1022 \t3 ~~~ \langle V_{21}^{d}, V_{22}^{d} \dots V_{2m_{2}}^{d} \rangle \\
1023 \t3 \dots \\
1024 \t3 \dots \\
1025 \t3 ~~~ \langle V_{n1}^{d}, V_{n2}^{d} \dots V_{nm_{n}}^{d} \rangle
1026 ~~ \rangle
1027 ~~ \]
1028
1029 The unit vector data has exactly the same structure but with different vectors all of dimension 1.
1030
1031 \[ catunits = \langle ~~ \langle V_{11}^{1}, V_{12}^{1} \dots V_{1m_{1}}^{1} \rangle \\
1032 \t4 ~~ \langle V_{21}^{1}, V_{22}^{1} \dots V_{2m_{2}}^{1} \rangle \\
1033 \t4 \dots \\
1034 \t4 \dots \\
1035 \t4 ~~~ \langle V_{n1}^{1}, V_{n2}^{1} \dots V_{nm_{n}}^{1} \rangle
1036 ~~ \rangle
1037 ~~ \]
1038
1039 \subsection{Making Search Vectors}
1040
1041 Suppose we had the following feature vectors for a track.
1042
1043 \[ \langle V_{1}^{d}, V_{2}^{d} , V_{3}^{d} \rangle \]
1044
1045 Also suppose that our sequence length $sl$ had a value of 2 and we applied the function $makesearchvs$. We would then make search vectors as follows.
1046
1047 \[ \t3 \langle V_{1}^{d} \cat V_{2}^{d} , V_{2}^{d} \cat V_{3}^{d} \rangle \]
1048
1049 \end{document}
1050