chore: new module system adjustments for the Mathlib port (#11093)

This commit is contained in:
Sebastian Ullrich 2025-11-05 23:17:53 +01:00 committed by GitHub
parent 28a3cf9a6c
commit ea2b745e57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 15 deletions

View file

@ -704,7 +704,7 @@ def mkSimpleThunk (type : Expr) : Expr :=
/--
`.lit l` is now the preferred form.
-/
def mkLit (l : Literal) : Expr :=
@[match_pattern, expose] def mkLit (l : Literal) : Expr :=
.lit l
/--
@ -712,7 +712,7 @@ Return the "raw" natural number `.lit (.natVal n)`.
This is not the default representation used by the Lean frontend.
See `mkNatLit`.
-/
def mkRawNatLit (n : Nat) : Expr :=
@[match_pattern, expose] def mkRawNatLit (n : Nat) : Expr :=
mkLit (.natVal n)
/--
@ -720,12 +720,12 @@ Return a natural number literal used in the frontend. It is a `OfNat.ofNat` appl
Recall that all theorems and definitions containing numeric literals are encoded using
`OfNat.ofNat` applications in the frontend.
-/
def mkNatLit (n : Nat) : Expr :=
@[match_pattern, expose] def mkNatLit (n : Nat) : Expr :=
let r := mkRawNatLit n
mkApp3 (mkConst ``OfNat.ofNat [levelZero]) (mkConst ``Nat) r (mkApp (mkConst ``instOfNatNat) r)
/-- Return the string literal `.lit (.strVal s)` -/
def mkStrLit (s : String) : Expr :=
@[match_pattern, expose] def mkStrLit (s : String) : Expr :=
mkLit (.strVal s)
@[export lean_expr_mk_bvar] def mkBVarEx : Nat → Expr := mkBVar

View file

@ -155,7 +155,6 @@ namespace Cases
structure Context where
inductiveVal : InductiveVal
casesOnVal : DefinitionVal
nminors : Nat := inductiveVal.ctors.length
majorDecl : LocalDecl
majorTypeFn : Expr
@ -171,16 +170,13 @@ private def mkCasesContext? (majorFVarId : FVarId) : MetaM (Option Context) := d
let majorType ← whnf majorDecl.type
majorType.withApp fun f args => matchConstInduct f (fun _ => pure none) fun ival _ =>
if args.size != ival.numIndices + ival.numParams then pure none
else match env.find? (Name.mkStr ival.name "casesOn") with
| ConstantInfo.defnInfo cval =>
return some {
inductiveVal := ival,
casesOnVal := cval,
majorDecl := majorDecl,
majorTypeFn := f,
majorTypeArgs := args
}
| _ => pure none
else if !env.contains (Name.mkStr ival.name "casesOn") then pure none
else return some {
inductiveVal := ival,
majorDecl := majorDecl,
majorTypeFn := f,
majorTypeArgs := args
}
/--
We say the major premise has independent indices IF