==============================================================================================
# Digit strings (Digit⁺) and their correspondence with toNat?'
`IsDigits` is the grammar-level notion of a non-empty run of digit characters — the
`Digit⁺` production common to numeric grammars. These lemmas connect it to the stdlib
natural-number parser `toNat?'`: a digit string is exactly one `toNat?'` accepts (modulo the
`'_'` separator, which `toNat?'` rejects and `Char.isDigit` never admits). The `IsDigits.*`
projections at the end give dot-notation for the facts parser proofs consume.
==============================================================================================
Digit{n}: a run of exactly n decimal digits. The fixed-width refinement of IsDigits,
used wherever a grammar pins a field's width (the datetime grammar's YYYY, MM, SSS, …).
Instances For
Digit{1,n}: between one and n decimal digits. IsDigits supplies the lower bound and the
length constraint the upper (the decimal grammar's Fraction ::= Digit{1,4}).
Instances For
Natural-number value of a captured decimal digit string, defaulting to 0 when parsing fails.
On a field satisfying IsDigits, the default is never taken.
Equations
- s.natOf = (Cedar.Spec.Ext.toNat?' s).getD 0
Instances For
Rendering a natural number and parsing it with Cedar's underscore-rejecting parser recovers the original number.
Nat.repr is accepted by Cedar's natural-number parser.
The canonical decimal rendering of a natural number is a nonempty digit string.
============================================================================================== # Splitting a string on a separator ==============================================================================================
==============================================================================================
# toString/repr of naturals contains no '.'
==============================================================================================
==============================================================================================
# Digit-accumulating folds and Nat.toDigits roundtrip
==============================================================================================