2013-09-02 19:29:21 +00:00
|
|
|
|
Set: pp::colors
|
2013-09-03 17:44:51 +00:00
|
|
|
|
Set: pp::unicode
|
2014-01-09 22:06:23 +00:00
|
|
|
|
Imported 'if_then_else'
|
2013-09-01 02:15:48 +00:00
|
|
|
|
Assumed: N
|
|
|
|
|
Assumed: lt
|
|
|
|
|
Assumed: zero
|
|
|
|
|
Assumed: one
|
|
|
|
|
Assumed: two
|
|
|
|
|
Assumed: three
|
|
|
|
|
Assumed: two_lt_three
|
|
|
|
|
Defined: vector
|
|
|
|
|
Defined: const
|
|
|
|
|
Defined: update
|
|
|
|
|
Defined: select
|
|
|
|
|
Defined: map
|
2014-01-05 20:05:08 +00:00
|
|
|
|
variable one : N
|
|
|
|
|
variable two : N
|
|
|
|
|
variable three : N
|
|
|
|
|
infix 50 < : lt
|
|
|
|
|
axiom two_lt_three : two < three
|
2014-01-08 08:38:39 +00:00
|
|
|
|
definition vector (A : Type) (n : N) : Type := ∀ (i : N), i < n → A
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition const {A : Type} (n : N) (d : A) : vector A n := λ (i : N) (H : i < n), d
|
|
|
|
|
definition update {A : Type} {n : N} (v : vector A n) (i : N) (d : A) : vector A n :=
|
2014-01-09 22:06:23 +00:00
|
|
|
|
λ (j : N) (H : j < n), if (j = i) then d else v j H
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition select {A : Type} {n : N} (v : vector A n) (i : N) (H : i < n) : A := v i H
|
|
|
|
|
definition map {A B C : Type} {n : N} (f : A → B → C) (v1 : vector A n) (v2 : vector B n) : vector C n :=
|
2013-09-01 17:34:57 +00:00
|
|
|
|
λ (i : N) (H : i < n), f (v1 i H) (v2 i H)
|
2013-09-09 05:54:22 +00:00
|
|
|
|
select (update (const three ⊥) two ⊤) two two_lt_three : Bool
|
2014-01-16 23:07:51 +00:00
|
|
|
|
if (two = two) then ⊤ else ⊥
|
2013-09-09 05:54:22 +00:00
|
|
|
|
update (const three ⊥) two ⊤ : vector Bool three
|
2013-09-01 02:15:48 +00:00
|
|
|
|
|
|
|
|
|
--------
|
2014-01-08 08:38:39 +00:00
|
|
|
|
@select : ∀ (A : Type) (n : N) (v : vector A n) (i : N), i < n → A
|
2013-09-01 02:15:48 +00:00
|
|
|
|
|
|
|
|
|
map type --->
|
2014-01-08 08:38:39 +00:00
|
|
|
|
@map : ∀ (A B C : Type) (n : N), (A → B → C) → vector A n → vector B n → vector C n
|
2013-09-01 02:15:48 +00:00
|
|
|
|
|
|
|
|
|
map normal form -->
|
2013-09-01 17:34:57 +00:00
|
|
|
|
λ (A B C : Type)
|
2013-09-01 02:15:48 +00:00
|
|
|
|
(n : N)
|
2013-09-01 17:34:57 +00:00
|
|
|
|
(f : A → B → C)
|
2014-01-08 08:38:39 +00:00
|
|
|
|
(v1 : ∀ (i : N), i < n → A)
|
|
|
|
|
(v2 : ∀ (i : N), i < n → B)
|
2013-09-01 02:15:48 +00:00
|
|
|
|
(i : N)
|
|
|
|
|
(H : i < n),
|
|
|
|
|
f (v1 i H) (v2 i H)
|
|
|
|
|
|
|
|
|
|
update normal form -->
|
2014-01-16 23:07:51 +00:00
|
|
|
|
λ (A : Type) (n : N) (v : ∀ (i : N), i < n → A) (i : N) (d : A) (j : N) (H : j < n), if (j = i) then d else v j H
|