Documentation

Cedar.Thm.Ext.Duration.Grammar

Duration grammar: definitions #

This file contains only grammar-level definitions: the well-formedness predicates and the value relation. IsWfDuration states the syntax, value gives the denotation of already identified components, and IsDurationValue str v combines the same witnesses to say that str denotes v. The executable extraction machinery used to connect these definitions to Duration.parse lives in Cedar.Thm.Ext.Duration.Lemmas.

Render an optional duration component as its string representation. none produces "", some digits produces digits ++ suffix.

Equations
Instances For

    Lift the Digit⁺ quantity-token predicate (IsDigits) to optional components: none is trivially valid.

    Equations
    Instances For

      The five optional digit-string components of a duration body, one per time unit. Each field holds none (unit absent) or some digits (unit present with that value).

      Instances For

        At least one component must be present (the body cannot be empty).

        Equations
        Instances For

          Every present component must be a valid duration quantity (nonempty, parseable digits).

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

            Canonical string representation: concatenate present components in order d h m s ms. Absent components contribute "".

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

              Natural-number value of an optional duration quantity. An absent component denotes zero; a present well-formed component is read by the shared grammar-level natOf.

              Equations
              Instances For

                Unsigned millisecond value of already identified duration components.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Cedar.Thm.Duration.value (sign : String) (components : Components) :

                  The grammar's value function, applied to an already identified sign and component record.

                  Equations
                  Instances For
                    def Cedar.Thm.Duration.canonicalComponents (days hours minutes seconds ms : Nat) :

                    Canonical maximized components for a duration value split into days, hours, minutes, seconds, and milliseconds. All five fields are present, including zero-valued fields.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def Cedar.Thm.Duration.canonicalBody (days hours minutes seconds ms : Nat) :

                      Canonical maximized duration body: days d, hours h, minutes m, seconds s, and milliseconds ms, printed largest-to-smallest.

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

                        A duration body string is well-formed iff it equals components.asString for some Components that is nonempty and has valid quantities.

                        Equations
                        Instances For

                          The grammar production witnessed by an optional sign and a nonempty component record.

                          Equations
                          Instances For

                            A duration string is well-formed iff it has a valid grammar production.

                            Equations
                            Instances For

                              v is the value assigned to a valid duration production.

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

                                Canonical-form normalizer: parse the string and re-serialize. Returns none for malformed or out-of-range inputs.

                                Equations
                                Instances For