Support JavaScript semantics for numbers (behind an option)

オープン
#205 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@ranita872 がすでに取り組んでいます。

2026年8月27日 から。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
  {
  }
}
主要言語
TypeScript
スター
113
フォーク
13
平均マージ
16時間 22分
マージ済み PR(30日)
40

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

midspiral/LemmaScript のほかの issue

midspiral/LemmaScript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。