Skip to content

Instantly share code, notes, and snippets.

@forked-from-1kasper
Last active December 22, 2022 13:49
Show Gist options
  • Save forked-from-1kasper/732eb6d6ab0c62f3d9675698db4575b8 to your computer and use it in GitHub Desktop.
Save forked-from-1kasper/732eb6d6ab0c62f3d9675698db4575b8 to your computer and use it in GitHub Desktop.
import Lean.Elab.Command
open Lean
elab "#defeq " σ₁:term " =?= " σ₂:term : command =>
Elab.Command.liftTermElabM (do
let τ₁ ← Elab.Term.elabTerm σ₁ none
let τ₂ ← Elab.Term.elabTerm σ₂ none
unless (← Meta.isDefEq τ₁ τ₂) do throwError s!"{τ₁} ≠ {τ₂}")
#defeq [1, 2, 3, 4].reverse =?= [4, 3, 2, 1]
macro "#defeqEval " σ₁:term " =?= " σ₂:term : command =>
`(#eval (unless ($σ₁ == $σ₂)
do throwError s!"{$σ₁} ≠ {$σ₂}" : Elab.Command.CommandElabM Unit))
#defeqEval [1, 2, 3, 4].reverse =?= [4, 3, 2, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment