lean4-htt/tests/elab/cbv_nullary.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

46 lines
1.2 KiB
Text

set_option cbv.warning false
/-! Tests for `cbv` evaluation of nullary (non-function) constants.
Nullary definitions like `def myNat : Nat := 42` should be unfolded by `cbv`
so that ground term evaluation (e.g. `evalEq`, `evalLT`) can recognize their
values as literals.
-/
def myNat : Nat := 42
-- Arithmetic: argument goes through pattern matching in Nat.add
example : myNat + 1 = 43 := by cbv
-- Direct equality
example : myNat = 42 := by cbv
-- Prop-level equality and comparisons
example : (myNat = myNat) = True := by cbv
example : (myNat = 42) = True := by cbv
example : (myNat < 100) = True := by cbv
example : (myNat ≤ 42) = True := by cbv
-- Bool-level equality
example : (myNat == 42) = true := by cbv
-- Condition involving a nullary constant
example : (if myNat = 42 then 1 else 0) = 1 := by cbv
-- String nullary constant
def myStr : String := "hello"
example : myStr.length = 5 := by cbv
example : (myStr = "hello") = True := by cbv
-- Custom inductive type
inductive Color where | red | green | blue
def myColor : Color := .red
def colorToNat : Color → Nat
| .red => 1
| .green => 2
| .blue => 3
example : colorToNat myColor = 1 := by cbv