Skip to content

Commit 961069e

Browse files
authored
Simplify inequality reasoning syntax in posets (#1533)
Pulled from #1353 .
1 parent b309a14 commit 961069e

File tree

3 files changed

+61
-48
lines changed

3 files changed

+61
-48
lines changed

src/order-theory/join-semilattices.lagda.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -497,28 +497,28 @@ module _
497497
leq-left-triple-join-Order-Theoretic-Join-Semilattice :
498498
x ≤ ((x ∨ y) ∨ z)
499499
leq-left-triple-join-Order-Theoretic-Join-Semilattice =
500-
calculate-in-Poset
501-
( poset-Order-Theoretic-Join-Semilattice A)
500+
let
501+
open
502+
inequality-reasoning-Poset (poset-Order-Theoretic-Join-Semilattice A)
503+
in
502504
chain-of-inequalities
503505
x ≤ x ∨ y
504506
by leq-left-join-Order-Theoretic-Join-Semilattice A x y
505-
in-Poset poset-Order-Theoretic-Join-Semilattice A
506507
≤ (x ∨ y) ∨ z
507508
by leq-left-join-Order-Theoretic-Join-Semilattice A (x ∨ y) z
508-
in-Poset poset-Order-Theoretic-Join-Semilattice A
509509
510510
leq-center-triple-join-Order-Theoretic-Join-Semilattice :
511511
y ≤ ((x ∨ y) ∨ z)
512512
leq-center-triple-join-Order-Theoretic-Join-Semilattice =
513-
calculate-in-Poset
514-
( poset-Order-Theoretic-Join-Semilattice A)
513+
let
514+
open
515+
inequality-reasoning-Poset (poset-Order-Theoretic-Join-Semilattice A)
516+
in
515517
chain-of-inequalities
516518
y ≤ x ∨ y
517519
by leq-right-join-Order-Theoretic-Join-Semilattice A x y
518-
in-Poset poset-Order-Theoretic-Join-Semilattice A
519520
≤ (x ∨ y) ∨ z
520521
by leq-left-join-Order-Theoretic-Join-Semilattice A (x ∨ y) z
521-
in-Poset poset-Order-Theoretic-Join-Semilattice A
522522
523523
leq-right-triple-join-Order-Theoretic-Join-Semilattice :
524524
z ≤ ((x ∨ y) ∨ z)
@@ -533,28 +533,28 @@ module _
533533
leq-center-triple-join-Order-Theoretic-Join-Semilattice' :
534534
y ≤ (x ∨ (y ∨ z))
535535
leq-center-triple-join-Order-Theoretic-Join-Semilattice' =
536-
calculate-in-Poset
537-
( poset-Order-Theoretic-Join-Semilattice A)
536+
let
537+
open
538+
inequality-reasoning-Poset (poset-Order-Theoretic-Join-Semilattice A)
539+
in
538540
chain-of-inequalities
539541
y ≤ y ∨ z
540542
by leq-left-join-Order-Theoretic-Join-Semilattice A y z
541-
in-Poset poset-Order-Theoretic-Join-Semilattice A
542543
≤ x ∨ (y ∨ z)
543544
by leq-right-join-Order-Theoretic-Join-Semilattice A x (y ∨ z)
544-
in-Poset poset-Order-Theoretic-Join-Semilattice A
545545
546546
leq-right-triple-join-Order-Theoretic-Join-Semilattice' :
547547
z ≤ (x ∨ (y ∨ z))
548548
leq-right-triple-join-Order-Theoretic-Join-Semilattice' =
549-
calculate-in-Poset
550-
( poset-Order-Theoretic-Join-Semilattice A)
549+
let
550+
open
551+
inequality-reasoning-Poset (poset-Order-Theoretic-Join-Semilattice A)
552+
in
551553
chain-of-inequalities
552554
z ≤ y ∨ z
553555
by leq-right-join-Order-Theoretic-Join-Semilattice A y z
554-
in-Poset poset-Order-Theoretic-Join-Semilattice A
555556
≤ x ∨ (y ∨ z)
556557
by leq-right-join-Order-Theoretic-Join-Semilattice A x (y ∨ z)
557-
in-Poset poset-Order-Theoretic-Join-Semilattice A
558558
559559
leq-associative-join-Order-Theoretic-Join-Semilattice :
560560
((x ∨ y) ∨ z) ≤ (x ∨ (y ∨ z))

src/order-theory/meet-semilattices.lagda.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -503,30 +503,30 @@ module _
503503
leq-left-triple-meet-Order-Theoretic-Meet-Semilattice :
504504
((x ∧ y) ∧ z) ≤ x
505505
leq-left-triple-meet-Order-Theoretic-Meet-Semilattice =
506-
calculate-in-Poset
507-
( poset-Order-Theoretic-Meet-Semilattice A)
506+
let
507+
open
508+
inequality-reasoning-Poset (poset-Order-Theoretic-Meet-Semilattice A)
509+
in
508510
chain-of-inequalities
509511
(x ∧ y) ∧ z
510512
≤ x ∧ y
511513
by leq-left-meet-Order-Theoretic-Meet-Semilattice A (x ∧ y) z
512-
in-Poset poset-Order-Theoretic-Meet-Semilattice A
513514
≤ x
514515
by leq-left-meet-Order-Theoretic-Meet-Semilattice A x y
515-
in-Poset poset-Order-Theoretic-Meet-Semilattice A
516516
517517
leq-center-triple-meet-Order-Theoretic-Meet-Semilattice :
518518
((x ∧ y) ∧ z) ≤ y
519519
leq-center-triple-meet-Order-Theoretic-Meet-Semilattice =
520-
calculate-in-Poset
521-
( poset-Order-Theoretic-Meet-Semilattice A)
520+
let
521+
open
522+
inequality-reasoning-Poset (poset-Order-Theoretic-Meet-Semilattice A)
523+
in
522524
chain-of-inequalities
523525
(x ∧ y) ∧ z
524526
≤ x ∧ y
525527
by leq-left-meet-Order-Theoretic-Meet-Semilattice A (x ∧ y) z
526-
in-Poset poset-Order-Theoretic-Meet-Semilattice A
527528
≤ y
528529
by leq-right-meet-Order-Theoretic-Meet-Semilattice A x y
529-
in-Poset poset-Order-Theoretic-Meet-Semilattice A
530530
531531
leq-right-triple-meet-Order-Theoretic-Meet-Semilattice :
532532
((x ∧ y) ∧ z) ≤ z
@@ -541,30 +541,30 @@ module _
541541
leq-center-triple-meet-Order-Theoretic-Meet-Semilattice' :
542542
(x ∧ (y ∧ z)) ≤ y
543543
leq-center-triple-meet-Order-Theoretic-Meet-Semilattice' =
544-
calculate-in-Poset
545-
( poset-Order-Theoretic-Meet-Semilattice A)
544+
let
545+
open
546+
inequality-reasoning-Poset (poset-Order-Theoretic-Meet-Semilattice A)
547+
in
546548
chain-of-inequalities
547549
x ∧ (y ∧ z)
548550
≤ y ∧ z
549551
by leq-right-meet-Order-Theoretic-Meet-Semilattice A x (y ∧ z)
550-
in-Poset poset-Order-Theoretic-Meet-Semilattice A
551552
≤ y
552553
by leq-left-meet-Order-Theoretic-Meet-Semilattice A y z
553-
in-Poset poset-Order-Theoretic-Meet-Semilattice A
554554
555555
leq-right-triple-meet-Order-Theoretic-Meet-Semilattice' :
556556
(x ∧ (y ∧ z)) ≤ z
557557
leq-right-triple-meet-Order-Theoretic-Meet-Semilattice' =
558-
calculate-in-Poset
559-
( poset-Order-Theoretic-Meet-Semilattice A)
558+
let
559+
open
560+
inequality-reasoning-Poset (poset-Order-Theoretic-Meet-Semilattice A)
561+
in
560562
chain-of-inequalities
561563
x ∧ (y ∧ z)
562564
≤ y ∧ z
563565
by leq-right-meet-Order-Theoretic-Meet-Semilattice A x (y ∧ z)
564-
in-Poset poset-Order-Theoretic-Meet-Semilattice A
565566
≤ z
566567
by leq-right-meet-Order-Theoretic-Meet-Semilattice A y z
567-
in-Poset poset-Order-Theoretic-Meet-Semilattice A
568568
569569
leq-associative-meet-Order-Theoretic-Meet-Semilattice :
570570
((x ∧ y) ∧ z) ≤ (x ∧ (y ∧ z))

src/order-theory/posets.lagda.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,38 +121,37 @@ module _
121121
Inequalities in preorders can be constructed by equational reasoning as follows:
122122

123123
```text
124-
calculate-in-Poset X
124+
let open inequality-reasoning-Poset X
125+
in
125126
chain-of-inequalities
126127
x ≤ y
127128
by ineq-1
128-
in-Poset X
129129
≤ z
130130
by ineq-2
131-
in-Poset X
132131
≤ v
133132
by ineq-3
134-
in-Poset X
135133
```
136134

137135
Note, however, that in our setup of equational reasoning with inequalities it is
138136
not possible to mix inequalities with equalities or strict inequalities.
139137

140138
```agda
141-
infixl 1 calculate-in-Poset_chain-of-inequalities_
142-
infixl 0 step-calculate-in-Poset
143-
144-
calculate-in-Poset_chain-of-inequalities_ :
139+
module inequality-reasoning-Poset
145140
{l1 l2 : Level} (X : Poset l1 l2)
146-
(x : type-Poset X) → leq-Poset X x x
147-
calculate-in-Poset_chain-of-inequalities_ = refl-leq-Poset
141+
where
148142
149-
step-calculate-in-Poset :
150-
{l1 l2 : Level} (X : Poset l1 l2)
151-
{x y : type-Poset X} → leq-Poset X x y →
152-
(z : type-Poset X) → leq-Poset X y z → leq-Poset X x z
153-
step-calculate-in-Poset X {x} {y} u z v = transitive-leq-Poset X x y z v u
143+
infixl 1 chain-of-inequalities_
144+
infixl 0 step-calculate-in-Poset
145+
146+
chain-of-inequalities_ : (x : type-Poset X) → leq-Poset X x x
147+
chain-of-inequalities_ = refl-leq-Poset X
148+
149+
step-calculate-in-Poset :
150+
{x y : type-Poset X} → leq-Poset X x y →
151+
(z : type-Poset X) → leq-Poset X y z → leq-Poset X x z
152+
step-calculate-in-Poset {x} {y} u z v = transitive-leq-Poset X x y z v u
154153
155-
syntax step-calculate-in-Poset X u z v = u ≤ z by v in-Poset X
154+
syntax step-calculate-in-Poset u z v = u ≤ z by v
156155
```
157156

158157
## Properties
@@ -201,3 +200,17 @@ module _
201200
```
202201

203202
It remains to show that these constructions form inverses to each other.
203+
204+
### 3-cycles in poset inequalities
205+
206+
```agda
207+
abstract
208+
three-cycle-leq-Poset :
209+
{l1 l2 : Level} → (P : Poset l1 l2) → {a b c : type-Poset P} →
210+
leq-Poset P a b → leq-Poset P b c → leq-Poset P c a →
211+
(a = b) × (a = c) × (b = c)
212+
three-cycle-leq-Poset P {a} {b} {c} a≤b b≤c c≤a =
213+
( antisymmetric-leq-Poset P a b a≤b (transitive-leq-Poset P _ c _ c≤a b≤c) ,
214+
antisymmetric-leq-Poset P a c (transitive-leq-Poset P _ b _ b≤c a≤b) c≤a ,
215+
antisymmetric-leq-Poset P b c b≤c (transitive-leq-Poset P _ a _ a≤b c≤a))
216+
```

0 commit comments

Comments
 (0)