diff options
author | Son HO | 2024-05-14 11:34:24 +0000 |
---|---|---|
committer | GitHub | 2024-05-14 11:34:24 +0000 |
commit | 44b31973eb5a8c27e5620081669488e3b5899638 (patch) | |
tree | 4a8aa96b32699a7e5ec98ccdd2aa14a40be7ffb7 /backends/lean | |
parent | f21cc739c3cc19b20ffd50b464dedb4f23d4512c (diff) | |
parent | b6a820cc3ed1d5d4d875cddf7982aaa84ff01d44 (diff) |
Merge pull request #164 from RaitoBezarius/ofnat_scalar
feat(backend/lean): Raw Lean literals can be parsed into scalars automatically
Diffstat (limited to 'backends/lean')
-rw-r--r-- | backends/lean/Base/Primitives/Scalar.lean | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/backends/lean/Base/Primitives/Scalar.lean b/backends/lean/Base/Primitives/Scalar.lean index 2bee8a2f..dccbcdf2 100644 --- a/backends/lean/Base/Primitives/Scalar.lean +++ b/backends/lean/Base/Primitives/Scalar.lean @@ -332,6 +332,11 @@ instance [Decide (Scalar.cMin ty ≤ v ∧ v ≤ Scalar.cMax ty)] : InBounds ty @[simp] abbrev Scalar.check_bounds (ty : ScalarTy) (x : Int) : Bool := (Scalar.cMin ty ≤ x || Scalar.min ty ≤ x) ∧ (x ≤ Scalar.cMax ty || x ≤ Scalar.max ty) +-- TODO(raitobezarius): the inbounds constraint is a bit ugly as we can pretty trivially +-- discharge the lhs on ≥ 0. +instance {ty: ScalarTy} [InBounds ty (Int.ofNat n)]: OfNat (Scalar ty) (n: ℕ) where + ofNat := Scalar.ofInt n + theorem Scalar.check_bounds_imp_in_bounds {ty : ScalarTy} {x : Int} (h: Scalar.check_bounds ty x) : Scalar.in_bounds ty x := by |