Documentation

Cvc.Types.Denote

The Lean type a sort denotes #

Typ.Denote τ is the Lean type that indexes terms of sort τ: .int denotes Int, .set .int denotes Set Int, a record its Record, a tuple its product. It is what makes a sort carried as data — a Typ field of a term's view — usable as a term's index: matching the Typ refines Term τ.Denote to Term Int, definitionally.

A sort with no better denotation denotes Sorted τ, a stand-in indexed by the sort itself: declared sorts, a container keyed on something with no order, a tuple whose last component is a tuple. A term at a stand-in is moved to a user's own index with Typed.Term.cast.

Everything here is reducible and exposed, so that a known Typ reduces both in unification and in instance resolution.

structure Cvc.Sorted (τ : Typ) :

The stand-in Lean type for a sort with no better denotation, indexed by the sort itself.

    Instances For
      @[instance_reducible]
      instance Cvc.instToTypSorted {τ : Typ} :
      Equations
      @[instance_reducible]
      instance Cvc.instOrdSorted {τ : Typ} :
      Ord (Sorted τ)

      Sorted τ has exactly one value, so the constant order is the right one.

      Equations
      @[reducible]

      Whether a tuple's last component is itself a tuple.

      Equations
      Instances For
        @[reducible]
        def Cvc.Typ.denoteWithOrd :
        Typ → (T : Type) × Option (Ord T)

        The Lean type a sort denotes, together with its order if it has one.

        Computed together because a container's denotation needs its element's order: .set .int denotes Set Int, which is only a type given Ord Int. A container whose element has no order — a set of functions — denotes Sorted τ, as do declared sorts. TotalMap and functions have no order of their own; a record or a tuple has one exactly when all its components do, lexicographically, as OrdFields and the product order give it.

        Equations
        Instances For
          @[reducible]

          A record's fields' denotations, by name, with the record's order if every field has one.

          Equations
          Instances For
            @[reducible]

            A tuple's denotation, ordered if every component is.

            The right-nested product of its components' denotations, as α × β × γ indexes a three-component tuple, and OneTuple for one component. A tuple whose last component is itself a tuple has no product to denote it — the product would flatten it — and neither has the empty tuple: those are Sorted.

            Equations
            Instances For
              @[reducible]
              def Cvc.Typ?.denoteWithOrd :
              Typ? → (T : Type) × Option (Ord T)

              Typ.denoteWithOrd lifted to Typ?; an abstract sort, never a term's, denotes Empty.

              Equations
              Instances For
                @[reducible]

                A record's fields' denotations, by name.

                Equations
                Instances For
                  @[reducible]

                  A tuple's denotation; see Typ.denoteProdWithOrd.

                  Equations
                  Instances For
                    @[reducible]
                    def Cvc.Typ.Denote (τ : Typ) :

                    The Lean type a sort denotes.

                    It reduces on a known Typ, which is what makes matching on a view's Typ refine the kids' index: Term (Typ.Denote .int) is Term Int, and Term (Typ.Denote (.set .int)) is Term (Set Int), with the very Ord Int a user's Set Int has.

                    Equations
                    Instances For
                      @[instance_reducible]
                      instance Cvc.instToTypDenote (τ : Typ) :

                      A denotation's sort is the sort it denotes.

                      Equations

                      The function type from the denotations of doms, in order, to β.

                      Equations
                      Instances For
                        @[instance_reducible]
                        instance Cvc.Typ.arrowsToTyp {β : Type} [ToTyp β] (doms : List Typ) :
                        ToTyp (arrows doms β)

                        A function type over denotations has the function sort they denote.

                        Equations

                        Shows a denotation, or a function type over denotations, as the type it reduces to.

                        Typ.Denote (.set .int) shows as Set Int. A sort that does not reduce, or only part-way — one bound by an unmatched pattern — shows as τ.Denote.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For