Equations
- Lean.instInhabitedStructureFieldInfo = { default := { fieldName := default, projFn := default, subobject? := default, binderInfo := default, inferMod := default } }
Equations
- Lean.instReprStructureFieldInfo = { reprPrec := [anonymous] }
Equations
- Lean.StructureFieldInfo.lt i₁ i₂ = Lean.Name.quickLt i₁.fieldName i₂.fieldName
- structName : Lean.Name
- fieldNames : Array Lean.Name
- fieldInfo : Array Lean.StructureFieldInfo
Equations
- Lean.instInhabitedStructureInfo = { default := { structName := default, fieldNames := default, fieldInfo := default } }
Equations
- Lean.StructureInfo.lt i₁ i₂ = Lean.Name.quickLt i₁.structName i₂.structName
Equations
- Lean.instInhabitedStructureState = { default := { map := default } }
- structName : Lean.Name
- fields : Array Lean.StructureFieldInfo
Equations
- Lean.instInhabitedStructureDescr = { default := { structName := default, fields := default } }
Equations
- Lean.registerStructure env e = Lean.PersistentEnvExtension.addEntry Lean.structureExt env { structName := e.structName, fieldNames := Array.map (fun e => e.fieldName) e.fields, fieldInfo := Array.qsort e.fields Lean.StructureFieldInfo.lt 0 (Array.size e.fields - 1) }
Equations
- Lean.getStructureInfo? env structName = match Lean.Environment.getModuleIdxFor? env structName with | some modIdx => Array.binSearch (Lean.PersistentEnvExtension.getModuleEntries Lean.structureExt env modIdx) { structName := structName, fieldNames := #[], fieldInfo := #[] } Lean.StructureInfo.lt 0 (Array.size (Lean.PersistentEnvExtension.getModuleEntries Lean.structureExt env modIdx) - 1) | none => Std.PersistentHashMap.find? (Lean.SimplePersistentEnvExtension.getState Lean.structureExt env).map structName
Equations
- Lean.getStructureCtor env constName = match Lean.Environment.find? env constName with | some (Lean.ConstantInfo.inductInfo { toConstantVal := { name := x, levelParams := x_1, type := x_2 }, numParams := x_3, numIndices := x_4, all := x_5, ctors := [ctorName], isRec := false, isUnsafe := x_6, isReflexive := x_7, isNested := x_8 }) => match Lean.Environment.find? env ctorName with | some (Lean.ConstantInfo.ctorInfo val) => val | x => panicWithPosWithDecl "Lean.Structure" "Lean.getStructureCtor" 67 11 "ill-formed environment" | x => panicWithPosWithDecl "Lean.Structure" "Lean.getStructureCtor" 68 9 "structure expected"
Equations
- Lean.getStructureFields env structName = match Lean.getStructureInfo? env structName with | some info => info.fieldNames | x => panicWithPosWithDecl "Lean.Structure" "Lean.getStructureFields" 75 4 "structure expected"
Equations
- Lean.getFieldInfo? env structName fieldName = match Lean.getStructureInfo? env structName with | some info => Array.binSearch info.fieldInfo { fieldName := fieldName, projFn := default, subobject? := none, binderInfo := default, inferMod := false } Lean.StructureFieldInfo.lt 0 (Array.size info.fieldInfo - 1) | x => none
def
Lean.isSubobjectField?
(env : Lean.Environment)
(structName : Lean.Name)
(fieldName : Lean.Name)
:
Equations
- Lean.isSubobjectField? env structName fieldName = match Lean.getFieldInfo? env structName fieldName with | some fieldInfo => fieldInfo.subobject? | x => none
Equations
- Lean.getParentStructures env structName = let fieldNames := Lean.getStructureFields env structName; Array.foldl (fun acc fieldName => match Lean.isSubobjectField? env structName fieldName with | some parentStructName => Array.push acc parentStructName | none => acc) #[] fieldNames 0 (Array.size fieldNames)
Equations
- Lean.getAllParentStructures env structName = (fun visit => (StateT.run (visit structName) #[]).snd) (Lean.getAllParentStructures.visit env)
partial def
Lean.findField?
(env : Lean.Environment)
(structName : Lean.Name)
(fieldName : Lean.Name)
:
def
Lean.getStructureFieldsFlattened
(env : Lean.Environment)
(structName : Lean.Name)
(includeSubobjectFields : optParam Bool true)
:
Equations
- Lean.getStructureFieldsFlattened env structName includeSubobjectFields = Lean.getStructureFieldsFlattenedAux env structName #[] includeSubobjectFields
Equations
- Lean.isStructure env constName = Option.isSome (Lean.getStructureInfo? env constName)
def
Lean.getProjFnForField?
(env : Lean.Environment)
(structName : Lean.Name)
(fieldName : Lean.Name)
:
Equations
- Lean.getProjFnForField? env structName fieldName = match Lean.getFieldInfo? env structName fieldName with | some fieldInfo => some fieldInfo.projFn | x => none
Equations
- Lean.mkDefaultFnOfProjFn projFn = projFn ++ `_default
def
Lean.getDefaultFnForField?
(env : Lean.Environment)
(structName : Lean.Name)
(fieldName : Lean.Name)
:
Equations
- Lean.getDefaultFnForField? env structName fieldName = match Lean.getProjFnForField? env structName fieldName with | some projName => let defFn := Lean.mkDefaultFnOfProjFn projName; if Lean.Environment.contains env defFn = true then some defFn else none | x => let defFn := Lean.mkDefaultFnOfProjFn (structName ++ fieldName); if Lean.Environment.contains env defFn = true then some defFn else none
partial def
Lean.getPathToBaseStructureAux
(env : Lean.Environment)
(baseStructName : Lean.Name)
(structName : Lean.Name)
(path : List Lean.Name)
:
def
Lean.getPathToBaseStructure?
(env : Lean.Environment)
(baseStructName : Lean.Name)
(structName : Lean.Name)
:
Equations
- Lean.getPathToBaseStructure? env baseStructName structName = Lean.getPathToBaseStructureAux env baseStructName structName []
Equations
- Lean.isStructureLike env constName = match Lean.Environment.find? env constName with | some (Lean.ConstantInfo.inductInfo { toConstantVal := { name := x, levelParams := x_1, type := x_2 }, numParams := x_3, numIndices := 0, all := x_4, ctors := [ctor], isRec := false, isUnsafe := x_5, isReflexive := x_6, isNested := x_7 }) => true | x => false
Equations
- Lean.getStructureLikeNumFields env constName = match Lean.Environment.find? env constName with | some (Lean.ConstantInfo.inductInfo { toConstantVal := { name := x, levelParams := x_1, type := x_2 }, numParams := x_3, numIndices := 0, all := x_4, ctors := [ctor], isRec := false, isUnsafe := x_5, isReflexive := x_6, isNested := x_7 }) => match Lean.Environment.find? env ctor with | some (Lean.ConstantInfo.ctorInfo { toConstantVal := { name := x, levelParams := x_8, type := x_9 }, induct := x_10, cidx := x_11, numParams := x_12, numFields := n, isUnsafe := x_13 }) => n | x => 0 | x => 0