@cella-lang/programlogic

中文文档
0.1.202611090959发布于 2026/11/09Apache-2.0零依赖近 30 天下载 9161

A language-generic program logic for Cella Lang: a language gives one step (next configuration, a final value, or a fault with its reason) and a separation algebra of resources; the package gives the weakest precondition Wp (explicitly step-indexed), soun

原始使用文档

@cella-lang/programlogic

A language-generic program logic for the Cella proof checker, as a compiled module pack. A language gives one step and a separation algebra of resources; the package gives the weakest precondition, its soundness, and the structural rules.

No dependencies besides cella-lang's standard modules.

Plugging in a language

  • programlogic.Step C V S W: the result of one step: advance c s (a new configuration and state), finish v s (a final value) or fault w (a fault with its reason; for C, undefined behavior with its node and clause).
  • programlogic.Language C V S W: { step : C -> S -> Step C V S W }.
  • programlogic.SeparationAlgebra S R: resources R with join a b c (a and b are disjoint and together make c), a unit with joinUnit, both directions of associativity (associateRight: from (a b) c to a (b c); associateLeft), and interpret s r (the state s holds the resource r).

The small-step machine of @cella-lang/machine (which the C family and Python run on) plugs in like this, with a statement and its frames as the configuration:

import machine.statement
import programlogic
open machine

def Cfg (S : Type) (R : Type) : Type := Statement S R String * List (Frame S R String)

def exitStep {S : Type} {R : Type} (e : Exit S R String) : programlogic.Step (Cfg S R) (Exit S R String) S String := match e with
  | stopped w => programlogic.fault w
  | normal s => programlogic.finish (normal s) s
  | breakOut s => programlogic.finish (breakOut s) s
  | continueLoop s => programlogic.finish (continueLoop s) s
  | returned v s => programlogic.finish (returned v s) s

def confStep {S : Type} {R : Type} (x : Configuration S R String) : programlogic.Step (Cfg S R) (Exit S R String) S String := match x with
  | running c k s => programlogic.advance (c, k) s
  | halted e => exitStep e

def lang (S : Type) (R : Type) : programlogic.Language (Cfg S R) (Exit S R String) S String :=
  { step := fun c s => confStep (Configuration.stepRun (fst c) (snd c) s) }

With the whole state owned exclusively as the resource, this proves while (x != 0) x = x - 1; (whileLoop with an update that stops on x = 0) safe for every x, and runs do { x = x - 1; } while (x != 0); from x = 0 to its fault.

What you get

  • programlogic.Wp L A c Q r: from resource r, running c never reaches a fault, and if it finishes with v, Q v r' holds for the remaining resource. It is WpWithin n for every n, explicitly step-indexed (Appel and McAllester 2001; Ahmed 2006): no guarded fixed point is needed, and a loop rule is proved by induction on the number of steps. The frame is part of the definition (as in Charguéraud's Separation Logic Foundations).
  • After a step, the resource is an Owned A frame s X: a record with the resource, the whole resource it makes with the frame, the proof they are joined, that the state held the whole, and that the resource satisfies X.
  • programlogic.safeOfWp: Wp L A c Q r -> A.interpret s r -> L.Safe c s, where L.Safe c s is: for every n, L.run n c s has not failed (partial correctness: termination is not required).
  • programlogic.wpConsequence (consequence), programlogic.wpFrame (frame: a disjoint resource is carried along unchanged, WithFrame), programlogic.wpWithinOfSucc (one more step implies one fewer).
  • Verdicts: a proved Wp is Accept; an input and a number of steps for which run reaches failed w is Reject (by computation, carrying w); otherwise Unknown.

版本与发布记录

@cella-lang/programlogic 共发布 53 个版本,首次发布于 2026/10/30;过去 12 个月发布了 53 个版本。

版本发布日期距今
0.1.202611090959latest2026/11/09今天
0.1.2026110909552026/11/09今天
0.1.2026110822142026/11/09今天
0.1.2026110809592026/11/081 天前
0.1.2026110805242026/11/081 天前
0.1.2026110804162026/11/081 天前

关于 @cella-lang/programlogic 的常见问题

@cella-lang/programlogic 是什么?

A language-generic program logic for Cella Lang: a language gives one step (next configuration, a final value, or a fault with its reason) and a separation algebra of resources; the package gives the weakest precondition Wp (explicitly step-indexed), soun

如何安装 @cella-lang/programlogic?

在项目目录运行 npm install @cella-lang/programlogic,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:cella-lang(0.1.202611090954)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cella-lang/programlogic 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cella-lang__programlogic 是否存在。

@cella-lang/programlogic 可以商用吗?

@cella-lang/programlogic 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cella-lang/programlogic 的下载量有多少?

根据 npm 官方下载统计,@cella-lang/programlogic 在 2026/10/10 – 2026/11/08 这 30 天内被下载 9,161 次,日均约 305 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cella-lang/programlogic 还在维护吗?

最新版本 0.1.202611090959 发布于 2026/11/09(今天);至今共发布 53 个版本,其中过去 12 个月发布了 53 个;首次发布于 2026/10/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。