Skip to content

examples: Example 9 — parser residue (balanced parens)#83

Merged
hyperpolymath merged 2 commits into
mainfrom
examples/parser-residue
May 20, 2026
Merged

examples: Example 9 — parser residue (balanced parens)#83
hyperpolymath merged 2 commits into
mainfrom
examples/parser-residue

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

Adds proofs/agda/EchoExampleParser.agda — Example 9 from the
presentation-dependence cluster identified by PR #76
(docs/echo-types/examples.md §9).

What lands

  • Toy Token (LP/RP) and parses : List Token → Bool (depth-counter
    balanced-parens decider — left-to-right state machine that aborts on
    negative depth and accepts iff final depth is zero).
  • Three concrete distinct token streams both parsing successfully:
    []ₜ, paren-pair = ()(), paren-nested = (()).
  • Headlines:
    • parses-non-injective — Σ-witness that distinct streams collapse
      to the same Boolean.
    • echo-parse-empty / echo-parse-pair / echo-parse-nested — three
      concrete Echo parses true carriers.
    • echo-parse-nested≢echo-parse-pair — the distinct-presentations
      headline; same shadow, distinct echoes.
    • parser-residue — the residue Σ-pair tying back to the
      EchoResidue-style framing (Boolean shadow forgets the stream).
  • BalancedClosed grammar inductive (four concrete constructors) +
    the four named grammar witnesses (empty-balanced,
    paren-empty-balanced, paren-nested-balanced,
    paren-pair-balanced) for the derivation-tree side of the residue.
  • Wired into All.agda + Smoke.agda (every headline pinned).

Model-shape choices

  • Took the pragmatic Bool-shadow path (per the prompt's suggested
    alternative): parses is a recursive depth-counter, not a full
    Σ-style derivation extractor. This avoids _++_ reasoning that
    the example's headline (presentation-dependence) does not need.
  • BalancedClosed enumerates the three concrete shapes we exhibit
    rather than passing through _++_-based concatenation — the
    closed-form constructors discharge each witness by case, keeping
    the file self-contained (no ++-lemma machinery, no rebuild of
    Balanced.bal-cat).
  • parser-residue is the lightweight Σ-pair shape (cf.
    EchoResidue.collapse-residue-same); the full
    Cert-relation + section lowering apparatus is overkill for
    Example 9 — the point is that the shadow is non-injective on
    Echo, witnessed concretely.

Cluster relationship

Parsers are the canonical example of "structured loss" — the
parsed/not-parsed Boolean forgets the actual derivation tree. Echo
carries what's lost. Per examples.md §9, this is the example that
forces the presentation-dependent axis (taxonomy axis 4): the same
parse shadow can be reached from different token streams, and the
Echo distinguishes them.

Invariants

  • --safe --without-K; no postulates, no funext, no escape pragmas.
  • Clean-worktree Agda build green: agda --safe --without-K proofs/agda/{EchoExampleParser,All,Smoke}.agda exit 0.
  • Base = main.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

hyperpolymath and others added 2 commits May 20, 2026 18:17
Adds `proofs/agda/EchoExampleParser.agda` — Example 9 from the
presentation-dependence cluster identified by PR #76
(docs/echo-types/examples.md §9). A toy `parses : List Token → Bool`
balanced-parens decider; the Boolean shadow is non-injective on
distinct presentations (`(())` vs `()()`), and the Echo retains the
token stream.

Headlines: `parses-non-injective`, three concrete `Echo parses true`
carriers (empty/pair/nested), `echo-parse-nested≢echo-parse-pair`,
and `parser-residue` (the residue Σ-pair). Four `BalancedClosed`
grammar witnesses for the same streams (concrete derivation-tree
side of the residue framing).

Wired into `All.agda` + `Smoke.agda`. Build green under
`--safe --without-K`; no postulates, no funext, no escape pragmas.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath hyperpolymath marked this pull request as ready for review May 20, 2026 17:29
@hyperpolymath hyperpolymath merged commit 0f37f12 into main May 20, 2026
2 of 10 checks passed
@hyperpolymath hyperpolymath deleted the examples/parser-residue branch May 20, 2026 17:29
hyperpolymath added a commit that referenced this pull request May 20, 2026
The `3227b15` merge of `main` into `examples/absint-sign` silently
dropped PR #83's additive changes (Example 9 parser residue, landed
on main as commit `0f37f12`).  This recovers them:

* `proofs/agda/EchoExampleParser.agda` — restored from
  `main:proofs/agda/EchoExampleParser.agda` (227 lines, byte-identical
  to the file PR #83 added).
* `proofs/agda/All.agda` — re-add `open import EchoExampleParser`
  alongside the AbsInt import.
* `proofs/agda/Smoke.agda` — re-add the 23-line `using` block from #83
  alongside this PR's AbsInt headline pins; both examples now pinned.

Build invariant restored: `agda proofs/agda/All.agda` and
`agda proofs/agda/Smoke.agda` exit 0 under `--safe --without-K` with
both Example 9 (parser) and Example 10 (AbsInt) wired in.  No
postulates, no escape pragmas.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request May 20, 2026
Second wave of the same merge regression: the `3227b15` merge of
`main` into `examples/absint-sign` also dropped PR #80's additive
changes (Axis 8(4) witness-search machine, landed on main as
commit `a1e9cbc`).  This recovers them on top of the previous
parser recovery commit `8950855`:

* `proofs/agda/EchoSearch.agda` — restored from
  `main:proofs/agda/EchoSearch.agda` (156 lines, byte-identical to
  PR #80).
* `proofs/agda/EchoSearchInstance.agda` — restored similarly
  (86 lines).
* `proofs/agda/All.agda` — re-add `open import EchoSearch` +
  `EchoSearchInstance` (in the post-`EchoDecidable` slot per #80).
* `proofs/agda/Smoke.agda` — re-add the 30-line headline-pin block
  for both modules, slotted between `EchoDecidable` and `EchoAccess`.

Build invariant restored: `agda proofs/agda/All.agda` and
`agda proofs/agda/Smoke.agda` exit 0 under `--safe --without-K`.
All four parallel-session additions (PRs #80 EchoSearch, #83
EchoExampleParser, plus this PR #82's EchoExampleAbsInt) are now
wired in together.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request May 20, 2026
…#86)

## Summary

Gate **F1** of the earn-back plan — the MAKE-OR-BREAK retraction from
[R-2026-05-18](../blob/main/docs/retractions.adoc) — now passes.

The 2026-05-18 spike `EchoGradedComonadF1.agda` had two of three
graded-comonad laws closed (`gc-counit-l`, `gc-counit-r`) and named
the remaining obstruction precisely: an isolated proof-engineering
type-mismatch at the inductive step of `gc-coassoc`, requiring an
explicit δ-naturality lemma over the outer `R` layer rather than the
ad-hoc `coe-cong-R ∘ sym` push. This PR discharges that obligation:

```agda
δ-suc : ∀ m n {A} (x : D (m + n) A) (b : Bool) →
        δ (suc m) n {A} (x , b) ≡ (δ m n x , b)
δ-suc m n {A} x b = coe-cong-R (D-+ m n A) x b
```

This factor + the existing `subst-D-suc` let `gc-coassoc` close as a
six-step `≡-Reasoning` chain. Stdlib's `+-assoc (suc m) n p` reduces
*definitionally* to `cong suc (+-assoc m n p)`, so the two ℕ-equation
proofs at the chain ends are syntactically identical and **ℕ-UIP is
not needed for `gc-coassoc` itself** (`gc-counit-l` still uses ℕ-UIP,
which is K-free via Hedberg / decidable equality).

## Mechanised content of F1

* Grade monoid `(ℕ, +, 0)`; `D 0 A = A`; `D (suc r) A = R (D r A)`
  where `R X = X × Bool` — a non-collapsing residue layer.
* `mapD r f` functorial (`mapD-id`, `mapD-∘`).
* `ε : D 0 A → A` — counit at the unit grade.
* `δ : D (m + n) A → D m (D n A)` — **NESTED** comultiplication.
* `gc-counit-r` (definitional), `gc-counit-l` (induction on grade),
  `gc-coassoc` (this PR).
* `D2-nontrivial` — separating witness that `D r` is not `⊤` / a prop.
* Echo is the grade-unit object: `D 0 (Echo f y) ≡ Echo f y`.

`--safe --without-K`, **zero postulates**, zero escape pragmas, no
funext. Wired into `All.agda` and pinned in `Smoke.agda`.

## Scope (please re-read with care)

F1 earns back the **existence** of a graded comonad with Echo as the
grade-unit object — that's the claim R-2026-05-18 retracted at its
strongest reading. It does **NOT** retroactively make `EchoGraded`
itself a graded comonad: `EchoGraded` remains a thin-poset reindexing
modality on a three-element lattice, with no nested family, no monoid
multiplication, no `D r r' ⇒ D r ∘ D r'`. The paper's title and central
thesis (Echo as a reindexing modality) stand unchanged; F1 enters the
codebase as an *additional* mechanised contribution beside
`EchoGraded`.

## What this unblocks

Gate **F3** — a genuinely independent second model of the comonad at
a different grade monoid (e.g. tropical or multiplicative semiring),
without a `× ⊤` carrier or a `⊑-prop`-equivalent field — is now in
scope. F3 is **not** started by this PR.

## Doc changes (gated, scoped)

* `docs/echo-types/earn-back-plan.adoc` — ledger row A1 + Status
  entry (F1 PASSED 2026-05-20), with the scope qualifier pinned.
* `docs/retractions.adoc` — follow-up **F-2026-05-20a** appended
  (append-only revision policy preserved); no edits to other doc
  bodies.
* `paper.adoc`, `types-abstract.adoc`, `conservativity.adoc` —
  **intentionally untouched** in this PR. Their bodies are about
  `EchoGraded`'s thin-poset structure, which F1 does not change.
  Whether to add a bounded new-contribution paragraph mentioning the
  F1 side-construction is **owner-gated**.

## Test plan

* [x] `agda proofs/agda/All.agda` exit 0 under `--safe --without-K`
* [x] `agda proofs/agda/Smoke.agda` exit 0 under `--safe --without-K`
* [x] `grep -nE '^\s*postulate\b|BUILTIN
REWRITE|NON_TERMINATING|TERMINATING'
      proofs/agda/EchoGradedComonadF1.agda` returns no matches in code
* [x] `--safe --without-K` OPTIONS line preserved on the F1 module
* [ ] (owner) confirm the scope language in `retractions.adoc`
      F-2026-05-20a matches intent
* [ ] (owner) decide whether `paper.adoc` / `types-abstract.adoc` /
      `conservativity.adoc` should gain a bounded contribution
      paragraph in a separate PR

## Non-overlap with parallel sessions

Touches: `EchoGradedComonadF1.agda` (existing 2026-05-18 spike,
finishing it), `All.agda` (one-line F1 import), `Smoke.agda` (F1 pin
block), `earn-back-plan.adoc`, `retractions.adoc`.

Stays clear of:
* `proofs/agda/Ordinal/**` — the Brouwer-arithmetic / `_<ᵇ⁻_` /
  rank-mono session's territory.
* Any module the recent estate PRs (#80 EchoSearch, #81
EchoExampleProvenance,
  #83 EchoExampleParser) added — restored their imports cleanly
  during the rebase onto fresh `origin/main`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request May 20, 2026
Third wave of the same merge regression pattern that the prior fix-up
commits (8950855 for #83 EchoExampleParser, 549f219 for #80 EchoSearch)
already addressed: between the last main-merge and now, PR #81 landed
on main, adding EchoExampleProvenance.agda and its imports/pins.

Resolution: keep this PR's EchoExampleAbsInt additions and add the
EchoExampleProvenance additions from main alongside them (additive on
both sides — no semantic conflict, both examples coexist).

* proofs/agda/All.agda — both `open import EchoExampleAbsInt` and
  `open import EchoExampleProvenance` retained; EchoExamples (which
  the conflict block had duplicated) appears once.
* proofs/agda/Smoke.agda — both the Example 10 (AbsInt) pin block
  and the Example 5 (Provenance) pin block retained, in that order.
* proofs/agda/EchoExampleProvenance.agda — restored from main (new
  file on this branch).

Build invariant restored: `agda proofs/agda/All.agda` and
`agda proofs/agda/Smoke.agda` exit 0 under `--safe --without-K`. All
examples added by parallel sessions (#80 EchoSearch, #81 EchoExampleProvenance,
#83 EchoExampleParser, plus this PR #82 EchoExampleAbsInt) are wired in
together. No postulates, no escape pragmas.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request May 20, 2026
…landed (#89)

Updates the `Current rung state (2026-05-20)` block to record Wave 3
of today's swarm and refresh the next-Claude plan.

## What this captures

* 5 Wave-3 PRs (`#80` EchoSearch, `#81` provenance, `#82` absint,
  `#83` parser, `#85` EchoCost) and 2 parallel-session merges
  (`#84` Pillar E Evaluation, `#86` F1 gc-coassoc).
* Axis 8 is now 4-of-4 (decidability + graded access + cost + search).
* Next-Claude plan refreshed: ordinal-track unbudgeted WF is the named
  next bottleneck; EchoApprox examples 6/8 still open; EchoSearch
  sequential/product composition deferred.

## Two minor lessons memorialised

* Per-lane Smoke `open import ... using ( ... )` blocks should be
  separate (with header comments), not shared paren-blocks — cuts
  swarm merge-conflict noise.
* During swarm-merge sequences, re-fetch the branch before any
  force-push: parallel claude sessions may be concurrently rebasing
  the same PR (observed on `#82`).

## Invariants

* Doc-only change; no Agda touched.
* `--safe --without-K` invariant unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request May 20, 2026
…luster landed (#92)

## Summary

Three small accuracy passes through `docs/echo-types/` after the
earn-back programme, the §"Theory work — no proof assistant needed"
section, and the canonical examples cluster (5/9/10) all closed in
this session. Pure prose; no Agda changes.

### 1. `roadmap.md` §"Theory work" — two stale items refreshed

* **Axis 8** line said the *decidability-respecting* candidate had
  shipped but listed the other three as still candidate refinements.
  All four have now shipped: `EchoDecidable`, `EchoCost` (#85),
  `EchoAccess` (#68 / #75), `EchoSearch` (#80). Updated to credit all
  four.
* **Negative / co-echoes** line was `[unblocked]`; now `[landed]` —
  `AntiEcho` (#69), tropical decomposition concrete + generic (#72 +
  #91), `antiecho-partition-dec` (#90). Names the `coecho.md` §5
  obligation-5 / obligation-6 closures explicitly.

After these edits, every item in §"Theory work — no proof assistant
needed" is either `[landed]` or `[ruled out]`/`[refreshed]` — the
section is genuinely closed.

### 2. `roadmap.md` §"Example work" — three items landed

* ex. 5 (`EchoExampleProvenance`, #81) → `[landed]`
* ex. 9 (`EchoExampleParser`, #83) → `[landed]`
* ex. 10 (`EchoExampleAbsInt`, #82) → `[landed]`

Only ex. 6 (approximate-echo numeric example) remains `[unblocked]`.

### 3. `earn-back-plan.adoc` — stale `roadmap-gates.adoc` claim
corrected

* Header note used to say "the gate discipline was historically
  attributed to a `roadmap-gates.adoc`; that file does not exist
  in-tree". The file **does** exist (created 2026-05-18; see its
  preamble). Header rewritten to list `roadmap-gates.adoc` alongside
  `retractions.adoc` / this plan / `next-questions.adoc` as the four
  canonical loci.
* Ledger row D (the "doesn't exist" entry) marked **CLOSED 2026-05-20**
  with the cite reflecting current reality.

## Test plan

* [x] Pure docs / `.adoc` / `.md` edits — no Agda touched
* [x] `agda proofs/agda/All.agda` exit 0 (confirms docs match code)
* [x] `agda proofs/agda/Smoke.agda` exit 0
* [x] No retracted-claim language moved; no earned-back claim
      overclaimed; `paper.adoc` / `types-abstract.adoc` /
      `conservativity.adoc` untouched

## Scope

Disjoint from all currently-open PRs:
* #88 (F3) — touches Agda + `retractions.adoc` (different sections)
  + `earn-back-plan.adoc` Status (different section from header /
  ledger-D)
* #90 (partition-dec) — touches Agda only
* #91 (generic-codomain) — touches Agda + preamble comments

No retracted claim is moved. No earned-back claim is overclaimed.
`paper.adoc` / `types-abstract.adoc` / `conservativity.adoc` are
intentionally untouched (owner-gated, per the posture set by #86 /
#88).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 10 issues detected

Severity Count
🔴 Critical 0
🟠 High 5
🟡 Medium 5
View findings
[
  {
    "reason": "No test directory or test files found",
    "type": "no_tests",
    "file": "/home/runner/work/echo-types/echo-types",
    "action": "flag",
    "rule_module": "honest_completion",
    "severity": "high",
    "deduction": 20
  },
  {
    "reason": "Issue in quality.yml",
    "type": "missing_workflow",
    "file": "quality.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in security-policy.yml",
    "type": "missing_workflow",
    "file": "security-policy.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in secret-scanner.yml",
    "type": "missing_workflow",
    "file": "secret-scanner.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Action actions/cache@v4 needs attention",
    "type": "unpinned_action",
    "file": "agda.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "No dependabot.yml or renovate.json found in echo-types",
    "type": "DependencyUpdate",
    "file": "/home/runner/work/echo-types/echo-types",
    "action": "auto_fix",
    "rule_module": "scorecard",
    "severity": "high",
    "remediation": "Add .github/dependabot.yml or renovate.json configuration.",
    "scorecard_check": "Dependency-Update-Tool"
  },
  {
    "reason": "Nominal-only SAST in echo-types: codeql.yml language matrix contains no language present in the repo and lacks `actions`, so CodeQL records zero results on every commit. Remediation: set the CodeQL matrix to `language: actions`.",
    "type": "StaticAnalysis",
    "file": "/home/runner/work/echo-types/echo-types",
    "action": "auto_fix",
    "rule_module": "scorecard",
    "severity": "medium",
    "remediation": "Add CodeQL or equivalent SAST workflow.",
    "scorecard_check": "SAST"
  },
  {
    "reason": "1 workflow(s) with tag-pinned (not SHA-pinned) actions in echo-types",
    "type": "DependencyPinning",
    "file": "/home/runner/work/echo-types/echo-types",
    "action": "auto_fix",
    "rule_module": "scorecard",
    "severity": "medium",
    "remediation": "Pin GitHub Actions and Docker base images by SHA hash.",
    "scorecard_check": "Pinned-Dependencies"
  },
  {
    "reason": "Repository has 1 non-main remote branch(es). Policy: single main branch only.",
    "type": "GS007",
    "file": ".",
    "action": "delete_remote_branches",
    "rule_module": "git_state",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

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