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
//! A higher-level interface for building lax Open Hypergraphs, including helpers to use *rust
//! operators* like `+`, `&`, etc. to build terms.
//! Here's an example of using this interface to build a "full adder" circuit.
//!
//! ```ignore
//! fn full_adder(a: Var, b: Var, cin: Var) -> (Var, Var) {
//! let a_xor_b = a.clone() ^ b.clone();
//! let a_and_b = a & b;
//!
//! (a_xor_b, a_and_b)
//! }
//! ```
//!
//! This constructs a [`crate::lax::OpenHypergraph`] like the one below, where dashed lines
//! indicate nodes connected by the quotient map.
//!
//! ```text
//! ┌──────┐ ┌──────┐
//! a │ ├───●╌╌╌╌╌●───┤ │ a ^ b
//! ●───┤ Var │ │ XOR ├───●
//! │ ├───● ●───┤ │
//! └──────┘ \ / └──────┘
//! \ /
//! X
//! / \
//! ┌──────┐ / \ ┌──────┐
//! b │ ├───● ●───┤ │ a & b
//! ●───┤ Var │ │ AND ├───●
//! │ ├───●╌╌╌╌╌●───┤ │
//! └──────┘ x1 y1 └──────┘
//! ```
//!
//! The purpose of a [`Var`] is to explicitly track variable usage:
//! each time the var is used in an expression, a new node is created in the underlying
//! OpenHypergraph, representing a *copy*.
//! Note however that a [`Var`] correponds to a *hyperedge* rather than a node.
//!
//! See `examples/adder.rs` for a comprehensive example, including a definition of a simple
//! language of simple digital circuits.
pub use *;
pub use *;