| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rzk.Check.Topes
Contents
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
- data Cube
- data Point (n :: S)
- = PVar !(Name n) !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)
- | PHole (Maybe VarIdent)
- | POpaque String
- data Tope (n :: S)
- cubeOf :: forall (n :: S). Point n -> Cube
- pointFirst :: forall (n :: S). Point n -> Point n
- pointSecond :: forall (n :: S). Point n -> Point n
- topeAnd :: forall (n :: S). Tope n -> Tope n -> Tope n
- topeOr :: forall (n :: S). Tope n -> Tope n -> Tope n
- data ModalTope (n :: S) = ModalTope {}
- plainTope :: forall (n :: S). Tope n -> ModalTope n
- isAccessible :: forall (n :: S). ModalTope n -> Bool
- data TopeContext (n :: S)
- emptyTopeContext :: forall (n :: S). TopeContext n
- contextTopes :: forall (n :: S). TopeContext n -> [ModalTope n]
- accessibleTopes :: forall (n :: S). TopeContext n -> [Tope n]
- assume :: forall (n :: S). Tope n -> TopeContext n -> TopeContext n
- assumeDiscrete :: forall (n :: S). Tope n -> TopeContext n -> TopeContext n
- applyModality :: forall (n :: S). TModality -> TopeContext n -> TopeContext n
- entails :: forall (n :: S). TopeContext n -> Tope n -> Bool
- entailsBottom :: forall (n :: S). TopeContext n -> Bool
- entailsUnion :: forall (n :: S). TopeContext n -> [Tope n] -> Bool
- entailedBy :: forall (n :: S). TopeContext n -> Tope n -> Bool
- disjoint :: forall (n :: S). TopeContext n -> Tope n -> Bool
- equivalent :: forall (n :: S). TopeContext n -> Tope n -> Tope n -> Bool
- topesEntail :: forall (n :: S). TopeContext n -> [Tope n] -> Tope n -> Bool
- alternatives :: forall (n :: S). TopeContext n -> [TopeContext n]
- inAlternatives :: forall (n :: S). TopeContext n -> (TopeContext n -> Bool) -> Bool
Topes
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 |
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 |
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) |
pointFirst :: forall (n :: S). Point n -> Point n Source #
The first component of a point of a product cube.
topeAnd :: forall (n :: S). Tope n -> Tope n -> Tope n Source #
Conjunction, with ⊥ absorbing and ⊤ 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.
Instances
| Show (ModalTope n) Source # | |
| Eq (ModalTope n) Source # | |
| Ord (ModalTope n) Source # | |
Defined in Rzk.Check.Topes | |
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.