Blog de Frédéric

Friday, July 30 2010

Master's Project - The Hidden Subgroup Problem

I've submitted my report on The Hidden Subgroup Problem to arXiv.org and I expect it to be published soon.

Comments are welcome on this blog entry.

Saturday, July 24 2010

Using Mozilla to print a scientific report based on Web formats

So I'm finally done with my Master's Project in Quantum Computing at Århus. My final report on The Hidden Subgroup Problem is now available in XHTML and pdf formats. There are also the slides I've made for the oral defense, although as always it is not really useful without the comments. This time, I've used the W3C's slidy tool and so my work is 100% based on Web formats :-)

The Hidden Subgroup Problem still remains difficult with our current knowledge, but I've very appreciated thinking on this challenging topic and I hope my work will help research in this area. As an advocate of the Web as a publishing medium for scientists, I've also found a meta-interest in seeing whether it is possible to use Web formats to produce documents readable both on the screen and on the paper (and in this latter case with the same quality as the more traditional methods). One way to do that is to use TeX-like documents and export them in Web/Printing formats using tools such that Tex4ht or GELLMU. Since my personal preference is to write Web contents by a hybrid method (mixing WYSIWYG and simple-syntax-parsers), I've rather considered how one can print these Web formats. One tool to do that is Prince but I'm not sure it is that good with SVG/MathML (there were some issues last time I tried it). Hence I've preferred to use a free layout engine and thus printed my report with Gecko :-).

The other problems are various bugs in Gecko. Thanks to the recent improvements in MathML (related to stretchy and fonts) , the mathematical formulas are now displayed with a good quality, or at least one of which I'm satisfied. One issue is the incorrect computation of dimension in mtable which is slightly visible for some split equations. I've also discovered a wrong thickness of bars which seems to be the only difference between print and screen renderings. However, I could workaround it and Karl gave me a hint that would hopefully allow to fix the bug. There are still some annoying bugs with linebreaking within mathematical expressions and around them. For the former I can avoid the problem by adding `<mrow/>`'s but the latter makes particularly weird effects. Typically, when some comma or period is placed just after an inline formula, a linebreak may happen and move the punctuation symbol to the beginning of the next line... Regarding quantum circuits and other schemas, the SVG code I use is very elementary. Hence I don't have any complaint to formulate, even if I'm among those who are expecting the possibility to use SVG images in the standard `<img/>` tag. Finally, I have some mysterious bugs with HTML tables printed on several pages and more issues with CSS page breaking, requiring me to do some small manual tweaking at two or three places.

As a conclusion, using Web formats to print a scientific report is not yet so easy. However, I'm quite satisfied of the result and I expect the issues above to be fixed in the near future...

Monday, July 5 2010

Thoughts on the Dihedral Hidden Subgroup Problem (part 3)

