lean4-htt/tests/lean/run/436_lean3.lean
Kim Morrison 3a457e6ad6
chore: use #guard_msgs in run tests (#4175)
Many of our tests in `tests/lean/run/` produce output from `#eval` (or
`#check`) statements, that is then ignored.

This PR tries to capture all the useful output using `#guard_msgs`. I've
only done a cursory check that the output is still sane --- there is a
chance that some "unchecked" tests have already accumulated regressions
and this just cements them!

In the other direction, I did identify two rotten tests:
* a minor one in `setStructInstNotation.lean`, where a comment says `Set
Nat`, but `#check` actually prints `?_`. Weird?
* `CompilerProbe.lean` is generating empty output, apparently indicating
that something is broken, but I don't know the signficance of this file.

In any case, I'll ask about these elsewhere.

(This started by noticing that a recent `grind` test file had an
untested `trace_state`, and then got carried away.)
2024-05-16 00:38:31 +00:00

41 lines
957 B
Text

inductive bvar : Type
| mk (n : Nat)
def bvar_eq : bvar → bvar → Bool
| bvar.mk n1, bvar.mk n2 => n1=n2
inductive bExpr : Type
| BLit (b: Bool)
| BVar (v: bvar)
def benv := bvar → Bool
def bEval : bExpr → benv → Bool
| bExpr.BLit b, i => b
| bExpr.BVar v, i => i v
def init_benv : benv := λ v => false
def update_benv : benv → bvar → Bool → benv
| i, v, b => λ v2 => if (bvar_eq v v2) then b else (i v2)
inductive bCmd : Type
| bAssm (v : bvar) (e : bExpr)
| bSeq (c1 c2 : bCmd)
-- Unlike Lean 3, we can have nested match-expressions and still use structural recursion
def cEval : benv → bCmd → benv
| i0, c => match c with
| bCmd.bAssm v e => update_benv i0 v (bEval e i0)
| bCmd.bSeq c1 c2 =>
let i1 := cEval i0 c1
cEval i1 c2
def myFirstProg := bCmd.bAssm (bvar.mk 0) (bExpr.BLit false)
def newEnv :=
cEval init_benv myFirstProg
/-- info: false -/
#guard_msgs in
#eval newEnv (bvar.mk 0)