All Projects → HarrisonGrodin → Rewrite.jl

HarrisonGrodin / Rewrite.jl

Licence: mit
An efficient symbolic term rewriting engine

Programming Languages

julia
2034 projects

Labels

Projects that are alternatives of or similar to Rewrite.jl

Cmathtuts
trying to collect all useful tutorials for famous C math and linear algebra libraries such as CBLAS, CLAPACK, GSL...
Stars: ✭ 266 (+336.07%)
Mutual labels:  algebra
Gap
Main development repository for GAP - Groups, Algorithms, Programming, a System for Computational Discrete Algebra
Stars: ✭ 447 (+632.79%)
Mutual labels:  algebra
Matryoshka
Generalized recursion schemes and traversals for Scala.
Stars: ✭ 764 (+1152.46%)
Mutual labels:  algebra
Grassmann.jl
⟨Leibniz-Grassmann-Clifford⟩ differential geometric algebra / multivector simplicial complex
Stars: ✭ 289 (+373.77%)
Mutual labels:  algebra
Fp Resources
Functional programming great resources
Stars: ✭ 369 (+504.92%)
Mutual labels:  algebra
Derive4j
Java 8 annotation processor and framework for deriving algebraic data types constructors, pattern-matching, folds, optics and typeclasses.
Stars: ✭ 511 (+737.7%)
Mutual labels:  algebra
Angourimath
Open-source symbolic algebra library for C# and F#. One of the most powerful in .NET
Stars: ✭ 266 (+336.07%)
Mutual labels:  algebra
Algebra Latex
Parse and calculate latex formatted math
Stars: ✭ 20 (-67.21%)
Mutual labels:  algebra
Algebra
Experimental project to lay out basic algebra type classes
Stars: ✭ 377 (+518.03%)
Mutual labels:  algebra
Static Land
Specification for common algebraic structures in JavaScript based on Fantasy Land
Stars: ✭ 699 (+1045.9%)
Mutual labels:  algebra
Basic Mathematics For Machine Learning
The motive behind Creating this repo is to feel the fear of mathematics and do what ever you want to do in Machine Learning , Deep Learning and other fields of AI
Stars: ✭ 300 (+391.8%)
Mutual labels:  algebra
Newton Api
➗ A really micro micro-service for advanced math.
Stars: ✭ 358 (+486.89%)
Mutual labels:  algebra
Ncalc
Power calculator for Android. Solve some problem algebra and calculus.
Stars: ✭ 512 (+739.34%)
Mutual labels:  algebra
Mather
zzllrr mather(an offline tool for Math learning, education and research)小乐数学,离线可用的数学学习(自学或教学)、研究辅助工具。计划覆盖数学全部学科的解题、作图、演示、探索工具箱。目前是演示Demo版(抛转引玉),但已经支持数学公式编辑显示,部分作图功能,部分学科,如线性代数、离散数学的部分解题功能。最终目标是推动专业数学家、编程专家、教育工作者、科普工作者共同打造出更加专业级的Mather数学工具
Stars: ✭ 270 (+342.62%)
Mutual labels:  algebra
Algebrite
Computer Algebra System in Javascript (Coffeescript)
Stars: ✭ 800 (+1211.48%)
Mutual labels:  algebra
Mu Scala
Mu is a purely functional library for building RPC endpoint based services with support for RPC and HTTP/2
Stars: ✭ 266 (+336.07%)
Mutual labels:  algebra
Klein
P(R*_{3, 0, 1}) specialized SIMD Geometric Algebra Library
Stars: ✭ 463 (+659.02%)
Mutual labels:  algebra
Rings
Rings: efficient JVM library for polynomial rings
Stars: ✭ 50 (-18.03%)
Mutual labels:  algebra
Witchcraft
Monads and other dark magic for Elixir
Stars: ✭ 864 (+1316.39%)
Mutual labels:  algebra
Alga
Algebraic graphs
Stars: ✭ 619 (+914.75%)
Mutual labels:  algebra

Rewrite.jl

Travis Build Status AppVeyor Build Status Coverage Status

Rewrite.jl is an efficient symbolic term rewriting engine.


There are three primary steps in the development and use of a rewriting program:

  1. Map each relevant function symbol to an equational theory. For example, we might specify that + is associative and commutative.
  2. Define a system of rules to rewrite with respect to. For example, we might describe a desired rewrite from x + 0 to x, for all x.
  3. Rewrite a concrete term using the rules.

Example

Theory Definition

In this example, we'll simplify boolean propositions.

First, we'll define the theories which each function symbol belongs to. "Free" symbols follow no special axioms during matching, whereas AC symbols will match under associativity and commutativity.

@theory! begin
    F => FreeTheory()
    T => FreeTheory()
    (&) => ACTheory()
    (|) => ACTheory()
    (!) => FreeTheory()
end

Using the @theory! macro, we associate each of our symbols with a theory. Note that F and T will be a nullary (zero-argument) function, so we assign it the FreeTheory.

Rules Definition

Given the defined theory, we now want to describe the rules which govern boolean logic. We include a handful of cases:

@rules Prop [x, y] begin
    x & F := F
    x & T := x

    x | F := x
    x | T := T

    !T := F
    !F := T

    !(x & y) := !x | !y
    !(x | y) := !x & !y
    !(!x)    := x
end

Naming the rewriting system Prop and using x as a variable, we define many rules. To verbalize a few of them:

  • "x and false" is definitely false.
  • "not true" is definitely false.
  • "not (x and y)" is equivalent to "(not x) or (not y)".
  • "not (not x)" is equivalent to whatever x is.

Under the hood, a custom function called Prop was defined, optimized for rewriting with these specific rules.

Rewriting

Let's test it out on some concrete terms. First, we can evaluate some expressions which are based on constants:

julia> @rewrite(Prop, !(T & F) | !(!F))
@term(T())

julia> @rewrite(Prop, !(T & T) | !(!F | F))
@term(F())

We can also bring in our own custom symbols, which the system knows nothing about:

julia> @rewrite(Prop, a & (T & b) & (c & !F))
@term(&(a(), b(), c()))

julia> @rewrite(Prop, F | f(!(b & T)))
@term(f(!(b())))

Success! We've rewritten some boolean terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].