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

Rzk.Check.Topes

Description

The tope solver, on first-order topes.

A tope is read off a value into Tope, a first-order syntax with no binders and no scope index, whose equality is structural and whose ordering keys a set. The solver is the saturation solver of Rzk.TypeCheck.Eval (Riehl and Shulman's tope logic, the lattice operations on the intervals, and the cover of a disjunction by alternatives), made pure and without inversion under ᵒᵖ (see saturateInv). The context caches its saturation lazily, and a query reads it.

The modal layer (topes assumed under a modality, locks, and ex falso across modalities) follows the modal topes of LIshy2 in the old checker (#230). Inversion under ᵒᵖ is not implemented yet.

Synopsis

Topes

data Cube Source #

A cube, as far as the solver tells cubes apart.

Constructors

KUnit 
K2 
KI 
KProd Cube Cube 
KOther

a cube the solver has no rules for: a neutral one, or a modal one

Instances

Instances details
Show Cube Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

showsPrec :: Int -> Cube -> ShowS #

show :: Cube -> String #

showList :: [Cube] -> ShowS #

Eq Cube Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

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

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

Ord Cube Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

compare :: Cube -> Cube -> Ordering #

(<) :: Cube -> Cube -> Bool #

(<=) :: Cube -> Cube -> Bool #

(>) :: Cube -> Cube -> Bool #

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

max :: Cube -> Cube -> Cube #

min :: Cube -> Cube -> Cube #

data Point (n :: S) Source #

A point of a cube. Evaluation has normalised it: a projection applies only to a neutral, the lattice operations only to points that are not endpoints, and a flip only to a neutral.

Constructors

PVar !(Name n) !Cube

a variable, with its cube

PStar 
P2_0 
P2_1 
PI_0 
PI_1 
PPair (Point n) (Point n) 
PFst (Point n) 
PSnd (Point n) 
PSup (Point n) (Point n) 
PInf (Point n) (Point n) 
PFlip (Point n) 
PUnflip (Point n) 
PModApp TModality (Point n) 
PModExtract TModality TModality (Point n) 
PApp !Cube (Point n) (Point n)

a neutral application, with its cube

PHole (Maybe VarIdent) 
POpaque String

a point the solver cannot read (an elimination it has no rule for), keyed by a fingerprint of its term, so that equal values read back equal

Instances

Instances details
Show (Point n) Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

showsPrec :: Int -> Point n -> ShowS #

show :: Point n -> String #

showList :: [Point n] -> ShowS #

Eq (Point n) Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

(==) :: Point n -> Point n -> Bool #

(/=) :: Point n -> Point n -> Bool #

Ord (Point n) Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

compare :: Point n -> Point n -> Ordering #

(<) :: Point n -> Point n -> Bool #

(<=) :: Point n -> Point n -> Bool #

(>) :: Point n -> Point n -> Bool #

(>=) :: Point n -> Point n -> Bool #

max :: Point n -> Point n -> Point n #

min :: Point n -> Point n -> Point n #

data Tope (n :: S) Source #

A tope.

Constructors

TTop 
TBot 
TEq (Point n) (Point n) 
TLeq (Point n) (Point n) 
TAnd (Tope n) (Tope n) 
TOr (Tope n) (Tope n) 
TInv (Tope n) 
TUninv (Tope n) 
TModal TModality (Tope n) 
TModApp TModality (Tope n) 
TNeutral (Point n)

a tope family applied, or a tope variable: a neutral point of the tope universe

THole (Maybe VarIdent) 

Instances

Instances details
Show (Tope n) Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

showsPrec :: Int -> Tope n -> ShowS #

show :: Tope n -> String #

showList :: [Tope n] -> ShowS #

Eq (Tope n) Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

(==) :: Tope n -> Tope n -> Bool #

(/=) :: Tope n -> Tope n -> Bool #

Ord (Tope n) Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

compare :: Tope n -> Tope n -> Ordering #

(<) :: Tope n -> Tope n -> Bool #

(<=) :: Tope n -> Tope n -> Bool #

(>) :: Tope n -> Tope n -> Bool #

(>=) :: Tope n -> Tope n -> Bool #

max :: Tope n -> Tope n -> Tope n #

min :: Tope n -> Tope n -> Tope n #

cubeOf :: forall (n :: S). Point n -> Cube Source #

The cube of a point.

pointFirst :: forall (n :: S). Point n -> Point n Source #

The first component of a point of a product cube.

pointSecond :: forall (n :: S). Point n -> Point n Source #

topeAnd :: forall (n :: S). Tope n -> Tope n -> Tope n Source #

Conjunction, with ⊥ absorbing and ⊤ dropped.

topeOr :: forall (n :: S). Tope n -> Tope n -> Tope n Source #

Disjunction, with ⊥ dropped.

data ModalTope (n :: S) Source #

A tope, together with the modalities under which it is available: the lock accumulated since it was assumed, and the modality it was assumed at.

Constructors

ModalTope 

Instances

Instances details
Show (ModalTope n) Source # 
Instance details

Defined in Rzk.Check.Topes

Eq (ModalTope n) Source # 
Instance details

Defined in Rzk.Check.Topes

Methods

(==) :: ModalTope n -> ModalTope n -> Bool #

(/=) :: ModalTope n -> ModalTope n -> Bool #

Ord (ModalTope n) Source # 
Instance details

Defined in Rzk.Check.Topes

plainTope :: forall (n :: S). Tope n -> ModalTope n Source #

isAccessible :: forall (n :: S). ModalTope n -> Bool Source #

The tope context

data TopeContext (n :: S) Source #

The assumed topes and what the solver derives from them. The derived parts are lazy: the alternatives of a disjunctive context, whether the context is contradictory, and its saturation are computed by the first query that needs them.

emptyTopeContext :: forall (n :: S). TopeContext n Source #

The empty context: ⊤ holds under every modality.

contextTopes :: forall (n :: S). TopeContext n -> [ModalTope n] Source #

The assumed topes, newest first, with their modalities.

accessibleTopes :: forall (n :: S). TopeContext n -> [Tope n] Source #

The assumed topes that are available at the current lock.

assume :: forall (n :: S). Tope n -> TopeContext n -> TopeContext n Source #

Assume a tope. A tope that says nothing new (a reflexive equation, or one already assumed) leaves the context as it is, so that the derived parts stay shared.

assumeDiscrete :: forall (n :: S). Tope n -> TopeContext n -> TopeContext n Source #

Add a discreteness axiom (a flat point of an interval is an endpoint).

applyModality :: forall (n :: S). TModality -> TopeContext n -> TopeContext n Source #

Accumulate a lock over the assumed topes.

Queries

entails :: forall (n :: S). TopeContext n -> Tope n -> Bool Source #

Does the context entail the tope?

entailsBottom :: forall (n :: S). TopeContext n -> Bool Source #

Is the context contradictory?

entailsUnion :: forall (n :: S). TopeContext n -> [Tope n] -> Bool Source #

Does the context entail the disjunction of the topes: is every point of the context covered by one of them?

entailedBy :: forall (n :: S). TopeContext n -> Tope n -> Bool Source #

Does the tope entail the conjunction of the context's accessible topes?

disjoint :: forall (n :: S). TopeContext n -> Tope n -> Bool Source #

Is the tope disjoint from the context: does assuming it make the context contradictory?

equivalent :: forall (n :: S). TopeContext n -> Tope n -> Tope n -> Bool Source #

Are two topes equivalent on their own, under the context's discreteness axioms?

topesEntail :: forall (n :: S). TopeContext n -> [Tope n] -> Tope n -> Bool Source #

Do the topes alone (with the discreteness axioms) entail the goal?

alternatives :: forall (n :: S). TopeContext n -> [TopeContext n] Source #

The alternatives of a disjunctive context, each as the context with that alternative assumed instead; a context with one alternative has none to split.

inAlternatives :: forall (n :: S). TopeContext n -> (TopeContext n -> Bool) -> Bool Source #

Does a check hold in every alternative of the context? A context with one alternative runs the check once, on itself.