1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! 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`].
use mangle_ast as ast;
pub use TypeChecker;
pub use BoundsChecker;
pub use LoweringContext;
pub use rewrite_unit;
pub use Planner;
pub use ;
/// A set of predicate symbols, typically used to represent a stratum or a
/// collection of EDB/IDB predicates.
pub type PredicateSet = FxHashSet;