Unicode Support for Mathematics Murray Sargent III Microsoft

  • Slides: 29
Download presentation
Unicode Support for Mathematics Murray Sargent III Microsoft

Unicode Support for Mathematics Murray Sargent III Microsoft

Overview v Unicode math characters v Semantics of math characters v Unicode and markup

Overview v Unicode math characters v Semantics of math characters v Unicode and markup v Multiple ways of encoding math characters v Not yet standardized math characters v Inputting math symbols

Unicode Math Characters • 340 math chars exist in ASCII, U+2200 – U+22 FF,

Unicode Math Characters • 340 math chars exist in ASCII, U+2200 – U+22 FF, arrows, combining marks of Unicode 3. 0 • 996 math alphanumeric characters are proposed to be added as requested by STIX project. Plane 1 • 951 new math symbols and operators are proposed for BMP • One math variant code • One new combining character (reverse solidus).

Math Alphanumeric Characters 1. Math needs various Latin and Greek alphabets like normal, bold,

Math Alphanumeric Characters 1. Math needs various Latin and Greek alphabets like normal, bold, italic, script, Fraktur, and open-face 2. May appear to be font variations, but have distinct semantics 3. Without these distinctions, you get gibberish, violating Unicode rule: plain text must contain enough info to permit the text to be rendered legibly, and nothing more 4. Plain-text searches should distinguish between alphabets, e. g. , search for script H shouldn’t match H, etc. 5. Reduces markup verbosity

