@@ -504,11 +504,11 @@ module Lattices_mono = struct
504
504
505
505
type ('a, 'b, 'd) morph =
506
506
| Id : ('a , 'a , 'd ) morph (* * identity morphism *)
507
- | Meet_with : 'a -> ('a , 'a , 'd * disallowed ) morph
507
+ | Meet_with : 'a -> ('a , 'a , 'l * 'r ) morph
508
508
(* * Meet the input with the parameter *)
509
509
| Imply : 'a -> ('a , 'a , disallowed * 'd ) morph
510
510
(* * The right adjoint of [Meet_with] *)
511
- | Join_with : 'a -> ('a , 'a , disallowed * 'd ) morph
511
+ | Join_with : 'a -> ('a , 'a , 'l * 'r ) morph
512
512
(* * Join the input with the parameter *)
513
513
| Subtract : 'a -> ('a , 'a , 'd * disallowed ) morph
514
514
(* * The left adjoint of [Join_with] *)
@@ -557,6 +557,7 @@ module Lattices_mono = struct
557
557
| Proj (src , ax ) -> Proj (src, ax)
558
558
| Min_with ax -> Min_with ax
559
559
| Meet_with c -> Meet_with c
560
+ | Join_with c -> Join_with c
560
561
| Subtract c -> Subtract c
561
562
| Compose (f , g ) ->
562
563
let f = allow_left f in
@@ -579,6 +580,7 @@ module Lattices_mono = struct
579
580
| Proj (src , ax ) -> Proj (src, ax)
580
581
| Max_with ax -> Max_with ax
581
582
| Join_with c -> Join_with c
583
+ | Meet_with c -> Meet_with c
582
584
| Imply c -> Imply c
583
585
| Compose (f , g ) ->
584
586
let f = allow_right f in
@@ -893,7 +895,9 @@ module Lattices_mono = struct
893
895
| Imply c0 , Imply c1 -> Some (Imply (meet dst c0 c1))
894
896
| Subtract c0 , Subtract c1 -> Some (Subtract (join dst c0 c1))
895
897
| Imply c0 , Join_with c1 when le dst c0 c1 -> Some (Join_with (max dst))
898
+ | Imply c0 , Meet_with c1 when le dst c0 c1 -> Some (Imply c0)
896
899
| Subtract c0 , Meet_with c1 when le dst c1 c0 -> Some (Meet_with (min dst))
900
+ | Subtract c0 , Join_with c1 when le dst c1 c0 -> Some (Subtract c0)
897
901
| Meet_with c0 , m1 when is_max c0 -> Some m1
898
902
| Join_with c0 , m1 when is_min c0 -> Some m1
899
903
| Imply c0 , m1 when is_max c0 -> Some m1
@@ -1045,6 +1049,10 @@ module Lattices_mono = struct
1045
1049
let g' = left_adjoint mid g in
1046
1050
Compose (g', f')
1047
1051
| Join_with c -> Subtract c
1052
+ | Meet_with _c ->
1053
+ (* The downward closure of [Meet_with c]'s image is all [x <= c].
1054
+ For those, [x <= meet c y] is equivalent to [x <= y]. *)
1055
+ Id
1048
1056
| Imply c -> Meet_with c
1049
1057
| Comonadic_to_monadic _ -> Monadic_to_comonadic_min
1050
1058
| Monadic_to_comonadic_max -> Comonadic_to_monadic dst
@@ -1072,6 +1080,10 @@ module Lattices_mono = struct
1072
1080
Compose (g', f')
1073
1081
| Meet_with c -> Imply c
1074
1082
| Subtract c -> Join_with c
1083
+ | Join_with _c ->
1084
+ (* The upward closure of [Join_with c]'s image is all [x >= c].
1085
+ For those, [join c y <= x] is equivalent to [y <= x]. *)
1086
+ Id
1075
1087
| Comonadic_to_monadic _ -> Monadic_to_comonadic_max
1076
1088
| Monadic_to_comonadic_min -> Comonadic_to_monadic dst
1077
1089
| Local_to_regional -> Regional_to_local
@@ -1346,11 +1358,9 @@ module Comonadic_with_regionality = struct
1346
1358
1347
1359
let proj ax m = Solver. via_monotone (proj_obj ax) (Proj (Obj. obj, ax)) m
1348
1360
1349
- let meet_const c m =
1350
- Solver. via_monotone obj (Meet_with c) (Solver. disallow_right m)
1361
+ let meet_const c m = Solver. via_monotone obj (Meet_with c) m
1351
1362
1352
- let join_const c m =
1353
- Solver. via_monotone obj (Join_with c) (Solver. disallow_left m)
1363
+ let join_const c m = Solver. via_monotone obj (Join_with c) m
1354
1364
1355
1365
let min_with ax m =
1356
1366
Solver. via_monotone Obj. obj (Min_with ax) (Solver. disallow_right m)
@@ -1411,11 +1421,9 @@ module Comonadic_with_locality = struct
1411
1421
1412
1422
let proj ax m = Solver. via_monotone (proj_obj ax) (Proj (Obj. obj, ax)) m
1413
1423
1414
- let meet_const c m =
1415
- Solver. via_monotone obj (Meet_with c) (Solver. disallow_right m)
1424
+ let meet_const c m = Solver. via_monotone obj (Meet_with c) m
1416
1425
1417
- let join_const c m =
1418
- Solver. via_monotone obj (Join_with c) (Solver. disallow_left m)
1426
+ let join_const c m = Solver. via_monotone obj (Join_with c) m
1419
1427
1420
1428
let min_with ax m =
1421
1429
Solver. via_monotone Obj. obj (Min_with ax) (Solver. disallow_right m)
@@ -1483,11 +1491,9 @@ module Monadic = struct
1483
1491
by [Solver_polarized], but some remain, such as the [Min_with] below which
1484
1492
is inverted from [Max_with]. *)
1485
1493
1486
- let meet_const c m =
1487
- Solver. via_monotone obj (Join_with c) (Solver. disallow_right m)
1494
+ let meet_const c m = Solver. via_monotone obj (Join_with c) m
1488
1495
1489
- let join_const c m =
1490
- Solver. via_monotone obj (Meet_with c) (Solver. disallow_left m)
1496
+ let join_const c m = Solver. via_monotone obj (Meet_with c) m
1491
1497
1492
1498
let max_with ax m =
1493
1499
Solver. via_monotone Obj. obj (Min_with ax) (Solver. disallow_left m)
@@ -1744,34 +1750,30 @@ module Value = struct
1744
1750
| Comonadic ax -> min_with_comonadic ax m
1745
1751
1746
1752
let join_with_monadic ax c { monadic; comonadic } =
1747
- let comonadic = Comonadic. disallow_left comonadic in
1748
1753
let monadic = Monadic. join_with ax c monadic in
1749
1754
{ monadic; comonadic }
1750
1755
1751
1756
let join_with_comonadic ax c { monadic; comonadic } =
1752
- let monadic = Monadic. disallow_left monadic in
1753
1757
let comonadic = Comonadic. join_with ax c comonadic in
1754
1758
{ comonadic; monadic }
1755
1759
1756
- let join_with :
1757
- type m a d l r . ( m , a , d ) axis -> a -> ( l * r ) t -> ( disallowed * r ) t =
1760
+ let join_with : type m a d l r . ( m , a , d ) axis -> a -> ( l * r ) t -> ( l * r ) t
1761
+ =
1758
1762
fun ax c m ->
1759
1763
match ax with
1760
1764
| Monadic ax -> join_with_monadic ax c m
1761
1765
| Comonadic ax -> join_with_comonadic ax c m
1762
1766
1763
1767
let meet_with_monadic ax c { monadic; comonadic } =
1764
- let comonadic = Comonadic. disallow_right comonadic in
1765
1768
let monadic = Monadic. meet_with ax c monadic in
1766
1769
{ monadic; comonadic }
1767
1770
1768
1771
let meet_with_comonadic ax c { monadic; comonadic } =
1769
- let monadic = Monadic. disallow_right monadic in
1770
1772
let comonadic = Comonadic. meet_with ax c comonadic in
1771
1773
{ comonadic; monadic }
1772
1774
1773
- let meet_with :
1774
- type m a d l r . ( m , a , d ) axis -> a -> ( l * r ) t -> ( l * disallowed ) t =
1775
+ let meet_with : type m a d l r . ( m , a , d ) axis -> a -> ( l * r ) t -> ( l * r ) t
1776
+ =
1775
1777
fun ax c m ->
1776
1778
match ax with
1777
1779
| Monadic ax -> meet_with_monadic ax c m
@@ -2004,34 +2006,30 @@ module Alloc = struct
2004
2006
| Comonadic ax -> min_with_comonadic ax m
2005
2007
2006
2008
let join_with_monadic ax c { monadic; comonadic } =
2007
- let comonadic = Comonadic. disallow_left comonadic in
2008
2009
let monadic = Monadic. join_with ax c monadic in
2009
2010
{ monadic; comonadic }
2010
2011
2011
2012
let join_with_comonadic ax c { monadic; comonadic } =
2012
- let monadic = Monadic. disallow_left monadic in
2013
2013
let comonadic = Comonadic. join_with ax c comonadic in
2014
2014
{ comonadic; monadic }
2015
2015
2016
- let join_with :
2017
- type m a d l r . ( m , a , d ) axis -> a -> ( l * r ) t -> ( disallowed * r ) t =
2016
+ let join_with : type m a d l r . ( m , a , d ) axis -> a -> ( l * r ) t -> ( l * r ) t
2017
+ =
2018
2018
fun ax c m ->
2019
2019
match ax with
2020
2020
| Monadic ax -> join_with_monadic ax c m
2021
2021
| Comonadic ax -> join_with_comonadic ax c m
2022
2022
2023
2023
let meet_with_monadic ax c { monadic; comonadic } =
2024
- let comonadic = Comonadic. disallow_right comonadic in
2025
2024
let monadic = Monadic. meet_with ax c monadic in
2026
2025
{ monadic; comonadic }
2027
2026
2028
2027
let meet_with_comonadic ax c { monadic; comonadic } =
2029
- let monadic = Monadic. disallow_right monadic in
2030
2028
let comonadic = Comonadic. meet_with ax c comonadic in
2031
2029
{ comonadic; monadic }
2032
2030
2033
- let meet_with :
2034
- type m a d l r . ( m , a , d ) axis -> a -> ( l * r ) t -> ( l * disallowed ) t =
2031
+ let meet_with : type m a d l r . ( m , a , d ) axis -> a -> ( l * r ) t -> ( l * r ) t
2032
+ =
2035
2033
fun ax c m ->
2036
2034
match ax with
2037
2035
| Monadic ax -> meet_with_monadic ax c m
0 commit comments