Crate tensorlogic_adapters

Crate tensorlogic_adapters 

Source
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§

AxisMetadata
Axis metadata linking variables to tensor dimensions
CacheStats
Cache statistics.
CompactSchema
Compact representation of a symbol table.
CompilerExport
Export utilities for compiler integration.
CompilerExportBundle
Complete export bundle for compiler integration.
CompilerImport
Import utilities for reverse synchronization.
CompositePredicate
A composable predicate definition that can be expanded.
CompositeRegistry
A registry of composite predicates for lookup and expansion.
CompressionStats
Compression statistics for compact schemas.
ComputedDomain
A computed domain that is derived from other domains.
ComputedDomainRegistry
Registry for managing computed domains.
DiffSummary
Summary statistics for a schema diff.
Documentation
Long-form documentation with examples and usage notes.
DomainHierarchy
Domain hierarchy tracking subtype relationships
DomainInfo
Domain information including cardinality and optional element enumeration
DomainMask
Domain mask for filtering and constraints
DomainModification
Modification details for a domain.
Example
An example demonstrating how to use a symbol.
FileSchemaLoader
File-based schema loader that reads from a directory structure.
FunctionalDependency
Functional dependency between predicate arguments
LazyLoadStats
Statistics about lazy loading behavior.
LazySymbolTable
A symbol table with lazy loading support.
LookupCache
Cache for frequently accessed lookups.
MatcherStats
Statistics about the signature matcher indices.
MemoryStats
Memory usage statistics for a string interner.
Metadata
Rich metadata container for domains and predicates.
ParametricType
A parameterized domain type with type parameters.
PredicateConstraints
Constraints associated with a predicate
PredicateInfo
Predicate metadata including arity and domain types
PredicateModification
Modification details for a predicate.
PredicateTemplate
A template for creating multiple similar predicates.
ProductDomain
A product domain representing a tuple of component domains.
Provenance
Provenance information tracking the origin and history of a symbol.
SchemaAnalyzer
Analyzer for generating schema recommendations.
SchemaBuilder
Builder for constructing SymbolTable instances.
SchemaDiff
Comparison result for two symbol tables.
SchemaRecommendations
Schema recommendations based on analysis.
SchemaStatistics
Comprehensive statistics about a schema.
SchemaValidator
Schema validator for symbol tables
SignatureMatcher
Indexed structure for fast predicate signature matching.
StringInterner
String interner for reducing memory usage of repeated strings.
SymbolTable
Symbol table containing all domain, predicate, and variable information
SymbolTableSync
Bidirectional synchronization utilities.
TagCategory
A tag category for organizing tags into groups.
TagRegistry
A registry of tag categories for organizing the tag namespace.
TypeBound
A type bound that constrains a type parameter.
ValidationReport
Validation results with errors, warnings, and hints
ValidationResult
Result of bundle validation.
ValueRange
Value range constraint for numeric predicates
VariableModification
Modification details for a variable binding.
VersionEntry
A version history entry tracking changes to a symbol.

Enums§

AdapterError
BoundConstraint
The kind of constraint in a type bound.
CompatibilityLevel
Compute schema compatibility between two versions.
DomainComputation
Types of domain computations.
LoadStrategy
Strategy for loading schema elements.
PredicateBody
The body of a composite predicate.
PredicateProperty
Properties that can be associated with predicates
SchemaIssue
Types of schema issues that can be detected.
TypeParameter
A type parameter that can be either a concrete type or another parametric type.

Traits§

ProductDomainExt
Extension trait for SymbolTable to support product domains.
SchemaLoader
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.