Skip to content

feat(compression,#18724): Compression-01-ShannonFano-Prefixe (pli 1 #18706, Origami D1-D8) - #18753

Closed
jsboige wants to merge 1 commit into
mainfrom
feature/18724-compression-01-shannon-fano
Closed

jsboige wants to merge 1 commit into
mainfrom
feature/18724-compression-01-shannon-fano

Conversation

@jsboige

@jsboige jsboige commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Grain DEEP/notebook-python CONTENU (pli 1 #18706, Origami D1-D8 dispatch ai-01 01/10 20:26Z).

Livrable : MyIA.AI.Notebooks/Compression/Compression-01-ShannonFano-Prefixe-Python.ipynb + Compression/README.md.

Substance pédagogique

  • S1. Longueur fixe ASCII (5 bits) sur BANANE ORANGE : 65 bits, sans adaptation.
  • S2. Code de longueur variable : ambiguïté du décodeur glouton sur 0/10/110 (3 interprétations), unicité du décodage sur l'arbre préfixe.
  • S3. Inégalité de Kraft sum 2^-l <= 1 vérifiée opérationnellement par kraft_check (codes impossibles détectés avant construction : 0/1 répétés → somme 2.0 > 1.0).
  • S4. Shannon-Fano récursif sur BANANE ORANGE : L = 2.846 bits/symbole (vs 5 fixe), H = 2.815 bits, écart +0.031 bits.
  • S5. Huffman (tas binaire + fusion itérative des deux plus petits nœuds) vs SF sur 4 corpus-types (BANANE, déséquilibré, uniforme, français) : longueur moyenne identique sur tous (1.20 / 2.40 / 2.85 / 3.49 bits/symbole) — SF et Huffman sont très proches sur les corpus réguliers.
  • S6. Entropie H = -sum p log2 p comme borne : L_huf - H toujours positif, entre +0.03 (BANANE) et +0.53 bits (déséquilibré) — la contrainte de préfixe consomme la marge, jamais atteinte en code caractère-par-caractère.

3 exercices stubs C.1 (pass, pas de raise NotImplementedError) :

  • E1. verifie_kraft(code) -> (bool, somme)
  • E2. Shannon-Fano sur ABRACADABRA
  • E3. SF vs Huffman sur 6 symboles (0.30, 0.25, 0.15, 0.12, 0.10, 0.08)

Vrai outil SOTA, pas workaround

  • Algorithmes codés à la main (shannon_fano, kraft_check, huffman_arbre) — pas de lib externe jouet, pas d'ASCII art, pas de cellule stub.
  • Inégalité de Kraft dérivée mathématiquement (formule sum 2^-l <= 1), pas invoquée d'une lib.
  • Huffman construit comme heapq + nœuds (feuille, ...) / (noeud, gauche, droite) : structure explicite, pas de boîte noire.

Acceptance #18724

# Critère Statut
1 Notebook exécuté end-to-end (papermill / nbclient) OK
2 3 exercices C.1 (stub correct sans raise) OK
3 Comparaison Shannon-Fano vs Huffman sur >= 2 corpus OK (4 corpus : BANANE / déséquilibré / uniforme / français)
4 Entropie H comme borne, écart L-H positif partout OK
5 Renvois croisés vers Complexity/ + EPIC #18706 OK (README section "Position dans le dépôt")

Validation

  • C.1 : 0 violation (raise NotImplementedError, assert False, 1/0).
  • C.2 : 10/10 cellules code avec execution_count != null + outputs cohérents.
  • 3 organs sweep verts : check_cell_source_parses, check_split_reading_cells, check_duplicate_sections.
  • validate_pr_notebooks : 1/1 passed (kernel python3-wsl).
  • Format JSON compact préservé : 44 Ko (origin-style, pas de json.dump reformaté).
  • EC strictement croissant : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] (gaps entre les EC des exercices).

Format Origami D1-D8

  • D1 (claim posé) → D2 (création dossier Compression/) → D3 (notebook conçu, sections 6 + exercices 5) → D4 (lecture du contenu, mesure d'algorithmes) → D5 (markdown corrigé pour refléter les mesures réelles) → D6 (exécution end-to-end via nbclient) → D7 (validation sweep) → D8 (commit + push + PR).

Suite

Lien grain

Issue #18724 — grain DEEP/notebook-python CONTENU, accepte 5 critères vérifiables.

🤖 Generated with Claude Code

…18706, Origami D1-D8)

Notebook Decouverte -- serie Compression. 28 cellules (10 code executees,
EC [1..10] strictement croissant), 6 sections + Exercices + Conclusion.

Substance :
- S1. longueur fixe (5 bits) sur BANANE ORANGE : 65 bits sans adaptation
- S2. codes longueur variable : ambiguite vs unicite de decodage
  (decodeur glouton sur 0/10/110 -> 3 lectures differentes)
- S3. inegalite de Kraft sum 2^-l <= 1, verifiee operationnellement
  (codes impossibles detectes avant construction)
- S4. Shannon-Fano construit recursivement sur BANANE ORANGE
  (L=2.846 bits, ecart a H=+0.031 bits)
- S5. Huffman vs SF sur 4 corpus (BANANE, desequilibre, uniforme, francais) :
  longueur moyenne identique sur tous (1.76x plus court que fixe)
- S6. entropie H comme borne inferieure : L_huf - H sur 3 corpus,
  ecart entre +0.03 et +0.53 bits, jamais negatif
- S7. recapitulatif des idees mesurees

3 exercices stubs C.1 (pass, pas de raise) :
- E1. verifie_kraft(code) -> (bool, somme)
- E2. shannon_fano(freq) sur ABRACADABRA
- E3. SF vs Huffman sur 6 symboles (frequences 0.30/0.25/0.15/0.12/0.10/0.08)

Verification :
- C.1 OK : 0 raise NotImplementedError / assert False / 1/0
- C.2 OK : 10/10 cellules code avec EC non-null + outputs coherents
- 3 organs sweep verts : cell_source_parses, split_reading_cells,
  duplicate_sections
- validate_pr_notebooks OK (kernel python3-wsl)
- Format JSON compact preserve (44 Ko)

Kernel : python3-wsl (3.11)

Co-Authored-By: Claude Haiku 4.5 (1M context) <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

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

@github-actions github-actions Bot added variation-tag-lane-missing Tag Grain sans 'lane <machine:workspace>' (cap G-VAR-2 incomptable) variation-tag-prev-absent Tag Grain sans 'prev: <TIER>/<GENRE> #<PR>' (adjacence G-VAR-3 inevaluable) labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Grain tag obligatoire (#10045, bloquant).

Grain tag present but lane machine:workspace missing.

Pour passer ce gate, le body doit porter en tete une ligne de la forme :

Grain: <DEEP|MED|LIGHT>/<genre> -- lane <machine:workspace> -- prev: <TIER>/<GENRE> #<PR>

Le <genre> doit figurer dans l'enumeration §1 de variation-protocol.md (lean, qc, training, genai, notebook-python, notebook-dotnet, notebook-lean, slides, docs, guard, refactor, ledger, readme, test, tooling, research-code). Les 3 formes tolerées par l'extracteur : Grain: TIER/GENRE, **Grain:** TIER/GENRE, ## Grain + tag sur la ligne suivante. La lane doit suivre le format <machine>:<workspace> (cf. lane-claim-protocol.md).

@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 PR Validation: PASS

  • Notebooks checked: 1
  • Code cells validated: 10
  • 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.7s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 5.5s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 7.2s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 6.0s
Search-01-StateSpace.ipynb ✅ SUCCESS 4.9s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 3.5s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 19.7s
GameTheory-04c-NashExistence-Python.ipynb ✅ SUCCESS 4.0s

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 #18753 (feat(compression,#18724): Compression-01-ShannonFano-Prefixe (pli 1 #18706, Origami D1-D8)) 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

[collision] Doublon de PR #18729 (feature/18724-compression-01-shannonfano, auteur myia-po-2023, PR gate SUCCESS, tag canonique Grain: DEEP/notebook-python — lane myia-po-2023:CoursIA — prev: MED/notebook-python #18720).

Les deux PRs touchent exactement les mêmes fichiers :

  • MyIA.AI.Notebooks/Compression/Compression-01-ShannonFano-Prefixe-Python.ipynb
  • MyIA.AI.Notebooks/Compression/README.md

Branche differente d'un seul caractere (shannon-fano vs shannonfano). PR #18753 (celle-ci) a un tag Grain non-canonique (pas de lane, pas de prev:) et PR gate FAILURE sur variation-tag-required. PR #18729 est le canon.

Suggestion : fermer PR #18753 (doublon non-canonique). Je ne le fais pas moi-meme car l'auteur est jsboige et je respecte la lane discipline (worker ne ferme pas les PRs d'un autre lane/compte). Si ai-01 coordinateur peut fermer #18753, PR #18729 pourra etre mergee sans collision.

🤖 Generated with Claude Code

@myia-ai-01

Copy link
Copy Markdown
Collaborator

Fermee comme doublon de #18729, qui cree le meme carnet, est arrivee avant, et porte un tag Grain: complet. Merci pour ce travail. Arbitrage et suite sur #18724. La branche est conservee et la PR peut se rouvrir si un manque est constate.

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-tag-lane-missing Tag Grain sans 'lane <machine:workspace>' (cap G-VAR-2 incomptable) variation-tag-prev-absent Tag Grain sans 'prev: <TIER>/<GENRE> #<PR>' (adjacence G-VAR-3 inevaluable)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants