diff --git a/.cursor/skills/marqdo/SKILL.md b/.cursor/skills/marqdo/SKILL.md index 0c990fe..df8516c 100644 --- a/.cursor/skills/marqdo/SKILL.md +++ b/.cursor/skills/marqdo/SKILL.md @@ -4,9 +4,10 @@ description: >- Author and edit Marqdo programs (.mq.md): Markdown markers are executable syntax (functions, calls, statements, returns, control flow). Use when writing or modifying .mq.md files, teaching Marqdo, generating Marqdo from prose, - importing lib/* or ext/web, running marqdo CLI, building dynamic sites with - ext/web, or when the user mentions Marqdo, mq.md, markup-as-syntax, - code-as-documentation, or web/网页 extension. + importing lib/* or ext/web or ext/quantum, running marqdo CLI, building dynamic + sites with ext/web, quantum circuits with ext/quantum, or when the user + mentions Marqdo, mq.md, markup-as-syntax, code-as-documentation, web/网页, or + quantum/量子 extension. --- # Marqdo development @@ -133,7 +134,7 @@ import clock:lib/time.mq.md - Instance methods stay `` > `obj`.method `` (backticks on the receiver only). - `lib/…` resolves via `MARQDO_LIB`, cwd `lib/`, or `lib/` next to the `marqdo` binary. - Design: [module-namespace.md](../../doc/design/module-namespace.md). -- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm|agent|web|quantum` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — document-driven agents: **step** (default writeback) / **plan** workbook ([ext-agent.md](../../doc/design/ext-agent.md), [ext-agent-plan.md](../../doc/design/ext-agent-plan.md)); **`ext/web`** — dynamic sites (W0–W7 + P3 complete; see below). +- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm|agent|web|quantum` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — document-driven agents: **step** (default writeback) / **plan** workbook ([ext-agent.md](../../doc/design/ext-agent.md), [ext-agent-plan.md](../../doc/design/ext-agent-plan.md)); **`ext/web`** — dynamic sites (W0–W7 + P3 complete; see below); **`ext/quantum`** — circuits + Q7 density/viz (see below). - Native plugins: `lib/plugin` — `## load` / `unload` / `list`. C ABI: `include/marqdo_abi.h`. - Prefer `table.put` / `表.改` for list/map element updates; keep `json` for parse/stringify/quote (see `doc/design/stdlib-table.md`). - Builtins (no import): `print`/`打印`, `input`/`输入`, `len`/`长度`, `str`/`文本`, `int`/`整数`; literals `True`/`真`, `False`/`假`, `None`/`空`; logic `and`/`且`, `or`/`或`, `not`/`非`. @@ -177,6 +178,23 @@ Design: [ext-web.md](../../doc/design/ext-web.md) · capability matrix: [web-net Web patterns: [examples.md](examples.md) §13 · API index: [reference.md](reference.md). +## Official extension: `ext/quantum` (circuits + Q7) + +Install: `marqdo ext add quantum` (ZH id: `量子`). Build: `cargo build --release -p marqdo_plugin_quantum`. + +- EN: `import quantum:ext/quantum/quantum.mq.md` +- ZH: `导入 量子:ext/quantum/量子.mq.md` + +**Hard rules:** `ext/**` never calls `host_*`; hot path is ABI plugin; ≤12 qubits for statevector; density-matrix ops ≤6 qubits; one language file per program. + +**Core:** `# circuit` / `# gate` / `# density` — table `steps=` or method chain; `simulate` / `probabilities` / `run` / `draw`. + +**Q7 linear algebra:** `density`, `partial_trace`, `eig`, `expect` (Pauli string, left=high bit), `purity`, `kron`, `schmidt`, `fidelity`. + +**Q7 draw kinds:** `circuit|probs|bloch|hinton|city|density|paulivec|qsphere|multibloch` (quote string args: `kind="hinton"`). + +Design: [ext-quantum.md](../../doc/design/ext-quantum.md) · Q7: [ext-quantum-q7.md](../../doc/design/ext-quantum-q7.md) · examples: [quantum-bell](../../examples/quantum-bell/) · [quantum-entanglement](../../examples/quantum-entanglement/). + ## AI authoring workflow 1. Decide language surface (English builtins + `lib/text.mq.md`, or Chinese + `lib/文本.mq.md`). @@ -201,6 +219,8 @@ Web patterns: [examples.md](examples.md) §13 · API index: [reference.md](refer | `json.set` to build page parts | GFM tables + `page.compose_*` / `web.page` methods | | Mix `web.page` and `网页.页面` in one file | One import language per `.mq.md` | | Call `host_web_*` from `ext/web` | Use `# app` / `# db` methods; plugin ABI only | +| Call `host_*` from `ext/quantum` | Use `# circuit` / `# density` methods; plugin ABI only | +| Bare `kind=hinton` inside `*…*` | `kind="hinton"` — quote text literals | ## Checklist before finishing diff --git a/.cursor/skills/marqdo/examples.md b/.cursor/skills/marqdo/examples.md index 52def08..d99288e 100644 --- a/.cursor/skills/marqdo/examples.md +++ b/.cursor/skills/marqdo/examples.md @@ -271,3 +271,30 @@ import db:db/index.mq.md - Import `ext/web/web.mq.md` **or** `ext/web/网页.mq.md` — not both; match API language to the file. - Full blog/CMS patterns: `examples/marqdo-blog/` (routes, SEO, RSS, auth, upload, WS). - Run after `marqdo ext add web` and building `marqdo_plugin_web`. + +## 14. Quantum entanglement lab (ext/quantum Q7) + +```markdown +--- +import quantum:ext/quantum/quantum.mq.md +--- + +# main + +`steps` = + +| step | gate | qubits | +|------|------|--------| +| 1 | H | 0 | +| 2 | CX | 0,1 | + +*qc = > quantum.circuit qubits=2 steps=`steps`* +*rho = > `qc`.density* +*red = > `rho`.partial_trace keep=0* +*sch = > `qc`.schmidt cut=1* +*_ = > `qc`.draw kind="hinton"* +> print text=`red` +``` + +- Full lab: `examples/quantum-entanglement/`. Bell-only: `examples/quantum-bell/`. +- Build `marqdo_plugin_quantum` then `marqdo ext add quantum`. diff --git a/.cursor/skills/marqdo/reference.md b/.cursor/skills/marqdo/reference.md index 8dca330..163d7df 100644 --- a/.cursor/skills/marqdo/reference.md +++ b/.cursor/skills/marqdo/reference.md @@ -55,6 +55,7 @@ Import one file; use **that** file’s function names. | `ext/llm.mq.md` | `ext/大模型.mq.md` | `# llm` / `# 大模型` object + chat methods | | `ext/agent.mq.md` | `ext/智能体.mq.md` | agent **framework** (layout now; LLM orchestration roadmap in `ext-agent.md`) | | `ext/web/web.mq.md` | `ext/web/网页.mq.md` | dynamic sites — see **ext/web** section below | +| `ext/quantum/quantum.mq.md` | `ext/quantum/量子.mq.md` | circuits + Q7 density/viz — see **ext/quantum** below | Open the imported `.mq.md` under `lib/` or `ext/` to see exact `##` / `#` names and parameters. Gold tests: `tests/lib/`, `tests/structure/`, `tests/ext/`. @@ -77,6 +78,24 @@ Drivers (Postgres / Redis / S3): `db url=postgres://…`, `cache url=memory:`, ` Example project: `examples/marqdo-blog/`. Capability matrix: `doc/design/web-net-capabilities.md`. +## ext/quantum (circuits + Q7) + +Install: `marqdo ext add quantum` (`量子`). Native: `cargo build --release -p marqdo_plugin_quantum`. + +| EN import | ZH import | Core types | +|-----------|-----------|------------| +| `ext/quantum/quantum.mq.md` | `ext/quantum/量子.mq.md` | `# circuit` `# gate` `# density` | + +| Area | EN APIs | Notes | +|------|---------|-------| +| Circuit | `h`/`cx`/…, `simulate`, `probabilities`, `run`, `draw`, `noise` | `steps=` GFM table; ≤12 qubits | +| Gate | `matrix`, `matches_matrix`, `draw` | named or `matrix=` custom unitary | +| Density (Q7) | `purity`, `partial_trace`, `eig`, `expect`, `draw` | ≤6 qubits for dense ρ | +| Free (Q7) | `kron`, `schmidt`, `fidelity` | top-level on import bind | +| Draw kinds | `circuit\|probs\|bloch\|hinton\|city\|density\|paulivec\|qsphere\|multibloch` | quote `kind="…"` | + +Examples: `examples/quantum-bell/`, `examples/quantum-entanglement/`. Design: `doc/design/ext-quantum-q7.md`. + ## Formula + plot (math) ```markdown @@ -154,4 +173,6 @@ See `doc/design/call-arguments.md`. | `doc/design/ext-cli.md` | `marqdo ext list/add/remove` | | `doc/design/ext-web.md` | `ext/web` dynamic sites (author API) | | `doc/design/web-net-capabilities.md` | ext/web capability matrix (W0–W7 + P3) | +| `doc/design/ext-quantum.md` | `ext/quantum` circuits | +| `doc/design/ext-quantum-q7.md` | Q7 density linear algebra + advanced SVG | | `doc/design/view-debug.md` | view / debug hosts | diff --git a/CHANGELOG.md b/CHANGELOG.md index 26ba8ab..9264c6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - **`ext/web` 样式装配(`web_style` / `网页.样式装配`)**: 样式即数据表格 —— GFM 样式表(`|选择器|属性|值|`,可用 `|媒体|` 列分组进 `@media` 块)经 `样式装配` 函数转成 CSS 文本,再拼装成完整主题。替代"整段手写 CSS 字符串"的写法,贯彻 文档即代码。见 [marqdo-blog](examples/marqdo-blog/styles/theme.mq.md)。 - **网络能力调研(`doc/design/web-net-capabilities.md`)**: 盘点 `ext/web` + `plugins/web` + `lib/net` 现状,对照主流语言网络栈(FastAPI / Express / Flask / axum),给出「开发一个完整 Web 项目」所需能力的差距清单与分波次补强路线(W1–W7 + P3,**2026-08-28 已全部落地**)。 - **AI Skill + 文档(ext/web 完结复核)**: `skills/marqdo/` 与 `.cursor/skills/marqdo/` 增加 **ext/web 动态站** 专节(硬规则、API 摘要、§13 最小站点样例);`doc/design/web-net-capabilities.md` 结论/对照表与 W7+P3 实现对齐;`doc/design/ai-skill.md` 更新用途说明。 -- **`ext/quantum` Q7(高阶线性代数 + 高级可视化)**: 密度矩阵 / 部分迹 / Hermitian 谱 / Schmidt / Pauli 期望 / 纯度;SVG:hinton、city、density、paulivec、qsphere、multibloch。全部经 `plugins/quantum` ABI。设计 [ext-quantum-q7.md](doc/design/ext-quantum-q7.md);金样 `quantum-linalg-smoke`、`quantum-viz-advanced-smoke`。 +- **`ext/quantum` Q7(高阶线性代数 + 高级可视化)**: 密度矩阵 / 部分迹 / Hermitian 谱 / Schmidt / Pauli 期望 / 纯度;SVG:hinton、city、density、paulivec、qsphere、multibloch。全部经 `plugins/quantum` ABI。设计 [ext-quantum-q7.md](doc/design/ext-quantum-q7.md);金样 `quantum-linalg-smoke`、`quantum-viz-advanced-smoke`;示例 [quantum-entanglement](examples/quantum-entanglement/)。 ### Changed - **Frontmatter import syntax**: `import bind:target` / `导入 bind:target` (file `.mq.md` or short name `lib.member`). Removed legacy `> path.mq.md` / `> use` imports. See [module-namespace.md](doc/design/module-namespace.md). diff --git a/doc/design/ext-quantum-q7.md b/doc/design/ext-quantum-q7.md index c11a1ad..d0fc513 100644 --- a/doc/design/ext-quantum-q7.md +++ b/doc/design/ext-quantum-q7.md @@ -2,7 +2,7 @@ | | | |---|---| -| 状态 | **Accepted · Q7a/Q7b 已落地**(Q7c 示例/文档摘要可跟进) | +| 状态 | **Accepted · Q7a/Q7b/Q7c 已落地** | | 日期 | 2026-08-28 | | 父设计 | [ext-quantum.md](ext-quantum.md) | | 路线图 | [roadmap/ext-quantum.md](../roadmap/ext-quantum.md) | diff --git a/doc/design/ext-quantum.md b/doc/design/ext-quantum.md index ed08700..aac2876 100644 --- a/doc/design/ext-quantum.md +++ b/doc/design/ext-quantum.md @@ -324,7 +324,7 @@ Q5 教学噪声 + barrier/measure/append/state — 见 [ext-quantum-q5.md](ext- | **Q4** | 概率图 + 布洛赫;`matches_matrix`;用户文档页 | `quantum-draw-smoke` / `quantum-gate-matrix-smoke`;`view output` 可浏览示例 | | **Q5** | `noise` 轨迹;`barrier`/`measure`/`append`/`state` | `quantum-noise-smoke` / `quantum-author-api-smoke` | | **Q6** | 公式/`matrix=` 自定义门 | [ext-quantum-custom-gate.md](ext-quantum-custom-gate.md) | -| **Q7** | 密度矩阵线性代数 + Hinton/City/QSphere 等 SVG | [ext-quantum-q7.md](ext-quantum-q7.md) | +| **Q7** | 密度矩阵线性代数 + Hinton/City/QSphere 等 SVG + 纠缠示例 | [ext-quantum-q7.md](ext-quantum-q7.md) ✅ | 实现路线图跟踪见 [roadmap/ext-quantum.md](../roadmap/ext-quantum.md)。 diff --git a/doc/roadmap/ext-quantum.md b/doc/roadmap/ext-quantum.md index 9b681f0..ccea280 100644 --- a/doc/roadmap/ext-quantum.md +++ b/doc/roadmap/ext-quantum.md @@ -2,7 +2,7 @@ | | | |---|---| -| 状态 | **Q0–Q7b 已落地 · Q7c 待补**(高阶线性代数 + 高级可视化) | +| 状态 | **Q0–Q7 完结**(高阶线性代数 + 高级可视化 + 纠缠示例) | | 日期 | 2026-08-28 | | **锁定设计** | [design/ext-quantum.md](../design/ext-quantum.md) | | 相关 | [ext-cli.md](../design/ext-cli.md) · [ext-abi.md](../design/ext-abi.md) · [stdlib-math.md](../design/stdlib-math.md) · [view.md](../design/view.md) | @@ -32,9 +32,9 @@ | **Q6** | 公式/`matrix=` 自定义门 + `apply` — [ext-quantum-custom-gate.md](../design/ext-quantum-custom-gate.md) | **done** | | **Q7a** | 密度矩阵 / Kronecker / 部分迹 / Hermitian 谱 / Schmidt / Pauli 期望 / 纯度·保真度 — [ext-quantum-q7.md](../design/ext-quantum-q7.md) | **done** | | **Q7b** | 高级 SVG:hinton / city / density / paulivec / qsphere / multibloch | **done** | -| **Q7c** | 纠缠示例 + 用户文档 / skill 摘要 | **pending** | +| **Q7c** | 纠缠示例 + 用户文档 / skill 摘要 | **done** | -验收金样:既有 `tests/ext/quantum-*-smoke.mq.md`;Q7 新增 `quantum-linalg-smoke`、`quantum-viz-advanced-smoke`(及中文对称)。 +验收金样:既有 `tests/ext/quantum-*-smoke.mq.md`;Q7:`quantum-linalg-smoke`、`quantum-viz-advanced-smoke`。示例:`examples/quantum-bell/`、`examples/quantum-entanglement/`。 --- diff --git a/examples/quantum-entanglement/README.md b/examples/quantum-entanglement/README.md new file mode 100644 index 0000000..3c69a98 --- /dev/null +++ b/examples/quantum-entanglement/README.md @@ -0,0 +1,13 @@ +# quantum-entanglement + +Bell |Φ⁺⟩ **entanglement lab** via `ext/quantum` Q7: density matrix, partial trace, Schmidt entropy, and advanced SVG (hinton / qsphere / multibloch / city). + +```bash +cargo build --release -p marqdo_plugin_quantum +marqdo ext add quantum # once +marqdo run examples/quantum-entanglement/index.mq.md +``` + +Prints probabilities, full/reduced purity, ⟨ZZ⟩, and Schmidt entropy; writes SVGs next to the program (sandbox cwd). + +Design: [ext-quantum-q7.md](../../doc/design/ext-quantum-q7.md) · sibling demo: [quantum-bell](../quantum-bell/). diff --git a/examples/quantum-entanglement/index.mq.md b/examples/quantum-entanglement/index.mq.md new file mode 100644 index 0000000..0b2601d --- /dev/null +++ b/examples/quantum-entanglement/index.mq.md @@ -0,0 +1,45 @@ +--- +title: Entanglement lab +description: Bell state — density, partial trace, Schmidt, advanced SVG (Q7). +import quantum:ext/quantum/quantum.mq.md +import math:lib/math.mq.md +--- + +# Entanglement from a runnable document + +Build |Φ⁺⟩ with H then CX. Full-state purity stays 1; tracing out one qubit yields a mixed state (purity 1/2). Schmidt coefficients and entropy quantify the bipartition. SVG plots (hinton / qsphere / multibloch) make the same facts visible. + +# main + +`steps` = + +| step | gate | qubits | +|------|------|--------| +| 1 | H | 0 | +| 2 | CX | 0,1 | + +*qc = > quantum.circuit qubits=2 steps=`steps`* +*p = > `qc`.probabilities* + +*rho = > `qc`.density* +*pur = > `rho`.purity* +*red = > `rho`.partial_trace keep=0* +*rpur = > `red`.purity* + +*zz = "ZZ"* +*ezz = > `qc`.expect obs=`zz`* + +*sch = > `qc`.schmidt cut=1* +*ent = sch[^entropy]* + +*_ = > `qc`.draw path="entangle-circuit.svg"* +*_ = > `qc`.draw kind="hinton" path="entangle-hinton.svg"* +*_ = > `qc`.draw kind="qsphere" path="entangle-qsphere.svg"* +*_ = > `qc`.draw kind="multibloch" path="entangle-multibloch.svg"* +*_ = > `rho`.draw kind="city" path="entangle-city.svg"* + +> print text=`p` +> print text=`pur` +> print text=`rpur` +> print text=`ezz` +> print text=`ent` diff --git a/public/features/06-quantum.mq.md b/public/features/06-quantum.mq.md index a624573..8e6c898 100644 --- a/public/features/06-quantum.mq.md +++ b/public/features/06-quantum.mq.md @@ -1,6 +1,6 @@ --- title: Quantum circuits (ext/quantum) -description: Official quantum simulator — tables, gates, probs/Bloch/matrix SVG +description: Official quantum simulator — tables, gates, Q7 density and advanced SVG import quantum:ext/quantum/quantum.mq.md --- @@ -8,7 +8,9 @@ import quantum:ext/quantum/quantum.mq.md Optional package (not stdlib). Install: `marqdo ext add quantum` (or build `marqdo_plugin_quantum`). -GHZ (3 qubits): H on q0, then CX 0→1 and 0→2. Ideal |000⟩ / |111⟩ each ≈ 1/2. `draw kind=probs` embeds probability bars; `gate.draw kind=matrix` shows a heatmap. +GHZ (3 qubits): H on q0, then CX 0→1 and 0→2. Ideal |000⟩ / |111⟩ each ≈ 1/2. + +Q7: Bell density, partial trace (mixed reduced state), Schmidt entropy, and `draw kind=hinton` / qsphere. See `examples/quantum-entanglement/`. `steps` = diff --git a/skills/marqdo/SKILL.md b/skills/marqdo/SKILL.md index 0c990fe..df8516c 100644 --- a/skills/marqdo/SKILL.md +++ b/skills/marqdo/SKILL.md @@ -4,9 +4,10 @@ description: >- Author and edit Marqdo programs (.mq.md): Markdown markers are executable syntax (functions, calls, statements, returns, control flow). Use when writing or modifying .mq.md files, teaching Marqdo, generating Marqdo from prose, - importing lib/* or ext/web, running marqdo CLI, building dynamic sites with - ext/web, or when the user mentions Marqdo, mq.md, markup-as-syntax, - code-as-documentation, or web/网页 extension. + importing lib/* or ext/web or ext/quantum, running marqdo CLI, building dynamic + sites with ext/web, quantum circuits with ext/quantum, or when the user + mentions Marqdo, mq.md, markup-as-syntax, code-as-documentation, web/网页, or + quantum/量子 extension. --- # Marqdo development @@ -133,7 +134,7 @@ import clock:lib/time.mq.md - Instance methods stay `` > `obj`.method `` (backticks on the receiver only). - `lib/…` resolves via `MARQDO_LIB`, cwd `lib/`, or `lib/` next to the `marqdo` binary. - Design: [module-namespace.md](../../doc/design/module-namespace.md). -- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm|agent|web|quantum` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — document-driven agents: **step** (default writeback) / **plan** workbook ([ext-agent.md](../../doc/design/ext-agent.md), [ext-agent-plan.md](../../doc/design/ext-agent-plan.md)); **`ext/web`** — dynamic sites (W0–W7 + P3 complete; see below). +- Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm|agent|web|quantum` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — document-driven agents: **step** (default writeback) / **plan** workbook ([ext-agent.md](../../doc/design/ext-agent.md), [ext-agent-plan.md](../../doc/design/ext-agent-plan.md)); **`ext/web`** — dynamic sites (W0–W7 + P3 complete; see below); **`ext/quantum`** — circuits + Q7 density/viz (see below). - Native plugins: `lib/plugin` — `## load` / `unload` / `list`. C ABI: `include/marqdo_abi.h`. - Prefer `table.put` / `表.改` for list/map element updates; keep `json` for parse/stringify/quote (see `doc/design/stdlib-table.md`). - Builtins (no import): `print`/`打印`, `input`/`输入`, `len`/`长度`, `str`/`文本`, `int`/`整数`; literals `True`/`真`, `False`/`假`, `None`/`空`; logic `and`/`且`, `or`/`或`, `not`/`非`. @@ -177,6 +178,23 @@ Design: [ext-web.md](../../doc/design/ext-web.md) · capability matrix: [web-net Web patterns: [examples.md](examples.md) §13 · API index: [reference.md](reference.md). +## Official extension: `ext/quantum` (circuits + Q7) + +Install: `marqdo ext add quantum` (ZH id: `量子`). Build: `cargo build --release -p marqdo_plugin_quantum`. + +- EN: `import quantum:ext/quantum/quantum.mq.md` +- ZH: `导入 量子:ext/quantum/量子.mq.md` + +**Hard rules:** `ext/**` never calls `host_*`; hot path is ABI plugin; ≤12 qubits for statevector; density-matrix ops ≤6 qubits; one language file per program. + +**Core:** `# circuit` / `# gate` / `# density` — table `steps=` or method chain; `simulate` / `probabilities` / `run` / `draw`. + +**Q7 linear algebra:** `density`, `partial_trace`, `eig`, `expect` (Pauli string, left=high bit), `purity`, `kron`, `schmidt`, `fidelity`. + +**Q7 draw kinds:** `circuit|probs|bloch|hinton|city|density|paulivec|qsphere|multibloch` (quote string args: `kind="hinton"`). + +Design: [ext-quantum.md](../../doc/design/ext-quantum.md) · Q7: [ext-quantum-q7.md](../../doc/design/ext-quantum-q7.md) · examples: [quantum-bell](../../examples/quantum-bell/) · [quantum-entanglement](../../examples/quantum-entanglement/). + ## AI authoring workflow 1. Decide language surface (English builtins + `lib/text.mq.md`, or Chinese + `lib/文本.mq.md`). @@ -201,6 +219,8 @@ Web patterns: [examples.md](examples.md) §13 · API index: [reference.md](refer | `json.set` to build page parts | GFM tables + `page.compose_*` / `web.page` methods | | Mix `web.page` and `网页.页面` in one file | One import language per `.mq.md` | | Call `host_web_*` from `ext/web` | Use `# app` / `# db` methods; plugin ABI only | +| Call `host_*` from `ext/quantum` | Use `# circuit` / `# density` methods; plugin ABI only | +| Bare `kind=hinton` inside `*…*` | `kind="hinton"` — quote text literals | ## Checklist before finishing diff --git a/skills/marqdo/examples.md b/skills/marqdo/examples.md index 52def08..d99288e 100644 --- a/skills/marqdo/examples.md +++ b/skills/marqdo/examples.md @@ -271,3 +271,30 @@ import db:db/index.mq.md - Import `ext/web/web.mq.md` **or** `ext/web/网页.mq.md` — not both; match API language to the file. - Full blog/CMS patterns: `examples/marqdo-blog/` (routes, SEO, RSS, auth, upload, WS). - Run after `marqdo ext add web` and building `marqdo_plugin_web`. + +## 14. Quantum entanglement lab (ext/quantum Q7) + +```markdown +--- +import quantum:ext/quantum/quantum.mq.md +--- + +# main + +`steps` = + +| step | gate | qubits | +|------|------|--------| +| 1 | H | 0 | +| 2 | CX | 0,1 | + +*qc = > quantum.circuit qubits=2 steps=`steps`* +*rho = > `qc`.density* +*red = > `rho`.partial_trace keep=0* +*sch = > `qc`.schmidt cut=1* +*_ = > `qc`.draw kind="hinton"* +> print text=`red` +``` + +- Full lab: `examples/quantum-entanglement/`. Bell-only: `examples/quantum-bell/`. +- Build `marqdo_plugin_quantum` then `marqdo ext add quantum`. diff --git a/skills/marqdo/reference.md b/skills/marqdo/reference.md index 8dca330..163d7df 100644 --- a/skills/marqdo/reference.md +++ b/skills/marqdo/reference.md @@ -55,6 +55,7 @@ Import one file; use **that** file’s function names. | `ext/llm.mq.md` | `ext/大模型.mq.md` | `# llm` / `# 大模型` object + chat methods | | `ext/agent.mq.md` | `ext/智能体.mq.md` | agent **framework** (layout now; LLM orchestration roadmap in `ext-agent.md`) | | `ext/web/web.mq.md` | `ext/web/网页.mq.md` | dynamic sites — see **ext/web** section below | +| `ext/quantum/quantum.mq.md` | `ext/quantum/量子.mq.md` | circuits + Q7 density/viz — see **ext/quantum** below | Open the imported `.mq.md` under `lib/` or `ext/` to see exact `##` / `#` names and parameters. Gold tests: `tests/lib/`, `tests/structure/`, `tests/ext/`. @@ -77,6 +78,24 @@ Drivers (Postgres / Redis / S3): `db url=postgres://…`, `cache url=memory:`, ` Example project: `examples/marqdo-blog/`. Capability matrix: `doc/design/web-net-capabilities.md`. +## ext/quantum (circuits + Q7) + +Install: `marqdo ext add quantum` (`量子`). Native: `cargo build --release -p marqdo_plugin_quantum`. + +| EN import | ZH import | Core types | +|-----------|-----------|------------| +| `ext/quantum/quantum.mq.md` | `ext/quantum/量子.mq.md` | `# circuit` `# gate` `# density` | + +| Area | EN APIs | Notes | +|------|---------|-------| +| Circuit | `h`/`cx`/…, `simulate`, `probabilities`, `run`, `draw`, `noise` | `steps=` GFM table; ≤12 qubits | +| Gate | `matrix`, `matches_matrix`, `draw` | named or `matrix=` custom unitary | +| Density (Q7) | `purity`, `partial_trace`, `eig`, `expect`, `draw` | ≤6 qubits for dense ρ | +| Free (Q7) | `kron`, `schmidt`, `fidelity` | top-level on import bind | +| Draw kinds | `circuit\|probs\|bloch\|hinton\|city\|density\|paulivec\|qsphere\|multibloch` | quote `kind="…"` | + +Examples: `examples/quantum-bell/`, `examples/quantum-entanglement/`. Design: `doc/design/ext-quantum-q7.md`. + ## Formula + plot (math) ```markdown @@ -154,4 +173,6 @@ See `doc/design/call-arguments.md`. | `doc/design/ext-cli.md` | `marqdo ext list/add/remove` | | `doc/design/ext-web.md` | `ext/web` dynamic sites (author API) | | `doc/design/web-net-capabilities.md` | ext/web capability matrix (W0–W7 + P3) | +| `doc/design/ext-quantum.md` | `ext/quantum` circuits | +| `doc/design/ext-quantum-q7.md` | Q7 density linear algebra + advanced SVG | | `doc/design/view-debug.md` | view / debug hosts |