Advertisement
caotic123

Untitled

Feb 20th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 80.91 KB | None | 0 0
  1. From Coq Require Import ssreflect ssrfun ssrbool.
  2. Set Implicit Arguments.
  3. Unset Strict Implicit.
  4. Unset Printing Implicit Defensive.
  5. Require Import Coq.Program.Equality.
  6.  
  7. Require Import Arith_base.
  8. Require Import Vectors.Fin.
  9. Require Import Vectors.VectorDef.
  10. Require Import Bool.
  11.  
  12. Class Lex (A : Set) (FCross : A -> A -> A) (CP : A -> A -> Prop) : Prop := {
  13. transformable : forall (x : A), {P | ~ CP x (P x)};
  14. anti_identity : forall (x y : A), ~ CP x y -> ~ CP x (FCross x y);
  15. convergent_equality : forall (x y : A), x = y -> CP x y;
  16. crossover_identity : forall (y : A), {x | ~ (CP x y) -> CP (FCross x y) y}
  17. }.
  18.  
  19. Record P_Product {B A} {H : Set -> Set} (k : H A) C (perception : forall {x y : B} {k : H A}, C k x -> C k y -> Prop) : Type := P' {
  20. Px : B;
  21. Py : B;
  22. Px' : C k Px;
  23. Py' : C k Py;
  24. PE : perception Px' Py'
  25. }.
  26.  
  27.  
  28. Notation "f ∘ g" := (fun x => f (g x)) (at level 80, right associativity).
  29.  
  30. Section Env.
  31. Variables X B A : Set.
  32. Variable f : X -> X -> X.
  33. Variable f' : X -> X -> bool.
  34. Variable K : Lex f f'.
  35. Variable H : Set -> Set.
  36. Variable C : H A -> B -> Prop.
  37. Variable point : forall x y , C x y -> A.
  38.  
  39. Class Agent (Lex' : Lex f f') (T : Set) := {
  40. memory : T -> X;
  41. perception : forall {x y : B} (k : H A), C k x -> C k y -> Prop;
  42. action : forall {x y : B} (k : H A) (x' : C k x) (y' : C k y), H A -> Prop;
  43. }.
  44.  
  45. Variable AG : Agent K A.
  46.  
  47. Record Functions : Type := F' {
  48. faction : H A -> H A;
  49. flang : H A -> H A
  50. }.
  51.  
  52.  
  53. Record Interation k (P : Functions) : Prop := I' {
  54. consistency_action : forall (Pr : P_Product ((flang P) k) (@perception _ _ AG)),
  55. action (Px' Pr) (Py' Pr) ((faction P) ((flang P)k));
  56.  
  57. knowlegde : forall (Pr : P_Product k (@perception _ _ AG)) (a : C ((flang P) k) (Px Pr)),
  58. memory (point a) = (f (memory (point (Px' Pr))) (memory ((point (Py' Pr)))))
  59.  
  60. }.
  61.  
  62. Class Environment (k : H A) (H' : Functions) : Prop := {
  63. inhabited : forall (x : H A), {b | C x b};
  64. perceived : P_Product k (@perception _ _ AG);
  65. active : forall (k : H A), {y : (B * B) | {c : (C k (fst y) * C k (snd y)) | perception (fst c) (snd c)}};
  66. iterable : Interation k H';
  67. }.
  68.  
  69. Class State {f' g'} {k} := {
  70. inductive_environment :
  71. Environment k (F' f' g') /\ (forall k (x : Environment k (F' f' g')), Environment ((g' ∘ f') k) (F' f' g'));
  72. }.
  73.  
  74.  
  75. End Env.
  76.  
  77. Inductive binary := |zero : binary |one : binary.
  78.  
  79. Inductive lex n :=
  80. |lex' : t binary (S n) -> lex n.
  81.  
  82. Fixpoint invert_binary {y} (x : t binary y) : t binary y.
  83. induction x.
  84. refine (nil _).
  85. destruct h.
  86. refine (cons _ one _ (invert_binary _ x)).
  87. refine (cons _ zero _ (invert_binary _ x)).
  88. Defined.
  89.  
  90. Theorem _not_conservation:
  91. forall n (x : lex n), {P : forall {n} {h : lex n}, lex n | x <> P n x}.
  92. move => x'.
  93. pose (fun y (x : lex y) =>
  94. match x with
  95. |@lex' _ v => @lex' y (invert_binary v)
  96. end).
  97. intros; exists l.
  98. destruct x; simpl; injection; intros.
  99. clear H.
  100. move : H0.
  101. elim/@caseS' : t.
  102. intros.
  103. destruct h.
  104. inversion H0.
  105. inversion H0.
  106. Qed.
  107.  
  108.  
  109. Export VectorNotations.
  110.  
  111. Definition case1 {A} (P : t A 1 -> Type)
  112. (H : forall h, @P [h]) (v: t A 1) : P v :=
  113. match v with
  114. |h :: t => match t with
  115. |nil _ => H h
  116. end
  117. |_ => fun devil => False_ind (@IDProp) devil
  118. end.
  119.  
  120. Definition case_2nat (P : nat -> nat -> Type)
  121. (H : P 0 0) (H' : forall y, P 0 (S y)) (H1 : forall x, P (S x) 0)
  122. (H2 : forall x y, P (S x) (S y))
  123. : forall x y, P x y.
  124. move => x y.
  125. destruct x.
  126. destruct y.
  127. exact H.
  128. refine (H' y).
  129. destruct y.
  130. refine (H1 x).
  131. refine (H2 x y).
  132. Defined.
  133.  
  134. Definition case_2t {A} (P : forall n, t A (S n) -> t A (S n) -> Type)
  135. (H' : forall n a b (t t' : t A n), P _ (a :: t) (b :: t'))
  136. : forall n (x y : t A (S n)), P _ x y.
  137. move => n x.
  138. refine (match x in (t _ (S n)) return (forall (y : (t A (S n))), P n x y) with
  139. |@cons _ k q c => _
  140. end).
  141. elim/@caseS'.
  142. intros.
  143. refine (H' _ k h _ _).
  144. Defined.
  145.  
  146. Search (_ < _).
  147.  
  148. Definition rect_leb (A : Type) (P:forall {n} {y}, t A (S n) -> y < S n -> Type)
  149. (out_of_gas: forall a {n} (H : 0 < (S (S n))) (v: t A (S n)), P (cons _ a _ v) H)
  150. (min_length : forall a (H : 0 < 1) (v: t A 0), P (cons _ a _ v) H)
  151. (rect: forall a {n} {y} (H : S y < (S (S n))) (v: t A (S n)), P v (le_S_n _ _ H) -> P (cons _ a _ v) H) :
  152. forall {n} {y} (H : y < S n) (v: t A (S n)), P v H.
  153. refine (fix rectS_fix {n} {y} (H : y < S n) (v: t A (S n)) {struct v} : P _ _ v H :=
  154. (match v in t _ (S n) return (forall (H : y < S n), P n _ v H) with
  155. |@cons _ a 0 v' =>
  156. (match v' in t _ 0 with
  157. |@nil _ => _
  158. |@cons _ _ l _ => _
  159. end)
  160. |@cons _ a (S nn') v1 => _
  161. |_ => fun devil => False_ind (@IDProp) devil
  162. end) _).
  163.  
  164. intros.
  165. destruct y.
  166. (*that's the fun case*)
  167. refine (min_length a H0 (nil A)).
  168. have : ~ S _ < 1.
  169. case.
  170. move => // h.
  171. apply le_not_lt in h.
  172. assert (2 <= 2).
  173. auto with arith.
  174. tauto.
  175. cbv; intros.
  176. apply le_S_n in H1; apply le_not_lt in H1.
  177. assert(0 < S (S n1)).
  178. auto with arith.
  179. auto.
  180. intros; destruct (x _ H0).
  181. intros; destruct y.
  182. exact idProp.
  183. exact idProp.
  184. intros.
  185. destruct y.
  186. refine (out_of_gas a _ H0 v1).
  187. have : y < S nn'.
  188. auto with arith.
  189. move => H1.
  190. refine (rect a _ _ H0 v1 (rectS_fix _ _ (le_S_n _ _ H0) v1)).
  191. Defined.
  192.  
  193. Definition rect_2per {A} (P : forall n, t A (S n) -> Type)
  194. (H : forall n h a (t : t A (S n)), P _ (a :: t) -> P _ (h :: a :: t))
  195. (H1' : forall h v, @P 1 [h; v])
  196. (H0 : forall h, P 0 [h]):
  197. forall n (x : t A (S n)), P _ x.
  198.  
  199. refine (fix fix_S n (v : t A (S n)) {struct v} : P n v := _).
  200. refine (match v as c in (t _ (S n)) return P n c with
  201. |cons _ h 0 v' => match v' with
  202. |@nil _ => _
  203. end
  204. | cons _ a (S (S n')) v' => _ (fix_S _ v')
  205. | cons _ a 1 v1 => _
  206. | _ => fun devil => False_rect (@IDProp) devil
  207. end).
  208.  
  209. elim/@case0 : v'; refine (H0 _).
  210. elim/@caseS' : v1; intros.
  211. elim/@case0 : t; refine (H1' _ _).
  212. elim/@caseS' : v'; intros.
  213. elim/@caseS' : v; intros.
  214. refine (H _ a h _ x).
  215. Defined.
  216.  
  217. (*
  218. Inductive vec_ind {A} (P : forall n, t A (S n) -> Type)
  219. : forall {n} (v : t A (S n)), Type :=
  220. |bas : forall e, P 0 [e] -> vec_ind P [e]
  221. |bas2 : forall e h, P 1 [e;h] -> vec_ind P [e; h]
  222. |ind : forall n' (x : t A (S n')) e, vec_ind P x -> P _ (cons _ e _ x) -> @vec_ind A P (S n') (cons _ e _ x).
  223.  
  224.  
  225. Definition v_ind {A n} (v : t A (S n)) P : vec_ind P v -> A.
  226. elim.
  227. refine (fun e H => e).
  228. refine (fun e h H => e).
  229. intros.
  230. exact e.
  231. Defined.
  232.  
  233. Definition rect_2per {A} (P : forall n, t A (S n) -> Type)
  234. (H : forall n h a (t : t A (S n)) (v : vec_ind P (h :: t)), P _ (a :: t) ->
  235. P _ (h :: (v_ind v) :: t))
  236. (H1' : forall h v, P _ [h;v])
  237. (H0 : forall h, P _ [h]):
  238. forall n (x : t A (S n)), vec_ind P x.
  239.  
  240. refine (fix fix_S n (v : t A (S n)) {struct v} : vec_ind P v := _).
  241. refine (match v as c in (t _ (S n)) return vec_ind P c with
  242. |cons _ h 0 v' => match v' with
  243. |@nil _ => _
  244. end
  245. | cons _ a (S (S n')) v' => _ (fix_S _ v')
  246. | cons _ a 1 v1 => _
  247. | _ => fun devil => False_rect (@IDProp) devil
  248. end).
  249.  
  250.  
  251. elim/@case0 : v'; refine (bas (H0 _)).
  252. elim/@caseS' : v1; intros.
  253. elim/@case0 : t.
  254. refine (bas2 (H1' _ _)).
  255. move => H3.
  256. elim/@caseS' : v' H3; intros.
  257. pose (H _ _ h _ H3).
  258.  
  259. refine (p a h _ x).
  260. Defined.
  261.  
  262. *)
  263.  
  264.  
  265. Definition rect_SS' {A} (P : forall n, t A (S n) -> Type)
  266. (H : forall n h a (t : t A (S n)), P _ t -> P _ (a :: h :: t)) (H' : forall h, @P 0 [h]) (H1' : forall h v, @P 1 [h; v]) : forall n (x : t A (S n)), P _ x.
  267.  
  268. refine (fix fix_S n (v : t A (S n)) {struct v} : P n v := _).
  269. refine (match v as c in (t _ (S n)) return P n c with
  270. |cons _ h 0 v' => match v' with
  271. |@nil _ => _
  272. end
  273. | cons _ h 1 v1 => _
  274. | cons _ a (S (S n')) v' => _
  275. | _ => fun devil => False_rect (@IDProp) devil
  276. end).
  277.  
  278. intros.
  279. refine (H' h).
  280. intros.
  281. refine (match v1 with
  282. |@cons _ k 0 q => match q in (t _ 0) with
  283. |@nil _ => _
  284. end
  285. end).
  286.  
  287. refine (H1' h k).
  288. refine (match v' as c in (t _ (S (S n'))) return P (S (S n')) (a :: c) with
  289. |@cons _ k n q => _
  290. end).
  291.  
  292. destruct n.
  293. exact idProp.
  294. refine (H _ k a _ (fix_S _ q)).
  295.  
  296. Defined.
  297.  
  298.  
  299. Definition rect_2S {A B} (P:forall {n}, t A (S n) -> t B (S n) -> Type)
  300. (bas : forall x y, P [x] [y]) (rect : forall {n} (v1 : t A (S n)) (v2 : t B (S n)), P v1 v2 ->
  301. forall a b, P (a :: v1) (b :: v2)) :
  302. forall {n} (v1 : t A (S n)) (v2 : t B (S n)), P v1 v2.
  303.  
  304. refine (fix rect2_fix {n} (v1 : t A (S n)) : forall v2 : t B (S n), P _ v1 v2 :=
  305. match v1 in t _ (S n) with
  306. | [] => idProp
  307. | @cons _ h1 (S n') t1 => fun v2 =>
  308. caseS' v2 (fun v2' => P _ (h1::t1) v2') (fun h2 t2 => rect _ _ _ (rect2_fix t1 t2) h1 h2)
  309. |cons _ a 0 x' => fun (v2 : t B 1) => _
  310. end).
  311.  
  312. elim/@case0 : x'.
  313. refine (match v2 with
  314. |cons _ b 0 y' => match y' with
  315. |nil _ => _
  316. |_ => _
  317. end
  318. end).
  319.  
  320. elim/@case0 : y'.
  321. refine (bas a b).
  322. exact idProp.
  323. Defined.
  324.  
  325. Fixpoint cross_binary_vector {n} (x : t binary (S n)) (y : t binary (S n)) : t binary (S n).
  326. elim/@rect_2S : x/y.
  327. intros.
  328. refine (cons _ (match (x, y) with
  329. |(one, one) => one
  330. |(zero, zero) => zero
  331. |(x', y') => y'
  332. end) _ (nil _)) .
  333. intros.
  334. refine (match (a, b) with
  335. |(one, one) => (cons _ a _ (cross_binary_vector _ v1 v2))
  336. |(zero, zero) => (cons _ a _ (cross_binary_vector _ v1 v2))
  337. |(x', y') => (cons _ b _ v1)
  338. end).
  339.  
  340. Defined.
  341.  
  342.  
  343. Definition cross_lex {n} (x : lex n) (y : lex n) : lex n.
  344. constructor.
  345. destruct x.
  346. destruct y.
  347. refine (cross_binary_vector t t0).
  348. Defined.
  349.  
  350.  
  351. Definition b_rect (P : binary -> binary -> Type) (H : P one one) (H' : P zero zero) (H1' : P one zero) (H2' : P zero one) (x y : binary) : P x y.
  352. intros.
  353. destruct x.
  354. destruct y.
  355. move => //=.
  356. move => //=.
  357. destruct y.
  358. move => //=.
  359. move => //=.
  360. Defined.
  361.  
  362. Theorem crossover_binary :
  363. forall n
  364. (x : t binary (S n))
  365. (y : t binary (S n)),
  366. x <> y ->
  367. x <> cross_binary_vector x y.
  368.  
  369. have : forall t t0, lex' t <> lex' t0 -> t <> t0.
  370. intros.
  371. cbv in H.
  372. cbv.
  373. move => h'.
  374. have : lex' t = lex' t0.
  375. congruence.
  376. tauto.
  377.  
  378. have : forall n h x y, cons _ n h x <> cons _ n h y -> x <> y.
  379. intros.
  380. move => H'.
  381. congruence.
  382. move => H'.
  383.  
  384. have : forall h n x y, x <> y -> cons _ n h x <> cons _ n h y.
  385. intros.
  386. move => H2'.
  387. pose (fun a n (x : t a (S n)) => match x in (t _ (S n)) with
  388. |@cons _ _ _ x => x
  389. end).
  390. pose (@f_equal (t T (S h)) (t T h) (@y0 _ _) _ _ H2').
  391. simpl in e.
  392. tauto.
  393. move => K.
  394.  
  395. intros.
  396. move : H; elim/@rect_2S : y/x0.
  397. intros; unfold cross_binary_vector; simpl in *.
  398. by move : H; elim/@b_rect : x0/y.
  399. intros; move : H0 H; elim/@b_rect : a/b.
  400. intros.
  401. unfold cross_binary_vector; simpl; fold @cross_binary_vector.
  402. apply H' in H0; apply H in H0.
  403. auto.
  404. intros.
  405. unfold cross_binary_vector; simpl; fold @cross_binary_vector.
  406. apply H' in H0; apply H in H0;apply : K.
  407. trivial.
  408. intros.
  409. unfold cross_binary_vector; simpl; fold @cross_binary_vector.
  410. move => H2'.
  411. inversion H2'.
  412. intros.
  413. unfold cross_binary_vector; simpl; fold @cross_binary_vector.
  414. move => H2';inversion H2'.
  415. Qed.
  416.  
  417. Definition eq_vector_binary : forall (n : nat), t binary n -> t binary n -> bool.
  418. pose (fun (x y : binary) => match (x, y) with
  419. |(one, one) => true
  420. |(zero, zero) => true
  421. |(x, y) => false
  422. end).
  423.  
  424. refine (fix fix_S n (t t0 : t binary n) {struct t} := _).
  425. elim/@rect2 : t/t0.
  426. refine (true).
  427. intros;refine ((b a b0) && (fix_S _ v1 v2)).
  428. Defined.
  429.  
  430. Definition lex_binary : forall (n : nat), lex n -> lex n -> bool.
  431. intros.
  432. destruct H.
  433. destruct H0.
  434. refine (eq_vector_binary t t0).
  435. Defined.
  436.  
  437. Theorem lex_vec_eq : forall n (v y : t binary (S n)), eq_vector_binary v y = true -> v = y.
  438. intros.
  439. move : H.
  440. elim/@rect_2S : v/y.
  441. move => x y.
  442. elim/b_rect : x/y.
  443. trivial.
  444. trivial.
  445. simpl in *; congruence.
  446. simpl in *; congruence.
  447. intros.
  448. move : H0.
  449. elim/b_rect : a/b.
  450. - intros; simpl in *; apply H in H0; congruence.
  451. - intros; simpl in *; apply H in H0; congruence.
  452. - intros; simpl in *; congruence.
  453. - intros; simpl in *; congruence.
  454. Qed.
  455.  
  456. Theorem lex_eq : forall n (v y : lex n), lex_binary v y = true -> v = y.
  457. intros.
  458. destruct v. destruct y.
  459. unfold lex_binary in H.
  460. pose (lex_vec_eq H).
  461. congruence.
  462. Qed.
  463.  
  464. Definition lex_prop : forall (n : nat), lex n -> lex n -> Prop.
  465. intros.
  466. exact (lex_binary H H0 = true).
  467. Defined.
  468.  
  469. Fixpoint imperfect_binary_cpy {n} (x : t binary (S n)) : t binary (S n).
  470. elim/@rectS : x.
  471. case.
  472. exact (cons _ one _ (nil _)).
  473. exact (cons _ zero _ (nil _)).
  474. intros.
  475. refine (cons _ a _ (imperfect_binary_cpy _ v)).
  476. Defined.
  477.  
  478. Theorem unique_binary_object_convergent_complement {n} (y : t binary (S n)) :
  479. {x | x <> y -> cross_binary_vector x y = y}.
  480. exists (imperfect_binary_cpy y).
  481. move : y; elim/@rectS.
  482. case => //=.
  483. case => //= H' V hi h.
  484. have : imperfect_binary_cpy V <> V.
  485. congruence.
  486. move => H.
  487. have : cross_binary_vector (imperfect_binary_cpy V) V = V.
  488. apply : hi H; move => H3.
  489. congruence.
  490. have : imperfect_binary_cpy V <> V.
  491. congruence.
  492. move => H.
  493. have : cross_binary_vector (imperfect_binary_cpy V) V = V.
  494. apply : hi H; move => H3.
  495. congruence.
  496. Qed.
  497.  
  498. Theorem lex_binary_eqv : forall {n} (m : lex n), lex_binary m m = true.
  499. intros.
  500. destruct m.
  501. elim/@rectS : t.
  502. by destruct a.
  503. by elim.
  504. Qed.
  505.  
  506.  
  507. Theorem neg_of_convergent_lex : forall n (x : lex n) y, x <> y -> lex_binary x y = false.
  508.  
  509. have : forall x y, lex_binary x y = false -> ~ lex_binary x y = true.
  510. move => n0 x0 y0.
  511. destruct (lex_binary x0 y0).
  512. move => h2.
  513. inversion h2.
  514. move => H2 H3.
  515. inversion H3.
  516.  
  517. intros.
  518. destruct x0.
  519. destruct y.
  520. move : H.
  521. elim/@rect_2S : t/t0.
  522. move => x0 y.
  523. elim/@b_rect : x0/y.
  524. intros.
  525. destruct H.
  526. auto.
  527. intros.
  528. destruct H.
  529. auto.
  530. auto.
  531. intros.
  532. done.
  533. intros.
  534. move : H H0.
  535. pose (fun n (x : t binary (S n)) => match x in t _ (S n) with
  536. |a :: b => b
  537. end).
  538. pose (fun n (x : t binary (S n)) => match x in t _ (S n) with
  539. |a :: b => a
  540. end).
  541. have : forall x v v', lex' (x :: v) <> lex' (x :: v') -> lex' v <> lex' v'.
  542. case => n1. elim/@caseS'.
  543. move => h n2; elim/@caseS'.
  544. move => h0; elim/@case0.
  545. elim/@case0 : n2.
  546. intros; move => H2.
  547. injection H2; move => n2; subst.
  548. by contradiction H.
  549. intros.
  550. move => H2'.
  551. have : v = v'.
  552. congruence.
  553. move => H3; rewrite H3 in H.
  554. by contradiction H.
  555. move => H2'.
  556. elim/@b_rect : a/b.
  557. intros; simpl in *; apply H2' in H0.
  558. tauto.
  559. intros; apply H2' in H0; tauto.
  560. intros; trivial.
  561. intros; trivial.
  562. Qed.
  563.  
  564. Theorem neg_of_convergent_lex' : forall n (x : lex n) y, lex_binary x y = false -> x <> y.
  565.  
  566. have : forall x y, lex_binary x y = false -> ~ lex_binary x y = true.
  567. move => n0 x0 y0.
  568. destruct (lex_binary x0 y0).
  569. move => h2.
  570. inversion h2.
  571. move => H2 H3.
  572. inversion H3.
  573.  
  574. intros.
  575. apply x in H.
  576. move => H2.
  577. destruct x0.
  578. destruct y.
  579. move : H2 H.
  580. elim/@rect_2S : t/t0.
  581. move => x0 y.
  582. elim/@b_rect : x0/y.
  583. auto.
  584. auto.
  585. intros; inversion H2.
  586. intros; inversion H2.
  587. move => n0 v1 v2 H a b.
  588.  
  589. pose (fun n (x : t binary (S n)) => match x in t _ (S n) with
  590. |a :: b => b
  591. end).
  592.  
  593. elim/@b_rect : a/b.
  594. intros.
  595. simpl in *.
  596. have : one :: v1 = one :: v2.
  597. congruence.
  598. move => e'.
  599. apply (@f_equal _ _ (@y (S n0))) in e'; simpl in e'.
  600. have : lex' v1 = lex' v2.
  601. congruence.
  602. auto.
  603. intros.
  604. simpl in *.
  605. have : zero :: v1 = zero :: v2.
  606. congruence.
  607. move => e'.
  608. apply (@f_equal _ _ (@y (S n0))) in e'; simpl in e'.
  609. have : lex' v1 = lex' v2.
  610. congruence.
  611. auto.
  612. intros.
  613. inversion H2.
  614. intros.
  615. inversion H2.
  616. Qed.
  617.  
  618.  
  619. Fixpoint pow_f' {A} (x : nat) (f : A -> A) {struct x} : x > 0 -> (A -> A).
  620. refine (match x with
  621. |(S x') => (fun x' => match x' as c return c = x' -> S c > 0 -> A -> A with
  622. |S y => _
  623. |0 => _
  624. end) x' eq_refl
  625. |0 => fun H => match ((gt_irrefl 0) H) with end
  626. end).
  627. refine (fun e h => f).
  628. intros.
  629. have : S y > 0.
  630. auto with arith.
  631. move => H2.
  632. rewrite H in H2.
  633. move : X.
  634. refine ((pow_f' _ _ f H2) ∘ f).
  635. Defined.
  636.  
  637. Fixpoint pow_f {A} (f : A -> A) (x : nat) {struct x} : A -> A :=
  638. match x with
  639. |(S x') => f ∘ (pow_f f x')
  640. |0 => f
  641. end.
  642.  
  643. Fixpoint pow_tf {A} (f : A -> A) (y : A) (x : nat) {struct x} : A :=
  644. match x with
  645. |(S x') => f (pow_f f x' y)
  646. |0 => f y
  647. end.
  648.  
  649. Theorem fpow_eq_cons : forall n1 l g (v3 v0 : t binary (S n1)), g
  650. :: cross_binary_vector
  651. (pow_f (cross_binary_vector^~ v3) l v0) v3 =
  652. cross_binary_vector
  653. (pow_f (cross_binary_vector^~ (g :: v3)) l (g :: v0))
  654. (g :: v3).
  655.  
  656. intros.
  657. induction l.
  658. simpl in *.
  659. by destruct g.
  660.  
  661. move : IHl.
  662. elim/@rect_2S : v3/v0.
  663. Ltac finish_feqv g IHl := intros; destruct g; simpl; by rewrite <- IHl.
  664. by finish_feqv g IHl.
  665. by finish_feqv g IHl.
  666. Qed.
  667.  
  668. Theorem fpow_eq_cons' : forall n1 l g w (v3 v0 : t binary (S n1)), w <> g ->
  669. g :: (pow_f (cross_binary_vector^~ v3) l v0) =
  670. (pow_f (cross_binary_vector^~ (g :: v3)) (S l) (w :: v0)).
  671.  
  672.  
  673. intros.
  674. move : H.
  675. induction l.
  676. elim/@b_rect : w/g.
  677. congruence.
  678. congruence.
  679. trivial.
  680. trivial.
  681. intros.
  682. apply IHl in H; clear IHl; simpl in *.
  683. rewrite <- H; simpl in *.
  684. by destruct g.
  685. Qed.
  686.  
  687. Theorem cross_eq : forall n (v2 : t binary (S n)), (cross_binary_vector v2 v2) = v2.
  688. move => n; elim/@rectS.
  689. by destruct a.
  690. intros.
  691. destruct a.
  692. simpl; by rewrite H.
  693. simpl; by rewrite H.
  694. Qed.
  695.  
  696. Theorem convergent_pair_totally : forall {n} (x y : t binary (S n)), eq_vector_binary ((pow_f (fun x => cross_binary_vector x y) (S n)) x) y = true.
  697. intros.
  698. elim/@rect_2S : x/y.
  699. intros.
  700. by elim/@b_rect : x/y.
  701. move => n0 v1 v2.
  702. intros.
  703. simpl in *.
  704. have : one <> zero.
  705. congruence.
  706. move => pH.
  707. elim/@b_rect : a/b.
  708. Ltac solve_powf_cross v1 v2 H :=
  709. rewrite <- (fpow_eq_cons _ _ v1 v2);
  710. simpl;
  711. rewrite (lex_vec_eq H);
  712. rewrite (cross_eq _);
  713. set f := (@lex_binary_eqv _ (lex' v1)).
  714.  
  715. Ltac solve_powf_cross' n0 v1 v2 H v v' proof_inv' :=
  716. change
  717. (cross_binary_vector
  718. (pow_f (cross_binary_vector^~ (_ :: v2)) _ (_ :: v1))
  719. (_ :: v2)) with
  720. (pow_f (cross_binary_vector^~ (v' :: v2))
  721. (S n0) (v :: v1));
  722. rewrite <- (fpow_eq_cons' _ v2 v1 proof_inv');
  723. simpl;
  724. rewrite <- H.
  725.  
  726. by solve_powf_cross v2 v1 H.
  727. by solve_powf_cross v2 v1 H.
  728. by solve_powf_cross' n0 v1 v2 H one zero pH.
  729. by solve_powf_cross' n0 v1 v2 H zero one (not_eq_sym pH).
  730. Qed.
  731.  
  732. Definition pure_lex l n := t (t binary (S l)) (S n).
  733.  
  734. Instance binary_lex : forall x, Lex (@cross_lex x) (@lex_prop x).
  735. {
  736.  
  737. constructor.
  738.  
  739. (* The proof of lex transform *)
  740. intros.
  741. pose (_not_conservation x0).
  742. destruct s.
  743. exists (x1 x).
  744. apply not_true_iff_false.
  745. apply (neg_of_convergent_lex).
  746. trivial.
  747.  
  748. (*Anti-identity proof of crossover function *)
  749. intros.
  750. destruct x0.
  751. destruct y.
  752. unfold lex_prop in *.
  753. apply not_true_iff_false.
  754.  
  755. apply not_true_is_false in H.
  756. apply neg_of_convergent_lex.
  757. apply neg_of_convergent_lex' in H.
  758. move => H2.
  759. unfold cross_lex in H2.
  760. have : t <> t0.
  761. congruence.
  762. move => H2'.
  763. pose (@crossover_binary _ _ _ H2').
  764. congruence.
  765.  
  766. (*Convergence implies to definitional equality *)
  767. intros.
  768. unfold lex_prop.
  769. rewrite H.
  770. clear H x0.
  771. apply : lex_binary_eqv.
  772.  
  773. (*Existence of Convergence aproximation from x to y*)
  774. intros.
  775. destruct y.
  776. destruct (unique_binary_object_convergent_complement t).
  777. exists (lex' x0).
  778. move => H'.
  779. unfold lex_prop in *.
  780.  
  781. apply not_true_is_false in H'.
  782. have : x0 <> t.
  783. set (neg_of_convergent_lex' H'); congruence.
  784. move => H.
  785. apply e in H.
  786. unfold cross_lex.
  787. rewrite H.
  788. apply : lex_binary_eqv.
  789. }
  790. Defined.
  791.  
  792. Inductive SAgent n :=
  793. T' : lex n -> SAgent n.
  794.  
  795. Definition agent_lex {n} (x : SAgent n) :=
  796. match x with
  797. |@T' _ l => l
  798. end.
  799.  
  800. Fixpoint len {a} {n} (x : t a n) :=
  801. match x with
  802. |_ :: y => (len y) + 1
  803. |[] => 0
  804. end.
  805.  
  806.  
  807. (*The class Agent is just a proof that there is a depedent product of a lex
  808. and one construction and the depedent product carry a memory that map the construction
  809. with one lexical memory *)
  810.  
  811. Definition get_agent {n} {l} (ls : t (SAgent n) l) (y : nat) (H : y < l) : SAgent n := nth_order ls H.
  812.  
  813. Definition boundness {n} {l} (ls : t (SAgent n) l) (y : nat) : Prop := y < l.
  814.  
  815. Definition view {l} {n} {y} {y'} (v : t (SAgent n) (S l)) (H : y < (S l)) (H' : y' < (S l)) :=
  816. (y =? 0) && (y' =? l) = true.
  817.  
  818. Definition action_prop {l} {n} {y} {y'} (v : t (SAgent n) (S l)) (H : y < S l) (H' : y' < S l) : t (SAgent n) (S l) -> Prop.
  819. move => v'.
  820. refine (get_agent v H = get_agent v' H').
  821. Defined.
  822.  
  823. Definition match_lex {l} {n} (v : t (SAgent n) (S l)) : t (SAgent n) (S l).
  824.  
  825. have : 0 < S l /\ l < S l.
  826. auto with arith.
  827. move => h.
  828. destruct h.
  829. set f' := v[@of_nat_lt H].
  830. set s' := v[@of_nat_lt H0].
  831.  
  832. exact (replace (replace v (of_nat_lt H0) (T' (cross_lex (agent_lex s') (agent_lex f'))))
  833. (of_nat_lt H) (T' (cross_lex (agent_lex f') (agent_lex s')))).
  834.  
  835. Defined.
  836.  
  837. Instance SAgent' : forall x y, @Agent _ _ _ _ _ (
  838. fun x => t x (S y)) (@boundness x _) (binary_lex x) (SAgent x). {
  839. constructor.
  840. refine (@agent_lex x).
  841. move => x0 y0.
  842. exact view.
  843. move => x0 y0.
  844. exact action_prop.
  845. }
  846. Defined.
  847.  
  848.  
  849. Definition tail := (fun a n (v : t a (S n)) => match v in (t _ (S n)) with
  850. |@cons _ _ _ v' => v'
  851. |@nil _ => idProp
  852. end).
  853.  
  854. Theorem head_get : forall a n (x : t a (S n)) (H : 0 < (S n)), hd x = nth x (Fin.of_nat_lt H).
  855. intros.
  856. move : H.
  857. by elim/@caseS : x.
  858. Qed.
  859.  
  860. Theorem last_tail : forall a n (x : t a (S n)) (H : n < (S n)), last x = nth x (Fin.of_nat_lt H).
  861. intros.
  862. move : H.
  863. elim/@rectS : x.
  864. intros.
  865. by simpl.
  866. intros.
  867. simpl in *.
  868. generalize (lt_S_n n0 (S n0) H0).
  869. move => t.
  870. pose (H t).
  871. trivial.
  872. Qed.
  873.  
  874. Theorem shift_hd_get' : forall A n (x : t A (S n)) (H : n < (S n)) (a : A), (shiftin a x)[@FS (Fin.of_nat_lt H)] = a.
  875. intros.
  876. move : H.
  877. elim/@rect_SS' : x.
  878. intros.
  879. simpl in *.
  880. by set (H (lt_S_n n0 (S n0)
  881. (lt_S_n (S n0)
  882. (S (S n0)) H0))).
  883. trivial.
  884. intros.
  885. simpl in *.
  886. trivial.
  887. Defined.
  888.  
  889. Theorem of_nat_lt_c : forall x y (v : x < y) (v' : x < y), of_nat_lt v = of_nat_lt v'.
  890. move => x y.
  891. elim/@nat_double_ind : x/y.
  892. intros.
  893. destruct n.
  894. inversion v.
  895. simpl in *; trivial.
  896. intros;inversion v.
  897. intros.
  898. set (H (lt_S_n n m v) (lt_S_n n m v')); simpl in *; rewrite e.
  899. reflexivity.
  900. Qed.
  901.  
  902. Definition shift {l} {n} (v : t (SAgent n) (S l)) : t (SAgent n) (S l).
  903. destruct l.
  904. exact v.
  905. destruct l.
  906. refine (cons _ (hd (tail v)) _ (cons _ (hd v) _ (nil _))).
  907. refine (shiftin (hd v) (tail v)).
  908. Defined.
  909.  
  910.  
  911. Theorem inj : forall n l (x y : t (SAgent n) (S l)), shift x = shift y -> x = y.
  912. have : forall a b v1 v2, shiftin a v1 = shiftin b v2 -> v1 = v2 /\ a = b.
  913. intros.
  914. move : H.
  915. elim/@rect2 : v1/v2.
  916. constructor; trivial.
  917. simpl in H; congruence.
  918. intros.
  919. simpl in *.
  920. pose (fun n (x : t T (S n)) => match x in (t _ (S n)) with
  921. |@cons _ _ _ y => y
  922. end).
  923. pose (fun n (x : t T (S n)) => match x in (t _ (S n)) with
  924. |@cons _ x _ _ => x
  925. end).
  926. set (f_equal (@y0 _) H0).
  927. set (f_equal (@y _) H0).
  928. simpl in *.
  929. apply H in e0.
  930. destruct e0.
  931. constructor.
  932. congruence.
  933. trivial.
  934.  
  935. intros; move : H.
  936. elim/@rect_2S : x0/y.
  937. trivial.
  938. intros.
  939. destruct n0.
  940. simpl in H0; injection H0; move : H H0.
  941. elim/@caseS' : v1; elim/@caseS' : v2.
  942. move => h t h0 t0.
  943. elim/@case0 : t; elim/@case0 : t0.
  944. intros.
  945. simpl in *; subst; trivial.
  946. simpl in *.
  947. destruct n0.
  948. by destruct (@x _ _ a b _ _ H0); subst.
  949. by destruct (@x _ _ a b _ _ H0); subst.
  950. Qed.
  951.  
  952. Theorem shift_back : forall n s (x : t (SAgent s) (S n)) (H : n < S n) (H' : 0 < S n), (shift x)[@of_nat_lt H] = x[@of_nat_lt H'].
  953. move => n s.
  954. elim/@rect_SS'.
  955. intros;simpl in *; apply : shift_hd_get'.
  956. done.
  957. done.
  958. Qed.
  959.  
  960. Theorem law1 : forall l y (k : t (SAgent l) (S y)) (x' : y < S y) (y' : 0 < S y), get_agent (match_lex k) y' = get_agent (shift (match_lex k)) x'.
  961. intros.
  962. move : x' y'.
  963. unfold get_agent.
  964. unfold nth_order.
  965. elim/@rectS : k.
  966. done.
  967. destruct n.
  968. done.
  969. simpl; unfold caseS'.
  970. elim/@caseS'.
  971. intros;move : H; elim/@caseS' : t.
  972. intros;symmetry.
  973. apply : shift_hd_get'.
  974. Qed.
  975.  
  976. Theorem law2 : forall l y (k : t (SAgent l) (S y)) (x' : y < S y) (y' : 0 < S y), agent_lex (match_lex k)[@of_nat_lt y'] = cross_lex (agent_lex k[@of_nat_lt y']) (agent_lex k[@of_nat_lt x']).
  977. move => l y.
  978. elim/@rectS.
  979. intros; trivial.
  980. intros; simpl in *.
  981. by rewrite (of_nat_lt_c (lt_S_n n (S n) (le_n (S (S n)))) (lt_S_n n (S n) x')).
  982. Qed.
  983.  
  984. Definition binary_crossing {l n} (x : pure_lex l n) : pure_lex l n :=
  985. shiftin (cross_binary_vector (hd x) (last x)) (tl x) .
  986.  
  987. Fixpoint binary_crossing' {l n} (x : pure_lex l n) {struct x} : pure_lex l n.
  988. elim/@rectS : x.
  989. intros.
  990. refine (cons _ a _ (nil _)).
  991. intros.
  992. refine (_ (binary_crossing' _ _ v)).
  993. move => K.
  994. elim/@caseS' : K.
  995. intros.
  996. refine (cons _ (cross_binary_vector a h) _ (h :: t)).
  997. Show Proof.
  998. Defined.
  999.  
  1000. Require Import FunInd.
  1001.  
  1002. Fixpoint cut_binary {l n} (x : pure_lex (S l) n) : pure_lex l n.
  1003. elim/@rectS : x.
  1004. refine (fun a => cons _ (take _ (le_S _ _(le_n (S l))) a) _ (nil _)).
  1005. intros.
  1006. refine (cons _ (take _ (le_S _ _(le_n (S l))) a) _ (cut_binary _ _ v)).
  1007. Defined.
  1008.  
  1009. Definition whole_crossing {l n} (x : pure_lex l n) : pure_lex l n :=
  1010. pow_f binary_crossing (S l) (pow_f binary_crossing (S n) x).
  1011.  
  1012. Definition equal_binary (x y : binary) : bool := match (x, y) with
  1013. |(one, one) => true
  1014. |(zero, zero) => true
  1015. |(_, _) => false
  1016. end.
  1017.  
  1018. Fixpoint eq_vec_partial_eqv {l} (x : t binary (S l)) (y : t binary (S l)) n (H : n < S l) : Prop.
  1019. intros;elim/@rect_leb : x/H y.
  1020. intros;elim/@caseS' : y.
  1021. intros.
  1022. refine (equal_binary a h = true).
  1023. intros; elim/@caseS' : y.
  1024. intros. refine (equal_binary a h = true).
  1025. intros; elim/@caseS' : y0.
  1026. intros.
  1027. refine ((equal_binary a h = true) /\ eq_vec_partial_eqv _ v t _ (le_S_n _ _ H)).
  1028. Defined.
  1029.  
  1030. Fixpoint eq_vec_binary_quantification {l} (x : t binary (S l)) (y : t binary (S l)) : nat -> nat.
  1031. elim/@rect_2S : x/y.
  1032. refine (fun x y n => match (x, y) with
  1033. |(one, one) => n + 1
  1034. |(zero, zero) => n + 1
  1035. |(_, _) => n
  1036. end).
  1037. intros.
  1038. refine (match (a, b) with
  1039. |(one, one) => eq_vec_binary_quantification _ v1 v2 H0 + 1
  1040. |(zero, zero) => eq_vec_binary_quantification _ v1 v2 H0 + 1
  1041. |(_, _) => H0
  1042. end).
  1043. Defined.
  1044.  
  1045. Definition eqv_progress {n y} (b : binary) (H : y < S n) (v : t binary (S n)) : Prop.
  1046. intros.
  1047. refine (nth v (of_nat_lt H) = b).
  1048. Defined.
  1049.  
  1050. Fixpoint count_progress {n} (v v' : t binary (S n)) (y' : nat) {struct v} : nat.
  1051. intros.
  1052. pose (fun x y (f : nat) f' => match (x, y) with
  1053. |(one, one) => f
  1054. |(zero, zero) => f
  1055. |(_, _) => f'
  1056. end).
  1057.  
  1058. elim/@rect_2S : v/v'.
  1059. intros.
  1060. refine (n0 x y (y' + 1) y').
  1061. intros.
  1062. refine ((n0 a b ((count_progress _ v1 v2 y') + 1) (count_progress _ v1 v2 y'))).
  1063. Show Proof.
  1064. Defined.
  1065.  
  1066. Theorem count_sym : forall n (v1 v2 : t binary (S n)),
  1067. (count_progress v2 v1 0) = (count_progress v1 v2 0).
  1068.  
  1069. intros.
  1070. elim/@rect_2S : v1/v2.
  1071. intros; by elim/@b_rect : x/y.
  1072. intros.
  1073. elim/@b_rect : a/b.
  1074. simpl in *; auto.
  1075. simpl in *; auto.
  1076. simpl in *; auto.
  1077. simpl in *; auto.
  1078. Qed.
  1079.  
  1080. Theorem despesero : forall {n} (x y : t binary (S n)), last x <> last y ->
  1081. count_progress y (cross_binary_vector x y) 0 =
  1082. S (count_progress x y 0).
  1083. intros.
  1084. move : H.
  1085. elim/@rect_2S : x/y.
  1086. intros.
  1087. move : H.
  1088. by elim/@b_rect : x/y.
  1089. intros.
  1090. move : H0.
  1091. elim/@b_rect : a/b.
  1092. intros; simpl in *; apply H in H0; by rewrite H0.
  1093. intros;simpl in *; apply H in H0; by rewrite H0.
  1094. intros; apply H in H0; simpl in *; rewrite <- (plus_n_Sm _ _); rewrite <- (plus_n_O _); by rewrite <- (count_sym _ _).
  1095. intros; apply H in H0; simpl in *; rewrite <- (plus_n_Sm _ _); rewrite <- (plus_n_O _); by rewrite <- (count_sym _ _).
  1096. Qed.
  1097.  
  1098. Theorem shift_hd : forall {A n} (x : t A (S n)) h,
  1099. hd (shiftin h x) = (hd x).
  1100. intros.
  1101. induction n.
  1102. elim/@caseS' : x.
  1103. move => h0.
  1104. by elim/@case0.
  1105. by elim/@caseS' : x.
  1106. Qed.
  1107.  
  1108. Fixpoint prop_list {A n}
  1109. (v : t A (S n)) (P : A -> A -> Prop) {struct v} : Prop.
  1110. intros.
  1111. elim/@rectS: v.
  1112. intros.
  1113. refine (P a a).
  1114. intros.
  1115. clear X.
  1116. refine (_ (prop_list _ _ v P)).
  1117. move => K.
  1118. elim/@caseS' : v.
  1119. move => a' v'.
  1120. exact (P a a' /\ K).
  1121. Defined.
  1122.  
  1123. Fixpoint to_back {A n} (x : t A n) (y : A) {struct x} : t A n.
  1124. destruct n.
  1125. refine (nil _).
  1126. elim/@rectS : x.
  1127. intros;refine (cons _ y _ (nil _)).
  1128. intros;refine (cons _ a _ (to_back _ _ v y)).
  1129. Defined.
  1130.  
  1131. Theorem one_le : forall n, 1 < (S (S n)).
  1132. auto with arith.
  1133. Qed.
  1134.  
  1135. Theorem hd_get' : forall {A n} (x : t A (S n)), hd x = x [@F1].
  1136. intros.
  1137. by elim/@rectS : x.
  1138. Qed.
  1139.  
  1140. Theorem sym_binary_pair : forall n q (x y : t binary (S n)) (H : q < S n) b,
  1141. x[@of_nat_lt H] = b -> y [@of_nat_lt H] = b ->
  1142. (cross_binary_vector x y) [@of_nat_lt H] = b.
  1143. intros.
  1144. move : H x y H0 H1.
  1145. elim/@nat_double_ind : n/q.
  1146. intros; simpl in *; move : H0 H1.
  1147. elim/@caseS' : x; elim/@caseS' : y.
  1148. intros; move : H0 H1.
  1149. by elim/@case0 : t; elim/@case0 : t0; elim/@b_rect : h/h0.
  1150. intros; move : H0; elim/@caseS' : x.
  1151. move : H1; elim/@caseS' : y.
  1152. intros; simpl in *; move : H1 H0.
  1153. by elim/@b_rect : h/h0.
  1154. intros; simpl in *; move : y H0 H1 H2; elim/@caseS' : x.
  1155. intros; move : t H0 H1 H2 H; elim/@caseS' : y.
  1156. intros; simpl in H1; simpl in H2.
  1157. pose (H (lt_S_n m (S n) H0) _ _ H1 H2).
  1158. simpl in *.
  1159. by elim/@b_rect : h/h0.
  1160. Qed.
  1161.  
  1162. Theorem vec_cons : forall A n (x : t A (S n)), x = x[@F1] :: (tl x).
  1163. intros.
  1164. by elim/@rectS : x.
  1165. Qed.
  1166.  
  1167. Theorem hd_bin : forall n m (x : t (t binary (S m)) (S (S n))),
  1168. (binary_crossing' x)[@F1] = cross_binary_vector x[@F1]
  1169. (binary_crossing' x)[@FS F1].
  1170. intros.
  1171. elim/@caseS' : x.
  1172. intros.
  1173. simpl.
  1174. by rewrite (vec_cons (binary_crossing' _)).
  1175. Qed.
  1176.  
  1177. Theorem cons_bin : forall {n m} (x : t (t binary (S m)) (S (S n))),
  1178. binary_crossing' x = cross_binary_vector x[@F1] (binary_crossing' x)[@FS F1]
  1179. :: (tl (binary_crossing' x)).
  1180.  
  1181. intros.
  1182. elim/@caseS' : x.
  1183. intros.
  1184. simpl.
  1185. by rewrite (vec_cons (binary_crossing' _)).
  1186. Qed.
  1187.  
  1188. Hint Rewrite hd_bin : cross.
  1189.  
  1190. Theorem tl_bin : forall n m (x : t (t binary (S m)) (S (S n))),
  1191. tl (binary_crossing' x) = (binary_crossing' (tl x)).
  1192. Ltac case3S' x := elim/@caseS' : x; move => h3 x; elim/@caseS' : x; move => h3' x; elim/@caseS' : x.
  1193. Ltac case2' x := elim/@caseS' : x; move => h3 x; elim/@caseS' : x; move => h3' x.
  1194. intros.
  1195. induction n.
  1196. by case2' x; elim/@case0 : x.
  1197. intros.
  1198. elim/@caseS' : x.
  1199. intros.
  1200. simpl.
  1201. by rewrite (cons_bin).
  1202. Qed.
  1203.  
  1204. Hint Rewrite tl_bin : cross.
  1205.  
  1206. Theorem cross_eq_pair_sym : forall n i (x y : t binary (S n)) a (H : i < S n),
  1207. (cross_binary_vector x y) [@of_nat_lt H] = a -> y [@of_nat_lt H] = a \/ x [@of_nat_lt H] = a.
  1208. move => i n.
  1209. elim/@nat_double_ind : i/n.
  1210. intros;move : H0.
  1211. elim/@caseS' : x; elim/@caseS' : y.
  1212. intros;move : H0.
  1213. elim/@case0 : t; elim/@case0 : t0.
  1214. intros;move : H0;left;move : H0.
  1215. by elim/@b_rect : h0/h.
  1216. intros.
  1217. simpl in *;move : y H H0;elim/@rectS : x.
  1218. intros;move : H0.
  1219. elim/@caseS' : y; intros; move : H0; elim/@case0 : t.
  1220. simpl; elim/@b_rect : a0/h.
  1221. destruct a.
  1222. move => H3; inversion H3.
  1223. intros; by left.
  1224. destruct a.
  1225. by right.
  1226. intros; by left.
  1227. destruct a.
  1228. intros; auto.
  1229. intros; auto.
  1230. destruct a.
  1231. intros; auto.
  1232. intros; auto.
  1233. intros; simpl in *;move : H1; elim/@caseS' : y.
  1234. intros; simpl in *.
  1235. destruct a.
  1236. move : H1; elim/@b_rect : a0/h; intros; simpl in *.
  1237. intros; auto.
  1238. intros; auto.
  1239. intros; auto.
  1240. intros; auto.
  1241. move : H1; elim/@b_rect : a0/h.
  1242. intros; auto.
  1243. intros; auto.
  1244. intros; auto.
  1245. intros; auto.
  1246. intros; simpl in *; move : H1.
  1247. elim/@caseS' : x; elim/@caseS' : y.
  1248. intros; simpl in *.
  1249. pose (H t0 t a (lt_S_n m (S n) H0)).
  1250. move : H1; elim/@b_rect : h/h0.
  1251. simpl in *; auto.
  1252. simpl in *; auto.
  1253. simpl; intros; auto.
  1254. simpl; intros; auto.
  1255. Qed.
  1256.  
  1257. Hint Rewrite cross_eq_pair_sym : cross.
  1258.  
  1259.  
  1260. Fixpoint pow_' {A} (f : A -> A) (x : nat) {struct x} : A -> A :=
  1261. match x with
  1262. |(S x') => f ∘ (pow_' f x')
  1263. |0 => id
  1264. end.
  1265.  
  1266. Theorem tl_pow_f_bin : forall n m q (v : t (t binary (S m)) (S n)) h,
  1267. tl (pow_' binary_crossing' q (h :: v))
  1268. = (pow_' binary_crossing' q v).
  1269. intros.
  1270. move : v h.
  1271. induction q.
  1272. intros.
  1273. by elim/@rect_2per : v.
  1274. intros; elim/@rect_2per : v IHq.
  1275. intros.
  1276. pose (IHq (h0 :: a :: t) h).
  1277. by rewrite (tl_bin _); fold @pow_'; rewrite e;simpl.
  1278. by intros; simpl; rewrite (tl_bin _); rewrite (IHq [h0;v] h).
  1279. intros; simpl.
  1280. pose (IHq [h] h0).
  1281. destruct q.
  1282. trivial.
  1283. by simpl in *; rewrite (tl_bin _); rewrite (IHq _ h).
  1284. Qed.
  1285.  
  1286. Hint Rewrite tl_pow_f_bin : cross.
  1287.  
  1288. Hint Rewrite vec_cons : cross.
  1289.  
  1290. (*
  1291. Theorem cons_powtf : forall m n0 h q (v : VectorDef.t (t binary (S m)) (S n0)) (H : q <= S n0),
  1292.  
  1293. (pow_' binary_crossing' (S q) (h :: v)) =
  1294. cross_binary_vector (nth (pow_' binary_crossing' q (h :: v)) (of_nat_lt (Nat.lt_0_succ _)))
  1295. (nth (pow_' binary_crossing' q (h :: v)) (of_nat_lt (one_le _)))
  1296. :: (pow_' binary_crossing' (S q) v).
  1297. intros.
  1298. move : H.
  1299. elim/@caseS : v.
  1300. intros.
  1301. have :
  1302. hd (pow_' binary_crossing' (S q) (h :: h0 :: t)) = cross_binary_vector
  1303. (pow_' binary_crossing' q (h :: h0 :: t))[@
  1304. of_nat_lt (Nat.lt_0_succ _)]
  1305. (pow_' binary_crossing' q ((h :: h0 :: t)))[@
  1306. of_nat_lt (one_le _)].
  1307. intros.
  1308. rewrite (hd_get').
  1309. rewrite (hd_bin _ ).
  1310. intros.
  1311. fold @pow_'.
  1312. simpl.
  1313. by rewrite (of_nat_lt_c (one_le n)).
  1314.  
  1315. auto with arith.
  1316.  
  1317. move => hd'.
  1318. have : (tl (pow_' binary_crossing' (S q) (h :: h0 :: t)))
  1319. = pow_' binary_crossing' (S q) (h0 :: t).
  1320.  
  1321. rewrite(tl_bin _).
  1322. fold @pow_'.
  1323. by rewrite (tl_pow_f_bin _).
  1324.  
  1325. move => H3.
  1326. simpl in *.
  1327. rewrite <- hd'.
  1328. rewrite <- H3.
  1329. apply : vec_cons.
  1330. Qed.
  1331.  
  1332.  
  1333. Theorem binary_S : forall b n0 c (v : t (t _ (S b)) (S n0)),
  1334. binary_crossing' (pow_' binary_crossing' c v) =
  1335. (pow_' binary_crossing' (S c) v).
  1336. intros.
  1337. trivial.
  1338. Qed.
  1339.  
  1340. Theorem cons_powtf' : forall m n0 h c q (v : VectorDef.t (t binary (S m)) (S n0)) (H : q <= S n0),
  1341.  
  1342. (pow_' binary_crossing' (S q) (c :: h :: v)) =
  1343. cross_binary_vector (nth (pow_' binary_crossing' q (c :: h :: v)) (of_nat_lt (Nat.lt_0_succ _)))
  1344. (nth (pow_' binary_crossing' q (c :: h :: v)) (of_nat_lt (one_le _)))
  1345. ::
  1346. cross_binary_vector (nth (pow_' binary_crossing' q (h :: v)) (of_nat_lt (Nat.lt_0_succ _)))
  1347. (nth (pow_' binary_crossing' q (h :: v)) (of_nat_lt (one_le _)))
  1348.  
  1349. :: (pow_' binary_crossing' (S q) v).
  1350. intros.
  1351. elim/@caseS' : v.
  1352. intros.
  1353. have : hd (pow_' binary_crossing' (S q) (c :: h :: h0 :: t)) =
  1354. cross_binary_vector
  1355. (pow_' binary_crossing' q (c :: h :: h0 :: t))[@
  1356. of_nat_lt (Nat.lt_0_succ (S (S n0)))]
  1357. (pow_' binary_crossing' q (c :: h :: h0 :: t))[@
  1358. of_nat_lt (one_le (S n0))].
  1359.  
  1360. rewrite (hd_bin _ _).
  1361. fold @pow_'; trivial.
  1362. auto with arith.
  1363. move => hd'.
  1364. have : tl (pow_' binary_crossing' (S q) (c :: h :: h0 :: t) ) =
  1365. cross_binary_vector
  1366. (pow_' binary_crossing' q (h :: h0 :: t))[@of_nat_lt
  1367. (Nat.lt_0_succ (S n0))]
  1368. (pow_' binary_crossing' q (h :: h0 :: t))[@of_nat_lt (one_le n0)]
  1369. :: pow_' binary_crossing' (S q) (h0 :: t).
  1370.  
  1371. rewrite(tl_bin _).
  1372. rewrite (tl_pow_f_bin _).
  1373. apply : cons_powtf.
  1374. assumption.
  1375. move => tl';rewrite <- hd';rewrite <- tl';apply : vec_cons.
  1376. Qed.
  1377.  
  1378. Hint Rewrite cons_powtf : cross.
  1379. Hint Rewrite cons_powtf' : cross.
  1380. *)
  1381.  
  1382. Fixpoint pred_binary_set {n m} (v : t (t binary (S m)) (S n)) :
  1383. t (t binary m) (S n).
  1384. intros; elim/@rectS : v.
  1385. intros; refine (cons _ (tl a) _ (nil _)).
  1386. intros; refine (cons _ (tl a) _ (pred_binary_set _ _ v)).
  1387. Defined.
  1388.  
  1389. Theorem rewrite_prop_list : forall {A} {n} (x : t A (S n)) (P : A -> A -> Prop) (F : A -> A -> Prop),
  1390. prop_list x P -> (forall x y, P x y -> F x y) -> prop_list x F.
  1391. intros.
  1392. elim/@rect_2per : x H.
  1393. intros; destruct H1; pose (H H2).
  1394. constructor.
  1395. by apply : H0.
  1396. by exact p.
  1397. intros;by simpl in *; apply : H0.
  1398. intros;by simpl in *; apply : H0.
  1399. Qed.
  1400.  
  1401. Theorem nth_prop_list : forall {A} {n} y (x : t A (S n)) (P : A -> A -> Prop) (H : y < S n) (H' : S y < S n),
  1402. prop_list x P -> P (nth x (of_nat_lt H)) (nth x (of_nat_lt H')).
  1403. intros;elim/@rect_leb : x/H H0 H'.
  1404. intros; elim/@rect_2per : v H H' H0.
  1405. by intros; simpl in *; destruct H1.
  1406. simpl; tauto.
  1407. simpl; tauto.
  1408. intros; inversion H'; inversion H2.
  1409. intros.
  1410. have : S y0 < S n0.
  1411. auto with arith.
  1412. move => H3; elim/@caseS' : v H0 H1 H3.
  1413. intros; destruct n0; simpl in H1.
  1414. inversion H3; inversion H4.
  1415. destruct n0; simpl in H1.
  1416. elim/@caseS' : t H0 H1 H3.
  1417. intros;elim/@case0 : t H0 H1.
  1418. intros; destruct H1; pose (H0 H2 H3).
  1419. simpl in p; simpl.
  1420. rewrite <- (of_nat_lt_c (le_S_n (S y0) 2 H) ).
  1421. by rewrite <- (of_nat_lt_c (lt_S_n y0 1 H3)).
  1422. destruct H1.
  1423. pose (H0 H2 H3).
  1424. simpl in p; simpl.
  1425. rewrite <- (of_nat_lt_c (le_S_n _ _ H)).
  1426. by rewrite <- (of_nat_lt_c (lt_S_n _ _ H3)).
  1427. Qed.
  1428.  
  1429. (*
  1430. Theorem progress_pred : forall {q l a n} (v : pure_lex l n) (H : q < S l)
  1431. (y : t binary (S q)) (k : a < S n),
  1432. prop_list v
  1433. (fun x y : VectorDef.t binary (S l) =>
  1434. eq_vector_binary (take _ H x) (take _ H y) = true) ->
  1435. (take _ H (nth v (of_nat_lt k))) = y.
  1436.  
  1437. intros.
  1438. have : forall x,
  1439. (fun x : t binary (S l) => eq_vector_binary (take (S q) H x) y = true) x ->
  1440. (take (S q) H x) = y.
  1441. intros.
  1442. by apply : lex_vec_eq.
  1443. move => inhabit.
  1444.  
  1445. pose (rewrite_prop_list H0 inhabit).
  1446. by apply (nth_prop_list k) in p.
  1447. Qed.
  1448. *)
  1449.  
  1450. Theorem take_fold : forall n h q (H : q < S n), (match
  1451. h in (VectorDef.t _ n)
  1452. return (S q <= n -> VectorDef.t binary (S q))
  1453. with
  1454. | [] => False_rect (VectorDef.t binary (S q)) ∘ Nat.nle_succ_0 q
  1455. | cons _ x n0 xs =>
  1456. fun le : S q <= S n0 => x :: take q (le_S_n q n0 le) xs
  1457. end H) = take _ H h.
  1458. by trivial.
  1459. Qed.
  1460.  
  1461. Theorem binary_refl : forall a, equal_binary a a = true.
  1462. by elim.
  1463. Qed.
  1464.  
  1465. Theorem binary_eq : forall a b, equal_binary a b = true -> a = b.
  1466. move => a b.
  1467. by elim/@b_rect : a/b.
  1468. Qed.
  1469.  
  1470. Theorem binary_sym : forall a b, equal_binary a b = true -> equal_binary b a = true.
  1471. by elim.
  1472. Qed.
  1473.  
  1474. Theorem eqv_partial_refl : forall {n} t y (H : y < S n), eq_vec_partial_eqv t t H.
  1475. intros.
  1476. elim/@rect_leb : t/H.
  1477. intros.
  1478. simpl.
  1479. elim/@caseS' : v.
  1480. intros; simpl.
  1481. apply : binary_refl.
  1482. intros.
  1483. elim/@case0 : v.
  1484. apply : binary_refl.
  1485. intros.
  1486. intros; simpl; unfold ssr_have; simpl.
  1487. constructor.
  1488. apply : binary_refl.
  1489. exact H0.
  1490. Qed.
  1491.  
  1492. (*
  1493. Theorem eqv_partial_1 : forall {n} v v' (H : 0 < S n), eq_vec_partial_eqv (cross_binary_vector v v') v' H.
  1494. intros.
  1495. elim/@rect_2S : v/v' H.
  1496. intros.
  1497. by simpl.
  1498. intros.
  1499. have : 0 < S n0.
  1500. auto with arith.
  1501. move => H3.
  1502. pose (H H3).
  1503. simpl.
  1504. elim/@b_rect : a/b e.
  1505. simpl.
  1506. intros.
  1507. *)
  1508. Theorem cross_refl_take : forall n x y q (H : q < S n),
  1509. take _ H x = take _ H y ->
  1510. take _ H (cross_binary_vector x y) = take _ H y.
  1511. intros; elim/@rect_leb : x/H y H0.
  1512. intros; elim/@caseS' : y H0.
  1513. intros.
  1514. simpl in H0; apply (f_equal hd) in H0; simpl in H0; rewrite H0.
  1515. by destruct h.
  1516. intros; elim/@caseS' : y H0; elim/@case0 : v.
  1517. intros; elim/@case0 : t H0.
  1518. intros; apply (f_equal hd) in H0.
  1519. simpl in H0; rewrite H0; by destruct h.
  1520. intros; move : H1; elim/@caseS' : y0.
  1521. intros; simpl in H1.
  1522. do 2! rewrite take_fold in H1.
  1523. set (f_equal tl H1); set (f_equal hd H1).
  1524. pose (H0 t e); simpl in e0.
  1525. rewrite e0; simpl.
  1526. destruct h; simpl.
  1527. do 2! rewrite take_fold; rewrite e1.
  1528. trivial.
  1529. do 2! rewrite take_fold; rewrite e1.
  1530. trivial.
  1531. Qed.
  1532.  
  1533. (*
  1534. Theorem next_eqv : forall n q H H' h (v : t binary (S n)),
  1535. eq_vector_binary (take (S q) H h) (take (S q) H v) = true
  1536. -> eq_vector_binary (take (S (S q)) H' h) (take (S (S q)) H' (cross_binary_vector h v)) = true.
  1537. intros.
  1538. elim/@rect_leb : h/H v H' H0.
  1539. intros.
  1540. elim/@caseS' : v0 H0.
  1541. intros.
  1542. elim/@caseS' : v H0.
  1543. elim/@caseS' : t.
  1544. intros.
  1545. elim/@b_rect : a/h H0.
  1546. intros.
  1547. apply lex_vec_eq in H0.
  1548.  
  1549.  
  1550. elim/@b_rect : h1/h0 H0.
  1551.  
  1552. inversion H'.
  1553. inversion H2.
  1554. intros.
  1555.  
  1556. elim/@b_rect : x/y H0.
  1557. *)
  1558.  
  1559.  
  1560. Theorem sym_eqv : forall {n} (h v : t binary (S n)) y (H : y < S n),
  1561. eq_vec_partial_eqv h v H -> eq_vec_partial_eqv v h H.
  1562. intros.
  1563. elim/@rect_leb : h/H v H0.
  1564. intros.
  1565. elim/@caseS' : v0 H0.
  1566. intros.
  1567. simpl in *.
  1568. elim/@caseS' : v H0.
  1569. elim/@caseS' : t.
  1570. intros.
  1571. simpl in *.
  1572. destruct H0.
  1573. by elim/@b_rect : h/a.
  1574.  
  1575. intros.
  1576. elim/@case1 : v0 H0.
  1577. elim/@case0 : v.
  1578. intros; by apply : binary_sym.
  1579. intros.
  1580. elim/@caseS' : v0 H1.
  1581. intros.
  1582. destruct H1.
  1583. simpl in *.
  1584. unfold ssr_have.
  1585. simpl.
  1586. constructor.
  1587. apply : (binary_sym H1).
  1588. exact (H0 _ H2).
  1589. Qed.
  1590.  
  1591. (*
  1592. Theorem trans_Seqv : forall {n} (h v a : t binary (S n)) y (H : y < S n) (H' : S y < S n),
  1593. eq_vec_partial_eqv a h H -> eq_vec_partial_eqv (cross_binary_vector a v) v H' ->
  1594. eq_vec_partial_eqv (cross_binary_vector h (cross_binary_vector a v)) (cross_binary_vector a v) H'.
  1595. intros.
  1596. elim/@rect_leb : h/H v a H' H0 H1.
  1597. intros.
  1598. elim/@caseS' : v0 H1 H0.
  1599. elim/@caseS' : a0.
  1600. intros.
  1601. elim/@b_rect : h/a H0 H1.
  1602. intros.
  1603. destruct h0.
  1604. simpl in *; unfold ssr_have in *; simpl in *.
  1605.  
  1606. by destruct h0.
  1607. intros.
  1608. by destruct h0.
  1609. intros.
  1610. destruct h0.
  1611. simpl in *; unfold ssr_have in *; simpl in *.
  1612.  
  1613. by [].
  1614. *)
  1615.  
  1616. Theorem trans_Seqv : forall {n} (h v z : t binary (S n)) y (H : y < S n),
  1617. eq_vec_partial_eqv h v H -> eq_vec_partial_eqv z h H -> eq_vec_partial_eqv z v H.
  1618. intros.
  1619. elim/@rect_leb : h/H v z H0 H1.
  1620. intros.
  1621. elim/@caseS' : v0 H0.
  1622. elim/@caseS' : z H1.
  1623. intros.
  1624. simpl in *.
  1625. elim/@caseS' : v H0 H1.
  1626. elim/@caseS' : t.
  1627. elim/@caseS' : t0.
  1628. intros.
  1629. rewrite (binary_eq H1).
  1630. rewrite (binary_eq H0).
  1631. by apply : binary_refl.
  1632. intros.
  1633. elim/@case1 : v0 H0.
  1634. elim/@case1 : z H1.
  1635. elim/@case0 : v.
  1636. intros.
  1637. simpl in *.
  1638.  
  1639. Admitted.
  1640.  
  1641. Theorem partial_0 : forall {n} (h v : t binary (S n)) (H : 0 < S n),
  1642. eq_vec_partial_eqv (cross_binary_vector h v) v H.
  1643. Admitted.
  1644.  
  1645.  
  1646. Theorem partial_eqv_S : forall {n} (h v : t binary (S n)) y (H : y < S n) (H' : (S y) < S n),
  1647. eq_vec_partial_eqv v h H -> eq_vec_partial_eqv (cross_binary_vector v h) h H'.
  1648. intros.
  1649. apply sym_eqv in H0.
  1650. elim/@rect_leb : h/H v H' H0.
  1651. intros.
  1652. elim/@caseS' : v0 H0.
  1653. intros.
  1654. simpl in *.
  1655. elim/@b_rect : a/h H0.
  1656. simpl.
  1657. unfold ssr_have.
  1658. simpl.
  1659. intros.
  1660. constructor.
  1661. apply : binary_refl.
  1662. apply : partial_0.
  1663. constructor.
  1664. apply : binary_refl.
  1665. apply : partial_0.
  1666. constructor.
  1667. apply : binary_refl.
  1668. inversion H0.
  1669. intros.
  1670. inversion H0.
  1671. intros.
  1672. inversion H'; inversion H2.
  1673. intros.
  1674. elim/@caseS' : v0 H1.
  1675. move => h t H1'.
  1676. simpl in H1'.
  1677. unfold ssr_have in H1'.
  1678. simpl in H1'.
  1679. destruct H1'.
  1680. pose (H0 t (le_S_n (S (S y0)) (S n0) H') H2).
  1681. by elim/@b_rect : a/h H1.
  1682. Qed.
  1683.  
  1684.  
  1685. Theorem cross_cons : forall {n} (v : t binary (S n)) t0 h0, (cross_binary_vector v (h0 :: t0)) = h0 :: (tl (cross_binary_vector v (h0 :: t0))).
  1686. Admitted.
  1687.  
  1688. Theorem trans_eqv : forall {n} (h v z : t binary (S n)) y (H : y < S n) (H' : S y < S n),
  1689. eq_vec_partial_eqv h v H -> eq_vec_partial_eqv v z H ->
  1690. eq_vec_partial_eqv (cross_binary_vector h z) (cross_binary_vector v z) H'.
  1691. intros.
  1692.  
  1693. elim/@rect_leb : h/H v z H' H1 H0.
  1694. intros.
  1695.  
  1696. elim/@caseS' : v0 H0 H1.
  1697. elim/@caseS' : z.
  1698. intros.
  1699. simpl in *;unfold ssr_have in *; simpl in *.
  1700. elim/@b_rect : a/h0 H0 H1.
  1701. destruct h.
  1702. simpl.
  1703. intros.
  1704. elim/@caseS' : t0 H0.
  1705. elim/@caseS' : t H1.
  1706. intros.
  1707. simpl in *.
  1708. destruct n0.
  1709. elim/@case1 : v H1 H0.
  1710. intros.
  1711. elim/@case0 : t H1.
  1712. elim/@case0 : t0.
  1713. intros.
  1714. simpl in *.
  1715. elim/@b_rect : h/h0 H0 H1.
  1716. intros.
  1717. destruct h1.
  1718. unfold ssr_have.
  1719. simpl.
  1720. unfold ssr_have in *;simpl.
  1721. by constructor.
  1722. by constructor.
  1723. by constructor.
  1724. by constructor.
  1725. by constructor.
  1726. by constructor.
  1727.  
  1728. intros.
  1729. simpl in *.
  1730. unfold ssr_have; simpl in *.
  1731. constructor.
  1732. trivial.
  1733. admit.
  1734. intros.
  1735. destruct h.
  1736. simpl in *; unfold ssr_have in *; simpl in *.
  1737. constructor.
  1738. trivial.
  1739. admit.
  1740. simpl in *; unfold ssr_have in *; simpl in *.
  1741. constructor.
  1742. trivial.
  1743. inversion H1.
  1744. intros.
  1745. destruct h.
  1746. simpl in *; unfold ssr_have in *; simpl in *.
  1747. inversion H0.
  1748. inversion H0.
  1749. destruct h.
  1750. intros.
  1751. inversion H0.
  1752. intros.
  1753. inversion H0.
  1754. intros.
  1755. inversion H'.
  1756. inversion H3.
  1757. intros.
  1758. elim/@caseS' : v0 H1 H2.
  1759. elim/@caseS' : z.
  1760. intros.
  1761. elim/@b_rect : a/h H1 H2.
  1762. destruct h0.
  1763. intros.
  1764. simpl in *; unfold ssr_have in *; simpl in *.
  1765. destruct H1.
  1766. inversion H1.
  1767. intros.
  1768. simpl in *; unfold ssr_have in *; simpl in *.
  1769. destruct H1.
  1770. destruct H2.
  1771. constructor.
  1772. trivial.
  1773. by apply (H0 t0 t (le_S_n (S (S y0)) (S n0) H') H3 H4).
  1774. intros.
  1775. simpl in *; unfold ssr_have in *; simpl in *.
  1776. destruct h0.
  1777. simpl in *; unfold ssr_have in *; simpl in *.
  1778. constructor.
  1779. trivial.
  1780. destruct H1.
  1781. destruct H2.
  1782. by apply (H0 t0 t (le_S_n (S (S y0)) (S n0) H') H3 H4).
  1783. intros.
  1784. destruct H1.
  1785. inversion H1.
  1786. intros.
  1787. simpl in *; unfold ssr_have in *; simpl in *.
  1788. destruct h0.
  1789. destruct H1.
  1790. destruct H2.
  1791. simpl in *; unfold ssr_have in *; simpl in *.
  1792. inversion H2.
  1793. destruct H1.
  1794. inversion H1.
  1795. intros.
  1796. destruct h0.
  1797. intros.
  1798. simpl in *; unfold ssr_have in *; simpl in *.
  1799. destruct H1.
  1800. inversion H1.
  1801. destruct H2.
  1802. inversion H2.
  1803. Admitted.
  1804.  
  1805. Theorem eqv_seq : forall {n} y (v v' : t binary (S n)) (H : S y < S n) (H' : y < S n),
  1806. eq_vec_partial_eqv v v' H -> eq_vec_partial_eqv v v' H'.
  1807. intros.
  1808. elim/@rect_leb : v/H' v' H H0.
  1809. intros.
  1810. elim/@caseS' : v' H1.
  1811. simpl; unfold ssr_have; simpl.
  1812. intros.
  1813. elim/@b_rect : a/h H1.
  1814. by simpl.
  1815. by simpl.
  1816. intros; inversion H1; inversion H2.
  1817. intros; inversion H1; inversion H2.
  1818. intros; inversion H0; inversion H3.
  1819. intros.
  1820. have : S y0 < S n0.
  1821. auto with arith.
  1822. move => H4.
  1823. elim/@caseS' : v' H2.
  1824. intros.
  1825. simpl in *; unfold ssr_have in *; simpl in *.
  1826. destruct H2.
  1827. pose (H0 t (le_S_n (S (S y0)) (S n0) H1) H3).
  1828. by constructor.
  1829. Qed.
  1830.  
  1831.  
  1832. Theorem pure_0_cross : forall {n} (v v0 t t0 : t binary (S n)) (H : 0 < S n),
  1833. eq_vec_partial_eqv t t0 H ->
  1834. eq_vec_partial_eqv (cross_binary_vector v t) (cross_binary_vector v0 t0) H.
  1835. intros.
  1836. apply : (@trans_Seqv _ _ _ (cross_binary_vector v t) _ _ (sym_eqv (partial_0 v0 t0 H)) (sym_eqv (@trans_Seqv _ _ _ t0 _ _ (sym_eqv (partial_0 v t H)) (sym_eqv H0)))).
  1837. Qed.
  1838.  
  1839. (*
  1840. Theorem g_f : forall {n} y (a z v v' : t binary (S n)) (H : y < S n) (H' : S y < S n),
  1841. eq_vec_partial_eqv a z H ->
  1842. eq_vec_partial_eqv v v' H' ->
  1843. eq_vec_partial_eqv (cross_binary_vector a v) (cross_binary_vector z v') H'.
  1844.  
  1845. intros.
  1846. elim/@rect_leb : a/H z v v' H' H0 H1.
  1847. intros.
  1848. elim/@caseS' : z H0.
  1849. elim/@caseS' : v0 H1.
  1850. elim/@caseS' : v'.
  1851. intros.
  1852. simpl in *; unfold ssr_have in *; simpl in *.
  1853. elim/@b_rect : a/h0 H1 H0.
  1854. elim/@b_rect : h/h1.
  1855. intros.
  1856. simpl in *; unfold ssr_have in *; simpl in *.
  1857. constructor.
  1858. trivial.
  1859. destruct H1.
  1860. apply : pure_0_cross.
  1861. exact H2.
  1862. intros.
  1863. inversion H0.
  1864. intros.
  1865. inversion H0.
  1866. intros.
  1867. destruct H1.
  1868. inversion H1.
  1869. elim/@b_rect : h/h1.
  1870. intros.
  1871. inversion H0.
  1872. intros.
  1873. destruct H1.
  1874. simpl in *; unfold ssr_have in *; simpl in *.
  1875. constructor.
  1876. trivial.
  1877. apply : pure_0_cross.
  1878. exact H2.
  1879. intros.
  1880. inversion H0.
  1881. destruct H1.
  1882. inversion H1.
  1883. intros.
  1884. inversion H0.
  1885. elim/@b_rect : h/h1.
  1886. intros.
  1887. destruct H1.
  1888. inversion H1.
  1889. intros.
  1890. inversion H0.
  1891. intros.
  1892. inversion H0.
  1893. intros.
  1894. destruct H1.
  1895. simpl in *; unfold ssr_have in *; simpl in *.
  1896. constructor.
  1897. trivial.
  1898. apply :
  1899.  
  1900. *)
  1901.  
  1902. Theorem cross_eqv_refl : forall {n} y (a c v : t binary (S n)) (H : y < S n) (H' : y < S n),
  1903. eq_vec_partial_eqv a c H ->
  1904. eq_vec_partial_eqv (cross_binary_vector a a) v H' ->
  1905. eq_vec_partial_eqv (cross_binary_vector a c) v H'.
  1906. intros.
  1907. elim/@rect_leb : a/H v c H0 H' H1.
  1908. intros.
  1909. elim/@caseS' : v H0 H1.
  1910. elim/@caseS' : c.
  1911. intros.
  1912. simpl in *.
  1913. elim/@b_rect : a/h H0 H1.
  1914. intros.
  1915. intros.
  1916. simpl in *.
  1917. destruct n0.
  1918. simpl in *.
  1919. exact H1.
  1920. simpl in *.
  1921. exact H1.
  1922. intros.
  1923. simpl in *.
  1924. exact H1.
  1925. intros.
  1926. simpl in *.
  1927. elim/@caseS' : v0 H1.
  1928. intros.
  1929. simpl in *.
  1930. destruct h.
  1931. inversion H0.
  1932. trivial.
  1933. intros.
  1934. inversion H0.
  1935. intros.
  1936. elim/@case0 : v H0 H1.
  1937. elim/@caseS' : v0; elim/@caseS' : c.
  1938. move => h; elim/@case0.
  1939. intros; simpl in *.
  1940. elim/@b_rect : a/h H0 H1.
  1941. by destruct h0.
  1942. by destruct h0.
  1943. by destruct h0.
  1944. by destruct h0.
  1945. intros.
  1946. elim/@caseS' : v0 H1 H2; elim/@caseS' : c.
  1947. intros.
  1948. simpl in *.
  1949. unfold ssr_have in *.
  1950. simpl in H1.
  1951. destruct H1.
  1952. pose (H0 t0 t H3).
  1953. elim/@b_rect : a/h H1 H0 H2 e.
  1954. intros.
  1955. simpl in *.
  1956. unfold ssr_have in *.
  1957. simpl in *.
  1958. destruct H2.
  1959. apply e in H4.
  1960. exact (conj H2 H4).
  1961. intros.
  1962. destruct H2.
  1963. apply e in H4.
  1964. exact (conj H2 H4).
  1965. intros.
  1966. inversion H1.
  1967. intros.
  1968. inversion H1.
  1969. Qed.
  1970.  
  1971. Theorem cross_eq_sym : forall {n} y (a c v : t binary (S n)) (H : y < S n),
  1972. eq_vec_partial_eqv a c H ->
  1973. eq_vec_partial_eqv (cross_binary_vector c a) v H ->
  1974. eq_vec_partial_eqv (cross_binary_vector a c) v H.
  1975.  
  1976. intros.
  1977. elim/@rect_leb : a/H v c H0 H1.
  1978. intros.
  1979. elim/@caseS' : v H0 H1.
  1980. elim/@caseS' : c.
  1981. intros.
  1982. simpl in *.
  1983. elim/@b_rect : a/h H0 H1.
  1984. intros.
  1985. destruct n0.
  1986. simpl in *.
  1987. exact H1.
  1988. simpl in *.
  1989. exact H1.
  1990. intros.
  1991. simpl in *.
  1992. exact H1.
  1993. intros.
  1994. simpl in *.
  1995. elim/@caseS' : v0 H1.
  1996. intros.
  1997. simpl in *.
  1998. destruct h.
  1999. inversion H1.
  2000. inversion H0.
  2001. intros.
  2002. inversion H0.
  2003. intros.
  2004. elim/@case0 : v H0 H1.
  2005. elim/@caseS' : v0; elim/@caseS' : c.
  2006. move => h; elim/@case0.
  2007. intros; simpl in *.
  2008. elim/@b_rect : a/h H0 H1.
  2009. by destruct h0.
  2010. by destruct h0.
  2011. by destruct h0.
  2012. by destruct h0.
  2013. intros.
  2014. elim/@caseS' : v0 H1 H2; elim/@caseS' : c.
  2015. intros.
  2016. simpl in *.
  2017. unfold ssr_have in *.
  2018. simpl in H1.
  2019. destruct H1.
  2020. pose (H0 t0 t H3).
  2021. elim/@b_rect : a/h H1 H0 H2 e.
  2022. intros.
  2023. simpl in *.
  2024. unfold ssr_have in *.
  2025. simpl in *.
  2026. destruct H2.
  2027. apply e in H4.
  2028. exact (conj H2 H4).
  2029. intros.
  2030. destruct H2.
  2031. apply e in H4.
  2032. exact (conj H2 H4).
  2033. intros.
  2034. inversion H1.
  2035. intros.
  2036. inversion H1.
  2037. Qed.
  2038.  
  2039. Theorem take_eqv : forall n q (x y : t binary (S n)) (H : q < S n),
  2040. take _ H x = take _ H y -> eq_vec_partial_eqv x y H.
  2041. intros.
  2042. elim/@rect_leb : x/H y H0.
  2043. intros.
  2044. elim/@caseS' : y H0.
  2045. intros.
  2046. simpl in *.
  2047. apply (f_equal hd) in H0.
  2048. simpl in H0.
  2049. rewrite H0.
  2050. apply : binary_refl.
  2051. intros.
  2052. elim/@case0 : v H0.
  2053. elim/@case1 : y.
  2054. intros.
  2055. simpl in *.
  2056. apply (f_equal hd) in H0.
  2057. simpl in H0.
  2058. rewrite H0.
  2059. apply : binary_refl.
  2060. intros.
  2061. elim/@caseS' : y0 H1.
  2062. move => h k H1.
  2063. simpl in H1.
  2064. pose (f_equal hd H1).
  2065. pose (f_equal tl H1).
  2066. simpl in e.
  2067. simpl in e0.
  2068. pose (H0 k e0).
  2069. simpl.
  2070. unfold ssr_have; simpl.
  2071. constructor.
  2072. rewrite e.
  2073. apply : binary_refl.
  2074. exact e1.
  2075. Qed.
  2076.  
  2077. Theorem take_eqv' : forall n q (x y : t binary (S n)) (H : q < S n),
  2078. eq_vec_partial_eqv x y H -> take _ H x = take _ H y.
  2079. intros.
  2080. elim/@rect_leb : x/H y H0.
  2081. intros.
  2082. elim/@caseS' : y H0.
  2083. intros.
  2084. simpl in *.
  2085. apply (binary_eq) in H0.
  2086. rewrite H0.
  2087. apply : eq_refl.
  2088. intros.
  2089. elim/@case0 : v H0.
  2090. elim/@case1 : y.
  2091. intros.
  2092. simpl in *.
  2093. apply (binary_eq) in H0.
  2094. simpl in H0.
  2095. rewrite H0.
  2096. apply : eq_refl.
  2097. intros.
  2098. elim/@caseS' : y0 H1.
  2099. move => h k H1.
  2100. simpl in H1.
  2101. unfold ssr_have in H1.
  2102. simpl in H1.
  2103. destruct H1.
  2104. apply binary_eq in H1.
  2105. rewrite H1.
  2106. pose (H0 k H2).
  2107.  
  2108. simpl.
  2109. simpl in e.
  2110. by rewrite e.
  2111. Qed.
  2112.  
  2113. Theorem take_cross : forall n q (x y x' y' : t binary (S n)) (H : q < S n) (H' : S q < S n),
  2114. take _ H x = take _ H x' /\ take _ H' y = take _ H' y' ->
  2115. take _ H' (cross_binary_vector x y) = take _ H' (cross_binary_vector x' y').
  2116. intros.
  2117. destruct H0.
  2118. elim/@rect_leb : x/H y x' y' H' H0 H1.
  2119. intros.
  2120. elim/@caseS' : y H1.
  2121. elim/@caseS' : x' H0.
  2122. elim/@caseS' : y'.
  2123. intros.
  2124. elim/@b_rect : a/h1 H0 H1.
  2125. elim/@b_rect : h/h0.
  2126. intros.
  2127. apply : take_eqv'.
  2128. apply take_eqv in H0.
  2129. apply take_eqv in H1.
  2130. simpl in *; unfold ssr_have in *; simpl in *.
  2131. destruct H1.
  2132. constructor.
  2133. trivial.
  2134. apply : pure_0_cross.
  2135. exact H2.
  2136. admit.
  2137. admit.
  2138. admit.
  2139. admit.
  2140. intros.
  2141. elim/@b_rect : h/h0 H0 H1.
  2142. admit.
  2143. admit.
  2144. admit.
  2145. intros.
  2146. apply : take_eqv'.
  2147. apply take_eqv in H0.
  2148. apply take_eqv in H1.
  2149. simpl in *; unfold ssr_have in *; simpl in *.
  2150. destruct H1.
  2151. constructor.
  2152. trivial.
  2153. Admitted.
  2154.  
  2155.  
  2156. Theorem eqv_succ : forall {n q} (h a h0 : t binary (S n)) (H : q < S n) (H' : S q < S n),
  2157. eq_vec_partial_eqv h a H /\ eq_vec_partial_eqv a h0 H
  2158. -> eq_vec_partial_eqv (cross_binary_vector h (cross_binary_vector a h0))
  2159. (cross_binary_vector a h0) H'.
  2160.  
  2161. intros.
  2162. destruct H0.
  2163. elim/@rect_leb : h/H H' a h0 H0 H1.
  2164. intros.
  2165. elim/@caseS' : a0 H0 H1.
  2166. elim/@caseS' : h0.
  2167. intros.
  2168. elim/@b_rect : h0/h H0 H1.
  2169. intros.
  2170. destruct a.
  2171. simpl in *.
  2172. inversion H0.
  2173. simpl in *; unfold ssr_have in *; simpl in *.
  2174. constructor.
  2175. trivial.
  2176. apply : pure_0_cross.
  2177. apply : partial_0.
  2178. intros.
  2179. destruct a.
  2180. simpl in *; unfold ssr_have in *; simpl in *.
  2181. constructor.
  2182. trivial.
  2183. apply : partial_0.
  2184. intros.
  2185. inversion H0.
  2186. intros.
  2187. simpl in *.
  2188. inversion H1.
  2189. intros.
  2190. inversion H1.
  2191. intros.
  2192. elim/@case1 : a0 H0 H1.
  2193. elim/@case1 : h0.
  2194. elim/@case0 : v.
  2195. intros.
  2196. apply binary_eq in H0.
  2197. apply binary_eq in H1.
  2198. rewrite H0.
  2199. rewrite H1.
  2200. do 2! rewrite (cross_eq).
  2201. apply : eqv_partial_refl.
  2202. intros.
  2203. elim/@caseS' : a0 H1 H2.
  2204. elim/@caseS' : h0.
  2205. intros.
  2206. simpl in H1; unfold ssr_have in H1; simpl in H1.
  2207. simpl in H2; unfold ssr_have in H2; simpl in H2.
  2208. destruct H1.
  2209. destruct H2.
  2210. pose (H0 (le_S_n (S (S y)) (S n0) H') _ _ H3 H4).
  2211. elim/@b_rect : h/h0 H1 H2.
  2212. intros.
  2213. destruct a.
  2214. inversion H1.
  2215. simpl; unfold ssr_have; simpl.
  2216. by constructor.
  2217. destruct a.
  2218. intros.
  2219. by constructor.
  2220. intros.
  2221. inversion H1.
  2222. intros.
  2223. inversion H2.
  2224. intros.
  2225. inversion H2.
  2226. Qed.
  2227.  
  2228. Theorem conservation_eqv : forall {n l} (v : t (t binary (S l)) (S n)) q (H : q < S l),
  2229. prop_list v (fun x y => eq_vec_partial_eqv x y H)
  2230. ->
  2231. prop_list (binary_crossing' v) (fun x y => eq_vec_partial_eqv x y H).
  2232.  
  2233. Admitted.
  2234.  
  2235. Theorem conservation_eq : forall {n l} (v : t (t binary (S l)) (S n)) q (H : q < S l),
  2236. prop_list v (fun x y => eq_vec_partial_eqv x y H) ->
  2237.  
  2238. eq_vec_partial_eqv v[@F1] (binary_crossing' v)[@F1] H.
  2239.  
  2240. intros.
  2241. elim/@rectS : v H0.
  2242. intros.
  2243. simpl.
  2244. apply : eqv_partial_refl.
  2245. intros.
  2246. destruct n0.
  2247. elim/@case1 : v H1 H0.
  2248. intros.
  2249. simpl in *.
  2250. destruct H1.
  2251. apply : sym_eqv.
  2252. apply : cross_eqv_refl.
  2253. exact H1.
  2254. rewrite (cross_eq).
  2255. apply : eqv_partial_refl.
  2256. elim/@caseS' : v H1 H0.
  2257. intros.
  2258. simpl in H1.
  2259. destruct H1.
  2260. pose (H0 H2).
  2261. simpl.
  2262. rewrite (vec_cons (binary_crossing' t)).
  2263. simpl.
  2264. simpl in e.
  2265. rewrite -> (vec_cons (binary_crossing' t)) in e.
  2266. simpl in e.
  2267. apply : sym_eqv.
  2268. apply : cross_eqv_refl.
  2269. exact (@trans_Seqv _ _ _ a _ H e H1).
  2270. rewrite (cross_eq).
  2271. apply : eqv_partial_refl.
  2272. Qed.
  2273.  
  2274. Theorem conservation2_eq : forall {n l} (v : t (t binary (S l)) (S (S n))) q (H : q < S l),
  2275. prop_list v (fun x y => eq_vec_partial_eqv x y H) ->
  2276.  
  2277. eq_vec_partial_eqv v[@FS F1] (binary_crossing' v)[@F1] H.
  2278.  
  2279. intros.
  2280. elim/@caseS' : v H0.
  2281. intros.
  2282. simpl.
  2283. rewrite (vec_cons (binary_crossing' _)).
  2284. simpl.
  2285. elim/@caseS' : t H0.
  2286. intros.
  2287. destruct H0.
  2288. intros.
  2289. destruct n.
  2290. elim/@case0 : t H1.
  2291. simpl.
  2292. intros.
  2293. apply : sym_eqv.
  2294. apply : cross_eqv_refl.
  2295. exact H0.
  2296. rewrite (cross_eq).
  2297. exact H0.
  2298. intros.
  2299. simpl.
  2300. rewrite (vec_cons (binary_crossing' t)).
  2301. simpl.
  2302. apply : sym_eqv.
  2303. apply : cross_eqv_refl.
  2304. simpl in H1.
  2305. pose (H1).
  2306. move : c.
  2307. rewrite -> (vec_cons t) in H1.
  2308. simpl in H1.
  2309. destruct H1.
  2310. intros.
  2311. apply : sym_eqv.
  2312. apply : cross_eqv_refl.
  2313. apply : sym_eqv.
  2314. apply : (@trans_Seqv _ _ _ (binary_crossing' t)[@F1] _ _ (sym_eqv H1)).
  2315. apply : sym_eqv.
  2316. apply : conservation_eq.
  2317. elim/@caseS' : t H1 H2 c.
  2318. intros.
  2319. simpl in c.
  2320. destruct c.
  2321. exact H4.
  2322. rewrite (cross_eq).
  2323. by apply : sym_eqv.
  2324. by rewrite (cross_eq).
  2325. Qed.
  2326.  
  2327. Theorem induction_eqv : forall {n l} (v : t (t binary (S l)) (S n)) q (H : q < S l) (H' : (S q) < S l),
  2328. prop_list v (fun x y => eq_vec_partial_eqv x y H)
  2329. ->
  2330. prop_list (binary_crossing' v) (fun x y => eq_vec_partial_eqv x y H').
  2331.  
  2332. intros;elim/@rect_2per : v H0.
  2333. + case.
  2334. - simpl in *; unfold caseS'.
  2335. intros; elim/@case1 : t H0 H1.
  2336. intros; simpl in *.
  2337. destruct H1.
  2338. constructor.
  2339. apply : eqv_succ.
  2340. destruct H2.
  2341. exact (conj H1 H2).
  2342. apply (H0 H2).
  2343. - intros.
  2344. destruct H1.
  2345. simpl.
  2346. rewrite (cons_bin _).
  2347. unfold caseS'; simpl.
  2348. constructor.
  2349. have : 2 < S (S (S n0)).
  2350. auto with arith.
  2351. move => H3.
  2352. apply : eqv_succ.
  2353. constructor.
  2354. exact H1.
  2355. pose (H0 H2).
  2356. pose (nth_prop_list (one_le _) H3 H2).
  2357. pose (nth_prop_list (Nat.lt_0_succ _) (one_le _) p).
  2358. simpl in e.
  2359.  
  2360. rewrite -> (cons_bin) in e0.
  2361. simpl in e0.
  2362. pose (nth_prop_list (Nat.lt_0_succ _) (one_le _) p).
  2363.  
  2364. apply : sym_eqv.
  2365. apply : cross_eqv_refl.
  2366. simpl in e1.
  2367. elim/@caseS' : t H0 H2 H1 p e1 e e0.
  2368. intros.
  2369. simpl in H2.
  2370. destruct H2.
  2371. simpl.
  2372. rewrite (vec_cons (binary_crossing' t)).
  2373. simpl.
  2374. simpl in e.
  2375. apply : sym_eqv.
  2376. apply : (@trans_Seqv _ _ _ (binary_crossing' t)[@F1] _ _ (sym_eqv e)).
  2377. apply : sym_eqv.
  2378. apply : conservation_eq.
  2379. elim/@caseS' : t H0 H2 H1 p e1 e H4 e0.
  2380. intros.
  2381. destruct H4.
  2382. exact H5.
  2383. rewrite (cross_eq).
  2384. apply : sym_eqv (nth_prop_list (Nat.lt_0_succ _) (one_le _) H2).
  2385. pose (H0 H2).
  2386. simpl in p.
  2387. rewrite -> (cons_bin) in p.
  2388. simpl in p.
  2389. exact p.
  2390.  
  2391. + intros.
  2392. simpl in *.
  2393. constructor.
  2394. destruct H0.
  2395. by apply : partial_eqv_S.
  2396. apply : eqv_partial_refl.
  2397.  
  2398. + intros.
  2399. apply : eqv_partial_refl.
  2400. Qed.
  2401.  
  2402. Theorem convergent_binary_vector : forall {n l} (v : t (t binary (S l)) (S n)) q (H : S q < S l),
  2403. prop_list (pow_' binary_crossing' (S (S q)) v) (fun x y => eq_vec_partial_eqv x y H).
  2404. intros.
  2405. induction q.
  2406. intros.
  2407. simpl.
  2408. elim/@rectS : v.
  2409. intros.
  2410. simpl in *.
  2411. apply : eqv_partial_refl.
  2412. intros.
  2413. simpl.
  2414. destruct n0.
  2415. elim/@case1 : v H0.
  2416. intros.
  2417. simpl in *.
  2418.  
  2419. apply :
  2420.  
  2421. have : q < S l.
  2422. auto with arith.
  2423. move => H3.
  2424. pose (IHq H3).
  2425. apply : (induction_eqv H p).
  2426.  
  2427. elim/@rect_2per : v.
  2428. admit.
  2429. intros.
  2430. simpl.
  2431. elim/@rect_2S : h/v H.
  2432. by simpl.
  2433. intros.
  2434. simpl in *.
  2435. elim/@b_rect : a/b.
  2436. simpl.
  2437. pose (H (Nat.lt_0_succ _)).
  2438.  
  2439. admit.
  2440. rewrite (cons_bin _ (one_le _)) in e.
  2441.  
  2442. pose (@partial_eqv_S _ a h0 _ H H' H2).
  2443.  
  2444.  
  2445. pose (@trans_Seqv _ _ _ h _ _ H2 H1).
  2446.  
  2447. have : eq_vec_partial_eqv (cross_binary_vector h a) a H'.
  2448. apply : sym_eqv.
  2449. apply : trans_eqv.
  2450. exact H1.
  2451. by apply sym_eqv in H1.
  2452. move => H4'.
  2453. pose (@trans_Seqv _ _ _ (cross_binary_vector h a) _ _ H4' (eqv_partial_refl _ _)).
  2454. pose (@trans_Seqv _ _ _ h _ _ H2 H1).
  2455. have : eq_vec_partial_eqv (cross_binary_vector a h0) a H.
  2456. intros.
  2457. apply : sym_eqv.
  2458. apply : trans_eqv.
  2459. exact H2.
  2460. apply : eqv_partial_refl.
  2461. move => H5'.
  2462.  
  2463. pose (sym_eqv (@trans_Seqv _ _ _ (cross_binary_vector a h0)_ _ (sym_eqv e) H5')).
  2464.  
  2465. apply : trans_eqv.
  2466.  
  2467. (eqv_seq H H1).
  2468. exact H2.
  2469.  
  2470. rewrite (cons_bin).
  2471. simpl.
  2472. simpl in H2.
  2473. move => H3.
  2474. simpl in p.
  2475. rewrite (tl_binary_cross).
  2476. move => Hp.
  2477. simpl.
  2478.  
  2479. simpl.
  2480. rewrite (cons_bin).
  2481.  
  2482. pose (@rewrite_prop_list).
  2483.  
  2484. Theorem one_eqv_progress : forall {n l} (v : t (t binary (S l)) (S n)) q (H : q < S l) (H' : (S q) < S l),
  2485. prop_list v (fun x y => eq_vec_partial_eqv x y H)
  2486. ->
  2487. prop_list (pow_' binary_crossing' n v) (fun x y => eq_vec_partial_eqv x y H').
  2488.  
  2489. intros.
  2490. elim/@rect_2per : v H0.
  2491. intros.
  2492. rewrite (cons_powtf').
  2493. auto with arith.
  2494. simpl.
  2495. constructor.
  2496. destruct H1.
  2497. pose (H0 H2).
  2498. have : 0 < S (S n0).
  2499. auto with arith.
  2500. have : 1 < S (S n0).
  2501. auto with arith.
  2502. move => H3' H2'.
  2503. pose (nth_prop_list H2' H3' p).
  2504. simpl in e.
  2505. apply : trans_eqv.
  2506. exact e.
  2507. rewrite (cons_bin).
  2508. auto with arith.
  2509. rewrite (tl_bin).
  2510. rewrite (tl_pow_f_bin).
  2511.  
  2512. simpl.
  2513. move => H3.
  2514. have : (pow_' binary_crossing' n0 (h :: a :: t))[@
  2515. FS F1] = (pow_' binary_crossing' n0 (a :: t))[@F1].
  2516. rewrite <- (hd_get').
  2517.  
  2518. rewrite (vec_cons ((pow_' binary_crossing' n0 (h :: a :: t)))).
  2519. simpl.
  2520. destruct n0.
  2521. trivial.
  2522. simpl.
  2523. rewrite (hd_bin).
  2524. rewrite (tl_bin).
  2525. rewrite (tl_pow_f_bin).
  2526. by rewrite (cons_bin).
  2527.  
  2528. pose(partial_eqv_S H' H1).
  2529. move => eq2.
  2530. rewrite eq2.
  2531.  
  2532. destruct n0.
  2533. admit.
  2534.  
  2535.  
  2536. have : eq_vec_partial_eqv (cross_binary_vector h a) (pow_' binary_crossing' n0 (h :: a :: t))[@FS F1] H'.
  2537.  
  2538. destruct n0.
  2539. simpl.
  2540.  
  2541. apply : (partial_eqv_S H' H1).
  2542. simpl.
  2543. rewrite (cons_bin).
  2544.  
  2545. auto with arith.
  2546. simpl.
  2547. simpl in e.
  2548. simpl in eq2.
  2549. rewrite (cons_bin) in eq2.
  2550. auto with arith.
  2551. rewrite (cons_bin) in eq2.
  2552. auto with arith.
  2553. simpl in eq2.
  2554. rewrite (tl_bin) in eq2.
  2555. rewrite (tl_pow_f_bin) in eq2.
  2556. rewrite (tl_bin).
  2557. rewrite (tl_pow_f_bin).
  2558. rewrite (cons_bin).
  2559. rewrite (tl_bin).
  2560. rewrite (tl_pow_f_bin).
  2561. simpl.
  2562. apply : trans_eqv.
  2563.  
  2564. rewrite <- eq2.
  2565. intros.
  2566. simpl.
  2567. apply : eqv_partial_refl.
  2568.  
  2569.  
  2570. Theorem one_eqv_progress : forall {n l} (v : t (t binary (S l)) (S n)) q (H : q < S l) (H' : (S q) < S l),
  2571. prop_list v (fun x y => eq_vector_binary (take _ H x) (take _ H y) = true)
  2572. ->
  2573. prop_list (pow_f binary_crossing' n v) (fun x y => eq_vector_binary (take _ H' x) (take _ H' y) = true).
  2574. intros.
  2575. elim/@rect_2per : v H0.
  2576. admit.
  2577. intros.
  2578. simpl in *.
  2579. do 2! rewrite take_fold.
  2580. do 2! rewrite take_fold in H0.
  2581.  
  2582. intros.
  2583. simpl in H1.
  2584. destruct H1.
  2585. apply H0 in H2.
  2586. simpl.
  2587. rewrite (cons_bin); intros.
  2588. do 2! rewrite (tl_bin).
  2589. rewrite -> binary_S.
  2590. rewrite (tl_pow_f_bin).
  2591. rewrite (cons_bin (binary_crossing' (pow_f binary_crossing' (S n0) (a :: t)))).
  2592. move => Hyp1.
  2593. do 2! rewrite (tl_bin).
  2594. rewrite (tl_pow_f_bin).
  2595. simpl.
  2596. constructor.
  2597. have : 0 < S (S n0).
  2598. auto with arith.
  2599. move => H3.
  2600. pose (nth_prop_list H3 Hyp1 H2).
  2601. simpl in e.
  2602. fold @take.
  2603. move : e H1.
  2604. do 6! rewrite take_fold.
  2605. move => e H1.
  2606. apply lex_vec_eq in e.
  2607. apply lex_vec_eq in H1.
  2608. apply cross_refl_take in e.
  2609.  
  2610. auto with arith.
  2611. have : (pow_f binary_crossing' (S n0) (h :: a :: t)))[@F1]
  2612.  
  2613. elim/@caseS' : t H0 H2.
  2614. auto with arith.
  2615. intros.
  2616.  
  2617.  
  2618. do 2! rewrite (tl_bin).
  2619.  
  2620. Theorem one_eqv_progress : forall {n l} (v : pure_lex l n) q (H : q < S l) (H : (S q) < S l) b,
  2621. prop_list v (eqv_progress b H)
  2622. ->
  2623. prop_list (pow_f binary_crossing' (S n) v) (eqv_progress b H)
  2624. .
  2625. intros.
  2626. induction q.
  2627. admit.
  2628.  
  2629. elim/@rect_2per : v IHq H H0 H1.
  2630. intros.
  2631. pose (IHq
  2632. simpl in *.
  2633. destruct H2.
  2634. destruct H3.
  2635. rewrite -> binary_S.
  2636. rewrite (cons_powtf' a h t).
  2637.  
  2638. by simpl.
  2639.  
  2640. intros.
  2641.  
  2642. rewrite cons_powtf.
  2643. auto with arith.
  2644. simpl.
  2645. constructor.
  2646. rewrite -> binary_S.
  2647. rewrite (cons_powtf' a h t).
  2648. auto with arith.
  2649. simpl.
  2650. do 3! rewrite <- (hd_get').
  2651. destruct n0.
  2652. admit.
  2653. rewrite (cons_bin (pow_f binary_crossing' (S n0) t)).
  2654. simpl.
  2655. intros.
  2656. rewrite (hd_bin _).
  2657. simpl.
  2658. move => H3.
  2659. unfold eqv_progress.
  2660. simpl in H2.
  2661. destruct H2.
  2662. destruct H4.
  2663. unfold eqv_progress in H2.
  2664. unfold eqv_progress in H4.
  2665. do 2! rewrite <- (hd_get').
  2666.  
  2667. rewrite (hd_bin).
  2668. intros;simpl in *.
  2669. admit.
  2670. auto with arith.
  2671. auto with arith.
  2672. auto with arith.
  2673.  
  2674. simpl in *.
  2675. destruct H2.
  2676. pose (H H0 H1 H3).
  2677. rewrite (cons_bin).
  2678. simpl.
  2679. constructor.
  2680. unfold eqv_progress in *.
  2681. destruct H3.
  2682.  
  2683.  
  2684. rewrite -> (cons_bin _ Hyp0) in p.
  2685. simpl in p.
  2686.  
  2687. destruct p.
  2688. rewrite -> (tl_bin) in H4.
  2689. rewrite -> (tl_bin) in H4.
  2690.  
  2691. rewrite (tl_pow_f_bin _) in H4.
  2692.  
  2693. rewrite -> binary_S.
  2694. rewrite cons_powtf.
  2695. auto with arith.
  2696. rewrite (cons_bin) in H3.
  2697. rewrite -> (tl_bin) in H3.
  2698. rewrite (tl_pow_f_bin _) in H3.
  2699. simpl in H3.
  2700. rewrite <- (hd_get') in H3.
  2701. rewrite <- (hd_get') in H3.
  2702.  
  2703. rewrite -> (hd_bin) in H3.
  2704.  
  2705. have : (cross_binary_vector
  2706. (pow_f binary_crossing' n0 (a :: t))[@of_nat_lt
  2707. (Nat.lt_0_succ (S n0))]
  2708. (pow_f binary_crossing' n0 (a :: t))[@of_nat_lt (one_le n0)])[@FS (of_nat_lt (lt_S_n q l H1))] = b.
  2709. have : of_nat_lt (Nat.lt_0_succ (S n0)) = F1.
  2710. trivial.
  2711. have : of_nat_lt (one_le n0) = FS F1.
  2712. trivial.
  2713. move => i i'.
  2714. rewrite i.
  2715. rewrite i'.
  2716.  
  2717. rewrite <- H3.
  2718.  
  2719. simpl.
  2720.  
  2721.  
  2722. have : FS (of_nat_lt (lt_S_n q l H1)) = of_nat_lt H1.
  2723. trivial.
  2724. move => H3'.
  2725.  
  2726. rewrite <- H3'.
  2727.  
  2728. rewrite <- (hd_get').
  2729. rewrite (hd_bin).
  2730. simpl.
  2731.  
  2732. destruct q.
  2733. intros.
  2734. simpl in *.
  2735. constructor.
  2736. unfold eqv_progress in *.
  2737. destruct H1.
  2738. exact (sym_binary_pair (sym_binary_pair ((sym_binary_pair H1 H2)) H2) H2).
  2739. by destruct H1.
  2740. intros.
  2741. simpl in *.
  2742. constructor.
  2743. unfold eqv_progress.
  2744. destruct H1.
  2745. exact (sym_binary_pair (sym_binary_pair ((sym_binary_pair H1 H2)) H2) H2).
  2746. by destruct H1.
  2747.  
  2748. intros.
  2749. by [].
  2750.  
  2751. by destruct q.
  2752. by simpl in *.
  2753.  
  2754.  
  2755. simpl in *.
  2756. destruct H2.
  2757. destruct H3.
  2758. rewrite (cons_bin).
  2759. intros.
  2760. simpl in *.
  2761. constructor.
  2762. unfold eqv_progress.
  2763. unfold eqv_progress in H2.
  2764. unfold eqv_progress in H3.
  2765. rewrite (cons_bin).
  2766. simpl.
  2767. rewrite (cons_bin).
  2768. simpl.
  2769. rewrite -> (tl_bin).
  2770. rewrite (tl_pow_f_bin).
  2771. rewrite (cons_bin (pow_f binary_crossing' n0 t)).
  2772. simpl.
  2773.  
  2774.  
  2775.  
  2776. rewrite (cons_bin (pow_f binary_crossing' (S n0) t)).
  2777. simpl.
  2778. destruct n0.
  2779. simpl.
  2780. intros.
  2781.  
  2782. (* intros; simpl.
  2783. have : a[@of_nat_lt H1] = b /\
  2784. prop_list t (fun v : VectorDef.t binary (S l) => v[@of_nat_lt H1] = b) .
  2785. have : @FS _ (of_nat_lt (lt_S_n q l H1)) = of_nat_lt H1.
  2786. by simpl.
  2787. move => H3'.
  2788. constructor.
  2789. by rewrite <- H3'.
  2790. by rewrite <- H3'.
  2791. move => H4'.
  2792. pose (H H0 H1 H4').
  2793. simpl in p. *)
  2794.  
  2795.  
  2796. rewrite (cons_bin).
  2797. intros.
  2798. do 2! rewrite -> (tl_bin).
  2799. rewrite (tl_pow_f_bin _).
  2800. rewrite -> binary_S.
  2801. rewrite -> binary_S.
  2802. rewrite -> binary_S.
  2803.  
  2804.  
  2805. intros.
  2806. simpl.
  2807. elim/@rect_leb : a/H.
  2808. intros.
  2809. destruct a.
  2810. right.
  2811. simpl.
  2812. rewrite (cross_eq _).
  2813. by unfold eqv_progress.
  2814. admit.
  2815. admit.
  2816. intros.
  2817. destruct H0.
  2818. destruct a.
  2819. right.
  2820. simpl in *.
  2821. rewrite (cross_eq _).
  2822. admit.
  2823. admit.
  2824. admit.
  2825. intros.
  2826. destruct H0.
  2827. left.
  2828. move : v H0.
  2829. elim/@rect_leb : a/H.
  2830. intros.
  2831. simpl.
  2832. rewrite (test (pow_f binary_crossing n0 v0)) in H0.
  2833. simpl in H0.
  2834. destruct n0.
  2835. move : H0.
  2836. elim/@caseS' : v0.
  2837. intros.
  2838. simpl in *.
  2839. move : H0.
  2840. elim/@case0 : t.
  2841. intros.
  2842. simpl in *.
  2843. rewrite (cross_eq _) in H0.
  2844. unfold eqv_progress in H0.
  2845. admit.
  2846. admit.
  2847. admit.
  2848. intros.
  2849. simpl in *.
  2850. rewrite (test (pow_f binary_crossing n0 v0)) in H1.
  2851.  
  2852.  
  2853. unfold binary_crossing.
  2854. rewrite -> (shift_S _ _).
  2855.  
  2856. Theorem one_eqv_progress : forall {n l y} (v : pure_lex l n) (H : y < S l),
  2857. eqv_progress (binary_crossing v) zero H \/ eqv_progress (binary_crossing v) one H.
  2858. intros.
  2859. elim/@rectS : v.
  2860. intros.
  2861. simpl.
  2862. rewrite (cross_eq _).
  2863. destruct (a[@of_nat_lt H]).
  2864. by left.
  2865. by right.
  2866. intros.
  2867. unfold binary_crossing.
  2868. simpl.
  2869. destruct H0.
  2870. left.
  2871. have : nth (last v) (of_nat_lt H) = zero.
  2872. intros.
  2873. move : H0.
  2874. elim/@rectS : v.
  2875. intros.
  2876. simpl in *.
  2877. by rewrite (cross_eq _) in H0.
  2878. intros.
  2879. simpl in *.
  2880. unfold binary_crossing in H1.
  2881. simpl in H1.
  2882. move : v H0 H1.
  2883. elim/@rect_leb : a0/H; intros.
  2884. simpl in *.
  2885. admit.
  2886. admit.
  2887.  
  2888.  
  2889. move : v H0.
  2890. elim/@rect_leb : a/H.
  2891. intros.
  2892. simpl in *.
  2893. unfold binary_crossing.
  2894.  
  2895.  
  2896. Fixpoint eq_walk_cross {l} (x y : t binary l) (k : nat) : t binary l.
  2897. destruct l.
  2898. refine (nil _).
  2899. elim/@caseS' : x.
  2900. elim/@caseS' : y.
  2901. intros.
  2902. refine (match k with
  2903. |S ns => _
  2904. |0 => _
  2905. end).
  2906. refine (cons _ h0 _ t0).
  2907. refine (cons _ h _ (eq_walk_cross _ t t0 ns)).
  2908. Defined.
  2909.  
  2910.  
  2911.  
  2912. Definition take_eqv {l s} (x' y' : t binary (S l)) (E : S s <= S l) : nat :=
  2913. eq_vec_binary_quantification (take _ E x') (take _ E y') 0.
  2914.  
  2915. Fixpoint quant_eqv {l n} (x' : pure_lex l n) (y : t binary (S l)) (s : nat) : S s <= S l -> Prop.
  2916. elim/@rectS : x'.
  2917. refine (fun x E => take_eqv x y E = S s).
  2918. intros.
  2919. refine (take_eqv a y H = S s \/ quant_eqv _ _ v y s H).
  2920. Defined.
  2921.  
  2922. Theorem quant_eqv_refl : forall {n q} (x : t binary (S n)) (e : S q <= S n),
  2923. quant_eqv [x] x e.
  2924. intros.
  2925. Ltac f_trivial H := simpl in *; unfold H; by elim.
  2926. elim/@rect_leb : x/e.
  2927. f_trivial @take_eqv.
  2928. f_trivial @take_eqv.
  2929. intros; move : H H0; elim/@caseS' : v.
  2930. destruct a.
  2931. Ltac ignorance H0 h' := intros; simpl in *; unfold h' in *; simpl in *; rewrite -> H0;
  2932. by rewrite <- (plus_n_Sm _ _); rewrite <- (plus_n_O _).
  2933.  
  2934.  
  2935. ignorance H0 @take_eqv.
  2936. ignorance H0 @take_eqv.
  2937. Qed.
  2938.  
  2939. Theorem eq_progess_conserv : forall {n} (v2 : t binary n) q,
  2940. eq_walk_cross v2 v2 q = v2.
  2941.  
  2942. intros.
  2943. move : v2.
  2944. elim/@nat_double_ind : q/n.
  2945. intros;destruct n.
  2946. by elim/@case0 : v2.
  2947. intros;by elim/@caseS' : v2.
  2948. intros;by elim/@case0 : v2.
  2949. intros;elim/@caseS' : v2.
  2950. by intros;simpl;rewrite (H t).
  2951. Qed.
  2952.  
  2953. Theorem cross_eq_partial_refl : True.
  2954.  
  2955. have : forall a b, eq_walk_cross a b 0 = a.
  2956. intros.
  2957. move : b.
  2958. destruct a.
  2959. trivial.
  2960. by elim/@caseS'.
  2961.  
  2962. move => H10.
  2963. have : forall n (v : t _ (S n)),
  2964. pow_f (fun x => shiftin (hd x) (tl x)) n v = v.
  2965. intros.
  2966. elim/@rectS : v.
  2967. intros.
  2968. by destruct n.
  2969. intros.
  2970. simpl.
  2971. have : forall n (v : t _ (S n)), a :: pow_f (fun x => shiftin (hd x) (tl x)) (S n) v = pow_f (fun x => shiftin (hd x) (tl x)) (S n) (a :: v).
  2972. intros.
  2973. elim/@rectS : v0.
  2974. intros.
  2975. destruct n1.
  2976. by [].
  2977. by [].
  2978. intros.
  2979. simpl.
  2980.  
  2981. elim/@case0 : t.
  2982. trivial.
  2983. elim/@caseS : t.
  2984. intros.
  2985. simpl.
  2986.  
  2987. move => H3.
  2988. have : forall n k (v : t (t binary (S k)) (S n)) q,
  2989. shiftin (eq_walk_cross (hd v) (last v) (S q)) (tl (pow_f binary_crossing q v)) = pow_f binary_crossing q v.
  2990. intros.
  2991. move : v.
  2992. elim/@nat_double_ind : n/q.
  2993. intros.
  2994. elim/@caseS' : v.
  2995. intros.
  2996. elim/@case0 : t.
  2997. elim/@caseS' : h.
  2998. simpl.
  2999. induction n.
  3000. simpl.
  3001. intros.
  3002. unfold binary_crossing.
  3003.  
  3004. change (shiftin (cross_binary_vector (hd [h :: t]) (last [h :: t]))
  3005. (tl [h :: t])) with [(cross_binary_vector (h :: t) (h :: t))].
  3006. rewrite (cross_eq _).
  3007. by rewrite (H3 _ _ _).
  3008. intros.
  3009. simpl in *.
  3010. pose (IHn h t).
  3011. rewrite -> (eq_progess_conserv _ (S n)).
  3012. rewrite -> (eq_progess_conserv _ n) in e.
  3013. rewrite <- e.
  3014. unfold binary_crossing.
  3015. rewrite <- (cross_eq _).
  3016.  
  3017. intros.
  3018. rewrite -> (cross_eq _).
  3019. have : forall x k, last (shiftin x k) = x.
  3020. intros.
  3021. by induction k0.
  3022.  
  3023. move => H4.
  3024. rewrite (H4 _ _ _ _).
  3025. have : forall (x : VectorDef.t _ 1) q,
  3026. pow_f binary_crossing q x = x.
  3027. intros.
  3028. elim/@caseS' : x.
  3029. intros.
  3030. elim/@case0 : t0.
  3031. induction q.
  3032. simpl.
  3033. unfold binary_crossing.
  3034. simpl.
  3035. by rewrite -> (cross_eq _).
  3036. simpl.
  3037. rewrite IHq.
  3038. unfold binary_crossing.
  3039. simpl.
  3040. by rewrite -> (cross_eq _).
  3041.  
  3042. move => H5.
  3043. have : (pow_f
  3044. (fun x : pure_lex k 0 =>
  3045. shiftin (cross_binary_vector (hd x) (last x)) (tl x)) n
  3046. [h :: t]) = [h :: t].
  3047. by apply : H5.
  3048. move => H6.
  3049. rewrite -> H6.
  3050. simpl.
  3051. clear e H6.
  3052. destruct k.
  3053. elim/@case0 : t.
  3054. simpl.
  3055. by destruct h.
  3056. elim/@caseS : t.
  3057. simpl.
  3058. destruct h.
  3059. intros; destruct n0.
  3060. elim/@case0 : t.
  3061. by destruct h.
  3062. simpl.
  3063. destruct h.
  3064. by rewrite (cross_eq _).
  3065. by rewrite (cross_eq _).
  3066. intros; destruct n0.
  3067. elim/@case0 : t.
  3068. by destruct h.
  3069. simpl.
  3070. destruct h.
  3071. by rewrite (cross_eq _).
  3072. by rewrite (cross_eq _).
  3073. intros.
  3074. admit.
  3075. intros.
  3076. elim/@caseS' : v.
  3077. intros.
  3078. pose(H t).
  3079. pose (pow_f binary_crossing (S m) (h :: t)).
  3080. simpl in p.
  3081.  
  3082. destruct n.
  3083. elim/@case0 : t.
  3084. simpl.
  3085. by rewrite (cross_eq _).
  3086. elim/@caseS' : t.
  3087. intros.
  3088.  
  3089. induction n0.
  3090. unfold binary_crossing.
  3091.  
  3092. intros; by elim/@b_rect : x/y.
  3093. simpl in *.
  3094. intros; rewrite <- (IHn0 x y).
  3095. unfold binary_crossing.
  3096. simpl.
  3097. by elim/@b_rect : x/y.
  3098. intros.
  3099. simpl.
  3100. have : forall a b, shiftin a [b] = [b; a].
  3101. auto.
  3102. move => H2.
  3103. rewrite (H2 _ _ _) in H.
  3104.  
  3105. simpl in *.
  3106. destruct q.
  3107. simpl in *.
  3108. intros.
  3109. pose (IHq x y).
  3110. move : e.
  3111. elim/@b_rect : x/y.
  3112. trivial.
  3113. trivial.
  3114.  
  3115. intros.
  3116. by elim/@b_rect : a/b.
  3117.  
  3118.  
  3119. have : forall x n, hd x = hd (shiftin n x).
  3120. intros.
  3121. by elim/@rectS : x.
  3122.  
  3123. have : forall {A} n (v : t A (S n)) k, (last (shiftin k v)) = k.
  3124. intros.
  3125. by elim/@rectS : v.
  3126.  
  3127. have : forall e e1 k v, e = e1 /\ v = k :: (tl v) -> shiftin e v = k :: tl (shiftin e1 v).
  3128. intros; destruct H.
  3129. move : H0 H.
  3130. elim/@rectS : v.
  3131. intros; simpl.
  3132. rewrite H; simpl in H.
  3133. apply (f_equal hd) in H0; simpl in H0.
  3134. by rewrite <- H0.
  3135. intros; simpl in *; rewrite H1.
  3136. pose (f_equal hd H0); simpl in e0; by rewrite e0.
  3137.  
  3138. have : forall v, v = hd v :: tl v.
  3139. move => t n.
  3140. by elim/@rectS.
  3141.  
  3142. intros.
  3143.  
  3144. move : H v.
  3145. move => H v0.
  3146. elim/@rectS : v0.
  3147. intros.
  3148. destruct q.
  3149. rewrite (x3 _ _ _ _).
  3150. simpl.
  3151. by unfold binary_crossing.
  3152. simpl.
  3153. unfold binary_crossing.
  3154. apply : x0.
  3155. constructor.
  3156. trivial.
  3157. rewrite <- (x2 _ _ _ _).
  3158. rewrite -> (x1 _ _ _ _).
  3159.  
  3160. intros.
  3161. simpl.
  3162. generalize (pow_f
  3163. (fun x0 : pure_lex l 1 =>
  3164. shiftin (cross_binary_vector (hd x0) (last x0)) (tl x0)) q
  3165. [a; a0]).
  3166. move => p.
  3167. have : forall H p, tl p =
  3168. eq_walk_cross (hd (tl p)) (cross_binary_vector (hd p) (last p)) H
  3169. :: tl (tl p).
  3170. intros.
  3171. induction n0.
  3172. rewrite (x3 _ _ _ _).
  3173. apply : x.
  3174. pose (IHn0 (le_Sn_le _ _ H0)).
  3175. rewrite -> e.
  3176. simpl in *.
  3177. have : forall x y v, x = y -> x :: v = y :: v.
  3178. congruence.
  3179. apply.
  3180. generalize (le_Sn_le (S n0) (S n1) H0).
  3181. intros.
  3182. have : forall p0 l0, eq_walk_cross (hd (tl p0)) (cross_binary_vector (hd p0) (last p0)) l0 =
  3183. eq_walk_cross
  3184. (eq_walk_cross (hd (tl p0)) (cross_binary_vector (hd p0) (last p0)) l0)
  3185. (cross_binary_vector (hd p0) (last p0)) l0.
  3186. intros.
  3187.  
  3188. elim/@caseS' : p1.
  3189. clear l0.
  3190. intros.
  3191. move : t.
  3192. simpl.
  3193.  
  3194. elim/@rect_leb : h/l1.
  3195. simpl.
  3196. unfold caseS'.
  3197. simpl.
  3198. intros.
  3199. elim/@caseS' : (last t).
  3200. intros;elim/@b_rect : a1/h.
  3201. simpl.
  3202. rewrite (x3 _ _ _).
  3203. by rewrite (x3 _ _ _).
  3204. by rewrite (x3 _ _ _).
  3205. by rewrite (x3 _ _ _).
  3206. by rewrite (x3 _ _ _).
  3207. intros.
  3208. by rewrite (x3 _ _ _).
  3209. intros.
  3210. simpl in *.
  3211.  
  3212.  
  3213. Admitted.
  3214.  
  3215. Theorem crossing_walk : forall {l n q} (x : pure_lex l n) (E : S q <= S l),
  3216. quant_eqv (pow_f binary_crossing q x) (hd x) E.
  3217.  
  3218. intros.
  3219. cbv in x.
  3220. elim/@rectS : x.
  3221. induction q.
  3222. intros.
  3223. simpl in *.
  3224. by simpl; rewrite (cross_eq _); apply : quant_eqv_refl.
  3225. admit.
  3226. intros.
  3227. simpl in *.
  3228. unfold quant_eqv.
  3229. Admitted.
  3230.  
  3231.  
  3232. Fixpoint EQ_vec {l n} (x : pure_lex l n) (y : t binary (S l)) : Prop.
  3233. refine (match x in (t _ (S n)) with
  3234. |cons _ _ 0 k => match k with
  3235. |cons _ _ _ _ => _
  3236. |nil _ => _
  3237. end
  3238. |cons _ _ (S n') _ => _
  3239. end).
  3240.  
  3241. refine (eq_vector_binary t y).
  3242. exact idProp.
  3243. refine (eq_vector_binary t y /\ (EQ_vec _ _ t1 y)).
  3244. Defined.
  3245.  
  3246. Theorem totally_convergent :
  3247. forall {l n} (x : pure_lex l n), EQ_vec (whole_crossing x) (hd (whole_crossing x)).
  3248. intros.
  3249. move : x.
  3250. induction l.
  3251. intros.
  3252. elim/@rectS : x.
  3253. intros.
  3254. elim/@caseS' : a.
  3255. intros.
  3256. simpl.
  3257. elim/@case0 : t.
  3258. simpl in *.
  3259. destruct h.
  3260. trivial.
  3261. trivial.
  3262. intros.
  3263. elim/@caseS' : a.
  3264. move : H.
  3265. elim/@caseS' : v.
  3266. intros.
  3267. move : H.
  3268. elim/@caseS' : h.
  3269. elim/@case0 : t0.
  3270.  
  3271. intros.
  3272. move : H.
  3273. elim/@case0 : t0.
  3274. intros.
  3275. unfold whole_crossing in *.
  3276. simpl in *.
  3277.  
  3278. pose(h :: t).
  3279. unfold whole_crossing.
  3280. simpl.
  3281.  
  3282. admit.
  3283. intros.
  3284. simpl in *.
  3285. unfold whole_crossing in *.
  3286. simpl in *.
  3287.  
  3288. intros.
  3289. simpl in *.
  3290.  
  3291.  
  3292. destruct l.
  3293.  
  3294.  
  3295.  
  3296. destruct v0.
  3297.  
  3298. by pose (lex_binary_eqv (lex' (cross_binary_vector (cross_binary_vector a a) (cross_binary_vector a a)))).
  3299. intros.
  3300.  
  3301.  
  3302. Instance SEnvironment : forall x y (k : t (SAgent x) (S y)),
  3303. @Environment _ _ _ _ _ _ (
  3304. fun x => t x (S y)) boundness get_agent (SAgent' x y) k (F' shift match_lex).
  3305. {
  3306. constructor.
  3307. exists 0.
  3308. elim/@caseS : x0.
  3309. unfold boundness.
  3310. auto with arith.
  3311.  
  3312. have : boundness k 0.
  3313. unfold boundness.
  3314. auto with arith.
  3315. move => H'.
  3316. have : boundness k y.
  3317. unfold boundness.
  3318. auto with arith.
  3319. move => H2'.
  3320. pose (@P' _ _ _ k boundness (@perception (lex x) nat (SAgent x) cross_lex (lex_binary (n:=x))
  3321. (t^~ (S y)) boundness (binary_lex x) (SAgent x)
  3322. (SAgent' x y)) 0 y H' H2').
  3323. have : perception H' H2'.
  3324. unfold perception.
  3325. simpl; unfold view.
  3326.  
  3327. by rewrite ( Nat.eqb_eq y y).
  3328. auto.
  3329.  
  3330. intros.
  3331. unfold boundness in *.
  3332. exists (0, y).
  3333. exists (Nat.lt_0_succ y, @le_n (S y)).
  3334. unfold view.
  3335. simpl.
  3336. apply : Nat.eqb_refl.
  3337.  
  3338. intros.
  3339. constructor;intros.
  3340. destruct Pr.
  3341. unfold view in PE0.
  3342. unfold action_prop.
  3343. unfold boundness in *.
  3344. simpl in *.
  3345. unfold action_prop.
  3346. unfold get_agent.
  3347. move : Px'0 Py'0 PE0.
  3348. intros.
  3349. apply andb_true_iff in PE0.
  3350. destruct PE0.
  3351. apply beq_nat_true in H.
  3352. apply beq_nat_true in H0.
  3353. subst.
  3354. intros; apply : law1.
  3355.  
  3356. simpl in *.
  3357. unfold boundness in *.
  3358. destruct Pr.
  3359. simpl in *.
  3360. unfold view in PE0.
  3361. apply andb_true_iff in PE0.
  3362. destruct PE0.
  3363. apply beq_nat_true in H; apply beq_nat_true in H0.
  3364. subst.
  3365.  
  3366. unfold get_agent; unfold nth_order.
  3367. have : of_nat_lt a = of_nat_lt Px'0.
  3368. apply of_nat_lt_c.
  3369. move => H2; rewrite H2.
  3370. apply : law2.
  3371. }
  3372.  
  3373. Defined.
  3374.  
  3375. Instance SUniverse : forall x y (v : t (SAgent x) (S y)), @State _ _ _ _ _ _ (
  3376. fun x => t x (S y)) boundness get_agent (SAgent' x y) shift match_lex v.
  3377. constructor.
  3378. intros.
  3379.  
  3380. constructor.
  3381. (*when P(0) for environment *)
  3382. apply : SEnvironment.
  3383. intros.
  3384. constructor.
  3385. (*when P k -> P (k + 1), for the environment *)
  3386. unfold boundness in *.
  3387. move => H2; exists y; auto with arith.
  3388.  
  3389. (*need to simplify *)
  3390. have : boundness k 0.
  3391. unfold boundness.
  3392. auto with arith.
  3393. move => H'.
  3394. have : boundness k y.
  3395. unfold boundness.
  3396. auto with arith.
  3397. move => H2'.
  3398. pose (@P' _ _ _ (match_lex (shift k)) boundness (@perception (lex x) nat (SAgent x) cross_lex (lex_binary (n:=x))
  3399. (t^~ (S y)) boundness (binary_lex x) (SAgent x)
  3400. (SAgent' x y)) 0 y H' H2').
  3401. have : perception H' H2'.
  3402. unfold perception.
  3403. simpl; unfold view.
  3404.  
  3405. by rewrite ( Nat.eqb_eq y y).
  3406. intros; auto.
  3407.  
  3408. intros; unfold boundness in *; exists (0, y); exists (Nat.lt_0_succ y, @le_n (S y)).
  3409. unfold view; apply : Nat.eqb_refl.
  3410. intros; constructor; simpl.
  3411. intros; destruct Pr; simpl in *.
  3412. intros;unfold action_prop; unfold boundness in *; apply andb_true_iff in PE0.
  3413. destruct PE0.
  3414. apply beq_nat_true in H; apply beq_nat_true in H0; subst.
  3415. (*both law1 and law2 proofs of inductive interaction was straightfoward, once law1 and law2 were
  3416. strong enough to generalization of any type obeying just the type constaint *)
  3417. apply : law1.
  3418. intros; destruct Pr; simpl in *.
  3419. intros; unfold boundness in *; apply andb_true_iff in PE0.
  3420. destruct PE0.
  3421. apply beq_nat_true in H; apply beq_nat_true in H0.
  3422. subst; apply : law2.
  3423. Defined.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement