Skip to content

Commit 7f2d764

Browse files
List.upto needs to be pushed down, ie called again
on result of first simplification: eg if len l1 = i (l1 ++ l2)[:i] --> l1[:i] --> l1 Actually makes insertion_sort work less well, because it allows ((_ ++ [|_|]) ++ _)[:_] to be turned into (_ ++ _ :: _)[:_] and putting the discard boundary at a cons is not yet supported
1 parent f8050a5 commit 7f2d764

File tree

2 files changed

+256
-68
lines changed

2 files changed

+256
-68
lines changed

LiveVerif/src/LiveVerifExamples/insertion_sort.v

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
(* -*- eval: (load-file "../LiveVerif/live_verif_setup.el"); -*- *)
12
Require Import coqutil.Sorting.Permutation.
23
Require Import LiveVerif.LiveVerifLib.
34
Require Import List Lia.
@@ -49,7 +50,18 @@ Derive insert SuchThat (fun_correct! insert) As insert_ok.
4950
.**/ { /**.
5051
assert (len (sort l1 ++ [|x|]) = \[i]+1) by (rewrite List.len_app; simpl; ZnWords).
5152
.**/ real_insert(p, i); /**.
52-
.**/ } /**.
53+
2: {
54+
replace (sort l1 ++ x :: l2) with ((sort l1 ++ [|x|]) ++ l2) by steps.
55+
rewrite List.upto_app_discard_r by steps.
56+
rewrite List.upto_pastend by steps.
57+
reflexivity.
58+
}
59+
.**/ } /*?.
60+
step. step. step. step. step. step. step. step. step. step. step. step.
61+
step.
62+
change (x :: l2) with ([|x|] ++ l2).
63+
rewrite List.from_app_discard_l.
64+
step. step. cbn. step.
5365
Qed.
5466

5567
(* Insertion sort *)

0 commit comments

Comments
 (0)