-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Conat #57
Add Conat #57
Conversation
The code looks fine to me, but is there anything univalent you can do with the co-natural numbers? |
I can't think of any. Maybe proving bisimulation on conat is equivalent to path? Happy Chinese new year! |
That sounds like a good idea! Maybe you can construct some non-trivial equivalence on conat as well? Or to some other type. You can then transport some things back and forth just to check that transp works for coinductives |
Xīnnián kuàilè! (I hope Google translate got that right) |
Yes the pronunciation is correct! I'm truggling with the definition of plus. TBH, I don't like Sized Types. I'm trying to get rid of it (while the Conat in the stdlib is completely based on Sized Types) |
A univalent thing you can do is to show that conat is equivalent and hence equal to the type of decreasing binary sequences, which is how I define conat here: http://www.cs.bham.ac.uk/~mhe/agda-new/CoNaturals.html |
I've just found that bisimulation on a sum type is quite hard to define since some definitional equalities are lost due to guarded recursion. I'll take a look at @martinescardo@'s code. |
@martinescardo@ it's a beautiful one, but the definition of CoNatural is using a different encoding from mine. I noticed that you have a I'm still not able to define a better |
When I did this in 2010-2011 (then extended in 2012 with coinduction), I was not satisfied with Agda's native treatment of coinduction/corecursion, and this is why I implemented conat without Agda's coinduction features. Also, the way I am using to encode conat comes from traditional constructive mathematics. However, it would be nice to do everything I did with native support for coinduction/corecursion. Perhaps you can suggest an idiom to expresses what you need as a feature request. But I believe it should be possible, without additional support, to show that my conat is equivalent (and hence equal) to your conat, no? |
What I've found missing in Agda is the support for with abstraction and path-patterns (cc agda/agda#2461) |
Can you be more precise in what you would like to be able to write, with a concrete example involving conat? |
You can see my unfinished proof in https://github.com/Agda-zh/cubical/tree/conat-bisi |
Thanks. But your link is broken. |
Complete explanationA little prelude to this comment, just plain coproduct and product: open import Agda.Builtin.Sigma
_×_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ-max ℓ ℓ')
A × B = Σ A (λ _ → B)
data _⊎_ {ℓ ℓ'} (P : Set ℓ) (Q : Set ℓ') : Set (ℓ-max ℓ ℓ') where
inl : P → P ⊎ Q
inr : Q → P ⊎ Q I have a conat which is a coinductive wrapper on a record Conat : Set
Prev = Unit ⊎ Conat
record Conat where
coinductive
constructor conat
field prev : Prev
pattern zero = inl tt
pattern suc n = inr n
succ : Conat → Conat
prev (succ a) = inr a I'm trying to define a bisimulation relation on it, so I came up with this definition: module Bisimulation where
data _≠0 : (a : Prev) → Set where
no0 : ∀ {a} → suc a ≠0
pred : Prev → Conat
prev (pred zero ) = zero
prev (pred (suc x)) = prev x
-- Maybe this definition is not good enough?
record _~_ (a b : Conat) : Set where
coinductive
constructor intro
field proof : (a ≡ b) ⊎ ((pred (prev a) ~ pred (prev b)) × (prev a ≠0 × prev b ≠0))
open _~_ With identity : ∀ n → n ~ n
proof (identity n) with prev n
... | zero = inl refl
... | suc x = inr (identity (pred (suc x)) , no0 , no0) And I failed to define a bisim : ∀ {a b} → a ~ b → a ≡ b Because with abstraction cannot be used with path patterns, I can't use a seem-to-better definition like the one in -- Fake code, rejected because copattern is not supported in path patterns
proof (bisim {a} {b} p i) with proof p I tried to use with abstraction without path types (and of course, without copatterns), and I come up with a code like this (have to pattern match on bisim {a} {b} p with prev a | prev b | proof p
... | _ | _ | inl x = x
... | suc x | suc y | suc (bi , no0 , no0) = cong {!succ !} (bisim bi) Agda rejects the hole because Since I tried a little to use the eq-reasoning style proving, as in the unfinished branch, and it causes termination error. I have no idea about how to prove this. I hope I'm making stupid mistake here. |
@ice1000 Here's a way to do bisimulation for You can pull that commit into your branch if you like it, so we can stay on this PR. (or is there a better way?) I defined Also, IMO |
I feel like what you're doing is manually lifting the I like the new style mutual recursion so I'll refactor your code a little bit and do the rest of the work. |
This is very opinion-based and actually I was using a standalone datatype and then switched to a sigma type. I'm gonna keep this anyway. |
It is a fairly simple corollary of the fact the |
I don't think it's possible to extract a general definition of bisimulation as a proposition, see our discussion above (we've come up with more than three definitions, each of them sounds amazingly reasonable but they all fail due to some mysteries until Mr. @gallais@'s final version based on |
IIUC defining bisimulation on a coinductive structure requires you to "look into" the structure, which means you'll need to define a specific bisimulation for every coinductive structures. If you have any idea about defining such general bisimulation proposition (except creating the definition by reflection) please explain. |
I think @potato4444 means that bisimulation satisfies |
Proved that bisimulation is a prop. |
Please take a look @mortberg@ |
Addressed all comments. |
It seems like you forgot to include |
Added the file. |
Thanks, I'm fine with merging as soon as Travis is happy |
Thanks to everyone who contributed to this PR! |
CI is very happy now. |
@Saizan Can you merge if you have no more comments? |
Add conat, prove that mugen plus one equals mugen :)