@@ -913,13 +913,13 @@ module Lattices_mono = struct
913
913
module Axis = struct
914
914
type ('t, 'r) t =
915
915
| Areality : ('a comonadic_with , 'a ) t
916
- | Linearity : ('areality comonadic_with , Linearity .t ) t
917
- | Portability : ('areality comonadic_with , Portability .t ) t
918
916
| Yielding : ('areality comonadic_with , Yielding .t ) t
917
+ | Linearity : ('areality comonadic_with , Linearity .t ) t
919
918
| Statefulness : ('areality comonadic_with , Statefulness .t ) t
919
+ | Portability : ('areality comonadic_with , Portability .t ) t
920
920
| Uniqueness : (Monadic_op .t , Uniqueness_op .t ) t
921
- | Contention : (Monadic_op .t , Contention_op .t ) t
922
921
| Visibility : (Monadic_op .t , Visibility_op .t ) t
922
+ | Contention : (Monadic_op .t , Contention_op .t ) t
923
923
924
924
let print : type p r. _ -> (p, r) t -> unit =
925
925
fun ppf -> function
@@ -960,7 +960,7 @@ module Lattices_mono = struct
960
960
| Contention -> t.contention
961
961
| Visibility -> t.visibility
962
962
963
- let update : type p r. (p, r) t -> r -> p -> p =
963
+ let set : type p r. (p, r) t -> r -> p -> p =
964
964
fun ax r t ->
965
965
match ax with
966
966
| Areality -> { t with areality = r }
@@ -1319,9 +1319,9 @@ module Lattices_mono = struct
1319
1319
| Visibility. Read -> Statefulness. Observing
1320
1320
| Visibility. Read_write -> Statefulness. Stateful
1321
1321
1322
- let min_with dst ax a = Axis. update ax a (min dst)
1322
+ let min_with dst ax a = Axis. set ax a (min dst)
1323
1323
1324
- let max_with dst ax a = Axis. update ax a (max dst)
1324
+ let max_with dst ax a = Axis. set ax a (max dst)
1325
1325
1326
1326
let monadic_to_comonadic_min :
1327
1327
type a . a comonadic_with obj -> Monadic_op. t -> a comonadic_with =
@@ -2078,9 +2078,9 @@ module BiHeyting_Product (L : BiHeyting) = struct
2078
2078
2079
2079
type 'a axis = (t , 'a ) Axis .t
2080
2080
2081
- let min_with ax c = Axis. update ax c min
2081
+ let min_with ax c = Axis. set ax c min
2082
2082
2083
- let max_with ax c = Axis. update ax c max
2083
+ let max_with ax c = Axis. set ax c max
2084
2084
2085
2085
let min_axis ax = Axis. proj ax min
2086
2086
@@ -2349,10 +2349,11 @@ module Value_with (Areality : Areality) = struct
2349
2349
2350
2350
let all =
2351
2351
[ P (Comonadic Areality );
2352
- P (Monadic Uniqueness );
2353
2352
P (Comonadic Linearity );
2354
- P (Monadic Contention );
2353
+ P (Monadic Uniqueness );
2355
2354
P (Comonadic Portability );
2355
+ P (Monadic Contention );
2356
+ P (Comonadic Yielding );
2356
2357
P (Comonadic Statefulness );
2357
2358
P (Monadic Visibility ) ]
2358
2359
end
@@ -3023,31 +3024,19 @@ module Modality = struct
3023
3024
Error
3024
3025
(Error (ax, { left = Join_with left; right = Join_with right }))
3025
3026
3026
- let compose : type a. a axis -> a raw -> t -> t =
3027
- fun ax a t ->
3028
- match a, t with
3029
- | Join_with c0 , Join_const c ->
3030
- Join_const (Mode.Const. join (Mode.Const. min_with ax c0) c)
3031
- | Meet_with _ , Join_const _ -> assert false
3032
-
3033
3027
let concat ~then_ t =
3034
3028
match then_, t with
3035
3029
| Join_const c0 , Join_const c1 -> Join_const (Mode.Const. join c0 c1)
3036
3030
3037
3031
let apply : type l r. t -> (l * r) Mode.t -> (l * r) Mode.t =
3038
3032
fun t x -> match t with Join_const c -> Mode. join_const c x
3039
3033
3040
- let to_list = function
3041
- | Join_const c ->
3042
- [ (let ax : _ Axis.t = Uniqueness in
3043
- Atom (Monadic ax, Join_with (Axis. proj ax c)));
3044
- (let ax : _ Axis.t = Contention in
3045
- Atom (Monadic ax, Join_with (Axis. proj ax c)));
3046
- (let ax : _ Axis.t = Visibility in
3047
- Atom (Monadic ax, Join_with (Axis. proj ax c))) ]
3034
+ let proj ax (Join_const c ) = Join_with (Axis. proj ax c)
3048
3035
3049
- let proj ax = function
3050
- | Join_const c -> Atom (Monadic ax, Join_with (Axis. proj ax c))
3036
+ let set ax a (Join_const c ) =
3037
+ match a with
3038
+ | Join_with a -> Join_const (Axis. set ax a c)
3039
+ | Meet_with _ -> assert false
3051
3040
3052
3041
let print ppf = function
3053
3042
| Join_const c -> Format. fprintf ppf " join_const(%a)" Mode.Const. print c
@@ -3178,35 +3167,19 @@ module Modality = struct
3178
3167
Error
3179
3168
(Error (ax, { left = Meet_with left; right = Meet_with right }))
3180
3169
3181
- let compose : type a. a axis -> a raw -> t -> t =
3182
- fun ax a t ->
3183
- match a, t with
3184
- | Meet_with c0 , Meet_const c ->
3185
- Meet_const (Mode.Const. meet (Mode.Const. max_with ax c0) c)
3186
- | Join_with _ , Meet_const _ -> assert false
3187
-
3188
3170
let concat ~then_ t =
3189
3171
match then_, t with
3190
3172
| Meet_const c0 , Meet_const c1 -> Meet_const (Mode.Const. meet c0 c1)
3191
3173
3192
3174
let apply : type l r. t -> (l * r) Mode.t -> (l * r) Mode.t =
3193
3175
fun t x -> match t with Meet_const c -> Mode. meet_const c x
3194
3176
3195
- let to_list = function
3196
- | Meet_const c ->
3197
- [ (let ax : _ Axis.t = Areality in
3198
- Atom (Comonadic ax, Meet_with (Axis. proj ax c)));
3199
- (let ax : _ Axis.t = Linearity in
3200
- Atom (Comonadic ax, Meet_with (Axis. proj ax c)));
3201
- (let ax : _ Axis.t = Portability in
3202
- Atom (Comonadic ax, Meet_with (Axis. proj ax c)));
3203
- (let ax : _ Axis.t = Yielding in
3204
- Atom (Comonadic ax, Meet_with (Axis. proj ax c)));
3205
- (let ax : _ Axis.t = Statefulness in
3206
- Atom (Comonadic ax, Meet_with (Axis. proj ax c))) ]
3207
-
3208
- let proj ax = function
3209
- | Meet_const c -> Atom (Comonadic ax, Meet_with (Axis. proj ax c))
3177
+ let proj ax (Meet_const c ) = Meet_with (Axis. proj ax c)
3178
+
3179
+ let set ax a (Meet_const c ) =
3180
+ match a with
3181
+ | Meet_with a -> Meet_const (Axis. set ax a c)
3182
+ | Join_with _ -> assert false
3210
3183
3211
3184
let print ppf = function
3212
3185
| Meet_const c -> Format. fprintf ppf " meet_const(%a)" Mode.Const. print c
@@ -3342,33 +3315,35 @@ module Modality = struct
3342
3315
let comonadic = Comonadic. apply t.comonadic comonadic in
3343
3316
{ monadic; comonadic }
3344
3317
3345
- let compose ~then_ :(Atom (ax , a )) t =
3346
- match ax with
3347
- | Monadic ax ->
3348
- let monadic = Monadic. compose ax a t.monadic in
3349
- { t with monadic }
3350
- | Comonadic ax ->
3351
- let comonadic = Comonadic. compose ax a t.comonadic in
3352
- { t with comonadic }
3353
-
3354
3318
let concat ~then_ t =
3355
3319
let monadic = Monadic. concat ~then_: then_.monadic t.monadic in
3356
3320
let comonadic = Comonadic. concat ~then_: then_.comonadic t.comonadic in
3357
3321
{ monadic; comonadic }
3358
3322
3359
- let of_list = List. fold_left (fun m atom -> compose m ~then_: atom) id
3360
-
3361
- let singleton a = compose ~then_: a id
3362
-
3363
- let to_list { monadic; comonadic } =
3364
- Comonadic. to_list comonadic @ Monadic. to_list monadic
3365
-
3366
3323
let proj (type a d0 d1 ) (ax : (a, d0, d1) Value.Axis.t )
3367
3324
{ monadic; comonadic } =
3368
3325
match ax with
3369
3326
| Monadic ax -> Monadic. proj ax monadic
3370
3327
| Comonadic ax -> Comonadic. proj ax comonadic
3371
3328
3329
+ let set (type a d0 d1 ) (ax : (a, d0, d1) Value.Axis.t ) (a : a raw )
3330
+ { monadic; comonadic } =
3331
+ match ax with
3332
+ | Monadic ax ->
3333
+ let monadic = Monadic. set ax a monadic in
3334
+ { monadic; comonadic }
3335
+ | Comonadic ax ->
3336
+ let comonadic = Comonadic. set ax a comonadic in
3337
+ { monadic; comonadic }
3338
+
3339
+ let diff t0 t1 =
3340
+ List. filter_map
3341
+ (fun (Value.Axis. P ax ) ->
3342
+ let a0 = proj ax t0 in
3343
+ let a1 = proj ax t1 in
3344
+ if a0 = a1 then None else Some (Atom (ax, a1)))
3345
+ Value.Axis. all
3346
+
3372
3347
let print ppf { monadic; comonadic } =
3373
3348
Format. fprintf ppf " %a;%a" Monadic. print monadic Comonadic. print
3374
3349
comonadic
@@ -3589,8 +3564,12 @@ module Crossing = struct
3589
3564
| Modality. Atom (ax , Meet_with c ) -> C. print (Value. proj_obj ax) ppf c
3590
3565
in
3591
3566
let l =
3592
- t |> Modality.Value.Const. to_list
3593
- |> List. filter (fun t -> not @@ Modality. is_id t)
3567
+ List. filter_map
3568
+ (fun (Value.Axis. P ax ) ->
3569
+ let a = Modality.Value.Const. proj ax t in
3570
+ let a = Modality. Atom (ax, a) in
3571
+ if Modality. is_id a then None else Some a)
3572
+ Value.Axis. all
3594
3573
in
3595
3574
Format. (pp_print_list ~pp_sep: pp_print_space print_atom ppf l)
3596
3575
end
0 commit comments