Skip to content

tr3dh/BALDUR

Repository files navigation

🌐 English | Deutsch

Basic Albebraic Language for Deriving Unified Tensor Representations (BALDUR)

Baldur is a minimalist interpreter language that natively supports symbolic manipulation of algebraic and index-notated tensor expressions. The program implements a C++ tensor algebra backend and makes it available via a language distribution generated by the interpreter forge Alberich. The Baldur scripting language was developed as part of a master’s thesis for the Institute of Continuum Mechanics (IKM) at Leibniz University Hannover (LUH).

🧬 Development

  • Language standard: C++20
  • Compiler: gcc/g++
  • Subsystem: MinGw64
  • Platform: Windows
  • Build system: Make

🔧 Features

  • Assembling symbolic algebraic and index-notated expressions
  • Algebraic differentiation, simplification, substitution
  • Exporting results in index notation as a Julia script

🚚 What’s Shipped

  • Interpreter
  • Language Server
  • VSCode Extension (bundles Interpreter + Language Server)
  • Minimalist editor (no language support)
  • Source code

The builds can be downloaded from the Releases.

🛠️ Language Characteristics

Baldur’s primary application is symbolic tensor calculus involving complex tensor expressions. When used appropriately, the backend can compute very large expressions within reasonable execution times (tested up to 110 million nodes, runs for 3.5 hours). Due to the algebraic inputs, the language syntax is strongly based on standard tensor algebra notation. The released backend is designed to give the user maximum control. For example, the user can control the AST convention of the constructed expressions and define extensive rule sets for derivations and simplifications. A plug-and-play solution can be set up via the pckg includes. Additionally, Alberich utilizes implicit and explicit, alternative semantic concepts that offer either low-level or high-level control over the runtime resources used. This allows the user to manually configure memory management and object handling or leave it to the interpreter, depending on their needs and use case. In addition, Baldur implements a dynamically configurable overloading scheme. The set of operators, the operator hierarchy, and operator overloading can be configured via __LPECONFIG.JSON. In addition to the language features mentioned above, the base language implements other interesting syntax concepts such as simultaneous bindings, input-switching if conventions, a fully recursive syntax, and more. Further information about the syntax concepts implemented there can be found in the GitHub repository of the interpreter development team Alberich and the associated master’s thesis.

✒️ Language Support

The language support for Baldur includes the following features:

  • Auto-completion
  • Hover
  • Dynamic syntax highlighting
  • Go to Definition
  • Find References

🚀 Getting Started

The included master's thesis provides an easy introduction using clear examples and references to the Alberich base language and the Baldur distribution. The language examples also provide a suitable foundation for getting started. The Language Support can also be consulted to explore implemented functions, operators, variables, and more.

🪖 Intended workflow

The intended workflow is described by the following example Baldur script. The core computation takes place entirely in algebraic notation. The index notation here is merely an export format of the algebraic notation and is primarily designed to be generated from an algebraic expression.

// Create dependencies
int nComps = 3

// The function tExpr(label, order, dimensions) returns an external algebraic node
A, B = tExpr(“A”, 2, args(nComps, nComps)), tExpr(“B”, 2, args(nComps, nComps))
a, b = tExpr(“a”, 0), tExpr(“b”, 0)

// Algebraic assembly
expr = wrap(a * A + b * B)

// Differentiation, simplification, substitution, other manipulations, ...
// ...  

// Conversion to index notation
assert(expr->isUnwrapped() == getUnwrapOperands(), “...”)
tIdn idnExpr = toIDN(expr)

// Export to Julia script
string jlScript = idnExpr->toJuliaString(“evalExpr”)
jlScript->writeToFile(“../Examples/juliaScripts/expr.jl”)

slog(jlScript)
// Output: '
// ...
// function evalExpr(a, A, b, B)
//  ...
//     @tensor opt=true res[idx2, idx3] := ((a * A[idx2, idx3]) + (b * B[idx2, idx3]))
//     return res
// end
// '

🤝 Acknowledgments

I would like to extend my special thanks to my advisor, Dr. Hendrik Geisler, who was a great help throughout the development process.

Hendrik Geisler was funded by the European Union (ERC, Gen-TSM, project number 101124463) during the period of supervision. However, the views and opinions expressed are solely those of the author(s) and do not necessarily reflect those of the European Union or the European Research Council Executive Agency. Neither the European Union nor the granting authority can be held responsible for them.

📚 Libraries and Assets Used

I would also like to thank the respective developers and maintainers of the open-source libraries used in the project, as well as the designers of the open-source assets used in the project. These are listed below. The corresponding license texts are stored in the thirdPartyLicenses folder.

Library / Asset License
raylib zlib/libpng
Eigen MPL2 (Mozilla Public License 2.0)
SymEngine BSD 2-Clause
magic_enum MIT
nlohmann/json MIT
Boost.PFR Boost Software License 1.0
Dear ImGui MIT
rlImGui MIT
ImPlot MIT
ImGuiFileBrowser MIT
lsp-framework MIT
LLVM Apache 2.0 with LLVM Exeptions
angle ANGLE
Anvil Icon (Alberich Logo) CC0
Spear and Shield Icon (Baldur Logo) CC0
Julimono Font OFL-1.1

About

The Baldur tensoralgebraic scripting language

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors