Documentation

Cvc.Types.Record

Records #

Record fields is both the index of a record-sorted term and the Lean value such a term denotes, fields being its named fields in order. The order is part of the sort: {a : Int, b : Bool} and {b : Bool, a : Int} are different sorts.

def origin : Record [("x", Int), ("y", Int)] := .cons "x" 0 (.last "y" 0)
#eval origin.get "y"   -- 0
class Cvc.ToTypFields (fields : List (String × Type)) :

The Typs a list of named Lean types denotes.

Instances
    @[instance_reducible]
    instance Cvc.ToTypFields.instConsProdStringTypeMkOfToTyp {α : Type} {fields : List (String × Type)} {name : String} [A : ToTyp α] [Fs : ToTypFields fields] :
    ToTypFields ((name, α) :: fields)
    Equations

    A record's field values: gamma for each field, in order, as nested pairs ending in PUnit.

    Equations
    Instances For
      structure Cvc.Record (fields : List (String × Type)) :

      A record of the named, ordered fields: a record sort, and a value of it.

      • values : Values fields

        The field values, in order.

      Instances For
        def Cvc.Record.last {gamma : Type} (_name : String) (value : gamma) :
        Record [(_name, gamma)]

        A record's last field, and its value.

        Equations
        Instances For
          def Cvc.Record.cons {gamma : Type} {fields : List (String × Type)} (_name : String) (value : gamma) (rest : Record fields) :
          Record ((_name, gamma) :: fields)

          Adds a field's value in front of the ones collected so far.

          Equations
          Instances For
            class Cvc.FieldOf (fields : List (String × Type)) (name : String) (gamma : outParam Type) :

            name is one of fields, with type gamma: where it sits, and how to reach it.

            Resolved by instance search, so a name that is not a field, or one asked for at the wrong type, does not compile.

            • idx : Fin fields.length

              Where the field sits in fields.

            • get : Values fields → gamma

              The field's value.

            • set : Values fields → gamma → Values fields

              The values, with this field's replaced.

            Instances
              @[instance_reducible, instance 10000]
              instance Cvc.instFieldOfConsProdStringTypeMk {name : String} {gamma : Type} {fields : List (String × Type)} :
              FieldOf ((name, gamma) :: fields) name gamma
              Equations
              • One or more equations did not get rendered due to their size.
              @[instance_reducible]
              instance Cvc.instFieldOfConsProdStringTypeMk_1 {fields : List (String × Type)} {name : String} {gamma : Type} {_other : String} {_beta : Type} [F : FieldOf fields name gamma] :
              FieldOf ((_other, _beta) :: fields) name gamma
              Equations
              • One or more equations did not get rendered due to their size.
              def Cvc.Record.get {fields : List (String × Type)} (r : Record fields) {gamma : Type} (name : String) [F : FieldOf fields name gamma] :
              gamma

              A field's value.

              Total: a name that is not a field has no FieldOf instance, so there is no none to answer.

              Equations
              Instances For
                def Cvc.Record.set {fields : List (String × Type)} (r : Record fields) {gamma : Type} (name : String) [F : FieldOf fields name gamma] (value : gamma) :
                Record fields

                The same record, with one field's value replaced.

                Equations
                Instances For

                  Instances for nesting #

                  A record's order, equality, hash and string form are lifted field by field, each through its own class, so a record demands of its fields only what is asked of the record.

                  class Cvc.OrdFields (fields : List (String × Type)) :

                  Lifts Ord over a record's fields, lexicographically.

                  Instances
                    @[instance_reducible]
                    Equations
                    @[instance_reducible]
                    instance Cvc.instOrdFieldsConsProdStringTypeMkOfOrd {gamma : Type} {fields : List (String × Type)} {_name : String} [Ord gamma] [R : OrdFields fields] :
                    OrdFields ((_name, gamma) :: fields)
                    Equations
                    • One or more equations did not get rendered due to their size.

                    Lifts DecidableEq over a record's fields.

                    Instances
                      @[instance_reducible]
                      instance Cvc.instDecidableEqFieldsConsProdStringTypeMkOfDecidableEq {gamma : Type} {fields : List (String × Type)} {_name : String} [DecidableEq gamma] [R : DecidableEqFields fields] :
                      DecidableEqFields ((_name, gamma) :: fields)
                      Equations
                      • One or more equations did not get rendered due to their size.

                      Lifts Hashable over a record's fields.

                      Instances
                        @[instance_reducible]
                        instance Cvc.instHashableFieldsConsProdStringTypeMkOfHashable {gamma : Type} {fields : List (String × Type)} {_name : String} [Hashable gamma] [R : HashableFields fields] :
                        HashableFields ((_name, gamma) :: fields)
                        Equations
                        • One or more equations did not get rendered due to their size.

                        Lifts ToString over a record's fields, and names them.

                        Instances
                          @[instance_reducible]
                          instance Cvc.instToStringFieldsConsProdStringTypeMkOfToString {gamma : Type} {fields : List (String × Type)} {name : String} [ToString gamma] [R : ToStringFields fields] :
                          ToStringFields ((name, gamma) :: fields)
                          Equations
                          • One or more equations did not get rendered due to their size.
                          @[instance_reducible]
                          instance Cvc.instOrdRecordOfOrdFields {fields : List (String × Type)} [O : OrdFields fields] :
                          Ord (Record fields)
                          Equations
                          @[instance_reducible]
                          Equations
                          • One or more equations did not get rendered due to their size.
                          @[instance_reducible]
                          Equations
                          @[instance_reducible]
                          Equations
                          @[instance_reducible]
                          instance Cvc.instToTypRecordOfToTypFields {fields : List (String × Type)} [Fs : ToTypFields fields] :
                          ToTyp (Record fields)
                          Equations