rzk-0.11.4: An experimental proof assistant for synthetic ∞-categories
Safe HaskellNone
LanguageHaskell2010

Rzk.Check.Context

Description

The typing context of the new checker: what every name in scope is, the tope context, the direction of a comparison, the options, and the stack of judgements kept for diagnostics.

Every entry holds values: the type of the name, and for a definition its value, evaluated once. The context is also the evaluation context of free-foil-NBE (the instance is in Rzk.Check.Value), so evaluation reads definitions and topes from the same place the checker does.

Synopsis

Values

type Value = Value Pattern Sig Source #

A value of the core: free-foil-NBE's, over the pattern binder and the signature.

Pieces

data Variance Source #

The direction of a comparison: whether the expected side is the supertype, the subtype, or neither.

Instances

Instances details
Show Variance Source # 
Instance details

Defined in Rzk.Check.Context

Eq Variance Source # 
Instance details

Defined in Rzk.Check.Context

data Verbosity Source #

Constructors

Debug 
Normal 
Silent 

Instances

Instances details
Show Verbosity Source # 
Instance details

Defined in Rzk.Check.Context

Eq Verbosity Source # 
Instance details

Defined in Rzk.Check.Context

Ord Verbosity Source # 
Instance details

Defined in Rzk.Check.Context

data LocationInfo Source #

Where a diagnostic points: the start of the declaration being checked, narrowed to the sub-term as the checker descends into it.

Instances

Instances details
Show LocationInfo Source # 
Instance details

Defined in Rzk.Check.Context

Eq LocationInfo Source # 
Instance details

Defined in Rzk.Check.Context

atPosition :: RzkPosition -> LocationInfo -> LocationInfo Source #

Point a location at a position in the same file.

data HoleMode Source #

How a user hole is treated.

Constructors

HolesAreErrors

reject an unsolved hole; the default for finished work and CI

HolesDeferred

record the goal and let the hole stand for a term of any type

HolesStructural

record the goal, but tolerate a mismatch only at a hole leaf of an otherwise matching structure

Instances

Instances details
Show HoleMode Source # 
Instance details

Defined in Rzk.Check.Context

Eq HoleMode Source # 
Instance details

Defined in Rzk.Check.Context

data Options Source #

The options a run or a file sets.

Constructors

Options 

Fields

Instances

Instances details
Show Options Source # 
Instance details

Defined in Rzk.Check.Context

Eq Options Source # 
Instance details

Defined in Rzk.Check.Context

Methods

(==) :: Options -> Options -> Bool #

(/=) :: Options -> Options -> Bool #

defaultOptions :: Options Source #

The default options.

>>> defaultOptions
Options {optVerbosity = Normal, optHoles = HolesAreErrors, optHintLemmas = [], optWarnOverhang = False, optWarnTopeFamilyDomain = True, optRender = Nothing}

data Approximation Source #

The state of a conversion check, after the approximate conversion checking of Kovács's smalltt. A check starts ApproxRigid. Two glued values of one defined name compare their folded sides ApproxFlex, with no unfolding, and if these differ their unfolded sides ApproxFull.

Constructors

ApproxRigid

unfold distinct definitions; equal ones may first compare folded

ApproxFlex

compare folded sides of one definition, without unfolding

ApproxFull

allow a full unfolded comparison after the folded attempt

Instances

Instances details
Show Approximation Source # 
Instance details

Defined in Rzk.Check.Context

Eq Approximation Source # 
Instance details

Defined in Rzk.Check.Context

data Unfolding #

Constructors

Folded 
Unfolded 

Entries

data EntryKind Source #

Constructors

EntryLocal

a local binder, not collected when a section closes

EntryAssumption

a section assumption, abstracted away when the section closes

EntryTopLevel

a definition or postulate that survives the section

Instances

Instances details
Show EntryKind Source # 
Instance details

Defined in Rzk.Check.Context

Eq EntryKind Source # 
Instance details

Defined in Rzk.Check.Context

data Entry (n :: S) Source #

What is known about a name in scope.

Constructors

Entry 

Fields

Instances

Instances details
Sinkable Entry Source # 
Instance details

Defined in Rzk.Check.Context

Methods

sinkabilityProof :: forall (n :: S) (l :: S). (Name n -> Name l) -> Entry n -> Entry l #

localEntry :: forall (n :: S). TModality -> Maybe VarIdent -> Maybe LocationInfo -> Value n -> Entry n Source #

The entry of a local name of a type.

data Section (n :: S) Source #

An open section: its name, and the top-level entries made in it, newest first. The module itself is an anonymous section, so that an assumption outside any named section is abstracted at the end of the module.

Constructors

Section 

Diagnostics

data Action (n :: S) Source #

The judgement being performed, for the trace and the error report.

Constructors

ActionCheck (Raw n) (Value n)

check a raw term against a type value

ActionInfer (Raw n)

infer the type of a raw term

ActionConvert (Value n) (Value n)

compare an expected value with an actual one

ActionEntails [Tope n] (Tope n)

check that the listed context topes entail a goal

ActionEntailsUnion [Tope n] [Tope n]

check that the listed context topes are covered by a union

ActionCheckLetValue (Maybe VarIdent)

check or infer a local definition's value

ActionCloseSection (Maybe String)

close a named section, or the anonymous module section

data Diag (n :: S) Source #

What a full run keeps for its diagnostics: the stack of judgements.

