annotate Paper/src/agda/utilities.agda.replaced @ 2:9176dff8f38a

ADD while loop description
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Fri, 05 Nov 2021 15:19:08 +0900
parents
children 339fb67b4375
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 {-@$\#$@ OPTIONS --allow-unsolved-metas @$\#$@-}
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 module utilities where
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Function
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Nat
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.Product
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Data.Bool hiding ( _≟_ ; _@$\leq$@?_)
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import Level renaming ( suc to succ ; zero to Zero )
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Relation.Nullary using (@$\neg$@_; Dec; yes; no)
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Relation.Binary.PropositionalEquality
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 Pred : Set @$\rightarrow$@ Set@$\_{1}$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 Pred X = X @$\rightarrow$@ Set
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 Imply : Set @$\rightarrow$@ Set @$\rightarrow$@ Set
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 Imply X Y = X @$\rightarrow$@ Y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 Iff : Set @$\rightarrow$@ Set @$\rightarrow$@ Set
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 Iff X Y = Imply X Y @$\times$@ Imply Y X
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 record _@$\wedge$@_ {n : Level } (a : Set n) (b : Set n): Set n where
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 field
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 pi1 : a
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 pi2 : b
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 open _@$\wedge$@_
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 _-_ : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 x - zero = x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 zero - _ = zero
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 (suc x) - (suc y) = x - y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 +zero : { y : @$\mathbb{N}$@ } @$\rightarrow$@ y + zero @$\equiv$@ y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 +zero {zero} = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 +zero {suc y} = cong ( @$\lambda$@ x @$\rightarrow$@ suc x ) ( +zero {y} )
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 +-sym : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ x + y @$\equiv$@ y + x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 +-sym {zero} {zero} = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 +-sym {zero} {suc y} = let open @$\equiv$@-Reasoning in
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 begin
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 zero + suc y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 @$\equiv$@@$\langle$@@$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 suc y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 @$\equiv$@@$\langle$@ sym +zero @$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 suc y + zero
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 @$\blacksquare$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 +-sym {suc x} {zero} = let open @$\equiv$@-Reasoning in
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 begin
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 suc x + zero
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 @$\equiv$@@$\langle$@ +zero @$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 suc x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 @$\equiv$@@$\langle$@@$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 zero + suc x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 @$\blacksquare$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 +-sym {suc x} {suc y} = cong ( @$\lambda$@ z @$\rightarrow$@ suc z ) ( let open @$\equiv$@-Reasoning in
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 begin
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 x + suc y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 @$\equiv$@@$\langle$@ +-sym {x} {suc y} @$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 suc (y + x)
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ suc z ) (+-sym {y} {x}) @$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 suc (x + y)
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 @$\equiv$@@$\langle$@ sym ( +-sym {y} {suc x}) @$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 y + suc x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 @$\blacksquare$@ )
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 minus-plus : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ (suc x - 1) + (y + 1) @$\equiv$@ suc x + y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 minus-plus {zero} {y} = +-sym {y} {1}
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 minus-plus {suc x} {y} = cong ( @$\lambda$@ z @$\rightarrow$@ suc z ) (minus-plus {x} {y})
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 +1@$\equiv$@suc : { x : @$\mathbb{N}$@ } @$\rightarrow$@ x + 1 @$\equiv$@ suc x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 +1@$\equiv$@suc {zero} = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 +1@$\equiv$@suc {suc x} = cong ( @$\lambda$@ z @$\rightarrow$@ suc z ) ( +1@$\equiv$@suc {x} )
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 lt : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Bool
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 lt x y with (suc x ) @$\leq$@? y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 lt x y | yes p = true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 lt x y | no @$\neg$@p = false
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 pred@$\mathbb{N}$@ : {n : @$\mathbb{N}$@ } @$\rightarrow$@ lt 0 n @$\equiv$@ true @$\rightarrow$@ @$\mathbb{N}$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 pred@$\mathbb{N}$@ {zero} ()
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 pred@$\mathbb{N}$@ {suc n} refl = n
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 pred@$\mathbb{N}$@+1=n : {n : @$\mathbb{N}$@ } @$\rightarrow$@ (less : lt 0 n @$\equiv$@ true ) @$\rightarrow$@ (pred@$\mathbb{N}$@ less) + 1 @$\equiv$@ n
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 pred@$\mathbb{N}$@+1=n {zero} ()
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 pred@$\mathbb{N}$@+1=n {suc n} refl = +1@$\equiv$@suc
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 suc-pred@$\mathbb{N}$@=n : {n : @$\mathbb{N}$@ } @$\rightarrow$@ (less : lt 0 n @$\equiv$@ true ) @$\rightarrow$@ suc (pred@$\mathbb{N}$@ less) @$\equiv$@ n
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 suc-pred@$\mathbb{N}$@=n {zero} ()
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 suc-pred@$\mathbb{N}$@=n {suc n} refl = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 Equal : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Bool
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 Equal x y with x ≟ y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 Equal x y | yes p = true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 Equal x y | no @$\neg$@p = false
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 _@$\Rightarrow$@_ : Bool @$\rightarrow$@ Bool @$\rightarrow$@ Bool
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 false @$\Rightarrow$@ _ = true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 true @$\Rightarrow$@ true = true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 true @$\Rightarrow$@ false = false
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 @$\Rightarrow$@t : {x : Bool} @$\rightarrow$@ x @$\Rightarrow$@ true @$\equiv$@ true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 @$\Rightarrow$@t {x} with x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 @$\Rightarrow$@t {x} | false = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 @$\Rightarrow$@t {x} | true = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 f@$\Rightarrow$@ : {x : Bool} @$\rightarrow$@ false @$\Rightarrow$@ x @$\equiv$@ true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 f@$\Rightarrow$@ {x} with x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 f@$\Rightarrow$@ {x} | false = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 f@$\Rightarrow$@ {x} | true = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 @$\wedge$@-pi1 : { x y : Bool } @$\rightarrow$@ x @$\wedge$@ y @$\equiv$@ true @$\rightarrow$@ x @$\equiv$@ true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 @$\wedge$@-pi1 {x} {y} eq with x | y | eq
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 @$\wedge$@-pi1 {x} {y} eq | false | b | ()
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 @$\wedge$@-pi1 {x} {y} eq | true | false | ()
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 @$\wedge$@-pi1 {x} {y} eq | true | true | refl = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 @$\wedge$@-pi2 : { x y : Bool } @$\rightarrow$@ x @$\wedge$@ y @$\equiv$@ true @$\rightarrow$@ y @$\equiv$@ true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 @$\wedge$@-pi2 {x} {y} eq with x | y | eq
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 @$\wedge$@-pi2 {x} {y} eq | false | b | ()
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 @$\wedge$@-pi2 {x} {y} eq | true | false | ()
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 @$\wedge$@-pi2 {x} {y} eq | true | true | refl = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 @$\wedge$@true : { x : Bool } @$\rightarrow$@ x @$\wedge$@ true @$\equiv$@ x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 @$\wedge$@true {x} with x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 @$\wedge$@true {x} | false = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 @$\wedge$@true {x} | true = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 true@$\wedge$@ : { x : Bool } @$\rightarrow$@ true @$\wedge$@ x @$\equiv$@ x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 true@$\wedge$@ {x} with x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 true@$\wedge$@ {x} | false = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 true@$\wedge$@ {x} | true = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 bool-case : ( x : Bool ) { p : Set } @$\rightarrow$@ ( x @$\equiv$@ true @$\rightarrow$@ p ) @$\rightarrow$@ ( x @$\equiv$@ false @$\rightarrow$@ p ) @$\rightarrow$@ p
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 bool-case x T F with x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 bool-case x T F | false = F refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 bool-case x T F | true = T refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 impl@$\Rightarrow$@ : {x y : Bool} @$\rightarrow$@ (x @$\equiv$@ true @$\rightarrow$@ y @$\equiv$@ true ) @$\rightarrow$@ x @$\Rightarrow$@ y @$\equiv$@ true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 impl@$\Rightarrow$@ {x} {y} p = bool-case x (@$\lambda$@ x=t @$\rightarrow$@ let open @$\equiv$@-Reasoning in
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 begin
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 x @$\Rightarrow$@ y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ x @$\Rightarrow$@ z ) (p x=t ) @$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 x @$\Rightarrow$@ true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 @$\equiv$@@$\langle$@ @$\Rightarrow$@t @$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 @$\blacksquare$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 ) ( @$\lambda$@ x=f @$\rightarrow$@ let open @$\equiv$@-Reasoning in
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 begin
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 x @$\Rightarrow$@ y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ z @$\Rightarrow$@ y ) x=f @$\rangle$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 @$\blacksquare$@
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 )
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 Equal@$\rightarrow$@@$\equiv$@ : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ Equal x y @$\equiv$@ true @$\rightarrow$@ x @$\equiv$@ y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 Equal@$\rightarrow$@@$\equiv$@ {x} {y} eq with x ≟ y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 Equal@$\rightarrow$@@$\equiv$@ {x} {y} refl | yes refl = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 Equal@$\rightarrow$@@$\equiv$@ {x} {y} () | no @$\neg$@p
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 Equal+1 : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ Equal x y @$\equiv$@ Equal (suc x) (suc y)
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 Equal+1 {x} {y} with x ≟ y
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 Equal+1 {x} {.x} | yes refl = {!!}
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 Equal+1 {x} {y} | no @$\neg$@p = {!!}
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 open import Data.Empty
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 @$\equiv$@@$\rightarrow$@Equal : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ x @$\equiv$@ y @$\rightarrow$@ Equal x y @$\equiv$@ true
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 @$\equiv$@@$\rightarrow$@Equal {x} {.x} refl with x ≟ x
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 @$\equiv$@@$\rightarrow$@Equal {x} {.x} refl | yes refl = refl
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 @$\equiv$@@$\rightarrow$@Equal {x} {.x} refl | no @$\neg$@p = @$\bot$@-elim ( @$\neg$@p refl )