-
Notifications
You must be signed in to change notification settings - Fork 257
[ new ] notions of finiteness #2017
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
Conversation
Some thoughts (or queries) -
More work here (that I will be carrying out)
I am supposed to take over this and #2005, but I cannot directly push to this branch. How should I proceed ahead with this? Should I create a new PR with @laMudri's code and then work on it with reviews? I think I will start with the checklist mentioned above and ask for help on the way 🙂 cc: @JacquesCarette |
Hi! You must be Jacques' student. I'm happy to give you push access to this branch, in case that's the easiest solution. As for your points:
|
Hi, yes! Thanks for the detailed discussion and the invite to the repository! I've started working on this locally.
I don't really have an opinion here. I'll leave this up to you and other maintainers 🙂
Oh, I see. A lot of API changes before 2.0.0
What exactly is supposed to in the Propositional module? Is it supposed to have a different version of
Yes, my bad, I meant |
da6aa3a
to
7a7350e
Compare
I will also comment on the current code regarding a number of other items. |
cong : to Preserves _≈₁_ ⟶ _≈₂_ | ||
surjective : Surjective to | ||
|
||
function : Func |
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.
This is a very big change (important name, etc). I would not want to try to sneak this in to this PR.
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.
Yeah, I'd be happy to have a separate PR for this. It seemed like a bug-fix, given that all of the surrounding records have a similar definition.
Ω : ∀ p → Setoid (lsuc p) p | ||
Ω p = record | ||
{ Carrier = Set p | ||
; _≈_ = λ P Q → (P → Q) × (Q → P) |
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.
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 think Function.Equivalence
is marked for deprecation in v2.0.0; hence, the repetition?
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.
Indeed, I missed that part - well spotted!
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.
Yeah, Function.Equivalence
, Function.Injection
, &c have been pre-deprecated for a long time (since the inception of Function.Bundles
, probably). Both definitions of _⇔_
are unfortunate in that the congruence fields become entirely redundant, which is a (post hoc) justification for this much simpler (P → Q) × (Q → P)
type. As for ⇔-setoid
, maybe I'm biased by the particular use of it here, but it seems like a terrible name. It's not just some random setoid made out of the notion of equivalence; it's the setoid of propositions.
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 agree, but I don't want this to explode any more than it already has!
} | ||
} | ||
|
||
Subset : Setoid c ℓ → (p : Level) → Set (c ⊔ ℓ ⊔ lsuc p) |
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.
Surely something like these two (Subset
and FullSubset
) already exist in stdlib elsewhere? Or should, independently.
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.
There is Data.Fin.Subset
but the definition is very different.
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 names might be quite different.
FullSubset : {X : Setoid c ℓ} → Subset X 0ℓ | ||
FullSubset = record { to = λ _ → ⊤ } | ||
|
||
record EquivalenceRelation (X : Setoid c ℓ) r : Set (c ⊔ ℓ ⊔ lsuc r) where |
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'm quite sure that all the definitions from EquivalenceRelation
to include-/
do not belong in this file (or even this PR). Some of them likely already exist while others are non-trivial new items that should be in a separate PR.
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.
These are used in lemma→
and lemma←
. Should these also go in a different PR?
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 think so. It might well turn out that you'll need a preliminary PR or two to set up the groundwork for this one.
open Setoid X | ||
open EquivalenceRelation R | ||
|
||
record IsStronglyFinite (X : Setoid c ℓ) (n : ℕ) : Set (c ⊔ ℓ) where |
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.
Above these, there should be comments as to the origin of the names (with links).
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 could not find an origin for the name StronglyFinite
. There are a few references that define finite sets or a notion of finiteness but I could not see any of them using StronglyFinite
in particular -
- Dependently typed programming with finite sets
- Brent's Yorgey's PhD thesis
- Towards Certifiable Implementation of Graph Transformation via Relation Categories
Which one should I cite? Or should it be the GitHub comment where StronglyFinite
popped up for the first time?
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.
Probably FinitelyEnumerable
is closer to what's used out there.
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.
Loking at the references, Dependently typed programming with finite sets introduces "finitely enumerable" for the first time. It classifies the notion of finiteness using some other references -
Intuitionistic frameworks give rise to a rich variety of notions of finiteness that collapse classically. In [8], [5] and [14], the author describe various concepts of finiteness and their interrrelation. According to their classification, this paper focuses on the strongest notion of finiteness, namely, finitely enumerable (listable) sets.
[8] talks about "Enumerated" sets which I found to be the closest here.
A set A will be said to be enumerated, or simply finite, noted A ε F when there is a list of all its elements. We call such a list an enumeration of A.
I also found https://github.com/agda/agda-finite-prover, which looks somewhat relevant 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.
Enumerated
is another excellent name.
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.
Spiwack and Coqand unfortunately use rather vague wording in our definition of interest:
Definition
A set A will be said to be enumerated, or simply finite, noted A ε 𝓕 when there
is a list of all its elements. We call such a list an enumeration of A.
I think this means ∃xs : List A. ∀x : A. x ∈ xs, which allows for duplicates in the list. This is equivalent to FinitelyEnumerable
from this PR:
Proof
(enumerated → FinitelyEnumerable
): Let size
be the length of the list xs. The function is given by lookup
. This is surjective by the fact that for every x, we have an e : x ∈ xs, and we can take the index of e, which lookup
maps to x.
(FinitelyEnumerable
→ enumerated): The list is given by the tabulation of the surjective function. Given an x : A, it is in the tabulation by surjectivity.
I think this discussion, if anything, motivates the name StronglyFinite
. It is stronger than all of these other commonly studied notions of finiteness, and is perhaps the strongest notion we could reasonably call “finiteness”. Definitely, if we had univalence, then any property stronger than “∃ n
. it's equivalent to Fin n
” precludes the type Fin n
for some n
. If StronglyFinite
is strictly stronger than the other notions of finiteness being discussed, we could ask whether it's worth having in the library at all. I think it is. For example, when people talk about categories whose objects are finite sets, I think they nearly always mean strongly finite sets. Also, I can imagine that strong finiteness is too trivial to mention in pen-and-paper mathematics, because you could just say Fin n instead, but I think people genuinely do want to talk about sets which are strongly finite in Agda.
Anyway, it's important that we get these things right, so thanks for doing the research. I don't have a good enough intuition on the three later (weaker) definitions from the same paper, but hopefully one of them is equivalent to being subfinitely enumerable (if I had to put money on it, I'd go with bounded size, because it seems to have similar properties). I guess it would be good to have all of these list-based definitions in the library too, connected with the appropriate equivalence/inclusion proofs to the definitions already in this PR. It would help get rid of some definitions without proofs.
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 certainly very happy to stick to StronglyFinite
!
size : ℕ | ||
srj : Surjection (≡.setoid (Fin size)) X | ||
|
||
record SubFinitelyEnumerable (X : Setoid c ℓ) c′ ℓ′ |
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 'source literature' here is silly with its names, and this is copied here.
InjectsIntoFinitelyEnumerable
? And then SurjectionFromFinitelyEnumerable
?
In this case, open import Data.Fin
open import Relation.Binary.PropositionalEquality as ≡
test : ∀ n → ≡.setoid (Fin n) ≡ ≡.setoid (Fin _)
test n = refl |
1d7a0f0
to
8efb395
Compare
I think it would be better to keep this PR intact and create small subset PRs. I have created #2022 to add the relevant finiteness records by picking up the first commit. |
I think it was right to turn #2022 back to DRAFT, but probably a mistake on my part to leave comments there, rather than a more substantial review of the material here, esp. eg the discussion of Related and/or candidate for deprecation in the course of this programme: |
We're also closing this one, for now, in favour of project issue #2511 as it's been hanging idle for too long and still requires a lot of work. |
This PR contains a rough draft of some definitions of constructively well behaved notions of finiteness for setoids, based on this math.se answer. Included are the proofs that the two definitions of subfinitely enumerable are logically equivalent (
lemma→
andlemma←
). It is a fairly direct transcription, perhaps meaning that we miss out on idiomatic uses of lists rather thanFin
.Clear problems to be resolved before this is merged:
Finite
module.SubFinitelyEnumerable
andSubfinitelyEnumerable
differ only in case (analogous to the presence/absence of a hyphen in the reference answer).lemma→
,lemma←
inj
andsrj
fields should not have abbreviated names._[_]
, has a name which might cause clashes. I don't use it here, but I thought I'd include it together with the inverse image_[_]⁻¹
. These two should be named as a pair._/_
, might also clash.Subset
andEquivalenceRelation
are conceptually related, but are named and implemented completely differently. We should think carefully about how we want to deal in general with predicates/relations which respect setoid equality.R
is a bit gnarly, with its 5-place iterated Σ-type. I'm following the reference answer here, but maybe it (together with the resulting quotient) could be defined in a more symmetric way, reflecting the symmetry of the pushout construction being performed.Fin
, so maybe the whole development could/should be generalised to arbitrary cardinalities.Related PR: #2005
cc @JacquesCarette @Sofia-Insa