Back to the DHSP again (see part 1 and part 2 in previous blog posts)... This time, I've tried to approximate the value of $d$ rather than finding its parity. For convenience, we assume $N$ to be even and define $N\text{'}=2M=\frac{N}{2}$. We consider for $a\in {ℤ}_{N}$ and $b\in {ℤ}_{2}$ the sets of $N\text{'}$ successive values${F}_{a}^{b}=\left\{f\left(a+i,b\right),i\in {ℤ}_{N\prime }\right\}$

We suppose that we can efficiently create uniform superposition over these states. As in part 2, we have ${F}_{a}^{1}={F}_{a-d}^{0}={F}_{s}^{0}$ with $-N and we measure the tensor product of the uniform superpositions over ${F}_{a}^{1}={F}_{s}^{0}$ and ${F}_{0}^{0}$ in the basis ${\mid x⟩\mid x⟩}_{x\in {ℤ}_{N}}$, ${\frac{1}{\sqrt{2}}\left(\mid x⟩\mid y⟩+\mid x⟩\mid y⟩\right)}_{x, ${\frac{1}{\sqrt{2}}\left(\mid x⟩\mid y⟩-\mid x⟩\mid y⟩\right)}_{x. We define $l=\mid {F}_{0}^{0}\cap {F}_{a}^{1}\mid$ the number of common elements.

$f\left(0,0\right)$ f(0,0) $f\left(N\text{'},0\right)$ f(0,0) $f\left(N-1,0\right)$ f(0,0) ${F}_{0}^{0}$ F_0^0 ${F}_{s}^{0}$ F_s^0 $s$ s $l$ l $N\text{'}$ N' $0\le s\le N\text{'}$ 0 ≤ s ≤ N'

The figure above shows that in the case $0\le s\le N\text{'}$, we have $l=N\text{'}-s$. In general, the expression is

$l=\mid N\text{'}-\mid s\mid \mid =\mid N\text{'}-\mid d-a\mid \mid$

Using an analysis similar to the one part 2, we get the probability to measure an element in ${\frac{1}{\sqrt{2}}\left(\mid x⟩\mid y⟩-\mid x⟩\mid y⟩\right)}_{x:

$P=\frac{1}{2}\left[1-{\left(\frac{l}{N\prime }\right)}^{2}\right]$

Repeating the measurements, we can approximate $P$, and consequently $l,s$ and finally $d$. We can also play with the value $a$, to improve the approximation. Unfortunately, using a number of repetitions polynomial in $\mathrm{log}N$, it does not seem possible to bound the error better than $O\left(N\right)$. It seems however that it is still a better result than the one that I obtained with the standard Coset Sampling method. Hence it is another hint of the fact that using a superposition over several oracles values would yield improvement.

I'm still wondering how to create efficiently an uniform superposition over several oracle values. One thing I've read in many papers, is given a superposition over elements $\mid x⟩\mid f\left(x\right)⟩$, erase or uncompute the first register to get a superposition over elements $\mid f\left(x\right)⟩$. However, I'm not sure what are the requirements to apply such an operation. If it could work for the algorithm of part 2, then this would solve the case $N={2}^{n}$.

Alternative content for the top-level math element and Internet Explorer feedback website

Microsoft has a page to provide feedback to the Internet Explorer team, but it seems very far from being as good as other tracking systems. In the bug reports I have read, the answers of the IE team are essentially pre-made messages and they have the bad habit to close reports without fixing the bugs. Two months ago, I requested a modest feature: since Internet Explorer does not have native implementation for MathML, I asked support for attributes `altimg`/`alttext`, so that people can provide alternative content. A few days later, I received a notification:

Thank you for your feedback. We will take your feedback into consideration in our ongoing process of improving Internet Explorer.

and another one, two months later:

Thank you again for your feedback. Since this is a feature request, we will resolve this as by design. However, we have taken your feedback into consideration.

Field Status changed from [Active] to [Resolved]
Field Resolution changed from [None] to [By Design]
Field Status changed from [Resolved] to [Closed]

Not sure how I should interpret these messages, but I'm not really optimistic about that.

Sunday, June 20 2010

Thoughts on the Dihedral Hidden Subgroup Problem (part 2)

In a previous post, I've proposed a way to solve the Dihedral Hidden Subgroup Problem using a superposition of oracle evaluations. However, it seems to require a way to inverse the functions $x↦f\left(x,.\right)$ which is a bit cheating since we do not have this feature for the classical problem. In this post, we will consider the case $M=\frac{N}{N\text{'}}=2$, $d=2d\text{'}+b$ and try to determine the parity $b$ of $d$. If $N$ is a power of two, this is enough to find $d$ recursively. As in the previous post, the main idea is to consider the superpositions

$\mid {\psi }_{0}⟩=\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(2i,0\right)⟩$

and

$\mid {\varphi }_{0}⟩=\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(2i,1\right)⟩$

Using the equality $f\left(g\left(d,1\right)\right)=f\left(g\right)$ we can rewrite the latter state

$\mid {\varphi }_{0}⟩=\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(2i-b,0\right)⟩$

If $b=0$, the latter state is the same superposition as the former state, over $N\text{'}$ values of ${ℤ}_{N}$. Otherwise, $b=1$ and the latter state is the superposition over the $N\text{'}$ other values of ${ℤ}_{N}$. We let ${f}_{i}^{b}=f\left(2i-b,0\right)$ and measure the product state $\mid {\psi }_{0}⟩\mid {\varphi }_{0}⟩$ in the basis ${\mid x⟩\mid x⟩}_{x\in {ℤ}_{N}}$, ${\mid x⟩\mid y⟩+\mid x⟩\mid y⟩}_{x, ${\mid x⟩\mid y⟩-\mid x⟩\mid y⟩}_{x . It turns out that this allows to distinguish the two cases:

• If $b=0$, the product contains vectors with the same coordinates $\mid {f}_{i}^{0}⟩\mid {f}_{i}^{0}⟩$ for $i\in {ℤ}_{N}$. For the other vectors, we have a symmetry between the two coordinates. Hence we can group them by pairs $\mid {f}_{{i}_{1}}^{0}⟩\mid {f}_{{i}_{2}}^{0}⟩+\mid {f}_{{i}_{2}}^{0}⟩\mid {f}_{{i}_{1}}^{0}⟩$ for ${i}_{1}<{i}_{2}\in {ℤ}_{N}$. Finally, the product state belongs to the space spanned by ${\mid x⟩\mid x⟩}_{x\in {ℤ}_{N}}$ and ${\mid x⟩\mid y⟩+\mid x⟩\mid y⟩}_{x.
• If $b=1$, the product contains vectors $\mid {f}_{{i}_{1}}^{0}⟩\mid {f}_{{i}_{2}}^{1}⟩$ where the two coordinates are not equal. We never have two symmetric vectors i.e. which are the same after permutating the two coordinates. Moreover, each vector $\mid {f}_{{i}_{1}}^{0}⟩\mid {f}_{{i}_{2}}^{1}⟩$ is the expression of a sum/difference (according to the respective order of ${f}_{{i}_{1}}^{0}$ and ${f}_{{i}_{2}}^{1}$) of two vectors $\mid x⟩\mid y⟩+\mid x⟩\mid y⟩$ and $\mid x⟩\mid y⟩-\mid x⟩\mid y⟩$. So the product state belongs half to ${\mid x⟩\mid y⟩+\mid x⟩\mid y⟩}_{x and half to ${\mid x⟩\mid y⟩-\mid x⟩\mid y⟩}_{x.

Suppose that we have a procedure to create many states $\mid {\psi }_{0}⟩$ and $\mid {\varphi }_{0}⟩$. We measure a state in the space ${\mid x⟩\mid y⟩-\mid x⟩\mid y⟩}_{x with probability $\frac{b}{2}$. So repeating the procedure a constant number of times allow to determine $b$ with high probability.

The only gap in the previous algorithm is whether we can create the states $\mid {\psi }_{0}⟩$ and $\mid {\varphi }_{0}⟩$. As in the previous post, this is possible if the gates ${V}_{f,.}$ are available. Otherwise, we can create a superposition of states over ${ℤ}_{N\text{'}}$ and use the gate ${U}_{f}$ as well as a Quantum Fourier Transform to randomize the first coordinate. We get two random numbers ${j}_{1},{j}_{2}\in {ℤ}_{N\text{'}}$ and the states

$\mid {\psi }_{{j}_{1}}⟩=\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}{e}^{\frac{2i\pi {j}_{1}i}{N\prime }}\mid f\left(2i,0\right)⟩$

and$\mid {\varphi }_{{j}_{2}}⟩=\frac{{e}^{\frac{2i\pi {j}_{2}d\prime }{N\prime }}}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}{e}^{\frac{2i\pi {j}_{2}i}{N\prime }}\mid f\left(2i-b,0\right)⟩$

Next, we can apply the same measurement as above. After a bit of calculation,we get the probabilities:

Space case $b=0$ case $b=1$
${\mid x⟩\mid x⟩}_{x\in {ℤ}_{N}}$ $\frac{1}{N\text{'}}$ 0
${\mid x⟩\mid y⟩+\mid x⟩\mid y⟩}_{x $\frac{2}{{N\prime }^{2}}\sum _{{i}_{2}=0}^{N\prime -1}\sum _{{i}_{1}=0}^{{i}_{2}-1}{\mathrm{cos}}^{2}\frac{\pi }{N\prime }\left({j}_{2}-{j}_{1}\right)\left({i}_{2}-{i}_{1}\right)$ $\frac{1}{2}$
${\mid x⟩\mid y⟩-\mid x⟩\mid y⟩}_{x $\frac{2}{{N\prime }^{2}}\sum _{{i}_{2}=0}^{N\prime -1}\sum _{{i}_{1}=0}^{{i}_{2}-1}{\mathrm{sin}}^{2}\frac{\pi }{N\prime }\left({j}_{2}-{j}_{1}\right)\left({i}_{2}-{i}_{1}\right)$ $\frac{1}{2}$

If we repeat the procedure several times, we need to take the means over the choice of ${j}_{1},{j}_{2}\in {ℤ}_{N\text{'}}$. Using some trigonometric identities, it is possible to write the sums of the first column $\frac{1}{2}+S+o\left(\frac{1}{N\text{'}}\right)$ where $S$ is a sum of cosinus. Unfortunately, evaluating $S$ with a computer suggests that $S=\Theta \left(\frac{1}{N\text{'}}\right)$ . Hence, we can not distinguish the two cases with only a polynomial (in $\mathrm{log}N$) number of samplings.

It is still open whether we can find a variation to make such an algorithm efficient...

Wednesday, June 16 2010

Thoughts on the Dihedral Hidden Subgroup Problem

This morning, I've been thinking again about a way to solve the Hidden Subgroup Problem for the dihedral group ${D}_{N}={ℤ}_{N}{⋊}_{\phi }{ℤ}_{2}$ (where $\phi \left(1\right)$ is the inversion of ${ℤ}_{N}$). It is well-known that there exists a reduction to the case where the hidden subgroup is $H=⟨\left(d,1\right)⟩$ for some $d\in {ℤ}_{N}$. In that case, if we fix $b\in \left\{0,1\right\}$, the elements $\left(i,b\right)$ for $i\in {ℤ}_{N}$ form a complete set of coset representatives, so $f$ is one-to-one over ${ℤ}_{N}×\left\{b\right\}$. Thus, $x↦f\left(x,b\right)$ is a permutation of ${ℤ}_{N}$, a property that will be used below to construct a unitary transform.

First let's recall the classical inductive method to determine $d$. If $M$ is a divisor of $N$, let $N\text{'}=\frac{N}{M}$ and write the euclidean division $d=Md\text{'}+r$. If we are able to determine $r$ in polynomial time, then we can define the oracle $f\text{'}\left(x,y\right)=f\left(Mx+r,y\right)$ for $x\in {ℤ}_{N\text{'}}$ and $y\in {ℤ}_{2}$ and obtain a dihedral HSP with hidden subgroup $⟨\left(d\text{'},1\right)⟩$. Since the prime factorization has only $O\left(\mathrm{log}N\right)$ factors, we can repeat this inductive step to get an efficient algorithm. Of course, this is likely to be useful only when the factors are small for otherwise it may be as much difficult to determine $r$ as to determine the whole $d$. One interesting case is $N={2}^{n}$ and $M=2$: at each step, $N$ remains a power of 2 and we determine the parity of $d$.

For $0\le l, we consider the $N\text{'}$-dimensional subspace spanned by the vectors $\mid lN\text{'}+m⟩$ for $0\le m. Since these $M$ subspaces are orthogonal, we can construct a unitary transform by applying a Quantum Fourier Transform ${F}_{N\text{'}}$ on each subspace separately. Finally, we apply the permutation mentionned at the beginning for $b=0$. We get a unitary transform $W$ below where $x=Mi+k$ is the euclidean division of $x$ by $M$:

$\forall x\in {Z}_{N},W\mid x⟩=\frac{1}{\sqrt{N\prime }}\sum _{j=0}^{N\prime -1}{e}^{2i\pi \frac{ij}{N\prime }}\mid f\left(Mj+k,0\right)⟩$

Now, let's consider the superposition (again, we see that it is well-defined by considering the permutation mentionned at the beginning for $b=1$):

$\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(Mi,1\right)⟩$

The state can be rewritten, using the fact that $f$ is constant on $H=⟨\left(d,1\right)⟩$:

$\begin{array}{rl}\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(Mi,1\right)⟩& =\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(Mi-d,0\right)\left(d,1\right)⟩\\ & =\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(Mi-d,0\right)⟩\\ & =\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(Mi-\left(Md\prime +r\right),0\right)⟩\\ & =\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(M\left(i-d\prime +\left(N\prime -1\right)\right)+\left(M-r\right),0\right)⟩\\ & =\frac{1}{\sqrt{N\prime }}\sum _{i=0}^{N\prime -1}\mid f\left(Mi+\left(M-r\right),0\right)⟩\end{array}$

Applying ${W}^{-1}$ to this state gives and so the value of $r$ by a measurement in the standard basis.

Two questions remain: can we implement $W$ and create the state $\mid \Psi ⟩$ efficiently? If $N={2}^{n}$ and $M=2$, there are many simplifications because we are working with qubits. In that case, it is easy to see that the answer to the previous questions is affirmative if we have gates ${V}_{f,b}\mid x⟩=\mid f\left(x,b\right)⟩$ implementing the permutation mentioned at the beginning. However, it is not clear how to build ${V}_{f,b}$ from the gate ${U}_{f}$ generally given in the classical presentation of the problem...

update: OK, there is also the trivial solution $N=M,N\text{'}=1$where the algorithm above is just computing . However, I'm still wondering if there is a way to modify the previous method to work with ${U}_{f}$.

Monday, June 14 2010

XSLT Stylesheet to help updating the MathML Operator Dictionary

MathML 3 comes with a new version of the operator dictionary and I expect to update Mozilla's own version accordingly. Some members of the MathML WG have actually written a separate recommendation XML Entity Definitions for Characters which contains various information on Unicode characters, including some properties relevant to mathematical operators. They provide a file unicode.xml which is very large (> 6Mb) so I've written an XSLT stylesheet to extract only the information required for the operator dictionary. The stylesheet does nothing magical: it only creates an XML document with a `<root/>` and `<entry/>`'s children. The attributes from the initial unicode.xml are attached to each of these entries, using the compact form of the MathML 3 dictionary for boolean-valued properties.

Using the xsltproc tool, the typical command is

```xsltproc -o dictionary.xml operatorDictionary.xsl unicode.xml```

which produces a XML file `dictionary.xml` of moderate size (< 150 ko) that should be easier to process. I hope it will help developers of MathML tools to align on the new operator dictionary. Note that the stylesheet is distributed under a triple MPL/GPL/LGPL licence, so people should be able to use it freely.

Friday, June 11 2010

stixfonts.org was last updated on 28 May. The next update will occur mid-June.

Two weeks ago, STIX Fonts Version 1.0 was finally released! Hence after about 15 years of work and regular announce of upcoming release, we now have a comprehensive set of Unicode fonts for mathematical symbols. Hopefully, this will greatly improve the rendering of MathML in browsers. However, this new version is not entirely compatible with the current version of Firefox, because some font files were renamed. A patch landed yesterday on trunk to fix this issue but I don't know whether it will also be pushed to old branch. For those who want to test the new STIX Fonts with the current version of Firefox, you just need to install STIX 1.0 and keep the former `STIXSiz*.otf` files from STIX Beta...

Sunday, May 30 2010

New pages written during the first semester at Århus

Today, I have added some pages to the international section of the website. Apart my hand-in exam for the course Category Theory for Computer Science, there are pages on Riemannian Geometry: my notes for the oral exam, my proposal of solutions to the exercises 4.12 and 7.1 of Lee's book (Riemannian Manifolds, An Introduction to Curvature) and my proof of the fact that in a 3-dimensional riemannian manifold, the curvature tensor is determined by the Ricci curvature. This proof uses a funny relationship between the determinant of the linear system involved and the one of the matrix of the riemannian metric that I have obtained using Maxima (yes, I'm too lazy to compute the determinant of a $6×6$ matrix). I haven't written material about the other courses but I hope to make available my report on Quantum Computation when I'm finished.

Monday, May 24 2010

Two contributions to the Hidden Subgroup Problem

Today, I have finished the preliminary version of my report on the Hidden Subgroup Problem (HSP). For those who have never heard about it before, we are given a finite group $G$, a subgroup $H$ and a function $f:G\to S$. This function is constant on each (left) coset of $H$ but takes different values on distinct cosets. Said otherwise we have:

$\forall {g}_{1},{g}_{2}\in G,f\left({g}_{1}\right)=f\left({g}_{2}\right)⇔{g}_{1}H={g}_{2}H$The purpose is to identify the "hidden" subgroup $H$ (for instance we can return a generating set) with a complexity polynomial in $\mathrm{log}\mid G\mid$. Although it may seem really abstract, this problem allows to describe various quantum algorithms exponentially faster than their known classical versions. This includes the famous Shor's algorithm for integer factorization, which can break the ubiquitous RSA cryptosystem. Shor's algorithm uses a solution to HSP over a cyclic group but we have quantum algorithms for the larger class of dedekindian groups as well as miscellaneous other groups. Unfortunately, these algorithms are not enough to solve HSP over the dihedral group or the symmetric group. These two cases are particularly interesting since the former could solve a lattice problem used in cryptography to establish security proofs while a solution to the latter provides an efficient algorithm for the graph isomorphism problem.

For the moment, I have essentially reviewed the major results on dedekindian, dihedral and symmetric groups. Even if there is not many new things for researchers working on that topic, I hope it could serve as an introduction to the subject and be a useful review of the state-of-the-art. In particular, I plan to complete the Table of Hidden Subgroup Problems which gives a good overview. There are at least two contributions I brought to the topic that I would like to discuss briefly in this blog post.

First, I have studied how Regev's algorithm works. As stated in his paper, we have a solution to the $\text{poly}\left(\mathrm{log}N\right)$-uniqueSVP if we can find a hidden subgroup $H=⟨\left(d,1\right)⟩$ in the dihedral group ${D}_{N}$ using coset sampling on the whole group. This point is often overlooked in several papers, where the reader could understand that an arbitrary solution to the dihedral HSP works. Fortunately, Regev's algorithm is sufficiently close to the coset sampling procedure so that we can modify it to include some kinds of recursive algorithm. With such a modification, a solution like Kuperberg's algorithm (where we apply coset sampling on subgroups of ${D}_{N}$) becomes acceptable. Actually, we can also modify the algorithm to work with the generalized dihedral group. Another remark is about the degree of the approximation given by Regev's algorithm: I have shown that we have a solution to the $\Theta \left({n}^{\frac{1}{2}+2D}\right)$-uniqueSVP if the query complexity of the HSP algorithm used is $O\left({\left(\mathrm{log}N\right)}^{D}\right)$, thus providing a more accurate statement.

Recently, I have considered a general approach to the HSP using the classical description of finite group via composition series and simple groups. The idea is that if $N$ is a non-trivial normal subgroup of $G$ we can split the problems on two HSPs over $G}{N}$ and $N$. We can repeat the procedure until we reach simple groups. Because the length of a composition series is polynomial in $\mathrm{log}\mid G\mid$, we get a solution to the general HSP under two conditions: we have algorithms for HSP over simple groups and we can build efficient oracles on the "reduced" groups. I've succeeded to find an alternative algorithm for the abelian case based on that framework but for the dihedral/symmetric, it seems that the two previous assumptions are exactly what we are stuck on. However, it could still be useful to solve HSP over other groups.

Now, my priority is to review the results we have for some semidirect products but I hope to have time to study various open issues such that HSP over simple groups, HSP-based algorithms etc

Thursday, May 6 2010

To kill five bugs with one stone

The `<semantics/>` has long been used by people who work on MathML tools. The idea is to have a MathML formula as the first child and to use the other children as annotations. These are an important information for software tools but should really not be shown by viewers. Roger B. Sidje fixed bug 154931 about seven years ago by adding CSS rules to display only the first child of a `<semantics/>` element. This looks an appropriate fix. However several issues have been reported in the last two years, regarding the `<semantics/>` element.

Some of these issues involved complicated context such that combination with `<maction/>` or javascript. Fortunately, some reduced testcases were provided afterwards. I could at least explain one of these bugs: the fact that displaystyle is not inherited through a `<semantics/>` element. Indeed, this inheritance is implemented in MathML frame classes but no class existed for `<semantics/>`! Of course, this absence of class was also likely to break many things in the MathML layout mechanisms since it basically prevented communication between MathML element frames.

Hence I've written a patch which is just implementing a `nsMathMLsemanticsFrame` class (the only thing this class adds with respect to its parent is the handling of embellished operator data). As expected, this simple change fixed the displaystyle bug. Furthermore, it also solved all the other `<semantics/>`-related issues as I could easily check using the testcases.

This is an example where something that looks like a minor defect - namely, the lack of frame class for a MathML element - can lead to many non-trivial bugs! Moreover, it demonstrates once again the importance of bug triage, since reducing testcases and grouping the <semantics/>-related issues in one meta bug have been very useful for solving that issue. The fix I've proposed does not add the desired behaviour for semantics, but maybe someone else will work on this in the future...

Sunday, May 2 2010

Hacking Dotclear 2 for writing XHTML+MathML+SVG

Of course, the first thing I've checked after setting this blog is whether it is possible to have a `XHTML+MathML+SVG` page in dotclear. As indicated in the Mozilla MathML Project page, one has to:

1. serve the page as `application/xhtml+xml`.

This is simply done by editing the value of parameter `\$content_type` in the function `serveDocument` of the file `dotclear/inc/public/lib.urlhandlers.php`.

2. write well-formed XML document.

Apparently, dotclear is good enough to do that. However, its editor does not seem to have any option for producing MathML or SVG. Personally, I don't use the wiki syntax and prefer to write the XHTML page myself with the tools I'm used to (no, I don't mean a code editor... I'm not crazy!). As a consequence, this is not really a problem for me.

It is also a good idea to write a valid XML document. By default, dotclear uses the doctype `XHTML 1.0 Strict` so I had to modify the files `themes/name_of_your_theme/tpl/*.html` to set `XHTML+MathML+SVG` instead.

Once this simple changes are made, you can insert MathML formulas such that this expression of a general Quantum Fourier Transform over a finite group:$\forall g\in G,{F}_{G}\mid g⟩=\frac{1}{\sqrt{\mid G\mid }}\sum _{\rho \in \stackrel{̂}{G}}\sqrt{{d}_{\rho }}\sum _{i,j=1}^{{d}_{\rho }}{\rho }_{ij}\left(g\right)\mid \rho ij⟩$

or SVG images such that this quantum circuit used in the famous Shor's algorithm:

$\left|{0}^{n}\right⟩$ |0^n⟩ $\left|{0}^{n}\right⟩$ |0^n⟩ ${U}_{f}$ U_f ${F}_{N}$ F_N ${F}_{N}$ F_N

Voilà!

Mise en place d'un blog

Voilà, je viens de mettre en place ce blog aujourd'hui. J'espère ainsi profiter des avantages offerts par ce medium: syndication de contenu, archivage en catégories, possibilité d'avoir des commentaires etc. Je compte m'en servir pour parler de mes différents travaux et il me sera alors indispensable de pouvoir utiliser le format `XHTML+MathML+SVG`. Par conséquent, mon prochain billet sera sur la manière de paramètrer Dotclear pour pouvoir répondre à ce besoin.