lean4-htt/src/Lean/Meta/Inductive.lean
2024-02-18 14:55:17 -08:00

24 lines
778 B
Text

/-
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import Lean.Meta.Basic
/-! # Helper methods for inductive datatypes -/
namespace Lean.Meta
/-- Return true if the types of the given constructors are compatible. -/
def compatibleCtors (ctorName₁ ctorName₂ : Name) : MetaM Bool := do
let ctorInfo₁ ← getConstInfoCtor ctorName₁
let ctorInfo₂ ← getConstInfoCtor ctorName₂
if ctorInfo₁.induct != ctorInfo₂.induct then
return false
else
let (_, _, ctorType₁) ← forallMetaTelescope ctorInfo₁.type
let (_, _, ctorType₂) ← forallMetaTelescope ctorInfo₂.type
isDefEq ctorType₁ ctorType₂
end Lean.Meta