Symbolic AI knowledge base system in Emacs Lisp with microtheories, truth maintenance, temporal logic, and data generation capabilities.
β οΈ DEVELOPMENT STATUS: This system is under active development. Several features are experimental or have known issues. See Current Status and Known Issues sections below.
- Basic Knowledge Storage: Facts can be asserted and queried
- Microtheory Framework: Context-scoped knowledge with inheritance (basic implementation)
- Truth Maintenance System (TMS): Justification tracking and belief revision
- Persistence System: Save/load knowledge base state to files with robust error handling
- Testing Framework: Comprehensive test suite for validation
- Event System: Event creation and basic temporal reasoning
- Non-Monotonic Reasoning: Default rules with exception handling
- Data Generation: Python scripts for LLM-powered fact extraction
- π Validation System: Comprehensive input validation and error handling across all modules
- π Error Recovery: Graceful degradation with helpful error messages and suggestions
- π User Validation Tools: Interactive functions to validate facts, microtheories, and system state
- Inference Engine: Layered inference workers (implementation incomplete)
- Temporal Reasoning: Basic temporal facts (full temporal logic not implemented)
- RDF Integration: Import/export framework exists but needs testing
- Query Caching: LRU cache system implemented but may have issues
- Initialization Problems: Multiple initialization calls cause errors (partially mitigated by validation)
- Test Suite Failures: All 17 tests currently fail due to microtheory re-initialization
- Incomplete Integration: Some modules don't properly communicate
- π Improved: Error handling significantly enhanced with validation system
- GNU Emacs 24.3 or later
- Python 3.7+ (for LLM data generation)
;; Add to your .emacs or init.el
(add-to-list 'load-path "/path/to/symbolic_ai_elisp_knowledge_base/lisp")
(require 'kb-advanced-system)
;; Initialize (with improved error handling)
(kb-init)
;; Enable validation for development (optional)
(setq kb-validation-enabled t)
(setq kb-validation-strict-mode t)# For LLM-powered data generation
cd scripts/
pip install -r requirements.txt<<<<<<< Updated upstream
||||||| Stash base
dagger call test
dagger call build
**Run the Container:**
```bash
# After pipeline completes, run the built image
docker run -it symbolic-ai-kb:latest
# Or run with custom tag
docker run -it kb-advanced-system:v2.1
The Dagger CI/CD pipeline provides:
- π Linting: Emacs Lisp syntax validation and style checking
- π§ͺ Testing: Automated execution of the knowledge base test suite
- ποΈ Building: Docker image creation from the project Dockerfile
- π·οΈ Tagging: Local Docker registry tagging (equivalent to
docker build -t tag .)
This replaces traditional make and docker build workflows with a modern, containerized CI/CD approach that produces the same result as running docker build -t kb-advanced-system:v2.1 . in your project directory.
Prerequisites:
- Dagger installed
- Docker running locally
dagger call test
dagger call build
**Run the Container:**
```bash
# After pipeline completes, run the built image
docker run -it symbolic-ai-kb:latest
# Or run with custom tag
docker run -it kb-advanced-system:v2.1
The Dagger CI/CD pipeline provides:
- π Linting: Emacs Lisp syntax validation and style checking
- π§ͺ Testing: Automated execution of the knowledge base test suite
- ποΈ Building: Docker image creation from the project Dockerfile
- π·οΈ Exporting: Export built image to local Docker daemon (equivalent to
docker build -t tag .)
This replaces traditional make and docker build workflows with a modern, containerized CI/CD approach that produces the same result as running docker build -t kb-advanced-system:v2.1 . in your project directory.
Prerequisites:
- Dagger installed
- Docker running locally
;; Initialize system (do only once)
(kb-init)
;; Assert facts
(kb-assert 'Socrates 'is-a 'human)
(kb-assert 'human 'is-a 'mammal)
;; Query facts
(kb-query 'Socrates 'is-a) ; Returns facts about Socrates
;; Create microtheories
(kb-create-microtheory 'MyMt 'BaseMt);; Initialize TMS
(kb-tms-init)
;; Assert with justification tracking
(kb-tms-assert-fact 'bird 'can-fly t)
;; Check belief status
(kb-tms-is-believed 'bird 'can-fly t)
;; Get explanations
(kb-tms-explain-fact 'bird 'can-fly t);; Save entire knowledge base
(kb-save "my-kb.el")
;; Load knowledge base
(kb-load "my-kb.el")
;; Create backup
(kb-backup);; Add default rule
(kb-add-default 'birds-fly
'((?x is-a bird))
'(?x can-fly t))
;; Add exception
(kb-add-exception 'penguin-exception
'birds-fly
'((?x is-a penguin))
'(?x can-fly nil))
;; Perform reasoning (may have issues)
(kb-reason);; Enable comprehensive validation
(setq kb-validation-enabled t)
(setq kb-validation-strict-mode t)
;; Operations now include automatic validation
(kb-assert 'John 'loves 'Mary) ; β Valid - succeeds
(kb-assert nil 'loves 'Mary) ; β Invalid - helpful error message
;; Check data validity before operations
(kb-check-fact 'Alice 'knows 'Bob) ; Returns t if valid
(kb-check-microtheory 'TestMt) ; Validates microtheory name
;; Validate entire system
(kb-validate-system) ; Comprehensive system check
;; Error recovery example
(condition-case err
(kb-persist-save "/invalid/path/kb.dat")
(kb-validation-error
(message "Save failed: %s" (cadr err))
(kb-persist-save "~/backup-kb.dat"))) ; Try alternative location
;; Toggle validation for performance
(kb-validation-disable) ; Disable for production
(kb-validation-enable) ; Re-enable for safetysymbolic_ai_elisp_knowledge_base/
βββ README.md # This file
βββ Makefile # Build automation (has issues)
βββ lisp/ # Core Elisp modules
β βββ kb-advanced-system.el # Main API (improved error handling)
β βββ kb-microtheories.el # Context management (enhanced validation)
β βββ kb-tms.el # Truth maintenance (working)
β βββ kb-persistence.el # Save/load system (robust error handling)
β βββ kb-testing.el # Test framework (working)
β βββ kb-inference-engine.el # Layered inference (incomplete)
β βββ kb-nonmonotonic.el # Default reasoning (partial)
β βββ kb-events.el # Event system (with validation)
β βββ kb-rdf.el # RDF integration (untested)
β βββ kb-debugger.el # Debug tools (basic)
β βββ kb-cache.el # Query caching (issues)
β βββ kb-validation.el # π Comprehensive validation system
β βββ kb-system.el # Legacy compatibility
βββ scripts/ # Python data generators
β βββ kb_openai_generator.py # OpenAI + Outlines integration
β βββ kb_data_generator.py # Local LLM version
β βββ requirements.txt # Python dependencies
βββ test/ # Test files (all failing)
βββ examples/ # Usage examples
β βββ validation-demo.el # π Validation system demonstration
βββ docs/ # Additional documentation
β βββ VALIDATION.md # π Comprehensive validation guide
Extract structured facts from text using Python scripts:
# Using OpenAI API
python scripts/kb_openai_generator.py --file input.txt --microtheory ScienceMt
# Using local models (if available)
python scripts/kb_data_generator.py --file input.txt --microtheory ScienceMtGenerated facts can be loaded into Emacs:
(load-file "openai_facts.el")# Attempt to run tests (will fail)
make test
# Individual test files can be examined in test/
ls test/test-*.el- Multiple Initialization Problem: Calling
kb-initmore than once causes "Microtheory already exists" errors - Test Suite Broken: All 17 tests fail due to initialization issues
- Demo Function Fails:
(kb-demo)fails on microtheory re-creation
- Missing lexical-binding declarations
- Deprecated pattern matching syntax
- Undefined function references between modules
- Free variable references
- Inference engine workers not properly connected
- Some modules don't communicate correctly
- Error handling is incomplete
# Compile (with warnings)
make compile
# Attempt tests (will fail)
make test
# Clean compiled files
make clean
# Basic lint check
make lintThis is a known issue. Avoid calling kb-init multiple times. If you encounter this:
- Restart Emacs
- Call
kb-initonly once - Consider using
(setq kb-microtheories (make-hash-table :test 'equal))to reset state
The test suite currently fails due to initialization issues. To help debug:
- Check individual test files in
test/ - Run single functions in isolation
- Use the TMS and persistence modules directly as they're more stable
If you experience slowdowns:
- Try enabling caching:
(kb-cache-on) - Limit inference depth
- Use specific microtheories to scope queries
- Fix initialization system - Prevent multiple init issues
- Repair test suite - Get all tests passing
- Complete inference engine - Finish layered inference implementation
- Improve error handling - Make system more robust
- Add proper documentation - Document working vs experimental features
This system needs significant work to reach production quality. High-value contributions:
- Fix the initialization/microtheory creation bug
- Repair the test suite
- Complete the inference engine implementation
- Add proper error handling throughout
- Improve module integration
- Microtheory System: Influenced by Cyc's context system
- Truth Maintenance: Based on Forbus & de Kleer's ATMS
- Non-Monotonic Reasoning: Implements Reiter's default logic
- Enhanced TMS: Extended justification tracking
- Persistence System: Full KB serialization/deserialization
- Testing Framework: Comprehensive validation system
- Python Integration: LLM-powered data generation
This is experimental software. Use with caution and expect rough edges.