-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathListToVect.v
65 lines (52 loc) · 1.89 KB
/
ListToVect.v
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(*
* Section 5 Preprocess Example
*)
Require Import Vector.
Require Import List.
Require Import ZArith.
Require Import Ornamental.Ornaments.
Notation "( x ; y )" := (existT _ x y) (no associativity).
Notation "p .1" := (projT1 p) (left associativity, at level 8, format "p .1").
Notation "p .2" := (projT2 p) (left associativity, at level 8, format "p .2").
Notation "p .&" := (p.1; p.2) (left associativity, at level 6, format "p .&").
Notation vector := Vector.t.
Notation vnil := Vector.nil.
Notation vcons := Vector.cons.
(* --- Preprocess --- *)
Preprocess Module List as List' { opaque (* ignore these: *)
RelationClasses
Nat
Coq.Init.Nat
}.
(* --- Search & Lift --- *)
(* We use automatic search here rather than calling Find Ornament ourselves. *)
Definition list_elim A P : P nil -> (forall x xs, P xs -> P (cons x xs)) -> forall xs, P xs :=
fun H__nil H__cons xs => @list_rect A P H__nil H__cons xs.
Lift list vector in list_elim as vect_elim.
Check (vect_elim :
forall (A : Type) (P : {n : nat & vector A n} -> Type),
P (0; vnil A) ->
(forall (x : A) (xs : {n : nat & vector A n}),
P xs.& -> P (S xs.1; vcons A x xs.1 xs.2)) ->
forall (xs : {n : nat & vector A n}),
P xs.&).
Lift Module list vector in List' as Vector' { opaque (* ignore these, just for speed *)
RelationClasses.Equivalence_Reflexive
RelationClasses.reflexivity
Nat.add
Nat.sub
Nat.lt_eq_cases
Nat.compare_refl
Nat.lt_irrefl
Nat.le_refl
Nat.bi_induction
Nat.central_induction
}.
(*
* There are still two proofs (`partition_length` and `elements_in_partition`)
* that fail to lift above, due to implementation bugs.
* See: https://github.com/uwplse/ornamental-search/issues/32
*
* The effort here is fully automatic, whereas the old tactics don't work for
* the repaired proofs here, so there are obvious development time savings.
*)