lean4-htt/src/Lean/Meta/CheckTactic.lean
2025-07-25 12:02:51 +00:00

28 lines
851 B
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.

/-
Copyright (c) 2024 Lean FRO. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joe Hendrix
-/
module
prelude
public import Lean.Meta.Basic
public section
namespace Lean.Meta.CheckTactic
def mkCheckGoalType (val type : Expr) : MetaM Expr := do
let lvl ← mkFreshLevelMVar
pure <| mkApp2 (mkConst ``CheckGoalType [lvl]) type val
def matchCheckGoalType (stx : Syntax) (goalType : Expr) : MetaM (Expr × Expr × Level) := do
let u ← mkFreshLevelMVar
let type ← mkFreshExprMVar (some (.sort u))
let val ← mkFreshExprMVar (some type)
let extType := mkAppN (.const ``CheckGoalType [u]) #[type, val]
if !(← isDefEq goalType extType) then
throwErrorAt stx "Goal{indentExpr goalType}\nis expected to match {indentExpr extType}"
pure (val, type, u)
end Lean.Meta.CheckTactic