Proposal: lawful lenses for verified state access
Maintainer thường phản hồi trong vòng 1 ngày
@Digger-Rockwell đang làm issue này rồi.
Từ ngày 18/11/2026.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- tooling
Hướng nghiên cứu
Bắt đầu bằng cách đọc docs/upstream/CSLIB_LENS_PROPOSAL.md và ví dụ Optics.Examples.MachineState trong lean-optics, sau đó so sánh vị trí được đề xuất dưới Cslib/Foundations/Data/Lens/. Một đóng góp hoàn chỉnh sẽ cần sự thống nhất của maintainer về cách đặt tên và phạm vi composition, tiếp theo là lens API tối thiểu và một ví dụ MachineState độc lập với các luật được nêu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Verified computer-science developments often need structured state updates over records. When modeling interpreters, simulators, or incremental transformations, authors repeatedly write the same pattern: read a field from a state record, compute an updated value, and write it back while preserving unrelated fields. Without a shared abstraction, each project reimplements getters, setters, and the algebraic laws that make those updates composable and trustworthy.
Proposed minimal API
A small lawful lens core for verified state access (not category theory or profunctor optics):
structure Lens (S A : Type u) where
get : S → A
set : S → A → S
structure LawfulLens (S A : Type u) extends Lens S A where
get_set : ∀ s a, get (set s a) = a
set_get : ∀ s, set s (get s) = s
set_set : ∀ s a b, set (set s a) b = set s b
Plus:
over— update the focused component with a functioncompose— chain nested field access
Example: interpreter state
structure MachineState where
pc : Nat
memory : List Nat
halted : Bool
A lawful lens for pc, a step function that increments pc when not halted, and proofs that step preserves memory and halted.
This pattern is exercised in lean-optics (Optics.Examples.MachineState) as an extraction candidate; see also docs/upstream/CSLIB_LENS_PROPOSAL.md in that repo.
Why CSLib
CSLib is the right venue for executable state semantics and verified transformations without tactic automation. The API should be small enough to review in one sitting and strong enough to support verified record updates in algorithms, semantics, and systems formalizations.
Explicitly out of scope (for this first PR)
- Profunctor hierarchy and optic generalizations
- Prisms, traversals, and other optic variants
- Macros (
lens!, field-syntax sugar) optic_laws!and other tactic automation- Telemetry and benchmarks
Suggested placement
Cslib/Foundations/Data/Lens/ (or similar under Foundations), with one self-contained example module.
Mathlib
Not proposed for this slice. Mathlib optimizes for mathematical structure; the immediate need is a tiny, law-carrying API for executable state in CS developments.
Next step
Happy to open a draft PR with only the minimal API + MachineState example if maintainers agree with the framing. Feedback welcome on naming, placement, and whether composition laws should ship in v1.
- Ngôn ngữ chính
- Lean
- Star
- 847
- Fork
- 234
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 49
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của leanprover/cslib
-
`listFullBeta_cons_r` should rename to `listFullBeta_concat_r`Có thể đã có người làm @lengyijun đã nhận 134 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
leanprover/cslib#784 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
logic
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
leanprover/cslib#74 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dependency-incompatibility
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 45/100
leanprover/cslib#1271 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Generalize `RelationAlgebra`Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
leanprover/cslib#1262 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BetaAt.appR doesn't require LC N, weakening BetaAt.lc_r, not consistent with FullBetaCó thể đã có người làm @Digger-Rockwell đã nhận 5 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
leanprover/cslib#1243 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của leanprover/cslib
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
erkamyaman/rust-anything#364 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
erkamyaman/safe-anything#47 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: `mellea.plugins.builtin_debug.generation.log_generation_post_call` shows model as unknownĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
generative-computing/mellea#1864 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
documentation good first issue
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 66/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ubugeeei-prod/vize#13586 ·
Maintainer thường phản hồi trong vòng 1 ngày