@@ -407,6 +407,9 @@ module Lattices = struct
407
407
| Linearity , (area , _ ) -> area, r
408
408
| Uniqueness , (_ , () ) -> r, ()
409
409
410
+ let set_areality : type a0 a1. a1 -> a0 comonadic_with -> a1 comonadic_with =
411
+ fun r (_ , lin ) -> r, lin
412
+
410
413
let proj_obj : type t r. (t, r) axis -> t obj -> r obj =
411
414
fun ax obj ->
412
415
match ax, obj with
@@ -885,13 +888,33 @@ module Lattices_mono = struct
885
888
type a b c d .
886
889
c obj -> (b , c , d ) morph -> (a , b , d ) morph -> (a , c , d ) morph option =
887
890
fun dst m0 m1 ->
891
+ let is_max c = le dst (max dst) c in
892
+ let is_min c = le dst c (min dst) in
893
+ let is_mid_max c =
894
+ let mid = src dst m0 in
895
+ le mid (max mid) c
896
+ in
897
+ let is_mid_min c =
898
+ let mid = src dst m0 in
899
+ le mid c (min mid)
900
+ in
888
901
match m0, m1 with
889
902
| Id , m -> Some m
890
903
| m , Id -> Some m
891
904
| Meet_with c0 , Meet_with c1 -> Some (Meet_with (meet dst c0 c1))
892
905
| Join_with c0 , Join_with c1 -> Some (Join_with (join dst c0 c1))
893
- | Meet_with c0 , m1 when le dst (max dst) c0 -> Some m1
894
- | Join_with c0 , m1 when le dst c0 (min dst) -> Some m1
906
+ | Imply c0 , Imply c1 -> Some (Imply (meet dst c0 c1))
907
+ | Subtract c0 , Subtract c1 -> Some (Subtract (join dst c0 c1))
908
+ | Imply c0 , Join_with c1 when le dst c0 c1 -> Some (Join_with (max dst))
909
+ | Subtract c0 , Meet_with c1 when le dst c1 c0 -> Some (Meet_with (min dst))
910
+ | Meet_with c0 , m1 when is_max c0 -> Some m1
911
+ | Join_with c0 , m1 when is_min c0 -> Some m1
912
+ | Imply c0 , m1 when is_max c0 -> Some m1
913
+ | Subtract c0 , m1 when is_min c0 -> Some m1
914
+ | m1 , Meet_with c0 when is_mid_max c0 -> Some m1
915
+ | m1 , Join_with c0 when is_mid_min c0 -> Some m1
916
+ | m1 , Imply c0 when is_mid_max c0 -> Some m1
917
+ | m1 , Subtract c0 when is_mid_min c0 -> Some m1
895
918
| Compose (f0 , f1 ), g -> (
896
919
let mid = src dst f0 in
897
920
match maybe_compose mid f1 g with
@@ -903,9 +926,9 @@ module Lattices_mono = struct
903
926
| Some m -> Some (compose dst m g1)
904
927
| None -> None )
905
928
| Proj (mid , ax ), Meet_with c ->
906
- Some (Compose (Meet_with (proj ax c), Proj (mid, ax)))
929
+ Some (compose dst (Meet_with (proj ax c)) ( Proj (mid, ax)))
907
930
| Proj (mid , ax ), Join_with c ->
908
- Some (Compose (Join_with (proj ax c), Proj (mid, ax)))
931
+ Some (compose dst (Join_with (proj ax c)) ( Proj (mid, ax)))
909
932
| Proj (_ , ax0 ), Max_with ax1 -> (
910
933
match eq_axis ax0 ax1 with None -> None | Some Refl -> Some Id )
911
934
| Proj (_ , ax0 ), Min_with ax1 -> (
@@ -952,18 +975,32 @@ module Lattices_mono = struct
952
975
Locality_as_regionality )
953
976
| Map_comonadic f , Join_with c ->
954
977
let dst0 = proj_obj Areality dst in
955
- let areality, linearity = c in
978
+ let areality = proj Areality c in
956
979
Some
957
980
(compose dst
958
- (Join_with (min_with dst Linearity linearity ))
981
+ (Join_with (set_areality (min dst0) c ))
959
982
(Map_comonadic (compose dst0 f (Join_with areality))))
960
983
| Map_comonadic f , Meet_with c ->
961
984
let dst0 = proj_obj Areality dst in
962
- let areality, linearity = c in
985
+ let areality = proj Areality c in
963
986
Some
964
987
(compose dst
965
- (Meet_with (max_with dst Linearity linearity ))
988
+ (Meet_with (set_areality (max dst0) c ))
966
989
(Map_comonadic (compose dst0 f (Meet_with areality))))
990
+ | Map_comonadic f , Imply c ->
991
+ let dst0 = proj_obj Areality dst in
992
+ let areality = proj Areality c in
993
+ Some
994
+ (compose dst
995
+ (Imply (set_areality (max dst0) c))
996
+ (Map_comonadic (compose dst0 f (Imply areality))))
997
+ | Map_comonadic f , Subtract c ->
998
+ let dst0 = proj_obj Areality dst in
999
+ let areality = proj Areality c in
1000
+ Some
1001
+ (compose dst
1002
+ (Subtract (set_areality (min dst0) c))
1003
+ (Map_comonadic (compose dst0 f (Subtract areality))))
967
1004
| Regional_to_global , Locality_as_regionality -> Some Id
968
1005
| Regional_to_global , Local_to_regional -> Some (Meet_with Locality. Global )
969
1006
| Local_to_regional , Regional_to_local -> None
0 commit comments