-
Notifications
You must be signed in to change notification settings - Fork 23
/
AbstractReductionSystem.ard
80 lines (55 loc) · 3.08 KB
/
AbstractReductionSystem.ard
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
\import Paths
\import Paths.Meta
\import Relation.Truncated
\class AbstractReductionSystem \alias ARS (A : \Set)
| \infix 4 ~> : Rel A -- | Reduction relation
| \infix 5 |--| : Rel A -- | Symmetric relation
| |--|_symmetric (a b : A) (a~b : a |--| b) : b |--| a
\class SimpleARS \extends AbstractReductionSystem
| |--| => \lam a b => a = b
| |--|_symmetric (a b : A) (p : a |--| b) => inv p
\func \infix 4 ~>_0 {A : ARS} : Rel A => =
\func \infix 4 ~>_1 {A : ARS} : Rel A => A.~>
\func \infix 4 ~>_= {A : ARS} : Rel A => reflexive-closure (~>)
\func \infix 4 ~>_+ {A : ARS} : Rel A => transitive-closure (~>)
\func \infix 4 ~>_* {A : ARS} : Rel A => transitive-refl-closure (~>)
\func \infix 4 <~ {A : ARS} : Rel A => \lam a b => b ~> a
\func \infix 4 <~> {A : ARS} : Rel A => symmetric-closure (~>)
\func <~>-reverse {A : ARS} {a b : A} (a<~>b : a <~> b) : b <~> a \elim a<~>b
| sc-left a~>b => sc-right a~>b
| sc-right a<~b => sc-left a<~b
\func \infix 4 <~>* {A : ARS} : A -> A -> \Prop => transitive-refl-closure (<~>)
\lemma <~>*-compose {A : ARS} {a c : A} (b : A) (a<~>*b : a <~>* b) (b<~>*c : b <~>* c) : a <~>* c \elim a<~>*b
| trc-direct a=b => rewrite a=b b<~>*c
| trc-connect c1 a<~>c1 c1<~>*c => trc-connect c1 a<~>c1 (<~>*-compose b c1<~>*c b<~>*c)
\lemma <~>*-reverse {A : ARS} {a b : A} (a<~>*b : a <~>* b) : b <~>* a \elim a<~>*b
| trc-direct p => trc-direct (inv p)
| trc-connect c a<~>c c<~>*b => <~>*-compose c (<~>*-reverse c<~>*b) (trc-connect a (<~>-reverse a<~>c) (trc-direct idp))
\lemma ~>=><~>* {A : ARS} {a b : A} (red : a ~> b) : a <~>* b => trc-connect b (sc-left red) (trc-direct idp)
\lemma ~>*=><~>* {A : ARS} {a b : A} (red : a ~>_* b) : a <~>* b \elim red
| trc-direct a=b => trc-direct a=b
| trc-connect c r t => trc-connect c (sc-left r) (~>*=><~>* t)
\lemma ~>*-concat {A : ARS} {a b c : A} (a~>*b : a ~>_* b) (b~>*c : b ~>_* c) : a ~>_* c \elim a~>*b
| trc-direct a=b => rewrite a=b b~>*c
| trc-connect c' a~>c' c'~>*b => trc-connect c' a~>c' (~>*-concat c'~>*b b~>*c)
\lemma ~>_=-append {A : ARS} {a b c : A} (a~>_=b : a ~>_= b) (b~>*c : b ~>_* c) : a ~>_* c \elim a~>_=b
| rc-id p => rewrite p b~>*c
| rc-rel a~>b => trc-connect b a~>b b~>*c
\truncated \data Join {A : ARS} (a b : A) : \Prop
| join (c : A) (a ~>_* c) (b ~>_* c)
\where {
\lemma append-left {A : ARS} {a b c : A} (c~>*a : c ~>_* a) (j : Join a b) : Join c b \elim j
| join c' a~>*c' b~>*c' => join c' (~>*-concat c~>*a a~>*c') b~>*c'
\lemma append-right {A : ARS} {a b c : A} (c~>*b : c ~>_* b) (j : Join a b) : Join a c \elim j
| join c' a~>*c' b~>*c' => join c' a~>*c' (~>*-concat c~>*b b~>*c')
}
\func \infix 5 ~ {A : ARS} : Rel A => transitive-refl-closure (|--|)
\truncated \data \infix 5 |==| {A : ARS} (a b : A) : \Prop
| red-to (a ~> b)
| red-from (a <~ b)
| eq (a ~ b)
\func Conversion~ {A : ARS} : Rel A => transitive-refl-closure (|==|)
\truncated \data Join~ {A : ARS} (a b : A) : \Prop
| join~ (c d : A) (a ~>_* c) (c ~ d) (b ~>_* d)
\truncated \data \infix 4 ~>~ {A : ARS} (a b : A) : \Prop
| red~ (c d : A) (a ~ c) (c ~> d) (d ~ b)