feature: allow non-unital theories to be meaningfully non-unital#1178
feature: allow non-unital theories to be meaningfully non-unital#1178tslil-topos wants to merge 1 commit intomainfrom
Conversation
1ff62dc to
c3e5ee2
Compare
Before this change the blanket impl `impl<Kind: DblTheoryKind>
VDCWithComposites for ModalDblTheory<Kind>` would always give a unit
pro-arrow to every object, which is semantically too powerful.
In order to allow _particular_ modal double theories to specify which
objects ("types") are unital ("categorical" in their semantics) we
need to track some state on the struct.
The approach taken in this change is to extend the API of
DblTheoryKind minimally with `type TypesWithUnits<X>: Default;` and
```rust
fn has_unit<Ob: Eq + Hash>(
unitful_types: &Self::TypesWithUnits<Ob>,
ob: &Ob,
) -> bool;
```
In the case of Unital theories TypesWithUnits is `()`, but for
NonUnital it's `HashSet`. In the latter case ModalDblTheory grows `pub
fn add_unit(&mut self, ob_type: ModalObType)`.
c3e5ee2 to
71cc9ef
Compare
epatters
left a comment
There was a problem hiding this comment.
Thanks for giving this a go!
I confess that when writing the RFC I didn't think through how units should be handled in the non-unital case since in all of our currently envisaged examples, none of the objects will have units. And in light of my comment below, there is some subtlety in handling the situation where some-but-not-all objects are specified to have units.
Unless you strongly feel otherwise, since we don't yet have any motivating examples, I'd recommend that we not yet go down this path, and for now make the simplifying assumption that non-unital theories have no chosen units.
| /// In a non-unital theory, object types do not automatically have unit | ||
| /// proarrows (hom types). This method explicitly grants one. | ||
| pub fn add_unit(&mut self, ob_type: ModalObType) { | ||
| self._unitful_types.insert(ob_type); |
There was a problem hiding this comment.
While this probably isn't legibly documented anywhere (sorry, we've got some mathematical debt to clear here), the modalities (double monads or comonads) on the theory are assumed to be strict, i.e., to preserve loose composites and units. In that case, this check isn't sufficient since if \id_{Tx} = T \id_x (GitHub math is laughably broken).
|
|
||
| impl DblTheoryKind for NonUnital { | ||
| type Wrap<T> = Option<T>; | ||
| type TypesWithUnits<X> = HashSet<X>; |
There was a problem hiding this comment.
It feels strange to me bake this assumption about how units would be checked into NonUnital, independent of the model implementation itself.
|
Thanks for the review @epatters ! sorry, i'm not sure i understand what you mean here. At the risk of saying something you well understand for the exercise of my trying to reason through your intentions: what's really going on in this change is that the VDCWithComposites implementation would always formally supply units for objects, regardless of the theory type. The code currently has I'm not sure what the intention of the code was, or what we want the final form to be, but looking around it's currently sufficient (and i thought mathematically correct) to make that "always formally add units" step conditional on something and that something (i thought) could only be the subset of objects for which we want units---is there some more general condition that you had in mind? I'm not sure i see how this interferes with modalities, even if they are strict. There are no lawfulness checks that i can see --- the code constructs Maybe the best approach here is to rethink this path from ModalDblTheory to DblTheory in the non-unital case in specific, and avoid piling on more and more concessions for this approach. I leave it to you to decide how, if at all, you want a change like this to be shaped (maybe we change non-unital to mean "no units ever at" at the type level (eg For now, as much as it is theoretically incorrect, i think i can continue on #1167 for example without having this change in there and just pretend that the units are never added. |
Before this change the blanket impl
impl<Kind: DblTheoryKind> VDCWithComposites for ModalDblTheory<Kind>would always give a unit pro-arrow to every object, which is semantically too powerful.In order to allow particular modal double theories to specify which objects ("types") are unital ("categorical" in their semantics) we need to track some state on the struct.
The approach taken in this change is to extend the API of DblTheoryKind minimally with
type TypesWithUnits<X>: Default;andIn the case of Unital theories
TypesWithUnits<X>is(), but for NonUnital it'sHashSet. In the latter case ModalDblTheory growspub fn add_unit(&mut self, ob_type: ModalObType).This change is needed to do #1167 and #1162 correctly