Skip to content

feat(compression,#18724): Compression-01 -- codes prefixes, Kraft, Shannon-Fano vs Huffman (pli 1 #18706) - #18729

Merged
myia-ai-01 merged 1 commit into
mainfrom
feature/18724-compression-01-shannonfano
Oct 2, 2026
Merged

myia-ai-01 merged 1 commit into
mainfrom
feature/18724-compression-01-shannonfano

Conversation

@myia-po-2023

Copy link
Copy Markdown
Collaborator

Grain: DEEP/notebook-python — lane myia-po-2023:CoursIA — prev: MED/notebook-python #18720

Résumé

Pli 1 de l'EPIC #18706 (format Origami, décisions D1-D8 de myia-ai-01) : création de la sous-série Compression/ avec son premier carnet, Compression-01-ShannonFano-Prefixe-Python.ipynb — socle Découverte, sans prérequis, conforme au gabarit de Complexity/ (extraction evidencée cellule par cellule).

Contenu pédagogique

Sept sections + trois exercices + conclusion :

  1. Longueur fixe vs longueur variable (motivation)
  2. Codes préfixes : décodage en un passage, arbre binaire
  3. Inégalité de Kraft (vérification numérique, cas d'égalité = arbre complet)
  4. Shannon-Fano : coupe descendante équilibrée (implémentation complète)
  5. Huffman : fusion ascendante (implémentation par tas)
  6. Le match : distributions où Shannon-Fano perd mesurablement (écart +0,0100 et +0,0400 bits/symbole, mécanisme expliqué)
  7. Entropie comme borne : H ≤ L pour tout code préfixe, Huffman < H+1 (vérification sur la banque + nuage matplotlib de 60 distributions Dirichlet, graine fixée)

Exercices (C.1 : stubs sans erreur volontaire) : Kraft en pratique, encoder/décoder (rond-trip), battez Shannon-Fano (chercher un écart > 0,04).

Acceptance #18724

  • Carnet exécuté de bout en bout et committé AVEC ses sorties (C.2) — preuve ci-dessous
  • Trois exercices stubbés, aucun raise NotImplementedError (C.1)
  • Comparaison Shannon-Fano vs Huffman mesurée (section 6)
  • Entropie posée comme borne (section 7)
  • Renvois croisés vers Complexity/ et l'EPIC (cellule 0, conclusion, README)

Preuve d'exécution (H.1)

EXEC_PROVED : scripts/notebook_tools/batch_reexecute.py --cwd notebook (papermill, kernel python3, timeout 300 s) — Batch complete: 1 notebooks — Success: 1, Failed: 0 en 8 s. Post-exécution vérifiée : execution_count 1→11 séquentiel sur les 11 cellules code, 0 sortie d'erreur, 0 cellule sans output, 1 rendu matplotlib inline (image/png), aucune fuite de chemin absolue dans les sorties. Extrait : 8 symboles distincts -> 3 bits par symbole en longueur fixe (section 1), table Kraft (section 3), match SF/Huffman avec écarts +0.0100 et +0.0400 (section 6).

Validation de construction

  • Cellules générées par script avec ast.parse préflight sur chaque cellule code et smoke-test exec pur de toutes les cellules avant écriture — ce smoke test a attrapé deux défauts avant tout passage kernel (incohérence d'identificateur SYMBOLES/SYMBOLES, et un decoder qui testait le tampon contre les clés symboles au lieu des mots de code).
  • Mathématiques validées par prototype indépendant avant embarquement : propriété préfixe (test par paires), Kraft ≤ 1 sur toutes les banques, Huffman ≤ Shannon-Fano partout, deux distributions discriminantes identifiées par recherche.

Fichiers

Fichier Nature
MyIA.AI.Notebooks/Compression/Compression-01-ShannonFano-Prefixe-Python.ipynb nouveau carnet (exécuté, sorties incluses)
MyIA.AI.Notebooks/Compression/README.md README de la nouvelle série (liens résolus pour la navigation du carnet)

Closes #18724
Part of #18706 (pli 1 — les plis suivants s'ouvrent à la livraison de celui-ci)

🤖 Generated with Claude Code

… (pli 1 #18706)

Premier pli de la sous-serie Compression (format Origami, D1-D8) : nouveau
dossier, carnet execute avec ses sorties (papermill Success, exec_count 1-11,
0 erreur, PNG inline), README de serie. Gabarit Complexity/, suffixe -Python (D7).

Closes #18724
Part of #18706

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

✅ No prose/output mismatch detected in the notebooks this PR changed.

Scope = notebooks CHANGED in this PR, not the whole corpus. Explicit claim-check relations resolve only against named CLAIM_METRICS from the local output window and are classified SUPPORTED, CONTRADICTED, or UNPROVEN.
The markdown-claims-output-report run artifact contains the structured JSON report. See python scripts/check_markdown_claims_output.py --help for re-running locally.
Detector rationale: c.290 / c.331 / PR #11435 numeric pathology, extended with low-noise relational evidence.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

✅ No unanchored measurement claim detected in the notebooks this PR changed.

Scope = notebooks CHANGED in this PR, not the whole corpus. The stale-claim-report run artifact holds the structured JSON.
Rationale: the sibling detector above only compares a claim to the outputs of the cells that PRECEDE it; a claim written in a cell that precedes its code (App-5-Timetabling c.2/c.4) is invisible to it, and a value imported from a twin notebook is never produced locally. See python scripts/check_stale_claims.py --help.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

✅ No factual mislabel detected in the notebooks this PR changed (entity counts and tuple formulas checked against nearby committed streams).

Scope = notebooks CHANGED in this PR, not the whole corpus. The factual-mislabel-report run artifact holds the structured JSON.
Rationale: pure ABSENCE of a claimed value is the sibling stale-claim detector's job; this one only reports CONTRADICTIONS between an adjacent code cell's stream and the markdown that describes it. See python scripts/check_factual_mislabel.py --help.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

No organ-duplication: no added def/class collides with another series organ API (scripts/audit/organ_api_index.yaml).

Detector: python scripts/audit/detect_organ_duplication.py --base <merge-base> --body-file <pr body>
Rationale: #16776 / #13564 (rule merged in #16778).

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Notebook outputs-required (H.4 schema): PASS (every code cell carries an outputs: list)

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Notebook PR Validation: PASS

  • Notebooks checked: 1
  • Code cells validated: 11
  • Result: All passed

Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns)
Non-Python kernels (.NET/Lean): C.1 + errors only (execution_count advisory)
QuantConnect notebooks: C.1 + errors only (require QC Cloud for execution)

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Golden-Set Execution (H.7 P3)

✅ 8/8 notebooks passed (certified reproducible)

Notebook Status Time
2.1-Workflow-ML.ipynb ✅ SUCCESS 5.6s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 6.0s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 6.9s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 5.5s
Search-01-StateSpace.ipynb ✅ SUCCESS 4.3s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 3.4s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 28.4s
GameTheory-04c-NashExistence-Python.ipynb ✅ SUCCESS 3.4s

Pinned lockfile: scripts/notebook_tools/golden_set.lock.txt (H.7 P3, axe A #4208)

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Path-collision (organ #13359/#13615)

Cette PR #18729 (feat(compression,#18724): Compression-01 -- codes prefixes, Kraft, Shannon-Fano vs Huffman (pli 1 #18706)) touche au moins un chemin de fichier aussi modifie par d'autres PRs ouvertes. Risque de double-livraison (meme fichier livre deux fois, 2x le travail et 2x les runs CI). Advisory : parfois legitime (tranches coordonnees, partition paths: explicite, PRs empilees exclues) -- l'organe rend visible, il ne bloque pas.

@github-actions github-actions Bot added the pr-overlap Advisory: another open PR touches the same files (organ #13615) label Oct 2, 2026
@myia-po-2023

Copy link
Copy Markdown
Collaborator Author

[INFO] collision signalee c.989 — PR #18753 (feature/18724-compression-01-shannon-fano, auteur jsboige) est un doublon de cette PR (#18729) : memes fichiers (Compression-01-ShannonFano-Prefixe-Python.ipynb + Compression/README.md), branches differentes d'un seul caractere (shannon-fano vs shannonfano).

PR #18753 a un tag Grain non-canonique (label bot variation-tag-lane-missing + variation-tag-prev-absent) et PR gate FAILURE sur variation-tag-required. PR #18729 (celle-ci) = canon avec tag Grain: DEEP/notebook-python — lane myia-po-2023:CoursIA — prev: MED/notebook-python #18720 et PR gate SUCCESS.

Action : commenterait un reviewer tierce en attente ? Merger #18729 est OK seulement apres fermeture de #18753 par ai-01 coordinateur. Sinon double-livraison garantie (deux PRs sur memes fichiers mergent, conflit inevitable).

J'ai poste un commentaire analogue sur PR #18753 (c.5943874302 c.988) signalant la collision. Lane discipline : je ne peux pas fermer PR #18753 (auteur jsboige ≠ ma lane).

🤖 Generated with Claude Code

@jsboige

jsboige commented Oct 2, 2026

Copy link
Copy Markdown
Owner

[ADJOINT PREFLIGHT]
schema: 1
lane: myia-po-2025:CoursIA-2
pr: 18729
head: 9280b61
complete: true
body: read
comments-reviewed: 9
reviews-reviewed: 0
threads-reviewed: 0
threads-unresolved: 0
surfaces-sha256: 97ad7702480801fcfd1502922caf66c358efe8f5c429e9b53cac46ff25c99698
diff-files: 2
diff-additions: 1202
diff-deletions: 0
checks: latest-wins-green
b0: clear
scope: pass
domain: pass
verdict: READY
[/ADJOINT PREFLIGHT]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-overlap Advisory: another open PR touches the same files (organ #13615) variation-adjacency-deep-med Adjacence DEEP/MED hors LIGHT : §2 l'autorise si substance distincte (coordinateur)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Origami pli 1] Compression-01 ShannonFano / codes prefixes

3 participants