Legibility Loss Without math alphabets, the Hamiltonian formula H = dτ [εE 2 +

Legibility Loss Without math alphabets, the Hamiltonian formula H = dτ [εE 2 + μH 2] becomes an integral equation H = dτ [εE 2 + μH 2]

Math Alphanumeric Chars (cont) Bold Italic Bold italic Script Bold script Fraktur Bold Fraktur

Math Alphanumeric Chars (cont) Bold Italic Bold italic Script Bold script Fraktur Bold Fraktur Open-face Sans-serif bold Sans-serif italic Sans-serif bold italic Monospace a-z, A-Z, 0 -9, -Ω a-z, A-Z, -Ω a-z, A-Z a-z, A-Z, 0 -9, -Ω a-z, A-Z, -Ω a-z, A-Z, 0 -9

How Display Math Alphabets? u u Can use Unicode surrogate pair mechanisms available on

How Display Math Alphabets? u u Can use Unicode surrogate pair mechanisms available on OS Alternatively, bind to standard fonts and use corresponding BMP characters. Second approach probably faster and to display Unicode one needs font binding in any event. A single math font may look more consistent.

Multiple Character Encodings u u u As with nonmath characters, math symbols can often

Multiple Character Encodings u u u As with nonmath characters, math symbols can often be encoded in multiple ways, composed and decomposed E. g. , ≠ can be U+003 D, U+0338 or U+2260 Recommendation: use the fully composed symbol, e. g. , U+2260 for ≠ For alphabetic characters, use the fully decomposed sequence, e. g. , use U+0061, U+0308 for ä, not U+00 E 4 Some representations use markup for the alphabetic cases. This allows multicharacter combining marks.

Compatibility Holes u u Compatibility holes (reserved positions) exist in some Unicode sequences to

Compatibility Holes u u Compatibility holes (reserved positions) exist in some Unicode sequences to avoid duplicate encodings (ugh!) E. g. , U+2071 -U+2073 are holes for ¹²³, which are U+00 B 9, U+00 B 2, and U+00 B 3, respectively Math alphanumerics have holes corresponding to Letterlike symbols. Recommendation: you can use the hole codes internally, but should import and export the standard codes.

Math Glyph Variants u One approach to the math alphanumerics was to use a

Math Glyph Variants u One approach to the math alphanumerics was to use a set of math glyph variant tags u Such a tag follows a base character imparting a math style u Approach was dropped since it seemed likely to be abused u One math variant tag does exist for purposes of offering a different line slant for some composite symbols.

Nonstandard Characters u People will always invent new math characters that aren’t yet standardized.

Nonstandard Characters u People will always invent new math characters that aren’t yet standardized. u Use private use area for these with a higher-level marking that these are for math. u This approach can lead to collisions in the math community (unless a standard is maintained) u Cut/copy in plain text can have collisions with other uses of the private use area

Unicode and Markup • • • Unicode was never intended to represent all aspects

Unicode and Markup • • • Unicode was never intended to represent all aspects of text Language attribute: sort order, word breaks Rich (fancy) text formatting: built-up fractions Content tags: headings, abstract, author, figure Glyph variants: Poetica font: 58 ampersands; Mantinia font: novel ligatures (TT, TE, etc. ) • Math. ML adds XML tags for math constructs, but seems awfully wordy

Unicode Plain Text • Can do a lot with plain text, e. g. ,

Unicode Plain Text • Can do a lot with plain text, e. g. , Bi. Di • Grey zone: use of embedded codes • Unicode ascribes semantics to characters, e. g. , paragraph mark, right-to-left mark • Lots of interesting punctuation characters in range U+2000 to U+204 F • Extensive character semantics/properties tables, including mathematical, numerical

Unicode Character Semantics u u u u Math characters have math property Math characters

Unicode Character Semantics u u u u Math characters have math property Math characters are numeric, variable, or operator, but not a combination Properties are useful in parsing math plain text Math. ML doesn’t use these properties: every quantity is explicitly tagged Properties still can be useful for inputting text for Math. ML (noone wants to type all those tags!) Sometimes default properties need to be overruled Might be useful to have more math properties

Plain Text Encoding • TEX fraction numerator is what follows a { up to

Plain Text Encoding • TEX fraction numerator is what follows a { up to keyword over • Denominator is what follows the over up to the matching } • { } are not printed • Simple rules give unambiguous “plain text”, but results don’t look like math • How to make a plain text that looks like math?

Simple plain text encoding • Simple operand is a span of non-operator characters •

Simple plain text encoding • Simple operand is a span of non-operator characters • E. g. , simple numerator or denominator is terminated by any operator • Operators include arithmetic operators, whitespace character, all U+22 xx, an argument “break” operator (displayed as small raised dot), sub/superscript operators • Fraction operator is given by the Unicode fraction slash operator U+2044

Fractions • abc/d gives • More complicated operands use parentheses ( ), brackets [

Fractions • abc/d gives • More complicated operands use parentheses ( ), brackets [ ], or { } • Outermost parens aren’t displayed in built-up form • E. g. , plain text (a + c)/d displays as • Easier to read than TEX’s, e. g. , {a + c over d} • Math. ML: <mfrac><mrow><mi>a</mi><mo>+</mo> <mi>c</mi></mrow><mi>d</mi> </mrow></mfrac> • Neat feature: plain text usually looks like math

Subscripts and Superscripts u u Unicode has numeric subscripts and superscripts along with some

Subscripts and Superscripts u u Unicode has numeric subscripts and superscripts along with some operators (U+2070 -U+208 E). Others need some kind of markup like <msup>…</msup> With special subscript and superscript operators (not yet in Unicode), these scripts can be encoded nestibly. Use parentheses as for fractions to overrule built-in precedence order.

Unicode TEX Example

Unicode TEX Example

Symbol Entry § § § GUI PCs can display a myriad glyphs, mathematics symbols,

Symbol Entry § § § GUI PCs can display a myriad glyphs, mathematics symbols, and international characters Hard to input special symbols. Menu methods are slow. Hot keys are great but hard to learn Reexamine and improve symbol-input and storage methods With left/right Ctrl/Alt keys, PC keyboard gives direct access to 600 symbols. Maximum possible = 2100 = 1030 Use on-screen, customizable, keyboards and symbol boxes Drag & drop any symbol into apps or onto keyboards

Hex to Unicode Input Method u Type Unicode character hexadecimal code u Make corrections

Hex to Unicode Input Method u Type Unicode character hexadecimal code u Make corrections as need be u Type Alt+x to convert to character u Type Alt+x to convert back to hex (useful especially for “missing glyph” character) u Resolve ambiguities by selection u Input higher-plane chars using 5 or 6 -digit code u New MS Office standard

Built-Up Formula Heuristics 1. 2. 3. 4. Math characters identify themselves and neighbors as

Built-Up Formula Heuristics 1. 2. 3. 4. Math characters identify themselves and neighbors as math E. g. , fraction (U 2044), ASCII operators, U 2200 –U 22 FF, and U 20 D 0–U 20 FF identify neighbors as mathematical Math characters include various English and Greek alphabets When heuristics fail, user can select math mode: WYSIWYG instead of visible math on/off codes

Operator Precedence • Everyone knows that multiply takes precedence over add, e. g. ,

Operator Precedence • Everyone knows that multiply takes precedence over add, e. g. , 3+5× 3 = 18, not 24 • C-language precedence is too intricate for most programmers to use extensively • TEX doesn’t use precedence; relies on { } to define operator scope • In general, ( ) can be used to clarify or overrule precedence • Precedence reduces clutter, so some precedence is desirable (else things look like LISP!) • But keep it simple enough to remember easily

Layout Operator Precedence Subscript, superscript Integral, sum Functions Times, divide Other operators Right brackets

Layout Operator Precedence Subscript, superscript Integral, sum Functions Times, divide Other operators Right brackets Left brackets End of paragraph ¯ SP Ö / * × · • Space ". , = - + LF Tab )]}| ([{ FF CR EOP

Mathematics as a Programming Language u u u u Fortran made great steps in

Mathematics as a Programming Language u u u u Fortran made great steps in getting computers to understand mathematics Java accepts Unicode variable names C++ has preprocessor and operator overloading, but needs extensions to be really powerful Use Unicode characters including math alphanumerics Use plain-text encoding of mathematical expressions Can’t use all mathematical expressions as code, but can go much further than current languages go When to to multiply? In abstract, multiplication is infinitely fast and precise, but not on a computer

void IHBMWM(void) { gammap = gamma*sqrt(1 + I 2); upsilon = cmplx(gamma+gamma 1, Delta);

void IHBMWM(void) { gammap = gamma*sqrt(1 + I 2); upsilon = cmplx(gamma+gamma 1, Delta); alphainc = alpha 0*(1 -(gamma*I 2/gammap)/(gammap + upsilon)); if (!gamma 1 && fabs(Delta*T 1) < 0. 01) alphacoh = -half*alpha 0*I 2*pow(gamma/gammap, 3); else { Gamma = 1/T 1 + gamma 1; I 2 s. F = (I 2/T 1)/cmplx(Gamma, Delta); betap 2 = upsilon*(upsilon + gamma*I 2 s. F); beta = sqrt(betap 2); alphacoh = 0. 5*gamma*alpha 0*(I 2 s. F*(gamma + upsilon) /(gammap*gammap - betap 2)) *((1+gamma/beta)*(beta - upsilon)/(beta + upsilon) - (1+gamma/gammap)*(gammap - upsilon)/ (gammap + upsilon)); } alpha 1 = alphainc + alphacoh; }

Conclusions § § § Unicode provides great support for math in both marked up

Conclusions § § § Unicode provides great support for math in both marked up and plain text Unicode character properties facilitate plain-text encoding of mathematics but aren’t used in Math. ML Heuristics allow plain text to be built up Need two more Unicode assignments: subscript and superscript operators On-screen keyboards and symbol boxes aid formula entry Unicode math characters could be useful for programming languages