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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//! Concrete e-graph identifier types.
pub use semi_persistent_containers::id::{SparseSetId, UseListId, UseNodeId};
semi_persistent_containers::define_id31! {
/// A 31-bit e-node identifier.
pub struct ENodeId / StoredENodeId, "e";
}
semi_persistent_containers::define_id31! {
/// A 31-bit sort identifier (Bool, Int, Real, …).
pub struct SortId / StoredSortId, "sort";
}
semi_persistent_containers::define_id31! {
/// A 31-bit operator identifier (+, ×, and, or, =, ite, …).
pub struct OpId / StoredOpId, "op";
}
semi_persistent_containers::define_id15! {
/// A 15-bit rule identifier (indexes into the rule registry).
pub struct RuleId / StoredRuleId, "r";
}
semi_persistent_containers::define_id15! {
/// A 15-bit axiom identifier (user-asserted equalities).
pub struct AxiomId / StoredAxiomId, "ax";
}
/// The ten node kinds. Stored in a routing table indexed by [`ENodeId`].
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u8)]
pub enum ENodeKind {
/// Nullary (constant, no children).
Plain0 = 0,
/// Unary (1 inline child).
Plain1 = 1,
/// Binary (2 inline children).
Plain2 = 2,
/// Ternary (3 inline children).
Plain3 = 3,
/// N-ary ordered (N > 3, children in pool).
PlainN = 4,
/// Commutative sorted pair (2 inline children).
C = 5,
/// Associative flattened list (variadic, pool).
A = 6,
/// Associative-commutative sorted multiset (variadic, pool).
AC = 7,
/// Associative-commutative-idempotent sorted set (variadic, pool).
ACI = 8,
/// Literal leaf (no children, has value).
Lit = 9,
}