Prolog-to-Prolog Transpilation and Dialect Support
Part of the UnifyWeaver Education Series
Welcome to the comprehensive guide to UnifyWeaver’s Prolog target system!
Note: Firewall and security content from this book has been extracted to Book 8: Security & Firewall.
Required:
Recommended:
Technical:
This book teaches you how to:
Start here if you’re new to the Prolog target. Learn what it is, how it works, and understand the different Prolog dialects.
Start with: Chapter 1: Introduction
Practical guides for generating scripts, compiling binaries, and managing dependencies.
Key Chapter: Chapter 5: Compilation vs Interpretation
Security policies, fallback mechanisms, and validation systems.
Highlights:
For developers who want to understand or extend the implementation.
Key Chapter: Chapter 2: Architecture Overview
Real-world patterns and a complete case study.
Must Read: Chapter 15: Case Study - Factorial Compilation
% 1. Load the Prolog target
:- use_module('src/unifyweaver/targets/prolog_target').
% 2. Define your predicate
factorial(0, 1) :- !.
factorial(N, R) :- N > 0, N1 is N-1, factorial(N1, R1), R is N*R1.
% 3. Generate a script
?- generate_prolog_script([factorial/2],
[dialect(gnu), compile(true)],
Code),
write_prolog_script(Code, 'factorial', [dialect(gnu), compile(true)]).
% 4. Run your binary!
$ ./factorial
Next: Read Chapter 1 for details.
Work through these chapters in order:
You’ll understand the basics and have working code.
Read the book in order from 00_index.md. Budget 3-4 hours for a complete reading.
Each chapter includes examples you can run. To follow along:
# Install SWI-Prolog
sudo apt-get install swi-prolog # Ubuntu/Debian
brew install swi-prolog # macOS
# Install GNU Prolog (for compilation)
sudo apt-get install gprolog # Ubuntu/Debian
brew install gnu-prolog # macOS
# Clone UnifyWeaver
git clone https://github.com/yourorg/UnifyWeaver.git
cd UnifyWeaver
# Navigate to UnifyWeaver directory
cd /path/to/UnifyWeaver
# Start SWI-Prolog
swipl
# Load the chapter examples
?- [examples/book_examples/chapter_04_basic_usage].
This book documents UnifyWeaver v0.1 which includes:
✅ Complete Prolog target implementation ✅ SWI-Prolog and GNU Prolog dialects ✅ Compilation support with error checking ✅ Firewall integration ✅ Basic fallback mechanisms ✅ Validation system
The following critical fixes were implemented:
initialization/1 for GNU Prolog compiled binariesThese fixes are covered in detail in Chapter 15: Case Study.
See Chapter 8: Fallback Mechanisms for roadmap details.
| Chapter | Status | Last Updated |
|---|---|---|
| 00 - Index | ✅ Complete | 2025-11-17 |
| 01 - Introduction | ✅ Complete | 2025-11-17 |
| 02 - Architecture | ✅ Complete | 2025-11-17 |
| 03 - Dialects | ✅ Complete | 2025-11-17 |
| 04 - Basic Usage | 📝 Planned | - |
| 05 - Compilation Modes | 📝 Planned | - |
| 06 - Dependencies | 📝 Planned | - |
| 07 - Firewall Integration | ✅ Complete | 2025-11-17 |
| 08 - Fallback Mechanisms | ✅ Complete | 2025-11-17 |
| 09 - Validation | 📝 Planned | - |
| 10 - Code Generation | 📝 Planned | - |
| 11 - Dialect Specifics | 📝 Planned | - |
| 12 - Compilation | 📝 Planned | - |
| 13 - Patterns | 📝 Planned | - |
| 14 - Troubleshooting | 📝 Planned | - |
| 15 - Case Study | ✅ Complete | 2025-11-17 |
| Appendix A - API Reference | 📝 Planned | - |
| Appendix B - Dialect Comparison | 📝 Planned | - |
| Appendix C - Firewall Examples | 📝 Planned | - |
Found an error or want to add content?
All contributions welcome!
This is part of the UnifyWeaver Educational Series:
Same license as UnifyWeaver (check main repository).
examples/ directoryVersion: 0.1.0 Last Updated: 2025-11-17 Maintainers: UnifyWeaver Team
Happy learning! 🎓