Skip to main content

logicaffeine_language/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![doc = include_str!("../README.md")]
3
4// Re-export base types for internal use and consumers
5pub use logicaffeine_base::{Arena, Interner, Span as BaseSpan, Symbol, SymbolEq};
6
7// Provide an `intern` module alias for internal code that uses `crate::intern::*`
8pub mod intern {
9    pub use logicaffeine_base::{Interner, Symbol, SymbolEq};
10}
11
12// Provide an `arena` module alias for internal code that uses `crate::arena::*`
13pub mod arena {
14    pub use logicaffeine_base::Arena;
15}
16
17// Core modules
18pub mod diagnostic;
19pub mod drs;
20pub mod error;
21pub mod lexer;
22pub mod lexicon;
23pub mod lgx;
24pub mod lint;
25pub mod printer;
26pub mod teach;
27pub mod token;
28pub mod token_class;
29
30// Parser and AST
31pub mod ast;
32pub mod ast_map;
33pub mod parser;
34
35// Semantic analysis
36pub mod lambda;
37pub mod semantics;
38pub mod transpile;
39
40// Compile API
41pub mod compile;
42
43// Support modules
44pub mod analysis;
45pub mod arena_ctx;
46pub mod ast_depth;
47pub mod debug;
48pub mod formatter;
49pub mod import_format;
50pub mod mwe;
51pub mod ontology;
52pub mod pragmatics;
53pub mod registry;
54pub mod scope;
55pub mod session;
56pub mod source_format;
57pub mod style;
58pub mod suggest;
59pub mod symbol_dict;
60pub mod view;
61pub mod visitor;
62
63// The registry of compiler optimization toggles.
64pub mod optimization;
65
66// Proof conversion: bridges language AST to proof engine
67pub mod proof_convert;
68pub use proof_convert::{logic_expr_to_proof_expr, term_to_proof_term};
69
70// Re-export key types at crate root
71pub use analysis::TypeRegistry;
72pub use arena_ctx::AstContext;
73pub use drs::{BoxType, Case, Drs, Gender, Number, WorldState};
74pub use error::{socratic_explanation, ParseError, ParseErrorKind};
75pub use lexer::{Lexer, LineLexer, LineToken};
76pub use parser::{NegativeScopeMode, Parser, ParserMode, QuantifierParsing};
77pub use registry::SymbolRegistry;
78pub use session::Session;
79pub use token::{BlockType, FocusKind, MeasureKind, PresupKind, Span, Token, TokenType};
80
81// Compile API re-exports
82pub use compile::{
83    compile, compile_all_scopes, compile_all_scopes_with_options, compile_ambiguous,
84    compile_ambiguous_with_options, compile_discourse, compile_discourse_with_options,
85    compile_forest, compile_forest_with_options, compile_kripke, compile_kripke_with,
86    compile_pragmatic, compile_simple, compile_theorem, compile_with_discourse,
87    compile_with_options, compile_with_world_state, compile_with_world_state_interner_options,
88    compile_with_world_state_options, run_proof_sketch, MAX_FOREST_READINGS,
89};
90
91// Runtime lexicon re-export (when dynamic-lexicon feature is enabled)
92#[cfg(feature = "dynamic-lexicon")]
93pub use logicaffeine_lexicon::runtime as runtime_lexicon;
94
95// Output format configuration
96#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
97pub enum OutputFormat {
98    #[default]
99    Unicode,
100    LaTeX,
101    SimpleFOL,
102    /// Kripke semantics output: modals lowered to explicit world quantification.
103    Kripke,
104}
105
106// Transpile context
107pub struct TranspileContext<'a> {
108    pub registry: &'a mut SymbolRegistry,
109    pub interner: &'a Interner,
110}
111
112impl<'a> TranspileContext<'a> {
113    pub fn new(registry: &'a mut SymbolRegistry, interner: &'a Interner) -> Self {
114        TranspileContext { registry, interner }
115    }
116}
117
118#[derive(Debug, Clone, Copy)]
119pub struct CompileOptions {
120    pub format: OutputFormat,
121    /// Enrich the parse with conversational (scalar) implicature (§8.7): a weak
122    /// scalar "some" is strengthened to `∃… +> ¬∀…`. Off by default so the literal
123    /// truth-conditional output is unchanged.
124    pub pragmatic: bool,
125}
126
127impl Default for CompileOptions {
128    fn default() -> Self {
129        CompileOptions {
130            format: OutputFormat::Unicode,
131            pragmatic: false,
132        }
133    }
134}