Skip to content

Commit 7036cfd

Browse files
Add proofs to Kleene Algebra (#1884)
1 parent 625a577 commit 7036cfd

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

src/Algebra/Properties/KleeneAlgebra.agda

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,110 @@ open import Relation.Binary.Reasoning.Setoid setoid
2020
1# + 0# ⋆ * 0# ≈⟨ +-congˡ ( zeroʳ (0# ⋆)) ⟩
2121
1# + 0# ≈⟨ +-identityʳ 1# ⟩
2222
1# ∎
23+
24+
1+x⋆≈x⋆ : x 1# + x ⋆ ≈ x ⋆
25+
1+x⋆≈x⋆ x = sym (begin
26+
x ⋆ ≈⟨ sym (starExpansiveʳ x) ⟩
27+
1# + x * x ⋆ ≈⟨ +-congʳ (sym (+-idem 1#)) ⟩
28+
1# + 1# + x * x ⋆ ≈⟨ +-assoc 1# 1# ((x * x ⋆ )) ⟩
29+
1# + (1# + x * x ⋆) ≈⟨ +-congˡ (starExpansiveʳ x) ⟩
30+
1# + x ⋆ ∎)
31+
32+
x⋆+xx⋆≈x⋆ : x x ⋆ + x * x ⋆ ≈ x ⋆
33+
x⋆+xx⋆≈x⋆ x = begin
34+
x ⋆ + x * x ⋆ ≈⟨ +-congʳ (sym (1+x⋆≈x⋆ x)) ⟩
35+
1# + x ⋆ + x * x ⋆ ≈⟨ +-congʳ (+-comm 1# ((x ⋆))) ⟩
36+
x ⋆ + 1# + x * x ⋆ ≈⟨ +-assoc ((x ⋆)) 1# ((x * x ⋆ )) ⟩
37+
x ⋆ + (1# + x * x ⋆) ≈⟨ +-congˡ (starExpansiveʳ x) ⟩
38+
x ⋆ + x ⋆ ≈⟨ +-idem (x ⋆) ⟩
39+
x ⋆ ∎
40+
41+
x⋆+x⋆x≈x⋆ : x x ⋆ + x ⋆ * x ≈ x ⋆
42+
x⋆+x⋆x≈x⋆ x = begin
43+
x ⋆ + x ⋆ * x ≈⟨ +-congʳ (sym (1+x⋆≈x⋆ x)) ⟩
44+
1# + x ⋆ + x ⋆ * x ≈⟨ +-congʳ (+-comm 1# (x ⋆)) ⟩
45+
x ⋆ + 1# + x ⋆ * x ≈⟨ +-assoc (x ⋆) 1# (x ⋆ * x) ⟩
46+
x ⋆ + (1# + x ⋆ * x) ≈⟨ +-congˡ (starExpansiveˡ x) ⟩
47+
x ⋆ + x ⋆ ≈⟨ +-idem (x ⋆) ⟩
48+
x ⋆ ∎
49+
50+
x+x⋆≈x⋆ : x x + x ⋆ ≈ x ⋆
51+
x+x⋆≈x⋆ x = begin
52+
x + x ⋆ ≈⟨ +-congˡ (sym (starExpansiveʳ x)) ⟩
53+
x + (1# + x * x ⋆) ≈⟨ +-congʳ (sym (*-identityʳ x)) ⟩
54+
x * 1# + (1# + x * x ⋆) ≈⟨ sym (+-assoc (x * 1#) 1# (x * x ⋆)) ⟩
55+
x * 1# + 1# + x * x ⋆ ≈⟨ +-congʳ (+-comm (x * 1#) 1#) ⟩
56+
1# + x * 1# + x * x ⋆ ≈⟨ +-assoc 1# (x * 1#) (x * x ⋆) ⟩
57+
1# + (x * 1# + x * x ⋆) ≈⟨ +-congˡ (sym (distribˡ x 1# ((x ⋆)))) ⟩
58+
1# + x * (1# + x ⋆) ≈⟨ +-congˡ (*-congˡ (1+x⋆≈x⋆ x)) ⟩
59+
1# + x * x ⋆ ≈⟨ (starExpansiveʳ x) ⟩
60+
x ⋆ ∎
61+
62+
1+x+x⋆≈x⋆ : x 1# + x + x ⋆ ≈ x ⋆
63+
1+x+x⋆≈x⋆ x = begin
64+
1# + x + x ⋆ ≈⟨ +-assoc 1# x (x ⋆) ⟩
65+
1# + (x + x ⋆) ≈⟨ +-congˡ (x+x⋆≈x⋆ x) ⟩
66+
1# + x ⋆ ≈⟨ 1+x⋆≈x⋆ x ⟩
67+
x ⋆ ∎
68+
69+
0+x+x⋆≈x⋆ : x 0# + x + x ⋆ ≈ x ⋆
70+
0+x+x⋆≈x⋆ x = begin
71+
0# + x + x ⋆ ≈⟨ +-assoc 0# x (x ⋆) ⟩
72+
0# + (x + x ⋆) ≈⟨ +-identityˡ ((x + x ⋆)) ⟩
73+
(x + x ⋆) ≈⟨ x+x⋆≈x⋆ x ⟩
74+
x ⋆ ∎
75+
76+
x⋆x⋆≈x⋆ : x x ⋆ * x ⋆ ≈ x ⋆
77+
x⋆x⋆≈x⋆ x = starDestructiveˡ x (x ⋆) (x ⋆) (x⋆+xx⋆≈x⋆ x)
78+
79+
1+x⋆x⋆≈x⋆ : x 1# + x ⋆ * x ⋆ ≈ x ⋆
80+
1+x⋆x⋆≈x⋆ x = begin
81+
1# + x ⋆ * x ⋆ ≈⟨ +-congˡ (x⋆x⋆≈x⋆ x) ⟩
82+
1# + x ⋆ ≈⟨ 1+x⋆≈x⋆ x ⟩
83+
x ⋆ ∎
84+
85+
x⋆⋆≈x⋆ : x (x ⋆) ⋆ ≈ x ⋆
86+
x⋆⋆≈x⋆ x = begin
87+
(x ⋆) ⋆ ≈⟨ sym (*-identityʳ ((x ⋆) ⋆)) ⟩
88+
(x ⋆) ⋆ * 1# ≈⟨ starDestructiveˡ (x ⋆) 1# (x ⋆) (1+x⋆x⋆≈x⋆ x) ⟩
89+
x ⋆ ∎
90+
91+
1+11≈1 : 1# + 1# * 1# ≈ 1#
92+
1+11≈1 = begin
93+
1# + 1# * 1# ≈⟨ +-congˡ ( *-identityʳ 1#) ⟩
94+
1# + 1# ≈⟨ +-idem 1# ⟩
95+
1# ∎
96+
97+
1⋆≈1 : 1# ⋆ ≈ 1#
98+
1⋆≈1 = begin
99+
1# ⋆ ≈⟨ sym (*-identityʳ (1# ⋆)) ⟩
100+
1# ⋆ * 1# ≈⟨ starDestructiveˡ 1# 1# 1# 1+11≈1 ⟩
101+
1# ∎
102+
103+
x≈y⇒1+xy⋆≈y⋆ : x y x ≈ y 1# + x * y ⋆ ≈ y ⋆
104+
x≈y⇒1+xy⋆≈y⋆ x y eq = begin
105+
1# + x * y ⋆ ≈⟨ +-congˡ (*-congʳ (eq)) ⟩
106+
1# + y * y ⋆ ≈⟨ starExpansiveʳ y ⟩
107+
y ⋆ ∎
108+
109+
x≈y⇒x⋆≈y⋆ : x y x ≈ y x ⋆ ≈ y ⋆
110+
x≈y⇒x⋆≈y⋆ x y eq = begin
111+
x ⋆ ≈⟨ sym (*-identityʳ (x ⋆)) ⟩
112+
x ⋆ * 1# ≈⟨ (starDestructiveˡ x 1# (y ⋆) (x≈y⇒1+xy⋆≈y⋆ x y eq)) ⟩
113+
y ⋆ ∎
114+
115+
ax≈xb⇒x+axb⋆≈xb⋆ : x a b a * x ≈ x * b x + a * (x * b ⋆) ≈ x * b ⋆
116+
ax≈xb⇒x+axb⋆≈xb⋆ x a b eq = begin
117+
x + a * (x * b ⋆) ≈⟨ +-congˡ (sym(*-assoc a x (b ⋆))) ⟩
118+
x + a * x * b ⋆ ≈⟨ +-congʳ (sym (*-identityʳ x)) ⟩
119+
x * 1# + a * x * b ⋆ ≈⟨ +-congˡ (*-congʳ (eq)) ⟩
120+
x * 1# + x * b * b ⋆ ≈⟨ +-congˡ (*-assoc x b (b ⋆) ) ⟩
121+
x * 1# + x * (b * b ⋆) ≈⟨ sym (distribˡ x 1# (b * b ⋆)) ⟩
122+
x * (1# + b * b ⋆) ≈⟨ *-congˡ (starExpansiveʳ b) ⟩
123+
x * b ⋆ ∎
124+
125+
ax≈xb⇒a⋆x≈xb⋆ : x a b a * x ≈ x * b a ⋆ * x ≈ x * b ⋆
126+
ax≈xb⇒a⋆x≈xb⋆ x a b eq = starDestructiveˡ a x ((x * b ⋆)) (ax≈xb⇒x+axb⋆≈xb⋆ x a b eq)
127+
128+
[xy]⋆x≈x[yx]⋆ : x y (x * y) ⋆ * x ≈ x * (y * x) ⋆
129+
[xy]⋆x≈x[yx]⋆ x y = ax≈xb⇒a⋆x≈xb⋆ x (x * y) (y * x) (*-assoc x y x)

0 commit comments

Comments
 (0)