chore: dsimproc for UIntX.ofNatLT (#7068)

This PR is a follow-up to #7057 and adds a builtin dsimproc for
`UIntX.ofNatLT` which it turns out we need in stage0 before we can get
the deprecation of `UIntX.ofNatCore` in favor of `UIntX.ofNatLT` off the
ground.
This commit is contained in:
Markus Himmel 2025-02-13 15:51:42 +01:00 committed by GitHub
parent cc76c46244
commit 40c6dfa3ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View file

@ -12,6 +12,7 @@ open Lean Meta Simp
macro "declare_uint_simprocs" typeName:ident : command =>
let ofNat := typeName.getId ++ `ofNat
let ofNatCore := mkIdent (typeName.getId ++ `ofNatCore)
let ofNatLT := mkIdent (typeName.getId ++ `ofNatLT)
let toNat := mkIdent (typeName.getId ++ `toNat)
let fromExpr := mkIdent `fromExpr
`(
@ -60,6 +61,12 @@ builtin_dsimproc [simp, seval] $(mkIdent `reduceOfNatCore):ident ($ofNatCore _ _
let value := $(mkIdent ofNat) value
return .done <| toExpr value
builtin_dsimproc [simp, seval] $(mkIdent `reduceOfNatLT):ident ($ofNatLT _ _) := fun e => do
unless e.isAppOfArity $(quote ofNatLT.getId) 2 do return .continue
let some value ← Nat.fromExpr? e.appFn!.appArg! | return .continue
let value := $(mkIdent ofNat) value
return .done <| toExpr value
builtin_dsimproc [simp, seval] $(mkIdent `reduceOfNat):ident ($(mkIdent ofNat) _) := fun e => do
unless e.isAppOfArity $(quote ofNat) 1 do return .continue
let some value ← Nat.fromExpr? e.appArg! | return .continue

View file

@ -10,6 +10,11 @@ example (h : x = 8) : x = UInt32.ofNatCore 8 (by decide) := by
trace_state
assumption
example (h : x = 8) : x = UInt32.ofNatLT 8 (by decide) := by
simp
trace_state
assumption
example : foo x = 8 + 2 := by
simp
trace_state

View file

@ -4,6 +4,9 @@ h : x = 8
x : UInt32
h : x = 8
⊢ x = 8
x : UInt32
h : x = 8
⊢ x = 8
x : Nat
⊢ foo x = 10
x : Nat