| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rzk.TypeCheck
Contents
Synopsis
- defaultTypeCheck :: TypeCheck var a -> Either (TypeErrorInScopedContext var) a
- defaultTypeCheckWithHoles :: TypeCheck var a -> Either (TypeErrorInScopedContext var) (a, [HoleInfo])
- defaultTypeCheckWithHoles' :: Context var -> TypeCheck var a -> Either (TypeErrorInScopedContext var) (a, [HoleInfo])
- data Decl var = Decl {
- declName :: var
- declType :: TermT var
- declValue :: Maybe (TermT var)
- declIsAssumption :: Bool
- declUsedVars :: [var]
- declLocation :: Maybe LocationInfo
- type Decl' = Decl VarIdent
- typecheckModulesWithLocationIncremental :: [(FilePath, [Decl'])] -> [(FilePath, Module)] -> TypeCheck VarIdent ([(FilePath, [Decl'])], [TypeErrorInScopedContext VarIdent])
- typecheckModulesWithLocation' :: [(FilePath, Module)] -> TypeCheck VarIdent ([(FilePath, [Decl'])], [TypeErrorInScopedContext VarIdent])
- typecheckModulesWithHoles :: [(FilePath, Module)] -> Either (TypeErrorInScopedContext VarIdent) ([(FilePath, [Decl'])], [TypeErrorInScopedContext VarIdent], [HoleInfo])
- typecheckModulesWithHolesAndLemmas :: [VarIdent] -> [(FilePath, Module)] -> Either (TypeErrorInScopedContext VarIdent) ([(FilePath, [Decl'])], [TypeErrorInScopedContext VarIdent], [HoleInfo])
- typecheckModulesWithLocation :: [(FilePath, Module)] -> TypeCheck VarIdent [(FilePath, [Decl'])]
- typecheckModules :: [Module] -> TypeCheck VarIdent [Decl']
- typecheckModuleWithLocation :: (FilePath, Module) -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent])
- countCommands :: Integral a => [Command] -> a
- typecheckModule :: Maybe FilePath -> Module -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent])
- splitSectionCommands :: SectionName -> [Command] -> TypeCheck var ([Command], [Command])
- setOption :: String -> String -> TypeCheck var a -> TypeCheck var a
- unsetOption :: String -> TypeCheck var a -> TypeCheck var a
- paramToParamDecl :: Param -> TypeCheck var [ParamDecl]
- addParamDecls :: [ParamDecl] -> Term -> Term
- addParams :: [Param] -> Term -> Term
- data TypeError var
- = TypeErrorOther String
- | TypeErrorUnify (TermT var) (TermT var) (TermT var)
- | TypeErrorUnifyTerms (TermT var) (TermT var)
- | TypeErrorNotPair (TermT var) (TermT var)
- | TypeErrorNotModal (Term var) TModality (TermT var)
- | TypeErrorModalityMismatch TModality TModality (Term var)
- | TypeErrorUnaccessibleVar var TModality TModality
- | TypeErrorNotTypeInModal (TermT var)
- | TypeErrorNotFunction (TermT var) (TermT var)
- | TypeErrorUnexpectedLambda (Term var) (TermT var)
- | TypeErrorUnexpectedPair (Term var) (TermT var)
- | TypeErrorUnexpectedRefl (Term var) (TermT var)
- | TypeErrorCannotInferBareLambda (Term var)
- | TypeErrorCannotInferBareRefl (Term var)
- | TypeErrorCannotInferHole (Term var)
- | TypeErrorUnsolvedHole (Maybe VarIdent) (TermT var)
- | TypeErrorUndefined var
- | TypeErrorTopeNotSatisfied [TermT var] (TermT var)
- | TypeErrorTopeContextDisjoint (TermT var) [TermT var]
- | TypeErrorTopesNotEquivalent (TermT var) (TermT var)
- | TypeErrorInvalidArgumentType (Term var) (TermT var)
- | TypeErrorDuplicateTopLevel [VarIdent] VarIdent
- | TypeErrorUnusedVariable var (TermT var)
- | TypeErrorUnusedUsedVariables [var] var
- | TypeErrorImplicitAssumption (var, TermT var) var
- data TypeErrorInContext var = TypeErrorInContext {
- typeErrorError :: TypeError var
- typeErrorContext :: Context var
- data TypeErrorInScopedContext var
- = PlainTypeError (TypeErrorInContext var)
- | ScopedTypeError (Maybe VarIdent) (TypeErrorInScopedContext (Inc var))
- type TypeError' = TypeError VarIdent
- ppModality :: TModality -> String
- ppTypeError' :: [(VarIdent, Binder)] -> TypeError' -> String
- contextBinders :: Context VarIdent -> ([(VarIdent, Binder)], [(VarIdent, [([Proj], VarIdent)])])
- ppFoldU :: [(VarIdent, Binder)] -> Term' -> String
- ppFoldT :: [(VarIdent, Binder)] -> TermT' -> String
- ppTypeErrorInContext :: OutputDirection -> TypeErrorInContext VarIdent -> String
- ppTypeErrorInScopedContextWith' :: OutputDirection -> [VarIdent] -> [VarIdent] -> TypeErrorInScopedContext VarIdent -> String
- ppTypeErrorInScopedContext' :: OutputDirection -> TypeErrorInScopedContext VarIdent -> String
- issueWarning :: String -> TypeCheck var ()
- fromTypeError :: TypeError var -> TypeCheck var (TypeErrorInScopedContext var)
- issueTypeError :: TypeError var -> TypeCheck var a
- panicImpossible :: String -> a
- data Action var
- = ActionTypeCheck (Term var) (TermT var)
- | ActionUnify (TermT var) (TermT var) (TermT var)
- | ActionUnifyTerms (TermT var) (TermT var)
- | ActionInfer (Term var)
- | ActionContextEntailedBy [TermT var] (TermT var)
- | ActionContextEntails [TermT var] (TermT var)
- | ActionContextEntailsUnion [TermT var] [TermT var]
- | ActionWHNF (TermT var)
- | ActionNF (TermT var)
- | ActionCheckCoherence (TermT var, TermT var) (TermT var, TermT var)
- | ActionCloseSection (Maybe SectionName)
- | ActionCheckLetValue (Maybe VarIdent)
- type Action' = Action VarIdent
- freshBinders :: Eq var => (var -> VarIdent) -> [(var, VarIdent)] -> [(var, Binder)] -> [(var, Binder)]
- binderProjMap :: (var -> VarIdent) -> [(var, Binder)] -> [(VarIdent, [([Proj], VarIdent)])]
- ppTermInContext :: Eq var => TermT var -> TypeCheck var String
- isCubeType :: TermT var -> Bool
- isCubeOrTopeType :: TermT var -> Bool
- isHoleT :: TermT var -> Bool
- containsHole :: TermT var -> Bool
- allEliminationsInto :: Eq var => TermT var -> TermT var -> TypeCheck var [TermT var]
- maxEliminationDepth :: Int
- fitsInto :: Eq var => TermT var -> TermT var -> TermT var -> TypeCheck var Bool
- data ElimCost
- eliminatorsOf :: Eq var => TermT var -> TypeCheck var [(ElimCost, TermT var -> TermT var)]
- destructuringBinder :: Binder -> TermT var -> Binder
- allIntroductionsOf :: Eq var => TermT var -> [VarIdent] -> TypeCheck var [TermT var]
- endpointsAgree :: Eq var => TermT var -> TermT var -> TypeCheck var Bool
- contextEntailsBottom :: Eq var => TypeCheck var Bool
- recBottomCandidates :: Eq var => TypeCheck var [TermT var]
- coverageHolds :: Eq var => [TermT var] -> TypeCheck var Bool
- recOrCandidates :: Eq var => TermT var -> TypeCheck var [TermT var]
- recordHole :: Eq var => Maybe VarIdent -> TermT var -> TypeCheck var ()
- recordHoleShape :: Eq var => Maybe VarIdent -> TermT var -> Maybe (Binder, TermT (Inc var)) -> TypeCheck var ()
- checkHoleAgainstShape :: Eq var => Maybe VarIdent -> Binder -> TermT var -> TermT (Inc var) -> TypeCheck var (TermT var)
- ppSomeAction :: Eq var => [(var, Maybe VarIdent)] -> Int -> Action var -> String
- ppAction :: [(VarIdent, Binder)] -> Int -> Action' -> String
- traceAction' :: Int -> Action' -> a -> a
- unsafeTraceAction' :: Int -> Action var -> a -> a
- data LocationInfo = LocationInfo {}
- data Verbosity
- trace' :: Verbosity -> Verbosity -> String -> a -> a
- traceTypeCheck :: Verbosity -> String -> TypeCheck var a -> TypeCheck var a
- localVerbosity :: Verbosity -> TypeCheck var a -> TypeCheck var a
- localRenderBackend :: Maybe RenderBackend -> TypeCheck var a -> TypeCheck var a
- localHideTerm :: Bool -> TypeCheck var a -> TypeCheck var a
- hidingTerm :: TypeCheck var a -> TypeCheck var a
- data Covariance
- data RenderBackend
- data ScopeInfo var = ScopeInfo {
- scopeName :: Maybe SectionName
- scopeVars :: [(var, VarInfo var)]
- addVarToScope :: var -> VarInfo var -> ScopeInfo var -> ScopeInfo var
- addModalityToScope :: TModality -> ScopeInfo var -> ScopeInfo var
- data VarInfo var = VarInfo {
- varType :: TermT var
- varValue :: Maybe (TermT var)
- varModality :: TModality
- modAccum :: TModality
- varOrig :: Binder
- varIsAssumption :: Bool
- varIsTopLevel :: Bool
- varDeclaredAssumptions :: [var]
- varLocation :: Maybe LocationInfo
- class ModeTheory m where
- data ModalTope var = ModalTope {}
- data Context var = Context {
- localScopes :: [ScopeInfo var]
- localTopes :: [ModalTope var]
- localTopesNF :: [ModalTope var]
- localTopesNFUnion :: [[ModalTope var]]
- localTopesEntailBottom :: Maybe Bool
- actionStack :: [Action var]
- currentCommand :: Maybe Command
- location :: Maybe LocationInfo
- verbosity :: Verbosity
- covariance :: Covariance
- renderBackend :: Maybe RenderBackend
- renderHideTerm :: Bool
- holesAreErrors :: Bool
- deferHoleMismatches :: Bool
- hintLemmas :: [VarIdent]
- addVarInCurrentScope :: var -> VarInfo var -> Context var -> Context var
- applyModalityToScopes :: TModality -> [ScopeInfo var] -> [ScopeInfo var]
- applyModalityToTopes :: TModality -> [ModalTope var] -> [ModalTope var]
- applyModality :: TModality -> Context var -> Context var
- emptyTopeContext :: [ModalTope var]
- emptyContext :: Context var
- allowHoles :: Context var -> Context var
- withHintLemmas :: [VarIdent] -> Context var -> Context var
- structuralHoleUnify :: Context var -> Context var
- askCurrentScope :: TypeCheck var (ScopeInfo var)
- isAccessible :: ModalTope var -> Bool
- filterAccessible :: [ModalTope var] -> [ModalTope var]
- filterInaccessible :: [ModalTope var] -> [ModalTope var]
- partitionAccessible :: [ModalTope var] -> ([ModalTope var], [ModalTope var])
- accessibleTopes :: [ModalTope var] -> [TermT var]
- plainTope :: TermT var -> ModalTope var
- availableTopes :: Context var -> [TermT var]
- availableTopesNF :: Context var -> [TermT var]
- varInfos :: Context var -> [(var, VarInfo var)]
- varTypes :: Context var -> [(var, TermT var)]
- varValues :: Context var -> [(var, Maybe (TermT var))]
- varOrigs :: Context var -> [(var, Maybe VarIdent)]
- varBinders :: Context var -> [(var, Binder)]
- varModalities :: Context var -> [(var, TModality)]
- varLocks :: Context var -> [(var, TModality)]
- varTopLevels :: Context var -> [(var, Bool)]
- withPartialDecls :: TypeCheck VarIdent ([Decl'], [err]) -> TypeCheck VarIdent ([Decl'], [err]) -> TypeCheck VarIdent ([Decl'], [err])
- withSection :: Maybe SectionName -> TypeCheck VarIdent ([Decl VarIdent], [TypeErrorInScopedContext VarIdent]) -> TypeCheck VarIdent ([Decl VarIdent], [TypeErrorInScopedContext VarIdent]) -> TypeCheck VarIdent ([Decl VarIdent], [TypeErrorInScopedContext VarIdent])
- startSection :: Maybe SectionName -> TypeCheck VarIdent a -> TypeCheck VarIdent a
- endSection :: [TypeErrorInScopedContext VarIdent] -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent])
- scopeToDecls :: Eq var => [TypeErrorInScopedContext var] -> ScopeInfo var -> TypeCheck var ([Decl var], [TypeErrorInScopedContext var])
- insertExplicitAssumptionFor :: Eq var => var -> (var, VarInfo var) -> TermT var -> TermT var
- insertExplicitAssumptionFor' :: Eq var => var -> (var, VarInfo var) -> VarInfo var -> VarInfo var
- makeAssumptionExplicit :: Eq var => (var, VarInfo var) -> [(var, VarInfo var)] -> TypeCheck var (Bool, [(var, VarInfo var)])
- collectScopeDecls :: Eq var => Bool -> [TypeErrorInScopedContext var] -> [(var, VarInfo var)] -> [(var, VarInfo var)] -> TypeCheck var ([Decl var], [TypeErrorInScopedContext var])
- abstractAssumption :: Eq var => (var, VarInfo var) -> Decl var -> Decl var
- data OutputDirection
- block :: OutputDirection -> [String] -> String
- namedBlock :: OutputDirection -> String -> [String] -> String
- ppContext' :: OutputDirection -> Context VarIdent -> String
- doesShadowName :: VarIdent -> TypeCheck var [VarIdent]
- checkTopLevelDuplicate :: VarIdent -> TypeCheck var ()
- checkNameShadowing :: VarIdent -> TypeCheck var ()
- withLocation :: LocationInfo -> TypeCheck var a -> TypeCheck var a
- withCommand :: Command -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent]) -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent])
- localDecls :: [Decl VarIdent] -> TypeCheck VarIdent a -> TypeCheck VarIdent a
- localDeclsPrepared :: [Decl VarIdent] -> TypeCheck VarIdent a -> TypeCheck VarIdent a
- localDecl :: Decl VarIdent -> TypeCheck VarIdent a -> TypeCheck VarIdent a
- localDeclPrepared :: Decl VarIdent -> TypeCheck VarIdent a -> TypeCheck VarIdent a
- data HoleEntry = HoleEntry {}
- data HoleInfo = HoleInfo {
- holeName :: Maybe VarIdent
- holeGoal :: Term'
- holeGoalShape :: Maybe (VarIdent, Term')
- holeTermVars :: [HoleEntry]
- holeCubeVars :: [HoleEntry]
- holeTopes :: [Term']
- holeCandidates :: [Term']
- holeIntroductions :: [Term']
- holeDiagram :: Maybe String
- holeLocation :: Maybe LocationInfo
- type TypeCheck var = ReaderT (Context var) (WriterT [HoleInfo] (Except (TypeErrorInScopedContext var)))
- freeVarsT_ :: Eq var => TermT var -> TypeCheck var [var]
- traceStartAndFinish :: Show a => String -> a -> a
- entailM :: Eq var => [ModalTope var] -> TermT var -> TypeCheck var Bool
- generateTopesForModalCubeVarsM :: Eq var => TypeCheck var [ModalTope var]
- entailTraceM :: Eq var => [ModalTope var] -> TermT var -> TypeCheck var Bool
- nubTermT :: Eq a => [a] -> [a]
- saturateTopes :: Eq var => [TermT var] -> [ModalTope var] -> [ModalTope var]
- saturateInv :: Eq var => [ModalTope var] -> TypeCheck var [ModalTope var]
- saturateBottom :: Eq var => [ModalTope var] -> [ModalTope var]
- saturateWith :: (a -> [a] -> Bool) -> ([a] -> [a] -> [a]) -> [a] -> [a]
- generateTopes :: Eq var => [TermT var] -> [TermT var] -> [TermT var]
- generateTopesForPointsM :: Eq var => [TermT var] -> TypeCheck var [TermT var]
- allTopePoints :: Eq var => TermT var -> [TermT var]
- topePoints :: TermT var -> [TermT var]
- subPoints :: TermT var -> [TermT var]
- simplifyLHSwithDisjunctions :: Eq var => [ModalTope var] -> [[ModalTope var]]
- simplifyLHS :: Eq var => [ModalTope var] -> [ModalTope var]
- solveRHSM :: Eq var => [ModalTope var] -> TermT var -> TypeCheck var Bool
- solveRHS :: Eq var => [TermT var] -> TermT var -> Bool
- checkTope :: Eq var => TermT var -> TypeCheck var Bool
- checkTopeEntails :: Eq var => TermT var -> TypeCheck var Bool
- checkEntails :: Eq var => TermT var -> TermT var -> TypeCheck var Bool
- contextEntails :: Eq var => TermT var -> TypeCheck var ()
- topesEquiv :: Eq var => TermT var -> TermT var -> TypeCheck var Bool
- contextEntailsUnion :: Eq var => [TermT var] -> TypeCheck var ()
- checkTopeAgainstContext :: Eq var => String -> TermT var -> TypeCheck var ()
- switchVariance :: TypeCheck var a -> TypeCheck var a
- setVariance :: Covariance -> TypeCheck var a -> TypeCheck var a
- enterScopeContext :: Binder -> TModality -> TermT var -> Maybe (TermT var) -> Context var -> Context (Inc var)
- enterScopeMaybe :: Binder -> TModality -> TermT var -> Maybe (TermT var) -> TypeCheck (Inc var) b -> TypeCheck var b
- enterScope :: Binder -> TModality -> TermT var -> TypeCheck (Inc var) b -> TypeCheck var b
- enterScopeWithBind :: Binder -> TModality -> TermT var -> TermT var -> TypeCheck (Inc var) b -> TypeCheck var b
- closeScope :: Binder -> WriterT [HoleInfo] (Except (TypeErrorInScopedContext (Inc var))) b -> TypeCheck var b
- enterModality :: TModality -> TypeCheck var b -> TypeCheck var b
- performing :: Eq var => Action var -> TypeCheck var a -> TypeCheck var a
- stripTypeRestrictions :: TermT var -> TermT var
- etaMatch :: Eq var => Maybe (TermT var) -> TermT var -> TermT var -> TypeCheck var (TermT var, TermT var)
- etaExpand :: Eq var => TermT var -> TypeCheck var (TermT var)
- inCubeLayer :: Eq var => TermT var -> TypeCheck var Bool
- inTopeLayer :: Eq var => TermT var -> TypeCheck var Bool
- tryRestriction :: Eq var => TermT var -> TypeCheck var (Maybe (TermT var))
- memoizeWHNF :: Eq var => TermT var -> TypeCheck var (TermT var)
- whnfT :: Eq var => TermT var -> TypeCheck var (TermT var)
- nfTope :: Eq var => TermT var -> TypeCheck var (TermT var)
- nfT :: Eq var => TermT var -> TypeCheck var (TermT var)
- checkDefinedVar :: VarIdent -> TypeCheck VarIdent ()
- valueOfVar :: Eq var => var -> TypeCheck var (Maybe (TermT var))
- typeOfVar :: Eq var => var -> TypeCheck var (TermT var)
- modalityOfVar :: Eq var => var -> TypeCheck var TModality
- locksOfVar :: Eq var => var -> TypeCheck var TModality
- isTopLevelVar :: Eq var => var -> TypeCheck var Bool
- typeOfUncomputed :: Eq var => TermT var -> TypeCheck var (TermT var)
- typeOf :: Eq var => TermT var -> TypeCheck var (TermT var)
- unifyTopes :: Eq var => TermT var -> TermT var -> TypeCheck var ()
- inAllSubContexts :: TypeCheck var () -> TypeCheck var () -> TypeCheck var ()
- unify :: Eq var => Maybe (TermT var) -> TermT var -> TermT var -> TypeCheck var ()
- unifyViaDecompose :: Eq var => TermT var -> TermT var -> TypeCheck var ()
- unifyInCurrentContext :: Eq var => Maybe (TermT var) -> TermT var -> TermT var -> TypeCheck var ()
- unifyTypes :: Eq var => TermT var -> TermT var -> TermT var -> TypeCheck var ()
- unifyTerms :: Eq var => TermT var -> TermT var -> TypeCheck var ()
- localTope :: Eq var => TermT var -> TypeCheck var a -> TypeCheck var a
- universeT :: TermT var
- cubeT :: TermT var
- topeT :: TermT var
- topeEQT :: TermT var -> TermT var -> TermT var
- topeLEQT :: TermT var -> TermT var -> TermT var
- topeOrT :: TermT var -> TermT var -> TermT var
- topeAndT :: TermT var -> TermT var -> TermT var
- cubeProductT :: TermT var -> TermT var -> TermT var
- cubeUnitT :: TermT var
- cubeUnitStarT :: TermT var
- typeUnitT :: TermT var
- unitT :: TermT var
- cube2T :: TermT var
- cube2_0T :: TermT var
- cube2_1T :: TermT var
- cubeIT :: TermT var
- cubeI_0T :: TermT var
- cubeI_1T :: TermT var
- cubeFlipT :: TermT var -> TermT var -> TermT var
- cubeUnflipT :: TermT var -> TermT var -> TermT var
- topeInvT :: TermT var -> TermT var
- topeUninvT :: TermT var -> TermT var
- topeTopT :: TermT var
- topeBottomT :: TermT var
- recBottomT :: TermT var
- typeRestrictedT :: TermT var -> [(TermT var, TermT var)] -> TermT var
- lambdaT :: TermT var -> Binder -> Maybe (TModality, TermT var, Maybe (Scope TermT var)) -> Scope TermT var -> TermT var
- letT :: TermT var -> Binder -> Maybe (TermT var) -> TermT var -> Scope TermT var -> TermT var
- letModT :: TermT var -> Binder -> TModality -> TModality -> Maybe (TermT var) -> TermT var -> Scope TermT var -> TermT var
- appT :: TermT var -> TermT var -> TermT var -> TermT var
- pairT :: TermT var -> TermT var -> TermT var -> TermT var
- firstT :: TermT var -> TermT var -> TermT var
- secondT :: TermT var -> TermT var -> TermT var
- reflT :: TermT var -> Maybe (TermT var, Maybe (TermT var)) -> TermT var
- typeFunT :: Binder -> TModality -> TermT var -> Maybe (Scope TermT var) -> Scope TermT var -> TermT var
- typeSigmaT :: Binder -> TModality -> TermT var -> Scope TermT var -> TermT var
- recOrT :: TermT var -> [(TermT var, TermT var)] -> TermT var
- typeIdT :: TermT var -> Maybe (TermT var) -> TermT var -> TermT var
- idJT :: TermT var -> TermT var -> TermT var -> TermT var -> TermT var -> TermT var -> TermT var -> TermT var
- typeAscT :: TermT var -> TermT var -> TermT var
- typeModalT :: TermT var -> TModality -> TermT var -> TermT var
- modAppT :: TermT var -> TModality -> TermT var -> TermT var
- modExtractT :: TermT var -> TModality -> TModality -> TermT var -> TermT var
- checkRecOrAgainst :: Eq var => TermT var -> [(Term var, Term var)] -> TypeCheck var (TermT var)
- pruneVacuousFaces :: Eq var => TermT var -> TypeCheck var (TermT var)
- typecheck :: Eq var => Term var -> TermT var -> TypeCheck var (TermT var)
- inferAs :: Eq var => TermT var -> Term var -> TypeCheck var (TermT var)
- infer :: Eq var => Term var -> TypeCheck var (TermT var)
- checkCoherence :: Eq var => (TermT var, TermT var) -> (TermT var, TermT var) -> TypeCheck var ()
- inferStandalone :: Eq var => Term var -> Either (TypeErrorInScopedContext var) (TermT var)
- unsafeInferStandalone' :: Term' -> TermT'
- unsafeTypeCheck' :: TypeCheck VarIdent a -> a
- type PointId = String
- type ShapeId = [PointId]
- cube2powerT :: Int -> TermT var
- splits :: [a] -> [([a], [a])]
- verticesFrom :: [TermT var] -> [(ShapeId, TermT var)]
- subTopes2 :: Int -> TermT var -> [(ShapeId, TermT var)]
- cubeSubTopes :: [(ShapeId, TermT (Inc var))]
- limitLength :: Int -> String -> String
- hideTermData :: Bool -> String -> RenderObjectData -> RenderObjectData
- renderObjectsFor :: Eq var => String -> Int -> TermT var -> TermT var -> TypeCheck var [(ShapeId, RenderObjectData)]
- componentWiseEQT :: Int -> TermT var -> TermT var -> TermT var
- renderObjectsInSubShapeFor :: Eq var => String -> Int -> [var] -> var -> TermT var -> TermT var -> TermT var -> TypeCheck var [(ShapeId, RenderObjectData)]
- renderForSubShapeSVG :: Eq var => String -> Int -> [var] -> var -> TermT var -> TermT var -> TermT var -> TypeCheck var String
- renderForSVG :: Eq var => String -> Int -> TermT var -> TermT var -> TypeCheck var String
- renderTermSVGFor :: Eq var => String -> Int -> (Maybe (TermT var, TermT var), [var]) -> TermT var -> TypeCheck var (Maybe String)
- renderTermSVG :: Eq var => TermT var -> TypeCheck var (Maybe String)
- renderGoalCellSVG :: Eq var => TermT var -> TypeCheck var (Maybe String)
- renderTermSVG' :: Eq var => TermT var -> TypeCheck var (Maybe String)
- type Point2D a = (a, a)
- type Point3D a = (a, a, a)
- type Edge3D a = (Point3D a, Point3D a)
- type Face3D a = (Point3D a, Point3D a, Point3D a)
- type Volume3D a = (Point3D a, Point3D a, Point3D a, Point3D a)
- data CubeCoords2D a b = CubeCoords2D {}
- data Matrix3D a = Matrix3D a a a a a a a a a
- data Matrix4D a = Matrix4D a a a a a a a a a a a a a a a a
- data Vector3D a = Vector3D a a a
- data Vector4D a = Vector4D a a a a
- rotateX :: Floating a => a -> Matrix3D a
- rotateY :: Floating a => a -> Matrix3D a
- rotateZ :: Floating a => a -> Matrix3D a
- data Camera a = Camera {
- cameraPos :: Point3D a
- cameraFoV :: a
- cameraAspectRatio :: a
- cameraAngleY :: a
- cameraAngleX :: a
- viewRotateX :: Floating a => Camera a -> Matrix4D a
- viewRotateY :: Floating a => Camera a -> Matrix4D a
- viewTranslate :: Num a => Camera a -> Matrix4D a
- project2D :: Floating a => Camera a -> Matrix4D a
- matrixVectorMult4D :: Num a => Matrix4D a -> Vector4D a -> Vector4D a
- matrix3Dto4D :: Num a => Matrix3D a -> Matrix4D a
- fromAffine :: Fractional a => Vector4D a -> (Point2D a, a)
- point3Dto2D :: Floating a => Camera a -> a -> Point3D a -> (Point2D a, a)
- data RenderObjectData = RenderObjectData {}
- renderCube :: (Floating a, Show a) => Camera a -> a -> (String -> Maybe RenderObjectData) -> String
- defaultCamera :: Floating a => Camera a
Documentation
>>>:set -XOverloadedStrings
defaultTypeCheck :: TypeCheck var a -> Either (TypeErrorInScopedContext var) a Source #
defaultTypeCheckWithHoles :: TypeCheck var a -> Either (TypeErrorInScopedContext var) (a, [HoleInfo]) Source #
Like defaultTypeCheck, but runs in lenient hole mode (allowHoles) and
also returns the holes recorded during checking (with their goal and context).
defaultTypeCheckWithHoles' :: Context var -> TypeCheck var a -> Either (TypeErrorInScopedContext var) (a, [HoleInfo]) Source #
Constructors
| Decl | |
Fields
| |
typecheckModulesWithLocation' :: [(FilePath, Module)] -> TypeCheck VarIdent ([(FilePath, [Decl'])], [TypeErrorInScopedContext VarIdent]) Source #
typecheckModulesWithHoles :: [(FilePath, Module)] -> Either (TypeErrorInScopedContext VarIdent) ([(FilePath, [Decl'])], [TypeErrorInScopedContext VarIdent], [HoleInfo]) Source #
Typecheck modules in lenient hole mode, returning the elaborated
declarations, any type errors, and the holes recorded (each with its goal and
local context). This is the structured goal/context query consumed by the
LSP and the game. Strict callers (the default CLI path, CI) keep using
typecheckModulesWithLocation, where holes are TypeErrorUnsolvedHole.
typecheckModulesWithHolesAndLemmas :: [VarIdent] -> [(FilePath, Module)] -> Either (TypeErrorInScopedContext VarIdent) ([(FilePath, [Decl'])], [TypeErrorInScopedContext VarIdent], [HoleInfo]) Source #
Like typecheckModulesWithHoles, but additionally offers the given named
top-level definitions as hole candidates (each applied to holes when its type
fits the goal). The game passes a level's allow-list of relevant lemmas so
they surface as moves; an empty list reproduces typecheckModulesWithHoles.
typecheckModulesWithLocation :: [(FilePath, Module)] -> TypeCheck VarIdent [(FilePath, [Decl'])] Source #
typecheckModuleWithLocation :: (FilePath, Module) -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent]) Source #
countCommands :: Integral a => [Command] -> a Source #
typecheckModule :: Maybe FilePath -> Module -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent]) Source #
splitSectionCommands :: SectionName -> [Command] -> TypeCheck var ([Command], [Command]) Source #
Constructors
Instances
| Functor TypeError Source # | |
| Foldable TypeError Source # | |
Defined in Rzk.TypeCheck Methods fold :: Monoid m => TypeError m -> m # foldMap :: Monoid m => (a -> m) -> TypeError a -> m # foldMap' :: Monoid m => (a -> m) -> TypeError a -> m # foldr :: (a -> b -> b) -> b -> TypeError a -> b # foldr' :: (a -> b -> b) -> b -> TypeError a -> b # foldl :: (b -> a -> b) -> b -> TypeError a -> b # foldl' :: (b -> a -> b) -> b -> TypeError a -> b # foldr1 :: (a -> a -> a) -> TypeError a -> a # foldl1 :: (a -> a -> a) -> TypeError a -> a # toList :: TypeError a -> [a] # length :: TypeError a -> Int # elem :: Eq a => a -> TypeError a -> Bool # maximum :: Ord a => TypeError a -> a # minimum :: Ord a => TypeError a -> a # | |
data TypeErrorInContext var Source #
Constructors
| TypeErrorInContext | |
Fields
| |
Instances
data TypeErrorInScopedContext var Source #
Constructors
| PlainTypeError (TypeErrorInContext var) | |
| ScopedTypeError (Maybe VarIdent) (TypeErrorInScopedContext (Inc var)) |
Instances
type TypeError' = TypeError VarIdent Source #
ppModality :: TModality -> String Source #
ppTypeError' :: [(VarIdent, Binder)] -> TypeError' -> String Source #
Render a type error, folding pattern-binder projections (e.g. π₁ x back to
the user's t) and showing a bare pattern point as the pattern, using the
context's freshened binders (see contextBinders).
contextBinders :: Context VarIdent -> ([(VarIdent, Binder)], [(VarIdent, [([Proj], VarIdent)])]) Source #
The pattern binders in scope, freshened and keyed by their (current) name, together with the projection-folding map derived from them. Both share the same freshened component names, so a term's projections and the binder shown in the context agree.
ppFoldU :: [(VarIdent, Binder)] -> Term' -> String Source #
Render an (untyped) term for an error or diagnostic message, given the
context's freshened pattern binders: fold a pattern-binder variable's
projections to their component names, then expand a bare use of the variable
to the pattern itself (see foldBinderProjections and restorePatternVars).
An empty binder list renders the term as-is.
ppFoldT :: [(VarIdent, Binder)] -> TermT' -> String Source #
Like ppFoldU for a type-annotated term, shown as term : type with the
same folding and pattern restoration applied to both halves.
ppTypeErrorInScopedContextWith' :: OutputDirection -> [VarIdent] -> [VarIdent] -> TypeErrorInScopedContext VarIdent -> String Source #
ppTypeErrorInScopedContext' :: OutputDirection -> TypeErrorInScopedContext VarIdent -> String Source #
issueWarning :: String -> TypeCheck var () Source #
fromTypeError :: TypeError var -> TypeCheck var (TypeErrorInScopedContext var) Source #
issueTypeError :: TypeError var -> TypeCheck var a Source #
panicImpossible :: String -> a Source #
Constructors
| ActionTypeCheck (Term var) (TermT var) | |
| ActionUnify (TermT var) (TermT var) (TermT var) | |
| ActionUnifyTerms (TermT var) (TermT var) | |
| ActionInfer (Term var) | |
| ActionContextEntailedBy [TermT var] (TermT var) | |
| ActionContextEntails [TermT var] (TermT var) | |
| ActionContextEntailsUnion [TermT var] [TermT var] | |
| ActionWHNF (TermT var) | |
| ActionNF (TermT var) | |
| ActionCheckCoherence (TermT var, TermT var) (TermT var, TermT var) | |
| ActionCloseSection (Maybe SectionName) | |
| ActionCheckLetValue (Maybe VarIdent) |
Instances
| Functor Action Source # | |
| Foldable Action Source # | |
Defined in Rzk.TypeCheck Methods fold :: Monoid m => Action m -> m # foldMap :: Monoid m => (a -> m) -> Action a -> m # foldMap' :: Monoid m => (a -> m) -> Action a -> m # foldr :: (a -> b -> b) -> b -> Action a -> b # foldr' :: (a -> b -> b) -> b -> Action a -> b # foldl :: (b -> a -> b) -> b -> Action a -> b # foldl' :: (b -> a -> b) -> b -> Action a -> b # foldr1 :: (a -> a -> a) -> Action a -> a # foldl1 :: (a -> a -> a) -> Action a -> a # elem :: Eq a => a -> Action a -> Bool # maximum :: Ord a => Action a -> a # minimum :: Ord a => Action a -> a # | |
freshBinders :: Eq var => (var -> VarIdent) -> [(var, VarIdent)] -> [(var, Binder)] -> [(var, Binder)] Source #
Freshen the compound (pattern) binders in scope so their component names avoid the display names already in use and one another. Returns each relevant variable paired with its freshened binder. Variables bound to a single name are omitted: they need no projection folding and are displayed normally.
binderProjMap :: (var -> VarIdent) -> [(var, Binder)] -> [(VarIdent, [([Proj], VarIdent)])] Source #
The projection-folding map for rendering: each pattern-binder variable's
display name mapped to the projection paths of its component names (e.g.
π₁ ↦ t, π₂ ↦ s). Ordinary projections (of non-pattern variables) are
left untouched.
isCubeType :: TermT var -> Bool Source #
Classify a (WHNF) type as a cube, so cube variables (e.g. t : 2) are
shown separately from ordinary term variables in a hole's context.
isCubeOrTopeType :: TermT var -> Bool Source #
Is a (WHNF) goal type in the cube or tope layer, so a hole of this type is a
cube point or a tope rather than a term? Used to suppress type-layer-specific
hole candidates (recOR, recBOT), which cannot inhabit a cube or a tope.
isHoleT :: TermT var -> Bool Source #
Is this term a hole? Holes only exist in lenient mode (see allowHoles);
they are opaque placeholders standing for a term of the expected type.
containsHole :: TermT var -> Bool Source #
Does this term contain a hole anywhere (including nested, e.g. f ?)?
Used to keep unification lenient around incomplete terms: a term with an
unfilled hole cannot be meaningfully compared, so a unification that would
otherwise fail is deferred. Evaluated only on the failure path.
allEliminationsInto :: Eq var => TermT var -> TermT var -> TypeCheck var [TermT var] Source #
All ways to eliminate a hypothesis into a value usable at a goal. Given a
target type and a hypothesis term (e.g. Pure v for a context variable),
return every elimination spine over that term whose type fits the target (or
a subtype of it). Arguments introduced by application are left as holes for
the caller to fill later. A value that already fits is returned as-is; a
function is applied to holes; a Σ-type (or anything that unfolds to one, e.g.
is-contr) is projected, possibly repeatedly — so e.g.
first (first (is-segal-A ? ? ? ? ?)) is discovered.
The search is driven uniformly by the eliminators a (weak head normal) type
admits (see eliminatorsOf), so adding a new eliminator extends it without
touching the search.
A Π-application is a forced spine step — there is exactly one way to fill an
argument (with a hole) — so it extends the spine for free and does not spend
the budget. Only the genuinely branching eliminators (Σ/cube projections and
idJ, flagged by eliminatorsOf) count against maxEliminationDepth. The
bound therefore limits real search depth, not argument count, so a lemma that
must be applied to many holes is still reached. The free spine terminates
because each application strips one Π binder off a finite type.
maxEliminationDepth :: Int Source #
How many branching eliminators allEliminationsInto will chain. Forced
Π-applications are free (see allEliminationsInto), so this bounds only the
Σ/cube projections and idJ steps, not the argument count of a spine. A
temporary fixed bound: branching is shallow in the goals seen so far (a few
projections), and a larger bound mostly adds self-referential spines (a built
result eliminated again). It should be made configurable once there is more
evidence of what real goals need.
fitsInto :: Eq var => TermT var -> TermT var -> TermT var -> TypeCheck var Bool Source #
Whether a term of the given (whnf) type may stand where a value of the
target type is expected: the two types unify under structuralHoleUnify,
so a hole acts as a wildcard leaf but a structural mismatch around it is still
a mismatch (an under-applied function does not match an extension-type goal,
but a partial application that genuinely fits an ordinary-function goal does).
Outer type restrictions are stripped from both sides first: an extension-type
boundary is satisfied by later refinement, not by the choice of spine, and
matching against the restricted goal would reject the very spine that
introduces the holes meant to satisfy it (e.g. f ? at a boundary goal).
Holes or constraints recorded while probing are discarded, so this is a pure yes/no query.
Whether eliminating a value spends the search budget. A forced
Π-application is a SpineStep — there is one way to fill the argument (with a
hole), so allEliminationsInto applies it for free; a Branching eliminator
(a Σ/cube projection or idJ) costs one against maxEliminationDepth.
eliminatorsOf :: Eq var => TermT var -> TypeCheck var [(ElimCost, TermT var -> TermT var)] Source #
The eliminators a value of the given (weak head normal) type admits, each
as a function wrapping the eliminated term, paired with its ElimCost. A
Π-type is eliminated by application to a fresh hole (a spine step); a Σ-type
by either projection; an identity type by path induction (idJ), with the
motive and base case left as holes. The projections and idJ branch.
Anything else admits no simple eliminator.
destructuringBinder :: Binder -> TermT var -> Binder Source #
The binder for a λ introduced over a domain type. A binder the type already
gives as a pattern is kept as-is — it carries the user's own names (e.g.
(t , s)). Otherwise an explicit (pre-whnf) Σ-type or product domain is
destructured into a fresh pair pattern, recursively for products, so that a
nameless 2 × 2 × 2 parameter is introduced as ((t1 , t2) , t3) rather than
a single opaque variable. Any other domain keeps its single binder.
Leaves are named by what they range over: a cube-product component is a point,
named t/s-style as tN; a Σ component is a term, named xN. The names are
display-only (the body is a hole that does not mention them) and carry a
shared running index, so every leaf in the pattern is distinct.
allIntroductionsOf :: Eq var => TermT var -> [VarIdent] -> TypeCheck var [TermT var] Source #
All ways to introduce a value of a goal type by its head constructor,
leaving the constituents as holes. Given a target type, return its
introduction forms:
- a Π-type is introduced by a λ-abstraction over a hole body (
\ x -> ?); the binder is taken from the type, so a pattern domain (e.g. aΔ²point(t , s)) is introduced as\ (t , s) -> ?; - a Σ-type or a cube product by a pair of holes (
(? , ?)); - an identity type by
refl, but only when its two endpoints already agree (otherwisereflwould not typecheck); - the unit type by
unit; - the tope universe by each tope constructor —
TOP,BOT,? ≡ ?,? ≤ ?,? ∧ ?,? ∨ ?— so a shape (a hole of typeTOPE) can be built up by tapping.
Any other type admits no simple introduction. Unlike allEliminationsInto
this does not search: a type has at most one introduction form (the tope
universe is the one exception), read off its (weak head normal) head
constructor. Outer type restrictions are stripped first, so an extension type
is introduced by the form of its underlying type (its boundary is met by later
refinement of the holes, not by the choice of constructor).
The λ binder of a Π-introduction is freshened against inScope (the names
already visible at the hole), so introducing over a type whose own definition
reuses an in-scope name (e.g. hom, whose internal binder is t) yields
\ t₁ -> ? rather than a t that shadows the existing one.
endpointsAgree :: Eq var => TermT var -> TermT var -> TypeCheck var Bool Source #
Whether the two endpoints of an identity type are definitionally equal, so
that refl inhabits it. Like fitsInto, any holes or constraints recorded
while probing are discarded, leaving a pure yes/no query.
contextEntailsBottom :: Eq var => TypeCheck var Bool Source #
Whether the local tope context is contradictory (entails ⊥). Reads the
precomputed flag when present, falling back to an entailment check. Used to
decide whether recBOT (ex falso) is available.
recBottomCandidates :: Eq var => TypeCheck var [TermT var] Source #
Ex falso: in a contradictory tope context recBOT inhabits any type, so it
is a candidate for every goal there (and only there — elsewhere it would not
typecheck). Independent of the goal and of the local hypotheses.
coverageHolds :: Eq var => [TermT var] -> TypeCheck var Bool Source #
Whether the local tope context is covered by the union of the given topes —
the coverage obligation of recOR (see contextEntailsUnion), but as a pure
yes/no query rather than a check that issues an error.
recOrCandidates :: Eq var => TermT var -> TypeCheck var [TermT var] Source #
Tope case-split moves: ways to build a value of the goal by recOR,
splitting the proof over a cover of the local tope context. Three sources,
offered together (the UI ranks and filters):
- each disjunction
ψ ∨ φalready in the context becomesrecOR(ψ ↦ ?, φ ↦ ?)— its cover is immediate; - when the goal is an extension type, its restriction faces are a cover
candidate
recOR(ψ₁ ↦ ?, …), offered only when they actually cover the context (so the move typechecks); - a generic two-way split
recOR(? ↦ ?, ? ↦ ?)with the guards left as holes, for an unusual split the player fills in by hand.
All three are offered only in a setting where a split makes sense — a cube variable is in scope, the context has a non-trivial tope, or the goal is a restricted type — so an ordinary (tope-free) goal is left alone.
recordHole :: Eq var => Maybe VarIdent -> TermT var -> TypeCheck var () Source #
Record the goal and local context at a hole (lenient mode only). The goal,
the local hypotheses, and the tope assumptions are all rendered to
user-facing VarIdent names here — reusing the same resolution as
ppTermInContext — so the resulting HoleInfo is independent of the De
Bruijn scope. The global environment is deliberately excluded (only
varIsTopLevel == False locals are kept), and locals are split into cube
variables and ordinary term variables.
recordHoleShape :: Eq var => Maybe VarIdent -> TermT var -> Maybe (Binder, TermT (Inc var)) -> TypeCheck var () Source #
Record a hole. When the hole is the argument of a shape-restricted function
its goal is a shape: the cube goalTy together with a membership tope. The
tope is a scope over the shape's bound variable (the third argument carries
the declared binder name, if any, and the tope); it is rendered under that
binder so the goal reads (binder : goalTy | tope).
checkHoleAgainstShape :: Eq var => Maybe VarIdent -> Binder -> TermT var -> TermT (Inc var) -> TypeCheck var (TermT var) Source #
Check a hole that appears as the argument of a shape-restricted function,
whose domain is the cube cube restricted by tope (a scope over the
domain's bound variable). Mirrors the hole case of typecheck, but records
the shape as the hole's goal so the diagnostic shows (binder : cube | tope).
traceAction' :: Int -> Action' -> a -> a Source #
unsafeTraceAction' :: Int -> Action var -> a -> a Source #
data LocationInfo Source #
Constructors
| LocationInfo | |
Fields | |
Instances
| Show LocationInfo Source # | |
Defined in Rzk.TypeCheck Methods showsPrec :: Int -> LocationInfo -> ShowS # show :: LocationInfo -> String # showList :: [LocationInfo] -> ShowS # | |
| Eq LocationInfo Source # | |
Defined in Rzk.TypeCheck | |
Instances
| Eq Verbosity Source # | |
| Ord Verbosity Source # | |
localRenderBackend :: Maybe RenderBackend -> TypeCheck var a -> TypeCheck var a Source #
localHideTerm :: Bool -> TypeCheck var a -> TypeCheck var a Source #
Run the enclosed action with the renderHideTerm policy set.
hidingTerm :: TypeCheck var a -> TypeCheck var a Source #
Render the enclosed action with the proof term hidden (see renderHideTerm).
data Covariance Source #
Constructors
| Covariant | Positive position. |
| Contravariant | Negative position. |
| Invariant | Unknown position. |
data RenderBackend Source #
Constructors
| RenderSVG | |
| RenderLaTeX |
Instances
| Functor ScopeInfo Source # | |
| Foldable ScopeInfo Source # | |
Defined in Rzk.TypeCheck Methods fold :: Monoid m => ScopeInfo m -> m # foldMap :: Monoid m => (a -> m) -> ScopeInfo a -> m # foldMap' :: Monoid m => (a -> m) -> ScopeInfo a -> m # foldr :: (a -> b -> b) -> b -> ScopeInfo a -> b # foldr' :: (a -> b -> b) -> b -> ScopeInfo a -> b # foldl :: (b -> a -> b) -> b -> ScopeInfo a -> b # foldl' :: (b -> a -> b) -> b -> ScopeInfo a -> b # foldr1 :: (a -> a -> a) -> ScopeInfo a -> a # foldl1 :: (a -> a -> a) -> ScopeInfo a -> a # toList :: ScopeInfo a -> [a] # length :: ScopeInfo a -> Int # elem :: Eq a => a -> ScopeInfo a -> Bool # maximum :: Ord a => ScopeInfo a -> a # minimum :: Ord a => ScopeInfo a -> a # | |
Constructors
| VarInfo | |
Fields
| |
Instances
| Functor VarInfo Source # | |
| Foldable VarInfo Source # | |
Defined in Rzk.TypeCheck Methods fold :: Monoid m => VarInfo m -> m # foldMap :: Monoid m => (a -> m) -> VarInfo a -> m # foldMap' :: Monoid m => (a -> m) -> VarInfo a -> m # foldr :: (a -> b -> b) -> b -> VarInfo a -> b # foldr' :: (a -> b -> b) -> b -> VarInfo a -> b # foldl :: (b -> a -> b) -> b -> VarInfo a -> b # foldl' :: (b -> a -> b) -> b -> VarInfo a -> b # foldr1 :: (a -> a -> a) -> VarInfo a -> a # foldl1 :: (a -> a -> a) -> VarInfo a -> a # elem :: Eq a => a -> VarInfo a -> Bool # maximum :: Ord a => VarInfo a -> a # minimum :: Ord a => VarInfo a -> a # | |
Instances
| Functor ModalTope Source # | |
| Foldable ModalTope Source # | |
Defined in Rzk.TypeCheck Methods fold :: Monoid m => ModalTope m -> m # foldMap :: Monoid m => (a -> m) -> ModalTope a -> m # foldMap' :: Monoid m => (a -> m) -> ModalTope a -> m # foldr :: (a -> b -> b) -> b -> ModalTope a -> b # foldr' :: (a -> b -> b) -> b -> ModalTope a -> b # foldl :: (b -> a -> b) -> b -> ModalTope a -> b # foldl' :: (b -> a -> b) -> b -> ModalTope a -> b # foldr1 :: (a -> a -> a) -> ModalTope a -> a # foldl1 :: (a -> a -> a) -> ModalTope a -> a # toList :: ModalTope a -> [a] # length :: ModalTope a -> Int # elem :: Eq a => a -> ModalTope a -> Bool # maximum :: Ord a => ModalTope a -> a # minimum :: Ord a => ModalTope a -> a # | |
| Eq var => Eq (ModalTope var) Source # | |
Constructors
| Context | |
Fields
| |
Instances
| Functor Context Source # | |
| Foldable Context Source # | |
Defined in Rzk.TypeCheck Methods fold :: Monoid m => Context m -> m # foldMap :: Monoid m => (a -> m) -> Context a -> m # foldMap' :: Monoid m => (a -> m) -> Context a -> m # foldr :: (a -> b -> b) -> b -> Context a -> b # foldr' :: (a -> b -> b) -> b -> Context a -> b # foldl :: (b -> a -> b) -> b -> Context a -> b # foldl' :: (b -> a -> b) -> b -> Context a -> b # foldr1 :: (a -> a -> a) -> Context a -> a # foldl1 :: (a -> a -> a) -> Context a -> a # elem :: Eq a => a -> Context a -> Bool # maximum :: Ord a => Context a -> a # minimum :: Ord a => Context a -> a # | |
emptyTopeContext :: [ModalTope var] Source #
emptyContext :: Context var Source #
allowHoles :: Context var -> Context var Source #
Switch to lenient hole mode: record each hole's goal and context instead
of reporting it as an error. Used by the structured goal/context query and
the --allow-holes CLI mode; the default (strict) mode rejects holes.
withHintLemmas :: [VarIdent] -> Context var -> Context var Source #
Allow a hole's candidate list to draw on the given named top-level
definitions (in addition to the local hypotheses). The game supplies the
per-level allow-list; recordHoleShape then offers each listed lemma whose
type fits the goal, applied to holes. See hintLemmas.
structuralHoleUnify :: Context var -> Context var Source #
Within the given action, a hole unifies only as a leaf in an otherwise
matching structure: a structural mismatch around a hole stays an error rather
than being deferred (see deferHoleMismatches). Used to ask whether a term
could have a given type, as opposed to tolerating an in-progress sketch.
askCurrentScope :: TypeCheck var (ScopeInfo var) Source #
isAccessible :: ModalTope var -> Bool Source #
filterAccessible :: [ModalTope var] -> [ModalTope var] Source #
filterInaccessible :: [ModalTope var] -> [ModalTope var] Source #
accessibleTopes :: [ModalTope var] -> [TermT var] Source #
availableTopes :: Context var -> [TermT var] Source #
availableTopesNF :: Context var -> [TermT var] Source #
varBinders :: Context var -> [(var, Binder)] Source #
The full binder (pattern) of each in-scope variable, used to restore
pattern-binder component names (e.g. t/s for \ (t , s) -> …) when
rendering goals, holes and contexts.
varModalities :: Context var -> [(var, TModality)] Source #
varTopLevels :: Context var -> [(var, Bool)] Source #
withPartialDecls :: TypeCheck VarIdent ([Decl'], [err]) -> TypeCheck VarIdent ([Decl'], [err]) -> TypeCheck VarIdent ([Decl'], [err]) Source #
withSection :: Maybe SectionName -> TypeCheck VarIdent ([Decl VarIdent], [TypeErrorInScopedContext VarIdent]) -> TypeCheck VarIdent ([Decl VarIdent], [TypeErrorInScopedContext VarIdent]) -> TypeCheck VarIdent ([Decl VarIdent], [TypeErrorInScopedContext VarIdent]) Source #
startSection :: Maybe SectionName -> TypeCheck VarIdent a -> TypeCheck VarIdent a Source #
endSection :: [TypeErrorInScopedContext VarIdent] -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent]) Source #
scopeToDecls :: Eq var => [TypeErrorInScopedContext var] -> ScopeInfo var -> TypeCheck var ([Decl var], [TypeErrorInScopedContext var]) Source #
insertExplicitAssumptionFor :: Eq var => var -> (var, VarInfo var) -> TermT var -> TermT var Source #
insertExplicitAssumptionFor' :: Eq var => var -> (var, VarInfo var) -> VarInfo var -> VarInfo var Source #
makeAssumptionExplicit :: Eq var => (var, VarInfo var) -> [(var, VarInfo var)] -> TypeCheck var (Bool, [(var, VarInfo var)]) Source #
collectScopeDecls :: Eq var => Bool -> [TypeErrorInScopedContext var] -> [(var, VarInfo var)] -> [(var, VarInfo var)] -> TypeCheck var ([Decl var], [TypeErrorInScopedContext var]) Source #
data OutputDirection Source #
Instances
| Eq OutputDirection Source # | |
Defined in Rzk.TypeCheck Methods (==) :: OutputDirection -> OutputDirection -> Bool # (/=) :: OutputDirection -> OutputDirection -> Bool # | |
namedBlock :: OutputDirection -> String -> [String] -> String Source #
ppContext' :: OutputDirection -> Context VarIdent -> String Source #
checkTopLevelDuplicate :: VarIdent -> TypeCheck var () Source #
checkNameShadowing :: VarIdent -> TypeCheck var () Source #
withLocation :: LocationInfo -> TypeCheck var a -> TypeCheck var a Source #
withCommand :: Command -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent]) -> TypeCheck VarIdent ([Decl'], [TypeErrorInScopedContext VarIdent]) Source #
A binding shown in a hole's local context: the display name and its type,
already rendered with user-facing VarIdent names (see HoleInfo).
Constructors
| HoleEntry | |
Fields | |
Instances
The structured goal and context at a hole, recorded in lenient mode (see
allowHoles). Everything is rendered to user-facing VarIdent names at
record time, so HoleInfo is independent of the De Bruijn scope it came
from. Local hypotheses are split into ordinary term variables and cube
variables (the cube/tope layer is specific to Rzk); the global environment is
deliberately excluded — it belongs in a searchable inventory, not the goal
panel.
Constructors
| HoleInfo | |
Fields
| |
type TypeCheck var = ReaderT (Context var) (WriterT [HoleInfo] (Except (TypeErrorInScopedContext var))) Source #
traceStartAndFinish :: Show a => String -> a -> a Source #
saturateBottom :: Eq var => [ModalTope var] -> [ModalTope var] Source #
Ex falso for BOT, lifted across modalities.
A contradiction in the topes that are genuinely available at the identity
modality entails BOT, and BOT entails _μ BOT for every modality μ by the
absurd rule (this holds for BOT specifically; a general tope φ does NOT give
_μ φ, which would need the missing unit id ⇒ μ). Re-asserting _μ BOT at
each lock μ where an available tope was hidden lets the contradiction survive
the lock: e.g. _b BOT is accessible under a _b lock (coe Flat Flat), so
mod _b recBOT in a vacuous context is accepted.
A tope counts as available at the identity modality when its variable modality
coerces into Id: a _b-modal tope qualifies via the counit (coe Flat Id),
but a _#-modal one does not (coe Sharp Id is False) — which is exactly why
_# BOT does not leak to plain BOT (see ill-modal-sharp-bot-not-bot).
saturateWith :: (a -> [a] -> Bool) -> ([a] -> [a] -> [a]) -> [a] -> [a] Source #
topePoints :: TermT var -> [TermT var] Source #
simplifyLHSwithDisjunctions :: Eq var => [ModalTope var] -> [[ModalTope var]] Source #
Simplify the context, including disjunctions. See also simplifyLHS.
simplifyLHS :: Eq var => [ModalTope var] -> [ModalTope var] Source #
Simplify the context, except disjunctions. See also simplifyLHSwithDisjunctions.
contextEntailsUnion :: Eq var => [TermT var] -> TypeCheck var () Source #
Check that the local tope context is included in (entails) the union of
the given topes. This is the COVERAGE obligation of recOR: every point of the
context must be covered by some branch guard.
Note that only coverage is required, not equivalence: branch guards may overhang
the context (e.g. when splitting with an already-defined shape), so we do not
require OR(guards) |- context.
checkTopeAgainstContext :: Eq var => String -> TermT var -> TypeCheck var () Source #
Diagnose a recOR branch guard or restriction face against the local tope context. There are three cases, by how the tope relates to the context:
- DISJOINT — the tope and a consistent context have empty overlap (their conjunction is ⊥). The face/branch is then vacuous everywhere, so this is a hard error.
- OVERHANG — the tope is not entailed by the context but still overlaps it.
This is allowed and often intentional (e.g. splitting or restricting with an
already-defined shape, whose faces live on the whole cube rather than being
relativised to the context), so we only emit a non-fatal hint. The hint is
gated at
Normalverbosity, hence silent underSilent(e.g. in tests). - CONTAINED — the tope entails the context: nothing to report.
switchVariance :: TypeCheck var a -> TypeCheck var a Source #
setVariance :: Covariance -> TypeCheck var a -> TypeCheck var a Source #
enterScopeContext :: Binder -> TModality -> TermT var -> Maybe (TermT var) -> Context var -> Context (Inc var) Source #
enterScopeMaybe :: Binder -> TModality -> TermT var -> Maybe (TermT var) -> TypeCheck (Inc var) b -> TypeCheck var b Source #
enterScopeWithBind :: Binder -> TModality -> TermT var -> TermT var -> TypeCheck (Inc var) b -> TypeCheck var b Source #
closeScope :: Binder -> WriterT [HoleInfo] (Except (TypeErrorInScopedContext (Inc var))) b -> TypeCheck var b Source #
Run a sub-scope computation and lift it back to the enclosing scope: close
the error channel one binder with ScopedTypeError (as before), and re-emit
the holes it recorded. HoleInfo is already rendered to VarIdent names, so
no De Bruijn re-indexing is needed — only a plain re-tell. On a thrown
error the sub-scope's holes are dropped, which is intended: holes only matter
on the success path (lenient mode), and strict mode wants the error anyway.
stripTypeRestrictions :: TermT var -> TermT var Source #
etaMatch :: Eq var => Maybe (TermT var) -> TermT var -> TermT var -> TypeCheck var (TermT var, TermT var) Source #
Perform at most one \(\eta\)-expansion at the top-level to assist unification.
memoizeWHNF :: Eq var => TermT var -> TypeCheck var (TermT var) Source #
Memoise a term's WHNF on its top node without reducing the term itself.
The returned term has the same (unreduced) structure, so free-variable and
uses detection see exactly what the user wrote, while a later whnfT is
O(1) via the cached infoWHNF. Used when storing a definition's elaborated
type and value, where an in-place reduction could otherwise discard or
expose a variable occurrence.
whnfT :: Eq var => TermT var -> TypeCheck var (TermT var) Source #
Compute a typed term to its WHNF.
>>>unsafeTypeCheck' $ whnfT "(\\ (x : Unit) -> x) unit"unit : Unit
nfT :: Eq var => TermT var -> TypeCheck var (TermT var) Source #
Compute a typed term to its NF.
>>>unsafeTypeCheck' $ nfT "(\\ (x : Unit) -> x) unit"unit : Unit
unifyInCurrentContext :: Eq var => Maybe (TermT var) -> TermT var -> TermT var -> TypeCheck var () Source #
cubeUnitStarT :: TermT var Source #
topeUninvT :: TermT var -> TermT var Source #
topeBottomT :: TermT var Source #
recBottomT :: TermT var Source #
lambdaT :: TermT var -> Binder -> Maybe (TModality, TermT var, Maybe (Scope TermT var)) -> Scope TermT var -> TermT var Source #
letT :: TermT var -> Binder -> Maybe (TermT var) -> TermT var -> Scope TermT var -> TermT var Source #
letModT :: TermT var -> Binder -> TModality -> TModality -> Maybe (TermT var) -> TermT var -> Scope TermT var -> TermT var Source #
typeFunT :: Binder -> TModality -> TermT var -> Maybe (Scope TermT var) -> Scope TermT var -> TermT var Source #
idJT :: TermT var -> TermT var -> TermT var -> TermT var -> TermT var -> TermT var -> TermT var -> TermT var Source #
checkRecOrAgainst :: Eq var => TermT var -> [(Term var, Term var)] -> TypeCheck var (TermT var) Source #
Check a recOR in checking position against a known expected type: each
branch is checked against that type under its guard tope, followed by the
usual pairwise coherence and the coverage obligation. Passing a restricted
type pushes the boundary into every branch, so a branch hole reports the
faces it must meet (under its tope) instead of the bare underlying type.
Under a branch guard, the faces belonging to the other (mutually exclusive)
branches become disjoint from this branch's tope context, so they are pruned
by pruneVacuousFaces before the branch is checked. Otherwise a face like
i ≡ 1₂ would be reported as vacuous while checking the i ≡ 0₂ branch
against A [i ≡ 0₂ ↦ a, i ≡ 1₂ ↦ b] — which arises in particular with
flat-discrete cube variables, where i ≡ 0₂ ∧ i ≡ 1₂ is provably ⊥.
pruneVacuousFaces :: Eq var => TermT var -> TypeCheck var (TermT var) Source #
Drop the restriction faces of an extension type that are vacuous in the current tope context (their overlap with the context is the empty tope ⊥). A face mentioning an unfilled hole cannot be decided, so it is kept. Non-extension types are returned unchanged. Used when descending into a recOR branch, where the sibling branches' faces are disjoint from the branch guard.
checkCoherence :: Eq var => (TermT var, TermT var) -> (TermT var, TermT var) -> TypeCheck var () Source #
inferStandalone :: Eq var => Term var -> Either (TypeErrorInScopedContext var) (TermT var) Source #
unsafeInferStandalone' :: Term' -> TermT' Source #
unsafeTypeCheck' :: TypeCheck VarIdent a -> a Source #
cube2powerT :: Int -> TermT var Source #
hideTermData :: Bool -> String -> RenderObjectData -> RenderObjectData Source #
Apply the renderHideTerm policy to a cell's render data: drop the
<title> (the full term) from every cell, and blank the visible label of a
proof-coloured (interior) cell. Boundary cells (coloured otherwise) keep
their given labels. A no-op when not hiding.
renderObjectsFor :: Eq var => String -> Int -> TermT var -> TermT var -> TypeCheck var [(ShapeId, RenderObjectData)] Source #
renderObjectsInSubShapeFor :: Eq var => String -> Int -> [var] -> var -> TermT var -> TermT var -> TermT var -> TypeCheck var [(ShapeId, RenderObjectData)] Source #
renderForSubShapeSVG :: Eq var => String -> Int -> [var] -> var -> TermT var -> TermT var -> TermT var -> TypeCheck var String Source #
renderGoalCellSVG :: Eq var => TermT var -> TypeCheck var (Maybe String) Source #
Render the goal cell for a (shape) type: introduce an abstract inhabitant
and render it with the proof term hidden. Under a boundary tope an abstract
inhabitant of an extension type reduces to the prescribed face value, so the
cell shows its given edges with a blank interior — the shape to inhabit, not
an answer. Nothing for a non-shape type (a 0-cell or a non-cube goal).
data CubeCoords2D a b Source #
Constructors
| Camera | |
Fields
| |
fromAffine :: Fractional a => Vector4D a -> (Point2D a, a) Source #
data RenderObjectData Source #
Constructors
| RenderObjectData | |
renderCube :: (Floating a, Show a) => Camera a -> a -> (String -> Maybe RenderObjectData) -> String Source #
defaultCamera :: Floating a => Camera a Source #
Orphan instances
| IsString TermT' Source # | Parse and |
Methods fromString :: String -> TermT' # | |