diff --git a/stage0/src/Lean/Elab/PreDefinition/Basic.lean b/stage0/src/Lean/Elab/PreDefinition/Basic.lean index 178cd64719..028c1d01ab 100644 --- a/stage0/src/Lean/Elab/PreDefinition/Basic.lean +++ b/stage0/src/Lean/Elab/PreDefinition/Basic.lean @@ -19,134 +19,134 @@ A (potentially recursive) definition. The elaborator converts it into Kernel definitions using many different strategies. -/ structure PreDefinition := -(kind : DefKind) -(lparams : List Name) -(modifiers : Modifiers) -(declName : Name) -(type : Expr) -(value : Expr) + (kind : DefKind) + (lparams : List Name) + (modifiers : Modifiers) + (declName : Name) + (type : Expr) + (value : Expr) instance : Inhabited PreDefinition := -⟨⟨DefKind.«def», [], {}, arbitrary _, arbitrary _, arbitrary _⟩⟩ + ⟨⟨DefKind.«def», [], {}, arbitrary _, arbitrary _, arbitrary _⟩⟩ def instantiateMVarsAtPreDecls (preDefs : Array PreDefinition) : TermElabM (Array PreDefinition) := -preDefs.mapM fun preDef => do - pure { preDef with type := (← instantiateMVars preDef.type), value := (← instantiateMVars preDef.value) } + preDefs.mapM fun preDef => do + pure { preDef with type := (← instantiateMVars preDef.type), value := (← instantiateMVars preDef.value) } private def levelMVarToParamExpr (e : Expr) : StateRefT Nat TermElabM Expr := do -let nextIdx ← get; -let (e, nextIdx) ← levelMVarToParam e nextIdx; -set nextIdx; -pure e + let nextIdx ← get + let (e, nextIdx) ← levelMVarToParam e nextIdx; + set nextIdx; + pure e private def levelMVarToParamPreDeclsAux (preDefs : Array PreDefinition) : StateRefT Nat TermElabM (Array PreDefinition) := -preDefs.mapM fun preDef => do - pure { preDef with type := (← levelMVarToParamExpr preDef.type), value := (← levelMVarToParamExpr preDef.value) } + preDefs.mapM fun preDef => do + pure { preDef with type := (← levelMVarToParamExpr preDef.type), value := (← levelMVarToParamExpr preDef.value) } def levelMVarToParamPreDecls (preDefs : Array PreDefinition) : TermElabM (Array PreDefinition) := -(levelMVarToParamPreDeclsAux preDefs).run' 1 + (levelMVarToParamPreDeclsAux preDefs).run' 1 private def getLevelParamsPreDecls (preDefs : Array PreDefinition) (scopeLevelNames allUserLevelNames : List Name) : TermElabM (List Name) := do -let s : CollectLevelParams.State := {} -for preDef in preDefs do - s := collectLevelParams s preDef.type - s := collectLevelParams s preDef.value -match sortDeclLevelParams scopeLevelNames allUserLevelNames s.params with -| Except.error msg => throwError msg -| Except.ok levelParams => pure levelParams + let s : CollectLevelParams.State := {} + for preDef in preDefs do + s := collectLevelParams s preDef.type + s := collectLevelParams s preDef.value + match sortDeclLevelParams scopeLevelNames allUserLevelNames s.params with + | Except.error msg => throwError msg + | Except.ok levelParams => pure levelParams private def shareCommon (preDefs : Array PreDefinition) : Array PreDefinition := -let result : Std.ShareCommonM (Array PreDefinition) := - preDefs.mapM fun preDef => do - pure { preDef with type := (← Std.withShareCommon preDef.type), value := (← Std.withShareCommon preDef.value) } -result.run + let result : Std.ShareCommonM (Array PreDefinition) := + preDefs.mapM fun preDef => do + pure { preDef with type := (← Std.withShareCommon preDef.type), value := (← Std.withShareCommon preDef.value) } + result.run def fixLevelParams (preDefs : Array PreDefinition) (scopeLevelNames allUserLevelNames : List Name) : TermElabM (Array PreDefinition) := do -let preDefs := shareCommon preDefs -let lparams ← getLevelParamsPreDecls preDefs scopeLevelNames allUserLevelNames -let us := lparams.map mkLevelParam -let fixExpr (e : Expr) : Expr := - e.replace fun c => match c with - | Expr.const declName _ _ => if preDefs.any fun preDef => preDef.declName == declName then some $ Lean.mkConst declName us else none - | _ => none -pure $ preDefs.map fun preDef => - { preDef with - type := fixExpr preDef.type, - value := fixExpr preDef.value, - lparams := lparams } + let preDefs := shareCommon preDefs + let lparams ← getLevelParamsPreDecls preDefs scopeLevelNames allUserLevelNames + let us := lparams.map mkLevelParam + let fixExpr (e : Expr) : Expr := + e.replace fun c => match c with + | Expr.const declName _ _ => if preDefs.any fun preDef => preDef.declName == declName then some $ Lean.mkConst declName us else none + | _ => none + pure $ preDefs.map fun preDef => + { preDef with + type := fixExpr preDef.type, + value := fixExpr preDef.value, + lparams := lparams } def applyAttributesOf (preDefs : Array PreDefinition) (applicationTime : AttributeApplicationTime) : TermElabM Unit := do -for preDef in preDefs do - applyAttributesAt preDef.declName preDef.modifiers.attrs applicationTime + for preDef in preDefs do + applyAttributesAt preDef.declName preDef.modifiers.attrs applicationTime def abstractNestedProofs (preDef : PreDefinition) : MetaM PreDefinition := -if preDef.kind.isTheorem || preDef.kind.isExample then - pure preDef -else do - let value ← Meta.abstractNestedProofs preDef.declName preDef.value - pure { preDef with value := value } + if preDef.kind.isTheorem || preDef.kind.isExample then + pure preDef + else do + let value ← Meta.abstractNestedProofs preDef.declName preDef.value + pure { preDef with value := value } /- Auxiliary method for (temporarily) adding pre definition as an axiom -/ def addAsAxiom (preDef : PreDefinition) : MetaM Unit := do -addDecl $ Declaration.axiomDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, isUnsafe := preDef.modifiers.isUnsafe } + addDecl $ Declaration.axiomDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, isUnsafe := preDef.modifiers.isUnsafe } private def addNonRecAux (preDef : PreDefinition) (compile : Bool) : TermElabM Unit := do -let preDef ← abstractNestedProofs preDef -let env ← getEnv -let decl := - match preDef.kind with - | DefKind.«example» => unreachable! - | DefKind.«theorem» => - Declaration.thmDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, value := preDef.value } - | DefKind.«opaque» => - Declaration.opaqueDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, value := preDef.value, + let preDef ← abstractNestedProofs preDef + let env ← getEnv + let decl := + match preDef.kind with + | DefKind.«example» => unreachable! + | DefKind.«theorem» => + Declaration.thmDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, value := preDef.value } + | DefKind.«opaque» => + Declaration.opaqueDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, value := preDef.value, + isUnsafe := preDef.modifiers.isUnsafe } + | DefKind.«abbrev» => + Declaration.defnDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, value := preDef.value, + hints := ReducibilityHints.«abbrev», isUnsafe := preDef.modifiers.isUnsafe } + | DefKind.«def» => + Declaration.defnDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, value := preDef.value, + hints := ReducibilityHints.regular (getMaxHeight env preDef.value + 1), isUnsafe := preDef.modifiers.isUnsafe } - | DefKind.«abbrev» => - Declaration.defnDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, value := preDef.value, - hints := ReducibilityHints.«abbrev», isUnsafe := preDef.modifiers.isUnsafe } - | DefKind.«def» => - Declaration.defnDecl { name := preDef.declName, lparams := preDef.lparams, type := preDef.type, value := preDef.value, - hints := ReducibilityHints.regular (getMaxHeight env preDef.value + 1), - isUnsafe := preDef.modifiers.isUnsafe } -addDecl decl -applyAttributesOf #[preDef] AttributeApplicationTime.afterTypeChecking -when (compile && !preDef.kind.isTheorem) $ - compileDecl decl -applyAttributesOf #[preDef] AttributeApplicationTime.afterCompilation -pure () + addDecl decl + applyAttributesOf #[preDef] AttributeApplicationTime.afterTypeChecking + if compile && !preDef.kind.isTheorem then + compileDecl decl + applyAttributesOf #[preDef] AttributeApplicationTime.afterCompilation + pure () def addAndCompileNonRec (preDef : PreDefinition) : TermElabM Unit := do -addNonRecAux preDef true + addNonRecAux preDef true def addNonRec (preDef : PreDefinition) : TermElabM Unit := do -addNonRecAux preDef false + addNonRecAux preDef false def addAndCompileUnsafe (preDefs : Array PreDefinition) : TermElabM Unit := do -let decl := Declaration.mutualDefnDecl $ preDefs.toList.map fun preDef => { - name := preDef.declName, - lparams := preDef.lparams, - type := preDef.type, - value := preDef.value, - isUnsafe := true, - hints := ReducibilityHints.opaque - } -addDecl decl -applyAttributesOf preDefs AttributeApplicationTime.afterTypeChecking -compileDecl decl -applyAttributesOf preDefs AttributeApplicationTime.afterCompilation -pure () + let decl := Declaration.mutualDefnDecl $ preDefs.toList.map fun preDef => { + name := preDef.declName, + lparams := preDef.lparams, + type := preDef.type, + value := preDef.value, + isUnsafe := true, + hints := ReducibilityHints.opaque + } + addDecl decl + applyAttributesOf preDefs AttributeApplicationTime.afterTypeChecking + compileDecl decl + applyAttributesOf preDefs AttributeApplicationTime.afterCompilation + pure () def addAndCompileUnsafeRec (preDefs : Array PreDefinition) : TermElabM Unit := do -addAndCompileUnsafe $ preDefs.map fun preDef => - { preDef with - declName := Compiler.mkUnsafeRecName preDef.declName, - value := preDef.value.replace fun e => match e with - | Expr.const declName us _ => - if preDefs.any fun preDef => preDef.declName == declName then - some $ mkConst (Compiler.mkUnsafeRecName declName) us - else - none - | _ => none, - modifiers := {} } + addAndCompileUnsafe $ preDefs.map fun preDef => + { preDef with + declName := Compiler.mkUnsafeRecName preDef.declName, + value := preDef.value.replace fun e => match e with + | Expr.const declName us _ => + if preDefs.any fun preDef => preDef.declName == declName then + some $ mkConst (Compiler.mkUnsafeRecName declName) us + else + none + | _ => none, + modifiers := {} } end Lean.Elab diff --git a/stage0/src/Lean/Elab/PreDefinition/Main.lean b/stage0/src/Lean/Elab/PreDefinition/Main.lean index 1bc146ef29..88091ffaaa 100644 --- a/stage0/src/Lean/Elab/PreDefinition/Main.lean +++ b/stage0/src/Lean/Elab/PreDefinition/Main.lean @@ -12,69 +12,70 @@ open Meta open Term private def addAndCompilePartial (preDefs : Array PreDefinition) : TermElabM Unit := do -for preDef in preDefs do - trace[Elab.definition]! "processing {preDef.declName}" - forallTelescope preDef.type fun xs type => do - let inh ← liftM $ mkInhabitantFor preDef.declName xs type - trace[Elab.definition]! "inhabitant for {preDef.declName}" - addNonRec { preDef with - kind := DefKind.«opaque», - value := inh } -addAndCompileUnsafeRec preDefs + for preDef in preDefs do + trace[Elab.definition]! "processing {preDef.declName}" + forallTelescope preDef.type fun xs type => do + let inh ← liftM $ mkInhabitantFor preDef.declName xs type + trace[Elab.definition]! "inhabitant for {preDef.declName}" + addNonRec { preDef with + kind := DefKind.«opaque», + value := inh + } + addAndCompileUnsafeRec preDefs private def isNonRecursive (preDef : PreDefinition) : Bool := -Option.isNone $ preDef.value.find? fun - | Expr.const declName _ _ => preDef.declName == declName - | _ => false + Option.isNone $ preDef.value.find? fun + | Expr.const declName _ _ => preDef.declName == declName + | _ => false private def partitionPreDefs (preDefs : Array PreDefinition) : Array (Array PreDefinition) := -let getPreDef := fun declName => (preDefs.find? fun preDef => preDef.declName == declName).get! -let vertices := preDefs.toList.map (·.declName) -let successorsOf := fun declName => (getPreDef declName).value.foldConsts [] fun declName successors => - if preDefs.any fun preDef => preDef.declName == declName then - declName :: successors - else - successors -let sccs := SCC.scc vertices successorsOf -sccs.toArray.map fun scc => scc.toArray.map getPreDef + let getPreDef := fun declName => (preDefs.find? fun preDef => preDef.declName == declName).get! + let vertices := preDefs.toList.map (·.declName) + let successorsOf := fun declName => (getPreDef declName).value.foldConsts [] fun declName successors => + if preDefs.any fun preDef => preDef.declName == declName then + declName :: successors + else + successors + let sccs := SCC.scc vertices successorsOf + sccs.toArray.map fun scc => scc.toArray.map getPreDef private def collectMVarsAtPreDef (preDef : PreDefinition) : StateRefT CollectMVars.State MetaM Unit := do -collectMVars preDef.value -collectMVars preDef.type + collectMVars preDef.value + collectMVars preDef.type private def getMVarsAtPreDef (preDef : PreDefinition) : MetaM (Array MVarId) := do -let (_, s) ← (collectMVarsAtPreDef preDef).run {} -pure s.result + let (_, s) ← (collectMVarsAtPreDef preDef).run {} + pure s.result private def ensureNoUnassignedMVarsAtPreDef (preDef : PreDefinition) : TermElabM Unit := do -let pendingMVarIds ← liftMetaM $ getMVarsAtPreDef preDef -if ← logUnassignedUsingErrorInfos pendingMVarIds then - throwAbort + let pendingMVarIds ← liftMetaM $ getMVarsAtPreDef preDef + if ← logUnassignedUsingErrorInfos pendingMVarIds then + throwAbort def addPreDefinitions (preDefs : Array PreDefinition) : TermElabM Unit := do -for preDef in preDefs do - trace[Elab.definition.body]! "{preDef.declName} : {preDef.type} :=\n{preDef.value}" -for preDef in preDefs do - ensureNoUnassignedMVarsAtPreDef preDef -for preDefs in partitionPreDefs preDefs do - trace[Elab.definition.scc]! "{preDefs.map (·.declName)}" - if preDefs.size == 1 && isNonRecursive preDefs[0] then - let preDef := preDefs[0] - if preDef.modifiers.isNoncomputable then - addNonRec preDef + for preDef in preDefs do + trace[Elab.definition.body]! "{preDef.declName} : {preDef.type} :=\n{preDef.value}" + for preDef in preDefs do + ensureNoUnassignedMVarsAtPreDef preDef + for preDefs in partitionPreDefs preDefs do + trace[Elab.definition.scc]! "{preDefs.map (·.declName)}" + if preDefs.size == 1 && isNonRecursive preDefs[0] then + let preDef := preDefs[0] + if preDef.modifiers.isNoncomputable then + addNonRec preDef + else + addAndCompileNonRec preDef + else if preDefs.any (·.modifiers.isUnsafe) then + addAndCompileUnsafe preDefs + else if preDefs.any (·.modifiers.isPartial) then + addAndCompilePartial preDefs else - addAndCompileNonRec preDef - else if preDefs.any (·.modifiers.isUnsafe) then - addAndCompileUnsafe preDefs - else if preDefs.any (·.modifiers.isPartial) then - addAndCompilePartial preDefs - else - mapError - (orelseMergeErrors - (structuralRecursion preDefs) - (WFRecursion preDefs)) - (fun msg => - let preDefMsgs := preDefs.toList.map (MessageData.ofExpr $ mkConst ·.declName) - msg!"fail to show termination for{indentD (MessageData.joinSep preDefMsgs Format.line)}\nwith errors\n{msg}") + mapError + (orelseMergeErrors + (structuralRecursion preDefs) + (WFRecursion preDefs)) + (fun msg => + let preDefMsgs := preDefs.toList.map (MessageData.ofExpr $ mkConst ·.declName) + msg!"fail to show termination for{indentD (MessageData.joinSep preDefMsgs Format.line)}\nwith errors\n{msg}") end Lean.Elab diff --git a/stage0/src/Lean/Elab/PreDefinition/MkInhabitant.lean b/stage0/src/Lean/Elab/PreDefinition/MkInhabitant.lean index efcfb5c346..67d0aae745 100644 --- a/stage0/src/Lean/Elab/PreDefinition/MkInhabitant.lean +++ b/stage0/src/Lean/Elab/PreDefinition/MkInhabitant.lean @@ -9,36 +9,36 @@ namespace Lean.Elab open Meta private def mkInhabitant? (type : Expr) : MetaM (Option Expr) := do -try - pure $ some (← mkAppM `arbitrary #[type]) -catch _ => - pure none + try + pure $ some (← mkAppM `arbitrary #[type]) + catch _ => + pure none private def findAssumption? (xs : Array Expr) (type : Expr) : MetaM (Option Expr) := do -xs.findM? fun x => do isDefEq (← inferType x) type + xs.findM? fun x => do isDefEq (← inferType x) type private def mkFnInhabitant? (xs : Array Expr) (type : Expr) : MetaM (Option Expr) := -let rec loop - | 0, type => mkInhabitant? type - | i+1, type => do - let x := xs[i] - let type ← mkForallFVars #[x] type; - match ← mkInhabitant? type with - | none => loop i type - | some val => pure $ some (← mkLambdaFVars xs[0:i] val) -loop xs.size type + let rec loop + | 0, type => mkInhabitant? type + | i+1, type => do + let x := xs[i] + let type ← mkForallFVars #[x] type; + match ← mkInhabitant? type with + | none => loop i type + | some val => pure $ some (← mkLambdaFVars xs[0:i] val) + loop xs.size type /- TODO: add a global IO.Ref to let users customize/extend this procedure -/ def mkInhabitantFor (declName : Name) (xs : Array Expr) (type : Expr) : MetaM Expr := do -match ← mkInhabitant? type with -| some val => mkLambdaFVars xs val -| none => -match ← findAssumption? xs type with -| some x => mkLambdaFVars xs x -| none => -match ← mkFnInhabitant? xs type with -| some val => pure val -| none => throwError! "failed to compile partial definition '{declName}', failed to show that type is inhabited" + match ← mkInhabitant? type with + | some val => mkLambdaFVars xs val + | none => + match ← findAssumption? xs type with + | some x => mkLambdaFVars xs x + | none => + match ← mkFnInhabitant? xs type with + | some val => pure val + | none => throwError! "failed to compile partial definition '{declName}', failed to show that type is inhabited" end Lean.Elab diff --git a/stage0/src/Lean/Elab/PreDefinition/Structural.lean b/stage0/src/Lean/Elab/PreDefinition/Structural.lean index f1d98f77b7..526fa47052 100644 --- a/stage0/src/Lean/Elab/PreDefinition/Structural.lean +++ b/stage0/src/Lean/Elab/PreDefinition/Structural.lean @@ -13,173 +13,173 @@ namespace Lean.Elab open Meta private def getFixedPrefix (declName : Name) (xs : Array Expr) (value : Expr) : Nat := -let visitor {ω} : StateRefT Nat (ST ω) Unit := - value.forEach' fun e => - if e.isAppOf declName then do - let args := e.getAppArgs - modify fun numFixed => if args.size < numFixed then args.size else numFixed - -- we continue searching if the e's arguments are not a prefix of `xs` - pure !args.isPrefixOf xs - else - pure true -runST fun _ => do let (_, numFixed) ← visitor.run xs.size; pure numFixed + let visitor {ω} : StateRefT Nat (ST ω) Unit := + value.forEach' fun e => + if e.isAppOf declName then do + let args := e.getAppArgs + modify fun numFixed => if args.size < numFixed then args.size else numFixed + -- we continue searching if the e's arguments are not a prefix of `xs` + pure !args.isPrefixOf xs + else + pure true + runST fun _ => do let (_, numFixed) ← visitor.run xs.size; pure numFixed structure RecArgInfo := -/- `fixedParams ++ ys` are the arguments of the function we are trying to justify termination using structural recursion. -/ -(fixedParams : Array Expr) -(ys : Array Expr) -- recursion arguments -(pos : Nat) -- position in `ys` of the argument we are recursing on -(indicesPos : Array Nat) -- position in `ys` of the inductive datatype indices we are recursing on -(indName : Name) -- inductive datatype name of the argument we are recursing on -(indLevels : List Level) -- inductice datatype universe levels of the argument we are recursing on -(indParams : Array Expr) -- inductive datatype parameters of the argument we are recursing on -(indIndices : Array Expr) -- inductive datatype indices of the argument we are recursing on, it is equal to `indicesPos.map fun i => ys.get! i` -(reflexive : Bool) -- true if we are recursing over a reflexive inductive datatype + /- `fixedParams ++ ys` are the arguments of the function we are trying to justify termination using structural recursion. -/ + (fixedParams : Array Expr) + (ys : Array Expr) -- recursion arguments + (pos : Nat) -- position in `ys` of the argument we are recursing on + (indicesPos : Array Nat) -- position in `ys` of the inductive datatype indices we are recursing on + (indName : Name) -- inductive datatype name of the argument we are recursing on + (indLevels : List Level) -- inductice datatype universe levels of the argument we are recursing on + (indParams : Array Expr) -- inductive datatype parameters of the argument we are recursing on + (indIndices : Array Expr) -- inductive datatype indices of the argument we are recursing on, it is equal to `indicesPos.map fun i => ys.get! i` + (reflexive : Bool) -- true if we are recursing over a reflexive inductive datatype private def getIndexMinPos (xs : Array Expr) (indices : Array Expr) : Nat := do -let minPos := xs.size -for index in indices do - match xs.indexOf? index with - | some pos => if pos.val < minPos then minPos := pos.val - | _ => pure () -return minPos + let minPos := xs.size + for index in indices do + match xs.indexOf? index with + | some pos => if pos.val < minPos then minPos := pos.val + | _ => pure () + return minPos -- Indices can only depend on other indices private def hasBadIndexDep? (ys : Array Expr) (indices : Array Expr) : MetaM (Option (Expr × Expr)) := do -for index in indices do - let indexType ← inferType index - for y in ys do - if !indices.contains y && (← dependsOn indexType y.fvarId!) then - return some (index, y) -return none + for index in indices do + let indexType ← inferType index + for y in ys do + if !indices.contains y && (← dependsOn indexType y.fvarId!) then + return some (index, y) + return none -- Inductive datatype parameters cannot depend on ys private def hasBadParamDep? (ys : Array Expr) (indParams : Array Expr) : MetaM (Option (Expr × Expr)) := do -for p in indParams do - let pType ← inferType p - for y in ys do - if ← dependsOn pType y.fvarId! then - return some (p, y) -return none + for p in indParams do + let pType ← inferType p + for y in ys do + if ← dependsOn pType y.fvarId! then + return some (p, y) + return none private def throwStructuralFailed {α} : MetaM α := -throwError "structural recursion cannot be used" + throwError "structural recursion cannot be used" private partial def findRecArg {α} (numFixed : Nat) (xs : Array Expr) (k : RecArgInfo → MetaM α) : MetaM α := -let rec loop (i : Nat) : MetaM α := do - if h : i < xs.size then - let x := xs.get ⟨i, h⟩ - let localDecl ← getFVarLocalDecl x - if localDecl.isLet then - throwStructuralFailed - else - let xType ← whnfD localDecl.type - matchConstInduct xType.getAppFn (fun _ => loop (i+1)) fun indInfo us => do - if !(← hasConst (mkBRecOnFor indInfo.name)) then - loop (i+1) - else if indInfo.isReflexive && !(← hasConst (mkBInductionOnFor indInfo.name)) then - loop (i+1) + let rec loop (i : Nat) : MetaM α := do + if h : i < xs.size then + let x := xs.get ⟨i, h⟩ + let localDecl ← getFVarLocalDecl x + if localDecl.isLet then + throwStructuralFailed else - let indArgs := xType.getAppArgs - let indParams := indArgs.extract 0 indInfo.nparams - let indIndices := indArgs.extract indInfo.nparams indArgs.size - if !indIndices.all Expr.isFVar then - orelseMergeErrors - (throwError! "argument #{i+1} was not used because its type is an inductive family and indices are not variables{indentExpr xType}") - (loop (i+1)) - else if !indIndices.allDiff then - orelseMergeErrors - (throwError! "argument #{i+1} was not used because its type is an inductive family and indices are not pairwise distinct{indentExpr xType}") - (loop (i+1)) + let xType ← whnfD localDecl.type + matchConstInduct xType.getAppFn (fun _ => loop (i+1)) fun indInfo us => do + if !(← hasConst (mkBRecOnFor indInfo.name)) then + loop (i+1) + else if indInfo.isReflexive && !(← hasConst (mkBInductionOnFor indInfo.name)) then + loop (i+1) else - let indexMinPos := getIndexMinPos xs indIndices - let numFixed := if indexMinPos < numFixed then indexMinPos else numFixed - let fixedParams := xs.extract 0 numFixed - let ys := xs.extract numFixed xs.size - match ← hasBadIndexDep? ys indIndices with - | some (index, y) => + let indArgs := xType.getAppArgs + let indParams := indArgs.extract 0 indInfo.nparams + let indIndices := indArgs.extract indInfo.nparams indArgs.size + if !indIndices.all Expr.isFVar then orelseMergeErrors - (throwError! "argument #{i+1} was not used because its type is an inductive family{indentExpr xType}\nand index{indentExpr index}\ndepends on the non index{indentExpr y}") + (throwError! "argument #{i+1} was not used because its type is an inductive family and indices are not variables{indentExpr xType}") (loop (i+1)) - | none => - match ← hasBadParamDep? ys indParams with - | some (indParam, y) => + else if !indIndices.allDiff then + orelseMergeErrors + (throwError! "argument #{i+1} was not used because its type is an inductive family and indices are not pairwise distinct{indentExpr xType}") + (loop (i+1)) + else + let indexMinPos := getIndexMinPos xs indIndices + let numFixed := if indexMinPos < numFixed then indexMinPos else numFixed + let fixedParams := xs.extract 0 numFixed + let ys := xs.extract numFixed xs.size + match ← hasBadIndexDep? ys indIndices with + | some (index, y) => orelseMergeErrors - (throwError! "argument #{i+1} was not used because its type is an inductive datatype{indentExpr xType}\nand parameter{indentExpr indParam}\ndepends on{indentExpr y}") + (throwError! "argument #{i+1} was not used because its type is an inductive family{indentExpr xType}\nand index{indentExpr index}\ndepends on the non index{indentExpr y}") (loop (i+1)) | none => - let indicesPos := indIndices.map fun index => match ys.indexOf? index with | some i => i.val | none => unreachable! - orelseMergeErrors - (k { fixedParams := fixedParams, ys := ys, pos := i - fixedParams.size, - indicesPos := indicesPos, - indName := indInfo.name, - indLevels := us, - indParams := indParams, - indIndices := indIndices, - reflexive := indInfo.isReflexive }) - (loop (i+1)) - else - throwStructuralFailed -loop numFixed + match ← hasBadParamDep? ys indParams with + | some (indParam, y) => + orelseMergeErrors + (throwError! "argument #{i+1} was not used because its type is an inductive datatype{indentExpr xType}\nand parameter{indentExpr indParam}\ndepends on{indentExpr y}") + (loop (i+1)) + | none => + let indicesPos := indIndices.map fun index => match ys.indexOf? index with | some i => i.val | none => unreachable! + orelseMergeErrors + (k { fixedParams := fixedParams, ys := ys, pos := i - fixedParams.size, + indicesPos := indicesPos, + indName := indInfo.name, + indLevels := us, + indParams := indParams, + indIndices := indIndices, + reflexive := indInfo.isReflexive }) + (loop (i+1)) + else + throwStructuralFailed + loop numFixed private def containsRecFn (recFnName : Name) (e : Expr) : Bool := -(e.find? fun e => e.isConstOf recFnName).isSome + (e.find? fun e => e.isConstOf recFnName).isSome private def ensureNoRecFn (recFnName : Name) (e : Expr) : MetaM Expr := do -if containsRecFn recFnName e then - Meta.forEachExpr e fun e => do - if e.isAppOf recFnName then - throwError! "unexpected occurrence of recursive application{indentExpr e}" - pure e -else - pure e + if containsRecFn recFnName e then + Meta.forEachExpr e fun e => do + if e.isAppOf recFnName then + throwError! "unexpected occurrence of recursive application{indentExpr e}" + pure e + else + pure e private def throwToBelowFailed {α} : MetaM α := -throwError "toBelow failed" + throwError "toBelow failed" /- See toBelow -/ private partial def toBelowAux (C : Expr) : Expr → Expr → Expr → MetaM Expr -| belowDict, arg, F => do - belowDict ← whnf belowDict - trace[Elab.definition.structural]! "belowDict: {belowDict}, arg: {arg}" - match belowDict with - | Expr.app (Expr.app (Expr.const `PProd _ _) d1 _) d2 _ => - (do toBelowAux C d1 arg (← mkAppM `PProd.fst #[F])) - <|> - (do toBelowAux C d2 arg (← mkAppM `PProd.snd #[F])) - | Expr.app (Expr.app (Expr.const `And _ _) d1 _) d2 _ => - (do toBelowAux C d1 arg (← mkAppM `And.left #[F])) - <|> - (do toBelowAux C d2 arg (← mkAppM `And.right #[F])) - | _ => forallTelescopeReducing belowDict fun xs belowDict => do - let argArgs := arg.getAppArgs - unless argArgs.size >= xs.size do throwToBelowFailed - let n := argArgs.size - let argTailArgs := argArgs.extract (n - xs.size) n - let belowDict := belowDict.replaceFVars xs argTailArgs + | belowDict, arg, F => do + belowDict ← whnf belowDict + trace[Elab.definition.structural]! "belowDict: {belowDict}, arg: {arg}" match belowDict with - | Expr.app belowDictFun belowDictArg _ => - unless belowDictFun.getAppFn == C do throwToBelowFailed - unless ← isDefEq belowDictArg arg do throwToBelowFailed - pure (mkAppN F argTailArgs) - | _ => throwToBelowFailed + | Expr.app (Expr.app (Expr.const `PProd _ _) d1 _) d2 _ => + (do toBelowAux C d1 arg (← mkAppM `PProd.fst #[F])) + <|> + (do toBelowAux C d2 arg (← mkAppM `PProd.snd #[F])) + | Expr.app (Expr.app (Expr.const `And _ _) d1 _) d2 _ => + (do toBelowAux C d1 arg (← mkAppM `And.left #[F])) + <|> + (do toBelowAux C d2 arg (← mkAppM `And.right #[F])) + | _ => forallTelescopeReducing belowDict fun xs belowDict => do + let argArgs := arg.getAppArgs + unless argArgs.size >= xs.size do throwToBelowFailed + let n := argArgs.size + let argTailArgs := argArgs.extract (n - xs.size) n + let belowDict := belowDict.replaceFVars xs argTailArgs + match belowDict with + | Expr.app belowDictFun belowDictArg _ => + unless belowDictFun.getAppFn == C do throwToBelowFailed + unless ← isDefEq belowDictArg arg do throwToBelowFailed + pure (mkAppN F argTailArgs) + | _ => throwToBelowFailed /- See toBelow -/ private def withBelowDict {α} (below : Expr) (numIndParams : Nat) (k : Expr → Expr → MetaM α) : MetaM α := do -let belowType ← inferType below -trace[Elab.definition.structural]! "belowType: {belowType}" -belowType.withApp fun f args => do - let motivePos := numIndParams + 1 - unless motivePos < args.size do throwError! "unexpected 'below' type{indentExpr belowType}" - let pre := mkAppN f (args.extract 0 numIndParams) - let preType ← inferType pre - forallBoundedTelescope preType (some 1) fun x _ => do - let motiveType ← inferType x[0] - let C ← mkFreshUserName `C - withLocalDeclD C motiveType fun C => - let belowDict := mkApp pre C - let belowDict := mkAppN belowDict (args.extract (numIndParams + 1) args.size) - k C belowDict + let belowType ← inferType below + trace[Elab.definition.structural]! "belowType: {belowType}" + belowType.withApp fun f args => do + let motivePos := numIndParams + 1 + unless motivePos < args.size do throwError! "unexpected 'below' type{indentExpr belowType}" + let pre := mkAppN f (args.extract 0 numIndParams) + let preType ← inferType pre + forallBoundedTelescope preType (some 1) fun x _ => do + let motiveType ← inferType x[0] + let C ← mkFreshUserName `C + withLocalDeclD C motiveType fun C => + let belowDict := mkApp pre C + let belowDict := mkAppN belowDict (args.extract (numIndParams + 1) args.size) + k C belowDict /- `below` is a free variable with type of the form `I.below indParams motive indices major`, @@ -202,160 +202,158 @@ belowType.withApp fun f args => do The dictionary is built using the `PProd` (`And` for inductive predicates). We keep searching it until we find `C recArg`, where `C` is the auxiliary fresh variable created at `withBelowDict`. -/ private partial def toBelow (below : Expr) (numIndParams : Nat) (recArg : Expr) : MetaM Expr := do -withBelowDict below numIndParams fun C belowDict => - toBelowAux C belowDict recArg below + withBelowDict below numIndParams fun C belowDict => + toBelowAux C belowDict recArg below private partial def replaceRecApps (recFnName : Name) (recArgInfo : RecArgInfo) (below : Expr) (e : Expr) : MetaM Expr := -let rec loop : Expr → Expr → MetaM Expr - | below, e@(Expr.lam n d b c) => do - withLocalDecl n c.binderInfo (← loop below d) fun x => do - mkLambdaFVars #[x] (← loop below (b.instantiate1 x)) - | below, e@(Expr.forallE n d b c) => do - withLocalDecl n c.binderInfo (← loop below d) fun x => do - mkForallFVars #[x] (← loop below (b.instantiate1 x)) - | below, Expr.letE n type val body _ => do - withLetDecl n (← loop below type) (← loop below val) fun x => do - mkLetFVars #[x] (← loop below (body.instantiate1 x)) - | below, Expr.mdata d e _ => do pure $ mkMData d (← loop below e) - | below, Expr.proj n i e _ => do pure $ mkProj n i (← loop below e) - | below, e@(Expr.app _ _ _) => do - let processApp (e : Expr) : MetaM Expr := - e.withApp fun f args => do - if f.isConstOf recFnName then - let numFixed := recArgInfo.fixedParams.size - let recArgPos := recArgInfo.fixedParams.size + recArgInfo.pos - if recArgPos >= args.size then - throwError! "insufficient number of parameters at recursive application {indentExpr e}" - let recArg := args[recArgPos] - let f ← try toBelow below recArgInfo.indParams.size recArg catch _ => throwError! "failed to eliminate recursive application{indentExpr e}" - -- Recall that the fixed parameters are not in the scope of the `brecOn`. So, we skip them. - let argsNonFixed := args.extract numFixed args.size - -- The function `f` does not explicitly take `recArg` and its indices as arguments. So, we skip them too. - let fArgs := #[] - for i in [:argsNonFixed.size] do - if recArgInfo.pos != i && !recArgInfo.indicesPos.contains i then - let arg := argsNonFixed[i] - let arg ← replaceRecApps recFnName recArgInfo below arg - fArgs := fArgs.push arg - pure $ mkAppN f fArgs + let rec loop : Expr → Expr → MetaM Expr + | below, e@(Expr.lam n d b c) => do + withLocalDecl n c.binderInfo (← loop below d) fun x => do + mkLambdaFVars #[x] (← loop below (b.instantiate1 x)) + | below, e@(Expr.forallE n d b c) => do + withLocalDecl n c.binderInfo (← loop below d) fun x => do + mkForallFVars #[x] (← loop below (b.instantiate1 x)) + | below, Expr.letE n type val body _ => do + withLetDecl n (← loop below type) (← loop below val) fun x => do + mkLetFVars #[x] (← loop below (body.instantiate1 x)) + | below, Expr.mdata d e _ => do pure $ mkMData d (← loop below e) + | below, Expr.proj n i e _ => do pure $ mkProj n i (← loop below e) + | below, e@(Expr.app _ _ _) => do + let processApp (e : Expr) : MetaM Expr := + e.withApp fun f args => do + if f.isConstOf recFnName then + let numFixed := recArgInfo.fixedParams.size + let recArgPos := recArgInfo.fixedParams.size + recArgInfo.pos + if recArgPos >= args.size then + throwError! "insufficient number of parameters at recursive application {indentExpr e}" + let recArg := args[recArgPos] + let f ← try toBelow below recArgInfo.indParams.size recArg catch _ => throwError! "failed to eliminate recursive application{indentExpr e}" + -- Recall that the fixed parameters are not in the scope of the `brecOn`. So, we skip them. + let argsNonFixed := args.extract numFixed args.size + -- The function `f` does not explicitly take `recArg` and its indices as arguments. So, we skip them too. + let fArgs := #[] + for i in [:argsNonFixed.size] do + if recArgInfo.pos != i && !recArgInfo.indicesPos.contains i then + let arg := argsNonFixed[i] + let arg ← replaceRecApps recFnName recArgInfo below arg + fArgs := fArgs.push arg + pure $ mkAppN f fArgs + else + pure $ mkAppN (← loop below f) (← args.mapM (loop below)) + let matcherApp? ← matchMatcherApp? e + match matcherApp? with + | some matcherApp => + if !containsRecFn recFnName e then + processApp e else - pure $ mkAppN (← loop below f) (← args.mapM (loop below)) - let matcherApp? ← matchMatcherApp? e - match matcherApp? with - | some matcherApp => - if !containsRecFn recFnName e then - processApp e - else - /- If we first try to process the `match` as a regular application. If it fails, then we try to `push` the below over the dependent `match`. - This is useful for examples such as: - ``` - def f (xs : List Nat) : Nat := - match xs with - | [] => 0 - | y::ys => - match ys with - | [] => 1 - | zs => f ys + 1 - ``` - We are matching on `ys`, but still using `ys` in the second alternative. - If we push the `below` argument over the dependent match it will be able to eliminate recursive call using `zs`. - This trick is not sufficient for the slightly more complicated example: - ``` - def g (xs : List Nat) : Nat := - match xs with - | [] => 0 - | y::ys => - match ys with - | [] => 1 - | _::_::zs => g zs + 1 - | _ => g ys + 2 - ``` - To make it work, users would have to write the last alternative as - ``` - | zs => g zs + 2 - ``` - - If this is too annoying in practice, we may replace `ys` with the matching term. - This may generate weird error messages, when it doesn't work. - -/ - processApp e - <|> - do let matcherApp ← mapError (matcherApp.addArg below) (fun msg => "failed to add `below` argument to 'matcher' application" ++ indentD msg) - let altsNew ← (Array.zip matcherApp.alts matcherApp.altNumParams).mapM fun (alt, numParams) => + /- Here is an example we currently not handle + ``` + def f (xs : List Nat) : Nat := + match xs with + | [] => 0 + | y::ys => + match ys with + | [] => 1 + | zs => f ys + 1 + ``` + We are matching on `ys`, but still using `ys` in the second alternative. + If we push the `below` argument over the dependent match it will be able to eliminate recursive call using `zs`. + To make it work, users have to write the second alternative as `| zs => f zs + 1` + We considered trying `processApp e` first, and only if fails trying the code below. + This trick is sufficient for solving the example above, but it is not sufficient for the slightly more complicated example: + ``` + def g (xs : List Nat) : Nat := + match xs with + | [] => 0 + | y::ys => + match ys with + | [] => 1 + | _::_::zs => g zs + 1 + | _ => g ys + 2 + ``` + To make it work, users would have to write the last alternative as + ``` + | zs => g zs + 2 + ``` + If this is too annoying in practice, we may replace `ys` with the matching term. + This may generate weird error messages, when it doesn't work. + -/ + let matcherApp ← mapError (matcherApp.addArg below) (fun msg => "failed to add `below` argument to 'matcher' application" ++ indentD msg) + let altsNew ← (Array.zip matcherApp.alts matcherApp.altNumParams).mapM fun (alt, numParams) => lambdaTelescope alt fun xs altBody => do trace[Elab.definition.structural]! "altNumParams: {numParams}, xs: {xs}" unless xs.size >= numParams do throwError! "unexpected matcher application alternative{indentExpr alt}\nat application{indentExpr e}" let belowForAlt := xs[numParams - 1] mkLambdaFVars xs (← loop belowForAlt altBody) - pure { matcherApp with alts := altsNew }.toExpr - | none => processApp e - | _, e => ensureNoRecFn recFnName e -loop below e + pure { matcherApp with alts := altsNew }.toExpr + | none => processApp e + | _, e => ensureNoRecFn recFnName e + loop below e private def mkBRecOn (recFnName : Name) (recArgInfo : RecArgInfo) (value : Expr) : MetaM Expr := do -let type := (← inferType value).headBeta -let major := recArgInfo.ys[recArgInfo.pos] -let otherArgs := recArgInfo.ys.filter fun y => y != major && !recArgInfo.indIndices.contains y -let motive ← mkForallFVars otherArgs type -let brecOnUniv ← getLevel motive -trace[Elab.definition.structural]! "brecOn univ: {brecOnUniv}" -let useBInductionOn := recArgInfo.reflexive && brecOnUniv == levelZero -if recArgInfo.reflexive && brecOnUniv != levelZero then - brecOnUniv ← decLevel brecOnUniv -let motive ← mkLambdaFVars (recArgInfo.indIndices.push major) motive -trace[Elab.definition.structural]! "brecOn motive: {motive}" -let brecOn := - if useBInductionOn then - Lean.mkConst (mkBInductionOnFor recArgInfo.indName) recArgInfo.indLevels - else - Lean.mkConst (mkBRecOnFor recArgInfo.indName) (brecOnUniv :: recArgInfo.indLevels) -let brecOn := mkAppN brecOn recArgInfo.indParams -let brecOn := mkApp brecOn motive -let brecOn := mkAppN brecOn recArgInfo.indIndices -let brecOn := mkApp brecOn major -check brecOn -let brecOnType ← inferType brecOn -trace[Elab.definition.structural]! "brecOn {brecOn}" -trace[Elab.definition.structural]! "brecOnType {brecOnType}" -forallBoundedTelescope brecOnType (some 1) fun F _ => do - let F := F[0] - let FType ← inferType F - let numIndices := recArgInfo.indIndices.size - forallBoundedTelescope FType (some $ numIndices + 1 /- major -/ + 1 /- below -/ + otherArgs.size) fun Fargs _ => do - let indicesNew := Fargs.extract 0 numIndices - let majorNew := Fargs[numIndices] - let below := Fargs[numIndices+1] - let otherArgsNew := Fargs.extract (numIndices+2) Fargs.size - let valueNew := value.replaceFVars recArgInfo.indIndices indicesNew - let valueNew := valueNew.replaceFVar major majorNew - let valueNew := valueNew.replaceFVars otherArgs otherArgsNew - let valueNew ← replaceRecApps recFnName recArgInfo below valueNew - let Farg ← mkLambdaFVars Fargs valueNew - let brecOn := mkApp brecOn Farg - pure $ mkAppN brecOn otherArgs + let type := (← inferType value).headBeta + let major := recArgInfo.ys[recArgInfo.pos] + let otherArgs := recArgInfo.ys.filter fun y => y != major && !recArgInfo.indIndices.contains y + let motive ← mkForallFVars otherArgs type + let brecOnUniv ← getLevel motive + trace[Elab.definition.structural]! "brecOn univ: {brecOnUniv}" + let useBInductionOn := recArgInfo.reflexive && brecOnUniv == levelZero + if recArgInfo.reflexive && brecOnUniv != levelZero then + brecOnUniv ← decLevel brecOnUniv + let motive ← mkLambdaFVars (recArgInfo.indIndices.push major) motive + trace[Elab.definition.structural]! "brecOn motive: {motive}" + let brecOn := + if useBInductionOn then + Lean.mkConst (mkBInductionOnFor recArgInfo.indName) recArgInfo.indLevels + else + Lean.mkConst (mkBRecOnFor recArgInfo.indName) (brecOnUniv :: recArgInfo.indLevels) + let brecOn := mkAppN brecOn recArgInfo.indParams + let brecOn := mkApp brecOn motive + let brecOn := mkAppN brecOn recArgInfo.indIndices + let brecOn := mkApp brecOn major + check brecOn + let brecOnType ← inferType brecOn + trace[Elab.definition.structural]! "brecOn {brecOn}" + trace[Elab.definition.structural]! "brecOnType {brecOnType}" + forallBoundedTelescope brecOnType (some 1) fun F _ => do + let F := F[0] + let FType ← inferType F + let numIndices := recArgInfo.indIndices.size + forallBoundedTelescope FType (some $ numIndices + 1 /- major -/ + 1 /- below -/ + otherArgs.size) fun Fargs _ => do + let indicesNew := Fargs.extract 0 numIndices + let majorNew := Fargs[numIndices] + let below := Fargs[numIndices+1] + let otherArgsNew := Fargs.extract (numIndices+2) Fargs.size + let valueNew := value.replaceFVars recArgInfo.indIndices indicesNew + let valueNew := valueNew.replaceFVar major majorNew + let valueNew := valueNew.replaceFVars otherArgs otherArgsNew + let valueNew ← replaceRecApps recFnName recArgInfo below valueNew + let Farg ← mkLambdaFVars Fargs valueNew + let brecOn := mkApp brecOn Farg + pure $ mkAppN brecOn otherArgs private def elimRecursion (preDef : PreDefinition) : MetaM PreDefinition := -withoutModifyingEnv do lambdaTelescope preDef.value fun xs value => do - addAsAxiom preDef - trace[Elab.definition.structural]! "{preDef.declName} {xs} :=\n{value}" - let numFixed := getFixedPrefix preDef.declName xs value - findRecArg numFixed xs fun recArgInfo => do - -- when (recArgInfo.indName == `Nat) throwStructuralFailed -- HACK to skip Nat argument - let valueNew ← mkBRecOn preDef.declName recArgInfo value - let valueNew ← mkLambdaFVars xs valueNew - trace[Elab.definition.structural]! "result: {valueNew}" - -- Recursive applications may still occur in expressions that were not visited by replaceRecApps (e.g., in types) - let valueNew ← ensureNoRecFn preDef.declName valueNew - pure { preDef with value := valueNew } + withoutModifyingEnv do lambdaTelescope preDef.value fun xs value => do + addAsAxiom preDef + trace[Elab.definition.structural]! "{preDef.declName} {xs} :=\n{value}" + let numFixed := getFixedPrefix preDef.declName xs value + findRecArg numFixed xs fun recArgInfo => do + -- when (recArgInfo.indName == `Nat) throwStructuralFailed -- HACK to skip Nat argument + let valueNew ← mkBRecOn preDef.declName recArgInfo value + let valueNew ← mkLambdaFVars xs valueNew + trace[Elab.definition.structural]! "result: {valueNew}" + -- Recursive applications may still occur in expressions that were not visited by replaceRecApps (e.g., in types) + let valueNew ← ensureNoRecFn preDef.declName valueNew + pure { preDef with value := valueNew } def structuralRecursion (preDefs : Array PreDefinition) : TermElabM Unit := -if preDefs.size != 1 then - throwError "structural recursion does not handle mutually recursive functions" -else do - let preDefNonRec ← elimRecursion preDefs[0] - addNonRec preDefNonRec - addAndCompileUnsafeRec preDefs + if preDefs.size != 1 then + throwError "structural recursion does not handle mutually recursive functions" + else do + let preDefNonRec ← elimRecursion preDefs[0] + addNonRec preDefNonRec + addAndCompileUnsafeRec preDefs builtin_initialize registerTraceClass `Elab.definition.structural diff --git a/stage0/src/Lean/Elab/PreDefinition/WF.lean b/stage0/src/Lean/Elab/PreDefinition/WF.lean index c511659a8b..c941e6125f 100644 --- a/stage0/src/Lean/Elab/PreDefinition/WF.lean +++ b/stage0/src/Lean/Elab/PreDefinition/WF.lean @@ -10,7 +10,7 @@ namespace Elab open Meta def WFRecursion (preDefs : Array PreDefinition) : TermElabM Unit := -throwError "well founded recursion has not been implemented yet" + throwError "well founded recursion has not been implemented yet" end Elab end Lean diff --git a/stage0/src/Lean/Expr.lean b/stage0/src/Lean/Expr.lean index 242b2a50fc..57a674be39 100644 --- a/stage0/src/Lean/Expr.lean +++ b/stage0/src/Lean/Expr.lean @@ -10,70 +10,70 @@ import Lean.Level namespace Lean inductive Literal -| natVal (val : Nat) -| strVal (val : String) + | natVal (val : Nat) + | strVal (val : String) instance : Inhabited Literal := ⟨Literal.natVal 0⟩ protected def Literal.hash : Literal → USize -| Literal.natVal v => hash v -| Literal.strVal v => hash v + | Literal.natVal v => hash v + | Literal.strVal v => hash v instance : Hashable Literal := ⟨Literal.hash⟩ def Literal.beq : Literal → Literal → Bool -| Literal.natVal v₁, Literal.natVal v₂ => v₁ == v₂ -| Literal.strVal v₁, Literal.strVal v₂ => v₁ == v₂ -| _, _ => false + | Literal.natVal v₁, Literal.natVal v₂ => v₁ == v₂ + | Literal.strVal v₁, Literal.strVal v₂ => v₁ == v₂ + | _, _ => false instance : HasBeq Literal := ⟨Literal.beq⟩ def Literal.lt : Literal → Literal → Bool -| Literal.natVal _, Literal.strVal _ => true -| Literal.natVal v₁, Literal.natVal v₂ => v₁ < v₂ -| Literal.strVal v₁, Literal.strVal v₂ => v₁ < v₂ -| _, _ => false + | Literal.natVal _, Literal.strVal _ => true + | Literal.natVal v₁, Literal.natVal v₂ => v₁ < v₂ + | Literal.strVal v₁, Literal.strVal v₂ => v₁ < v₂ + | _, _ => false instance : HasLess Literal := ⟨fun a b => a.lt b⟩ instance (a b : Literal) : Decidable (a < b) := -inferInstanceAs (Decidable (a.lt b)) + inferInstanceAs (Decidable (a.lt b)) inductive BinderInfo -| default | implicit | strictImplicit | instImplicit | auxDecl + | default | implicit | strictImplicit | instImplicit | auxDecl def BinderInfo.hash : BinderInfo → USize -| BinderInfo.default => 947 -| BinderInfo.implicit => 1019 -| BinderInfo.strictImplicit => 1087 -| BinderInfo.instImplicit => 1153 -| BinderInfo.auxDecl => 1229 + | BinderInfo.default => 947 + | BinderInfo.implicit => 1019 + | BinderInfo.strictImplicit => 1087 + | BinderInfo.instImplicit => 1153 + | BinderInfo.auxDecl => 1229 def BinderInfo.isExplicit : BinderInfo → Bool -| BinderInfo.implicit => false -| BinderInfo.strictImplicit => false -| BinderInfo.instImplicit => false -| _ => true + | BinderInfo.implicit => false + | BinderInfo.strictImplicit => false + | BinderInfo.instImplicit => false + | _ => true instance : Hashable BinderInfo := ⟨BinderInfo.hash⟩ instance : Inhabited BinderInfo := ⟨BinderInfo.default⟩ def BinderInfo.isInstImplicit : BinderInfo → Bool -| BinderInfo.instImplicit => true -| _ => false + | BinderInfo.instImplicit => true + | _ => false def BinderInfo.isAuxDecl : BinderInfo → Bool -| BinderInfo.auxDecl => true -| _ => false + | BinderInfo.auxDecl => true + | _ => false protected def BinderInfo.beq : BinderInfo → BinderInfo → Bool -| BinderInfo.default, BinderInfo.default => true -| BinderInfo.implicit, BinderInfo.implicit => true -| BinderInfo.strictImplicit, BinderInfo.strictImplicit => true -| BinderInfo.instImplicit, BinderInfo.instImplicit => true -| BinderInfo.auxDecl, BinderInfo.auxDecl => true -| _, _ => false + | BinderInfo.default, BinderInfo.default => true + | BinderInfo.implicit, BinderInfo.implicit => true + | BinderInfo.strictImplicit, BinderInfo.strictImplicit => true + | BinderInfo.instImplicit, BinderInfo.instImplicit => true + | BinderInfo.auxDecl, BinderInfo.auxDecl => true + | _, _ => false instance : HasBeq BinderInfo := ⟨BinderInfo.beq⟩ @@ -93,74 +93,74 @@ abbrev MData.empty : MData := {} def Expr.Data := UInt64 instance: Inhabited Expr.Data := -inferInstanceAs (Inhabited UInt64) + inferInstanceAs (Inhabited UInt64) def Expr.Data.hash (c : Expr.Data) : USize := -c.toUInt32.toUSize + c.toUInt32.toUSize instance : HasBeq Expr.Data := -⟨fun (a b : UInt64) => a == b⟩ + ⟨fun (a b : UInt64) => a == b⟩ def Expr.Data.looseBVarRange (c : Expr.Data) : UInt32 := -(c.shiftRight 40).toUInt32 + (c.shiftRight 40).toUInt32 def Expr.Data.hasFVar (c : Expr.Data) : Bool := -((c.shiftRight 32).land 1) == 1 + ((c.shiftRight 32).land 1) == 1 def Expr.Data.hasExprMVar (c : Expr.Data) : Bool := -((c.shiftRight 33).land 1) == 1 + ((c.shiftRight 33).land 1) == 1 def Expr.Data.hasLevelMVar (c : Expr.Data) : Bool := -((c.shiftRight 34).land 1) == 1 + ((c.shiftRight 34).land 1) == 1 def Expr.Data.hasLevelParam (c : Expr.Data) : Bool := -((c.shiftRight 35).land 1) == 1 + ((c.shiftRight 35).land 1) == 1 def Expr.Data.nonDepLet (c : Expr.Data) : Bool := -((c.shiftRight 36).land 1) == 1 + ((c.shiftRight 36).land 1) == 1 @[extern c inline "(uint8_t)((#1 << 24) >> 61)"] def Expr.Data.binderInfo (c : Expr.Data) : BinderInfo := -let bi := (c.shiftLeft 24).shiftRight 61 -if bi == 0 then BinderInfo.default -else if bi == 1 then BinderInfo.implicit -else if bi == 2 then BinderInfo.strictImplicit -else if bi == 3 then BinderInfo.instImplicit -else BinderInfo.auxDecl + let bi := (c.shiftLeft 24).shiftRight 61 + if bi == 0 then BinderInfo.default + else if bi == 1 then BinderInfo.implicit + else if bi == 2 then BinderInfo.strictImplicit + else if bi == 3 then BinderInfo.instImplicit + else BinderInfo.auxDecl @[extern c inline "(uint64_t)#1"] def BinderInfo.toUInt64 : BinderInfo → UInt64 -| BinderInfo.default => 0 -| BinderInfo.implicit => 1 -| BinderInfo.strictImplicit => 2 -| BinderInfo.instImplicit => 3 -| BinderInfo.auxDecl => 4 + | BinderInfo.default => 0 + | BinderInfo.implicit => 1 + | BinderInfo.strictImplicit => 2 + | BinderInfo.instImplicit => 3 + | BinderInfo.auxDecl => 4 @[inline] private def Expr.mkDataCore (h : USize) (looseBVarRange : Nat) (hasFVar hasExprMVar hasLevelMVar hasLevelParam nonDepLet : Bool) (bi : BinderInfo) : Expr.Data := -if looseBVarRange > Nat.pow 2 24 - 1 then panic! "bound variable index is too big" -else - let r : UInt64 := - h.toUInt32.toUInt64 + - hasFVar.toUInt64.shiftLeft 32 + - hasExprMVar.toUInt64.shiftLeft 33 + - hasLevelMVar.toUInt64.shiftLeft 34 + - hasLevelParam.toUInt64.shiftLeft 35 + - nonDepLet.toUInt64.shiftLeft 36 + - bi.toUInt64.shiftLeft 37 + - looseBVarRange.toUInt64.shiftLeft 40 - r + if looseBVarRange > Nat.pow 2 24 - 1 then panic! "bound variable index is too big" + else + let r : UInt64 := + h.toUInt32.toUInt64 + + hasFVar.toUInt64.shiftLeft 32 + + hasExprMVar.toUInt64.shiftLeft 33 + + hasLevelMVar.toUInt64.shiftLeft 34 + + hasLevelParam.toUInt64.shiftLeft 35 + + nonDepLet.toUInt64.shiftLeft 36 + + bi.toUInt64.shiftLeft 37 + + looseBVarRange.toUInt64.shiftLeft 40 + r def Expr.mkData (h : USize) (looseBVarRange : Nat := 0) (hasFVar hasExprMVar hasLevelMVar hasLevelParam : Bool := false) : Expr.Data := -Expr.mkDataCore h looseBVarRange hasFVar hasExprMVar hasLevelMVar hasLevelParam false BinderInfo.default + Expr.mkDataCore h looseBVarRange hasFVar hasExprMVar hasLevelMVar hasLevelParam false BinderInfo.default def Expr.mkDataForBinder (h : USize) (looseBVarRange : Nat) (hasFVar hasExprMVar hasLevelMVar hasLevelParam : Bool) (bi : BinderInfo) : Expr.Data := -Expr.mkDataCore h looseBVarRange hasFVar hasExprMVar hasLevelMVar hasLevelParam false bi + Expr.mkDataCore h looseBVarRange hasFVar hasExprMVar hasLevelMVar hasLevelParam false bi def Expr.mkDataForLet (h : USize) (looseBVarRange : Nat) (hasFVar hasExprMVar hasLevelMVar hasLevelParam nonDepLet : Bool) : Expr.Data := -Expr.mkDataCore h looseBVarRange hasFVar hasExprMVar hasLevelMVar hasLevelParam nonDepLet BinderInfo.default + Expr.mkDataCore h looseBVarRange hasFVar hasExprMVar hasLevelMVar hasLevelParam nonDepLet BinderInfo.default open Expr @@ -170,82 +170,82 @@ abbrev FVarId := Name /- We use the `E` suffix (short for `Expr`) to avoid collision with keywords. We considered using «...», but it is too inconvenient to use. -/ inductive Expr -| bvar : Nat → Data → Expr -- bound variables -| fvar : FVarId → Data → Expr -- free variables -| mvar : MVarId → Data → Expr -- meta variables -| sort : Level → Data → Expr -- Sort -| const : Name → List Level → Data → Expr -- constants -| app : Expr → Expr → Data → Expr -- application -| lam : Name → Expr → Expr → Data → Expr -- lambda abstraction -| forallE : Name → Expr → Expr → Data → Expr -- (dependent) arrow -| letE : Name → Expr → Expr → Expr → Data → Expr -- let expressions -| lit : Literal → Data → Expr -- literals -| mdata : MData → Expr → Data → Expr -- metadata -| proj : Name → Nat → Expr → Data → Expr -- projection --- IMPORTANT: the following constructor will be deleted -| localE : Name → Name → Expr → Data → Expr -- Lean2 legacy. TODO: delete + | bvar : Nat → Data → Expr -- bound variables + | fvar : FVarId → Data → Expr -- free variables + | mvar : MVarId → Data → Expr -- meta variables + | sort : Level → Data → Expr -- Sort + | const : Name → List Level → Data → Expr -- constants + | app : Expr → Expr → Data → Expr -- application + | lam : Name → Expr → Expr → Data → Expr -- lambda abstraction + | forallE : Name → Expr → Expr → Data → Expr -- (dependent) arrow + | letE : Name → Expr → Expr → Expr → Data → Expr -- let expressions + | lit : Literal → Data → Expr -- literals + | mdata : MData → Expr → Data → Expr -- metadata + | proj : Name → Nat → Expr → Data → Expr -- projection + -- IMPORTANT: the following constructor will be deleted + | localE : Name → Name → Expr → Data → Expr -- Lean2 legacy. TODO: delete namespace Expr instance : Inhabited Expr := -⟨sort (arbitrary _) (arbitrary _)⟩ + ⟨sort (arbitrary _) (arbitrary _)⟩ @[inline] def data : Expr → Data -| bvar _ d => d -| fvar _ d => d -| mvar _ d => d -| sort _ d => d -| const _ _ d => d -| app _ _ d => d -| lam _ _ _ d => d -| forallE _ _ _ d => d -| letE _ _ _ _ d => d -| lit _ d => d -| mdata _ _ d => d -| proj _ _ _ d => d -| localE _ _ _ d => d + | bvar _ d => d + | fvar _ d => d + | mvar _ d => d + | sort _ d => d + | const _ _ d => d + | app _ _ d => d + | lam _ _ _ d => d + | forallE _ _ _ d => d + | letE _ _ _ _ d => d + | lit _ d => d + | mdata _ _ d => d + | proj _ _ _ d => d + | localE _ _ _ d => d def ctorName : Expr → String -| bvar _ _ => "bvar" -| fvar _ _ => "fvar" -| mvar _ _ => "mvar" -| sort _ _ => "sort" -| const _ _ _ => "const" -| app _ _ _ => "app" -| lam _ _ _ _ => "lam" -| forallE _ _ _ _ => "forallE" -| letE _ _ _ _ _ => "letE" -| lit _ _ => "lit" -| mdata _ _ _ => "mdata" -| proj _ _ _ _ => "proj" -| localE _ _ _ _ => "localE" + | bvar _ _ => "bvar" + | fvar _ _ => "fvar" + | mvar _ _ => "mvar" + | sort _ _ => "sort" + | const _ _ _ => "const" + | app _ _ _ => "app" + | lam _ _ _ _ => "lam" + | forallE _ _ _ _ => "forallE" + | letE _ _ _ _ _ => "letE" + | lit _ _ => "lit" + | mdata _ _ _ => "mdata" + | proj _ _ _ _ => "proj" + | localE _ _ _ _ => "localE" protected def hash (e : Expr) : USize := -e.data.hash + e.data.hash instance : Hashable Expr := ⟨Expr.hash⟩ def hasFVar (e : Expr) : Bool := -e.data.hasFVar + e.data.hasFVar def hasExprMVar (e : Expr) : Bool := -e.data.hasExprMVar + e.data.hasExprMVar def hasLevelMVar (e : Expr) : Bool := -e.data.hasLevelMVar + e.data.hasLevelMVar def hasMVar (e : Expr) : Bool := -let d := e.data -d.hasExprMVar || d.hasLevelMVar + let d := e.data + d.hasExprMVar || d.hasLevelMVar def hasLevelParam (e : Expr) : Bool := -e.data.hasLevelParam + e.data.hasLevelParam def looseBVarRange (e : Expr) : Nat := -e.data.looseBVarRange.toNat + e.data.looseBVarRange.toNat def binderInfo (e : Expr) : BinderInfo := -e.data.binderInfo + e.data.binderInfo @[export lean_expr_hash] def hashEx : Expr → USize := hash @[export lean_expr_has_fvar] def hasFVarEx : Expr → Bool := hasFVar @@ -259,92 +259,92 @@ e.data.binderInfo end Expr def mkLit (l : Literal) : Expr := -Expr.lit l $ mkData (mixHash 3 (hash l)) + Expr.lit l $ mkData (mixHash 3 (hash l)) def mkNatLit (n : Nat) : Expr := -mkLit (Literal.natVal n) + mkLit (Literal.natVal n) def mkStrLit (s : String) : Expr := -mkLit (Literal.strVal s) + mkLit (Literal.strVal s) def mkConst (n : Name) (lvls : List Level := []) : Expr := -Expr.const n lvls $ mkData (mixHash 5 $ mixHash (hash n) (hash lvls)) 0 false false (lvls.any Level.hasMVar) (lvls.any Level.hasParam) + Expr.const n lvls $ mkData (mixHash 5 $ mixHash (hash n) (hash lvls)) 0 false false (lvls.any Level.hasMVar) (lvls.any Level.hasParam) def Literal.type : Literal → Expr -| Literal.natVal _ => mkConst `Nat -| Literal.strVal _ => mkConst `String + | Literal.natVal _ => mkConst `Nat + | Literal.strVal _ => mkConst `String @[export lean_lit_type] def Literal.typeEx : Literal → Expr := Literal.type def mkBVar (idx : Nat) : Expr := -Expr.bvar idx $ mkData (mixHash 7 $ hash idx) (idx+1) + Expr.bvar idx $ mkData (mixHash 7 $ hash idx) (idx+1) def mkSort (lvl : Level) : Expr := -Expr.sort lvl $ mkData (mixHash 11 $ hash lvl) 0 false false lvl.hasMVar lvl.hasParam + Expr.sort lvl $ mkData (mixHash 11 $ hash lvl) 0 false false lvl.hasMVar lvl.hasParam def mkFVar (fvarId : FVarId) : Expr := -Expr.fvar fvarId $ mkData (mixHash 13 $ hash fvarId) 0 true + Expr.fvar fvarId $ mkData (mixHash 13 $ hash fvarId) 0 true def mkMVar (fvarId : MVarId) : Expr := -Expr.mvar fvarId $ mkData (mixHash 17 $ hash fvarId) 0 false true + Expr.mvar fvarId $ mkData (mixHash 17 $ hash fvarId) 0 false true def mkMData (d : MData) (e : Expr) : Expr := -Expr.mdata d e $ mkData (mixHash 19 $ hash e) e.looseBVarRange e.hasFVar e.hasExprMVar e.hasLevelMVar e.hasLevelParam + Expr.mdata d e $ mkData (mixHash 19 $ hash e) e.looseBVarRange e.hasFVar e.hasExprMVar e.hasLevelMVar e.hasLevelParam def mkProj (s : Name) (i : Nat) (e : Expr) : Expr := -Expr.proj s i e $ mkData (mixHash 23 $ mixHash (hash s) $ mixHash (hash i) (hash e)) - e.looseBVarRange e.hasFVar e.hasExprMVar e.hasLevelMVar e.hasLevelParam + Expr.proj s i e $ mkData (mixHash 23 $ mixHash (hash s) $ mixHash (hash i) (hash e)) + e.looseBVarRange e.hasFVar e.hasExprMVar e.hasLevelMVar e.hasLevelParam def mkApp (f a : Expr) : Expr := -Expr.app f a $ mkData (mixHash 29 $ mixHash (hash f) (hash a)) - (Nat.max f.looseBVarRange a.looseBVarRange) - (f.hasFVar || a.hasFVar) - (f.hasExprMVar || a.hasExprMVar) - (f.hasLevelMVar || a.hasLevelMVar) - (f.hasLevelParam || a.hasLevelParam) + Expr.app f a $ mkData (mixHash 29 $ mixHash (hash f) (hash a)) + (Nat.max f.looseBVarRange a.looseBVarRange) + (f.hasFVar || a.hasFVar) + (f.hasExprMVar || a.hasExprMVar) + (f.hasLevelMVar || a.hasLevelMVar) + (f.hasLevelParam || a.hasLevelParam) def mkLambda (x : Name) (bi : BinderInfo) (t : Expr) (b : Expr) : Expr := --- let x := x.eraseMacroScopes -Expr.lam x t b $ mkDataForBinder (mixHash 31 $ mixHash (hash t) (hash b)) - (Nat.max t.looseBVarRange (b.looseBVarRange - 1)) - (t.hasFVar || b.hasFVar) - (t.hasExprMVar || b.hasExprMVar) - (t.hasLevelMVar || b.hasLevelMVar) - (t.hasLevelParam || b.hasLevelParam) - bi + -- let x := x.eraseMacroScopes + Expr.lam x t b $ mkDataForBinder (mixHash 31 $ mixHash (hash t) (hash b)) + (Nat.max t.looseBVarRange (b.looseBVarRange - 1)) + (t.hasFVar || b.hasFVar) + (t.hasExprMVar || b.hasExprMVar) + (t.hasLevelMVar || b.hasLevelMVar) + (t.hasLevelParam || b.hasLevelParam) + bi def mkForall (x : Name) (bi : BinderInfo) (t : Expr) (b : Expr) : Expr := --- let x := x.eraseMacroScopes -Expr.forallE x t b $ mkDataForBinder (mixHash 37 $ mixHash (hash t) (hash b)) - (Nat.max t.looseBVarRange (b.looseBVarRange - 1)) - (t.hasFVar || b.hasFVar) - (t.hasExprMVar || b.hasExprMVar) - (t.hasLevelMVar || b.hasLevelMVar) - (t.hasLevelParam || b.hasLevelParam) - bi + -- let x := x.eraseMacroScopes + Expr.forallE x t b $ mkDataForBinder (mixHash 37 $ mixHash (hash t) (hash b)) + (Nat.max t.looseBVarRange (b.looseBVarRange - 1)) + (t.hasFVar || b.hasFVar) + (t.hasExprMVar || b.hasExprMVar) + (t.hasLevelMVar || b.hasLevelMVar) + (t.hasLevelParam || b.hasLevelParam) + bi /- Return `Unit -> type`. Do not confuse with `Thunk type` -/ def mkSimpleThunkType (type : Expr) : Expr := -mkForall Name.anonymous BinderInfo.default (Lean.mkConst `Unit) type + mkForall Name.anonymous BinderInfo.default (Lean.mkConst `Unit) type /- Return `fun (_ : Unit), e` -/ def mkSimpleThunk (type : Expr) : Expr := -mkLambda `_ BinderInfo.default (Lean.mkConst `Unit) type + mkLambda `_ BinderInfo.default (Lean.mkConst `Unit) type def mkLet (x : Name) (t : Expr) (v : Expr) (b : Expr) (nonDep : Bool := false) : Expr := --- let x := x.eraseMacroScopes -Expr.letE x t v b $ mkDataForLet (mixHash 41 $ mixHash (hash t) $ mixHash (hash v) (hash b)) - (Nat.max (Nat.max t.looseBVarRange v.looseBVarRange) (b.looseBVarRange - 1)) - (t.hasFVar || v.hasFVar || b.hasFVar) - (t.hasExprMVar || v.hasExprMVar || b.hasExprMVar) - (t.hasLevelMVar || v.hasLevelMVar || b.hasLevelMVar) - (t.hasLevelParam || v.hasLevelParam || b.hasLevelParam) - nonDep + -- let x := x.eraseMacroScopes + Expr.letE x t v b $ mkDataForLet (mixHash 41 $ mixHash (hash t) $ mixHash (hash v) (hash b)) + (Nat.max (Nat.max t.looseBVarRange v.looseBVarRange) (b.looseBVarRange - 1)) + (t.hasFVar || v.hasFVar || b.hasFVar) + (t.hasExprMVar || v.hasExprMVar || b.hasExprMVar) + (t.hasLevelMVar || v.hasLevelMVar || b.hasLevelMVar) + (t.hasLevelParam || v.hasLevelParam || b.hasLevelParam) + nonDep -- TODO: delete def mkLocal (x u : Name) (t : Expr) (bi : BinderInfo) : Expr := -Expr.localE x u t $ mkDataForBinder (mixHash 43 $ hash t) t.looseBVarRange true t.hasExprMVar t.hasLevelMVar t.hasLevelParam bi + Expr.localE x u t $ mkDataForBinder (mixHash 43 $ hash t) t.looseBVarRange true t.hasExprMVar t.hasLevelMVar t.hasLevelParam bi @[export lean_expr_mk_bvar] def mkBVarEx : Nat → Expr := mkBVar @[export lean_expr_mk_fvar] def mkFVarEx : FVarId → Expr := mkFVar @@ -361,252 +361,252 @@ Expr.localE x u t $ mkDataForBinder (mixHash 43 $ hash t) t.looseBVarRange true @[export lean_expr_mk_local] def mkLocalEx : Name → Name → Expr → BinderInfo → Expr := mkLocal def mkAppN (f : Expr) (args : Array Expr) : Expr := -args.foldl mkApp f + args.foldl mkApp f private partial def mkAppRangeAux (n : Nat) (args : Array Expr) (i : Nat) (e : Expr) : Expr := -if i < n then mkAppRangeAux n args (i+1) (mkApp e (args.get! i)) else e + if i < n then mkAppRangeAux n args (i+1) (mkApp e (args.get! i)) else e /-- `mkAppRange f i j #[a_1, ..., a_i, ..., a_j, ... ]` ==> the expression `f a_i ... a_{j-1}` -/ def mkAppRange (f : Expr) (i j : Nat) (args : Array Expr) : Expr := -mkAppRangeAux j args i f + mkAppRangeAux j args i f def mkAppRev (fn : Expr) (revArgs : Array Expr) : Expr := -revArgs.foldr (fun a r => mkApp r a) fn + revArgs.foldr (fun a r => mkApp r a) fn namespace Expr -- TODO: implement it in Lean @[extern "lean_expr_dbg_to_string"] -constant dbgToString (e : @& Expr) : String := arbitrary String +constant dbgToString (e : @& Expr) : String @[extern "lean_expr_quick_lt"] -constant quickLt (a : @& Expr) (b : @& Expr) : Bool := arbitrary _ +constant quickLt (a : @& Expr) (b : @& Expr) : Bool @[extern "lean_expr_lt"] -constant lt (a : @& Expr) (b : @& Expr) : Bool := arbitrary _ +constant lt (a : @& Expr) (b : @& Expr) : Bool /- Return true iff `a` and `b` are alpha equivalent. Binder annotations are ignored. -/ @[extern "lean_expr_eqv"] -constant eqv (a : @& Expr) (b : @& Expr) : Bool := arbitrary _ +constant eqv (a : @& Expr) (b : @& Expr) : Bool instance : HasBeq Expr := ⟨Expr.eqv⟩ /- Return true iff `a` and `b` are equal. Binder names and annotations are taking into account. -/ @[extern "lean_expr_equal"] -constant equal (a : @& Expr) (b : @& Expr) : Bool := arbitrary _ +constant equal (a : @& Expr) (b : @& Expr) : Bool def isSort : Expr → Bool -| sort _ _ => true -| _ => false + | sort _ _ => true + | _ => false def isBVar : Expr → Bool -| bvar _ _ => true -| _ => false + | bvar _ _ => true + | _ => false def isMVar : Expr → Bool -| mvar _ _ => true -| _ => false + | mvar _ _ => true + | _ => false def isFVar : Expr → Bool -| fvar _ _ => true -| _ => false + | fvar _ _ => true + | _ => false def isApp : Expr → Bool -| app _ _ _ => true -| _ => false + | app .. => true + | _ => false def isProj : Expr → Bool -| proj _ _ _ _ => true -| _ => false + | proj .. => true + | _ => false def isConst : Expr → Bool -| const _ _ _ => true -| _ => false + | const .. => true + | _ => false def isConstOf : Expr → Name → Bool -| const n _ _, m => n == m -| _, _ => false + | const n _ _, m => n == m + | _, _ => false def isForall : Expr → Bool -| forallE _ _ _ _ => true -| _ => false + | forallE .. => true + | _ => false def isLambda : Expr → Bool -| lam _ _ _ _ => true -| _ => false + | lam .. => true + | _ => false def isBinding : Expr → Bool -| lam _ _ _ _ => true -| forallE _ _ _ _ => true -| _ => false + | lam .. => true + | forallE .. => true + | _ => false def isLet : Expr → Bool -| letE _ _ _ _ _ => true -| _ => false + | letE .. => true + | _ => false def isMData : Expr → Bool -| mdata _ _ _ => true -| _ => false + | mdata .. => true + | _ => false def isLit : Expr → Bool -| lit _ _ => true -| _ => false + | lit .. => true + | _ => false def getAppFn : Expr → Expr -| app f a _ => getAppFn f -| e => e + | app f a _ => getAppFn f + | e => e def getAppNumArgsAux : Expr → Nat → Nat -| app f a _, n => getAppNumArgsAux f (n+1) -| e, n => n + | app f a _, n => getAppNumArgsAux f (n+1) + | e, n => n def getAppNumArgs (e : Expr) : Nat := -getAppNumArgsAux e 0 + getAppNumArgsAux e 0 private def getAppArgsAux : Expr → Array Expr → Nat → Array Expr -| app f a _, as, i => getAppArgsAux f (as.set! i a) (i-1) -| _, as, _ => as + | app f a _, as, i => getAppArgsAux f (as.set! i a) (i-1) + | _, as, _ => as @[inline] def getAppArgs (e : Expr) : Array Expr := -let dummy := mkSort levelZero -let nargs := e.getAppNumArgs -getAppArgsAux e (mkArray nargs dummy) (nargs-1) + let dummy := mkSort levelZero + let nargs := e.getAppNumArgs + getAppArgsAux e (mkArray nargs dummy) (nargs-1) private def getAppRevArgsAux : Expr → Array Expr → Array Expr -| app f a _, as => getAppRevArgsAux f (as.push a) -| _, as => as + | app f a _, as => getAppRevArgsAux f (as.push a) + | _, as => as @[inline] def getAppRevArgs (e : Expr) : Array Expr := -getAppRevArgsAux e (Array.mkEmpty e.getAppNumArgs) + getAppRevArgsAux e (Array.mkEmpty e.getAppNumArgs) @[specialize] def withAppAux {α} (k : Expr → Array Expr → α) : Expr → Array Expr → Nat → α -| app f a _, as, i => withAppAux k f (as.set! i a) (i-1) -| f, as, i => k f as + | app f a _, as, i => withAppAux k f (as.set! i a) (i-1) + | f, as, i => k f as @[inline] def withApp {α} (e : Expr) (k : Expr → Array Expr → α) : α := -let dummy := mkSort levelZero -let nargs := e.getAppNumArgs -withAppAux k e (mkArray nargs dummy) (nargs-1) + let dummy := mkSort levelZero + let nargs := e.getAppNumArgs + withAppAux k e (mkArray nargs dummy) (nargs-1) @[specialize] private def withAppRevAux {α} (k : Expr → Array Expr → α) : Expr → Array Expr → α -| app f a _, as => withAppRevAux k f (as.push a) -| f, as => k f as + | app f a _, as => withAppRevAux k f (as.push a) + | f, as => k f as @[inline] def withAppRev {α} (e : Expr) (k : Expr → Array Expr → α) : α := -withAppRevAux k e (Array.mkEmpty e.getAppNumArgs) + withAppRevAux k e (Array.mkEmpty e.getAppNumArgs) def getRevArgD : Expr → Nat → Expr → Expr -| app f a _, 0, _ => a -| app f _ _, i+1, v => getRevArgD f i v -| _, _, v => v + | app f a _, 0, _ => a + | app f _ _, i+1, v => getRevArgD f i v + | _, _, v => v def getRevArg! : Expr → Nat → Expr -| app f a _, 0 => a -| app f _ _, i+1 => getRevArg! f i -| _, _ => panic! "invalid index" + | app f a _, 0 => a + | app f _ _, i+1 => getRevArg! f i + | _, _ => panic! "invalid index" @[inline] def getArg! (e : Expr) (i : Nat) (n := e.getAppNumArgs) : Expr := -getRevArg! e (n - i - 1) + getRevArg! e (n - i - 1) @[inline] def getArgD (e : Expr) (i : Nat) (v₀ : Expr) (n := e.getAppNumArgs) : Expr := -getRevArgD e (n - i - 1) v₀ + getRevArgD e (n - i - 1) v₀ def isAppOf (e : Expr) (n : Name) : Bool := -match e.getAppFn with -| const c _ _ => c == n -| _ => false + match e.getAppFn with + | const c _ _ => c == n + | _ => false def isAppOfArity : Expr → Name → Nat → Bool -| const c _ _, n, 0 => c == n -| app f _ _, n, a+1 => isAppOfArity f n a -| _, _, _ => false + | const c _ _, n, 0 => c == n + | app f _ _, n, a+1 => isAppOfArity f n a + | _, _, _ => false def appFn! : Expr → Expr -| app f _ _ => f -| _ => panic! "application expected" + | app f _ _ => f + | _ => panic! "application expected" def appArg! : Expr → Expr -| app _ a _ => a -| _ => panic! "application expected" + | app _ a _ => a + | _ => panic! "application expected" def isNatLit : Expr → Bool -| lit (Literal.natVal _) _ => true -| _ => false + | lit (Literal.natVal _) _ => true + | _ => false def natLit? : Expr → Option Nat -| lit (Literal.natVal v) _ => v -| _ => none + | lit (Literal.natVal v) _ => v + | _ => none def isStringLit : Expr → Bool -| lit (Literal.strVal _) _ => true -| _ => false + | lit (Literal.strVal _) _ => true + | _ => false def isCharLit (e : Expr) : Bool := -e.isAppOfArity `Char.ofNat 1 && e.appArg!.isNatLit + e.isAppOfArity `Char.ofNat 1 && e.appArg!.isNatLit def constName! : Expr → Name -| const n _ _ => n -| _ => panic! "constant expected" + | const n _ _ => n + | _ => panic! "constant expected" def constName? : Expr → Option Name -| const n _ _ => some n -| _ => none + | const n _ _ => some n + | _ => none def constLevels! : Expr → List Level -| const _ ls _ => ls -| _ => panic! "constant expected" + | const _ ls _ => ls + | _ => panic! "constant expected" def bvarIdx! : Expr → Nat -| bvar idx _ => idx -| _ => panic! "bvar expected" + | bvar idx _ => idx + | _ => panic! "bvar expected" def fvarId! : Expr → FVarId -| fvar n _ => n -| _ => panic! "fvar expected" + | fvar n _ => n + | _ => panic! "fvar expected" def mvarId! : Expr → MVarId -| mvar n _ => n -| _ => panic! "mvar expected" + | mvar n _ => n + | _ => panic! "mvar expected" def bindingName! : Expr → Name -| forallE n _ _ _ => n -| lam n _ _ _ => n -| _ => panic! "binding expected" + | forallE n _ _ _ => n + | lam n _ _ _ => n + | _ => panic! "binding expected" def bindingDomain! : Expr → Expr -| forallE _ d _ _ => d -| lam _ d _ _ => d -| _ => panic! "binding expected" + | forallE _ d _ _ => d + | lam _ d _ _ => d + | _ => panic! "binding expected" def bindingBody! : Expr → Expr -| forallE _ _ b _ => b -| lam _ _ b _ => b -| _ => panic! "binding expected" + | forallE _ _ b _ => b + | lam _ _ b _ => b + | _ => panic! "binding expected" def bindingInfo! : Expr → BinderInfo -| forallE _ _ _ c => c.binderInfo -| lam _ _ _ c => c.binderInfo -| _ => panic! "binding expected" + | forallE _ _ _ c => c.binderInfo + | lam _ _ _ c => c.binderInfo + | _ => panic! "binding expected" def letName! : Expr → Name -| letE n _ _ _ _ => n -| _ => panic! "let expression expected" + | letE n _ _ _ _ => n + | _ => panic! "let expression expected" def consumeMData : Expr → Expr -| mdata _ e _ => consumeMData e -| e => e + | mdata _ e _ => consumeMData e + | e => e def hasLooseBVars (e : Expr) : Bool := -e.looseBVarRange > 0 + e.looseBVarRange > 0 @[extern "lean_expr_has_loose_bvar"] -constant hasLooseBVar (e : @& Expr) (bvarIdx : @& Nat) : Bool := arbitrary _ +constant hasLooseBVar (e : @& Expr) (bvarIdx : @& Nat) : Bool /-- Return true if `e` contains the loose bound variable `bvarIdx` in an explicit parameter, or in the range if `tryRange == true`. -/ def hasLooseBVarInExplicitDomain : Expr → Nat → Bool → Bool -| Expr.forallE _ d b c, bvarIdx, tryRange => (c.binderInfo.isExplicit && hasLooseBVar d bvarIdx) || hasLooseBVarInExplicitDomain b (bvarIdx+1) tryRange -| e, bvarIdx, tryRange => tryRange && hasLooseBVar e bvarIdx + | Expr.forallE _ d b c, bvarIdx, tryRange => (c.binderInfo.isExplicit && hasLooseBVar d bvarIdx) || hasLooseBVarInExplicitDomain b (bvarIdx+1) tryRange + | e, bvarIdx, tryRange => tryRange && hasLooseBVar e bvarIdx /-- Lower the loose bound variables `>= s` in `e` by `d`. @@ -615,12 +615,12 @@ def hasLooseBVarInExplicitDomain : Expr → Nat → Bool → Bool Remark: if `s < d`, then result is `e` -/ @[extern "lean_expr_lower_loose_bvars"] -constant lowerLooseBVars (e : @& Expr) (s d : @& Nat) : Expr := arbitrary _ +constant lowerLooseBVars (e : @& Expr) (s d : @& Nat) : Expr /-- Lift loose bound variables `>= s` in `e` by `d`. -/ @[extern "lean_expr_lift_loose_bvars"] -constant liftLooseBVars (e : @& Expr) (s d : @& Nat) : Expr := arbitrary _ +constant liftLooseBVars (e : @& Expr) (s d : @& Nat) : Expr /-- `inferImplicit e numParams considerRange` updates the first `numParams` parameter binder annotations of the `e` forall type. @@ -631,70 +631,68 @@ constant liftLooseBVars (e : @& Expr) (s d : @& Nat) : Expr := arbitrary _ When the `{}` annotation is used in these commands, we set `considerRange == false`. -/ def inferImplicit : Expr → Nat → Bool → Expr -| Expr.forallE n d b c, i+1, considerRange => - let b := inferImplicit b i considerRange - let newInfo := if c.binderInfo.isExplicit && hasLooseBVarInExplicitDomain b 0 considerRange then BinderInfo.implicit else c.binderInfo - mkForall n newInfo d b -| e, 0, _ => e -| e, _, _ => e + | Expr.forallE n d b c, i+1, considerRange => + let b := inferImplicit b i considerRange + let newInfo := if c.binderInfo.isExplicit && hasLooseBVarInExplicitDomain b 0 considerRange then BinderInfo.implicit else c.binderInfo + mkForall n newInfo d b + | e, 0, _ => e + | e, _, _ => e /-- Instantiate the loose bound variables in `e` using `subst`. That is, a loose `Expr.bvar i` is replaced with `subst[i]`. -/ @[extern "lean_expr_instantiate"] -constant instantiate (e : @& Expr) (subst : @& Array Expr) : Expr := arbitrary _ +constant instantiate (e : @& Expr) (subst : @& Array Expr) : Expr @[extern "lean_expr_instantiate1"] -constant instantiate1 (e : @& Expr) (subst : @& Expr) : Expr := arbitrary _ +constant instantiate1 (e : @& Expr) (subst : @& Expr) : Expr /-- Similar to instantiate, but `Expr.bvar i` is replaced with `subst[subst.size - i - 1]` -/ @[extern "lean_expr_instantiate_rev"] -constant instantiateRev (e : @& Expr) (subst : @& Array Expr) : Expr := arbitrary _ +constant instantiateRev (e : @& Expr) (subst : @& Array Expr) : Expr /-- Similar to `instantiate`, but consider only the variables `xs` in the range `[beginIdx, endIdx)`. Function panics if `beginIdx <= endIdx <= xs.size` does not hold. -/ @[extern "lean_expr_instantiate_range"] -constant instantiateRange (e : @& Expr) (beginIdx endIdx : @& Nat) (xs : @& Array Expr) : Expr := arbitrary _ +constant instantiateRange (e : @& Expr) (beginIdx endIdx : @& Nat) (xs : @& Array Expr) : Expr /-- Similar to `instantiateRev`, but consider only the variables `xs` in the range `[beginIdx, endIdx)`. Function panics if `beginIdx <= endIdx <= xs.size` does not hold. -/ @[extern "lean_expr_instantiate_rev_range"] -constant instantiateRevRange (e : @& Expr) (beginIdx endIdx : @& Nat) (xs : @& Array Expr) : Expr := arbitrary _ +constant instantiateRevRange (e : @& Expr) (beginIdx endIdx : @& Nat) (xs : @& Array Expr) : Expr /-- Replace free variables `xs` with loose bound variables. -/ @[extern "lean_expr_abstract"] -constant abstract (e : @& Expr) (xs : @& Array Expr) : Expr := arbitrary _ +constant abstract (e : @& Expr) (xs : @& Array Expr) : Expr /-- Similar to `abstract`, but consider only the first `min n xs.size` entries in `xs`. -/ @[extern "lean_expr_abstract_range"] -constant abstractRange (e : @& Expr) (n : @& Nat) (xs : @& Array Expr) : Expr := arbitrary _ +constant abstractRange (e : @& Expr) (n : @& Nat) (xs : @& Array Expr) : Expr /-- Replace occurrences of the free variable `fvar` in `e` with `v` -/ def replaceFVar (e : Expr) (fvar : Expr) (v : Expr) : Expr := -(e.abstract #[fvar]).instantiate1 v + (e.abstract #[fvar]).instantiate1 v /-- Replace occurrences of the free variable `fvarId` in `e` with `v` -/ def replaceFVarId (e : Expr) (fvarId : FVarId) (v : Expr) : Expr := -replaceFVar e (mkFVar fvarId) v + replaceFVar e (mkFVar fvarId) v /-- Replace occurrences of the free variables `fvars` in `e` with `vs` -/ def replaceFVars (e : Expr) (fvars : Array Expr) (vs : Array Expr) : Expr := -(e.abstract fvars).instantiateRev vs + (e.abstract fvars).instantiateRev vs -instance : HasToString Expr := -⟨Expr.dbgToString⟩ +instance : HasToString Expr := ⟨Expr.dbgToString⟩ -- TODO: should not use dbgToString, but constructors. -instance : HasRepr Expr := -⟨Expr.dbgToString⟩ +instance : HasRepr Expr := ⟨Expr.dbgToString⟩ def isAtomic : Expr → Bool -| Expr.const _ _ _ => true -| Expr.sort _ _ => true -| Expr.bvar _ _ => true -| Expr.lit _ _ => true -| Expr.mvar _ _ => true -| Expr.fvar _ _ => true -| _ => false + | Expr.const _ _ _ => true + | Expr.sort _ _ => true + | Expr.bvar _ _ => true + | Expr.lit _ _ => true + | Expr.mvar _ _ => true + | Expr.fvar _ _ => true + | _ => false end Expr @@ -710,10 +708,10 @@ def mkApp9 (f a b c d e₁ e₂ e₃ e₄ e₅ : Expr) := mkApp5 (mkApp4 f a b c def mkApp10 (f a b c d e₁ e₂ e₃ e₄ e₅ e₆ : Expr) := mkApp6 (mkApp4 f a b c d) e₁ e₂ e₃ e₄ e₅ e₆ def mkDecIsTrue (pred proof : Expr) := -mkAppB (mkConst `Decidable.isTrue) pred proof + mkAppB (mkConst `Decidable.isTrue) pred proof def mkDecIsFalse (pred proof : Expr) := -mkAppB (mkConst `Decidable.isFalse) pred proof + mkAppB (mkConst `Decidable.isFalse) pred proof open Std (HashMap HashSet PHashMap PHashSet) @@ -725,17 +723,17 @@ abbrev PExprSet := PersistentExprSet /- Auxiliary type for forcing `==` to be structural equality for `Expr` -/ structure ExprStructEq := -(val : Expr) + (val : Expr) instance : Coe Expr ExprStructEq := ⟨ExprStructEq.mk⟩ namespace ExprStructEq protected def beq : ExprStructEq → ExprStructEq → Bool -| ⟨e₁⟩, ⟨e₂⟩ => Expr.equal e₁ e₂ + | ⟨e₁⟩, ⟨e₂⟩ => Expr.equal e₁ e₂ protected def hash : ExprStructEq → USize -| ⟨e⟩ => e.hash + | ⟨e⟩ => e.hash instance : Inhabited ExprStructEq := ⟨{ val := arbitrary _ }⟩ instance : HasBeq ExprStructEq := ⟨ExprStructEq.beq⟩ @@ -758,19 +756,19 @@ private partial def mkAppRevRangeAux (revArgs : Array Expr) (start : Nat) (b : E /-- `mkAppRevRange f b e args == mkAppRev f (revArgs.extract b e)` -/ def mkAppRevRange (f : Expr) (beginIdx endIdx : Nat) (revArgs : Array Expr) : Expr := -mkAppRevRangeAux revArgs beginIdx f endIdx + mkAppRevRangeAux revArgs beginIdx f endIdx private def betaRevAux (revArgs : Array Expr) (sz : Nat) : Expr → Nat → Expr -| Expr.lam _ _ b _, i => - if i + 1 < sz then - betaRevAux revArgs sz b (i+1) - else - let n := sz - (i + 1) + | Expr.lam _ _ b _, i => + if i + 1 < sz then + betaRevAux revArgs sz b (i+1) + else + let n := sz - (i + 1) + mkAppRevRange (b.instantiateRange n sz revArgs) 0 n revArgs + | Expr.mdata _ b _, i => betaRevAux revArgs sz b i + | b, i => + let n := sz - i mkAppRevRange (b.instantiateRange n sz revArgs) 0 n revArgs -| Expr.mdata _ b _, i => betaRevAux revArgs sz b i -| b, i => - let n := sz - i - mkAppRevRange (b.instantiateRange n sz revArgs) 0 n revArgs /-- If `f` is a lambda expression, than "beta-reduce" it using `revArgs`. This function is often used with `getAppRev` or `withAppRev`. @@ -783,29 +781,29 @@ private def betaRevAux (revArgs : Array Expr) (sz : Nat) : Expr → Nat → Expr `args := t.getAppRev` is `#[d, c, b, a]`, and `betaRev (fun x y => t x y) #[d, c, b, a]` is `t a b c d`. -/ def betaRev (f : Expr) (revArgs : Array Expr) : Expr := -if revArgs.size == 0 then f -else betaRevAux revArgs revArgs.size f 0 + if revArgs.size == 0 then f + else betaRevAux revArgs revArgs.size f 0 def isHeadBetaTargetFn : Expr → Bool -| Expr.lam _ _ _ _ => true -| Expr.mdata _ b _ => isHeadBetaTargetFn b -| _ => false + | Expr.lam _ _ _ _ => true + | Expr.mdata _ b _ => isHeadBetaTargetFn b + | _ => false def headBeta (e : Expr) : Expr := -let f := e.getAppFn -if f.isHeadBetaTargetFn then betaRev f e.getAppRevArgs else e + let f := e.getAppFn + if f.isHeadBetaTargetFn then betaRev f e.getAppRevArgs else e def isHeadBetaTarget (e : Expr) : Bool := -e.getAppFn.isHeadBetaTargetFn + e.getAppFn.isHeadBetaTargetFn private def etaExpandedBody : Expr → Nat → Nat → Option Expr -| app f (bvar j _) _, n+1, i => if j == i then etaExpandedBody f n (i+1) else none -| _, n+1, _ => none -| f, 0, _ => if f.hasLooseBVars then none else some f + | app f (bvar j _) _, n+1, i => if j == i then etaExpandedBody f n (i+1) else none + | _, n+1, _ => none + | f, 0, _ => if f.hasLooseBVars then none else some f private def etaExpandedAux : Expr → Nat → Option Expr -| lam _ _ b _, n => etaExpandedAux b (n+1) -| e, n => etaExpandedBody e n 0 + | lam _ _ b _, n => etaExpandedAux b (n+1) + | e, n => etaExpandedBody e n 0 /-- If `e` is of the form `(fun x₁ ... xₙ => f x₁ ... xₙ)` and `f` does not contain `x₁`, ..., `xₙ`, @@ -815,45 +813,45 @@ private def etaExpandedAux : Expr → Nat → Option Expr Remark: `ₙ` may be 0 -/ def etaExpanded? (e : Expr) : Option Expr := -etaExpandedAux e 0 + etaExpandedAux e 0 /-- Similar to `etaExpanded?`, but only succeeds if `ₙ ≥ 1`. -/ def etaExpandedStrict? : Expr → Option Expr -| lam _ _ b _ => etaExpandedAux b 1 -| _ => none + | lam _ _ b _ => etaExpandedAux b 1 + | _ => none def getOptParamDefault? (e : Expr) : Option Expr := -if e.isAppOfArity `optParam 2 then - some e.appArg! -else - none + if e.isAppOfArity `optParam 2 then + some e.appArg! + else + none def getAutoParamTactic? (e : Expr) : Option Expr := -if e.isAppOfArity `autoParam 2 then - some e.appArg! -else - none + if e.isAppOfArity `autoParam 2 then + some e.appArg! + else + none def isOptParam (e : Expr) : Bool := -e.isAppOfArity `optParam 2 + e.isAppOfArity `optParam 2 def isAutoParam (e : Expr) : Bool := -e.isAppOfArity `autoParam 2 + e.isAppOfArity `autoParam 2 /-- Return true iff `e` contains a free variable which statisfies `p`. -/ @[inline] def hasAnyFVar (e : Expr) (p : FVarId → Bool) : Bool := -let rec @[specialize] visit (e : Expr) := if !e.hasFVar then false else - match e with - | Expr.forallE _ d b _ => visit d || visit b - | Expr.lam _ d b _ => visit d || visit b - | Expr.mdata _ e _ => visit e - | Expr.letE _ t v b _ => visit t || visit v || visit b - | Expr.app f a _ => visit f || visit a - | Expr.proj _ _ e _ => visit e - | Expr.localE _ _ _ _ => unreachable! - | e@(Expr.fvar fvarId _) => p fvarId - | e => false -visit e + let rec @[specialize] visit (e : Expr) := if !e.hasFVar then false else + match e with + | Expr.forallE _ d b _ => visit d || visit b + | Expr.lam _ d b _ => visit d || visit b + | Expr.mdata _ e _ => visit e + | Expr.letE _ t v b _ => visit t || visit v || visit b + | Expr.app f a _ => visit f || visit a + | Expr.proj _ _ e _ => visit e + | Expr.localE _ _ _ _ => unreachable! + | e@(Expr.fvar fvarId _) => p fvarId + | e => false + visit e /- The update functions here are defined using C code. They will try to avoid @@ -867,145 +865,145 @@ visit e @[extern "lean_expr_update_app"] def updateApp (e : Expr) (newFn : Expr) (newArg : Expr) (h : e.isApp = true) : Expr := -mkApp newFn newArg + mkApp newFn newArg @[inline] def updateApp! (e : Expr) (newFn : Expr) (newArg : Expr) : Expr := -match e with -| app fn arg c => updateApp (app fn arg c) newFn newArg rfl -| _ => panic! "application expected" + match e with + | app fn arg c => updateApp (app fn arg c) newFn newArg rfl + | _ => panic! "application expected" @[extern "lean_expr_update_const"] def updateConst (e : Expr) (newLevels : List Level) (h : e.isConst = true) : Expr := -mkConst e.constName! newLevels + mkConst e.constName! newLevels @[inline] def updateConst! (e : Expr) (newLevels : List Level) : Expr := -match e with -| const n ls c => updateConst (const n ls c) newLevels rfl -| _ => panic! "constant expected" + match e with + | const n ls c => updateConst (const n ls c) newLevels rfl + | _ => panic! "constant expected" @[extern "lean_expr_update_sort"] def updateSort (e : Expr) (newLevel : Level) (h : e.isSort = true) : Expr := -mkSort newLevel + mkSort newLevel @[inline] def updateSort! (e : Expr) (newLevel : Level) : Expr := -match e with -| sort l c => updateSort (sort l c) newLevel rfl -| _ => panic! "level expected" + match e with + | sort l c => updateSort (sort l c) newLevel rfl + | _ => panic! "level expected" @[extern "lean_expr_update_proj"] def updateProj (e : Expr) (newExpr : Expr) (h : e.isProj = true) : Expr := -match e with -| proj s i _ _ => mkProj s i newExpr -| _ => e -- unreachable because of `h` + match e with + | proj s i _ _ => mkProj s i newExpr + | _ => e -- unreachable because of `h` @[extern "lean_expr_update_mdata"] def updateMData (e : Expr) (newExpr : Expr) (h : e.isMData = true) : Expr := -match e with -| mdata d _ _ => mkMData d newExpr -| _ => e -- unreachable because of `h` + match e with + | mdata d _ _ => mkMData d newExpr + | _ => e -- unreachable because of `h` @[inline] def updateMData! (e : Expr) (newExpr : Expr) : Expr := -match e with -| mdata d e c => updateMData (mdata d e c) newExpr rfl -| _ => panic! "mdata expected" + match e with + | mdata d e c => updateMData (mdata d e c) newExpr rfl + | _ => panic! "mdata expected" @[inline] def updateProj! (e : Expr) (newExpr : Expr) : Expr := -match e with -| proj s i e c => updateProj (proj s i e c) newExpr rfl -| _ => panic! "proj expected" + match e with + | proj s i e c => updateProj (proj s i e c) newExpr rfl + | _ => panic! "proj expected" @[extern "lean_expr_update_forall"] def updateForall (e : Expr) (newBinfo : BinderInfo) (newDomain : Expr) (newBody : Expr) (h : e.isForall = true) : Expr := -mkForall e.bindingName! newBinfo newDomain newBody + mkForall e.bindingName! newBinfo newDomain newBody @[inline] def updateForall! (e : Expr) (newBinfo : BinderInfo) (newDomain : Expr) (newBody : Expr) : Expr := -match e with -| forallE n d b c => updateForall (forallE n d b c) newBinfo newDomain newBody rfl -| _ => panic! "forall expected" + match e with + | forallE n d b c => updateForall (forallE n d b c) newBinfo newDomain newBody rfl + | _ => panic! "forall expected" @[inline] def updateForallE! (e : Expr) (newDomain : Expr) (newBody : Expr) : Expr := -match e with -| forallE n d b c => updateForall (forallE n d b c) c.binderInfo newDomain newBody rfl -| _ => panic! "forall expected" + match e with + | forallE n d b c => updateForall (forallE n d b c) c.binderInfo newDomain newBody rfl + | _ => panic! "forall expected" @[extern "lean_expr_update_lambda"] def updateLambda (e : Expr) (newBinfo : BinderInfo) (newDomain : Expr) (newBody : Expr) (h : e.isLambda = true) : Expr := -mkLambda e.bindingName! newBinfo newDomain newBody + mkLambda e.bindingName! newBinfo newDomain newBody @[inline] def updateLambda! (e : Expr) (newBinfo : BinderInfo) (newDomain : Expr) (newBody : Expr) : Expr := -match e with -| lam n d b c => updateLambda (lam n d b c) newBinfo newDomain newBody rfl -| _ => panic! "lambda expected" + match e with + | lam n d b c => updateLambda (lam n d b c) newBinfo newDomain newBody rfl + | _ => panic! "lambda expected" @[inline] def updateLambdaE! (e : Expr) (newDomain : Expr) (newBody : Expr) : Expr := -match e with -| lam n d b c => updateLambda (lam n d b c) c.binderInfo newDomain newBody rfl -| _ => panic! "lambda expected" + match e with + | lam n d b c => updateLambda (lam n d b c) c.binderInfo newDomain newBody rfl + | _ => panic! "lambda expected" @[extern "lean_expr_update_let"] def updateLet (e : Expr) (newType : Expr) (newVal : Expr) (newBody : Expr) (h : e.isLet = true) : Expr := -mkLet e.letName! newType newVal newBody + mkLet e.letName! newType newVal newBody @[inline] def updateLet! (e : Expr) (newType : Expr) (newVal : Expr) (newBody : Expr) : Expr := -match e with -| letE n t v b c => updateLet (letE n t v b c) newType newVal newBody rfl -| _ => panic! "let expression expected" + match e with + | letE n t v b c => updateLet (letE n t v b c) newType newVal newBody rfl + | _ => panic! "let expression expected" def updateFn : Expr → Expr → Expr -| e@(app f a _), g => e.updateApp! (updateFn f g) a -| _, g => g + | e@(app f a _), g => e.updateApp! (updateFn f g) a + | _, g => g /- Instantiate level parameters -/ @[inline] def instantiateLevelParamsCore (s : Name → Option Level) (e : Expr) : Expr := -let rec @[specialize] visit (e : Expr) : Expr := - if !e.hasLevelParam then e - else match e with - | lam n d b _ => e.updateLambdaE! (visit d) (visit b) - | forallE n d b _ => e.updateForallE! (visit d) (visit b) - | letE n t v b _ => e.updateLet! (visit t) (visit v) (visit b) - | app f a _ => e.updateApp! (visit f) (visit a) - | proj _ _ s _ => e.updateProj! (visit s) - | mdata _ b _ => e.updateMData! (visit b) - | const _ us _ => e.updateConst! (us.map (fun u => u.instantiateParams s)) - | sort u _ => e.updateSort! (u.instantiateParams s) - | localE .. => unreachable! - | e => e -visit e + let rec @[specialize] visit (e : Expr) : Expr := + if !e.hasLevelParam then e + else match e with + | lam n d b _ => e.updateLambdaE! (visit d) (visit b) + | forallE n d b _ => e.updateForallE! (visit d) (visit b) + | letE n t v b _ => e.updateLet! (visit t) (visit v) (visit b) + | app f a _ => e.updateApp! (visit f) (visit a) + | proj _ _ s _ => e.updateProj! (visit s) + | mdata _ b _ => e.updateMData! (visit b) + | const _ us _ => e.updateConst! (us.map (fun u => u.instantiateParams s)) + | sort u _ => e.updateSort! (u.instantiateParams s) + | localE .. => unreachable! + | e => e + visit e private def getParamSubst : List Name → List Level → Name → Option Level -| p::ps, u::us, p' => if p == p' then some u else getParamSubst ps us p' -| _, _, _ => none + | p::ps, u::us, p' => if p == p' then some u else getParamSubst ps us p' + | _, _, _ => none def instantiateLevelParams (e : Expr) (paramNames : List Name) (lvls : List Level) : Expr := -instantiateLevelParamsCore (getParamSubst paramNames lvls) e + instantiateLevelParamsCore (getParamSubst paramNames lvls) e private partial def getParamSubstArray (ps : Array Name) (us : Array Level) (p' : Name) (i : Nat) : Option Level := -if h : i < ps.size then - let p := ps.get ⟨i, h⟩ - if h : i < us.size then - let u := us.get ⟨i, h⟩ - if p == p' then some u else getParamSubstArray ps us p' (i+1) + if h : i < ps.size then + let p := ps.get ⟨i, h⟩ + if h : i < us.size then + let u := us.get ⟨i, h⟩ + if p == p' then some u else getParamSubstArray ps us p' (i+1) + else none else none -else none def instantiateLevelParamsArray (e : Expr) (paramNames : Array Name) (lvls : Array Level) : Expr := -instantiateLevelParamsCore (fun p => getParamSubstArray paramNames lvls p 0) e + instantiateLevelParamsCore (fun p => getParamSubstArray paramNames lvls p 0) e end Expr def mkAnnotation (kind : Name) (e : Expr) : Expr := -mkMData (KVMap.empty.insert kind (DataValue.ofBool true)) e + mkMData (KVMap.empty.insert kind (DataValue.ofBool true)) e def annotation? (kind : Name) (e : Expr) : Option Expr := -match e with -| Expr.mdata d b _ => if d.size == 1 && d.getBool kind false then some b else none -| _ => none + match e with + | Expr.mdata d b _ => if d.size == 1 && d.getBool kind false then some b else none + | _ => none def mkFreshFVarId {m : Type → Type} [Monad m] [MonadNameGenerator m] : m FVarId := -mkFreshId + mkFreshId def mkFreshMVarId {m : Type → Type} [Monad m] [MonadNameGenerator m] : m FVarId := -mkFreshId + mkFreshId end Lean diff --git a/stage0/src/Lean/InternalExceptionId.lean b/stage0/src/Lean/InternalExceptionId.lean index 324f350dd2..4b64551ef0 100644 --- a/stage0/src/Lean/InternalExceptionId.lean +++ b/stage0/src/Lean/InternalExceptionId.lean @@ -7,30 +7,30 @@ Authors: Leonardo de Moura namespace Lean structure InternalExceptionId := -(idx : Nat := 0) + (idx : Nat := 0) instance : Inhabited InternalExceptionId := ⟨{}⟩ instance : HasBeq InternalExceptionId := -⟨fun id₁ id₂ => id₁.idx == id₂.idx⟩ + ⟨fun id₁ id₂ => id₁.idx == id₂.idx⟩ builtin_initialize internalExceptionsRef : IO.Ref (Array Name) ← IO.mkRef #[] def registerInternalExceptionId (name : Name) : IO InternalExceptionId := do -let exs ← internalExceptionsRef.get -if exs.contains name then throw $ IO.userError s!"invalid internal exception id, '{name}' has already been used" -let nextIdx := exs.size -internalExceptionsRef.modify fun a => a.push name -pure { idx := nextIdx } + let exs ← internalExceptionsRef.get + if exs.contains name then throw $ IO.userError s!"invalid internal exception id, '{name}' has already been used" + let nextIdx := exs.size + internalExceptionsRef.modify fun a => a.push name + pure { idx := nextIdx } def InternalExceptionId.toString (id : InternalExceptionId) : String := -s!"internal exception #{id.idx}" + s!"internal exception #{id.idx}" def InternalExceptionId.getName (id : InternalExceptionId) : IO Name := do -let exs ← internalExceptionsRef.get -let i := id.idx; -if h : i < exs.size then - pure $ exs.get ⟨i, h⟩ -else - throw $ IO.userError "invalid internal exception id" + let exs ← internalExceptionsRef.get + let i := id.idx; + if h : i < exs.size then + pure $ exs.get ⟨i, h⟩ + else + throw $ IO.userError "invalid internal exception id" end Lean diff --git a/stage0/src/Lean/KeyedDeclsAttribute.lean b/stage0/src/Lean/KeyedDeclsAttribute.lean index e1a5806c1a..a4e2c246b8 100644 --- a/stage0/src/Lean/KeyedDeclsAttribute.lean +++ b/stage0/src/Lean/KeyedDeclsAttribute.lean @@ -29,140 +29,140 @@ abbrev Key := Name Important: `mkConst valueTypeName` and `γ` must be definitionally equal. -/ structure Def (γ : Type) := -(builtinName : Name) -- Builtin attribute name (e.g., `builtinTermElab) -(name : Name) -- Attribute name (e.g., `termElab) -(descr : String) -- Attribute description -(valueTypeName : Name) --- Convert `Syntax` into a `Key`, the default implementation expects an identifier. -(evalKey : Bool → Syntax → AttrM Key := - fun builtin arg => match attrParamSyntaxToIdentifier arg with - | some id => pure id - | none => throwError "invalid attribute argument, expected identifier") + (builtinName : Name) -- Builtin attribute name (e.g., `builtinTermElab) + (name : Name) -- Attribute name (e.g., `termElab) + (descr : String) -- Attribute description + (valueTypeName : Name) + -- Convert `Syntax` into a `Key`, the default implementation expects an identifier. + (evalKey : Bool → Syntax → AttrM Key := + fun builtin arg => match attrParamSyntaxToIdentifier arg with + | some id => pure id + | none => throwError "invalid attribute argument, expected identifier") instance {γ} : Inhabited (Def γ) := -⟨{ builtinName := arbitrary _, name := arbitrary _, descr := arbitrary _, valueTypeName := arbitrary _ }⟩ + ⟨{ builtinName := arbitrary _, name := arbitrary _, descr := arbitrary _, valueTypeName := arbitrary _ }⟩ structure OLeanEntry := -(key : Key) -(decl : Name) -- Name of a declaration stored in the environment which has type `mkConst Def.valueTypeName`. + (key : Key) + (decl : Name) -- Name of a declaration stored in the environment which has type `mkConst Def.valueTypeName`. structure AttributeEntry (γ : Type) extends OLeanEntry := -/- Recall that we cannot store `γ` into .olean files because it is a closure. - Given `OLeanEntry.decl`, we convert it into a `γ` by using the unsafe function `evalConstCheck`. -/ -(value : γ) + /- Recall that we cannot store `γ` into .olean files because it is a closure. + Given `OLeanEntry.decl`, we convert it into a `γ` by using the unsafe function `evalConstCheck`. -/ + (value : γ) abbrev Table (γ : Type) := SMap Key (List γ) structure ExtensionState (γ : Type) := -(newEntries : List OLeanEntry := []) -(table : Table γ := {}) + (newEntries : List OLeanEntry := []) + (table : Table γ := {}) abbrev Extension (γ : Type) := PersistentEnvExtension OLeanEntry (AttributeEntry γ) (ExtensionState γ) end KeyedDeclsAttribute structure KeyedDeclsAttribute (γ : Type) := -(defn : KeyedDeclsAttribute.Def γ) --- imported/builtin instances -(tableRef : IO.Ref (KeyedDeclsAttribute.Table γ)) --- instances from current module -(ext : KeyedDeclsAttribute.Extension γ) + (defn : KeyedDeclsAttribute.Def γ) + -- imported/builtin instances + (tableRef : IO.Ref (KeyedDeclsAttribute.Table γ)) + -- instances from current module + (ext : KeyedDeclsAttribute.Extension γ) namespace KeyedDeclsAttribute def Table.insert {γ : Type} (table : Table γ) (k : Key) (v : γ) : Table γ := -match table.find? k with -| some vs => SMap.insert table k (v::vs) -| none => SMap.insert table k [v] + match table.find? k with + | some vs => SMap.insert table k (v::vs) + | none => SMap.insert table k [v] instance {γ} : Inhabited (ExtensionState γ) := ⟨{}⟩ instance {γ} : Inhabited (KeyedDeclsAttribute γ) := -⟨{ defn := arbitrary _, tableRef := arbitrary _, ext := arbitrary _ }⟩ + ⟨{ defn := arbitrary _, tableRef := arbitrary _, ext := arbitrary _ }⟩ private def mkInitial {γ} (tableRef : IO.Ref (Table γ)) : IO (ExtensionState γ) := do -let table ← tableRef.get -pure { table := table } + let table ← tableRef.get + pure { table := table } private unsafe def addImported {γ} (df : Def γ) (tableRef : IO.Ref (Table γ)) (es : Array (Array OLeanEntry)) : ImportM (ExtensionState γ) := do -let ctx ← read -let table ← tableRef.get -let table ← es.foldlM - (fun table entries => - entries.foldlM - (fun (table : Table γ) entry => - match ctx.env.evalConstCheck γ ctx.opts df.valueTypeName entry.decl with - | Except.ok f => pure $ table.insert entry.key f - | Except.error ex => throw (IO.userError ex)) - table) - table -pure { table := table } + let ctx ← read + let table ← tableRef.get + let table ← es.foldlM + (fun table entries => + entries.foldlM + (fun (table : Table γ) entry => + match ctx.env.evalConstCheck γ ctx.opts df.valueTypeName entry.decl with + | Except.ok f => pure $ table.insert entry.key f + | Except.error ex => throw (IO.userError ex)) + table) + table + pure { table := table } private def addExtensionEntry {γ} (s : ExtensionState γ) (e : AttributeEntry γ) : ExtensionState γ := -{ table := s.table.insert e.key e.value, newEntries := e.toOLeanEntry :: s.newEntries } + { table := s.table.insert e.key e.value, newEntries := e.toOLeanEntry :: s.newEntries } def addBuiltin {γ} (attr : KeyedDeclsAttribute γ) (key : Key) (val : γ) : IO Unit := -attr.tableRef.modify $ fun m => m.insert key val + attr.tableRef.modify $ fun m => m.insert key val /-- def _regBuiltin$(declName) : IO Unit := @addBuiltin $(mkConst valueTypeName) $(mkConst attrDeclName) $(key) $(mkConst declName) -/ def declareBuiltin {γ} (df : Def γ) (attrDeclName : Name) (env : Environment) (key : Key) (declName : Name) : IO Environment := -let name := `_regBuiltin ++ declName -let type := mkApp (mkConst `IO) (mkConst `Unit) -let val := mkAppN (mkConst `Lean.KeyedDeclsAttribute.addBuiltin) #[mkConst df.valueTypeName, mkConst attrDeclName, toExpr key, mkConst declName] -let decl := Declaration.defnDecl { name := name, lparams := [], type := type, value := val, hints := ReducibilityHints.opaque, isUnsafe := false } -match env.addAndCompile {} decl with --- TODO: pretty print error -| Except.error e => do - let msg ← (e.toMessageData {}).toString - throw (IO.userError s!"failed to emit registration code for builtin '{declName}': {msg}") -| Except.ok env => IO.ofExcept (setBuiltinInitAttr env name) + let name := `_regBuiltin ++ declName + let type := mkApp (mkConst `IO) (mkConst `Unit) + let val := mkAppN (mkConst `Lean.KeyedDeclsAttribute.addBuiltin) #[mkConst df.valueTypeName, mkConst attrDeclName, toExpr key, mkConst declName] + let decl := Declaration.defnDecl { name := name, lparams := [], type := type, value := val, hints := ReducibilityHints.opaque, isUnsafe := false } + match env.addAndCompile {} decl with + -- TODO: pretty print error + | Except.error e => do + let msg ← (e.toMessageData {}).toString + throw (IO.userError s!"failed to emit registration code for builtin '{declName}': {msg}") + | Except.ok env => IO.ofExcept (setBuiltinInitAttr env name) /- TODO: add support for scoped attributes -/ protected unsafe def init {γ} (df : Def γ) (attrDeclName : Name) : IO (KeyedDeclsAttribute γ) := do -let tableRef ← IO.mkRef ({} : Table γ) -let ext : Extension γ ← registerPersistentEnvExtension { - name := df.name, - mkInitial := mkInitial tableRef, - addImportedFn := addImported df tableRef, - addEntryFn := addExtensionEntry, - exportEntriesFn := fun s => s.newEntries.reverse.toArray, - statsFn := fun s => f!"number of local entries: {s.newEntries.length}" -} -registerBuiltinAttribute { - name := df.builtinName, - descr := "(builtin) " ++ df.descr, - add := fun declName arg persistent => do - unless persistent do throwError! "invalid attribute '{df.builtinName}', must be persistent" - let key ← df.evalKey true arg - let decl ← getConstInfo declName - match decl.type with - | Expr.const c _ _ => - if c != df.valueTypeName then throwError! "unexpected type at '{declName}', '{df.valueTypeName}' expected" - else - let env ← getEnv - let env ← liftIO $ declareBuiltin df attrDeclName env key declName - setEnv env - | _ => throwError! "unexpected type at '{declName}', '{df.valueTypeName}' expected", - applicationTime := AttributeApplicationTime.afterCompilation -} -registerBuiltinAttribute { - name := df.name, - descr := df.descr, - add := fun constName arg persistent => do - let key ← df.evalKey false arg - let val ← evalConstCheck γ df.valueTypeName constName - let env ← getEnv - setEnv $ ext.addEntry env { key := key, decl := constName, value := val }, - applicationTime := AttributeApplicationTime.afterCompilation -} -pure { defn := df, tableRef := tableRef, ext := ext } + let tableRef ← IO.mkRef ({} : Table γ) + let ext : Extension γ ← registerPersistentEnvExtension { + name := df.name, + mkInitial := mkInitial tableRef, + addImportedFn := addImported df tableRef, + addEntryFn := addExtensionEntry, + exportEntriesFn := fun s => s.newEntries.reverse.toArray, + statsFn := fun s => f!"number of local entries: {s.newEntries.length}" + } + registerBuiltinAttribute { + name := df.builtinName, + descr := "(builtin) " ++ df.descr, + add := fun declName arg persistent => do + unless persistent do throwError! "invalid attribute '{df.builtinName}', must be persistent" + let key ← df.evalKey true arg + let decl ← getConstInfo declName + match decl.type with + | Expr.const c _ _ => + if c != df.valueTypeName then throwError! "unexpected type at '{declName}', '{df.valueTypeName}' expected" + else + let env ← getEnv + let env ← liftIO $ declareBuiltin df attrDeclName env key declName + setEnv env + | _ => throwError! "unexpected type at '{declName}', '{df.valueTypeName}' expected", + applicationTime := AttributeApplicationTime.afterCompilation + } + registerBuiltinAttribute { + name := df.name, + descr := df.descr, + add := fun constName arg persistent => do + let key ← df.evalKey false arg + let val ← evalConstCheck γ df.valueTypeName constName + let env ← getEnv + setEnv $ ext.addEntry env { key := key, decl := constName, value := val }, + applicationTime := AttributeApplicationTime.afterCompilation + } + pure { defn := df, tableRef := tableRef, ext := ext } /-- Retrieve values tagged with `[attr key]` or `[builtinAttr key]`. -/ def getValues {γ} (attr : KeyedDeclsAttribute γ) (env : Environment) (key : Name) : List γ := -(attr.ext.getState env).table.findD key [] + (attr.ext.getState env).table.findD key [] end KeyedDeclsAttribute diff --git a/stage0/src/Lean/Level.lean b/stage0/src/Lean/Level.lean index 62ec9d54bc..ac880dca3a 100644 --- a/stage0/src/Lean/Level.lean +++ b/stage0/src/Lean/Level.lean @@ -25,62 +25,62 @@ namespace Lean def Level.Data := UInt64 instance : Inhabited Level.Data := -inferInstanceAs (Inhabited UInt64) + inferInstanceAs (Inhabited UInt64) def Level.Data.hash (c : Level.Data) : USize := -c.toUInt32.toUSize + c.toUInt32.toUSize instance : HasBeq Level.Data := -⟨fun (a b : UInt64) => a == b⟩ + ⟨fun (a b : UInt64) => a == b⟩ def Level.Data.depth (c : Level.Data) : UInt32 := -(c.shiftRight 40).toUInt32 + (c.shiftRight 40).toUInt32 def Level.Data.hasMVar (c : Level.Data) : Bool := -((c.shiftRight 32).land 1) == 1 + ((c.shiftRight 32).land 1) == 1 def Level.Data.hasParam (c : Level.Data) : Bool := -((c.shiftRight 33).land 1) == 1 + ((c.shiftRight 33).land 1) == 1 def Level.mkData (h : USize) (depth : Nat) (hasMVar hasParam : Bool) : Level.Data := -if depth > Nat.pow 2 24 - 1 then panic! "universe level depth is too big" -else - let r : UInt64 := h.toUInt32.toUInt64 + hasMVar.toUInt64.shiftLeft 32 + hasParam.toUInt64.shiftLeft 33 + depth.toUInt64.shiftLeft 40 - r + if depth > Nat.pow 2 24 - 1 then panic! "universe level depth is too big" + else + let r : UInt64 := h.toUInt32.toUInt64 + hasMVar.toUInt64.shiftLeft 32 + hasParam.toUInt64.shiftLeft 33 + depth.toUInt64.shiftLeft 40 + r open Level inductive Level -| zero : Data → Level -| succ : Level → Data → Level -| max : Level → Level → Data → Level -| imax : Level → Level → Data → Level -| param : Name → Data → Level -| mvar : Name → Data → Level + | zero : Data → Level + | succ : Level → Data → Level + | max : Level → Level → Data → Level + | imax : Level → Level → Data → Level + | param : Name → Data → Level + | mvar : Name → Data → Level namespace Level @[inline] def data : Level → Data -| zero d => d -| mvar _ d => d -| param _ d => d -| succ _ d => d -| max _ _ d => d -| imax _ _ d => d + | zero d => d + | mvar _ d => d + | param _ d => d + | succ _ d => d + | max _ _ d => d + | imax _ _ d => d protected def hash (u : Level) : USize := -u.data.hash + u.data.hash instance : Hashable Level := ⟨Level.hash⟩ def depth (u : Level) : Nat := -u.data.depth.toNat + u.data.depth.toNat def hasMVar (u : Level) : Bool := -u.data.hasMVar + u.data.hasMVar def hasParam (u : Level) : Bool := -u.data.hasParam + u.data.hasParam @[export lean_level_hash] def hashEx : Level → USize := Level.hash @[export lean_level_has_mvar] def hasMVarEx : Level → Bool := hasMVar @@ -90,26 +90,26 @@ u.data.hasParam end Level def levelZero := -Level.zero $ mkData 2221 0 false false + Level.zero $ mkData 2221 0 false false def mkLevelMVar (mvarId : Name) := -Level.mvar mvarId $ mkData (mixHash 2237 $ hash mvarId) 0 true false + Level.mvar mvarId $ mkData (mixHash 2237 $ hash mvarId) 0 true false def mkLevelParam (name : Name) := -Level.param name $ mkData (mixHash 2239 $ hash name) 0 false true + Level.param name $ mkData (mixHash 2239 $ hash name) 0 false true def mkLevelSucc (u : Level) := -Level.succ u $ mkData (mixHash 2243 $ hash u) (u.depth + 1) u.hasMVar u.hasParam + Level.succ u $ mkData (mixHash 2243 $ hash u) (u.depth + 1) u.hasMVar u.hasParam def mkLevelMax (u v : Level) := -Level.max u v $ mkData (mixHash 2251 $ mixHash (hash u) (hash v)) (Nat.max u.depth v.depth + 1) - (u.hasMVar || v.hasMVar) - (u.hasParam || v.hasParam) + Level.max u v $ mkData (mixHash 2251 $ mixHash (hash u) (hash v)) (Nat.max u.depth v.depth + 1) + (u.hasMVar || v.hasMVar) + (u.hasParam || v.hasParam) def mkLevelIMax (u v : Level) := -Level.imax u v $ mkData (mixHash 2267 $ mixHash (hash u) (hash v)) (Nat.max u.depth v.depth + 1) - (u.hasMVar || v.hasMVar) - (u.hasParam || v.hasParam) + Level.imax u v $ mkData (mixHash 2267 $ mixHash (hash u) (hash v)) (Nat.max u.depth v.depth + 1) + (u.hasMVar || v.hasMVar) + (u.hasParam || v.hasParam) def levelOne := mkLevelSucc levelZero @@ -125,79 +125,79 @@ namespace Level instance : Inhabited Level := ⟨levelZero⟩ def isZero : Level → Bool -| zero _ => true -| _ => false + | zero _ => true + | _ => false def isSucc : Level → Bool -| succ _ _ => true -| _ => false + | succ .. => true + | _ => false def isMax : Level → Bool -| max _ _ _ => true -| _ => false + | max .. => true + | _ => false def isIMax : Level → Bool -| imax _ _ _ => true -| _ => false + | imax .. => true + | _ => false def isMaxIMax : Level → Bool -| max _ _ _ => true -| imax _ _ _ => true -| _ => false + | max .. => true + | imax .. => true + | _ => false def isParam : Level → Bool -| param _ _ => true -| _ => false + | param .. => true + | _ => false def isMVar : Level → Bool -| mvar _ _ => true -| _ => false + | mvar .. => true + | _ => false def mvarId! : Level → Name -| mvar mvarId _ => mvarId -| _ => panic! "metavariable expected" + | mvar mvarId _ => mvarId + | _ => panic! "metavariable expected" /-- If result is true, then forall assignments `A` which assigns all parameters and metavariables occuring in `l`, `l[A] != zero` -/ def isNeverZero : Level → Bool -| zero _ => false -| param _ _ => false -| mvar _ _ => false -| succ _ _ => true -| max l₁ l₂ _ => isNeverZero l₁ || isNeverZero l₂ -| imax l₁ l₂ _ => isNeverZero l₂ + | zero _ => false + | param .. => false + | mvar .. => false + | succ .. => true + | max l₁ l₂ _ => isNeverZero l₁ || isNeverZero l₂ + | imax l₁ l₂ _ => isNeverZero l₂ def ofNat : Nat → Level -| 0 => levelZero -| n+1 => mkLevelSucc (ofNat n) + | 0 => levelZero + | n+1 => mkLevelSucc (ofNat n) def addOffsetAux : Nat → Level → Level -| 0, u => u -| (n+1), u => addOffsetAux n (mkLevelSucc u) + | 0, u => u + | (n+1), u => addOffsetAux n (mkLevelSucc u) def addOffset (u : Level) (n : Nat) : Level := -u.addOffsetAux n + u.addOffsetAux n def isExplicit : Level → Bool -| zero _ => true -| succ u _ => !u.hasMVar && !u.hasParam && isExplicit u -| _ => false + | zero _ => true + | succ u _ => !u.hasMVar && !u.hasParam && isExplicit u + | _ => false def getOffsetAux : Level → Nat → Nat -| succ u _, r => getOffsetAux u (r+1) -| _, r => r + | succ u _, r => getOffsetAux u (r+1) + | _, r => r def getOffset (lvl : Level) : Nat := - getOffsetAux lvl 0 + getOffsetAux lvl 0 def getLevelOffset : Level → Level -| succ u _ => getLevelOffset u -| u => u + | succ u _ => getLevelOffset u + | u => u def toNat (lvl : Level) : Option Nat := -match lvl.getLevelOffset with -| zero _ => lvl.getOffset -| _ => none + match lvl.getLevelOffset with + | zero _ => lvl.getOffset + | _ => none @[extern "lean_level_eq"] protected constant beq (a : @& Level) (b : @& Level) : Bool := arbitrary _ @@ -206,34 +206,34 @@ instance : HasBeq Level := ⟨Level.beq⟩ /-- `occurs u l` return `true` iff `u` occurs in `l`. -/ def occurs : Level → Level → Bool -| u, v@(succ v₁ _) => u == v || occurs u v₁ -| u, v@(max v₁ v₂ _) => u == v || occurs u v₁ || occurs u v₂ -| u, v@(imax v₁ v₂ _) => u == v || occurs u v₁ || occurs u v₂ -| u, v => u == v + | u, v@(succ v₁ _) => u == v || occurs u v₁ + | u, v@(max v₁ v₂ _) => u == v || occurs u v₁ || occurs u v₂ + | u, v@(imax v₁ v₂ _) => u == v || occurs u v₁ || occurs u v₂ + | u, v => u == v def ctorToNat : Level → Nat -| zero _ => 0 -| param _ _ => 1 -| mvar _ _ => 2 -| succ _ _ => 3 -| max _ _ _ => 4 -| imax _ _ _ => 5 +| zero .. => 0 +| param .. => 1 +| mvar .. => 2 +| succ .. => 3 +| max .. => 4 +| imax .. => 5 /- TODO: use well founded recursion. -/ partial def normLtAux : Level → Nat → Level → Nat → Bool -| succ l₁ _, k₁, l₂, k₂ => normLtAux l₁ (k₁+1) l₂ k₂ -| l₁, k₁, succ l₂ _, k₂ => normLtAux l₁ k₁ l₂ (k₂+1) -| l₁@(max l₁₁ l₁₂ _), k₁, l₂@(max l₂₁ l₂₂ _), k₂ => - if l₁ == l₂ then k₁ < k₂ - else if l₁₁ == l₂₁ then normLtAux l₁₁ 0 l₂₁ 0 - else normLtAux l₁₂ 0 l₂₂ 0 -| l₁@(imax l₁₁ l₁₂ _), k₁, l₂@(imax l₂₁ l₂₂ _), k₂ => - if l₁ == l₂ then k₁ < k₂ - else if l₁₁ == l₂₁ then normLtAux l₁₁ 0 l₂₁ 0 - else normLtAux l₁₂ 0 l₂₂ 0 -| param n₁ _, k₁, param n₂ _, k₂ => if n₁ == n₂ then k₁ < k₂ else Name.lt n₁ n₂ -- use Name.lt because it is lexicographical -| mvar n₁ _, k₁, mvar n₂ _, k₂ => if n₁ == n₂ then k₁ < k₂ else Name.quickLt n₁ n₂ -- metavariables are temporary, the actual order doesn't matter -| l₁, k₁, l₂, k₂ => if l₁ == l₂ then k₁ < k₂ else ctorToNat l₁ < ctorToNat l₂ + | succ l₁ _, k₁, l₂, k₂ => normLtAux l₁ (k₁+1) l₂ k₂ + | l₁, k₁, succ l₂ _, k₂ => normLtAux l₁ k₁ l₂ (k₂+1) + | l₁@(max l₁₁ l₁₂ _), k₁, l₂@(max l₂₁ l₂₂ _), k₂ => + if l₁ == l₂ then k₁ < k₂ + else if l₁₁ == l₂₁ then normLtAux l₁₁ 0 l₂₁ 0 + else normLtAux l₁₂ 0 l₂₂ 0 + | l₁@(imax l₁₁ l₁₂ _), k₁, l₂@(imax l₂₁ l₂₂ _), k₂ => + if l₁ == l₂ then k₁ < k₂ + else if l₁₁ == l₂₁ then normLtAux l₁₁ 0 l₂₁ 0 + else normLtAux l₁₂ 0 l₂₂ 0 + | param n₁ _, k₁, param n₂ _, k₂ => if n₁ == n₂ then k₁ < k₂ else Name.lt n₁ n₂ -- use Name.lt because it is lexicographical + | mvar n₁ _, k₁, mvar n₂ _, k₂ => if n₁ == n₂ then k₁ < k₂ else Name.quickLt n₁ n₂ -- metavariables are temporary, the actual order doesn't matter + | l₁, k₁, l₂, k₂ => if l₁ == l₂ then k₁ < k₂ else ctorToNat l₁ < ctorToNat l₂ /-- A total order on level expressions that has the following properties @@ -241,30 +241,30 @@ partial def normLtAux : Level → Nat → Level → Nat → Bool - `zero` is the minimal element. This total order is used in the normalization procedure. -/ def normLt (l₁ l₂ : Level) : Bool := -normLtAux l₁ 0 l₂ 0 + normLtAux l₁ 0 l₂ 0 private def isAlreadyNormalizedCheap : Level → Bool -| zero _ => true -| param _ _ => true -| mvar _ _ => true -| succ u _ => isAlreadyNormalizedCheap u -| _ => false + | zero _ => true + | param _ _ => true + | mvar _ _ => true + | succ u _ => isAlreadyNormalizedCheap u + | _ => false /- Auxiliary function used at `normalize` -/ private def mkIMaxAux : Level → Level → Level -| _, u@(zero _) => u -| zero _, u => u -| u₁, u₂ => if u₁ == u₂ then u₁ else mkLevelIMax u₁ u₂ + | _, u@(zero _) => u + | zero _, u => u + | u₁, u₂ => if u₁ == u₂ then u₁ else mkLevelIMax u₁ u₂ /- Auxiliary function used at `normalize` -/ @[specialize] private partial def getMaxArgsAux (normalize : Level → Level) : Level → Bool → Array Level → Array Level -| max l₁ l₂ _, alreadyNormalized, lvls => getMaxArgsAux normalize l₂ alreadyNormalized (getMaxArgsAux normalize l₁ alreadyNormalized lvls) -| l, false, lvls => getMaxArgsAux normalize (normalize l) true lvls -| l, true, lvls => lvls.push l + | max l₁ l₂ _, alreadyNormalized, lvls => getMaxArgsAux normalize l₂ alreadyNormalized (getMaxArgsAux normalize l₁ alreadyNormalized lvls) + | l, false, lvls => getMaxArgsAux normalize (normalize l) true lvls + | l, true, lvls => lvls.push l private def accMax (result : Level) (prev : Level) (offset : Nat) : Level := -if result.isZero then prev.addOffset offset -else mkLevelMax result (prev.addOffset offset) + if result.isZero then prev.addOffset offset + else mkLevelMax result (prev.addOffset offset) /- Auxiliary function used at `normalize`. Remarks: @@ -275,26 +275,26 @@ else mkLevelMax result (prev.addOffset offset) - `result` is the accumulator -/ private partial def mkMaxAux (lvls : Array Level) (extraK : Nat) (i : Nat) (prev : Level) (prevK : Nat) (result : Level) : Level := -if h : i < lvls.size then - let lvl := lvls.get ⟨i, h⟩ - let curr := lvl.getLevelOffset - let currK := lvl.getOffset - if curr == prev then - mkMaxAux lvls extraK (i+1) curr currK result + if h : i < lvls.size then + let lvl := lvls.get ⟨i, h⟩ + let curr := lvl.getLevelOffset + let currK := lvl.getOffset + if curr == prev then + mkMaxAux lvls extraK (i+1) curr currK result + else + mkMaxAux lvls extraK (i+1) curr currK (accMax result prev (extraK + prevK)) else - mkMaxAux lvls extraK (i+1) curr currK (accMax result prev (extraK + prevK)) -else - accMax result prev (extraK + prevK) + accMax result prev (extraK + prevK) /- Auxiliary function for `normalize`. It assumes `lvls` has been sorted using `normLt`. It finds the first position that is not an explicit universe. -/ private partial def skipExplicit (lvls : Array Level) (i : Nat) : Nat := -if h : i < lvls.size then - let lvl := lvls.get ⟨i, h⟩ - if lvl.getLevelOffset.isZero then skipExplicit lvls (i+1) else i -else - i + if h : i < lvls.size then + let lvl := lvls.get ⟨i, h⟩ + if lvl.getLevelOffset.isZero then skipExplicit lvls (i+1) else i + else + i /- Auxiliary function for `normalize`. @@ -303,19 +303,19 @@ else `i` starts at the first non explict level. It assumes `lvls` has been sorted using `normLt`. -/ private partial def isExplicitSubsumedAux (lvls : Array Level) (maxExplicit : Nat) (i : Nat) : Bool := -if h : i < lvls.size then - let lvl := lvls.get ⟨i, h⟩ - if lvl.getOffset ≥ maxExplicit then true - else isExplicitSubsumedAux lvls maxExplicit (i+1) -else - false + if h : i < lvls.size then + let lvl := lvls.get ⟨i, h⟩ + if lvl.getOffset ≥ maxExplicit then true + else isExplicitSubsumedAux lvls maxExplicit (i+1) + else + false /- Auxiliary function for `normalize`. See `isExplicitSubsumedAux` -/ private def isExplicitSubsumed (lvls : Array Level) (firstNonExplicit : Nat) : Bool := -if firstNonExplicit == 0 then false -else - let max := (lvls.get! (firstNonExplicit - 1)).getOffset; - isExplicitSubsumedAux lvls max firstNonExplicit + if firstNonExplicit == 0 then false + else + let max := (lvls.get! (firstNonExplicit - 1)).getOffset; + isExplicitSubsumedAux lvls max firstNonExplicit partial def normalize (l : Level) : Level := if isAlreadyNormalizedCheap l then l @@ -344,74 +344,74 @@ partial def normalize (l : Level) : Level := /- Return true if `u` and `v` denote the same level. Check is currently incomplete. -/ def isEquiv (u v : Level) : Bool := -u == v || u.normalize == v.normalize + u == v || u.normalize == v.normalize /-- Reduce (if possible) universe level by 1 -/ def dec : Level → Option Level -| zero _ => none -| param _ _ => none -| mvar _ _ => none -| succ l _ => l -| max l₁ l₂ _ => mkLevelMax <$> dec l₁ <*> dec l₂ -/- Remark: `mkLevelMax` in the following line is not a typo. - If `dec l₂` succeeds, then `imax l₁ l₂` is equivalent to `max l₁ l₂`. -/ -| imax l₁ l₂ _ => mkLevelMax <$> dec l₁ <*> dec l₂ + | zero _ => none + | param _ _ => none + | mvar _ _ => none + | succ l _ => l + | max l₁ l₂ _ => mkLevelMax <$> dec l₁ <*> dec l₂ + /- Remark: `mkLevelMax` in the following line is not a typo. + If `dec l₂` succeeds, then `imax l₁ l₂` is equivalent to `max l₁ l₂`. -/ + | imax l₁ l₂ _ => mkLevelMax <$> dec l₁ <*> dec l₂ /- Level to Format -/ namespace LevelToFormat inductive Result -| leaf : Format → Result -| num : Nat → Result -| offset : Result → Nat → Result -| maxNode : List Result → Result -| imaxNode : List Result → Result + | leaf : Format → Result + | num : Nat → Result + | offset : Result → Nat → Result + | maxNode : List Result → Result + | imaxNode : List Result → Result def Result.succ : Result → Result -| Result.offset f k => Result.offset f (k+1) -| Result.num k => Result.num (k+1) -| f => Result.offset f 1 + | Result.offset f k => Result.offset f (k+1) + | Result.num k => Result.num (k+1) + | f => Result.offset f 1 def Result.max : Result → Result → Result -| f, Result.maxNode Fs => Result.maxNode (f::Fs) -| f₁, f₂ => Result.maxNode [f₁, f₂] + | f, Result.maxNode Fs => Result.maxNode (f::Fs) + | f₁, f₂ => Result.maxNode [f₁, f₂] def Result.imax : Result → Result → Result -| f, Result.imaxNode Fs => Result.imaxNode (f::Fs) -| f₁, f₂ => Result.imaxNode [f₁, f₂] + | f, Result.imaxNode Fs => Result.imaxNode (f::Fs) + | f₁, f₂ => Result.imaxNode [f₁, f₂] def parenIfFalse : Format → Bool → Format -| f, true => f -| f, false => f.paren + | f, true => f + | f, false => f.paren @[specialize] private def formatLst (fmt : Result → Format) : List Result → Format -| [] => Format.nil -| r::rs => Format.line ++ fmt r ++ formatLst fmt rs + | [] => Format.nil + | r::rs => Format.line ++ fmt r ++ formatLst fmt rs partial def Result.format : Result → Bool → Format -| Result.leaf f, _ => f -| Result.num k, _ => toString k -| Result.offset f 0, r => format f r -| Result.offset f (k+1), r => - let f' := format f false; - parenIfFalse (f' ++ "+" ++ fmt (k+1)) r -| Result.maxNode fs, r => parenIfFalse (Format.group $ "max" ++ formatLst (fun r => format r false) fs) r -| Result.imaxNode fs, r => parenIfFalse (Format.group $ "imax" ++ formatLst (fun r => format r false) fs) r + | Result.leaf f, _ => f + | Result.num k, _ => toString k + | Result.offset f 0, r => format f r + | Result.offset f (k+1), r => + let f' := format f false; + parenIfFalse (f' ++ "+" ++ fmt (k+1)) r + | Result.maxNode fs, r => parenIfFalse (Format.group $ "max" ++ formatLst (fun r => format r false) fs) r + | Result.imaxNode fs, r => parenIfFalse (Format.group $ "imax" ++ formatLst (fun r => format r false) fs) r def toResult : Level → Result -| zero _ => Result.num 0 -| succ l _ => Result.succ (toResult l) -| max l₁ l₂ _ => Result.max (toResult l₁) (toResult l₂) -| imax l₁ l₂ _ => Result.imax (toResult l₁) (toResult l₂) -| param n _ => Result.leaf (fmt n) -| mvar n _ => - let n := n.replacePrefix `_uniq `u; - Result.leaf ("?" ++ fmt n) + | zero _ => Result.num 0 + | succ l _ => Result.succ (toResult l) + | max l₁ l₂ _ => Result.max (toResult l₁) (toResult l₂) + | imax l₁ l₂ _ => Result.imax (toResult l₁) (toResult l₂) + | param n _ => Result.leaf (fmt n) + | mvar n _ => + let n := n.replacePrefix `_uniq `u; + Result.leaf ("?" ++ fmt n) end LevelToFormat protected def format (l : Level) : Format := -(LevelToFormat.toResult l).format true + (LevelToFormat.toResult l).format true instance : HasFormat Level := ⟨Level.format⟩ instance : HasToString Level := ⟨Format.pretty ∘ Level.format⟩ @@ -427,47 +427,47 @@ instance : HasToString Level := ⟨Format.pretty ∘ Level.format⟩ @[extern "lean_level_update_succ"] def updateSucc (lvl : Level) (newLvl : Level) (h : lvl.isSucc = true) : Level := -mkLevelSucc newLvl + mkLevelSucc newLvl @[inline] def updateSucc! (lvl : Level) (newLvl : Level) : Level := match lvl with -| succ lvl d => updateSucc (succ lvl d) newLvl rfl -| _ => panic! "succ level expected" + | succ lvl d => updateSucc (succ lvl d) newLvl rfl + | _ => panic! "succ level expected" @[extern "lean_level_update_max"] def updateMax (lvl : Level) (newLhs : Level) (newRhs : Level) (h : lvl.isMax = true) : Level := -mkLevelMax newLhs newRhs + mkLevelMax newLhs newRhs @[inline] def updateMax! (lvl : Level) (newLhs : Level) (newRhs : Level) : Level := -match lvl with -| max lhs rhs d => updateMax (max lhs rhs d) newLhs newRhs rfl -| _ => panic! "max level expected" + match lvl with + | max lhs rhs d => updateMax (max lhs rhs d) newLhs newRhs rfl + | _ => panic! "max level expected" @[extern "lean_level_update_imax"] def updateIMax (lvl : Level) (newLhs : Level) (newRhs : Level) (h : lvl.isIMax = true) : Level := -mkLevelIMax newLhs newRhs + mkLevelIMax newLhs newRhs @[inline] def updateIMax! (lvl : Level) (newLhs : Level) (newRhs : Level) : Level := -match lvl with -| imax lhs rhs d => updateIMax (imax lhs rhs d) newLhs newRhs rfl -| _ => panic! "imax level expected" + match lvl with + | imax lhs rhs d => updateIMax (imax lhs rhs d) newLhs newRhs rfl + | _ => panic! "imax level expected" def mkNaryMax : List Level → Level -| [] => levelZero -| [u] => u -| u::us => mkLevelMax u (mkNaryMax us) + | [] => levelZero + | [u] => u + | u::us => mkLevelMax u (mkNaryMax us) /- Level to Format -/ @[specialize] def instantiateParams (s : Name → Option Level) : Level → Level -| u@(zero _) => u -| u@(succ v _) => if u.hasParam then u.updateSucc! (instantiateParams s v) else u -| u@(max v₁ v₂ _) => if u.hasParam then u.updateMax! (instantiateParams s v₁) (instantiateParams s v₂) else u -| u@(imax v₁ v₂ _) => if u.hasParam then u.updateIMax! (instantiateParams s v₁) (instantiateParams s v₂) else u -| u@(param n _) => match s n with - | some u' => u' - | none => u -| u => u + | u@(zero _) => u + | u@(succ v _) => if u.hasParam then u.updateSucc! (instantiateParams s v) else u + | u@(max v₁ v₂ _) => if u.hasParam then u.updateMax! (instantiateParams s v₁) (instantiateParams s v₂) else u + | u@(imax v₁ v₂ _) => if u.hasParam then u.updateIMax! (instantiateParams s v₁) (instantiateParams s v₂) else u + | u@(param n _) => match s n with + | some u' => u' + | none => u + | u => u end Level @@ -482,4 +482,4 @@ abbrev PLevelSet := PersistentLevelSet end Lean abbrev Nat.toLevel (n : Nat) : Lean.Level := -Lean.Level.ofNat n + Lean.Level.ofNat n diff --git a/stage0/src/Lean/Modifiers.lean b/stage0/src/Lean/Modifiers.lean index 5c4087d4f9..15a4af5b75 100644 --- a/stage0/src/Lean/Modifiers.lean +++ b/stage0/src/Lean/Modifiers.lean @@ -12,11 +12,11 @@ builtin_initialize protectedExt : TagDeclarationExtension ← mkTagDeclarationEx @[export lean_add_protected] def addProtected (env : Environment) (n : Name) : Environment := -protectedExt.tag env n + protectedExt.tag env n @[export lean_is_protected] def isProtected (env : Environment) (n : Name) : Bool := -protectedExt.isTagged env n + protectedExt.isTagged env n builtin_initialize privateExt : EnvExtension Nat ← registerEnvExtension (pure 1) @@ -36,44 +36,44 @@ def privateHeader : Name := `_private @[export lean_mk_private_prefix] def mkUniquePrivatePrefix (env : Environment) : Environment × Name := -let idx := privateExt.getState env -let p := mkNameNum (privateHeader ++ env.mainModule) idx -let env := privateExt.setState env (idx+1) -(env, p) + let idx := privateExt.getState env + let p := mkNameNum (privateHeader ++ env.mainModule) idx + let env := privateExt.setState env (idx+1) + (env, p) @[export lean_mk_private_name] def mkUniquePrivateName (env : Environment) (n : Name) : Environment × Name := -let (env, p) := mkUniquePrivatePrefix env -(env, p ++ n) + let (env, p) := mkUniquePrivatePrefix env + (env, p ++ n) def mkPrivateName (env : Environment) (n : Name) : Name := -mkNameNum (privateHeader ++ env.mainModule) 0 ++ n + mkNameNum (privateHeader ++ env.mainModule) 0 ++ n def isPrivateName : Name → Bool -| n@(Name.str p _ _) => n == privateHeader || isPrivateName p -| Name.num p _ _ => isPrivateName p -| _ => false + | n@(Name.str p _ _) => n == privateHeader || isPrivateName p + | Name.num p _ _ => isPrivateName p + | _ => false @[export lean_is_private_name] def isPrivateNameExport (n : Name) : Bool := -isPrivateName n + isPrivateName n private def privateToUserNameAux : Name → Name -| Name.str p s _ => mkNameStr (privateToUserNameAux p) s -| _ => Name.anonymous + | Name.str p s _ => mkNameStr (privateToUserNameAux p) s + | _ => Name.anonymous @[export lean_private_to_user_name] def privateToUserName? (n : Name) : Option Name := -if isPrivateName n then privateToUserNameAux n -else none + if isPrivateName n then privateToUserNameAux n + else none private def privatePrefixAux : Name → Name -| Name.str p _ _ => privatePrefixAux p -| n => n + | Name.str p _ _ => privatePrefixAux p + | n => n @[export lean_private_prefix] def privatePrefix (n : Name) : Option Name := -if isPrivateName n then privatePrefixAux n -else none + if isPrivateName n then privatePrefixAux n + else none end Lean diff --git a/stage0/src/Lean/MonadEnv.lean b/stage0/src/Lean/MonadEnv.lean index dba50c21f8..8aec2f484b 100644 --- a/stage0/src/Lean/MonadEnv.lean +++ b/stage0/src/Lean/MonadEnv.lean @@ -14,107 +14,107 @@ section Methods variables {m : Type → Type} [MonadEnv m] def setEnv (env : Environment) : m Unit := -modifyEnv fun _ => env + modifyEnv fun _ => env @[inline] def withoutModifyingEnv [Monad m] [MonadFinally m] {α : Type} (x : m α) : m α := do -let env ← getEnv -try x finally setEnv env + let env ← getEnv + try x finally setEnv env @[inline] def matchConst [Monad m] {α : Type} (e : Expr) (failK : Unit → m α) (k : ConstantInfo → List Level → m α) : m α := do -match e with -| Expr.const constName us _ => do - match (← getEnv).find? constName with - | some cinfo => k cinfo us - | none => failK () -| _ => failK () + match e with + | Expr.const constName us _ => do + match (← getEnv).find? constName with + | some cinfo => k cinfo us + | none => failK () + | _ => failK () @[inline] def matchConstInduct [Monad m] {α : Type} (e : Expr) (failK : Unit → m α) (k : InductiveVal → List Level → m α) : m α := -matchConst e failK fun cinfo us => - match cinfo with - | ConstantInfo.inductInfo val => k val us - | _ => failK () + matchConst e failK fun cinfo us => + match cinfo with + | ConstantInfo.inductInfo val => k val us + | _ => failK () @[inline] def matchConstCtor [Monad m] {α : Type} (e : Expr) (failK : Unit → m α) (k : ConstructorVal → List Level → m α) : m α := -matchConst e failK fun cinfo us => - match cinfo with - | ConstantInfo.ctorInfo val => k val us - | _ => failK () + matchConst e failK fun cinfo us => + match cinfo with + | ConstantInfo.ctorInfo val => k val us + | _ => failK () @[inline] def matchConstRec [Monad m] {α : Type} (e : Expr) (failK : Unit → m α) (k : RecursorVal → List Level → m α) : m α := -matchConst e failK fun cinfo us => - match cinfo with - | ConstantInfo.recInfo val => k val us - | _ => failK () + matchConst e failK fun cinfo us => + match cinfo with + | ConstantInfo.recInfo val => k val us + | _ => failK () section variables [Monad m] def hasConst (constName : Name) : m Bool := do -return (← getEnv).contains constName + return (← getEnv).contains constName private partial def mkAuxNameAux (env : Environment) (base : Name) (i : Nat) : Name := -let candidate := base.appendIndexAfter i -if env.contains candidate then - mkAuxNameAux env base (i+1) -else - candidate + let candidate := base.appendIndexAfter i + if env.contains candidate then + mkAuxNameAux env base (i+1) + else + candidate def mkAuxName (baseName : Name) (idx : Nat) : m Name := do -return mkAuxNameAux (← getEnv) baseName idx + return mkAuxNameAux (← getEnv) baseName idx variables [MonadExceptOf Exception m] [Ref m] [AddErrorMessageContext m] def getConstInfo (constName : Name) : m ConstantInfo := do -match (← getEnv).find? constName with -| some info => pure info -| none => throwError! "unknown constant '{mkConst constName}'" + match (← getEnv).find? constName with + | some info => pure info + | none => throwError! "unknown constant '{mkConst constName}'" def getConstInfoInduct (constName : Name) : m InductiveVal := do -match (← getConstInfo constName) with -| ConstantInfo.inductInfo v => pure v -| _ => throwError! "'{mkConst constName}' is not a inductive type" + match (← getConstInfo constName) with + | ConstantInfo.inductInfo v => pure v + | _ => throwError! "'{mkConst constName}' is not a inductive type" def getConstInfoCtor (constName : Name) : m ConstructorVal := do -match (← getConstInfo constName) with -| ConstantInfo.ctorInfo v => pure v -| _ => throwError! "'{mkConst constName}' is not a constructor" + match (← getConstInfo constName) with + | ConstantInfo.ctorInfo v => pure v + | _ => throwError! "'{mkConst constName}' is not a constructor" def getConstInfoRec (constName : Name) : m RecursorVal := do -match (← getConstInfo constName) with -| ConstantInfo.recInfo v => pure v -| _ => throwError! "'{mkConst constName}' is not a recursor" + match (← getConstInfo constName) with + | ConstantInfo.recInfo v => pure v + | _ => throwError! "'{mkConst constName}' is not a recursor" @[inline] def matchConstStruct {α : Type} (e : Expr) (failK : Unit → m α) (k : InductiveVal → List Level → ConstructorVal → m α) : m α := -matchConstInduct e failK fun ival us => do - if ival.isRec then failK () - else match ival.ctors with - | [ctor] => - match (← getConstInfo ctor) with - | ConstantInfo.ctorInfo cval => k ival us cval + matchConstInduct e failK fun ival us => do + if ival.isRec then failK () + else match ival.ctors with + | [ctor] => + match (← getConstInfo ctor) with + | ConstantInfo.ctorInfo cval => k ival us cval + | _ => failK () | _ => failK () - | _ => failK () def addDecl [MonadOptions m] (decl : Declaration) : m Unit := do -match (← getEnv).addDecl decl with -| Except.ok env => setEnv env -| Except.error ex => throwKernelException ex + match (← getEnv).addDecl decl with + | Except.ok env => setEnv env + | Except.error ex => throwKernelException ex def compileDecl [MonadOptions m] (decl : Declaration) : m Unit := do -match (← getEnv).compileDecl (← getOptions) decl with -| Except.ok env => setEnv env -| Except.error ex => throwKernelException ex + match (← getEnv).compileDecl (← getOptions) decl with + | Except.ok env => setEnv env + | Except.error ex => throwKernelException ex def addAndCompile [MonadOptions m] (decl : Declaration) : m Unit := do -addDecl decl; -compileDecl decl + addDecl decl; + compileDecl decl variables [MonadExceptOf Exception m] [Ref m] [AddErrorMessageContext m] [MonadOptions m] unsafe def evalConst (α) (constName : Name) : m α := do -ofExcept $ (← getEnv).evalConst α (← getOptions) constName + ofExcept $ (← getEnv).evalConst α (← getOptions) constName unsafe def evalConstCheck (α) (typeName : Name) (constName : Name) : m α := do -ofExcept $ (← getEnv).evalConstCheck α (← getOptions) typeName constName + ofExcept $ (← getEnv).evalConstCheck α (← getOptions) typeName constName end diff --git a/stage0/src/Lean/PrettyPrinter.lean b/stage0/src/Lean/PrettyPrinter.lean index 3c0a38c99b..0dc664b66e 100644 --- a/stage0/src/Lean/PrettyPrinter.lean +++ b/stage0/src/Lean/PrettyPrinter.lean @@ -12,51 +12,51 @@ import Lean.Parser.Module namespace Lean def PPContext.runCoreM {α : Type} (ppCtx : PPContext) (x : CoreM α) : IO α := -Prod.fst <$> x.toIO { options := ppCtx.opts } { env := ppCtx.env } + Prod.fst <$> x.toIO { options := ppCtx.opts } { env := ppCtx.env } def PPContext.runMetaM {α : Type} (ppCtx : PPContext) (x : MetaM α) : IO α := -ppCtx.runCoreM $ x.run' { lctx := ppCtx.lctx } { mctx := ppCtx.mctx } + ppCtx.runCoreM $ x.run' { lctx := ppCtx.lctx } { mctx := ppCtx.mctx } namespace PrettyPrinter def ppTerm (stx : Syntax) : CoreM Format := do -let opts ← getOptions -let stx := (sanitizeSyntax stx).run' { options := opts } -parenthesizeTerm stx >>= formatTerm + let opts ← getOptions + let stx := (sanitizeSyntax stx).run' { options := opts } + parenthesizeTerm stx >>= formatTerm def ppExpr (currNamespace : Name) (openDecls : List OpenDecl) (e : Expr) : MetaM Format := do -let lctx ← getLCtx -let opts ← getOptions -let lctx := lctx.sanitizeNames.run' { options := opts } -Meta.withLCtx lctx #[] do - let stx ← delab currNamespace openDecls e - ppTerm stx + let lctx ← getLCtx + let opts ← getOptions + let lctx := lctx.sanitizeNames.run' { options := opts } + Meta.withLCtx lctx #[] do + let stx ← delab currNamespace openDecls e + ppTerm stx @[export lean_pp_expr] def ppExprLegacy (env : Environment) (mctx : MetavarContext) (lctx : LocalContext) (opts : Options) (e : Expr) : IO Format := -Prod.fst <$> ((ppExpr Name.anonymous [] e).run' { lctx := lctx } { mctx := mctx }).toIO { options := opts } { env := env } + Prod.fst <$> ((ppExpr Name.anonymous [] e).run' { lctx := lctx } { mctx := mctx }).toIO { options := opts } { env := env } def ppCommand (stx : Syntax) : CoreM Format := -parenthesizeCommand stx >>= formatCommand + parenthesizeCommand stx >>= formatCommand def ppModule (stx : Syntax) : CoreM Format := do -parenthesize Lean.Parser.Module.module.parenthesizer stx >>= format Lean.Parser.Module.module.formatter + parenthesize Lean.Parser.Module.module.parenthesizer stx >>= format Lean.Parser.Module.module.formatter private partial def noContext : MessageData → MessageData -| MessageData.withContext ctx msg => noContext msg -| MessageData.withNamingContext ctx msg => MessageData.withNamingContext ctx (noContext msg) -| MessageData.nest n msg => MessageData.nest n (noContext msg) -| MessageData.group msg => MessageData.group (noContext msg) -| MessageData.compose msg₁ msg₂ => MessageData.compose (noContext msg₁) (noContext msg₂) -| MessageData.tagged tag msg => MessageData.tagged tag (noContext msg) -| MessageData.node msgs => MessageData.node (msgs.map noContext) -| msg => msg + | MessageData.withContext ctx msg => noContext msg + | MessageData.withNamingContext ctx msg => MessageData.withNamingContext ctx (noContext msg) + | MessageData.nest n msg => MessageData.nest n (noContext msg) + | MessageData.group msg => MessageData.group (noContext msg) + | MessageData.compose msg₁ msg₂ => MessageData.compose (noContext msg₁) (noContext msg₂) + | MessageData.tagged tag msg => MessageData.tagged tag (noContext msg) + | MessageData.node msgs => MessageData.node (msgs.map noContext) + | msg => msg -- strip context (including environments with registered pretty printers) to prevent infinite recursion when pretty printing pretty printer error private def withoutContext {m} [MonadExcept Exception m] (x : m Format) : m Format := -tryCatch x fun - | Exception.error ref msg => throw $ Exception.error ref (noContext msg) - | ex => throw ex + tryCatch x fun + | Exception.error ref msg => throw $ Exception.error ref (noContext msg) + | ex => throw ex builtin_initialize ppFnsRef.set { diff --git a/stage0/src/Lean/ProjFns.lean b/stage0/src/Lean/ProjFns.lean index 07e6a1135b..75794659be 100644 --- a/stage0/src/Lean/ProjFns.lean +++ b/stage0/src/Lean/ProjFns.lean @@ -11,19 +11,19 @@ namespace Lean /- Given a structure `S`, Lean automatically creates an auxiliary definition (projection function) for each field. This structure caches information about these auxiliary definitions. -/ structure ProjectionFunctionInfo := -(ctorName : Name) -- Constructor associated with the auxiliary projection function. -(nparams : Nat) -- Number of parameters in the structure -(i : Nat) -- The field index associated with the auxiliary projection function. -(fromClass : Bool) -- `true` if the structure is a class + (ctorName : Name) -- Constructor associated with the auxiliary projection function. + (nparams : Nat) -- Number of parameters in the structure + (i : Nat) -- The field index associated with the auxiliary projection function. + (fromClass : Bool) -- `true` if the structure is a class @[export lean_mk_projection_info] def mkProjectionInfoEx (ctorName : Name) (nparams : Nat) (i : Nat) (fromClass : Bool) : ProjectionFunctionInfo := -{ctorName := ctorName, nparams := nparams, i := i, fromClass := fromClass } + {ctorName := ctorName, nparams := nparams, i := i, fromClass := fromClass } @[export lean_projection_info_from_class] -def ProjectionFunctionInfo.fromClassEx (info : ProjectionFunctionInfo) : Bool := info.fromClass + def ProjectionFunctionInfo.fromClassEx (info : ProjectionFunctionInfo) : Bool := info.fromClass instance : Inhabited ProjectionFunctionInfo := -⟨{ ctorName := arbitrary _, nparams := arbitrary _, i := 0, fromClass := false }⟩ + ⟨{ ctorName := arbitrary _, nparams := arbitrary _, i := 0, fromClass := false }⟩ builtin_initialize projectionFnInfoExt : SimplePersistentEnvExtension (Name × ProjectionFunctionInfo) (NameMap ProjectionFunctionInfo) ← registerSimplePersistentEnvExtension { @@ -35,32 +35,32 @@ builtin_initialize projectionFnInfoExt : SimplePersistentEnvExtension (Name × P @[export lean_add_projection_info] def addProjectionFnInfo (env : Environment) (projName : Name) (ctorName : Name) (nparams : Nat) (i : Nat) (fromClass : Bool) : Environment := -projectionFnInfoExt.addEntry env (projName, { ctorName := ctorName, nparams := nparams, i := i, fromClass := fromClass }) + projectionFnInfoExt.addEntry env (projName, { ctorName := ctorName, nparams := nparams, i := i, fromClass := fromClass }) namespace Environment @[export lean_get_projection_info] def getProjectionFnInfo? (env : Environment) (projName : Name) : Option ProjectionFunctionInfo := -match env.getModuleIdxFor? projName with -| some modIdx => - match (projectionFnInfoExt.getModuleEntries env modIdx).binSearch (projName, arbitrary _) (fun a b => Name.quickLt a.1 b.1) with - | some e => some e.2 - | none => none -| none => (projectionFnInfoExt.getState env).find? projName + match env.getModuleIdxFor? projName with + | some modIdx => + match (projectionFnInfoExt.getModuleEntries env modIdx).binSearch (projName, arbitrary _) (fun a b => Name.quickLt a.1 b.1) with + | some e => some e.2 + | none => none + | none => (projectionFnInfoExt.getState env).find? projName def isProjectionFn (env : Environment) (n : Name) : Bool := -match env.getModuleIdxFor? n with -| some modIdx => (projectionFnInfoExt.getModuleEntries env modIdx).binSearchContains (n, arbitrary _) (fun a b => Name.quickLt a.1 b.1) -| none => (projectionFnInfoExt.getState env).contains n + match env.getModuleIdxFor? n with + | some modIdx => (projectionFnInfoExt.getModuleEntries env modIdx).binSearchContains (n, arbitrary _) (fun a b => Name.quickLt a.1 b.1) + | none => (projectionFnInfoExt.getState env).contains n /-- If `projName` is the name of a projection function, return the associated structure name -/ def getProjectionStructureName? (env : Environment) (projName : Name) : Option Name := -match env.getProjectionFnInfo? projName with -| none => none -| some projInfo => - match env.find? projInfo.ctorName with - | some (ConstantInfo.ctorInfo val) => some val.induct - | _ => none + match env.getProjectionFnInfo? projName with + | none => none + | some projInfo => + match env.find? projInfo.ctorName with + | some (ConstantInfo.ctorInfo val) => some val.induct + | _ => none end Environment end Lean diff --git a/stage0/src/Lean/ReducibilityAttrs.lean b/stage0/src/Lean/ReducibilityAttrs.lean index 91f69c2bea..5c6de7d11a 100644 --- a/stage0/src/Lean/ReducibilityAttrs.lean +++ b/stage0/src/Lean/ReducibilityAttrs.lean @@ -9,7 +9,7 @@ import Lean.Attributes namespace Lean inductive ReducibilityStatus -| reducible | semireducible | irreducible + | reducible | semireducible | irreducible instance : Inhabited ReducibilityStatus := ⟨ReducibilityStatus.semireducible⟩ @@ -21,19 +21,19 @@ builtin_initialize reducibilityAttrs : EnumAttributes ReducibilityStatus ← @[export lean_get_reducibility_status] def getReducibilityStatus (env : Environment) (n : Name) : ReducibilityStatus := -match reducibilityAttrs.getValue env n with -| some s => s -| none => ReducibilityStatus.semireducible + match reducibilityAttrs.getValue env n with + | some s => s + | none => ReducibilityStatus.semireducible @[export lean_set_reducibility_status] def setReducibilityStatus (env : Environment) (n : Name) (s : ReducibilityStatus) : Environment := -match reducibilityAttrs.setValue env n s with -| Except.ok env => env -| _ => env -- TODO(Leo): we should extend EnumAttributes.setValue in the future and ensure it never fails + match reducibilityAttrs.setValue env n s with + | Except.ok env => env + | _ => env -- TODO(Leo): we should extend EnumAttributes.setValue in the future and ensure it never fails def isReducible (env : Environment) (n : Name) : Bool := -match getReducibilityStatus env n with -| ReducibilityStatus.reducible => true -| _ => false + match getReducibilityStatus env n with + | ReducibilityStatus.reducible => true + | _ => false end Lean diff --git a/stage0/src/Lean/ResolveName.lean b/stage0/src/Lean/ResolveName.lean index c639b6e14e..9248beb5ec 100644 --- a/stage0/src/Lean/ResolveName.lean +++ b/stage0/src/Lean/ResolveName.lean @@ -18,9 +18,9 @@ abbrev AliasState := SMap Name (List Name) abbrev AliasEntry := Name × Name def addAliasEntry (s : AliasState) (e : AliasEntry) : AliasState := -match s.find? e.1 with -| none => s.insert e.1 [e.2] -| some es => if es.elem e.2 then s else s.insert e.1 (e.2 :: es) + match s.find? e.1 with + | none => s.insert e.1 [e.2] + | some es => if es.elem e.2 then s else s.insert e.1 (e.2 :: es) builtin_initialize aliasExtension : SimplePersistentEnvExtension AliasEntry AliasState ← registerSimplePersistentEnvExtension { @@ -31,101 +31,101 @@ builtin_initialize aliasExtension : SimplePersistentEnvExtension AliasEntry Alia /- Add alias `a` for `e` -/ @[export lean_add_alias] def addAlias (env : Environment) (a : Name) (e : Name) : Environment := -aliasExtension.addEntry env (a, e) + aliasExtension.addEntry env (a, e) def getAliases (env : Environment) (a : Name) : List Name := -match aliasExtension.getState env $.find? a with -| none => [] -| some es => es + match aliasExtension.getState env $.find? a with + | none => [] + | some es => es -- slower, but only used in the pretty printer def getRevAliases (env : Environment) (e : Name) : List Name := -(aliasExtension.getState env).fold (fun as a es => if List.contains es e then a :: as else as) [] + (aliasExtension.getState env).fold (fun as a es => if List.contains es e then a :: as else as) [] /- Global name resolution -/ namespace ResolveName /- Check whether `ns ++ id` is a valid namepace name and/or there are aliases names `ns ++ id`. -/ private def resolveQualifiedName (env : Environment) (ns : Name) (id : Name) : List Name := -let resolvedId := ns ++ id -let resolvedIds := getAliases env resolvedId -if env.contains resolvedId && (!id.isAtomic || !isProtected env resolvedId) then - resolvedId :: resolvedIds -else - -- Check whether environment contains the private version. That is, `_private..ns.id`. - let resolvedIdPrv := mkPrivateName env resolvedId - if env.contains resolvedIdPrv then resolvedIdPrv :: resolvedIds - else resolvedIds + let resolvedId := ns ++ id + let resolvedIds := getAliases env resolvedId + if env.contains resolvedId && (!id.isAtomic || !isProtected env resolvedId) then + resolvedId :: resolvedIds + else + -- Check whether environment contains the private version. That is, `_private..ns.id`. + let resolvedIdPrv := mkPrivateName env resolvedId + if env.contains resolvedIdPrv then resolvedIdPrv :: resolvedIds + else resolvedIds /- Check surrounding namespaces -/ private def resolveUsingNamespace (env : Environment) (id : Name) : Name → List Name -| ns@(Name.str p _ _) => - match resolveQualifiedName env ns id with - | [] => resolveUsingNamespace env id p - | resolvedIds => resolvedIds -| _ => [] + | ns@(Name.str p _ _) => + match resolveQualifiedName env ns id with + | [] => resolveUsingNamespace env id p + | resolvedIds => resolvedIds + | _ => [] /- Check exact name -/ private def resolveExact (env : Environment) (id : Name) : Option Name := -if id.isAtomic then none -else - let resolvedId := id.replacePrefix rootNamespace Name.anonymous - if env.contains resolvedId then some resolvedId + if id.isAtomic then none else - -- We also allow `_root` when accessing private declarations. - -- If we change our minds, we should just replace `resolvedId` with `id` - let resolvedIdPrv := mkPrivateName env resolvedId - if env.contains resolvedIdPrv then some resolvedIdPrv - else none + let resolvedId := id.replacePrefix rootNamespace Name.anonymous + if env.contains resolvedId then some resolvedId + else + -- We also allow `_root` when accessing private declarations. + -- If we change our minds, we should just replace `resolvedId` with `id` + let resolvedIdPrv := mkPrivateName env resolvedId + if env.contains resolvedIdPrv then some resolvedIdPrv + else none /- Check open namespaces -/ private def resolveOpenDecls (env : Environment) (id : Name) : List OpenDecl → List Name → List Name -| [], resolvedIds => resolvedIds -| OpenDecl.simple ns exs :: openDecls, resolvedIds => - if exs.elem id then + | [], resolvedIds => resolvedIds + | OpenDecl.simple ns exs :: openDecls, resolvedIds => + if exs.elem id then + resolveOpenDecls env id openDecls resolvedIds + else + let newResolvedIds := resolveQualifiedName env ns id + resolveOpenDecls env id openDecls (newResolvedIds ++ resolvedIds) + | OpenDecl.explicit openedId resolvedId :: openDecls, resolvedIds => + let resolvedIds := if id == openedId then resolvedId :: resolvedIds else resolvedIds resolveOpenDecls env id openDecls resolvedIds - else - let newResolvedIds := resolveQualifiedName env ns id - resolveOpenDecls env id openDecls (newResolvedIds ++ resolvedIds) -| OpenDecl.explicit openedId resolvedId :: openDecls, resolvedIds => - let resolvedIds := if id == openedId then resolvedId :: resolvedIds else resolvedIds - resolveOpenDecls env id openDecls resolvedIds def resolveGlobalName (env : Environment) (ns : Name) (openDecls : List OpenDecl) (id : Name) : List (Name × List String) := --- decode macro scopes from name before recursion -let extractionResult := extractMacroScopes id -let rec loop : Name → List String → List (Name × List String) - | id@(Name.str p s _), projs => - -- NOTE: we assume that macro scopes always belong to the projected constant, not the projections - let id := { extractionResult with name := id }.review - match resolveUsingNamespace env id ns with - | resolvedIds@(_ :: _) => resolvedIds.eraseDups.map fun id => (id, projs) - | [] => - match resolveExact env id with - | some newId => [(newId, projs)] - | none => - let resolvedIds := if env.contains id then [id] else [] - let idPrv := mkPrivateName env id - let resolvedIds := if env.contains idPrv then [idPrv] ++ resolvedIds else resolvedIds - let resolvedIds := resolveOpenDecls env id openDecls resolvedIds - let resolvedIds := getAliases env id ++ resolvedIds - match resolvedIds with - | _ :: _ => resolvedIds.eraseDups.map fun id => (id, projs) - | [] => loop p (s::projs) - | _, _ => [] -loop extractionResult.name [] + -- decode macro scopes from name before recursion + let extractionResult := extractMacroScopes id + let rec loop : Name → List String → List (Name × List String) + | id@(Name.str p s _), projs => + -- NOTE: we assume that macro scopes always belong to the projected constant, not the projections + let id := { extractionResult with name := id }.review + match resolveUsingNamespace env id ns with + | resolvedIds@(_ :: _) => resolvedIds.eraseDups.map fun id => (id, projs) + | [] => + match resolveExact env id with + | some newId => [(newId, projs)] + | none => + let resolvedIds := if env.contains id then [id] else [] + let idPrv := mkPrivateName env id + let resolvedIds := if env.contains idPrv then [idPrv] ++ resolvedIds else resolvedIds + let resolvedIds := resolveOpenDecls env id openDecls resolvedIds + let resolvedIds := getAliases env id ++ resolvedIds + match resolvedIds with + | _ :: _ => resolvedIds.eraseDups.map fun id => (id, projs) + | [] => loop p (s::projs) + | _, _ => [] + loop extractionResult.name [] /- Namespace resolution -/ def resolveNamespaceUsingScope (env : Environment) (n : Name) : Name → Option Name -| Name.anonymous => none -| ns@(Name.str p _ _) => if env.isNamespace (ns ++ n) then some (ns ++ n) else resolveNamespaceUsingScope env n p -| _ => unreachable! + | Name.anonymous => none + | ns@(Name.str p _ _) => if env.isNamespace (ns ++ n) then some (ns ++ n) else resolveNamespaceUsingScope env n p + | _ => unreachable! def resolveNamespaceUsingOpenDecls (env : Environment) (n : Name) : List OpenDecl → Option Name -| [] => none -| OpenDecl.simple ns [] :: ds => if env.isNamespace (ns ++ n) then some (ns ++ n) else resolveNamespaceUsingOpenDecls env n ds -| _ :: ds => resolveNamespaceUsingOpenDecls env n ds + | [] => none + | OpenDecl.simple ns [] :: ds => if env.isNamespace (ns ++ n) then some (ns ++ n) else resolveNamespaceUsingOpenDecls env n ds + | _ :: ds => resolveNamespaceUsingOpenDecls env n ds /- Given a name `id` try to find namespace it refers to. The resolution procedure works as follows @@ -136,24 +136,25 @@ Given a name `id` try to find namespace it refers to. The resolution procedure w We search "backwards" again. That is, we try the most recent `open` command first. We only consider simple `open` commands. -/ def resolveNamespace? (env : Environment) (ns : Name) (openDecls : List OpenDecl) (id : Name) : Option Name := -if env.isNamespace id then some id -else match resolveNamespaceUsingScope env id ns with - | some n => some n - | none => - match resolveNamespaceUsingOpenDecls env id openDecls with + if env.isNamespace id then some id + else match resolveNamespaceUsingScope env id ns with | some n => some n - | none => none -end ResolveName + | none => + match resolveNamespaceUsingOpenDecls env id openDecls with + | some n => some n + | none => none + end ResolveName class MonadResolveName (m : Type → Type) := -(getCurrNamespace : m Name) -(getOpenDecls : m (List OpenDecl)) + (getCurrNamespace : m Name) + (getOpenDecls : m (List OpenDecl)) export MonadResolveName (getCurrNamespace getOpenDecls) -instance (m n) [MonadResolveName m] [MonadLift m n] : MonadResolveName n := -{ getCurrNamespace := liftM (getCurrNamespace : m _), - getOpenDecls := liftM (getOpenDecls : m _) } +instance (m n) [MonadResolveName m] [MonadLift m n] : MonadResolveName n := { + getCurrNamespace := liftM (getCurrNamespace : m _), + getOpenDecls := liftM (getOpenDecls : m _) +} section Methods @@ -182,27 +183,27 @@ variables {m : Type → Type} [Monad m] [MonadResolveName m] [MonadEnv m] - `resolveGlobalName x.z.w` => `[(Foo.x, [z, w]), (Boo.x, [z, w])]` -/ def resolveGlobalName (id : Name) : m (List (Name × List String)) := do -return ResolveName.resolveGlobalName (← getEnv) (← getCurrNamespace) (← getOpenDecls) id + return ResolveName.resolveGlobalName (← getEnv) (← getCurrNamespace) (← getOpenDecls) id variables [MonadExceptOf Exception m] [Ref m] [AddErrorMessageContext m] def resolveNamespace (id : Name) : m Name := do -match ResolveName.resolveNamespace? (← getEnv) (← getCurrNamespace) (← getOpenDecls) id with -| some ns => return ns -| none => throwError s!"unknown namespace '{id}'" + match ResolveName.resolveNamespace? (← getEnv) (← getCurrNamespace) (← getOpenDecls) id with + | some ns => return ns + | none => throwError s!"unknown namespace '{id}'" /- Similar to `resolveGlobalName`, but discard any candidate whose `fieldList` is not empty. -/ def resolveGlobalConst (n : Name) : m (List Name) := do -let cs ← resolveGlobalName n -let cs := cs.filter fun (_, fieldList) => fieldList.isEmpty -if cs.isEmpty then throwUnknownConstant n -return cs.map (·.1) + let cs ← resolveGlobalName n + let cs := cs.filter fun (_, fieldList) => fieldList.isEmpty + if cs.isEmpty then throwUnknownConstant n + return cs.map (·.1) def resolveGlobalConstNoOverload (n : Name) : m Name := do -let cs ← resolveGlobalConst n -match cs with -| [c] => pure c -| _ => throwError s!"ambiguous identifier '{mkConst n}', possible interpretations: {cs.map mkConst}" + let cs ← resolveGlobalConst n + match cs with + | [c] => pure c + | _ => throwError s!"ambiguous identifier '{mkConst n}', possible interpretations: {cs.map mkConst}" end Methods end Lean diff --git a/stage0/stdlib/Lean/Elab/PreDefinition/Basic.c b/stage0/stdlib/Lean/Elab/PreDefinition/Basic.c index 8f3236cad8..66b85ac024 100644 --- a/stage0/stdlib/Lean/Elab/PreDefinition/Basic.c +++ b/stage0/stdlib/Lean/Elab/PreDefinition/Basic.c @@ -82,6 +82,7 @@ uint8_t l_Lean_Elab_DefKind_isTheorem(uint8_t); lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux_match__1___rarg(uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___closed__3; lean_object* l_Lean_Elab_addAndCompileUnsafeRec___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); +lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_levelMVarToParamExpr(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Elab_fixLevelParams_match__1___rarg(lean_object*, lean_object*, lean_object*); lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_shareCommon___spec__2(lean_object*, lean_object*, lean_object*); @@ -104,6 +105,7 @@ uint8_t l_Array_anyRangeMAux___at_Lean_Elab_fixLevelParams___spec__1(lean_object lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_getLevelParamsPreDecls___spec__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Elab_instantiateMVarsAtPreDecls(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Array_anyRangeMAux___at_Lean_Elab_addAndCompileUnsafeRec___spec__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); +lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); extern lean_object* l_Lean_Expr_Lean_Expr___instance__11___closed__1; lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_levelMVarToParamExpr_match__1___rarg(lean_object*, lean_object*); extern lean_object* l_Lean_mkOptionalNode___closed__2; @@ -1875,6 +1877,62 @@ x_8 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux_match_ return x_8; } } +lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { +_start: +{ +uint8_t x_10; lean_object* x_11; +x_10 = 1; +x_11 = l_Lean_Elab_applyAttributesOf(x_1, x_10, x_3, x_4, x_5, x_6, x_7, x_8, x_9); +if (lean_obj_tag(x_11) == 0) +{ +uint8_t x_12; +x_12 = !lean_is_exclusive(x_11); +if (x_12 == 0) +{ +lean_object* x_13; lean_object* x_14; +x_13 = lean_ctor_get(x_11, 0); +lean_dec(x_13); +x_14 = lean_box(0); +lean_ctor_set(x_11, 0, x_14); +return x_11; +} +else +{ +lean_object* x_15; lean_object* x_16; lean_object* x_17; +x_15 = lean_ctor_get(x_11, 1); +lean_inc(x_15); +lean_dec(x_11); +x_16 = lean_box(0); +x_17 = lean_alloc_ctor(0, 2, 0); +lean_ctor_set(x_17, 0, x_16); +lean_ctor_set(x_17, 1, x_15); +return x_17; +} +} +else +{ +uint8_t x_18; +x_18 = !lean_is_exclusive(x_11); +if (x_18 == 0) +{ +return x_11; +} +else +{ +lean_object* x_19; lean_object* x_20; lean_object* x_21; +x_19 = lean_ctor_get(x_11, 0); +x_20 = lean_ctor_get(x_11, 1); +lean_inc(x_20); +lean_inc(x_19); +lean_dec(x_11); +x_21 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_21, 0, x_19); +lean_ctor_set(x_21, 1, x_20); +return x_21; +} +} +} +} static lean_object* _init_l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___closed__1() { _start: { @@ -1898,7 +1956,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___closed__1; x_2 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___closed__2; x_3 = lean_unsigned_to_nat(98u); -x_4 = lean_unsigned_to_nat(25u); +x_4 = lean_unsigned_to_nat(27u); x_5 = l___private_Init_LeanInit_0__Lean_eraseMacroScopesAux___closed__3; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -1944,105 +2002,105 @@ lean_inc(x_22); switch (x_17) { case 0: { -lean_object* x_84; lean_object* x_85; uint32_t x_86; uint32_t x_87; uint32_t x_88; lean_object* x_89; uint8_t x_90; lean_object* x_91; lean_object* x_92; -x_84 = lean_alloc_ctor(0, 3, 0); -lean_ctor_set(x_84, 0, x_20); -lean_ctor_set(x_84, 1, x_18); -lean_ctor_set(x_84, 2, x_21); +lean_object* x_54; lean_object* x_55; uint32_t x_56; uint32_t x_57; uint32_t x_58; lean_object* x_59; uint8_t x_60; lean_object* x_61; lean_object* x_62; +x_54 = lean_alloc_ctor(0, 3, 0); +lean_ctor_set(x_54, 0, x_20); +lean_ctor_set(x_54, 1, x_18); +lean_ctor_set(x_54, 2, x_21); lean_inc(x_22); -x_85 = l_Lean_getMaxHeight(x_16, x_22); -x_86 = lean_unbox_uint32(x_85); -lean_dec(x_85); -x_87 = 1; -x_88 = x_86 + x_87; -x_89 = lean_alloc_ctor(2, 0, 4); -lean_ctor_set_uint32(x_89, 0, x_88); -x_90 = lean_ctor_get_uint8(x_19, sizeof(void*)*2 + 3); +x_55 = l_Lean_getMaxHeight(x_16, x_22); +x_56 = lean_unbox_uint32(x_55); +lean_dec(x_55); +x_57 = 1; +x_58 = x_56 + x_57; +x_59 = lean_alloc_ctor(2, 0, 4); +lean_ctor_set_uint32(x_59, 0, x_58); +x_60 = lean_ctor_get_uint8(x_19, sizeof(void*)*2 + 3); lean_dec(x_19); -x_91 = lean_alloc_ctor(0, 3, 1); -lean_ctor_set(x_91, 0, x_84); -lean_ctor_set(x_91, 1, x_22); -lean_ctor_set(x_91, 2, x_89); -lean_ctor_set_uint8(x_91, sizeof(void*)*3, x_90); -x_92 = lean_alloc_ctor(1, 1, 0); -lean_ctor_set(x_92, 0, x_91); -x_23 = x_92; -goto block_83; +x_61 = lean_alloc_ctor(0, 3, 1); +lean_ctor_set(x_61, 0, x_54); +lean_ctor_set(x_61, 1, x_22); +lean_ctor_set(x_61, 2, x_59); +lean_ctor_set_uint8(x_61, sizeof(void*)*3, x_60); +x_62 = lean_alloc_ctor(1, 1, 0); +lean_ctor_set(x_62, 0, x_61); +x_23 = x_62; +goto block_53; } case 1: { -lean_object* x_93; lean_object* x_94; lean_object* x_95; +lean_object* x_63; lean_object* x_64; lean_object* x_65; lean_dec(x_19); lean_dec(x_16); -x_93 = lean_alloc_ctor(0, 3, 0); -lean_ctor_set(x_93, 0, x_20); -lean_ctor_set(x_93, 1, x_18); -lean_ctor_set(x_93, 2, x_21); -x_94 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_94, 0, x_93); -lean_ctor_set(x_94, 1, x_22); -x_95 = lean_alloc_ctor(2, 1, 0); -lean_ctor_set(x_95, 0, x_94); -x_23 = x_95; -goto block_83; +x_63 = lean_alloc_ctor(0, 3, 0); +lean_ctor_set(x_63, 0, x_20); +lean_ctor_set(x_63, 1, x_18); +lean_ctor_set(x_63, 2, x_21); +x_64 = lean_alloc_ctor(0, 2, 0); +lean_ctor_set(x_64, 0, x_63); +lean_ctor_set(x_64, 1, x_22); +x_65 = lean_alloc_ctor(2, 1, 0); +lean_ctor_set(x_65, 0, x_64); +x_23 = x_65; +goto block_53; } case 2: { -lean_object* x_96; lean_object* x_97; lean_object* x_98; +lean_object* x_66; lean_object* x_67; lean_object* x_68; lean_dec(x_22); lean_dec(x_21); lean_dec(x_20); lean_dec(x_19); lean_dec(x_18); lean_dec(x_16); -x_96 = l_Lean_Lean_Declaration___instance__3; -x_97 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___closed__3; -x_98 = lean_panic_fn(x_96, x_97); -x_23 = x_98; -goto block_83; +x_66 = l_Lean_Lean_Declaration___instance__3; +x_67 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___closed__3; +x_68 = lean_panic_fn(x_66, x_67); +x_23 = x_68; +goto block_53; } case 3: { -lean_object* x_99; uint8_t x_100; lean_object* x_101; lean_object* x_102; +lean_object* x_69; uint8_t x_70; lean_object* x_71; lean_object* x_72; lean_dec(x_16); -x_99 = lean_alloc_ctor(0, 3, 0); -lean_ctor_set(x_99, 0, x_20); -lean_ctor_set(x_99, 1, x_18); -lean_ctor_set(x_99, 2, x_21); -x_100 = lean_ctor_get_uint8(x_19, sizeof(void*)*2 + 3); +x_69 = lean_alloc_ctor(0, 3, 0); +lean_ctor_set(x_69, 0, x_20); +lean_ctor_set(x_69, 1, x_18); +lean_ctor_set(x_69, 2, x_21); +x_70 = lean_ctor_get_uint8(x_19, sizeof(void*)*2 + 3); lean_dec(x_19); -x_101 = lean_alloc_ctor(0, 2, 1); -lean_ctor_set(x_101, 0, x_99); -lean_ctor_set(x_101, 1, x_22); -lean_ctor_set_uint8(x_101, sizeof(void*)*2, x_100); -x_102 = lean_alloc_ctor(3, 1, 0); -lean_ctor_set(x_102, 0, x_101); -x_23 = x_102; -goto block_83; +x_71 = lean_alloc_ctor(0, 2, 1); +lean_ctor_set(x_71, 0, x_69); +lean_ctor_set(x_71, 1, x_22); +lean_ctor_set_uint8(x_71, sizeof(void*)*2, x_70); +x_72 = lean_alloc_ctor(3, 1, 0); +lean_ctor_set(x_72, 0, x_71); +x_23 = x_72; +goto block_53; } default: { -lean_object* x_103; uint8_t x_104; lean_object* x_105; lean_object* x_106; lean_object* x_107; +lean_object* x_73; uint8_t x_74; lean_object* x_75; lean_object* x_76; lean_object* x_77; lean_dec(x_16); -x_103 = lean_alloc_ctor(0, 3, 0); -lean_ctor_set(x_103, 0, x_20); -lean_ctor_set(x_103, 1, x_18); -lean_ctor_set(x_103, 2, x_21); -x_104 = lean_ctor_get_uint8(x_19, sizeof(void*)*2 + 3); +x_73 = lean_alloc_ctor(0, 3, 0); +lean_ctor_set(x_73, 0, x_20); +lean_ctor_set(x_73, 1, x_18); +lean_ctor_set(x_73, 2, x_21); +x_74 = lean_ctor_get_uint8(x_19, sizeof(void*)*2 + 3); lean_dec(x_19); -x_105 = lean_box(1); -x_106 = lean_alloc_ctor(0, 3, 1); -lean_ctor_set(x_106, 0, x_103); -lean_ctor_set(x_106, 1, x_22); -lean_ctor_set(x_106, 2, x_105); -lean_ctor_set_uint8(x_106, sizeof(void*)*3, x_104); -x_107 = lean_alloc_ctor(1, 1, 0); -lean_ctor_set(x_107, 0, x_106); -x_23 = x_107; -goto block_83; +x_75 = lean_box(1); +x_76 = lean_alloc_ctor(0, 3, 1); +lean_ctor_set(x_76, 0, x_73); +lean_ctor_set(x_76, 1, x_22); +lean_ctor_set(x_76, 2, x_75); +lean_ctor_set_uint8(x_76, sizeof(void*)*3, x_74); +x_77 = lean_alloc_ctor(1, 1, 0); +lean_ctor_set(x_77, 0, x_76); +x_23 = x_77; +goto block_53; } } -block_83: +block_53: { lean_object* x_24; lean_inc(x_7); @@ -2065,58 +2123,69 @@ if (lean_obj_tag(x_29) == 0) { if (x_2 == 0) { -lean_object* x_30; uint8_t x_31; lean_object* x_32; +lean_object* x_30; lean_object* x_31; lean_object* x_32; lean_dec(x_23); x_30 = lean_ctor_get(x_29, 1); lean_inc(x_30); lean_dec(x_29); -x_31 = 1; -x_32 = l_Lean_Elab_applyAttributesOf(x_27, x_31, x_3, x_4, x_5, x_6, x_7, x_8, x_30); +x_31 = lean_box(0); +x_32 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___lambda__1(x_27, x_31, x_3, x_4, x_5, x_6, x_7, x_8, x_30); lean_dec(x_6); lean_dec(x_5); lean_dec(x_27); -if (lean_obj_tag(x_32) == 0) -{ -uint8_t x_33; -x_33 = !lean_is_exclusive(x_32); -if (x_33 == 0) -{ -lean_object* x_34; lean_object* x_35; -x_34 = lean_ctor_get(x_32, 0); -lean_dec(x_34); -x_35 = lean_box(0); -lean_ctor_set(x_32, 0, x_35); return x_32; } else { +lean_object* x_33; uint8_t x_34; +x_33 = lean_ctor_get(x_29, 1); +lean_inc(x_33); +lean_dec(x_29); +x_34 = l_Lean_Elab_DefKind_isTheorem(x_17); +if (x_34 == 0) +{ +lean_object* x_35; +lean_inc(x_7); +lean_inc(x_3); +x_35 = l_Lean_compileDecl___at_Lean_Elab_Term_declareTacticSyntax___spec__4(x_23, x_3, x_4, x_5, x_6, x_7, x_8, x_33); +lean_dec(x_23); +if (lean_obj_tag(x_35) == 0) +{ lean_object* x_36; lean_object* x_37; lean_object* x_38; -x_36 = lean_ctor_get(x_32, 1); +x_36 = lean_ctor_get(x_35, 0); lean_inc(x_36); -lean_dec(x_32); -x_37 = lean_box(0); -x_38 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_38, 0, x_37); -lean_ctor_set(x_38, 1, x_36); +x_37 = lean_ctor_get(x_35, 1); +lean_inc(x_37); +lean_dec(x_35); +x_38 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___lambda__1(x_27, x_36, x_3, x_4, x_5, x_6, x_7, x_8, x_37); +lean_dec(x_6); +lean_dec(x_5); +lean_dec(x_36); +lean_dec(x_27); return x_38; } -} else { uint8_t x_39; -x_39 = !lean_is_exclusive(x_32); +lean_dec(x_27); +lean_dec(x_8); +lean_dec(x_7); +lean_dec(x_6); +lean_dec(x_5); +lean_dec(x_3); +x_39 = !lean_is_exclusive(x_35); if (x_39 == 0) { -return x_32; +return x_35; } else { lean_object* x_40; lean_object* x_41; lean_object* x_42; -x_40 = lean_ctor_get(x_32, 0); -x_41 = lean_ctor_get(x_32, 1); +x_40 = lean_ctor_get(x_35, 0); +x_41 = lean_ctor_get(x_35, 1); lean_inc(x_41); lean_inc(x_40); -lean_dec(x_32); +lean_dec(x_35); x_42 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_42, 0, x_40); lean_ctor_set(x_42, 1, x_41); @@ -2126,170 +2195,20 @@ return x_42; } else { -lean_object* x_43; uint8_t x_44; -x_43 = lean_ctor_get(x_29, 1); -lean_inc(x_43); -lean_dec(x_29); -x_44 = l_Lean_Elab_DefKind_isTheorem(x_17); -if (x_44 == 0) -{ -lean_object* x_45; -lean_inc(x_7); -lean_inc(x_3); -x_45 = l_Lean_compileDecl___at_Lean_Elab_Term_declareTacticSyntax___spec__4(x_23, x_3, x_4, x_5, x_6, x_7, x_8, x_43); +lean_object* x_43; lean_object* x_44; lean_dec(x_23); -if (lean_obj_tag(x_45) == 0) -{ -lean_object* x_46; uint8_t x_47; lean_object* x_48; -x_46 = lean_ctor_get(x_45, 1); -lean_inc(x_46); -lean_dec(x_45); -x_47 = 1; -x_48 = l_Lean_Elab_applyAttributesOf(x_27, x_47, x_3, x_4, x_5, x_6, x_7, x_8, x_46); +x_43 = lean_box(0); +x_44 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___lambda__1(x_27, x_43, x_3, x_4, x_5, x_6, x_7, x_8, x_33); lean_dec(x_6); lean_dec(x_5); lean_dec(x_27); -if (lean_obj_tag(x_48) == 0) -{ -uint8_t x_49; -x_49 = !lean_is_exclusive(x_48); -if (x_49 == 0) -{ -lean_object* x_50; lean_object* x_51; -x_50 = lean_ctor_get(x_48, 0); -lean_dec(x_50); -x_51 = lean_box(0); -lean_ctor_set(x_48, 0, x_51); -return x_48; -} -else -{ -lean_object* x_52; lean_object* x_53; lean_object* x_54; -x_52 = lean_ctor_get(x_48, 1); -lean_inc(x_52); -lean_dec(x_48); -x_53 = lean_box(0); -x_54 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_54, 0, x_53); -lean_ctor_set(x_54, 1, x_52); -return x_54; -} -} -else -{ -uint8_t x_55; -x_55 = !lean_is_exclusive(x_48); -if (x_55 == 0) -{ -return x_48; -} -else -{ -lean_object* x_56; lean_object* x_57; lean_object* x_58; -x_56 = lean_ctor_get(x_48, 0); -x_57 = lean_ctor_get(x_48, 1); -lean_inc(x_57); -lean_inc(x_56); -lean_dec(x_48); -x_58 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_58, 0, x_56); -lean_ctor_set(x_58, 1, x_57); -return x_58; +return x_44; } } } else { -uint8_t x_59; -lean_dec(x_27); -lean_dec(x_8); -lean_dec(x_7); -lean_dec(x_6); -lean_dec(x_5); -lean_dec(x_3); -x_59 = !lean_is_exclusive(x_45); -if (x_59 == 0) -{ -return x_45; -} -else -{ -lean_object* x_60; lean_object* x_61; lean_object* x_62; -x_60 = lean_ctor_get(x_45, 0); -x_61 = lean_ctor_get(x_45, 1); -lean_inc(x_61); -lean_inc(x_60); -lean_dec(x_45); -x_62 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_62, 0, x_60); -lean_ctor_set(x_62, 1, x_61); -return x_62; -} -} -} -else -{ -uint8_t x_63; lean_object* x_64; -lean_dec(x_23); -x_63 = 1; -x_64 = l_Lean_Elab_applyAttributesOf(x_27, x_63, x_3, x_4, x_5, x_6, x_7, x_8, x_43); -lean_dec(x_6); -lean_dec(x_5); -lean_dec(x_27); -if (lean_obj_tag(x_64) == 0) -{ -uint8_t x_65; -x_65 = !lean_is_exclusive(x_64); -if (x_65 == 0) -{ -lean_object* x_66; lean_object* x_67; -x_66 = lean_ctor_get(x_64, 0); -lean_dec(x_66); -x_67 = lean_box(0); -lean_ctor_set(x_64, 0, x_67); -return x_64; -} -else -{ -lean_object* x_68; lean_object* x_69; lean_object* x_70; -x_68 = lean_ctor_get(x_64, 1); -lean_inc(x_68); -lean_dec(x_64); -x_69 = lean_box(0); -x_70 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_70, 0, x_69); -lean_ctor_set(x_70, 1, x_68); -return x_70; -} -} -else -{ -uint8_t x_71; -x_71 = !lean_is_exclusive(x_64); -if (x_71 == 0) -{ -return x_64; -} -else -{ -lean_object* x_72; lean_object* x_73; lean_object* x_74; -x_72 = lean_ctor_get(x_64, 0); -x_73 = lean_ctor_get(x_64, 1); -lean_inc(x_73); -lean_inc(x_72); -lean_dec(x_64); -x_74 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_74, 0, x_72); -lean_ctor_set(x_74, 1, x_73); -return x_74; -} -} -} -} -} -else -{ -uint8_t x_75; +uint8_t x_45; lean_dec(x_27); lean_dec(x_23); lean_dec(x_8); @@ -2297,29 +2216,29 @@ lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); -x_75 = !lean_is_exclusive(x_29); -if (x_75 == 0) +x_45 = !lean_is_exclusive(x_29); +if (x_45 == 0) { return x_29; } else { -lean_object* x_76; lean_object* x_77; lean_object* x_78; -x_76 = lean_ctor_get(x_29, 0); -x_77 = lean_ctor_get(x_29, 1); -lean_inc(x_77); -lean_inc(x_76); +lean_object* x_46; lean_object* x_47; lean_object* x_48; +x_46 = lean_ctor_get(x_29, 0); +x_47 = lean_ctor_get(x_29, 1); +lean_inc(x_47); +lean_inc(x_46); lean_dec(x_29); -x_78 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_78, 0, x_76); -lean_ctor_set(x_78, 1, x_77); -return x_78; +x_48 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_48, 0, x_46); +lean_ctor_set(x_48, 1, x_47); +return x_48; } } } else { -uint8_t x_79; +uint8_t x_49; lean_dec(x_23); lean_dec(x_11); lean_dec(x_8); @@ -2327,56 +2246,69 @@ lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); -x_79 = !lean_is_exclusive(x_24); -if (x_79 == 0) +x_49 = !lean_is_exclusive(x_24); +if (x_49 == 0) { return x_24; } else { -lean_object* x_80; lean_object* x_81; lean_object* x_82; -x_80 = lean_ctor_get(x_24, 0); -x_81 = lean_ctor_get(x_24, 1); -lean_inc(x_81); -lean_inc(x_80); +lean_object* x_50; lean_object* x_51; lean_object* x_52; +x_50 = lean_ctor_get(x_24, 0); +x_51 = lean_ctor_get(x_24, 1); +lean_inc(x_51); +lean_inc(x_50); lean_dec(x_24); -x_82 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_82, 0, x_80); -lean_ctor_set(x_82, 1, x_81); -return x_82; +x_52 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_52, 0, x_50); +lean_ctor_set(x_52, 1, x_51); +return x_52; } } } } else { -uint8_t x_108; +uint8_t x_78; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); -x_108 = !lean_is_exclusive(x_10); -if (x_108 == 0) +x_78 = !lean_is_exclusive(x_10); +if (x_78 == 0) { return x_10; } else { -lean_object* x_109; lean_object* x_110; lean_object* x_111; -x_109 = lean_ctor_get(x_10, 0); -x_110 = lean_ctor_get(x_10, 1); -lean_inc(x_110); -lean_inc(x_109); +lean_object* x_79; lean_object* x_80; lean_object* x_81; +x_79 = lean_ctor_get(x_10, 0); +x_80 = lean_ctor_get(x_10, 1); +lean_inc(x_80); +lean_inc(x_79); lean_dec(x_10); -x_111 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_111, 0, x_109); -lean_ctor_set(x_111, 1, x_110); -return x_111; +x_81 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_81, 0, x_79); +lean_ctor_set(x_81, 1, x_80); +return x_81; } } } } +lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { +_start: +{ +lean_object* x_10; +x_10 = l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9); +lean_dec(x_6); +lean_dec(x_5); +lean_dec(x_4); +lean_dec(x_2); +lean_dec(x_1); +return x_10; +} +} lean_object* l___private_Lean_Elab_PreDefinition_Basic_0__Lean_Elab_addNonRecAux___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { diff --git a/stage0/stdlib/Lean/Elab/PreDefinition/Structural.c b/stage0/stdlib/Lean/Elab/PreDefinition/Structural.c index fbf2c01ca0..c7d8bccdad 100644 --- a/stage0/stdlib/Lean/Elab/PreDefinition/Structural.c +++ b/stage0/stdlib/Lean/Elab/PreDefinition/Structural.c @@ -31,7 +31,6 @@ lean_object* l_Lean_registerTraceClass(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_throwToBelowFailed___rarg___closed__1; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_withBelowDict___rarg___closed__1; lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__6___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__12; lean_object* l_Lean_stringToMessageData(lean_object*); lean_object* l_Lean_Elab_addAsAxiom(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); @@ -41,10 +40,8 @@ uint8_t l_Array_contains___at___private_Lean_Meta_FunInfo_0__Lean_Meta_collectDe lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop_match__3___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t l_Array_contains___at_Lean_Meta_addInstanceEntry___spec__11(lean_object*, lean_object*); lean_object* l_Lean_Meta_mkAppM___at_Lean_Meta_mkDecideProof___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadParamDep_x3f___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__6(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__12(lean_object*); lean_object* l_Lean_Meta_isExprDefEq___at_Lean_Meta_isExprDefEqGuarded___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___lambda__2___closed__1; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); @@ -59,6 +56,7 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replace lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__2___closed__2; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux_match__1(lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_withBelowDict___spec__1(lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_MatcherApp_addArg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___closed__2; lean_object* l_Array_filterAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); @@ -66,7 +64,6 @@ extern lean_object* l_Std_HashMap_inhabited___closed__1; lean_object* l_Lean_Meta_inferType___at___private_Lean_Meta_InferType_0__Lean_Meta_inferAppType___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_ensureNoRecFn___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__16; -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__2; lean_object* lean_array_fswap(lean_object*, lean_object*, lean_object*); lean_object* l_Array_extract___rarg(lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop_match__1___rarg(lean_object*, lean_object*); @@ -77,12 +74,14 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadP lean_object* lean_environment_find(lean_object*, lean_object*); lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__2___closed__1; lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__2___boxed(lean_object*, lean_object*, lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_throwToBelowFailed___rarg___closed__3; lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadParamDep_x3f___spec__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___lambda__4(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_st_ref_get(lean_object*, lean_object*); lean_object* l_Lean_Elab_addAndCompileUnsafeRec(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__1; +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__3; +lean_object* l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_setEnv___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_elimRecursion___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t l_Lean_Expr_isAppOf(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_throwStructuralFailed___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); @@ -109,10 +108,7 @@ lean_object* l_Array_iterateMAux___at_Lean_mkAppN___spec__1(lean_object*, lean_o lean_object* l_Lean_Expr_replaceFVars(lean_object*, lean_object*, lean_object*); lean_object* l_Array_isPrefixOf___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getFixedPrefix___spec__1___boxed(lean_object*, lean_object*); uint8_t l_USize_decLt(size_t, size_t); -lean_object* l_Std_Range_forIn_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___lambda__3___closed__6; -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__6; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_withBelowDict___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); extern lean_object* l_Lean_levelZero; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__17; @@ -126,9 +122,9 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRec lean_object* l_Array_zip___rarg(lean_object*, lean_object*); lean_object* l_Lean_Elab_structuralRecursion___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_mkMData(lean_object*, lean_object*); -lean_object* l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__10___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__9; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__4; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getFixedPrefix_match__1(lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__4; lean_object* l___private_Lean_Expr_0__Lean_Expr_getAppArgsAux(lean_object*, lean_object*, lean_object*); @@ -141,7 +137,6 @@ lean_object* l_Lean_Meta_forEachExprImp_x27(lean_object*, lean_object*, lean_obj lean_object* lean_array_fget(lean_object*, lean_object*); lean_object* l___private_Lean_CoreM_0__Lean_Core_mkFreshNameImp(lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux_match__1___rarg(lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_mkProj(lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__7; uint8_t lean_nat_dec_eq(lean_object*, lean_object*); @@ -149,10 +144,12 @@ lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Struc lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__3(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); extern lean_object* l___private_Init_LeanInit_0__Lean_eraseMacroScopesAux___closed__3; lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_st_ref_take(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadParamDep_x3f_match__4___rarg(lean_object*, lean_object*, lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_nat_sub(lean_object*, lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); +lean_object* l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7(lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__1; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___closed__1; lean_object* l_Lean_Meta_whnfD___at___private_Lean_Meta_InferType_0__Lean_Meta_getLevelImp___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); @@ -172,12 +169,10 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRec lean_object* lean_array_fset(lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__14; lean_object* l_Lean_Meta_forEachExpr___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux_match__3___rarg(lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getIndexMinPos___spec__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_throwError___at_Lean_Meta_initFn____x40_Lean_Meta_Basic___hyg_878____spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__6___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_mkLambdaFVars___at_Lean_Meta_SynthInstance_tryResolveCore___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__18; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__5; @@ -185,28 +180,23 @@ lean_object* l_Lean_Elab_structuralRecursion___closed__3; lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getIndexMinPos___spec__1(lean_object*, lean_object*, size_t, size_t, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__5; lean_object* l_Lean_Meta_whnf___at___private_Lean_Meta_Basic_0__Lean_Meta_isClassExpensive_x3f___spec__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadIndexDep_x3f___spec__3___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__14; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__15; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_throwToBelowFailed___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_st_mk_ref(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__6; -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__3___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_forEachExpr_x27___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_ensureNoRecFn___spec__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_name_mk_string(lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__4; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_elimRecursion___lambda__1___closed__1; lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___lambda__2___closed__2; -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__8; lean_object* l_Lean_setEnv___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_elimRecursion___spec__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_elimRecursion___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_withBelowDict___spec__1___rarg___closed__2; extern lean_object* l___private_Lean_Meta_ExprDefEq_0__Lean_Meta_processAssignmentFOApprox_loop___closed__3; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_elimRecursion___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__12___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t l_Lean_Environment_contains(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getIndexMinPos_match__1___rarg(lean_object*, lean_object*, lean_object*); @@ -217,14 +207,14 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadP lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelow(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_getFVarLocalDecl___at___private_Lean_Meta_Basic_0__Lean_Meta_withNewLocalInstanceImp___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__3; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop_match__2(lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadIndexDep_x3f___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__2___closed__3; +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__2; lean_object* l___private_Init_Util_0__mkPanicMessageWithDecl(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_ensureNoRecFn(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Lean_Elab_initFn____x40_Lean_Elab_PreDefinition_Structural___hyg_3445_(lean_object*); +lean_object* l_Lean_Elab_initFn____x40_Lean_Elab_PreDefinition_Structural___hyg_3438_(lean_object*); uint8_t l_Lean_Expr_isConstOf(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_throwStructuralFailed___rarg___closed__2; lean_object* l_Lean_hasConst___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); @@ -234,6 +224,7 @@ lean_object* l_Lean_ForEachExpr_visit___at___private_Lean_Elab_PreDefinition_Str lean_object* l_Lean_Meta_mapErrorImp___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___rarg___closed__12; lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadIndexDep_x3f___spec__3(lean_object*, lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); +lean_object* l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadParamDep_x3f_match__3___rarg(lean_object*, lean_object*); uint8_t l_Lean_Expr_Data_binderInfo(uint64_t); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__8; @@ -245,10 +236,8 @@ lean_object* l_List_map___main___at_Lean_MessageData_Lean_Message___instance__12 lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop_match__1___rarg(lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__6; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___lambda__3___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Std_Range_forIn_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___lambda__4___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__5(lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__5; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__4; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___lambda__3___closed__4; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop_match__3___rarg(lean_object*, lean_object*, lean_object*); @@ -265,6 +254,7 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRec lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__2; extern lean_object* l_Lean_Expr_FindImpl_initCache; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadIndexDep_x3f_match__4___rarg(lean_object*, lean_object*, lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__6; lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadParamDep_x3f___spec__2(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_matchMatcherApp_x3f(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_withBelowDict___spec__1___rarg___lambda__2___closed__1; @@ -288,11 +278,13 @@ lean_object* l_Lean_mkApp(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux_match__2___rarg___closed__1; lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadParamDep_x3f___spec__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadParamDep_x3f(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__8; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__15; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_containsRecFn___boxed(lean_object*, lean_object*); lean_object* lean_panic_fn(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux___closed__3; lean_object* l_Lean_Meta_MatcherApp_toExpr(lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__1; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getIndexMinPos_match__1(lean_object*, lean_object*); lean_object* l_Array_anyRangeMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__3___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelowAux_match__2___rarg(lean_object*, lean_object*, lean_object*, lean_object*); @@ -305,6 +297,7 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replace lean_object* lean_st_ref_set(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__6___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t l_Lean_Expr_isFVar(lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__5; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__1___closed__2; lean_object* l_Lean_Meta_decLevel___at_Lean_Meta_getDecLevel___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_containsRecFn(lean_object*, lean_object*); @@ -338,14 +331,13 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getFixe lean_object* l_Lean_Expr_getAppFn(lean_object*); lean_object* l_Array_isPrefixOfAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getFixedPrefix___spec__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadIndexDep_x3f_match__1___rarg(lean_object*, lean_object*); +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__7; extern lean_object* l_Nat_Inhabited; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop_match__2(lean_object*); -lean_object* l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__10(lean_object*); lean_object* l_unsafeCast(lean_object*, lean_object*, lean_object*); uint8_t l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_containsRecFn___lambda__1(lean_object*, lean_object*); lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__6___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Meta_Basic_0__Lean_Meta_lambdaTelescopeImp___rarg(lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop(lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_containsRecFn___lambda__1___boxed(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_mkBRecOn___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); @@ -373,6 +365,7 @@ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelow lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__4___boxed(lean_object*, lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_hasBadIndexDep_x3f_match__3(lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__1___closed__3; +lean_object* l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9(lean_object*); lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getFixedPrefix(lean_object*, lean_object*, lean_object*); lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Elab_structuralRecursion___closed__2; @@ -386,7 +379,6 @@ extern lean_object* l___private_Lean_Meta_Match_Match_0__Lean_Meta_updateAlts___ lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop_match__1___boxed(lean_object*, lean_object*); lean_object* l_Std_HashMapImp_find_x3f___at_Lean_Meta_ForEachExpr_visit___spec__1(lean_object*, lean_object*); lean_object* l_Std_Range_forIn_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__7; lean_object* l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_getFixedPrefix_match__1___rarg(lean_object* x_1, lean_object* x_2) { _start: { @@ -4372,7 +4364,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__2___closed__1; x_2 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_findRecArg_loop___spec__2___closed__2; x_3 = lean_unsigned_to_nat(111u); -x_4 = lean_unsigned_to_nat(117u); +x_4 = lean_unsigned_to_nat(119u); x_5 = l___private_Init_LeanInit_0__Lean_eraseMacroScopesAux___closed__3; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9876,601 +9868,7 @@ return x_60; } } } -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10) { -_start: -{ -lean_object* x_11; uint8_t x_12; -x_11 = lean_array_get_size(x_5); -x_12 = lean_nat_dec_lt(x_4, x_11); -lean_dec(x_11); -if (x_12 == 0) -{ -lean_object* x_13; lean_object* x_14; -lean_dec(x_9); -lean_dec(x_8); -lean_dec(x_7); -lean_dec(x_6); -lean_dec(x_4); -lean_dec(x_3); -lean_dec(x_2); -lean_dec(x_1); -x_13 = x_5; -x_14 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_14, 0, x_13); -lean_ctor_set(x_14, 1, x_10); -return x_14; -} -else -{ -lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; -x_15 = lean_array_fget(x_5, x_4); -x_16 = lean_unsigned_to_nat(0u); -x_17 = lean_array_fset(x_5, x_4, x_16); -x_18 = x_15; -lean_inc(x_9); -lean_inc(x_8); -lean_inc(x_7); -lean_inc(x_6); -lean_inc(x_3); -lean_inc(x_2); -lean_inc(x_1); -x_19 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_18, x_6, x_7, x_8, x_9, x_10); -if (lean_obj_tag(x_19) == 0) -{ -lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; -x_20 = lean_ctor_get(x_19, 0); -lean_inc(x_20); -x_21 = lean_ctor_get(x_19, 1); -lean_inc(x_21); -lean_dec(x_19); -x_22 = lean_unsigned_to_nat(1u); -x_23 = lean_nat_add(x_4, x_22); -x_24 = x_20; -x_25 = lean_array_fset(x_17, x_4, x_24); -lean_dec(x_4); -x_4 = x_23; -x_5 = x_25; -x_10 = x_21; -goto _start; -} -else -{ -uint8_t x_27; -lean_dec(x_17); -lean_dec(x_9); -lean_dec(x_8); -lean_dec(x_7); -lean_dec(x_6); -lean_dec(x_4); -lean_dec(x_3); -lean_dec(x_2); -lean_dec(x_1); -x_27 = !lean_is_exclusive(x_19); -if (x_27 == 0) -{ -return x_19; -} -else -{ -lean_object* x_28; lean_object* x_29; lean_object* x_30; -x_28 = lean_ctor_get(x_19, 0); -x_29 = lean_ctor_get(x_19, 1); -lean_inc(x_29); -lean_inc(x_28); -lean_dec(x_19); -x_30 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_30, 0, x_28); -lean_ctor_set(x_30, 1, x_29); -return x_30; -} -} -} -} -} -lean_object* l_Std_Range_forIn_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12, lean_object* x_13, lean_object* x_14) { -_start: -{ -lean_object* x_15; uint8_t x_16; -x_15 = lean_ctor_get(x_6, 1); -x_16 = lean_nat_dec_le(x_15, x_8); -if (x_16 == 0) -{ -lean_object* x_17; uint8_t x_18; -x_17 = lean_unsigned_to_nat(0u); -x_18 = lean_nat_dec_eq(x_7, x_17); -if (x_18 == 0) -{ -lean_object* x_19; lean_object* x_20; uint8_t x_21; -x_19 = lean_unsigned_to_nat(1u); -x_20 = lean_nat_sub(x_7, x_19); -lean_dec(x_7); -x_21 = lean_nat_dec_eq(x_4, x_8); -if (x_21 == 0) -{ -lean_object* x_22; uint8_t x_23; -x_22 = lean_ctor_get(x_2, 3); -lean_inc(x_22); -x_23 = l_Array_contains___at___private_Lean_Meta_FunInfo_0__Lean_Meta_collectDeps_visit___spec__2(x_22, x_8); -lean_dec(x_22); -if (x_23 == 0) -{ -lean_object* x_24; lean_object* x_25; lean_object* x_26; -x_24 = l_Lean_Expr_Lean_Expr___instance__11; -x_25 = lean_array_get(x_24, x_5, x_8); -lean_inc(x_13); -lean_inc(x_12); -lean_inc(x_11); -lean_inc(x_10); -lean_inc(x_3); -lean_inc(x_2); -lean_inc(x_1); -x_26 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_25, x_10, x_11, x_12, x_13, x_14); -if (lean_obj_tag(x_26) == 0) -{ -lean_object* x_27; lean_object* x_28; lean_object* x_29; lean_object* x_30; lean_object* x_31; -x_27 = lean_ctor_get(x_26, 0); -lean_inc(x_27); -x_28 = lean_ctor_get(x_26, 1); -lean_inc(x_28); -lean_dec(x_26); -x_29 = lean_array_push(x_9, x_27); -x_30 = lean_ctor_get(x_6, 2); -x_31 = lean_nat_add(x_8, x_30); -lean_dec(x_8); -x_7 = x_20; -x_8 = x_31; -x_9 = x_29; -x_14 = x_28; -goto _start; -} -else -{ -uint8_t x_33; -lean_dec(x_20); -lean_dec(x_13); -lean_dec(x_12); -lean_dec(x_11); -lean_dec(x_10); -lean_dec(x_9); -lean_dec(x_8); -lean_dec(x_3); -lean_dec(x_2); -lean_dec(x_1); -x_33 = !lean_is_exclusive(x_26); -if (x_33 == 0) -{ -return x_26; -} -else -{ -lean_object* x_34; lean_object* x_35; lean_object* x_36; -x_34 = lean_ctor_get(x_26, 0); -x_35 = lean_ctor_get(x_26, 1); -lean_inc(x_35); -lean_inc(x_34); -lean_dec(x_26); -x_36 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_36, 0, x_34); -lean_ctor_set(x_36, 1, x_35); -return x_36; -} -} -} -else -{ -lean_object* x_37; lean_object* x_38; -x_37 = lean_ctor_get(x_6, 2); -x_38 = lean_nat_add(x_8, x_37); -lean_dec(x_8); -x_7 = x_20; -x_8 = x_38; -goto _start; -} -} -else -{ -lean_object* x_40; lean_object* x_41; -x_40 = lean_ctor_get(x_6, 2); -x_41 = lean_nat_add(x_8, x_40); -lean_dec(x_8); -x_7 = x_20; -x_8 = x_41; -goto _start; -} -} -else -{ -lean_object* x_43; -lean_dec(x_13); -lean_dec(x_12); -lean_dec(x_11); -lean_dec(x_10); -lean_dec(x_8); -lean_dec(x_7); -lean_dec(x_3); -lean_dec(x_2); -lean_dec(x_1); -x_43 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_43, 0, x_9); -lean_ctor_set(x_43, 1, x_14); -return x_43; -} -} -else -{ -lean_object* x_44; -lean_dec(x_13); -lean_dec(x_12); -lean_dec(x_11); -lean_dec(x_10); -lean_dec(x_8); -lean_dec(x_7); -lean_dec(x_3); -lean_dec(x_2); -lean_dec(x_1); -x_44 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_44, 0, x_9); -lean_ctor_set(x_44, 1, x_14); -return x_44; -} -} -} -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12) { -_start: -{ -lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; -x_13 = lean_array_get_size(x_1); -x_14 = l_Array_extract___rarg(x_1, x_2, x_13); -x_15 = lean_array_get_size(x_14); -x_16 = lean_unsigned_to_nat(0u); -x_17 = lean_unsigned_to_nat(1u); -lean_inc(x_15); -x_18 = lean_alloc_ctor(0, 3, 0); -lean_ctor_set(x_18, 0, x_16); -lean_ctor_set(x_18, 1, x_15); -lean_ctor_set(x_18, 2, x_17); -x_19 = l_Array_empty___closed__1; -x_20 = l_Std_Range_forIn_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8(x_3, x_4, x_5, x_6, x_14, x_18, x_15, x_16, x_19, x_8, x_9, x_10, x_11, x_12); -lean_dec(x_18); -lean_dec(x_14); -if (lean_obj_tag(x_20) == 0) -{ -uint8_t x_21; -x_21 = !lean_is_exclusive(x_20); -if (x_21 == 0) -{ -lean_object* x_22; lean_object* x_23; -x_22 = lean_ctor_get(x_20, 0); -x_23 = l_Array_iterateMAux___at_Lean_mkAppN___spec__1(x_22, x_22, x_16, x_7); -lean_dec(x_22); -lean_ctor_set(x_20, 0, x_23); -return x_20; -} -else -{ -lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; -x_24 = lean_ctor_get(x_20, 0); -x_25 = lean_ctor_get(x_20, 1); -lean_inc(x_25); -lean_inc(x_24); -lean_dec(x_20); -x_26 = l_Array_iterateMAux___at_Lean_mkAppN___spec__1(x_24, x_24, x_16, x_7); -lean_dec(x_24); -x_27 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_27, 0, x_26); -lean_ctor_set(x_27, 1, x_25); -return x_27; -} -} -else -{ -uint8_t x_28; -lean_dec(x_7); -x_28 = !lean_is_exclusive(x_20); -if (x_28 == 0) -{ -return x_20; -} -else -{ -lean_object* x_29; lean_object* x_30; lean_object* x_31; -x_29 = lean_ctor_get(x_20, 0); -x_30 = lean_ctor_get(x_20, 1); -lean_inc(x_30); -lean_inc(x_29); -lean_dec(x_20); -x_31 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_31, 0, x_29); -lean_ctor_set(x_31, 1, x_30); -return x_31; -} -} -} -} -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12, lean_object* x_13, lean_object* x_14) { -_start: -{ -lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; -x_15 = l_Lean_Expr_Lean_Expr___instance__11; -x_16 = lean_array_get(x_15, x_1, x_2); -x_17 = lean_ctor_get(x_5, 6); -lean_inc(x_17); -x_18 = lean_array_get_size(x_17); -lean_dec(x_17); -lean_inc(x_13); -lean_inc(x_12); -lean_inc(x_11); -lean_inc(x_10); -lean_inc(x_6); -x_19 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_toBelow(x_6, x_18, x_16, x_10, x_11, x_12, x_13, x_14); -if (lean_obj_tag(x_19) == 0) -{ -lean_object* x_20; lean_object* x_21; lean_object* x_22; -lean_dec(x_8); -x_20 = lean_ctor_get(x_19, 0); -lean_inc(x_20); -x_21 = lean_ctor_get(x_19, 1); -lean_inc(x_21); -lean_dec(x_19); -x_22 = l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__1(x_1, x_3, x_4, x_5, x_6, x_7, x_20, x_10, x_11, x_12, x_13, x_21); -return x_22; -} -else -{ -lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; lean_object* x_28; lean_object* x_29; uint8_t x_30; -lean_dec(x_6); -lean_dec(x_5); -lean_dec(x_4); -lean_dec(x_3); -lean_dec(x_1); -x_23 = lean_ctor_get(x_19, 1); -lean_inc(x_23); -lean_dec(x_19); -x_24 = l_Lean_indentExpr(x_8); -x_25 = l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___lambda__2___closed__2; -x_26 = lean_alloc_ctor(10, 2, 0); -lean_ctor_set(x_26, 0, x_25); -lean_ctor_set(x_26, 1, x_24); -x_27 = l_Array_iterateMAux___at_Lean_withNestedTraces___spec__5___closed__1; -x_28 = lean_alloc_ctor(10, 2, 0); -lean_ctor_set(x_28, 0, x_26); -lean_ctor_set(x_28, 1, x_27); -x_29 = l_Lean_throwError___at_Lean_Meta_getMVarDecl___spec__1___rarg(x_28, x_10, x_11, x_12, x_13, x_23); -lean_dec(x_13); -lean_dec(x_12); -lean_dec(x_11); -lean_dec(x_10); -x_30 = !lean_is_exclusive(x_29); -if (x_30 == 0) -{ -return x_29; -} -else -{ -lean_object* x_31; lean_object* x_32; lean_object* x_33; -x_31 = lean_ctor_get(x_29, 0); -x_32 = lean_ctor_get(x_29, 1); -lean_inc(x_32); -lean_inc(x_31); -lean_dec(x_29); -x_33 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_33, 0, x_31); -lean_ctor_set(x_33, 1, x_32); -return x_33; -} -} -} -} -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12) { -_start: -{ -if (lean_obj_tag(x_5) == 5) -{ -lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; -x_13 = lean_ctor_get(x_5, 0); -lean_inc(x_13); -x_14 = lean_ctor_get(x_5, 1); -lean_inc(x_14); -lean_dec(x_5); -x_15 = lean_array_set(x_6, x_7, x_14); -x_16 = lean_unsigned_to_nat(1u); -x_17 = lean_nat_sub(x_7, x_16); -lean_dec(x_7); -x_5 = x_13; -x_6 = x_15; -x_7 = x_17; -goto _start; -} -else -{ -uint8_t x_19; -lean_dec(x_7); -x_19 = l_Lean_Expr_isConstOf(x_5, x_1); -if (x_19 == 0) -{ -lean_object* x_20; -lean_dec(x_4); -lean_inc(x_11); -lean_inc(x_10); -lean_inc(x_9); -lean_inc(x_8); -lean_inc(x_3); -lean_inc(x_2); -lean_inc(x_1); -x_20 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_5, x_8, x_9, x_10, x_11, x_12); -if (lean_obj_tag(x_20) == 0) -{ -lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; -x_21 = lean_ctor_get(x_20, 0); -lean_inc(x_21); -x_22 = lean_ctor_get(x_20, 1); -lean_inc(x_22); -lean_dec(x_20); -x_23 = x_6; -x_24 = lean_unsigned_to_nat(0u); -x_25 = lean_alloc_closure((void*)(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7), 10, 5); -lean_closure_set(x_25, 0, x_1); -lean_closure_set(x_25, 1, x_2); -lean_closure_set(x_25, 2, x_3); -lean_closure_set(x_25, 3, x_24); -lean_closure_set(x_25, 4, x_23); -x_26 = x_25; -x_27 = lean_apply_5(x_26, x_8, x_9, x_10, x_11, x_22); -if (lean_obj_tag(x_27) == 0) -{ -uint8_t x_28; -x_28 = !lean_is_exclusive(x_27); -if (x_28 == 0) -{ -lean_object* x_29; lean_object* x_30; -x_29 = lean_ctor_get(x_27, 0); -x_30 = l_Array_iterateMAux___at_Lean_mkAppN___spec__1(x_29, x_29, x_24, x_21); -lean_dec(x_29); -lean_ctor_set(x_27, 0, x_30); -return x_27; -} -else -{ -lean_object* x_31; lean_object* x_32; lean_object* x_33; lean_object* x_34; -x_31 = lean_ctor_get(x_27, 0); -x_32 = lean_ctor_get(x_27, 1); -lean_inc(x_32); -lean_inc(x_31); -lean_dec(x_27); -x_33 = l_Array_iterateMAux___at_Lean_mkAppN___spec__1(x_31, x_31, x_24, x_21); -lean_dec(x_31); -x_34 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_34, 0, x_33); -lean_ctor_set(x_34, 1, x_32); -return x_34; -} -} -else -{ -uint8_t x_35; -lean_dec(x_21); -x_35 = !lean_is_exclusive(x_27); -if (x_35 == 0) -{ -return x_27; -} -else -{ -lean_object* x_36; lean_object* x_37; lean_object* x_38; -x_36 = lean_ctor_get(x_27, 0); -x_37 = lean_ctor_get(x_27, 1); -lean_inc(x_37); -lean_inc(x_36); -lean_dec(x_27); -x_38 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_38, 0, x_36); -lean_ctor_set(x_38, 1, x_37); -return x_38; -} -} -} -else -{ -uint8_t x_39; -lean_dec(x_11); -lean_dec(x_10); -lean_dec(x_9); -lean_dec(x_8); -lean_dec(x_6); -lean_dec(x_3); -lean_dec(x_2); -lean_dec(x_1); -x_39 = !lean_is_exclusive(x_20); -if (x_39 == 0) -{ -return x_20; -} -else -{ -lean_object* x_40; lean_object* x_41; lean_object* x_42; -x_40 = lean_ctor_get(x_20, 0); -x_41 = lean_ctor_get(x_20, 1); -lean_inc(x_41); -lean_inc(x_40); -lean_dec(x_20); -x_42 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_42, 0, x_40); -lean_ctor_set(x_42, 1, x_41); -return x_42; -} -} -} -else -{ -lean_object* x_43; lean_object* x_44; lean_object* x_45; lean_object* x_46; lean_object* x_47; uint8_t x_48; -lean_dec(x_5); -x_43 = lean_ctor_get(x_2, 0); -lean_inc(x_43); -x_44 = lean_array_get_size(x_43); -lean_dec(x_43); -x_45 = lean_ctor_get(x_2, 2); -lean_inc(x_45); -x_46 = lean_nat_add(x_44, x_45); -x_47 = lean_array_get_size(x_6); -x_48 = lean_nat_dec_le(x_47, x_46); -lean_dec(x_47); -if (x_48 == 0) -{ -lean_object* x_49; lean_object* x_50; -x_49 = lean_box(0); -x_50 = l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__2(x_6, x_46, x_44, x_1, x_2, x_3, x_45, x_4, x_49, x_8, x_9, x_10, x_11, x_12); -lean_dec(x_45); -lean_dec(x_46); -return x_50; -} -else -{ -lean_object* x_51; lean_object* x_52; lean_object* x_53; lean_object* x_54; lean_object* x_55; lean_object* x_56; uint8_t x_57; -lean_dec(x_46); -lean_dec(x_45); -lean_dec(x_44); -lean_dec(x_6); -lean_dec(x_3); -lean_dec(x_2); -lean_dec(x_1); -x_51 = l_Lean_indentExpr(x_4); -x_52 = l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___closed__2; -x_53 = lean_alloc_ctor(10, 2, 0); -lean_ctor_set(x_53, 0, x_52); -lean_ctor_set(x_53, 1, x_51); -x_54 = l_Array_iterateMAux___at_Lean_withNestedTraces___spec__5___closed__1; -x_55 = lean_alloc_ctor(10, 2, 0); -lean_ctor_set(x_55, 0, x_53); -lean_ctor_set(x_55, 1, x_54); -x_56 = l_Lean_throwError___at_Lean_Meta_getMVarDecl___spec__1___rarg(x_55, x_8, x_9, x_10, x_11, x_12); -lean_dec(x_11); -lean_dec(x_10); -lean_dec(x_9); -lean_dec(x_8); -x_57 = !lean_is_exclusive(x_56); -if (x_57 == 0) -{ -return x_56; -} -else -{ -lean_object* x_58; lean_object* x_59; lean_object* x_60; -x_58 = lean_ctor_get(x_56, 0); -x_59 = lean_ctor_get(x_56, 1); -lean_inc(x_59); -lean_inc(x_58); -lean_dec(x_56); -x_60 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_60, 0, x_58); -lean_ctor_set(x_60, 1, x_59); -return x_60; -} -} -} -} -} -} -lean_object* l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__10___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { +lean_object* l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { uint8_t x_8; lean_object* x_9; @@ -10522,15 +9920,15 @@ return x_17; } } } -lean_object* l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__10(lean_object* x_1) { +lean_object* l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7(lean_object* x_1) { _start: { lean_object* x_2; -x_2 = lean_alloc_closure((void*)(l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__10___rarg), 7, 0); +x_2 = lean_alloc_closure((void*)(l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7___rarg), 7, 0); return x_2; } } -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11) { +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11) { _start: { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; @@ -10587,7 +9985,7 @@ return x_23; } } } -static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__1() { +static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__1() { _start: { lean_object* x_1; @@ -10595,16 +9993,16 @@ x_1 = lean_mk_string("unexpected matcher application alternative"); return x_1; } } -static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__2() { +static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__2() { _start: { lean_object* x_1; lean_object* x_2; -x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__1; +x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__1; x_2 = l_Lean_stringToMessageData(x_1); return x_2; } } -static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__3() { +static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__3() { _start: { lean_object* x_1; @@ -10612,16 +10010,16 @@ x_1 = lean_mk_string("\nat application"); return x_1; } } -static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__4() { +static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__4() { _start: { lean_object* x_1; lean_object* x_2; -x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__3; +x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__3; x_2 = l_Lean_stringToMessageData(x_1); return x_2; } } -static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__5() { +static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__5() { _start: { lean_object* x_1; @@ -10629,16 +10027,16 @@ x_1 = lean_mk_string("altNumParams: "); return x_1; } } -static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__6() { +static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__6() { _start: { lean_object* x_1; lean_object* x_2; -x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__5; +x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__5; x_2 = l_Lean_stringToMessageData(x_1); return x_2; } } -static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__7() { +static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__7() { _start: { lean_object* x_1; @@ -10646,16 +10044,16 @@ x_1 = lean_mk_string(", xs: "); return x_1; } } -static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__8() { +static lean_object* _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__8() { _start: { lean_object* x_1; lean_object* x_2; -x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__7; +x_1 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__7; x_2 = l_Lean_stringToMessageData(x_1); return x_2; } } -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12) { +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12) { _start: { lean_object* x_13; uint8_t x_33; lean_object* x_34; lean_object* x_51; lean_object* x_52; lean_object* x_53; uint8_t x_54; @@ -10712,11 +10110,11 @@ lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_16 = l_Lean_indentExpr(x_4); -x_17 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__2; +x_17 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__2; x_18 = lean_alloc_ctor(10, 2, 0); lean_ctor_set(x_18, 0, x_17); lean_ctor_set(x_18, 1, x_16); -x_19 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__4; +x_19 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__4; x_20 = lean_alloc_ctor(10, 2, 0); lean_ctor_set(x_20, 0, x_18); lean_ctor_set(x_20, 1, x_19); @@ -10758,7 +10156,7 @@ lean_object* x_30; lean_object* x_31; lean_dec(x_5); lean_dec(x_4); x_30 = lean_box(0); -x_31 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__1(x_1, x_6, x_2, x_3, x_7, x_30, x_8, x_9, x_10, x_11, x_13); +x_31 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__1(x_1, x_6, x_2, x_3, x_7, x_30, x_8, x_9, x_10, x_11, x_13); lean_dec(x_1); return x_31; } @@ -10777,11 +10175,11 @@ lean_inc(x_1); x_35 = l_Lean_fmt___at_Lean_Position_Lean_Data_Position___instance__2___spec__1(x_1); x_36 = lean_alloc_ctor(0, 1, 0); lean_ctor_set(x_36, 0, x_35); -x_37 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__6; +x_37 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__6; x_38 = lean_alloc_ctor(10, 2, 0); lean_ctor_set(x_38, 0, x_37); lean_ctor_set(x_38, 1, x_36); -x_39 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__8; +x_39 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__8; x_40 = lean_alloc_ctor(10, 2, 0); lean_ctor_set(x_40, 0, x_38); lean_ctor_set(x_40, 1, x_39); @@ -10807,7 +10205,7 @@ goto block_32; } } } -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10) { +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10) { _start: { lean_object* x_11; uint8_t x_12; @@ -10847,7 +10245,7 @@ lean_inc(x_3); lean_inc(x_19); lean_inc(x_2); lean_inc(x_1); -x_21 = lean_alloc_closure((void*)(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2), 12, 5); +x_21 = lean_alloc_closure((void*)(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2), 12, 5); lean_closure_set(x_21, 0, x_20); lean_closure_set(x_21, 1, x_1); lean_closure_set(x_21, 2, x_2); @@ -10857,7 +10255,7 @@ lean_inc(x_9); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); -x_22 = l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__10___rarg(x_19, x_21, x_6, x_7, x_8, x_9, x_10); +x_22 = l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7___rarg(x_19, x_21, x_6, x_7, x_8, x_9, x_10); if (lean_obj_tag(x_22) == 0) { lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; lean_object* x_28; @@ -10910,7 +10308,7 @@ return x_33; } } } -lean_object* l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__12___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { +lean_object* l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; @@ -10961,11 +10359,11 @@ return x_18; } } } -lean_object* l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__12(lean_object* x_1) { +lean_object* l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9(lean_object* x_1) { _start: { lean_object* x_2; -x_2 = lean_alloc_closure((void*)(l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__12___rarg), 9, 0); +x_2 = lean_alloc_closure((void*)(l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___rarg), 9, 0); return x_2; } } @@ -11186,50 +10584,216 @@ return x_29; } else { -lean_object* x_30; lean_object* x_31; lean_object* x_32; lean_object* x_33; lean_object* x_34; lean_object* x_35; lean_object* x_36; lean_object* x_37; lean_object* x_38; lean_object* x_39; lean_object* x_40; lean_object* x_41; lean_object* x_42; lean_object* x_43; lean_object* x_44; lean_object* x_45; -x_30 = lean_unsigned_to_nat(0u); -x_31 = l_Lean_Expr_getAppNumArgsAux(x_4, x_30); -x_32 = l_Lean_Expr_getAppArgs___closed__1; -lean_inc(x_31); -x_33 = lean_mk_array(x_31, x_32); -x_34 = lean_unsigned_to_nat(1u); -x_35 = lean_nat_sub(x_31, x_34); -lean_dec(x_31); -lean_inc(x_3); -x_36 = lean_alloc_closure((void*)(l_Lean_Meta_MatcherApp_addArg), 7, 2); -lean_closure_set(x_36, 0, x_21); -lean_closure_set(x_36, 1, x_3); -x_37 = lean_st_ref_get(x_8, x_20); -x_38 = lean_ctor_get(x_37, 0); -lean_inc(x_38); -x_39 = lean_ctor_get(x_37, 1); -lean_inc(x_39); -lean_dec(x_37); -x_40 = lean_ctor_get(x_38, 0); -lean_inc(x_40); -lean_dec(x_38); -x_41 = lean_st_ref_get(x_6, x_39); -x_42 = lean_ctor_get(x_41, 0); -lean_inc(x_42); -x_43 = lean_ctor_get(x_41, 1); -lean_inc(x_43); -lean_dec(x_41); -x_44 = lean_ctor_get(x_42, 0); -lean_inc(x_44); -lean_dec(x_42); +lean_object* x_30; lean_object* x_31; lean_object* x_32; +x_30 = lean_alloc_closure((void*)(l_Lean_Meta_MatcherApp_addArg), 7, 2); +lean_closure_set(x_30, 0, x_21); +lean_closure_set(x_30, 1, x_3); +x_31 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___closed__1; lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); -lean_inc_n(x_4, 2); -lean_inc(x_2); -lean_inc(x_1); -x_45 = l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9(x_1, x_2, x_3, x_4, x_4, x_33, x_35, x_5, x_6, x_7, x_8, x_43); -if (lean_obj_tag(x_45) == 0) +x_32 = l_Lean_Meta_mapErrorImp___rarg(x_30, x_31, x_5, x_6, x_7, x_8, x_20); +if (lean_obj_tag(x_32) == 0) { +lean_object* x_33; lean_object* x_34; uint8_t x_35; +x_33 = lean_ctor_get(x_32, 0); +lean_inc(x_33); +x_34 = lean_ctor_get(x_32, 1); +lean_inc(x_34); +lean_dec(x_32); +x_35 = !lean_is_exclusive(x_33); +if (x_35 == 0) +{ +lean_object* x_36; lean_object* x_37; lean_object* x_38; lean_object* x_39; lean_object* x_40; lean_object* x_41; lean_object* x_42; lean_object* x_43; lean_object* x_44; lean_object* x_45; lean_object* x_46; lean_object* x_47; lean_object* x_48; lean_object* x_49; lean_object* x_50; +x_36 = lean_ctor_get(x_33, 0); +x_37 = lean_ctor_get(x_33, 1); +x_38 = lean_ctor_get(x_33, 2); +x_39 = lean_ctor_get(x_33, 3); +x_40 = lean_ctor_get(x_33, 4); +x_41 = lean_ctor_get(x_33, 5); +x_42 = lean_ctor_get(x_33, 6); +x_43 = lean_ctor_get(x_33, 7); +x_44 = lean_ctor_get(x_33, 8); +x_45 = l_Array_zip___rarg(x_43, x_42); +lean_dec(x_43); +x_46 = x_45; +x_47 = lean_unsigned_to_nat(0u); +x_48 = lean_alloc_closure((void*)(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8), 10, 5); +lean_closure_set(x_48, 0, x_1); +lean_closure_set(x_48, 1, x_2); +lean_closure_set(x_48, 2, x_4); +lean_closure_set(x_48, 3, x_47); +lean_closure_set(x_48, 4, x_46); +x_49 = x_48; +x_50 = lean_apply_5(x_49, x_5, x_6, x_7, x_8, x_34); +if (lean_obj_tag(x_50) == 0) +{ +uint8_t x_51; +x_51 = !lean_is_exclusive(x_50); +if (x_51 == 0) +{ +lean_object* x_52; lean_object* x_53; +x_52 = lean_ctor_get(x_50, 0); +lean_ctor_set(x_33, 7, x_52); +x_53 = l_Lean_Meta_MatcherApp_toExpr(x_33); +lean_ctor_set(x_50, 0, x_53); +return x_50; +} +else +{ +lean_object* x_54; lean_object* x_55; lean_object* x_56; lean_object* x_57; +x_54 = lean_ctor_get(x_50, 0); +x_55 = lean_ctor_get(x_50, 1); +lean_inc(x_55); +lean_inc(x_54); +lean_dec(x_50); +lean_ctor_set(x_33, 7, x_54); +x_56 = l_Lean_Meta_MatcherApp_toExpr(x_33); +x_57 = lean_alloc_ctor(0, 2, 0); +lean_ctor_set(x_57, 0, x_56); +lean_ctor_set(x_57, 1, x_55); +return x_57; +} +} +else +{ +uint8_t x_58; +lean_free_object(x_33); lean_dec(x_44); +lean_dec(x_42); +lean_dec(x_41); lean_dec(x_40); +lean_dec(x_39); +lean_dec(x_38); +lean_dec(x_37); lean_dec(x_36); +x_58 = !lean_is_exclusive(x_50); +if (x_58 == 0) +{ +return x_50; +} +else +{ +lean_object* x_59; lean_object* x_60; lean_object* x_61; +x_59 = lean_ctor_get(x_50, 0); +x_60 = lean_ctor_get(x_50, 1); +lean_inc(x_60); +lean_inc(x_59); +lean_dec(x_50); +x_61 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_61, 0, x_59); +lean_ctor_set(x_61, 1, x_60); +return x_61; +} +} +} +else +{ +lean_object* x_62; lean_object* x_63; lean_object* x_64; lean_object* x_65; lean_object* x_66; lean_object* x_67; lean_object* x_68; lean_object* x_69; lean_object* x_70; lean_object* x_71; lean_object* x_72; lean_object* x_73; lean_object* x_74; lean_object* x_75; lean_object* x_76; +x_62 = lean_ctor_get(x_33, 0); +x_63 = lean_ctor_get(x_33, 1); +x_64 = lean_ctor_get(x_33, 2); +x_65 = lean_ctor_get(x_33, 3); +x_66 = lean_ctor_get(x_33, 4); +x_67 = lean_ctor_get(x_33, 5); +x_68 = lean_ctor_get(x_33, 6); +x_69 = lean_ctor_get(x_33, 7); +x_70 = lean_ctor_get(x_33, 8); +lean_inc(x_70); +lean_inc(x_69); +lean_inc(x_68); +lean_inc(x_67); +lean_inc(x_66); +lean_inc(x_65); +lean_inc(x_64); +lean_inc(x_63); +lean_inc(x_62); +lean_dec(x_33); +x_71 = l_Array_zip___rarg(x_69, x_68); +lean_dec(x_69); +x_72 = x_71; +x_73 = lean_unsigned_to_nat(0u); +x_74 = lean_alloc_closure((void*)(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8), 10, 5); +lean_closure_set(x_74, 0, x_1); +lean_closure_set(x_74, 1, x_2); +lean_closure_set(x_74, 2, x_4); +lean_closure_set(x_74, 3, x_73); +lean_closure_set(x_74, 4, x_72); +x_75 = x_74; +x_76 = lean_apply_5(x_75, x_5, x_6, x_7, x_8, x_34); +if (lean_obj_tag(x_76) == 0) +{ +lean_object* x_77; lean_object* x_78; lean_object* x_79; lean_object* x_80; lean_object* x_81; lean_object* x_82; +x_77 = lean_ctor_get(x_76, 0); +lean_inc(x_77); +x_78 = lean_ctor_get(x_76, 1); +lean_inc(x_78); +if (lean_is_exclusive(x_76)) { + lean_ctor_release(x_76, 0); + lean_ctor_release(x_76, 1); + x_79 = x_76; +} else { + lean_dec_ref(x_76); + x_79 = lean_box(0); +} +x_80 = lean_alloc_ctor(0, 9, 0); +lean_ctor_set(x_80, 0, x_62); +lean_ctor_set(x_80, 1, x_63); +lean_ctor_set(x_80, 2, x_64); +lean_ctor_set(x_80, 3, x_65); +lean_ctor_set(x_80, 4, x_66); +lean_ctor_set(x_80, 5, x_67); +lean_ctor_set(x_80, 6, x_68); +lean_ctor_set(x_80, 7, x_77); +lean_ctor_set(x_80, 8, x_70); +x_81 = l_Lean_Meta_MatcherApp_toExpr(x_80); +if (lean_is_scalar(x_79)) { + x_82 = lean_alloc_ctor(0, 2, 0); +} else { + x_82 = x_79; +} +lean_ctor_set(x_82, 0, x_81); +lean_ctor_set(x_82, 1, x_78); +return x_82; +} +else +{ +lean_object* x_83; lean_object* x_84; lean_object* x_85; lean_object* x_86; +lean_dec(x_70); +lean_dec(x_68); +lean_dec(x_67); +lean_dec(x_66); +lean_dec(x_65); +lean_dec(x_64); +lean_dec(x_63); +lean_dec(x_62); +x_83 = lean_ctor_get(x_76, 0); +lean_inc(x_83); +x_84 = lean_ctor_get(x_76, 1); +lean_inc(x_84); +if (lean_is_exclusive(x_76)) { + lean_ctor_release(x_76, 0); + lean_ctor_release(x_76, 1); + x_85 = x_76; +} else { + lean_dec_ref(x_76); + x_85 = lean_box(0); +} +if (lean_is_scalar(x_85)) { + x_86 = lean_alloc_ctor(1, 2, 0); +} else { + x_86 = x_85; +} +lean_ctor_set(x_86, 0, x_83); +lean_ctor_set(x_86, 1, x_84); +return x_86; +} +} +} +else +{ +uint8_t x_87; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); @@ -11237,251 +10801,23 @@ lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); -return x_45; +x_87 = !lean_is_exclusive(x_32); +if (x_87 == 0) +{ +return x_32; } else { -lean_object* x_46; lean_object* x_47; lean_object* x_48; lean_object* x_49; lean_object* x_50; lean_object* x_51; lean_object* x_52; -x_46 = lean_ctor_get(x_45, 1); -lean_inc(x_46); -lean_dec(x_45); -x_47 = l_Lean_setEnv___at_Lean_Meta_setInlineAttribute___spec__1(x_40, x_5, x_6, x_7, x_8, x_46); -x_48 = lean_ctor_get(x_47, 1); -lean_inc(x_48); -lean_dec(x_47); -x_49 = l_Lean_Meta_setMCtx___at___private_Lean_Meta_Basic_0__Lean_Meta_liftMkBindingM___spec__1(x_44, x_5, x_6, x_7, x_8, x_48); -x_50 = lean_ctor_get(x_49, 1); -lean_inc(x_50); -lean_dec(x_49); -x_51 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___closed__1; -lean_inc(x_8); -lean_inc(x_7); -lean_inc(x_6); -lean_inc(x_5); -x_52 = l_Lean_Meta_mapErrorImp___rarg(x_36, x_51, x_5, x_6, x_7, x_8, x_50); -if (lean_obj_tag(x_52) == 0) -{ -lean_object* x_53; lean_object* x_54; uint8_t x_55; -x_53 = lean_ctor_get(x_52, 0); -lean_inc(x_53); -x_54 = lean_ctor_get(x_52, 1); -lean_inc(x_54); -lean_dec(x_52); -x_55 = !lean_is_exclusive(x_53); -if (x_55 == 0) -{ -lean_object* x_56; lean_object* x_57; lean_object* x_58; lean_object* x_59; lean_object* x_60; lean_object* x_61; lean_object* x_62; lean_object* x_63; lean_object* x_64; lean_object* x_65; lean_object* x_66; lean_object* x_67; lean_object* x_68; lean_object* x_69; -x_56 = lean_ctor_get(x_53, 0); -x_57 = lean_ctor_get(x_53, 1); -x_58 = lean_ctor_get(x_53, 2); -x_59 = lean_ctor_get(x_53, 3); -x_60 = lean_ctor_get(x_53, 4); -x_61 = lean_ctor_get(x_53, 5); -x_62 = lean_ctor_get(x_53, 6); -x_63 = lean_ctor_get(x_53, 7); -x_64 = lean_ctor_get(x_53, 8); -x_65 = l_Array_zip___rarg(x_63, x_62); -lean_dec(x_63); -x_66 = x_65; -x_67 = lean_alloc_closure((void*)(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11), 10, 5); -lean_closure_set(x_67, 0, x_1); -lean_closure_set(x_67, 1, x_2); -lean_closure_set(x_67, 2, x_4); -lean_closure_set(x_67, 3, x_30); -lean_closure_set(x_67, 4, x_66); -x_68 = x_67; -x_69 = lean_apply_5(x_68, x_5, x_6, x_7, x_8, x_54); -if (lean_obj_tag(x_69) == 0) -{ -uint8_t x_70; -x_70 = !lean_is_exclusive(x_69); -if (x_70 == 0) -{ -lean_object* x_71; lean_object* x_72; -x_71 = lean_ctor_get(x_69, 0); -lean_ctor_set(x_53, 7, x_71); -x_72 = l_Lean_Meta_MatcherApp_toExpr(x_53); -lean_ctor_set(x_69, 0, x_72); -return x_69; -} -else -{ -lean_object* x_73; lean_object* x_74; lean_object* x_75; lean_object* x_76; -x_73 = lean_ctor_get(x_69, 0); -x_74 = lean_ctor_get(x_69, 1); -lean_inc(x_74); -lean_inc(x_73); -lean_dec(x_69); -lean_ctor_set(x_53, 7, x_73); -x_75 = l_Lean_Meta_MatcherApp_toExpr(x_53); -x_76 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_76, 0, x_75); -lean_ctor_set(x_76, 1, x_74); -return x_76; -} -} -else -{ -uint8_t x_77; -lean_free_object(x_53); -lean_dec(x_64); -lean_dec(x_62); -lean_dec(x_61); -lean_dec(x_60); -lean_dec(x_59); -lean_dec(x_58); -lean_dec(x_57); -lean_dec(x_56); -x_77 = !lean_is_exclusive(x_69); -if (x_77 == 0) -{ -return x_69; -} -else -{ -lean_object* x_78; lean_object* x_79; lean_object* x_80; -x_78 = lean_ctor_get(x_69, 0); -x_79 = lean_ctor_get(x_69, 1); -lean_inc(x_79); -lean_inc(x_78); -lean_dec(x_69); -x_80 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_80, 0, x_78); -lean_ctor_set(x_80, 1, x_79); -return x_80; -} -} -} -else -{ -lean_object* x_81; lean_object* x_82; lean_object* x_83; lean_object* x_84; lean_object* x_85; lean_object* x_86; lean_object* x_87; lean_object* x_88; lean_object* x_89; lean_object* x_90; lean_object* x_91; lean_object* x_92; lean_object* x_93; lean_object* x_94; -x_81 = lean_ctor_get(x_53, 0); -x_82 = lean_ctor_get(x_53, 1); -x_83 = lean_ctor_get(x_53, 2); -x_84 = lean_ctor_get(x_53, 3); -x_85 = lean_ctor_get(x_53, 4); -x_86 = lean_ctor_get(x_53, 5); -x_87 = lean_ctor_get(x_53, 6); -x_88 = lean_ctor_get(x_53, 7); -x_89 = lean_ctor_get(x_53, 8); +lean_object* x_88; lean_object* x_89; lean_object* x_90; +x_88 = lean_ctor_get(x_32, 0); +x_89 = lean_ctor_get(x_32, 1); lean_inc(x_89); lean_inc(x_88); -lean_inc(x_87); -lean_inc(x_86); -lean_inc(x_85); -lean_inc(x_84); -lean_inc(x_83); -lean_inc(x_82); -lean_inc(x_81); -lean_dec(x_53); -x_90 = l_Array_zip___rarg(x_88, x_87); -lean_dec(x_88); -x_91 = x_90; -x_92 = lean_alloc_closure((void*)(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11), 10, 5); -lean_closure_set(x_92, 0, x_1); -lean_closure_set(x_92, 1, x_2); -lean_closure_set(x_92, 2, x_4); -lean_closure_set(x_92, 3, x_30); -lean_closure_set(x_92, 4, x_91); -x_93 = x_92; -x_94 = lean_apply_5(x_93, x_5, x_6, x_7, x_8, x_54); -if (lean_obj_tag(x_94) == 0) -{ -lean_object* x_95; lean_object* x_96; lean_object* x_97; lean_object* x_98; lean_object* x_99; lean_object* x_100; -x_95 = lean_ctor_get(x_94, 0); -lean_inc(x_95); -x_96 = lean_ctor_get(x_94, 1); -lean_inc(x_96); -if (lean_is_exclusive(x_94)) { - lean_ctor_release(x_94, 0); - lean_ctor_release(x_94, 1); - x_97 = x_94; -} else { - lean_dec_ref(x_94); - x_97 = lean_box(0); -} -x_98 = lean_alloc_ctor(0, 9, 0); -lean_ctor_set(x_98, 0, x_81); -lean_ctor_set(x_98, 1, x_82); -lean_ctor_set(x_98, 2, x_83); -lean_ctor_set(x_98, 3, x_84); -lean_ctor_set(x_98, 4, x_85); -lean_ctor_set(x_98, 5, x_86); -lean_ctor_set(x_98, 6, x_87); -lean_ctor_set(x_98, 7, x_95); -lean_ctor_set(x_98, 8, x_89); -x_99 = l_Lean_Meta_MatcherApp_toExpr(x_98); -if (lean_is_scalar(x_97)) { - x_100 = lean_alloc_ctor(0, 2, 0); -} else { - x_100 = x_97; -} -lean_ctor_set(x_100, 0, x_99); -lean_ctor_set(x_100, 1, x_96); -return x_100; -} -else -{ -lean_object* x_101; lean_object* x_102; lean_object* x_103; lean_object* x_104; -lean_dec(x_89); -lean_dec(x_87); -lean_dec(x_86); -lean_dec(x_85); -lean_dec(x_84); -lean_dec(x_83); -lean_dec(x_82); -lean_dec(x_81); -x_101 = lean_ctor_get(x_94, 0); -lean_inc(x_101); -x_102 = lean_ctor_get(x_94, 1); -lean_inc(x_102); -if (lean_is_exclusive(x_94)) { - lean_ctor_release(x_94, 0); - lean_ctor_release(x_94, 1); - x_103 = x_94; -} else { - lean_dec_ref(x_94); - x_103 = lean_box(0); -} -if (lean_is_scalar(x_103)) { - x_104 = lean_alloc_ctor(1, 2, 0); -} else { - x_104 = x_103; -} -lean_ctor_set(x_104, 0, x_101); -lean_ctor_set(x_104, 1, x_102); -return x_104; -} -} -} -else -{ -uint8_t x_105; -lean_dec(x_8); -lean_dec(x_7); -lean_dec(x_6); -lean_dec(x_5); -lean_dec(x_4); -lean_dec(x_2); -lean_dec(x_1); -x_105 = !lean_is_exclusive(x_52); -if (x_105 == 0) -{ -return x_52; -} -else -{ -lean_object* x_106; lean_object* x_107; lean_object* x_108; -x_106 = lean_ctor_get(x_52, 0); -x_107 = lean_ctor_get(x_52, 1); -lean_inc(x_107); -lean_inc(x_106); -lean_dec(x_52); -x_108 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_108, 0, x_106); -lean_ctor_set(x_108, 1, x_107); -return x_108; -} +lean_dec(x_32); +x_90 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_90, 0, x_88); +lean_ctor_set(x_90, 1, x_89); +return x_90; } } } @@ -11489,14 +10825,14 @@ return x_108; } case 6: { -lean_object* x_109; lean_object* x_110; lean_object* x_111; uint64_t x_112; lean_object* x_113; -x_109 = lean_ctor_get(x_4, 0); -lean_inc(x_109); -x_110 = lean_ctor_get(x_4, 1); -lean_inc(x_110); -x_111 = lean_ctor_get(x_4, 2); -lean_inc(x_111); -x_112 = lean_ctor_get_uint64(x_4, sizeof(void*)*3); +lean_object* x_91; lean_object* x_92; lean_object* x_93; uint64_t x_94; lean_object* x_95; +x_91 = lean_ctor_get(x_4, 0); +lean_inc(x_91); +x_92 = lean_ctor_get(x_4, 1); +lean_inc(x_92); +x_93 = lean_ctor_get(x_4, 2); +lean_inc(x_93); +x_94 = lean_ctor_get_uint64(x_4, sizeof(void*)*3); lean_dec(x_4); lean_inc(x_8); lean_inc(x_7); @@ -11505,29 +10841,29 @@ lean_inc(x_5); lean_inc(x_3); lean_inc(x_2); lean_inc(x_1); -x_113 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_110, x_5, x_6, x_7, x_8, x_9); -if (lean_obj_tag(x_113) == 0) +x_95 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_92, x_5, x_6, x_7, x_8, x_9); +if (lean_obj_tag(x_95) == 0) { -lean_object* x_114; lean_object* x_115; uint8_t x_116; lean_object* x_117; lean_object* x_118; -x_114 = lean_ctor_get(x_113, 0); -lean_inc(x_114); -x_115 = lean_ctor_get(x_113, 1); -lean_inc(x_115); -lean_dec(x_113); -x_116 = (uint8_t)((x_112 << 24) >> 61); -x_117 = lean_alloc_closure((void*)(l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__2___boxed), 10, 4); -lean_closure_set(x_117, 0, x_111); -lean_closure_set(x_117, 1, x_1); -lean_closure_set(x_117, 2, x_2); -lean_closure_set(x_117, 3, x_3); -x_118 = l_Lean_Meta_withLocalDecl___at_Lean_Meta_forallTelescopeCompatibleAux___spec__1___rarg(x_109, x_116, x_114, x_117, x_5, x_6, x_7, x_8, x_115); -return x_118; +lean_object* x_96; lean_object* x_97; uint8_t x_98; lean_object* x_99; lean_object* x_100; +x_96 = lean_ctor_get(x_95, 0); +lean_inc(x_96); +x_97 = lean_ctor_get(x_95, 1); +lean_inc(x_97); +lean_dec(x_95); +x_98 = (uint8_t)((x_94 << 24) >> 61); +x_99 = lean_alloc_closure((void*)(l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__2___boxed), 10, 4); +lean_closure_set(x_99, 0, x_93); +lean_closure_set(x_99, 1, x_1); +lean_closure_set(x_99, 2, x_2); +lean_closure_set(x_99, 3, x_3); +x_100 = l_Lean_Meta_withLocalDecl___at_Lean_Meta_forallTelescopeCompatibleAux___spec__1___rarg(x_91, x_98, x_96, x_99, x_5, x_6, x_7, x_8, x_97); +return x_100; } else { -uint8_t x_119; -lean_dec(x_111); -lean_dec(x_109); +uint8_t x_101; +lean_dec(x_93); +lean_dec(x_91); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); @@ -11535,36 +10871,36 @@ lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); -x_119 = !lean_is_exclusive(x_113); -if (x_119 == 0) +x_101 = !lean_is_exclusive(x_95); +if (x_101 == 0) { -return x_113; +return x_95; } else { -lean_object* x_120; lean_object* x_121; lean_object* x_122; -x_120 = lean_ctor_get(x_113, 0); -x_121 = lean_ctor_get(x_113, 1); -lean_inc(x_121); -lean_inc(x_120); -lean_dec(x_113); -x_122 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_122, 0, x_120); -lean_ctor_set(x_122, 1, x_121); -return x_122; +lean_object* x_102; lean_object* x_103; lean_object* x_104; +x_102 = lean_ctor_get(x_95, 0); +x_103 = lean_ctor_get(x_95, 1); +lean_inc(x_103); +lean_inc(x_102); +lean_dec(x_95); +x_104 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_104, 0, x_102); +lean_ctor_set(x_104, 1, x_103); +return x_104; } } } case 7: { -lean_object* x_123; lean_object* x_124; lean_object* x_125; uint64_t x_126; lean_object* x_127; -x_123 = lean_ctor_get(x_4, 0); -lean_inc(x_123); -x_124 = lean_ctor_get(x_4, 1); -lean_inc(x_124); -x_125 = lean_ctor_get(x_4, 2); -lean_inc(x_125); -x_126 = lean_ctor_get_uint64(x_4, sizeof(void*)*3); +lean_object* x_105; lean_object* x_106; lean_object* x_107; uint64_t x_108; lean_object* x_109; +x_105 = lean_ctor_get(x_4, 0); +lean_inc(x_105); +x_106 = lean_ctor_get(x_4, 1); +lean_inc(x_106); +x_107 = lean_ctor_get(x_4, 2); +lean_inc(x_107); +x_108 = lean_ctor_get_uint64(x_4, sizeof(void*)*3); lean_dec(x_4); lean_inc(x_8); lean_inc(x_7); @@ -11573,29 +10909,29 @@ lean_inc(x_5); lean_inc(x_3); lean_inc(x_2); lean_inc(x_1); -x_127 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_124, x_5, x_6, x_7, x_8, x_9); -if (lean_obj_tag(x_127) == 0) +x_109 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_106, x_5, x_6, x_7, x_8, x_9); +if (lean_obj_tag(x_109) == 0) { -lean_object* x_128; lean_object* x_129; uint8_t x_130; lean_object* x_131; lean_object* x_132; -x_128 = lean_ctor_get(x_127, 0); -lean_inc(x_128); -x_129 = lean_ctor_get(x_127, 1); -lean_inc(x_129); -lean_dec(x_127); -x_130 = (uint8_t)((x_126 << 24) >> 61); -x_131 = lean_alloc_closure((void*)(l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__3___boxed), 10, 4); -lean_closure_set(x_131, 0, x_125); -lean_closure_set(x_131, 1, x_1); -lean_closure_set(x_131, 2, x_2); -lean_closure_set(x_131, 3, x_3); -x_132 = l_Lean_Meta_withLocalDecl___at_Lean_Meta_forallTelescopeCompatibleAux___spec__1___rarg(x_123, x_130, x_128, x_131, x_5, x_6, x_7, x_8, x_129); -return x_132; +lean_object* x_110; lean_object* x_111; uint8_t x_112; lean_object* x_113; lean_object* x_114; +x_110 = lean_ctor_get(x_109, 0); +lean_inc(x_110); +x_111 = lean_ctor_get(x_109, 1); +lean_inc(x_111); +lean_dec(x_109); +x_112 = (uint8_t)((x_108 << 24) >> 61); +x_113 = lean_alloc_closure((void*)(l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__3___boxed), 10, 4); +lean_closure_set(x_113, 0, x_107); +lean_closure_set(x_113, 1, x_1); +lean_closure_set(x_113, 2, x_2); +lean_closure_set(x_113, 3, x_3); +x_114 = l_Lean_Meta_withLocalDecl___at_Lean_Meta_forallTelescopeCompatibleAux___spec__1___rarg(x_105, x_112, x_110, x_113, x_5, x_6, x_7, x_8, x_111); +return x_114; } else { -uint8_t x_133; -lean_dec(x_125); -lean_dec(x_123); +uint8_t x_115; +lean_dec(x_107); +lean_dec(x_105); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); @@ -11603,37 +10939,37 @@ lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); -x_133 = !lean_is_exclusive(x_127); -if (x_133 == 0) +x_115 = !lean_is_exclusive(x_109); +if (x_115 == 0) { -return x_127; +return x_109; } else { -lean_object* x_134; lean_object* x_135; lean_object* x_136; -x_134 = lean_ctor_get(x_127, 0); -x_135 = lean_ctor_get(x_127, 1); -lean_inc(x_135); -lean_inc(x_134); -lean_dec(x_127); -x_136 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_136, 0, x_134); -lean_ctor_set(x_136, 1, x_135); -return x_136; +lean_object* x_116; lean_object* x_117; lean_object* x_118; +x_116 = lean_ctor_get(x_109, 0); +x_117 = lean_ctor_get(x_109, 1); +lean_inc(x_117); +lean_inc(x_116); +lean_dec(x_109); +x_118 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_118, 0, x_116); +lean_ctor_set(x_118, 1, x_117); +return x_118; } } } case 8: { -lean_object* x_137; lean_object* x_138; lean_object* x_139; lean_object* x_140; lean_object* x_141; -x_137 = lean_ctor_get(x_4, 0); -lean_inc(x_137); -x_138 = lean_ctor_get(x_4, 1); -lean_inc(x_138); -x_139 = lean_ctor_get(x_4, 2); -lean_inc(x_139); -x_140 = lean_ctor_get(x_4, 3); -lean_inc(x_140); +lean_object* x_119; lean_object* x_120; lean_object* x_121; lean_object* x_122; lean_object* x_123; +x_119 = lean_ctor_get(x_4, 0); +lean_inc(x_119); +x_120 = lean_ctor_get(x_4, 1); +lean_inc(x_120); +x_121 = lean_ctor_get(x_4, 2); +lean_inc(x_121); +x_122 = lean_ctor_get(x_4, 3); +lean_inc(x_122); lean_dec(x_4); lean_inc(x_8); lean_inc(x_7); @@ -11642,15 +10978,15 @@ lean_inc(x_5); lean_inc(x_3); lean_inc(x_2); lean_inc(x_1); -x_141 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_138, x_5, x_6, x_7, x_8, x_9); -if (lean_obj_tag(x_141) == 0) +x_123 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_120, x_5, x_6, x_7, x_8, x_9); +if (lean_obj_tag(x_123) == 0) { -lean_object* x_142; lean_object* x_143; lean_object* x_144; -x_142 = lean_ctor_get(x_141, 0); -lean_inc(x_142); -x_143 = lean_ctor_get(x_141, 1); -lean_inc(x_143); -lean_dec(x_141); +lean_object* x_124; lean_object* x_125; lean_object* x_126; +x_124 = lean_ctor_get(x_123, 0); +lean_inc(x_124); +x_125 = lean_ctor_get(x_123, 1); +lean_inc(x_125); +lean_dec(x_123); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); @@ -11658,29 +10994,29 @@ lean_inc(x_5); lean_inc(x_3); lean_inc(x_2); lean_inc(x_1); -x_144 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_139, x_5, x_6, x_7, x_8, x_143); -if (lean_obj_tag(x_144) == 0) +x_126 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_121, x_5, x_6, x_7, x_8, x_125); +if (lean_obj_tag(x_126) == 0) { -lean_object* x_145; lean_object* x_146; lean_object* x_147; lean_object* x_148; -x_145 = lean_ctor_get(x_144, 0); -lean_inc(x_145); -x_146 = lean_ctor_get(x_144, 1); -lean_inc(x_146); -lean_dec(x_144); -x_147 = lean_alloc_closure((void*)(l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__2___boxed), 10, 4); -lean_closure_set(x_147, 0, x_140); -lean_closure_set(x_147, 1, x_1); -lean_closure_set(x_147, 2, x_2); -lean_closure_set(x_147, 3, x_3); -x_148 = l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__12___rarg(x_137, x_142, x_145, x_147, x_5, x_6, x_7, x_8, x_146); -return x_148; +lean_object* x_127; lean_object* x_128; lean_object* x_129; lean_object* x_130; +x_127 = lean_ctor_get(x_126, 0); +lean_inc(x_127); +x_128 = lean_ctor_get(x_126, 1); +lean_inc(x_128); +lean_dec(x_126); +x_129 = lean_alloc_closure((void*)(l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__2___boxed), 10, 4); +lean_closure_set(x_129, 0, x_122); +lean_closure_set(x_129, 1, x_1); +lean_closure_set(x_129, 2, x_2); +lean_closure_set(x_129, 3, x_3); +x_130 = l_Lean_Meta_withLetDecl___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___rarg(x_119, x_124, x_127, x_129, x_5, x_6, x_7, x_8, x_128); +return x_130; } else { -uint8_t x_149; -lean_dec(x_142); -lean_dec(x_140); -lean_dec(x_137); +uint8_t x_131; +lean_dec(x_124); +lean_dec(x_122); +lean_dec(x_119); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); @@ -11688,19 +11024,112 @@ lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); -x_149 = !lean_is_exclusive(x_144); +x_131 = !lean_is_exclusive(x_126); +if (x_131 == 0) +{ +return x_126; +} +else +{ +lean_object* x_132; lean_object* x_133; lean_object* x_134; +x_132 = lean_ctor_get(x_126, 0); +x_133 = lean_ctor_get(x_126, 1); +lean_inc(x_133); +lean_inc(x_132); +lean_dec(x_126); +x_134 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_134, 0, x_132); +lean_ctor_set(x_134, 1, x_133); +return x_134; +} +} +} +else +{ +uint8_t x_135; +lean_dec(x_122); +lean_dec(x_121); +lean_dec(x_119); +lean_dec(x_8); +lean_dec(x_7); +lean_dec(x_6); +lean_dec(x_5); +lean_dec(x_3); +lean_dec(x_2); +lean_dec(x_1); +x_135 = !lean_is_exclusive(x_123); +if (x_135 == 0) +{ +return x_123; +} +else +{ +lean_object* x_136; lean_object* x_137; lean_object* x_138; +x_136 = lean_ctor_get(x_123, 0); +x_137 = lean_ctor_get(x_123, 1); +lean_inc(x_137); +lean_inc(x_136); +lean_dec(x_123); +x_138 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_138, 0, x_136); +lean_ctor_set(x_138, 1, x_137); +return x_138; +} +} +} +case 10: +{ +lean_object* x_139; lean_object* x_140; lean_object* x_141; +x_139 = lean_ctor_get(x_4, 0); +lean_inc(x_139); +x_140 = lean_ctor_get(x_4, 1); +lean_inc(x_140); +lean_dec(x_4); +x_141 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_140, x_5, x_6, x_7, x_8, x_9); +if (lean_obj_tag(x_141) == 0) +{ +uint8_t x_142; +x_142 = !lean_is_exclusive(x_141); +if (x_142 == 0) +{ +lean_object* x_143; lean_object* x_144; +x_143 = lean_ctor_get(x_141, 0); +x_144 = l_Lean_mkMData(x_139, x_143); +lean_ctor_set(x_141, 0, x_144); +return x_141; +} +else +{ +lean_object* x_145; lean_object* x_146; lean_object* x_147; lean_object* x_148; +x_145 = lean_ctor_get(x_141, 0); +x_146 = lean_ctor_get(x_141, 1); +lean_inc(x_146); +lean_inc(x_145); +lean_dec(x_141); +x_147 = l_Lean_mkMData(x_139, x_145); +x_148 = lean_alloc_ctor(0, 2, 0); +lean_ctor_set(x_148, 0, x_147); +lean_ctor_set(x_148, 1, x_146); +return x_148; +} +} +else +{ +uint8_t x_149; +lean_dec(x_139); +x_149 = !lean_is_exclusive(x_141); if (x_149 == 0) { -return x_144; +return x_141; } else { lean_object* x_150; lean_object* x_151; lean_object* x_152; -x_150 = lean_ctor_get(x_144, 0); -x_151 = lean_ctor_get(x_144, 1); +x_150 = lean_ctor_get(x_141, 0); +x_151 = lean_ctor_get(x_141, 1); lean_inc(x_151); lean_inc(x_150); -lean_dec(x_144); +lean_dec(x_141); x_152 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_152, 0, x_150); lean_ctor_set(x_152, 1, x_151); @@ -11708,169 +11137,76 @@ return x_152; } } } -else -{ -uint8_t x_153; -lean_dec(x_140); -lean_dec(x_139); -lean_dec(x_137); -lean_dec(x_8); -lean_dec(x_7); -lean_dec(x_6); -lean_dec(x_5); -lean_dec(x_3); -lean_dec(x_2); -lean_dec(x_1); -x_153 = !lean_is_exclusive(x_141); -if (x_153 == 0) -{ -return x_141; -} -else -{ -lean_object* x_154; lean_object* x_155; lean_object* x_156; -x_154 = lean_ctor_get(x_141, 0); -x_155 = lean_ctor_get(x_141, 1); -lean_inc(x_155); -lean_inc(x_154); -lean_dec(x_141); -x_156 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_156, 0, x_154); -lean_ctor_set(x_156, 1, x_155); -return x_156; -} -} -} -case 10: -{ -lean_object* x_157; lean_object* x_158; lean_object* x_159; -x_157 = lean_ctor_get(x_4, 0); -lean_inc(x_157); -x_158 = lean_ctor_get(x_4, 1); -lean_inc(x_158); -lean_dec(x_4); -x_159 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_158, x_5, x_6, x_7, x_8, x_9); -if (lean_obj_tag(x_159) == 0) -{ -uint8_t x_160; -x_160 = !lean_is_exclusive(x_159); -if (x_160 == 0) -{ -lean_object* x_161; lean_object* x_162; -x_161 = lean_ctor_get(x_159, 0); -x_162 = l_Lean_mkMData(x_157, x_161); -lean_ctor_set(x_159, 0, x_162); -return x_159; -} -else -{ -lean_object* x_163; lean_object* x_164; lean_object* x_165; lean_object* x_166; -x_163 = lean_ctor_get(x_159, 0); -x_164 = lean_ctor_get(x_159, 1); -lean_inc(x_164); -lean_inc(x_163); -lean_dec(x_159); -x_165 = l_Lean_mkMData(x_157, x_163); -x_166 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_166, 0, x_165); -lean_ctor_set(x_166, 1, x_164); -return x_166; -} -} -else -{ -uint8_t x_167; -lean_dec(x_157); -x_167 = !lean_is_exclusive(x_159); -if (x_167 == 0) -{ -return x_159; -} -else -{ -lean_object* x_168; lean_object* x_169; lean_object* x_170; -x_168 = lean_ctor_get(x_159, 0); -x_169 = lean_ctor_get(x_159, 1); -lean_inc(x_169); -lean_inc(x_168); -lean_dec(x_159); -x_170 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_170, 0, x_168); -lean_ctor_set(x_170, 1, x_169); -return x_170; -} -} -} case 11: { -lean_object* x_171; lean_object* x_172; lean_object* x_173; lean_object* x_174; -x_171 = lean_ctor_get(x_4, 0); -lean_inc(x_171); -x_172 = lean_ctor_get(x_4, 1); -lean_inc(x_172); -x_173 = lean_ctor_get(x_4, 2); -lean_inc(x_173); +lean_object* x_153; lean_object* x_154; lean_object* x_155; lean_object* x_156; +x_153 = lean_ctor_get(x_4, 0); +lean_inc(x_153); +x_154 = lean_ctor_get(x_4, 1); +lean_inc(x_154); +x_155 = lean_ctor_get(x_4, 2); +lean_inc(x_155); lean_dec(x_4); -x_174 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_173, x_5, x_6, x_7, x_8, x_9); -if (lean_obj_tag(x_174) == 0) +x_156 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop(x_1, x_2, x_3, x_155, x_5, x_6, x_7, x_8, x_9); +if (lean_obj_tag(x_156) == 0) { -uint8_t x_175; -x_175 = !lean_is_exclusive(x_174); -if (x_175 == 0) +uint8_t x_157; +x_157 = !lean_is_exclusive(x_156); +if (x_157 == 0) { -lean_object* x_176; lean_object* x_177; -x_176 = lean_ctor_get(x_174, 0); -x_177 = l_Lean_mkProj(x_171, x_172, x_176); -lean_ctor_set(x_174, 0, x_177); -return x_174; +lean_object* x_158; lean_object* x_159; +x_158 = lean_ctor_get(x_156, 0); +x_159 = l_Lean_mkProj(x_153, x_154, x_158); +lean_ctor_set(x_156, 0, x_159); +return x_156; } else { -lean_object* x_178; lean_object* x_179; lean_object* x_180; lean_object* x_181; -x_178 = lean_ctor_get(x_174, 0); -x_179 = lean_ctor_get(x_174, 1); -lean_inc(x_179); -lean_inc(x_178); -lean_dec(x_174); -x_180 = l_Lean_mkProj(x_171, x_172, x_178); -x_181 = lean_alloc_ctor(0, 2, 0); -lean_ctor_set(x_181, 0, x_180); -lean_ctor_set(x_181, 1, x_179); -return x_181; +lean_object* x_160; lean_object* x_161; lean_object* x_162; lean_object* x_163; +x_160 = lean_ctor_get(x_156, 0); +x_161 = lean_ctor_get(x_156, 1); +lean_inc(x_161); +lean_inc(x_160); +lean_dec(x_156); +x_162 = l_Lean_mkProj(x_153, x_154, x_160); +x_163 = lean_alloc_ctor(0, 2, 0); +lean_ctor_set(x_163, 0, x_162); +lean_ctor_set(x_163, 1, x_161); +return x_163; } } else { -uint8_t x_182; -lean_dec(x_172); -lean_dec(x_171); -x_182 = !lean_is_exclusive(x_174); -if (x_182 == 0) +uint8_t x_164; +lean_dec(x_154); +lean_dec(x_153); +x_164 = !lean_is_exclusive(x_156); +if (x_164 == 0) { -return x_174; +return x_156; } else { -lean_object* x_183; lean_object* x_184; lean_object* x_185; -x_183 = lean_ctor_get(x_174, 0); -x_184 = lean_ctor_get(x_174, 1); -lean_inc(x_184); -lean_inc(x_183); -lean_dec(x_174); -x_185 = lean_alloc_ctor(1, 2, 0); -lean_ctor_set(x_185, 0, x_183); -lean_ctor_set(x_185, 1, x_184); -return x_185; +lean_object* x_165; lean_object* x_166; lean_object* x_167; +x_165 = lean_ctor_get(x_156, 0); +x_166 = lean_ctor_get(x_156, 1); +lean_inc(x_166); +lean_inc(x_165); +lean_dec(x_156); +x_167 = lean_alloc_ctor(1, 2, 0); +lean_ctor_set(x_167, 0, x_165); +lean_ctor_set(x_167, 1, x_166); +return x_167; } } } default: { -lean_object* x_186; +lean_object* x_168; lean_dec(x_3); lean_dec(x_2); -x_186 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_ensureNoRecFn(x_1, x_4, x_5, x_6, x_7, x_8, x_9); -return x_186; +x_168 = l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_ensureNoRecFn(x_1, x_4, x_5, x_6, x_7, x_8, x_9); +return x_168; } } } @@ -11945,42 +11281,11 @@ lean_dec(x_2); return x_15; } } -lean_object* l_Std_Range_forIn_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12, lean_object* x_13, lean_object* x_14) { -_start: -{ -lean_object* x_15; -x_15 = l_Std_Range_forIn_loop___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9, x_10, x_11, x_12, x_13, x_14); -lean_dec(x_6); -lean_dec(x_5); -lean_dec(x_4); -return x_15; -} -} -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12) { -_start: -{ -lean_object* x_13; -x_13 = l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9, x_10, x_11, x_12); -lean_dec(x_6); -return x_13; -} -} -lean_object* l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11, lean_object* x_12, lean_object* x_13, lean_object* x_14) { -_start: -{ -lean_object* x_15; -x_15 = l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__9___lambda__2(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9, x_10, x_11, x_12, x_13, x_14); -lean_dec(x_9); -lean_dec(x_7); -lean_dec(x_2); -return x_15; -} -} -lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11) { +lean_object* l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9, lean_object* x_10, lean_object* x_11) { _start: { lean_object* x_12; -x_12 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9, x_10, x_11); +x_12 = l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9, x_10, x_11); lean_dec(x_6); lean_dec(x_1); return x_12; @@ -13652,7 +12957,7 @@ lean_inc(x_5); lean_inc(x_4); lean_inc(x_3); lean_inc(x_2); -x_13 = l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__10___rarg(x_7, x_8, x_2, x_3, x_4, x_5, x_11); +x_13 = l_Lean_Meta_lambdaTelescope___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__7___rarg(x_7, x_8, x_2, x_3, x_4, x_5, x_11); if (lean_obj_tag(x_13) == 0) { lean_object* x_14; lean_object* x_15; lean_object* x_16; uint8_t x_17; @@ -13899,7 +13204,7 @@ lean_dec(x_3); return x_9; } } -lean_object* l_Lean_Elab_initFn____x40_Lean_Elab_PreDefinition_Structural___hyg_3445_(lean_object* x_1) { +lean_object* l_Lean_Elab_initFn____x40_Lean_Elab_PreDefinition_Structural___hyg_3438_(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; @@ -14051,22 +13356,22 @@ l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean lean_mark_persistent(l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___closed__1); l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___closed__2 = _init_l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___closed__2(); lean_mark_persistent(l_Lean_Expr_withAppAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__3___closed__2); -l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__1 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__1(); -lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__1); -l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__2 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__2(); -lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__2); -l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__3 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__3(); -lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__3); -l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__4 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__4(); -lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__4); -l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__5 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__5(); -lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__5); -l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__6 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__6(); -lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__6); -l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__7 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__7(); -lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__7); -l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__8 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__8(); -lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__11___lambda__2___closed__8); +l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__1 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__1(); +lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__1); +l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__2 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__2(); +lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__2); +l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__3 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__3(); +lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__3); +l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__4 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__4(); +lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__4); +l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__5 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__5(); +lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__5); +l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__6 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__6(); +lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__6); +l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__7 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__7(); +lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__7); +l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__8 = _init_l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__8(); +lean_mark_persistent(l_Array_umapMAux___at___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___spec__8___lambda__2___closed__8); l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__1___closed__1 = _init_l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__1___closed__1(); lean_mark_persistent(l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__1___closed__1); l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__1___closed__2 = _init_l___private_Lean_Elab_PreDefinition_Structural_0__Lean_Elab_replaceRecApps_loop___lambda__1___closed__2(); @@ -14105,7 +13410,7 @@ l_Lean_Elab_structuralRecursion___closed__2 = _init_l_Lean_Elab_structuralRecurs lean_mark_persistent(l_Lean_Elab_structuralRecursion___closed__2); l_Lean_Elab_structuralRecursion___closed__3 = _init_l_Lean_Elab_structuralRecursion___closed__3(); lean_mark_persistent(l_Lean_Elab_structuralRecursion___closed__3); -res = l_Lean_Elab_initFn____x40_Lean_Elab_PreDefinition_Structural___hyg_3445_(lean_io_mk_world()); +res = l_Lean_Elab_initFn____x40_Lean_Elab_PreDefinition_Structural___hyg_3438_(lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); return lean_io_result_mk_ok(lean_box(0)); diff --git a/stage0/stdlib/Lean/Expr.c b/stage0/stdlib/Lean/Expr.c index fcf5abfc31..8904eedabd 100644 --- a/stage0/stdlib/Lean/Expr.c +++ b/stage0/stdlib/Lean/Expr.c @@ -2159,7 +2159,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__2; x_3 = lean_unsigned_to_nat(143u); -x_4 = lean_unsigned_to_nat(42u); +x_4 = lean_unsigned_to_nat(44u); x_5 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__3; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -8021,7 +8021,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_getRevArg_x21___closed__1; x_3 = lean_unsigned_to_nat(507u); -x_4 = lean_unsigned_to_nat(20u); +x_4 = lean_unsigned_to_nat(22u); x_5 = l_List_get_x21___rarg___closed__3; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -8404,7 +8404,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_appFn_x21___closed__1; x_3 = lean_unsigned_to_nat(527u); -x_4 = lean_unsigned_to_nat(15u); +x_4 = lean_unsigned_to_nat(17u); x_5 = l_Lean_Expr_appFn_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -8488,7 +8488,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_appArg_x21___closed__1; x_3 = lean_unsigned_to_nat(531u); -x_4 = lean_unsigned_to_nat(15u); +x_4 = lean_unsigned_to_nat(17u); x_5 = l_Lean_Expr_appFn_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -8906,7 +8906,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_constName_x21___closed__1; x_3 = lean_unsigned_to_nat(550u); -x_4 = lean_unsigned_to_nat(17u); +x_4 = lean_unsigned_to_nat(19u); x_5 = l_Lean_Expr_constName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9053,7 +9053,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_constLevels_x21___closed__1; x_3 = lean_unsigned_to_nat(558u); -x_4 = lean_unsigned_to_nat(18u); +x_4 = lean_unsigned_to_nat(20u); x_5 = l_Lean_Expr_constName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9143,7 +9143,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_bvarIdx_x21___closed__1; x_3 = lean_unsigned_to_nat(562u); -x_4 = lean_unsigned_to_nat(16u); +x_4 = lean_unsigned_to_nat(18u); x_5 = l_Lean_Expr_bvarIdx_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9233,7 +9233,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_fvarId_x21___closed__1; x_3 = lean_unsigned_to_nat(566u); -x_4 = lean_unsigned_to_nat(14u); +x_4 = lean_unsigned_to_nat(16u); x_5 = l_Lean_Expr_fvarId_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9323,7 +9323,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_mvarId_x21___closed__1; x_3 = lean_unsigned_to_nat(570u); -x_4 = lean_unsigned_to_nat(14u); +x_4 = lean_unsigned_to_nat(16u); x_5 = l_Lean_Expr_mvarId_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9438,7 +9438,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_bindingName_x21___closed__1; x_3 = lean_unsigned_to_nat(575u); -x_4 = lean_unsigned_to_nat(21u); +x_4 = lean_unsigned_to_nat(23u); x_5 = l_Lean_Expr_bindingName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9554,7 +9554,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_bindingDomain_x21___closed__1; x_3 = lean_unsigned_to_nat(580u); -x_4 = lean_unsigned_to_nat(21u); +x_4 = lean_unsigned_to_nat(23u); x_5 = l_Lean_Expr_bindingName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9670,7 +9670,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_bindingBody_x21___closed__1; x_3 = lean_unsigned_to_nat(585u); -x_4 = lean_unsigned_to_nat(21u); +x_4 = lean_unsigned_to_nat(23u); x_5 = l_Lean_Expr_bindingName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9786,7 +9786,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_bindingInfo_x21___closed__1; x_3 = lean_unsigned_to_nat(590u); -x_4 = lean_unsigned_to_nat(21u); +x_4 = lean_unsigned_to_nat(23u); x_5 = l_Lean_Expr_bindingName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -9895,7 +9895,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_letName_x21___closed__1; x_3 = lean_unsigned_to_nat(594u); -x_4 = lean_unsigned_to_nat(20u); +x_4 = lean_unsigned_to_nat(22u); x_5 = l_Lean_Expr_letName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -12107,8 +12107,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_hasAnyFVar_visit___closed__1; -x_3 = lean_unsigned_to_nat(853u); -x_4 = lean_unsigned_to_nat(30u); +x_3 = lean_unsigned_to_nat(851u); +x_4 = lean_unsigned_to_nat(32u); x_5 = l___private_Init_LeanInit_0__Lean_eraseMacroScopesAux___closed__3; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -12374,8 +12374,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateApp_x21___closed__1; -x_3 = lean_unsigned_to_nat(875u); -x_4 = lean_unsigned_to_nat(18u); +x_3 = lean_unsigned_to_nat(873u); +x_4 = lean_unsigned_to_nat(20u); x_5 = l_Lean_Expr_appFn_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -12480,8 +12480,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateConst_x21___closed__1; -x_3 = lean_unsigned_to_nat(884u); -x_4 = lean_unsigned_to_nat(18u); +x_3 = lean_unsigned_to_nat(882u); +x_4 = lean_unsigned_to_nat(20u); x_5 = l_Lean_Expr_constName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -12591,8 +12591,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateSort_x21___closed__1; -x_3 = lean_unsigned_to_nat(893u); -x_4 = lean_unsigned_to_nat(14u); +x_3 = lean_unsigned_to_nat(891u); +x_4 = lean_unsigned_to_nat(16u); x_5 = l_Lean_Expr_updateSort_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -12779,8 +12779,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateMData_x21___closed__1; -x_3 = lean_unsigned_to_nat(910u); -x_4 = lean_unsigned_to_nat(17u); +x_3 = lean_unsigned_to_nat(908u); +x_4 = lean_unsigned_to_nat(19u); x_5 = l_Lean_Expr_updateMData_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -12886,8 +12886,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateProj_x21___closed__1; -x_3 = lean_unsigned_to_nat(915u); -x_4 = lean_unsigned_to_nat(18u); +x_3 = lean_unsigned_to_nat(913u); +x_4 = lean_unsigned_to_nat(20u); x_5 = l_Lean_Expr_updateProj_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -13006,8 +13006,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateForall_x21___closed__1; -x_3 = lean_unsigned_to_nat(924u); -x_4 = lean_unsigned_to_nat(21u); +x_3 = lean_unsigned_to_nat(922u); +x_4 = lean_unsigned_to_nat(23u); x_5 = l_Lean_Expr_updateForall_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -13119,8 +13119,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateForallE_x21___closed__1; -x_3 = lean_unsigned_to_nat(929u); -x_4 = lean_unsigned_to_nat(21u); +x_3 = lean_unsigned_to_nat(927u); +x_4 = lean_unsigned_to_nat(23u); x_5 = l_Lean_Expr_updateForall_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -13243,8 +13243,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateLambda_x21___closed__1; -x_3 = lean_unsigned_to_nat(938u); -x_4 = lean_unsigned_to_nat(17u); +x_3 = lean_unsigned_to_nat(936u); +x_4 = lean_unsigned_to_nat(19u); x_5 = l_Lean_Expr_updateLambda_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -13356,8 +13356,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateLambdaE_x21___closed__1; -x_3 = lean_unsigned_to_nat(943u); -x_4 = lean_unsigned_to_nat(17u); +x_3 = lean_unsigned_to_nat(941u); +x_4 = lean_unsigned_to_nat(19u); x_5 = l_Lean_Expr_updateLambda_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -13472,8 +13472,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_updateLet_x21___closed__1; -x_3 = lean_unsigned_to_nat(952u); -x_4 = lean_unsigned_to_nat(20u); +x_3 = lean_unsigned_to_nat(950u); +x_4 = lean_unsigned_to_nat(22u); x_5 = l_Lean_Expr_letName_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -13869,8 +13869,8 @@ _start: lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l___private_Lean_Expr_0__Lean_Expr_mkDataCore___closed__1; x_2 = l_Lean_Expr_instantiateLevelParamsCore_visit___closed__1; -x_3 = lean_unsigned_to_nat(972u); -x_4 = lean_unsigned_to_nat(23u); +x_3 = lean_unsigned_to_nat(970u); +x_4 = lean_unsigned_to_nat(25u); x_5 = l___private_Init_LeanInit_0__Lean_eraseMacroScopesAux___closed__3; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; diff --git a/stage0/stdlib/Lean/Level.c b/stage0/stdlib/Lean/Level.c index 8afa092197..fa9a419c1f 100644 --- a/stage0/stdlib/Lean/Level.c +++ b/stage0/stdlib/Lean/Level.c @@ -509,7 +509,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l_Lean_Level_mkData___closed__2; x_2 = l_Lean_Level_mkData___closed__3; x_3 = lean_unsigned_to_nat(46u); -x_4 = lean_unsigned_to_nat(33u); +x_4 = lean_unsigned_to_nat(35u); x_5 = l_Lean_Level_mkData___closed__4; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -1845,7 +1845,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l_Lean_Level_mkData___closed__2; x_2 = l_Lean_Level_mvarId_x21___closed__1; x_3 = lean_unsigned_to_nat(158u); -x_4 = lean_unsigned_to_nat(19u); +x_4 = lean_unsigned_to_nat(21u); x_5 = l_Lean_Level_mvarId_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -5890,7 +5890,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l_Lean_Level_mkData___closed__2; x_2 = l_Lean_Level_updateSucc_x21___closed__1; x_3 = lean_unsigned_to_nat(435u); -x_4 = lean_unsigned_to_nat(16u); +x_4 = lean_unsigned_to_nat(18u); x_5 = l_Lean_Level_updateSucc_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -6000,7 +6000,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l_Lean_Level_mkData___closed__2; x_2 = l_Lean_Level_updateMax_x21___closed__1; x_3 = lean_unsigned_to_nat(444u); -x_4 = lean_unsigned_to_nat(19u); +x_4 = lean_unsigned_to_nat(21u); x_5 = l_Lean_Level_updateMax_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; @@ -6114,7 +6114,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l_Lean_Level_mkData___closed__2; x_2 = l_Lean_Level_updateIMax_x21___closed__1; x_3 = lean_unsigned_to_nat(453u); -x_4 = lean_unsigned_to_nat(20u); +x_4 = lean_unsigned_to_nat(22u); x_5 = l_Lean_Level_updateIMax_x21___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; diff --git a/stage0/stdlib/Lean/ResolveName.c b/stage0/stdlib/Lean/ResolveName.c index 6e83396c04..952582c788 100644 --- a/stage0/stdlib/Lean/ResolveName.c +++ b/stage0/stdlib/Lean/ResolveName.c @@ -3770,7 +3770,7 @@ lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_obj x_1 = l_Lean_ResolveName_resolveNamespaceUsingScope___closed__1; x_2 = l_Lean_ResolveName_resolveNamespaceUsingScope___closed__2; x_3 = lean_unsigned_to_nat(123u); -x_4 = lean_unsigned_to_nat(25u); +x_4 = lean_unsigned_to_nat(27u); x_5 = l___private_Init_LeanInit_0__Lean_eraseMacroScopesAux___closed__3; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6;