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
//! TensorLogic: Neuro-Symbolic Reasoning via Tensor Operations
//!
//! This module implements the TensorLogic paradigm (Domingos, 2025), unifying neural
//! and symbolic reasoning through tensor operations. All logical operations are
//! expressed as Einstein summations, enabling:
//!
//! - **Differentiable inference**: Backpropagation through logical reasoning
//! - **Dual-mode operation**: Boolean (guaranteed correctness) or Continuous (learnable)
//! - **Knowledge graph reasoning**: RESCAL factorization and embedding space queries
//!
//! # Toyota Way Principles
//!
//! - **Jidoka**: Boolean mode guarantees no hallucinations (output ⊆ derivable facts)
//! - **Poka-Yoke**: Type-safe mode selection prevents accidental mixing
//! - **Genchi Genbutsu**: Explicit tensor equations for auditability
//!
//! # Example
//!
//! ```rust
//! use aprender::logic::{LogicMode, logical_join, logical_project};
//!
//! // Family tree reasoning: Grandparent = Parent @ Parent
//! let parent = vec![
//! vec![0.0, 1.0, 0.0], // Alice is parent of Bob
//! vec![0.0, 0.0, 1.0], // Bob is parent of Charlie
//! vec![0.0, 0.0, 0.0], // Charlie has no children
//! ];
//!
//! let grandparent = logical_join(&parent, &parent, LogicMode::Boolean);
//! // grandparent[0][2] = 1.0 (Alice is grandparent of Charlie)
//! ```
//!
//! # References
//!
//! - Domingos, P. (2025). "Tensor Logic: The Language of AI." arXiv:2510.12269
//! - Nickel, M. et al. (2011). "RESCAL: A Three-Way Model for Collective Learning"
//! - Bordes, A. et al. (2013). "TransE: Translating Embeddings for Multi-relational Data"
pub use ;
pub use ;
pub use ;