Constructors

Diag 

Fields

emptyDiag :: forall (n :: S). Diag n Source #

The context

data Context (n :: S) Source #

Constructors

Context 

Fields

Instances

Instances details
Eval Context Pattern Sig 
Instance details

Defined in Rzk.Check.Value

Methods

definition :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n

unfolding :: forall (n :: S). Scope n -> Context n -> Value Pattern Sig n -> Value Pattern Sig n -> Value Pattern Sig n

glueSpeculation :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n -> Name n -> Value Pattern Sig n -> GlueSpeculation Context n

unfoldGlued :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n -> Maybe (Context n)

evalSig :: forall (o :: S) (i :: S). (Distinct o, Distinct i) => Scope o -> Context o -> Substitution (Value Pattern Sig) i o -> Sig (ScopedAST Pattern Sig i) (AST Pattern Sig i) -> Value Pattern Sig o

etaMatchWith :: forall a (n :: S) c b d. (a -> EtaScoped Context Pattern Sig n -> c) -> (b -> EtaTerm Context Pattern Sig n -> d) -> Sig a b -> Maybe (Sig c d)

extendScopedWith :: forall (n :: S) a c d. Distinct n => (a -> Extend Context Pattern Sig n -> c) -> (Value Pattern Sig n -> d) -> Sig a (Value Pattern Sig n) -> Sig c d

relateWith :: forall m (n :: S) a a'. (Monoid m, Distinct n) => Scope n -> Context n -> (a -> a' -> Context n -> Extend Context Pattern Sig n -> m) -> (Value Pattern Sig n -> Value Pattern Sig n -> Context n -> m) -> (Value Pattern Sig n -> Value Pattern Sig n -> Context n -> m) -> Sig a (Value Pattern Sig n) -> Sig a' (Value Pattern Sig n) -> Maybe m

relateMismatch :: forall (n :: S). (Eval Context Pattern Sig, Distinct n) => Scope n -> Context n -> Value Pattern Sig n -> Value Pattern Sig n -> Bool

refineVar :: forall (n :: S). (Eval Context Pattern Sig, Distinct n) => Scope n -> Context n -> Name n -> Value Pattern Sig n

refineSig :: forall (n :: S) a. (Eval Context Pattern Sig, Distinct n) => Scope n -> Context n -> Value Pattern Sig n -> Sig a (Value Pattern Sig n) -> Value Pattern Sig n

binderValue :: forall (n :: S) (l :: S). (Distinct n, Distinct l) => Scope l -> Context l -> Pattern n l -> Maybe (Value Pattern Sig l)

bindValue :: forall (o :: S) (i :: S) (l :: S). Distinct o => Scope o -> Context o -> Substitution (Value Pattern Sig) i o -> Pattern i l -> Value Pattern Sig o -> Maybe (Substitution (Value Pattern Sig) l o)

evalBinder :: forall (n :: S) (i :: S) (e :: S -> Type) (l :: S) r. (CoSinkable Pattern, Distinct n, Distinct i, Sinkable e, InjectName e) => Scope n -> Context n -> Substitution (Value Pattern Sig) i n -> Pattern i l -> (forall (n' :: S). DExt n n' => (Substitution e i n -> Substitution e l n') -> Pattern n n' -> Scope n' -> r) -> r

HasDefinitions Context Pattern Sig

A defined name is glued to its value; any other name is a neutral.

Instance details

Defined in Rzk.Check.Value

Methods

contextDefinition :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n

contextUnfolding :: forall (n :: S). Scope n -> Context n -> Value Pattern Sig n -> Value Pattern Sig n -> Value Pattern Sig n

contextGlueSpeculation :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n -> Name n -> Value Pattern Sig n -> GlueSpeculation Context n

contextUnfoldGlued :: forall (n :: S). Scope n -> Context n -> Name n -> Value Pattern Sig n -> Maybe (Context n)

emptyContext :: Context 'VoidS Source #

The empty context, with defaultOptions. Conversion starts covariantly, with definitions unfolded and the rigid approximation strategy.

>>> ctxVariance emptyContext
Covariant
>>> case ctxUnfolding emptyContext of { Unfolded -> True; Folded -> False }
True
>>> ctxApproximation emptyContext
ApproxRigid

lookupEntry :: forall (n :: S). Name n -> Context n -> Entry n Source #

What a name stands for. Total: every name in scope has an entry.

lookupNamed :: forall (n :: S). VarIdent -> Context n -> Maybe (Name n) Source #

entriesInScope :: forall (n :: S). Context n -> [(Name n, Entry n)] Source #

Every entry in scope, oldest binding first.

enterPattern :: forall (n :: S) (l :: S). (Distinct n, DExt n l) => Pattern n l -> [Entry l] -> Context n -> Context l Source #

Enter the scope of a pattern: extend the scope with its names and record an entry for each, in binding order.

sinkContextUnchecked :: forall (n :: S) (l :: S). DExt n l => Context n -> Context l Source #

Sink a context along a scope extension. Unsound on its own: the scope and the entries still describe the old scope, so the caller must extend both, as enterPattern does. Everything else in the context mentions the scope only through values and names, which sink by coercion.

insertEntry :: forall (n :: S). Name n -> Entry n -> Context n -> Context n Source #

Replace what a name stands for.

withVariance :: forall (n :: S). Variance -> Context n -> Context n Source #