Thanks to visit codestin.com
Credit goes to lib.rs

#ir #planning #predicate #ast #join #negation #intermediate-representation #strata

mangle-analysis

Rust implementation of Mangle, a logic programming language

6 releases (breaking)

Uses new Rust 2024

0.7.0 Apr 15, 2026
0.5.0 Mar 9, 2026
0.4.0 Feb 27, 2026
0.3.0 Feb 27, 2026
0.1.0 Jun 11, 2024

#434 in Math


Used in 7 crates (5 directly)

Apache-2.0

330KB
7K SLoC

mangle_analysis

This package is part of the Mangle logic programming language. It contains code related to semantic analysis (name resolution, type inference and type-checking).

See https://codeberg.org/TauCeti/mangle-rs for more information about Mangle.


lib.rs:

Analysis and Transformation Pipeline for Mangle.

This crate provides the core analysis passes and transformations that turn a parsed Mangle AST into an executable plan.

Transformation Stages

  1. Program Structure: The raw AST is wrapped in a Program abstraction which distinguishes between extensional (data) and intensional (rules) predicates.

  2. Stratification: The program is analyzed for dependencies and stratified to handle negation correctly. This produces a StratifiedProgram, where predicates are grouped into layers (strata) that can be evaluated sequentially.

  3. Lowering: The AST (or stratified program parts) is lowered into the Intermediate Representation (IR). See LoweringContext.

  4. Type Checking: The IR is checked for type consistency and safety. See BoundsChecker.

  5. Planning: The Logical IR rules are transformed into Physical Operations (like nested-loop joins) ready for execution or codegen. See Planner.

Dependencies

~3–4.5MB
~80K SLoC