40b7ed13c2
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
49 lines
1.5 KiB
Text
49 lines
1.5 KiB
Text
Set: pp::colors
|
||
Set: pp::unicode
|
||
Imported 'if_then_else'
|
||
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
|
||
variable one : N
|
||
variable two : N
|
||
variable three : N
|
||
infix 50 < : lt
|
||
axiom two_lt_three : two < three
|
||
definition vector (A : Type) (n : N) : Type := ∀ (i : N), i < n → A
|
||
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 :=
|
||
λ (j : N) (H : j < n), if j = i then d else v j H
|
||
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 :=
|
||
λ (i : N) (H : i < n), f (v1 i H) (v2 i H)
|
||
select (update (const three ⊥) two ⊤) two two_lt_three : Bool
|
||
if two = two then ⊤ else ⊥
|
||
update (const three ⊥) two ⊤ : vector Bool three
|
||
|
||
--------
|
||
@select : ∀ (A : Type) (n : N) (v : vector A n) (i : N), i < n → A
|
||
|
||
map type --->
|
||
@map : ∀ (A B C : Type) (n : N), (A → B → C) → vector A n → vector B n → vector C n
|
||
|
||
map normal form -->
|
||
λ (A B C : Type)
|
||
(n : N)
|
||
(f : A → B → C)
|
||
(v1 : ∀ (i : N), i < n → A)
|
||
(v2 : ∀ (i : N), i < n → B)
|
||
(i : N)
|
||
(H : i < n),
|
||
f (v1 i H) (v2 i H)
|
||
|
||
update normal form -->
|
||
λ (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
|