Skip to content

Commit

Permalink
List.upto needs to be pushed down, ie called again
Browse files Browse the repository at this point in the history
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
  • Loading branch information
samuelgruetter committed Mar 30, 2023
1 parent f8050a5 commit 7f2d764
Show file tree
Hide file tree
Showing 2 changed files with 256 additions and 68 deletions.
14 changes: 13 additions & 1 deletion LiveVerif/src/LiveVerifExamples/insertion_sort.v
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
(* -*- eval: (load-file "../LiveVerif/live_verif_setup.el"); -*- *)
Require Import coqutil.Sorting.Permutation.
Require Import LiveVerif.LiveVerifLib.
Require Import List Lia.
Expand Down Expand Up @@ -49,7 +50,18 @@ Derive insert SuchThat (fun_correct! insert) As insert_ok.
.**/ { /**.
assert (len (sort l1 ++ [|x|]) = \[i]+1) by (rewrite List.len_app; simpl; ZnWords).
.**/ real_insert(p, i); /**.
.**/ } /**.
2: {
replace (sort l1 ++ x :: l2) with ((sort l1 ++ [|x|]) ++ l2) by steps.
rewrite List.upto_app_discard_r by steps.
rewrite List.upto_pastend by steps.
reflexivity.
}
.**/ } /*?.
step. step. step. step. step. step. step. step. step. step. step. step.
step.
change (x :: l2) with ([|x|] ++ l2).
rewrite List.from_app_discard_l.
step. step. cbn. step.
Qed.

(* Insertion sort *)
Expand Down
Loading

0 comments on commit 7f2d764

Please sign in to comment.