Expand description
Adapter utilities for the Tensorlogic ecosystem.
This crate provides the bridge between logical expressions and tensor execution by managing symbol tables, domain hierarchies, and schema validation.
§Overview
tensorlogic-adapters offers a comprehensive system for managing the metadata
and structure of logical systems compiled to tensor operations. It provides:
- Symbol tables - Central registry for predicates, domains, and variables
- Domain hierarchies - Type relationships with subtyping and inheritance
- Parametric types - Generic domains like
List<T>,Option<T>,Map<K,V> - Predicate composition - Define predicates in terms of other predicates
- Rich metadata - Provenance tracking, documentation, version history
- Schema validation - Completeness, consistency, and semantic checks
§Quick Start
use tensorlogic_adapters::{SymbolTable, DomainInfo, PredicateInfo};
// Create a symbol table
let mut table = SymbolTable::new();
// Add a domain
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
// Add a predicate
let knows = PredicateInfo::new(
"knows",
vec!["Person".to_string(), "Person".to_string()]
);
table.add_predicate(knows).unwrap();
// Bind a variable
table.bind_variable("x", "Person").unwrap();§Features
§Domain Hierarchies
Define type hierarchies with subtype relationships:
use tensorlogic_adapters::DomainHierarchy;
let mut hierarchy = DomainHierarchy::new();
hierarchy.add_subtype("Student", "Person");
hierarchy.add_subtype("Person", "Agent");
assert!(hierarchy.is_subtype("Student", "Agent")); // Transitive§Parametric Types
Create generic domain types:
use tensorlogic_adapters::{ParametricType, TypeParameter};
let list_person = ParametricType::list(
TypeParameter::concrete("Person")
);
assert_eq!(list_person.to_string(), "List<Person>");§Schema Validation
Validate schemas for correctness:
use tensorlogic_adapters::{SymbolTable, SchemaValidator, DomainInfo};
let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
let validator = SchemaValidator::new(&table);
let report = validator.validate().unwrap();
assert!(report.errors.is_empty());Structs§
- Axis
Metadata - Axis metadata linking variables to tensor dimensions
- Cache
Stats - Cache statistics.
- Compact
Schema - Compact representation of a symbol table.
- Compiler
Export - Export utilities for compiler integration.
- Compiler
Export Bundle - Complete export bundle for compiler integration.
- Compiler
Import - Import utilities for reverse synchronization.
- Composite
Predicate - A composable predicate definition that can be expanded.
- Composite
Registry - A registry of composite predicates for lookup and expansion.
- Compression
Stats - Compression statistics for compact schemas.
- Computed
Domain - A computed domain that is derived from other domains.
- Computed
Domain Registry - Registry for managing computed domains.
- Diff
Summary - Summary statistics for a schema diff.
- Documentation
- Long-form documentation with examples and usage notes.
- Domain
Hierarchy - Domain hierarchy tracking subtype relationships
- Domain
Info - Domain information including cardinality and optional element enumeration
- Domain
Mask - Domain mask for filtering and constraints
- Domain
Modification - Modification details for a domain.
- Example
- An example demonstrating how to use a symbol.
- File
Schema Loader - File-based schema loader that reads from a directory structure.
- Functional
Dependency - Functional dependency between predicate arguments
- Lazy
Load Stats - Statistics about lazy loading behavior.
- Lazy
Symbol Table - A symbol table with lazy loading support.
- Lookup
Cache - Cache for frequently accessed lookups.
- Matcher
Stats - Statistics about the signature matcher indices.
- Memory
Stats - Memory usage statistics for a string interner.
- Metadata
- Rich metadata container for domains and predicates.
- Parametric
Type - A parameterized domain type with type parameters.
- Predicate
Constraints - Constraints associated with a predicate
- Predicate
Info - Predicate metadata including arity and domain types
- Predicate
Modification - Modification details for a predicate.
- Predicate
Template - A template for creating multiple similar predicates.
- Product
Domain - A product domain representing a tuple of component domains.
- Provenance
- Provenance information tracking the origin and history of a symbol.
- Schema
Analyzer - Analyzer for generating schema recommendations.
- Schema
Builder - Builder for constructing SymbolTable instances.
- Schema
Diff - Comparison result for two symbol tables.
- Schema
Recommendations - Schema recommendations based on analysis.
- Schema
Statistics - Comprehensive statistics about a schema.
- Schema
Validator - Schema validator for symbol tables
- Signature
Matcher - Indexed structure for fast predicate signature matching.
- String
Interner - String interner for reducing memory usage of repeated strings.
- Symbol
Table - Symbol table containing all domain, predicate, and variable information
- Symbol
Table Sync - Bidirectional synchronization utilities.
- TagCategory
- A tag category for organizing tags into groups.
- TagRegistry
- A registry of tag categories for organizing the tag namespace.
- Type
Bound - A type bound that constrains a type parameter.
- Validation
Report - Validation results with errors, warnings, and hints
- Validation
Result - Result of bundle validation.
- Value
Range - Value range constraint for numeric predicates
- Variable
Modification - Modification details for a variable binding.
- Version
Entry - A version history entry tracking changes to a symbol.
Enums§
- Adapter
Error - Bound
Constraint - The kind of constraint in a type bound.
- Compatibility
Level - Compute schema compatibility between two versions.
- Domain
Computation - Types of domain computations.
- Load
Strategy - Strategy for loading schema elements.
- Predicate
Body - The body of a composite predicate.
- Predicate
Property - Properties that can be associated with predicates
- Schema
Issue - Types of schema issues that can be detected.
- Type
Parameter - A type parameter that can be either a concrete type or another parametric type.
Traits§
- Product
Domain Ext - Extension trait for SymbolTable to support product domains.
- Schema
Loader - A loader trait for fetching schema elements on demand.
Functions§
- check_
compatibility - Determine compatibility level between two schemas.
- compute_
diff - Compute the difference between two symbol tables.
- merge_
tables - Merge two symbol tables, preferring values from the newer table.