leanprover / lean4

Lean 4 programming language and theorem prover
https://lean-lang.org
Apache License 2.0
4.75k stars 428 forks source link

feat: Lean.RArray #6070

Closed nomeata closed 2 weeks ago

nomeata commented 2 weeks ago

This PR adds the Lean.RArray data structure.

This data structure is equivalent to Fin n → α or Array α, but optimized for a fast kernel-reduction get operation.

It is not suitable as a general-purpose data structure. The primary intended use case is the “denote” function of a typical proof by reflection proof, where only the get operation is necessary, and where using List.get unnecessarily slows down proofs with more than a hand-full of atomic expressions.

There is no well-formedness invariant attached to this data structure, to keep it concise; it's semantics is given through RArray.get. In that way one can also view an RArray as a decision tree implementing Nat → α.

In #6068 this data structure is used in simp_arith.

leanprover-community-bot commented 2 weeks ago

Mathlib CI status (docs):