{-# OPTIONS --guardedness #-}
open import Agda.Builtin.Equality
open import Data.Product
open import Level
open import Relation.Unary using (_โ_)
module is-lib.InfSys.Coinduction {๐} where
private
variable
U : Set ๐
open import is-lib.InfSys.Base {๐}
open import is-lib.InfSys.Induction {๐}
open MetaRule
open IS
record CoIndโฆ_โง {๐c ๐p ๐n : Level} (is : IS {๐c} {๐p} {๐n} U) (u : U) : Set (๐ โ ๐c โ ๐p โ ๐n) where
coinductive
constructor cofold_
field
unfold : ISF[ is ] CoIndโฆ is โง u
coind[_] : โ{๐c ๐p ๐n ๐'}
โ (is : IS {๐c} {๐p} {๐n} U)
โ (S : U โ Set ๐')
โ (S โ ISF[ is ] S)
โ S โ CoIndโฆ is โง
CoIndโฆ_โง.unfold (coind[ is ] S cn Su) with cn Su
... | rn , c , refl , pr = rn , c , refl , ฮป i โ coind[ is ] S cn (pr i)
apply-coind : โ{๐c ๐p ๐n}{is : IS {๐c} {๐p} {๐n} U} โ (rn : is .Names) โ RClosed (is .rules rn) CoIndโฆ is โง
apply-coind {is = is} rn = prefixโclosed (is .rules rn) {P = CoIndโฆ _ โง} ฮป{(c , refl , pr) โ cofold (rn , c , refl , pr)}
coind-postfix : โ{๐c ๐p ๐n}{is : IS {๐c} {๐p} {๐n} U} โ CoIndโฆ is โง โ ISF[ is ] CoIndโฆ is โง
coind-postfix x = x .CoIndโฆ_โง.unfold
coind-prefix : โ{๐c ๐p ๐n}{is : IS {๐c} {๐p} {๐n} U} โ ISF[ is ] CoIndโฆ is โง โ CoIndโฆ is โง
coind-prefix x = cofold x