Skip to content

Commit 6bb96d3

Browse files
felixlotterd-torrance
authored andcommitted
new package "PathSignatures"
1 parent a4b4c80 commit 6bb96d3

File tree

6 files changed

+2414
-0
lines changed

6 files changed

+2414
-0
lines changed
Lines changed: 351 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,351 @@
1+
newPackage("PathSignatures",
2+
Version => "1.0",
3+
Authors => {{Name => "Felix Lotter", HomePage => "https://felixlotter.gitlab.io"}, {Name => "Oriol Reig"}, {Name => "Angelo El Saliby"}, {Name => "Carlos Amendola"}},
4+
Headline => "A package for working with signatures of algebraic paths",
5+
AuxiliaryFiles => true,
6+
Keywords => {"Applied Algebraic Geometry"},
7+
PackageExports => {"NCAlgebra", "Permutations"}
8+
);
9+
export {
10+
--types
11+
"Path",
12+
--methods
13+
"sig",
14+
"polyPath",
15+
"linPath",
16+
"pwLinPath",
17+
"concatPath",
18+
"matrixAction",
19+
"CAxisTensor",
20+
"CMonTensor",
21+
"tensorParametrization",
22+
"wordAlgebra",
23+
"sgnVolTensor",
24+
"shuffle",
25+
"halfshuffle",
26+
"wordFormat",
27+
"wordString",
28+
"getDimension",
29+
"getPieces",
30+
"getCoefficientRing",
31+
"getNumberOfPieces",
32+
-- symbols
33+
"adjointWord",
34+
"tensorArray",
35+
"inner",
36+
"lyndonWords",
37+
"lie",
38+
"lieBasis",
39+
"tensorExp",
40+
"tensorLog",
41+
"lyndonShuffle",
42+
"VarWordTable"
43+
-- "type",
44+
-- "pieces",
45+
-- "dimension",
46+
-- "numberOfPieces",
47+
-- "bR"
48+
};
49+
50+
exportFrom("NCAlgebra",{"NCRingElement", "NCPolynomialRing"})
51+
52+
--------------------------------------------
53+
--Include interface for NCAlgebra
54+
load "./PathSignatures/interfaceNCAlgebra.m2"
55+
56+
--Include tensor algebra
57+
load "./PathSignatures/algebra.m2"
58+
59+
--Include types
60+
load "./PathSignatures/types.m2"
61+
62+
--Include signatures
63+
load "./PathSignatures/signatures.m2"
64+
65+
--Include documentation
66+
load "./PathSignatures/documentation.m2"
67+
--------------------------------------------
68+
69+
----------------------------------------------------
70+
--Landing page and case use documentation
71+
----------------------------------------------------
72+
beginDocumentation()
73+
doc ///
74+
Node
75+
Key
76+
PathSignatures
77+
Headline
78+
a package for working with signatures of algebraic paths
79+
Description
80+
Text
81+
{\em PathSignatures} is a package for studying the signature of piecewise polynomial paths.
82+
Text
83+
The package heavily simplifies the process of obtaining data related to signature varieties, e.g. as in @HREF("#ref1","[1]")@. See @TO "Computing Path Varieties"@.
84+
Text
85+
A polynomial path is a path $X: [0,1] \to \mathbb R^d$ whose coordinate functions are given by polynomials. A piecewise polynomial path is a path $X: [0,1] \to \mathbb R^d$ which is polynomial on each interval in a partition of $[0,1]$.
86+
Text
87+
Given such a path $X$, its signature is the linear form $\sigma: T((\mathbb{R}^d)^*)\rightarrow \mathbb{R}$ on the tensor algebra of the dual of
88+
$\mathbb{R}^d$, whose image on a decomposable tensor $\alpha_1\otimes \dots\otimes \alpha_k$ is the iterated integral $$
89+
\alpha_1\otimes \dots\otimes \alpha_k\overset{\sigma}{\mapsto} \int_0^1\int_0^{t_k}\dots\int_0^{t_2}\partial(\alpha_1 X)\dots \partial (\alpha_k X) d t_1\dots dt_k.
90+
$$
91+
This form is invariant under translation, reparametrization and tree-like equivalence of $X$ and characterizes $X$ uniquely up to these relations.
92+
Text
93+
In this package, we identify $T((\mathbb{R}^d)^*)$ with the free associative algebra over the alphabet $\{\texttt{1},\dots,\texttt{d}\}$ via $\texttt{i} \mapsto e_i^*$ where $e_1^*, \dots, e_d^*$ is the dual of the canonical basis of $\mathbb{R}^d$. For example, the word $\texttt{12}$ corresponds to $e_1^* \otimes e_2^*$.
94+
Text
95+
It is easy to create a polynomial path:
96+
Example
97+
R = QQ[t];
98+
X = polyPath({t + t^2, t^3})
99+
Text
100+
A piecewise polynomial path is obtained by concatenating polynomial paths:
101+
Example
102+
Y = X ** X
103+
Text
104+
Any @TO2 {"NCAlgebra::NCPolynomialRing", "NCPolynomialRing"}@ can serve as a tensor algebra. Use @TO wordAlgebra@ to quickly create one in variables $\texttt{Lt}_i$. The package introduces a convenient notation for words in this algebra.
105+
Example
106+
A2 = wordAlgebra(2)
107+
[1,2]_A2 -- the word 12.
108+
Text
109+
To evaluate the signature of $\mathtt{X}$ at a tensor $\mathtt{w}$, use @TO sig@. The following computes the @ITALIC "signed volume"@ of the path; also see @TO sgnVolTensor@.
110+
Example
111+
sig(X,[1,2]_A2-[2,1]_A2)
112+
Text
113+
@TO sig@ can also be used to obtain the @ITALIC "$k$-th level signature tensor"@. Use @TO wordFormat@ or @TO tensorArray@ to display the tensor in a nicer way.
114+
Example
115+
T = sig(X,2)
116+
T // wordFormat
117+
T // tensorArray
118+
Text
119+
The package allows for the computation of signatures for parametrized families of paths.
120+
Example
121+
S = QQ[a,b,c]
122+
R = S[t]
123+
X = polyPath({a*t+b*t^2,c*t^3})
124+
Y = X ** X
125+
sig(X, sgnVolTensor(A2))
126+
References
127+
@LABEL("[1]","id" => "ref1")@ Améndola, C., Friz, P., & Sturmfels, B. (2019, January). Varieties of signature tensors. In Forum of Mathematics, Sigma (Vol. 7, p. e10). Cambridge University Press.
128+
129+
130+
Node
131+
Key
132+
"Computing Path Varieties"
133+
Description
134+
Text
135+
@TO PathSignatures@ simplifies the computation of varieties coming from signature tensors. We showcase this in a number of examples:
136+
Subnodes
137+
"Polynomial paths of degree m"
138+
"A family of paths on a cone"
139+
"The universal variety and toric coordinates"
140+
Node
141+
Key
142+
"Polynomial paths of degree m"
143+
Description
144+
Text
145+
We reproduce a computation from @HREF("#ref1","[1]")@.
146+
We briefly recall the setting for this computation. We are interested in paths $X:[0,1]\rightarrow \mathbb{R}^\mathtt{d}$ whose coordinates are polynomials of degree $\mathtt{m}$. These can be
147+
represented by a $\mathtt{d}\times \mathtt{m}$ matrix with real entries whose coordinates are determined by the expressions
148+
$$ X_i(t) = x_{i,1}t+x_{i,2}t^2+\dots+ x_{i,m}t^m$$
149+
When we restrict to the $\mathtt{k}$-th level signature of $X$, $\sigma:= \sigma^{(\mathtt{k})}(X)$, each of its coordinates $\sigma_{i_1, \dots, i_{\mathtt{k}}}$ is a homogeneous
150+
polynomial of degree $\mathtt{k}$ in the $\mathtt{d}\cdot \mathtt{m}$ unknowns $x_{i,j}$ corresponding to the matrix representation of the path $X$. Let $\mathtt{CMon}$ be the canonical monomial path
151+
in $\mathbb{R}^{\mathtt{m}}$ introduced in @TO CMonTensor@. Then $\sigma$ can be computed through the @TO matrixAction@ of $X$ on $\sigma^{(k)}(\mathtt{CMon})$.
152+
Moreover, we can view the entries of $X$ as coordinates in the projective space $\mathbb{P}^{\mathtt{d}\cdot \mathtt{m}-1}$ over some algebraically closed field $\mathbb{K}$ containing
153+
$\mathbb{R}$. Then the matrix action just described gives rise to a rational map $$
154+
\sigma^{(\mathtt{k})}:\mathbb{P}^{\mathtt{d}\cdot \mathtt{m}-1}\rightarrow \mathbb{P}^{\mathtt{d}^{\mathtt{k}}-1}$$
155+
determined by $X\mapsto \sigma^{(\mathtt{k})}(X)$, of degree $\mathtt{k}$. The {\em polynomial signature variety}, denoted $\mathcal{P}_{\mathtt{d},\mathtt{k},\mathtt{m}}$, is then defined to be
156+
the Zariski closure of the image of this map (informally, the closure of the space of all tensors of order $\mathtt{k}$ that arise as signatures of paths of the specified type), while its homogeneous prime ideal is called
157+
{\em polynomial signature ideal} and denoted $P_{{\mathtt{d},\mathtt{k},\mathtt{m}}}$.
158+
Text
159+
We set up the procedure to compute the ideal $P_{\mathtt{d},\mathtt{k},\mathtt{m}}$.
160+
Example
161+
d = 2; k = 3; m = 2;
162+
Text
163+
We create a ring $\mathtt{R}$ with $\mathtt{d}\cdot\mathtt{m}$ variables, corresponding to the entries of a path. Then we create the free algebra $\mathtt{A}$ over $\mathtt{R}$ with $\mathtt{m}$ generators, where we can compute the $\mathtt{k}$-th level signature of the canonical monomial path in $\mathbb{R}^{\mathtt{m}}$.
164+
Example
165+
R = CC[x_1..x_(d*m)]; --x_1, ..., x_(d*m) are the entries of the degree m paths in d-dimensional space, seen as matrices
166+
A = wordAlgebra(m, CoefficientRing => R); --Signatures in m-dimensional space, where the signature of CMon lives.
167+
sigmaCMon = CMonTensor(k, A); sigmaCMon // wordFormat -- The 2nd level signature of CMon
168+
Text
169+
Next we create the @TO genericMatrix@ with $\mathtt{d}\times \mathtt{m}$ variables.
170+
Example
171+
M = genericMatrix (R, d, m)
172+
Text
173+
Finally we compute the matrix action on $\sigma^{(k)}(\mathtt{CMon})$ with @TO (symbol *, Matrix, NCRingElement)@, and then compute the corresponding map on rings using @TO tensorParametrization@.
174+
Example
175+
f = M * sigmaCMon;
176+
sigVarietyParam = tensorParametrization(f, CoefficientRing => CC);
177+
Text
178+
Now that we have the map, any tool for implicitization can be used. We compute its dimension and degree with @TO2 {"NumericalImplicitization::NumericalImplicitization", "NumericalImplicitization"}@.
179+
Example
180+
needsPackage "NumericalImplicitization";
181+
numericalImageDim(sigVarietyParam,ideal 0_R)
182+
numericalImageDegree(sigVarietyParam,ideal 0_R, Verbose => false)
183+
Text
184+
This agrees with the result in Table 3 of @HREF("#ref1","[1]")@, where dimension and degree of the corresponding projective variety is computed.
185+
References
186+
@LABEL("[1]","id" => "ref1")@ Améndola, C., Friz, P., & Sturmfels, B. (2019, January). Varieties of signature tensors. In Forum of Mathematics, Sigma (Vol. 7, p. e10). Cambridge University Press.
187+
188+
Node
189+
Key
190+
"A family of paths on a cone"
191+
Description
192+
Text
193+
We consider the following family of polynomial paths of degree 6:
194+
Example
195+
S = QQ[a_1..a_6]
196+
R = S[t]
197+
u = a_1*t + a_2*t^2 + a_3*t^3;
198+
v = a_4*t + a_5*t^2 + a_6*t^3;
199+
X = polyPath({u^2 - v^2, 2*u*v, u^2 + v^2});
200+
Text
201+
Let us take a look at its signature matrix variety. We obtain its parametrization as follows:
202+
Example
203+
sigMatrix = sig(X,2);
204+
S = QQ[s_(1,1)..s_(3,3)]
205+
vwtable = hashTable apply(gens S, i-> (i, new Array from last baseName i))
206+
m = tensorParametrization(sigMatrix, VarWordTable => vwtable);
207+
Text
208+
Let us use numericalImplicitization to obtain information about the dimension of the image.
209+
Example
210+
needsPackage "NumericalImplicitization";
211+
Snum = CC[a_1..a_6];
212+
Rnum = Snum[t];
213+
unum = sub(u, Rnum);
214+
vnum = sub(v, Rnum);
215+
Xnum = polyPath({unum^2 - vnum^2, 2*unum*vnum, unum^2 + vnum^2});
216+
sigMatrixnum = sig(Xnum,2);
217+
mnum = tensorParametrization(sigMatrixnum,CoefficientRing => CC);
218+
numericalImageDim(mnum,ideal 0_Snum)
219+
Text
220+
The universal variety has dimension 6, so we expect at least one additional relation. We use MultigradedImplicitization:
221+
Example
222+
needsPackage "MultigradedImplicitization";
223+
I = sub(ideal flatten values componentsOfKernel(2, m, Grading => matrix {toList(9:1)}), S);
224+
dim I
225+
isPrime I
226+
betti mingens I
227+
degree I
228+
Text
229+
We conclude that our variety is cut out by one linear relation and 6 quadrics. Let us take a look at the linear relation:
230+
Example
231+
lin = select(flatten entries gens I, i-> (degree i == {1}))
232+
Text
233+
We recognize it as a shuffle polynomial in the letters $\mathtt{1},\mathtt{2},\mathtt{3}$. It corresponds to the constraint $X(1) - X(0) \in V(x^2 + y^2 - z^2)$ for paths in our family.
234+
Text
235+
Recall that the universal variety is cut out by the 2-minors of the symmetric part of the matrix. We check if the linear relation is the only additional one on our path family:
236+
Example
237+
A = genericMatrix(S,3,3)
238+
univI = minors(2, A + transpose(A));
239+
I == univI + ideal lin
240+
241+
Node
242+
Key
243+
"The universal variety and toric coordinates"
244+
Description
245+
Text
246+
Recall that $K \langle \mathtt{1}, \ldots, \mathtt{d} \rangle$ is isomorphic to the free commutative algebra over the Lyndon words and if we grade each word by its length, the algebra homomorphism
247+
$$\phi: K[\mathtt{w} \ | \ \mathtt{w} \ \mathrm{Lyndon}] \cong K \langle \mathtt{1}, \ldots, \mathtt{d} \rangle, \ \mathtt{w} \mapsto \mathtt{w}$$
248+
is an isomorphism of graded vector spaces. The inverse $\psi$ of this isomorphism is computed by @TO lyndonShuffle@. Dually, we have the isomorphism of graded vector spaces
249+
$$\psi^*: K[\mathtt{w} \ | \ \mathtt{w} \ \mathrm{Lyndon}]^* \cong K \langle \mathtt{1}, \ldots, \mathtt{d} \rangle^*, \ \alpha \mapsto \alpha \circ \psi.$$
250+
Text
251+
We view the two vector spaces $K\langle \mathtt{1}, \ldots, \mathtt{d}\rangle^*$ and $K[\mathtt{w} \ | \ \mathtt{w} \ \mathrm{Lyndon}]^*$ as infinite-dimensional affine spaces. We are interested in the subset $\mathcal U_d$ of those points of $K\langle \mathtt{1}, \ldots, \mathtt{d}\rangle^*$ that define shuffle algebra homomorphisms. This is a Zariski closed set. As $\psi$ is an algebra homomorphism, they correspond to the points of $K[\mathtt{w} \ | \ \mathtt{w} \ \mathrm{Lyndon}]^*$ under $\psi^*$ that define algebra homomorphisms; these are parametrized by the points of the vector space $K^{\mathcal L}$, where $\mathcal L$ is the set of Lyndon words, via the map
252+
$$\eta: K^{\mathcal L} \to K[\mathtt{w} \ | \ \mathtt{w} \ \mathrm{Lyndon}]^*, \ x \mapsto ev_x.$$
253+
In particular, $\mathcal U_d$ is parametrized by $\psi^* \circ \eta, \ x \mapsto (\mathtt{w} \mapsto \psi(\mathtt{w})(x))$.
254+
255+
Projecting $\mathcal U_d$ to the degree $k$ component, we obtain a subvariety of $((K^d)^{\otimes k})^* \cong (K^d)^{\otimes k}$, called the universal variety, $\mathcal U_{d,k}$.
256+
257+
As the map $\psi$ is compatible with the projection, $\psi^* \circ \eta$ restricts to a parametrization of $\mathcal U_{d,k}$: it is the image of the induced morphism
258+
$$K^{\mathcal L_k} \to (K\langle \mathtt{1}, \ldots, \mathtt{d}\rangle_k)^* \cong (K^d)^{\otimes k}, \ x \mapsto (\psi(\mathtt{w})(x) \cdot \mathtt{w})$$
259+
where $\mathcal L_k$ is the set of Lyndon words of length at most $k$.
260+
261+
As usual, we can compute the ideal that cuts out the image variety as the kernel of the corresponding ring map $$K[x_{\mathtt w} \ | \ \mathtt{w} \text{ of length } k] \to K[y_{\mathtt w} \ | \ \mathtt{w} \text{ Lyndon of length } \leq k].$$ This map can be computed via @TO lyndonShuffle@. Let us do this in the example $d=3, k=3$.
262+
Example
263+
words = toList apply((3:1)..(3:3), i -> new Array from i);
264+
lwords = lyndonWords(3,3)
265+
R = QQ new Array from apply(words, i->x_i);
266+
Q = QQ new Array from (apply(lwords,i->y_i) | {Degrees => apply(lwords, i->length(i))});
267+
A3 = wordAlgebra(3);
268+
lpolyHT = apply(words, i -> lyndonShuffle(i_A3));
269+
lpols = apply(lpolyHT, f -> sum(pairs f, (term,coef) -> coef * product(pairs term, (word,ex)-> y_word^ex)));
270+
lpols_{0..4}
271+
m = map(Q,R,lpols);
272+
Text
273+
Let us compute the kernel.
274+
Example
275+
I = ker m;
276+
dim I
277+
degree I
278+
betti mingens I
279+
(mingens I)_(0,0)
280+
Text
281+
This agrees with the result in Table 2 of @HREF("#ref1","[1]")@.
282+
Text
283+
As $\phi$ is an isomorphism of graded vector spaces, we see that the variety $\mathcal U_{d,k}$ is parametrized by the vector of degree $k$ monomials in Lyndon words after a linear coordinate change on $(K^d)^{\otimes k}$. We can use this to simplify the computation of the universal variety.
284+
Example
285+
mons = flatten entries basis(3,Q);
286+
S = QQ[z_1..z_(length mons)];
287+
m = map(Q,S,mons);
288+
I = ker m;
289+
dim I
290+
degree I
291+
betti mingens I
292+
Text
293+
Let us compute the matrix of the coordinate change for $d=2, k=4$.
294+
Example
295+
words = toList apply((4:1)..(4:2), i-> new Array from i);
296+
lwords = lyndonWords(2,4);
297+
R = QQ new Array from apply(words,i->x_i);
298+
Q = QQ new Array from (apply(lwords,i->y_i) | {Degrees => apply(lwords, i->length(i))});
299+
A2 = wordAlgebra(2);
300+
lpolyHT = apply(words, i -> lyndonShuffle(i_A2));
301+
lpols = apply(lpolyHT, f -> sum(pairs f, (term,coef) -> coef * product(pairs term, (word,ex)-> y_word^ex)));
302+
mons = basis(4,Q)
303+
M = sub(matrix apply(lpols, i -> (flatten entries (coefficients(i, Monomials => mons))#1) ),QQ)
304+
M^(-1)
305+
Text
306+
Note that the coordinate change differs from the one described in Example 21 of @HREF("#ref2","[2]")@ as our toric parametrization does not arise from the exponential map on the Lie algebra. We can easily construct this coordinate change as well, by using @TO lieBasis@ and @TO tensorExp@:
307+
Example
308+
A2 = wordAlgebra(2, CoefficientRing => Q)
309+
lbasis = apply(lwords, i -> lieBasis(i,A2));
310+
lT = sum(0..length(lbasis)-1, i-> Q_i * lbasis_i);
311+
gT = tensorExp(lT,4);
312+
lpols = apply(words, i-> gT @ i_A2)
313+
M = sub(matrix apply(lpols, i -> (flatten entries (coefficients(i, Monomials => mons))#1) ),QQ);
314+
M^(-1)
315+
Text
316+
This is the matrix from Example 21 in @HREF("#ref2","[2]")@. Note that while we obtained the coordinate change by inverting the map that sends a word to its coefficient in the exponential (which is a linear combination of Lyndon word monomials), in @HREF("#ref2","[2]")@ the coordinate change is obtained directly without computing the exponential. Both strategies yield the same result by Lemma 18 in loc. cit..
317+
-- Text
318+
-- Let us compute a path variety after toric coordinate change.
319+
-- Example
320+
-- S = QQ[a_(1,1)..a_(3,2)]
321+
-- A2 = wordAlgebra(3, CoefficientRing => S)
322+
-- T = CAxisTensor(4,A2)
323+
-- A = genericMatrix(S,2,3)
324+
-- m = tensorParametrization(A * T, VarWordTable => hashTable apply(gens R, i-> (i, last baseName i)))
325+
-- cc = map(R,R,flatten entries (M^(-1) * (transpose basis(1,R))))
326+
-- mcc = m * cc;
327+
-- needsPackage "MultigradedImplicitization"
328+
-- I = ideal componentOfKernel({2},source mcc,mcc)
329+
-- J = ideal componentOfKernel({3},source mcc,mcc)
330+
-- dim (I+J)
331+
-- isPrime (I+J)
332+
References
333+
@LABEL("[1]","id" => "ref1")@ Améndola, C., Friz, P., & Sturmfels, B. (2019, January). Varieties of signature tensors. In Forum of Mathematics, Sigma (Vol. 7, p. e10). Cambridge University Press.
334+
335+
@LABEL("[2]","id" => "ref2")@ Galuppi, F. (2019). The rough Veronese variety. Linear algebra and its applications, 583, 282-299.
336+
///
337+
338+
339+
endPackage;
340+
341+
342+
343+
344+
345+
346+
347+
348+
349+
350+
351+

0 commit comments

Comments
 (0)