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
//! Weighted Pushdown Automata (WPDA).
//!
//! This module implements weighted pushdown automata for recognizing
//! weighted context-free languages. PDAs extend finite automata with
//! a stack, enabling recognition of nested structures.
//!
//! # Mathematical Definition
//!
//! A weighted pushdown automaton is a tuple P = (Q, Σ, Γ, q₀, Z₀, F, Δ, ρ) where:
//! - Q: Finite set of states
//! - Σ: Input alphabet
//! - Γ: Stack alphabet
//! - q₀: Initial state
//! - Z₀: Initial stack symbol
//! - F ⊆ Q: Final states
//! - Δ: Transition relation
//! - ρ: Final weight function
//!
//! # Transition Format
//!
//! ```text
//! (state, input?, stack_top) → (next_state, stack_action, weight)
//! ```
//!
//! Stack actions:
//! - Pop: Remove top symbol
//! - Push: Add symbols to top
//! - Replace: Pop and push (combined operation)
//! - Noop: Leave stack unchanged
//!
//! # Example
//!
//! ```rust,ignore
//! use lling_llang::pushdown::{VectorPda, PdaBuilder, StackSymbol};
//! use lling_llang::semiring::TropicalWeight;
//!
//! // Build a PDA for balanced parentheses
//! let mut builder = PdaBuilder::<char, TropicalWeight>::new();
//!
//! let s0 = builder.add_state();
//! builder.set_start(s0);
//! builder.set_final(s0, TropicalWeight::one());
//!
//! let z0 = builder.initial_stack();
//! let left_paren = builder.add_stack_symbol();
//!
//! // On '(', push left_paren
//! builder.add_transition(s0, Some('('), z0, s0, StackAction::Push(vec![z0, left_paren]));
//!
//! // On ')', pop left_paren
//! builder.add_transition(s0, Some(')'), left_paren, s0, StackAction::Pop);
//!
//! let pda = builder.build();
//! assert!(pda.accepts("(())"));
//! ```
//!
//! # Applications
//!
//! - Weighted parsing beyond FST composition
//! - Nested structure validation
//! - Programming language parsing with weights
//! - XML/JSON validation
pub use PdaBuilder;
pub use ;
pub use ;
pub use PdaTransition;
pub use ;