How to write a linear-algebra formula documentok
文档
怎样读这份可执行文档
正文说明意图,标记指出哪些片段会执行。遮蔽只在正文显示动作说明,实际逻辑放在侧注;阅读、展开与定位都不会运行代码。
| 标记 | 阅读含义 |
|---|---|
无标记文字 | 作者的解释,按普通 Markdown 阅读。 |
空行 | 分隔叙述与结构,不是计算步骤。 |
# / ## | 一级标题声明对象或入口,更深标题声明函数;说明按钮可查看输入、返回与依据。 |
> | 调用函数;实际执行结果另有标注。 |
1. 递增 | 按条件选择分支,不是普通编号说明。 |
- | 重复或遍历结构;迭代选择器只切换已有运行记录。 |
+ `名` | 兼容的显式形参;新库优先在叙述中声明参数,标题下的表格解释契约。 |
GFM 表 | 未绑定的契约表是说明;绑定表按列、行和 @ 形态构成数据。 |
```lang | 代码块;绑定的外语代码与普通示例区分展示,数学公式另有公式卡片。 |
--- / *** | 分隔内容,不能把分隔线当作函数返回。 |
<!-- marqdo-out --> | 程序写回的结果,区别于作者原始正文。 |
`名` | 叙述中的参数或变量;默认值跟在名称之后。 |
**…** | 执行语句:赋值、调用或计算;不是打印,也不是返回。 |
*…* | 返回表达式;句中以返回、Return 等明确引出。 |
*None* / **** | 显式返回空值或结束当前函数。 |
[键](集合) | 正文显示描述,侧注按函数与参数、可跳转链接、结构化内容展示括号内的细节;空括号表示待补充实际逻辑。阅读不会执行调用。classic 模式保留旧链接取元。 |
修饰… [函数] … | 兼容的带修饰调用;不能把任意普通链接当作执行授权。 |
集合[^键] | 兼容的脚注取元;当前库优先用 access 读取集合。 |
*仅* / **说明** | 普通强调仍属于文字;界面按真实解析结果区分强调、语句与返回。 |
la:ext/linalg/linalg.mq.md
Not stdlib. Install: marqdo ext add linalg (or build marqdo_plugin_linalg).
Idea: if the
.mq.md runs and the asserted form matches, the identity holds under the library rules. Algebra reads like a lecture; factorize / lstsq / draw stay explicit calculation steps.| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
Declare symbols in a table, multiply, transpose — T_ascii is one-step display (auto-simplify).
shapes =
| @ | name | rows | cols |
|---|---|---|---|
| 1 | A | 2 | 3 |
| 2 | B | 3 | 2 |
We first env = for the next step.
函数调用Compute env
la.declare- table
`shapes`
原始写法
la.declare(table=`shapes`)We first A = for the next step.
函数调用A
access- 参数 1
`env`- 参数 2
- A
原始写法
access(`env`, "A")We first B = for the next step.
函数调用B
access- 参数 1
`env`- 参数 2
- B
原始写法
access(`env`, "B")We first P = (`A` * `B`) for the next step.
We first t = for the next step.
函数调用Compute t
P.T_ascii无需传入参数
原始写法
> `P`.T_asciiWe now .
函数调用Display this step's result
print- text
`t`
原始写法
> print text=`t`- t == "B^T*A^T"We now .
函数调用Display this step's result
源码说明 · 不是运行结果print- text
- formula-doc-ok
原始写法
> print text="formula-doc-ok" - elseWe now .
函数调用Display this step's result
源码说明 · 不是运行结果print- text
- formula-doc-fail
原始写法
> print text="formula-doc-fail"
We now .
函数调用Display this step's result
print- text
- see-examples-linalg-transpose
原始写法
> print text="see-examples-linalg-transpose"Functions
Variables
-
A matrix
_type matrix ascii A cols 3 kind symbol latex A name A … key value _type matrix ascii A cols 3 kind symbol latex A name A rows 2 shape # value 1 2 2 3 -
B matrix
_type matrix ascii B cols 2 kind symbol latex B name B … key value _type matrix ascii B cols 2 kind symbol latex B name B rows 3 shape # value 1 3 2 2 -
P matrix
_type matrix ascii A*B factors List(2) kind mul latex AB shape List(2) key value _type matrix ascii A*B factors # _type ascii cols kind latex name rows shape 1 matrix A 3 symbol A A 2 # value 1 2 2 3 2 matrix B 2 symbol B B 3 # value 1 3 2 2 kind mul latex AB shape # value 1 2 2 2 -
description textext/linalg formula-doc — declare, infix, run-implies-correctext/linalg formula-doc — declare, infix, run-implies-correct
-
env matrix_env
A Map(8) B Map(8) _type matrix_env key value A key value _type matrix ascii A cols 3 kind symbol latex A name A rows 2 shape # value 1 2 2 3 B key value _type matrix ascii B cols 2 kind symbol latex B name B rows 3 shape # value 1 3 2 2 _type matrix_env -
markup textocclusionocclusion
-
shapes list · 2
# name rows cols 1 A 2 3 2 B 3 2 # name rows cols 1 A 2 3 2 B 3 2 -
t textB^T*A^TB^T*A^T
-
title textHow to write a linear-algebra formula documentHow to write a linear-algebra formula document
可执行知识 · 输入、返回与依据
这份文档怎样成为可调用的知识
2 个知识单元 · 16 个结构步骤。先读输入、返回与调用边界,再按需查看依赖和依据。
以下来自静态分析,不代表程序已经运行、测试通过或内容已获领域确认。实际运行见正文标注与“运行与结果”。
Formula documents with ext/linalg对象
回到正文 · 第 9 行
这是程序入口或对象声明。成员函数的输入输出在各自说明中列出。
调用边界
无已知宿主副作用。权限由实际运行入口授予;静态副作用信息不等于运行许可。
当前有哪些依据
- 语法与引用
- 检查通过;检查通过
- 契约检查
- 尚未检查
- 测试记录
- 没有可用记录
- 内容来源
- 尚无已核验证据
- 领域审阅
- 尚未进行领域审阅
技术详情:身份、摘要与原始状态
- 目标标识
mq://public/features%2F07-linalg/type/Formula%20documents%20with%20ext%2Flinalg- 制品摘要(未检查锁定状态)
sha256:2839b0a3cf2c13e0d83cff6a9cae1807187aff52086ff61672e5cb3ed857912e- 依赖标识
- 原始验证状态
parse: passed; resolve: passed; contract: unchecked; execution: not_run; tests: unknown; evidence: unverified; domain: unreviewed
main程序入口
回到正文 · 第 16 行
这是程序入口或对象声明。成员函数的输入输出在各自说明中列出。
源码中的返回契约
any · None; execute this page's documented steps in order and observe their output or stated effects
调用边界
输出文本、plugin.call、process.control。权限由实际运行入口授予;静态副作用信息不等于运行许可。
当前有哪些依据
- 语法与引用
- 检查通过;检查通过
- 契约检查
- 尚未检查
- 测试记录
- 没有可用记录
- 内容来源
- 尚无已核验证据
- 领域审阅
- 尚未进行领域审阅
查看本单元的结构步骤
这是源码结构,不是实际执行时序;正文引用不会因阅读而执行。
- 调用Compute env
- 正文引用A
- 正文引用B
- 正文引用Compute t
- 正文引用Display this step's result
- 正文引用Display this step's result
- 正文引用Display this step's result
- 正文引用Display this step's result
- 观察A
- 观察B
- 调用Compute t
- 调用Display this step's result
- 调用Display this step's result
- 调用Display this step's result
- 调用Display this step's result
- 正文引用Compute env
技术详情:身份、摘要与原始状态
- 目标标识
mq://public/features%2F07-linalg/type/main- 制品摘要(未检查锁定状态)
sha256:053972935e888af98a7cb43979f09dd6e5142d8630caff8e79864171eae94d39- 依赖标识
- 原始验证状态
parse: passed; resolve: passed; contract: unchecked; execution: not_run; tests: unknown; evidence: unverified; domain: unreviewed
运行与结果
B^T*A^T
formula-doc-ok
see-examples-linalg-transpose
完整源码
--- markup: occlusion title: How to write a linear-algebra formula document description: ext/linalg formula-doc — declare, infix, run-implies-correct import: la: ext/linalg/linalg.mq.md --- # Formula documents with ext/linalg Not stdlib. Install: `marqdo ext add linalg` (or build `marqdo_plugin_linalg`). *Idea:* if the `.mq.md` runs and the asserted form matches, the identity holds under the library rules. Algebra reads like a lecture; `factorize` / `lstsq` / `draw` stay explicit calculation steps. # main | 返回 | 类型 | 说明 | |---|---|---| | result | any | None; execute this page's documented steps in order and observe their output or stated effects | Declare symbols in a table, multiply, transpose — `T_ascii` is one-step display (auto-simplify). `shapes` = | @ | name | rows | cols | |---|------|------|------| | 1 | A | 2 | 3 | | 2 | B | 3 | 2 | We first **env = [Compute env](la.declare(table=`shapes`))** for the next step. We first **A = [A](access(`env`, "A"))** for the next step. We first **B = [B](access(`env`, "B"))** for the next step. We first **P = (`A` * `B`)** for the next step. We first **t = [Compute t](> `P`.T_ascii)** for the next step. We now **[Display this step's result](> print text=`t`)**. 1. `t` == "B^T*A^T" We now **[Display this step's result](> print text="formula-doc-ok")**. 2. * We now **[Display this step's result](> print text="formula-doc-fail")**. We now **[Display this step's result](> print text="see-examples-linalg-transpose")**.