Support JavaScript semantics for numbers (behind an option)

Đang mở
#205 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@ranita872 đang làm issue này rồi.

Từ ngày 27/8/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
Công nghệ
typescript
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Start by investigating how LemmaScript translates JavaScript numbers into Dafny, using the listed Dafny type-system and newtype options and the uint64 wrapping example as a test case. The configuration form is still undecided, so first establish the design for optional semantics; done means JavaScript number behavior is modeled and verified without changing defaults for existing users.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The goal would be to support faithful semantics for JavaScript numbers. For backward compatibility, this support would be optional, with the exact form of the configuration TBD.

This support would require some investigation of the best way to go about it in Dafny.

Below some preliminary investigations.

Some useful Dafny options: --type-system-refresh --general-traits=datatype --general-newtypes

In dfyconfig.toml:

includes = ["**/*.dfy"]

[options]
type-system-refresh = true
general-traits = "datatype"
general-newtypes = true

Possible encoding:

// Run with the new type system + general newtypes:
//   dafny verify --type-system-refresh --general-traits=datatype --general-newtypes n_overflow.dfy
// (or just `dafny verify dfyconfig.toml`, which sets those flags for the project)
//
// A newtype over bv64 gives wrapping (mod 2^64) arithmetic, like a C
// `uint64_t`. Without the flags above this declaration is rejected
// ("newtypes must be based on some numeric type"). With overflow,
// factorial(n) wraps below n, so factorial_greater no longer holds and
// the postcondition fails to verify -- which is the overflow we wanted
// to surface. (With `nat`, it verifies: nat never overflows.)
module Wrapping {
  newtype uint64 = b: bv64 | true

  function factorial(n: uint64): uint64
    decreases n
  {
    if n == 0 then
      1
    else
      n * factorial(n - 1)
  }

  lemma factorial_greater(n: uint64)
    requires n >= 3
    ensures factorial(n) > n   // FAILS: factorial wraps mod 2^64 for large n
  {
  }
}
Ngôn ngữ chính
TypeScript
Star
113
Fork
13
Merge trung bình
16 giờ 22 phút
Pull request đã merge (30 ngày)
40

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của midspiral/LemmaScript

Tất cả issue của midspiral/LemmaScript

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.