Skip to content

fix(smt,#3801): Z3-Python-06 Pareto-front enumeration returned dominated points - #7912

Merged
jsboige merged 1 commit into
mainfrom
fix/z3-06-pareto-front-dominated
Jul 22, 2026
Merged

jsboige merged 1 commit into
mainfrom
fix/z3-06-pareto-front-dominated

Conversation

@jsboige

@jsboige jsboige commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Grain: MED/code-correctness — lane myia-po-2025:CoursIA — prev: LIGHT/docs (#7908 SC-8)

Defect (class A code-correctness, G.1 firsthand-verified, scan finding #1)

Z3-Python-06-Advanced-Optimization.ipynb cell 10 — the notebook's centerpiece Pareto-front example — enumerated DOMINATED points and labeled them Pareto-optimal.

enumerer_front_pareto called opt.maximize(qualite) but never minimized cout. Z3 then returned an arbitrary cost in [2*qualite, cout_precedent-1]. The committed output prints its own refutation — a "Cout min = 2*q" column showing 6 of 9 points had Cout > Cout min:

     3 |       8 |    17 |              16      <- Cout 17, but (8,16) feasible -> DOMINATED
     4 |       7 |    15 |              14      <- DOMINATED by (7,14)
     5 |       6 |    13 |              12      <- DOMINATED
     ...

Point 3 = (qualite=8, cout=17) while (8,16) is feasible — same quality, strictly lower cost → (8,17) is dominated by (8,16). Yet cell 13 markdown claimed:

"Chaque point est Pareto-optimal : on ne peut pas ameliorer un objectif sans degrader l'autre... aucun point n'est domine par un autre."

Directly refuted by the cell's own output. Cell 11 compounded it with a false pedagogical defense: "à qualité fixée, plusieurs coûts sont Pareto-équivalents" — but (8,16) dominates (8,17); they are NOT Pareto-equivalent.

A second bug amplified it: the dedup "keep first point per quality" kept the arbitrary (high) cost and dropped the minimal one, with a now-false comment.

G.1 firsthand verification

Read the FULL cell 10 source AND its full committed output, plus the cell 11 + cell 13 markdowns, before editing. Confirmed the 6 dominated points and the false "Pareto-équivalents" claim verbatim. Also confirmed cells 4/7/17/22 (hierarchical, lexicographic, MaxSAT, budget) are correct → this is an isolated defect in the Pareto section.

Fix — lexicographic two-phase enumeration

Phase 1: opt.maximize(qualite) under cout < cout_precedent  -> max quality
Phase 2: opt2.minimize(cout)  at that fixed quality         -> minimal cost

Phase 2 guarantees the point is truly Pareto-optimal: without it, the solver returns an arbitrary (dominated) cost. This is the standard correct bi-objective enumeration (max-A-then-min-B).

Re-executed cells 1+10+12 with real z3 4.16.0 (rule F) → real outputs transplanted (Stop & Repair, no hand-edit):

  • cell 10 stdout: 11 Pareto points, ALL on cout=2q (every row carries the <-- cout min marker — zero dominated points). For this model the minimal cost of quality q is exactly 2q (the constraint cout >= 2*qualite), so the true front coincides with the feasibility floor.
  • cell 12: real matplotlib PNG regenerated from the fixed front.

Markdown honesty

  • cell 11: removed the false "Pareto-équivalents / strictement au-dessus" claim; the front now honestly coincides with the cout=2q floor, explained by the two-phase method guaranteeing every point is non-dominated.
  • cell 13: rewrote the step table to reflect the two phases; added a key point that phase 2 is essential — without it the solver returns a dominated cost.

Validation

  • nbformat validate OK (27 cells)
  • Scope: cell 10 (code + output), cell 11 (md), cell 12 (output: plot + stdout), cell 13 (md). 23 other cells byte-identical to origin/main (surgical raw-json round-trip, 42+/44-, 1 file).
  • C.1 clean (no NotImplementedError/assert False), 0 leaks, CRLF=0, LF, UTF-8 no-BOM, trailing newline.
  • Rule F: z3-solver 4.16.0 installed locally; real re-execution, real stdout + real PNG.

SOTA verdict

SOTA-OK — the cell now runs the correct Pareto-enumeration algorithm (lexicographic two-phase, the standard method) and Z3's real optimization is exercised at each step (11 Optimize solves, each maximizing then minimizing). The displayed output is Z3's genuine output. The other optimization examples in the notebook (cells 4/7/17/22: hierarchical, lexicographic, MaxSAT, budget) were already correct and are untouched. No workaround.

Visual note (transparent)

Cell 12's plot is regenerated from verified-correct data (front points are exactly (q, 2q); the plot draws those points + the cout=2q dashed line, so the markers sit on the dashed line by construction). GLM lane has no vision capability — visual confirmation of the plot at merge-gate (ai-01/Opus has vision) is welcome, but data-level correctness is guaranteed by the verified enumeration.

Method

Defect found via Explore sonnet scan (read-only, Z3-Python family — fresh rotation out of SmartContract per R6), G.1 firsthand-verified (read FULL cell source + output + markdowns). The scan's 2 other findings (Z3-04 cell 20 "Star" claim, Z3-04 cell 13 date label) are separate lighter grains.

See #3801.

Generated with Claude Code

…TED points

enumerer_front_pareto (cell 10) called opt.maximize(qualite) but NEVER minimized
cout. Z3 then returned an arbitrary cost in [2*qualite, cout_precedent-1]. The
committed output printed a "Cout min = 2*q" column showing 6 of 9 points had
Cout > Cout min — e.g. point 3 = (qualite=8, cout=17) while (8,16) is feasible,
so (8,17) is DOMINATED by (8,16) (same quality, strictly lower cost).

Yet cell 13 markdown claimed "Chaque point est Pareto-optimal : aucun point
n'est domine" — directly refuted by the cell's own output. cell 11 compounded
this with a FALSE pedagogical defense ("plusieurs couts sont Pareto-equivalents")
— but (8,16) DOMINATES (8,17); they are NOT Pareto-equivalent.

A second bug amplified it: the dedup "keep first point per quality" kept the
arbitrary (high) cost and dropped the minimal one, with a now-false comment.

Fix: lexicographic two-phase enumeration.
  Phase 1 : opt.maximize(qualite) under cout < cout_precedent -> max quality.
  Phase 2 : opt2.minimize(cout) at that fixed quality -> minimal cost, which
            guarantees the point is truly Pareto-optimal (non-dominated).
Re-exec cells 1+10+12 (z3 4.16.0, rule F): 11 Pareto points, all on cout=2q
(the feasibility floor — for this model the minimal cost of quality q is exactly
2q, so the true front coincides with the floor). Real stdout transplanted to
cell 10; real matplotlib PNG transplanted to cell 12.

cell 11 markdown: removed the false "Pareto-equivalents" / "strictement au-dessus"
claim; the front now honestly coincides with the cout=2q floor, explained by the
two-phase method.
cell 13 markdown: rewrote the step table to reflect the two phases; added a key
point that phase 2 (minimize cost) is essential — without it the solver returns a
dominated cost.

Scope: cell 10 (code + output), cell 11 (md), cell 12 (output: plot + stdout),
cell 13 (md). 23 other cells byte-identical to origin/main. nbformat validate OK
(27 cells). C.1 clean, 0 leaks, CRLF=0, LF, no-BOM, trailing-nl. Surgical raw-json
round-trip (42+/44-, 1 file).

Visual note: cell 12 plot regenerated from verified-correct data (front points
are exactly (q, 2q); the plot draws those points + the cout=2q dashed line, so the
markers sit ON the dashed line by construction). GLM lane has no vision — visual
confirmation of the plot at merge-gate (ai-01/Opus has vision) welcome but the
data-level correctness is guaranteed.

Defect found via Explore sonnet scan (read-only, Z3-Python family — fresh rotation
out of SmartContract per R6), G.1 firsthand-verified: read the FULL cell 10 source
+ output and the cell 11/13 markdowns before editing; confirmed the dominated
points and the false Pareto-equivalence claim verbatim. Companion findings Z3-04
cell 20 (Star claim) + cell 13 (date label) are separate lighter grains.

See #3801.

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

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.1s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 3.5s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 3.2s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 4.0s
Search-1-StateSpace.ipynb ✅ SUCCESS 3.6s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 2.6s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 18.5s
GameTheory-4c-NashExistence-Python.ipynb ✅ SUCCESS 2.9s

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

@github-actions

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)

@jsboige
jsboige merged commit 1b673e6 into main Jul 22, 2026
26 checks passed
@jsboige
jsboige deleted the fix/z3-06-pareto-front-dominated branch September 2, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant