@@ -158,7 +158,7 @@ class :class:`Groups` can be imported and is fully functional without
158
158
True
159
159
160
160
For the former idiom to work, and with the current implementation of
161
- axioms, the class :class:`FiniteGrphs ` needs to be aware of the base
161
+ axioms, the class :class:`FiniteGroups ` needs to be aware of the base
162
162
category class (here, :class:`Groups`) and of the axiom (here,
163
163
``Finite``)::
164
164
@@ -399,22 +399,47 @@ class `D_S` should be the child of a single class `D_{S'}` where `S'`
399
399
Discussion of the design
400
400
^^^^^^^^^^^^^^^^^^^^^^^^
401
401
402
+ Asymmetry
403
+ ~~~~~~~~~
404
+
405
+ As we have seen at the beginning of this section this design
406
+ introduces an asymmetry. It's not so bad in practice as in most
407
+ practical cases, we want to work incrementally. It's for example more
408
+ natural to describe :class:`FiniteFields` as :class:`Fields` with the
409
+ axiom ``Finite`` rather than :class:`Magmas` and
410
+ :class:`AdditiveMagmas` with all (or at least sufficiently many) of
411
+ the following axioms (not counting ``Distributive`` which is not yet
412
+ implemented)::
413
+
414
+ sage: Fields().axioms()
415
+ frozenset(['Division', 'AdditiveUnital', 'NoZeroDivisors', 'Commutative',
416
+ 'AdditiveInverse', 'AdditiveAssociative', 'Unital',
417
+ 'AdditiveCommutative', 'Associative'])
418
+
419
+ The main limitation is that the infrastructure currently imposes to be
420
+ incremental by steps of one axiom.
421
+
422
+ In practice, among the roughly 60 categories with axioms that are
423
+ currently implemented in Sage, most admitted a (rather) natural choice
424
+ of a base category and single axiom to add. For example, one usually
425
+ thinks more naturally of a monoid as a semigroup which is unital
426
+ rather than as a unital magma which is associative. Only in a few
427
+ cases is a choice made that feels mathematically arbitrary. This is
428
+ essentially in the chain of nested classes
429
+ :class:`DistributiveMagmasAndAdditiveMagmas.AdditiveAssociative.AdditiveCommutative.AdditiveUnital`.
430
+
402
431
Placeholder classes
403
432
~~~~~~~~~~~~~~~~~~~
404
433
405
- Given that we can only remove one axiom at a time when going up the
406
- tree, we need to create some category classes that are just
407
- placeholders. See for example the chain of nested classes
434
+ Given that we can only add a single axiom at a time when implementing
435
+ a :class:`CategoryWithAxiom`, we need to create a few category classes
436
+ that are just placeholders. See for example the chain of nested
437
+ classes
408
438
:class:`DistributiveMagmasAndAdditiveMagmas.AdditiveAssociative.AdditiveCommutative.AdditiveUnital`.
409
439
410
- Asymmetry
411
- ~~~~~~~~~
412
-
413
- As we have seen at the beginning of this section this design
414
- introduces an asymmetry. It's not so bad in practice since, more often
415
- than not, one of the link is more natural than the other: a monoid is
416
- usually defined as a unital monoid rather than as a unital magma which
417
- is associative.
440
+ Yet, this is well within the scope of the axiom infrastructure which
441
+ is to go from a potentially exponential number of placeholder
442
+ categories to just a couple.
418
443
419
444
Mismatch between the tree of nested classes and the hierarchy of categories
420
445
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -434,14 +459,43 @@ class `D_S` should be the child of a single class `D_{S'}` where `S'`
434
459
Flexibility
435
460
~~~~~~~~~~~
436
461
437
-
438
462
This design also brings in quite some flexibility, with the
439
- possibility to support features such as::
463
+ possibility to support features such as defining new axioms depending
464
+ on other axioms. See below.
465
+
466
+ Limitations
467
+ ~~~~~~~~~~~
468
+
469
+ As a small variant of what we have seen above, defining the
470
+ ``Distributive`` axiom within this infrastructure would require to
471
+ implement a placeholder category ``MagmasAndAdditiveMagmas``. What is
472
+ more annoying is that Sage can't currently be taught that
473
+ ``MagmasAndAdditiveMagmas`` is the join of :class:`Magmas` and
474
+ :class:`AdditiveMagmas`, which is why ``MagmasAndAdditiveMagmas``
475
+ together with its ``Distributive`` axiom are not yet implemented.
476
+
477
+ .. TODO::
478
+
479
+ Make :meth:`Category.join` more powerful, to handle such
480
+ joins. Another typical use case is::
481
+
482
+ sage: C = Algebras(QQ) & Coalgebras(QQ); C # todo: not implemented
483
+ Category of bialgebras
484
+
485
+ sage: C.Hopf() # todo: not implemented
486
+ Category of hopf algebras
440
487
441
- - Defining new axioms within a category with axiom. See for example
442
- :class:`Magmas.Unital.Inverse`.
488
+ One could also have the category :class:`Bimodules` be the join of
489
+ :class:`LeftModules` and :class:`RightModules` with an axiom
490
+ stating the compatibility between the left and right action.
491
+
492
+ This will require some thought on appropriate idioms and
493
+ algorithms. Potential directions include refactoring the whole
494
+ implementation with a database mapping sets of axioms to
495
+ categories together with other deduction rules, or just adding
496
+ some hook or registration process to specify what the join of two
497
+ categories is.
443
498
444
- - ...
445
499
446
500
Axioms defined upon other axioms
447
501
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -522,8 +576,9 @@ class `D_S` should be the child of a single class `D_{S'}` where `S'`
522
576
523
577
.. WARNING::
524
578
525
- In some situations this idiom is inapplicable as it would lead to
526
- an infinite recursion. This is the purpose of the next section.
579
+ In some situations this idiom is inapplicable as it would require
580
+ to implement two classes for the same category. This is the
581
+ purpose of the next section.
527
582
528
583
Special case
529
584
~~~~~~~~~~~~
@@ -577,7 +632,9 @@ class `D_S` should be the child of a single class `D_{S'}` where `S'`
577
632
mathematical facts specifying non trivial inclusion relations between
578
633
categories are implemented elsewhere in the various
579
634
``extra_super_categories`` methods of axiom categories and covariant
580
- functorial constructions.
635
+ functorial constructions. Besides, it gives a natural spot to document
636
+ and test the modeling of the mathematical fact.
637
+
581
638
582
639
In general, if several categories ``C1s(), C2s(), ... are mapped to
583
640
the same category when applying some axiom ``A`` (that is ``C1s().A()
@@ -709,8 +766,9 @@ class `D_S` should be the child of a single class `D_{S'}` where `S'`
709
766
710
767
- A category can only implement an axiom if this axiom is defined by
711
768
some super category. The code has not been systematically checked to
712
- work if two super categories define the same axiom. You are welcome
713
- to try, at your own risk :-)
769
+ support having two super categories defining the same axiom (which
770
+ should of course have the same semantic). You are welcome to try, at
771
+ your own risk :-)
714
772
715
773
- When a category defines an axiom or functorial construction ``A``,
716
774
this fixes the semantic of ``A`` for all the subcategories. In
@@ -844,6 +902,9 @@ class ``Sets.Finite``), or in a separate file (typically in a class
844
902
Description of the algorithmic
845
903
==============================
846
904
905
+ Computing joins
906
+ ---------------
907
+
847
908
The workhorse of the axiom infrastructure is the algorithm for
848
909
computing the join `J` of a set `C_1,\dots,C_k` of categories (see
849
910
:meth:`Category.join`). Formally, `J` is defined as the largest
@@ -864,10 +925,10 @@ class ``Sets.Finite``), or in a separate file (typically in a class
864
925
subcategory of ``C``.
865
926
866
927
As usual in such closure computations, the result does not depend on
867
- the order of execution. Futhermore, assuming that there is a finite
868
- number of axioms defined in the code, and given that adding an axiom
869
- is an idempotent and regressive operation, the process is guaranteed
870
- to stop in a finite number of steps .
928
+ the order of execution. Futhermore, given that adding an axiom is an
929
+ idempotent and regressive operation, the process is guaranteed to stop
930
+ in a number of steps which is bounded by the number of super
931
+ categories of `J`. In particular, it is a finite process .
871
932
872
933
.. TODO::
873
934
@@ -878,16 +939,73 @@ class ``Sets.Finite``), or in a separate file (typically in a class
878
939
execution. Note that this situation violates the specifications
879
940
since C1.A() is supposed to be a subcategory of C2.A(), ... so we
880
941
would have an infinite increasing chain of constructible
881
- categories. There remains to argue that any infinite execution of
882
- the algorithm would give rise to such an infinite sequence.
942
+ categories.
943
+
944
+ It's reasonnable to assume that there is a finite number of axioms
945
+ defined in the code. There remains to use this assumptiono to
946
+ argue that any infinite execution of the algorithm would give rise
947
+ to such an infinite sequence.
948
+
949
+ Adding an axiom
950
+ ---------------
951
+
952
+ Let ``Cs`` be a category and ``A`` an axiom defined for this
953
+ category. To compute ``Cs().A()``, there are two cases.
954
+
955
+ Adding an axiom ``A`` to a category ``Cs()`` not implementing it
956
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
957
+
958
+ In this case, ``Cs().A()`` returns the join of:
959
+
960
+ - ``Cs()``
961
+ - ``Bs().A()`` for every super category ``Bs()`` of ``Cs()``
962
+ - the categories appearing in ``Cs().A_extra_super_categories()``
963
+
964
+ This is a highly recursive process. In fact, as such, it would run
965
+ right away into an infinite loop! Indeed, the join of ``Cs()`` with
966
+ ``Bs().A()`` would trigger the construction of ``Cs().A()`` and
967
+ reciprocally. To avoid this, the :meth:`Category.join` method itself
968
+ does not use :meth:`Category._with_axiom` to add axioms, but its
969
+ sister :meth:`Category._with_axiom_as_tuple`; the latter builds a
970
+ tuple of categories that should be joined together but leaves the
971
+ computation of the join to its caller the master join calculation.
972
+
973
+ Adding an axiom ``A`` to a category ``Cs()`` implementing it
974
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
975
+
976
+ In this case ``Cs().A()`` simply constructs an instance `D` of
977
+ ``Cs.A`` which models the desired category. The non trivial part is
978
+ the construction of the the super categories of `D`. Very much like
979
+ above, this includes:
980
+
981
+ - ``Cs()``
982
+ - ``Bs().A()`` for every super category ``Bs()`` of ``Cs()``
983
+ - the categories appearing in ``D.extra_super_categories()``
984
+
985
+ This by itself may not be sufficient, due in particular to deduction
986
+ rules. On may for example discover a new axiom ``A1`` satisfied by
987
+ `D`, imposing to add ``A1`` to all of the above categories. Therefore
988
+ the super categories are computed as the join of the above categories.
989
+ Up to one twist: as is, the computation of this join would trigger
990
+ recursively a recalculation of ``Cs().A()``! To avoid this,
991
+ :meth:`Category.join` is given an optional argument to specify that
992
+ the axiom ``A`` should *not* be applied to ``Cs()``.
993
+
994
+ Examples where things go wrong if we are not careful
995
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
996
+
997
+ As we have seen, this is a highly recursive process. In particular,
998
+ some appropriate steps need to be taken to not run in an infinite
999
+ recursion, in particular in case of deduction rule.
1000
+
1001
+ .. TODO:: Examples
883
1002
884
- .. TODO:: Describe the algorithm for adding axioms
1003
+ Conclusion
1004
+ ==========
885
1005
886
- This is a highly recursive process. In particular, some appropriate
887
- steps need to be taken to not run in an infinite recursion, in
888
- particular in case of deduction rule.
1006
+ This is the end of the axioms documentation. Congratulations on
1007
+ having read that far!
889
1008
890
- .. TODO:: Example where things will go wrong if we are not careful
891
1009
892
1010
Tests
893
1011
=====
0 commit comments