@@ -6,15 +6,98 @@ Import ListNotations.
66From Hammer Require Import
77 Tactics.
88
9+ Require Import Setoids.
10+
11+ Open Scope slot_scope.
12+
913Section defn.
1014 Context {A : Type}.
1115
12- Inductive Pick : list A -> A -> list A -> Prop :=
13- | pick_this : forall a l,
14- Pick (a :: l) a l
15- | pick_next : forall a b l l',
16- Pick l a l' ->
17- Pick (b :: l) a (b :: l').
16+ Definition Pick (l : list A) a (l' : list A) : Prop :=
17+ Add a l' l.
18+
19+ (* Lemma permutation_split (a : A) l1 l2 : *)
20+ (* (a :: l1) =p= l2 -> *)
21+ (* exists l3 l4, *)
22+ (* l2 = (l3 ++ a :: l4). *)
23+ (* Admitted. *)
24+
25+ Lemma pick_equiv l1 l1' l2 a :
26+ l1 =p= l1' ->
27+ Pick l1 a l2 ->
28+ exists l2',
29+ Pick l1' a l2' /\ l2 =p= l2'.
30+ (* Proof. *)
31+ (* unfold Pick. intros Hl1 Hl2. *)
32+ (* generalize dependent l1'. *)
33+
34+ (* induction Hl2; intros l1' Hl1. *)
35+ (* - apply Permutation_in with (x := a) in Hl1 as Hl1'. *)
36+ (* + destruct (Add_inv a l1' Hl1') as [l2' Hl2']. *)
37+ (* exists l2'. split. *)
38+ (* * assumption. *)
39+ (* * apply Permutation_Add in Hl2'. *)
40+ (* rewrite <-Hl1 in Hl2'. *)
41+ (* now apply Permutation_cons_inv in Hl2'. *)
42+ (* + now constructor. *)
43+ (* - apply permutation_split in Hl1 as H. *)
44+ (* destruct H as [l3 [l4 Hl34]]. subst. *)
45+ (* rewrite <-Permutation_middle in Hl1. apply Permutation_cons_inv in Hl1. *)
46+ (* specialize (IHHl2 (l3 ++ l4) Hl1). *)
47+ (* destruct IHHl2 as [l5 [Hl5 Hll5]]. *)
48+ (* exists (x :: ). *)
49+ (* split. *)
50+ (* + *)
51+ (* exists (l3 ++ l4). *)
52+
53+
54+
55+
56+
57+ (* Search Permutation. *)
58+ (* induction Hl2. *)
59+ (* - apply Permutation_Add in Hl1. *)
60+ (* apply Permutation_Add in Hl2 as H. rewrite Hl1 in H. clear Hl1. *)
61+
62+ (* induction Hl1. *)
63+ (* 2:{ *)
64+
65+
66+ (* apply Add_split in Hl2. *)
67+ (* destruct Hl2 as [l3 [l4 [Hl3 Hl4]]]. subst. *)
68+ (* Check Permutation_Add. *)
69+
70+ (* induction l1'. *)
71+ (* - exfalso. inversion Hl1. *)
72+ (* now apply Permutation_sym, Permutation_nil_cons in Hl1. *)
73+ (* - *)
74+ (* Check Permutation_cons_app. *)
75+
76+ (* rewrite Permutation_middle in Hl1. *)
77+ (* Search Permutation. *)
78+ (* apply Permutation_cons_inv in H. *)
79+
80+
81+ (* replace (a :: l2) with ([] ++ a :: l2) in Hl1 by now rewrite <-app_nil_l. *)
82+ (* rewrite <-Permutation_middle in Hl1. *)
83+ (* Search Add. *)
84+
85+ (* (* intros Hl1 Hl2. *) *)
86+ (* apply pick_via_app in Hl2 as H. destruct H as [l3 [l4 Hl34]]. subst. *)
87+ (* rewrite <-Permutation_middle in Hl1. *)
88+ (* apply pick_via_permutation2 in Hl1 as Hl5. *)
89+ (* destruct Hl5 as [l5 Hl5]. *)
90+ (* exists l5. *)
91+ (* split. *)
92+ (* - assumption. *)
93+ (* - apply pick_via_permutation in Hl5. *)
94+ (* apply pick_via_permutation in Hl2. *)
95+ (* rewrite <-Permutation_middle in Hl2. *)
96+ (* apply Permutation_cons_inv in Hl2. *)
97+ (* rewrite Hl2. rewrite <-Hl1 in Hl5. *)
98+ (* now apply Permutation_cons_inv, Permutation_sym in Hl5. *)
99+ (* Qed. *)
100+ Admitted .
18101End defn.
19102
20103Section tests.
0 commit comments