Skip to main content

panproto_inst/
lib.rs

1//! # panproto-inst
2//!
3//! Instance representation for panproto (attributed C-sets).
4//!
5//! This crate provides three instance shapes, unified under [`Instance`]:
6//!
7//! - **[`WInstance`]**: Tree-shaped (W-type) instances with nodes,
8//!   arcs, and optional hyper-edge fans.
9//! - **[`FInstance`]**: Relational (set-valued functor) instances
10//!   with tables and foreign keys.
11//! - **[`GInstance`]**: Graph-shaped instances with nodes and edges
12//!   (most general form, no root, cycles allowed).
13//!
14//! All three are attributed C-sets over different shape categories.
15//! The [`Instance`] enum provides a unified interface.
16
17// Allow concrete HashMap/HashSet in public API signatures per ENGINEERING.md spec.
18#![allow(clippy::implicit_hasher)]
19
20/// Generic attributed C-set trait unifying all instance shapes.
21pub mod acset;
22/// Incremental contraction tracker for ancestor contraction.
23pub mod contraction;
24/// Edit errors for tree and table edits.
25pub mod edit_error;
26/// Operations on the category of elements `∫F` (Grothendieck construction).
27pub mod element_ops;
28/// Error types for instance operations.
29pub mod error;
30/// Hyperedge fan representation.
31pub mod fan;
32/// Set-valued functor instance representation.
33pub mod functor;
34/// Graph-shaped instance representation.
35pub mod ginstance;
36/// Internal hom schema construction and evaluation.
37pub mod hom;
38/// Unified instance enum (attributed C-set).
39pub mod instance;
40/// Instance-aware expression evaluation (graph traversal builtins).
41pub mod instance_env;
42/// Metadata types for instance nodes.
43pub mod metadata;
44/// JSON parsing for W-type instances.
45pub mod parse;
46/// Right Kan extension (Pi_F) for instances.
47pub mod pi;
48/// Polynomial functor operations (fiber, group-by, join, section).
49pub mod poly;
50/// W-type instance representation and the `wtype_restrict` pipeline.
51pub mod provenance;
52/// Declarative query engine for instance presheaves.
53pub mod query;
54/// Incremental reachability index for W-type instances.
55pub mod reachability;
56/// Edit algebra for functor (table-shaped) instances.
57pub mod table_edit;
58/// Edit algebra for W-type (tree-shaped) instances.
59pub mod tree_edit;
60/// Validation of W-type instances against schemas.
61pub mod validate;
62/// Value types and field presence.
63pub mod value;
64pub mod wtype;
65
66// Re-exports for convenience.
67pub use acset::AcsetOps;
68pub use contraction::{ContractionRecord, ContractionTracker};
69pub use edit_error::EditError;
70pub use element_ops::{ElementOps, decode_finstance_id, encode_finstance_id};
71pub use error::{InstError, ParseError, RestrictError, ValidationError};
72pub use fan::Fan;
73pub use functor::{FInstance, functor_extend, functor_restrict};
74pub use ginstance::{GInstance, graph_extend, graph_restrict};
75pub use hom::{curry_migration, eval_hom, hom_schema};
76pub use instance::Instance;
77pub use instance_env::{eval_with_element_ops, eval_with_instance};
78pub use metadata::{Node, NodeShape};
79pub use parse::{parse_json, to_json};
80pub use pi::{functor_pi, wtype_pi};
81pub use poly::{
82    Complement, DroppedNode, SectionEnrichment, fiber_at_anchor, fiber_at_node,
83    fiber_decomposition, fiber_with_predicate, group_by, join, restrict_with_complement, section,
84};
85pub use provenance::{Provenance, ProvenanceMap, SourceField, TransformStep, compute_provenance};
86pub use query::{
87    InstanceQuery, QueryMatch, build_node_env, execute as execute_query, execute_any,
88    execute_elements, execute_functor, execute_graph,
89};
90pub use reachability::ReachabilityIndex;
91pub use table_edit::TableEdit;
92pub use tree_edit::TreeEdit;
93pub use validate::validate_wtype;
94pub use value::{FieldPresence, Value};
95pub use wtype::{
96    CaseBranch, CompiledMigration, FieldTransform, WInstance, ancestor_contraction,
97    anchor_surviving, build_env_from_extra_fields, build_env_with_children,
98    collect_scalar_child_values, expr_literal_to_value, reconstruct_fans, resolve_edge,
99    value_to_expr_literal, wtype_extend, wtype_restrict,
100};