1. An optical-symbol-recognition system comprising: one or more processors; one or more memories; and computer instructions, stored in one or more of the one or more memories that, when executed by one or more of the one or more processors, control the optical-symbol-recognition system to process an image containing a mathematical expression by applying blocking to the image containing the mathematical expression to decompose the image into an ordered set of symbol variants, selecting, from among candidate paths corresponding to the ordered set of symbol variants, a most probable path, using the most probable path and ordered set of symbol variants to generate an encoded mathematical expression equivalent to the mathematical expression contained in the image, and storing the encoded mathematical expression in one or more of the one or more memories.