-
Notifications
You must be signed in to change notification settings - Fork 247
/
Copy pathProperties.agda
52 lines (40 loc) · 1.47 KB
/
Properties.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some properties about signs
------------------------------------------------------------------------
module Data.Sign.Properties where
open import Data.Empty
open import Function
open import Data.Sign
open import Data.Product using (_,_)
open import Relation.Binary.PropositionalEquality
open import Algebra.FunctionProperties (_≡_ {A = Sign})
-- The opposite of a sign is not equal to the sign.
opposite-not-equal : ∀ s → s ≢ opposite s
opposite-not-equal - ()
opposite-not-equal + ()
opposite-cong : ∀ {s t} → opposite s ≡ opposite t → s ≡ t
opposite-cong { - } { - } refl = refl
opposite-cong { - } { + } ()
opposite-cong { + } { - } ()
opposite-cong { + } { + } refl = refl
------------------------------------------------------------------------
-- _*_
*-identityˡ : LeftIdentity + _*_
*-identityˡ _ = refl
*-identityʳ : RightIdentity + _*_
*-identityʳ - = refl
*-identityʳ + = refl
*-identity : Identity + _*_
*-identity = *-identityˡ , *-identityʳ
cancel-*-right : RightCancellative _*_
cancel-*-right - - _ = refl
cancel-*-right - + eq = ⊥-elim (opposite-not-equal _ $ sym eq)
cancel-*-right + - eq = ⊥-elim (opposite-not-equal _ eq)
cancel-*-right + + _ = refl
cancel-*-left : LeftCancellative _*_
cancel-*-left - eq = opposite-cong eq
cancel-*-left + eq = eq
*-cancellative : Cancellative _*_
*-cancellative = cancel-*-left , cancel-*-right