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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! MathML semantic correction layer for lling-llang.
//!
//! This module provides semantic type checking and homoglyph disambiguation
//! for mathematical expressions based on Content MathML semantics.
//!
//! # Overview
//!
//! The MathML semantic layer consists of several components:
//!
//! - **Type System** (`types`): Defines mathematical types like `Number`, `Function`,
//! `Relation`, etc., along with type environments and type checking results.
//!
//! - **Type Checker** (`checker`): Performs type inference and checking on mathematical
//! expressions, validating operator arities and argument types.
//!
//! - **Homoglyph Disambiguator** (`homoglyph`): Handles visually similar characters
//! with different meanings (e.g., `x` vs `×`, `0` vs `O`).
//!
//! - **Semantic Layer** (`semantic`): The main `CorrectionLayer` implementation that
//! combines type checking and homoglyph disambiguation for lattice filtering.
//!
//! # Example
//!
//! ```ignore
//! use lling_llang::layers::mathml::{MathMLSemanticLayer, MathMLSemanticConfig};
//!
//! // Create a semantic layer with default configuration
//! let layer = MathMLSemanticLayer::new();
//!
//! // Or with custom configuration
//! let layer = MathMLSemanticLayer::with_config(MathMLSemanticConfig::strict());
//!
//! // Apply to a lattice
//! let result = layer.apply(&lattice)?;
//!
//! // Check analysis results
//! for result in layer.last_results() {
//! if !result.is_valid {
//! for issue in result.errors() {
//! println!("Error: {}", issue.message);
//! }
//! }
//! }
//! ```
//!
//! # Type System
//!
//! The type system supports common mathematical types:
//!
//! ```ignore
//! use lling_llang::layers::mathml::types::{MathType, Arity};
//!
//! // Function type: sin : Number -> Number
//! let sin_type = MathType::Function {
//! arity: Arity::Unary,
//! domain: vec![MathType::Number],
//! codomain: Box::new(MathType::Number),
//! };
//!
//! // Vector type: R^n
//! let vector_type = MathType::Vector {
//! element: Box::new(MathType::Number),
//! dimension: Some(3),
//! };
//! ```
//!
//! # Homoglyph Disambiguation
//!
//! The disambiguator uses context to determine the meaning of ambiguous characters:
//!
//! ```ignore
//! use lling_llang::layers::mathml::homoglyph::{HomoglyphDisambiguator, MathContext};
//!
//! let disambiguator = HomoglyphDisambiguator::new();
//!
//! // After a number, 'x' is likely multiplication
//! let context = MathContext {
//! prev_was_number: true,
//! in_math_mode: true,
//! ..Default::default()
//! };
//!
//! let meaning = disambiguator.disambiguate('x', &context);
//! // Returns GlyphMeaning::Multiplication
//! ```
//!
//! # Configuration
//!
//! The layer supports several configuration presets:
//!
//! - `MathMLSemanticConfig::default()`: Balanced configuration
//! - `MathMLSemanticConfig::strict()`: Aggressive pruning, normalization enabled
//! - `MathMLSemanticConfig::lenient()`: Keep more paths, no normalization
//! - `MathMLSemanticConfig::minimal()`: Fast processing, minimal checking
// Re-export main types
pub use ;
pub use ;
pub use ;
pub use ;