-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathClase5.Listas.fst
45 lines (35 loc) · 1.09 KB
/
Clase5.Listas.fst
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
module Clase5.Listas
open FStar.List.Tot
val sum_int : list int -> int
let rec sum_int xs =
match xs with
| [] -> 0
| x::xs' -> x + sum_int xs'
(* Demuestre que sum_int "distribuye" sobre la concatenación de listas. *)
let rec sum_append (l1 l2 : list int)
: Lemma (sum_int (l1 @ l2) == sum_int l1 + sum_int l2)
= admit()
(* Idem para length, definida en la librería de F*. *)
let rec len_append (l1 l2 : list int)
: Lemma (length (l1 @ l2) == length l1 + length l2)
= admit()
let rec snoc (xs : list int) (x : int) : list int =
match xs with
| [] -> [x]
| y::ys -> y :: snoc ys x
(* unit-tests *)
let _ = assert (snoc [1;2;3] 4 == [1;2;3;4])
let _ = assert (snoc [1;2;3] 5 == [1;2;3;5])
let rec rev_int (xs : list int) : list int =
match xs with
| [] -> []
| x::xs' -> snoc (rev_int xs') x
let rev_append_int (xs ys : list int)
: Lemma (rev_int (xs @ ys) == rev_int ys @ rev_int xs)
= admit()
let rev_rev (xs : list int)
: Lemma (rev_int (rev_int xs) == xs)
= admit()
let rev_injective (xs ys : list int)
: Lemma (requires rev_int xs == rev_int ys) (ensures xs == ys)
= admit()