lean4-htt/tests/elab/633.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

37 lines
1.4 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

abbrev semantics (α:Type) := StateM (List Nat) α
inductive expression : Nat → Type
| const : (n : Nat) → expression n
def uext {w:Nat} (x: expression w) (o:Nat) : expression w := expression.const _
def eval {n : Nat} (v:expression n) : semantics (expression n) := pure (expression.const _)
def set_overflow {w : Nat} (e : expression w) : semantics Unit := pure ()
structure instruction :=
(mnemonic:String)
(patterns:List Nat)
def definst (mnem:String) (body: expression 8 -> semantics Unit) : instruction :=
{ mnemonic := mnem
, patterns := ((body (expression.const _)).run []).snd.reverse
}
def mul : instruction := Id.run <| do -- this is a "pure" do block (as in it is the Id monad)
definst "mul" $ fun (src : expression 8) =>
let action : semantics Unit := do -- this is not "pure" do block
let tmp <- eval $ uext src 16
set_overflow $ tmp
action
def mul' : instruction := Id.run <| do -- this is a "pure" do block (as in it is the Id monad)
definst "mul" $ fun (src : expression 8) =>
let rec action : semantics Unit := do -- this is not "pure" do block
let tmp <- eval $ uext src 16
set_overflow $ tmp
action
def mul'' : instruction := Id.run <| do -- this is a "pure" do block (as in it is the Id monad)
definst "mul" $ fun (src : expression 8) =>
let action : semantics (expression 8) :=
return (<- eval $ uext src 16)
pure ()