-
Notifications
You must be signed in to change notification settings - Fork 260
Attempt at the INT construction #2891
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
base: master
Are you sure you want to change the base?
Conversation
f0fafe4 to
5087388
Compare
| record _≃_ (i j : ℤ) : Set where | ||
| constructor mk≃ | ||
| field | ||
| eq : ℤ.minuend i ℕ.+ ℤ.subtrahend j ≡ ℤ.minuend j ℕ.+ ℤ.subtrahend i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First observation from Properties: use of sym to flip rewrites in the RHS of such equations... so suggest instead
| eq : ℤ.minuend i ℕ.+ ℤ.subtrahend j ≡ ℤ.minuend j ℕ.+ ℤ.subtrahend i | |
| eq : ℤ.minuend i ℕ.+ ℤ.subtrahend j ≡ ℤ.subtrahend i ℕ.+ ℤ.minuend j |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I did it this way was so that reflexivity is exactly refl. But you're right, that doesn't seem to be worth the tradeoff
| 1ℤ : ℤ | ||
| 1ℤ = 1 ⊖ 0 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also:
| 1ℤ : ℤ | |
| 1ℤ = 1 ⊖ 0 | |
| 1ℤ : ℤ | |
| 1ℤ = 1 ⊖ 0 | |
| -1ℤ : ℤ | |
| -1ℤ = 0 ⊖ 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy enough, but does it pass the Fairbairn threshold? -1ℤ = - 1ℤ, after all
| infix 8 ⁻_ ⁺_ | ||
|
|
||
| ⁺_ : ℕ → ℤ | ||
| ⁺ n = n ⊖ 0 | ||
|
|
||
| ⁻_ : ℕ → ℤ | ||
| ⁻ n = 0 ⊖ n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ⁻ symbol is in particular quite hard to discern as distinct form -. Would it be better to use Sign here (and reimplement the corresponding signAbs/SignAbs plumbing)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly got annoyed at Agda not being able to tell if a section (x +_) was _+_ x or x (+_), so I wanted different symbols for them... the superscript-minus symbol is used in APL's number syntax for a negative, and that's what inspired the use of these here. I'm not attached to them, though.
| a ℕ.% n ℕ.+ 0 ≡⟨ ℕ.+-identityʳ (a ℕ.% n) ⟩ | ||
| a ℕ.% n ≡⟨ ℕ.m∸n+n≡m p ⟨ | ||
| a ℕ.% n ℕ.∸ b ℕ.% n ℕ.+ b ℕ.% n ∎ | ||
| ... | no b%n≰a%n = ≃-trans property′ $ mk≃ $ begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Tempting to use a (Semi)Ring solver here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do those work well when I'm using monus? Not that I ever really can manage to get them to work well for me...
| open import Data.Product.Base | ||
| open import Function.Base | ||
| open import Relation.Binary.PropositionalEquality | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it easier to derive each of these properties from the 'adjoint equivalence'/'graph relation' forms:
fromINT i ≡ j → i ≃ toINT j
i ≃ toINT j → fromINT i ≡ j(plus, perhaps, some additional lemmas to 'explain' these two graph relations)?
(I think even the congs follow from this, but I'd need to check that...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second one is easy enough, it's hidden in my surjective proof. I'll have a go at the first one later.
As weak evidence that the congs don't follow from this: they're separate fields in the IsInverse structure in Function.Structures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No proper review as yet, but some suggestions for consideration.
Also I need to look again at Landau.
Closes #2890 (eventually)
The proofs, while purely algebraic, are often very tedious, especially
*-cong.I've got basic arithmetic, ordering with addition, and divmod working!