Algebraic Expression Simplifier

Xingbang Liu & Zijun Xia

4/23/2019


Linear Algebra flickr photo by Ewan Cross shared under a Creative Commons (BY-NC-ND) license

What is our project?

Compiler-like algebraic expression simplifier

  • It can simplify the algebraic expression
demo

What is our project?

Tools

  • Tokenizer, parser, and optimizer
  • Python3, LLVMPY, and PLY

Why These Tools?

  • Python3 is easy to use
  • PLY is based on Python,
    • contains LAX as tokenizor
    • YACC as parser
  • LLVMPY is the optimizer, python version of LLVM

Motivation

  • Chemical formula translator
  • Get a better understanding of the compiler by using easier objects
  • Solve the real life problem
formula

The Grammer

  • Operators: PLUS, MINUS, TIMES, etc
  • Constants: ln2, 2^2, etc
  • Regular numbers
  • Variables: x^2, y^23

e.g. x^2 + 2x^2 + ln3 =

The Precedence of Parser

It is simple shift-reduce parser (LR(1)), because they are simple expressions

The precedence:
('left','PLUS','MINUS')
('left','TIMES','DIVIDE')
('right','UMINUS') e.g. (-5)

Challange

  • Rugular expression
  • Get familiar with new tools
  • Constract rules

Demo

Where to Go From Here?

Dedending on how many time we left, we can finish the parser or optimizer

The End