Debian Codegraph @

src/Algebra/Properties/KleeneAlgebra.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Some derivable properties
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 open import Algebra.Bundles using (KleeneAlgebra)
10
11 module Algebra.Properties.KleeneAlgebra {k₁ k₂} (K : KleeneAlgebra k₁ k₂) where
12
13 open KleeneAlgebra K
14 open import Algebra.Definitions _≈_
15 open import Relation.Binary.Reasoning.Setoid setoid
16
17 0⋆≈1 : 0# ⋆ ≈ 1#
18 0⋆≈1 = begin
19 0# ⋆ ≈⟨ sym (starExpansiveˡ 0#) ⟩
20 1# + 0# ⋆ * 0# ≈⟨ +-congˡ ( zeroʳ (0# ⋆)) ⟩
21 1# + 0# ≈⟨ +-identityʳ 1# ⟩
22 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)