{-# OPTIONS --cubical-compatible --safe #-}
module Data.Star.Nat where
open import Data.Unit
open import Function.Base using (const)
open import Relation.Binary.Core using (Rel)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
open import Relation.Binary.Construct.Always using (Always)
ℕ : Set
ℕ = Star Always tt tt
zero : ℕ
zero = ε
suc : ℕ → ℕ
suc = _◅_ _
length : ∀ {i t} {I : Set i} {T : Rel I t} {i j} → Star T i j → ℕ
length = gmap (const _) (const _)
infixl 7 _*_
infixl 6 _+_ _∸_
_+_ : ℕ → ℕ → ℕ
_+_ = _◅◅_
_*_ : ℕ → ℕ → ℕ
_*_ m = const m ⋆
_∸_ : ℕ → ℕ → ℕ
m ∸ ε = m
ε ∸ (_ ◅ n) = zero
(_ ◅ m) ∸ (_ ◅ n) = m ∸ n
0# = zero
1# = suc 0#
2# = suc 1#
3# = suc 2#
4# = suc 3#
5# = suc 4#