Skip to content

Project Proposal: LaTeX Equation Language (LEL): LaTeX equation to LLVM #610

@YoruCathy

Description

@YoruCathy

What will you do?
I will implement a compiler which will be refered to as LEL (LaTeX Equation Language), that translates LaTeX-formatted mathematical equations into executable LLVM IR code.
LaTeX is a common language for writing professional documents like academic papers. In the past, I have worked on many research projects that involve implementing mathematical equations. It’s natural to think of a tool that converts the LaTeX formatted equations into usable code directly and allows the generated code to connect with other developing technologies.
The goal is to enable direct conversion from symbolic mathematical notation (as used in academic papers) to low-level program code, bridging the gap between human-readable formulas and machine-executable representations.

The compiler will focus on supporting a subset of LaTeX equation grammar, specifically:

  • Arithmetic expressions
  • Conditional expressions (using \begin{cases})
  • Function definitions and recursive function calls

How will you do it?

  1. Parse LaTeX equations into an internal form for three constructs: arithmetic, piecewise conditions via \begin{cases}...\end{cases}, and function calls/definitions.
  2. Infer semantics: treat the left-hand symbol as the function name; collect single-letter variables on the right-hand side as arguments; interpret \text{if} predicates and \text{otherwise} as control flow; use a consistent integer type.
  3. Generate LLVM IR: emit a function per equation, allocate and load locals for arguments, lower arithmetic ops, build conditional branches for cases with a shared exit, and lower function calls with call.

How will you empirically measure success?
I will first verify the compiler’s correctness with a small set of hand-written LaTeX test cases for arithmetic equations, piecewise conditions, and recursive function calls. For each case, I will manually check that the generated LLVM IR structure and outputs match the expected behavior. After confirming these core cases, I will leverage GPT to automatically generate a larger benchmark suite of LaTeX equations covering varied arithmetic and conditional patterns. This expanded set will test the robustness of the parser and code generator across diverse equation structures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions