--- license: apache-2.0 language: - ar - en pretty_name: KhalilAlgoWorks — Classical Arabic Grammar to AI & SWE Algorithm Atlas tags: - classical-arabic - arabic-grammar - usul-al-fiqh - algorithms - software-engineering - llm-verification - rootformer - al-khalil - sibawayh - al-ghazali configs: - config_name: default data_files: - split: train path: principles.jsonl --- # KhalilAlgoWorks (`خليل ألغووركس` — *Kitāb al-ʿIlal al-Khawārizmiyya*) > **Classical Arabic Grammar & *Uṣūl al-Fiqh* Converted into a Machine-Verified AI & Software Engineering Algorithm Atlas.** Instead of searching 47 MB of raw classical Arabic manuscripts every time we hit an AI/LLM/coding bottleneck, **KhalilAlgoWorks** gives both humans and coding agents O(1) lookup from any engineering problem directly to the exact classical principle, verbatim verified Arabic quote + line number, proven Rootformer code, and actionable algorithm blueprint. ## Corpus & Atlas Stats - **Classical Books Indexed:** `16` primary texts (`47.08 MB`, `585,867` lines) in `/root/grammarian_corpus/` - **Verified Operational Principles:** **`84`** (100% machine-verified against disk, `0` line drift) - `[PROVEN]` in Rootformer: **`29`** - `[PARTIAL]` / Prototype: **`19`** - `[UNTAPPED]` High-ROI Blueprints Ready to Build: **`36`** ## Instant CLI & Python Lookup ```bash # Search by AI/SWE engineering problem or keyword python3 /root/rootformer/khalil_algo_works/src/lookup.py --query "hallucination" python3 /root/rootformer/khalil_algo_works/src/lookup.py --domain verification_search --status UNTAPPED python3 /root/rootformer/khalil_algo_works/src/lookup.py --book sibawayh python3 /root/rootformer/khalil_algo_works/src/lookup.py --id GH-04 # Re-verify 100% citation integrity against /root/grammarian_corpus/ python3 /root/rootformer/khalil_algo_works/src/verify_citations.py ``` ## Navigation Map - **[ATLAS_INDEX.md](ATLAS_INDEX.md)** — Reverse Lookup Table: Engineering Domain → All Matching Principles - **[PROVEN_VS_UNTAPPED.md](PROVEN_VS_UNTAPPED.md)** — Rootformer Proven Ledger + Top 12 Highest-ROI Untapped Algorithms - **[books/](books/)** — All `16` per-book engineering dossiers (`01_ghazali_mustasfa.md` … `16_ibn_faris_maqayis_al_lughah.md`) - **[patterns/](patterns/)** — `6` cross-book AI/SWE Engineering Playbooks: - **[Training, RL & Preference Purification](patterns/01_training_and_preference_purification.md)** — Minimal-diff contrastive alignment, non-regression KL tethering, gradualism, web-prior debiasing, and goldilocks curation. - **[Constrained Decoding, Speculation & Pruning](patterns/02_constrained_decoding_and_pruning.md)** — Mustaʿmal/Muhmal validity masks, O(1) structural hallucination guards, lossless KV/context pruning, lookahead speculation, and layer elision. - **[Execution Verification, Testing & Search](patterns/03_execution_verification_and_search.md)** — 5-state Istiqāmah verification, dual-polarity Ṭard/ʿAks tests, differential al-Farq adjudication, monotonic repair, and counterfactual Law/Lawlā debugging. - **[Agentic Routing, Planning & Conflict Resolution](patterns/04_agentic_routing_and_conflict.md)** — 10-class speech-act triage, Taghlīb priority promotion, 3-way Taʿāruḍ conflict arbitration, Balā/Naʿam anti-sycophancy, and bounded-depth planning. - **[AST/API Contracts, Indexing & Representation](patterns/05_ast_api_contracts_and_representation.md)** — ʿĀmil/Maʿmūl typed governance, 28×28 output-first signature indexing, canonical root hashing, S³ orbit sharing, and axiomatic semantic compression. - **[Provenance, RAG & Data Hygiene](patterns/06_provenance_rag_and_data_hygiene.md)** — Multi-witness Tawaqquf quarantine, Taṣḥīf corpus sanitation, field execution anchoring, domain Iṣṭilāḥ layering, and Shādhdh outlier isolation. - **[corpus_manifest.json](corpus_manifest.json)** & **[principles_registry.json](principles_registry.json)** — Machine-readable JSON catalogs for automated agents ## Corpus Hygiene Notes > **Critical Corpus-Hygiene Findings (for KhalilAlgoWorks builders):** > 1. **Line-number shift vs older specs:** `andalusian/GRAMMARIAN_QIYAS_SPEC.md` cites an older line-offset of `Ghazali_Al_Mustasfa.txt` (~111–145 lines earlier than the copy on disk). Every line number below is verified against the **actual `.txt` file on disk**. > 2. **Modern editor prefaces to skip in automated parsers:** `Al_Jawhari_Al_Sihah.txt` (author starts `L1152`), `Ibn_Faris_Mujam_Maqayis_Al_Lughah.txt` (author starts `L1152`), `Ibn_Jinni_Sirr_Sinat_Al_Irab.txt` (author starts `~L240`), `Ibn_Faris_Al_Sahibi.txt` (author starts `L153`), `Sibawayh_Al_Kitab.txt` (OpenITI/transmission preface `L1–L127`, *Bāb ʿIlm al-Kalim* starts `L128`). All citations below are strictly from the **classical authors' own text**. > 3. **Directory vs. historical school alignment:** `andalusian/` holds `Ghazali_Al_Mustasfa.txt` (Shāfiʿī/Ashʿarī Uṣūl al-Fiqh, adopted by Andalusian uṣūlīs like Ibn Rushd & al-Shāṭibī); `kufan/` holds `Al_Jawhari_Al_Sihah.txt` (Iraqi/Basran-Baghdadi-trained classical lexicographer). Both directory and historical school are explicitly noted below. ## All 16 Indexed Classical Books | # | Book Dossier | Author | School | Lines | Principles | |---|---|---|---:|---:|---:| | 1 | [Al-Ghazālī — *Al-Mustaṣfā min ʿIlm al-Uṣūl*](books/01_ghazali_mustasfa.md) | Abū Ḥāmid al-Ghazālī (505) | `andalusian/` · **Uṣūl al-Fiqh & Logic** (Shāfiʿī/Ashʿarī) | 15,518 | 6 | | 2 | [Al-Khalīl ibn Aḥmad — *Kitāb al-ʿAyn*](books/02_khalil_al_ayn.md) | al-Khalīl ibn Aḥmad al-Farāhīdī (170/175) | `basran/` · **Basran** (Founder) | 36,381 | 5 | | 3 | [Sībawayh — *Al-Kitāb*](books/03_sibawayh_al_kitab.md) | ʿAmr ibn ʿUthmān Sībawayh (180) | `basran/` · **Basran** (Canonical Syntactician) | 27,400 | 6 | | 4 | [Al-Akhfash al-Awsaṭ — *Maʿānī al-Qurʾān*](books/04_akhfash_maani_al_quran.md) | Saʿīd ibn Masʿadah al-Akhfash al-Awsaṭ (215) | `basran/` · **Basran** (Sībawayh's student/transmitter) | 8,752 | 5 | | 5 | [Al-Mubarrad — *Al-Muqtaḍab*](books/05_mubarrad_al_muqtadab.md) | Muḥammad ibn Yazīd al-Mubarrad (285) | `basran/` · **Basran** (Systematizer) | 22,923 | 5 | | 6 | [Ibn Durayd — *Jamharat al-Lughah*](books/06_ibn_durayd_jamhara.md) | Abū Bakr Muḥammad Ibn Durayd (321) | `basran/` · **Basran** (Lexicographer) | 47,973 | 5 | | 7 | [Ibn Durayd — *Kitāb al-Ishtiqāq*](books/07_ibn_durayd_ishtiqaq.md) | Abū Bakr Muḥammad Ibn Durayd (321) | `basran/` · **Basran** (Etymologist) | 7,506 | 5 | | 8 | [Al-Zajjājī — *Al-Īḍāḥ fī ʿIlal al-Naḥw*](books/08_zajjaji_idah_fi_ilal.md) | Abū al-Qāsim al-Zajjājī (337/340) | `basran/` · **Basran / Baghdadi** (Grammar Philosophy) | 1,702 | 6 | | 9 | [Al-Zajjājī — *Ḥurūf al-Maʿānī*](books/09_zajjaji_huruf_al_maani.md) | Abū al-Qāsim al-Zajjājī (337/340) | `basran/` · **Basran / Baghdadi** (Function-Word Logic) | 943 | 5 | | 10 | [Ibn Jinnī — *Al-Khaṣāʾiṣ*](books/10_ibn_jinni_khasais.md) | Abū al-Fatḥ ʿUthmān Ibn Jinnī (392) | `basran/` · **Basran / Baghdadi** (Philosophical Philology) | 21,054 | 6 | | 11 | [Ibn Jinnī — *Sirr Ṣināʿat al-Iʿrāb*](books/11_ibn_jinni_sirr_sinat_irab.md) | Abū al-Fatḥ ʿUthmān Ibn Jinnī (392) | `basran/` · **Basran / Baghdadi** (Phonology & Morphophonemics) | 12,241 | 5 | | 12 | [Ibn al-Sikkīt — *Iṣlāḥ al-Manṭiq*](books/12_ibn_sikkit_islah_al_mantiq.md) | Yaʿqūb ibn Isḥāq Ibn al-Sikkīt (244) | `kufan/` · **Core Kufan** (Pupil of al-Farrāʾ) | 7,396 | 5 | | 13 | [Al-Azharī — *Tahdhīb al-Lughah*](books/13_azhari_tahdhib_al_lughah.md) | Abū Manṣūr al-Azharī (370) | `kufan/` · **Kufan-affiliated / Eclectic** (Phonetic-Order Lexicographer) | 166,974 | 5 | | 14 | [Al-Jawharī — *Tāj al-Lughah wa-Ṣiḥāḥ al-ʿArabiyyah*](books/14_jawhari_al_sihah.md) | Ismāʿīl ibn Ḥammād al-Jawharī (393) | `kufan/` · **Classical Lexicographer** (Basran-Baghdadi trained) | 77,833 | 5 | | 15 | [Ibn Fāris — *Al-Ṣāḥibī fī Fiqh al-Lughah*](books/15_ibn_faris_al_sahibi.md) | Aḥmad ibn Fāris al-Rāzī (395) | `kufan/` · **Kufan-aligned** (*"طريقته طريقة الكوفيين"*) | 4,450 | 5 | | 16 | [Ibn Fāris — *Muʿjam Maqāyīs al-Lughah*](books/16_ibn_faris_maqayis_al_lughah.md) | Aḥmad ibn Fāris al-Rāzī (395) | `kufan/` · **Kufan-aligned** (Axiomatic Lexicographer) | 126,821 | 5 |