Guest User

Untitled

a guest
Apr 24th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.92 KB | None | 0 0
  1. Require Import ZArith.
  2.  
  3. Variable eqdec : forall {A} (x y:A), {x=y}+{x<>y}.
  4. Variable extensionality : forall A B (f g : A -> B), (forall x, f x = g x) -> f = g.
  5.  
  6. Variable Label : Set.
  7. Variable Channel : Set.
  8. Variable label : Channel -> Label.
  9. Variable Value : Set.
  10. Definition LabeledValueSeq := list (Value * Label).
  11. Variable Key : Set.
  12. Definition Store := Key -> LabeledValueSeq.
  13. Variable Code : Set.
  14. Inductive Thread :=
  15. Thrd : Code -> Label -> Thread.
  16. Definition Threads := Thread -> nat.
  17. Definition ReadContinuation := LabeledValueSeq -> Code.
  18. Inductive Operation :=
  19. | Read : Key -> ReadContinuation -> Operation
  20. | Write : Key -> Value -> Code -> Operation
  21. | Delete : Key -> Code -> Operation
  22. | GetAllKeys : ReadContinuation -> Operation
  23. | Send : Channel -> Value -> Code -> Operation
  24. | Fork : Code -> Code -> Operation
  25. | RaiseLabel : Label -> Code -> Operation
  26. | Stuck : Operation
  27. .
  28. Inductive Event :=
  29. | Input : Thread -> Event
  30. | Output : Channel -> Value -> Event
  31. | Epsilon : Event
  32. .
  33. Inductive State :=
  34. St : Store -> Threads -> State.
  35. Variable run : Code -> Operation.
  36. Variable Flows : Label -> Label -> Prop.
  37. Variable Flows_dec : forall l1 l2, {Flows l1 l2}+{~Flows l1 l2}.
  38. Variable Flows_trans : forall l1 l2 l3, Flows l1 l2 -> Flows l2 l3 -> Flows l1 l3.
  39. Fixpoint delete (S:LabeledValueSeq) l : LabeledValueSeq :=
  40. match S with
  41. | nil =>
  42. nil
  43. | cons (v', l') S' =>
  44. if Flows_dec l l' then
  45. delete S' l
  46. else
  47. cons (v', l') (delete S' l)
  48. end.
  49. Definition write (S:LabeledValueSeq) v l : LabeledValueSeq :=
  50. cons (v, l) (delete S l).
  51. Fixpoint pS (S:LabeledValueSeq) l : LabeledValueSeq :=
  52. match S with
  53. | nil =>
  54. nil
  55. | cons (v', l') S' =>
  56. if Flows_dec l' l then
  57. cons (v', l') (pS S' l)
  58. else
  59. pS S' l
  60. end.
  61. Definition thread_label t :=
  62. match t with
  63. | Thrd _ l => l
  64. end.
  65. Definition pts (ts:Threads) l : Threads :=
  66. fun t =>
  67. if Flows_dec (thread_label t) l then
  68. ts t
  69. else
  70. 0
  71. .
  72. Definition px (x:Store) l : Store :=
  73. fun k =>
  74. pS (x k) l
  75. .
  76. Definition pe e l : Event :=
  77. match e with
  78. | Input t =>
  79. if Flows_dec (thread_label t) l then
  80. e
  81. else
  82. Epsilon
  83. | Output ch v =>
  84. if Flows_dec (label ch) l then
  85. e
  86. else
  87. Epsilon
  88. | Epsilon =>
  89. Epsilon
  90. end
  91. .
  92. Definition pX (X:State) l : State :=
  93. match X with
  94. | St x ts => St (px x l) (pts ts l)
  95. end
  96. .
  97. Definition multi_one (t:Thread) : Threads :=
  98. fun t' =>
  99. if eqdec t' t then
  100. 1
  101. else
  102. 0
  103. .
  104. Definition multi_two (t1:Thread) (t2:Thread) : Threads :=
  105. fun t' =>
  106. if eqdec t' t1 then
  107. 1
  108. else if eqdec t' t2 then
  109. 1
  110. else
  111. 0
  112. .
  113. Definition upd (x:Store) k S : Store :=
  114. fun k' =>
  115. if eqdec k k' then
  116. S
  117. else
  118. x k'
  119. .
  120. Inductive Step : Store -> Thread -> Event -> State -> Prop :=
  121. | SSend : forall x c l ch v c',
  122. run c = Send ch v c' ->
  123. Flows l (label ch) ->
  124. Step x (Thrd c l) (Output ch v) (St x (multi_one (Thrd c' l)))
  125. | SRead : forall x c l f k,
  126. run c = Read k f ->
  127. Step x (Thrd c l) Epsilon (St x (multi_one (Thrd (f (pS (x k) l)) l)))
  128. | SWrite : forall x c l k v c',
  129. run c = Write k v c' ->
  130. Step x (Thrd c l) Epsilon (St (upd x k (write (x k) v l)) (multi_one (Thrd c' l)))
  131. (*
  132. | SDelete : forall c k c' x l,
  133. run c = Delete k c' ->
  134. Step x (Thrd c l) Epsilon (St (upd x k (delete (x k) l)) (multi_one (Thrd c' l)))
  135. | SGetAllKeys : forall c f x l,
  136. run c = GetAllKeys f ->
  137. Step x (Thrd c l) Epsilon (St x (multi_one (Thrd (f (getallkeys x l)) l)))
  138. *)
  139. | SFork : forall x c l c1 c2,
  140. run c = Fork c1 c2 ->
  141. Step x (Thrd c l) Epsilon (St x (multi_two (Thrd c1 l) (Thrd c2 l)))
  142. | SRaiseLabel : forall c l' c' x l,
  143. run c = RaiseLabel l' c' ->
  144. Flows l l' ->
  145. Step x (Thrd c l) Epsilon (St x (multi_one (Thrd c' l')))
  146. .
  147. Definition multi_cons (ts:Threads) t : Threads :=
  148. fun t' =>
  149. if eqdec t t' then
  150. 1 + ts t'
  151. else
  152. ts t'
  153. .
  154. Definition multi_plus (ts1 ts2:Threads) : Threads :=
  155. fun t =>
  156. ts1 t + ts2 t
  157. .
  158. Inductive SStep : State -> Event -> State -> Prop :=
  159. | SSStart : forall x ts t,
  160. SStep (St x ts) (Input t) (St x (multi_cons ts t))
  161. | SSSkip : forall X,
  162. SStep X Epsilon X
  163. | SSThread : forall x ts c l e x' ts',
  164. Step x (Thrd c l) e (St x' ts') ->
  165. SStep (St x (multi_cons ts (Thrd c l))) e (St x' (multi_plus ts ts'))
  166. .
  167.  
  168. Definition ConjectureTSNI := forall X1 l X2 e1 X1',
  169. pX X1 l = pX X2 l ->
  170. SStep X1 e1 X1' ->
  171. exists X2' e2,
  172. SStep X2 e2 X2'
  173. /\
  174. pX X1' l = pX X2' l
  175. /\
  176. pe e1 l = pe e2 l
  177. .
  178.  
  179. Fixpoint pes (es : list Event) (l : Label) : list Event :=
  180. match es with
  181. | nil => nil
  182. | cons e xxx => cons (pe e l) (pes xxx l)
  183. end
  184. .
  185. Inductive SStepStar : State -> list Event -> State -> Prop :=
  186. | StarNil : forall X,
  187. SStepStar X nil X
  188. | StarCons : forall X e X' es X'',
  189. SStep X e X' ->
  190. SStepStar X' es X'' ->
  191. SStepStar X (cons e es) X''
  192. .
  193. Definition ConjectureTSNIStar := forall X1 l es1 X1',
  194. SStepStar X1 es1 X1' ->
  195. forall X2,
  196. pX X1 l = pX X2 l ->
  197. exists X2' es2,
  198. SStepStar X2 es2 X2'
  199. /\
  200. pX X1' l = pX X2' l
  201. /\
  202. pes es1 l = pes es2 l
  203. .
  204.  
  205. (****************)
  206.  
  207. Definition LSStep X1 e L X2 := exists e' X2', SStep X1 e' X2' /\ pe e' L = e /\ pX X2' L = X2.
  208.  
  209. Lemma lemma_pts_multicons_1 : forall ts c l l',
  210. Flows l' l ->
  211. pts (multi_cons ts (Thrd c l')) l = multi_cons (pts ts l) (Thrd c l')
  212. .
  213. Proof.
  214. intros.
  215. apply extensionality.
  216. intros.
  217. unfold pts, multi_cons, thread_label.
  218. destruct (eqdec (Thrd c l') x).
  219. -
  220. destruct x as (c2, l2).
  221. injection e; intros.
  222. rewrite <- H0.
  223. destruct (Flows_dec l' l); intuition.
  224. -
  225. reflexivity.
  226. Qed.
  227.  
  228. Lemma lemma_pts_multicons_2 : forall ts c l l',
  229. ~Flows l' l ->
  230. pts (multi_cons ts (Thrd c l')) l = pts ts l
  231. .
  232. Proof.
  233. intros.
  234. apply extensionality.
  235. intros.
  236. unfold pts, multi_cons, thread_label.
  237. destruct (eqdec (Thrd c l') x).
  238. -
  239. destruct x as (c2, l2).
  240. injection e; intros.
  241. rewrite <- H0.
  242. destruct (Flows_dec l' l); intuition.
  243. -
  244. reflexivity.
  245. Qed.
  246.  
  247. Lemma lemma_pts_multiplus : forall ts1 ts2 l ,
  248. pts (multi_plus ts1 ts2) l = multi_plus (pts ts1 l) (pts ts2 l)
  249. .
  250. Proof.
  251. intros.
  252. apply extensionality.
  253. intro t.
  254. destruct t as (c, l').
  255. unfold pts, multi_plus, thread_label.
  256. destruct (Flows_dec l' l)
  257. ; reflexivity.
  258. Qed.
  259.  
  260. Lemma lemma_multiplus_zero : forall ts,
  261. multi_plus ts (fun t => 0) = ts.
  262. Proof.
  263. intros.
  264. unfold multi_plus.
  265. apply extensionality; intro t.
  266. omega.
  267. Qed.
  268.  
  269. Lemma lemma_pts_multione : forall c l' l,
  270. Flows l' l ->
  271. pts (multi_one (Thrd c l')) l = multi_one (Thrd c l')
  272. .
  273. intros.
  274. unfold pts, multi_one, thread_label.
  275. apply extensionality.
  276. intro t.
  277. destruct t.
  278. destruct (Flows_dec l0 l); auto.
  279. destruct (eqdec (Thrd c0 l0) (Thrd c l')).
  280. congruence.
  281. trivial.
  282. Qed.
  283.  
  284. Lemma lemma_pts_multitwo : forall c1 c2 l' l,
  285. Flows l' l ->
  286. pts (multi_two (Thrd c1 l') (Thrd c2 l')) l = multi_two (Thrd c1 l') (Thrd c2 l')
  287. .
  288. intros.
  289. unfold pts, multi_two, thread_label.
  290. apply extensionality.
  291. intro t.
  292. destruct t.
  293. destruct (Flows_dec l0 l); auto.
  294. destruct (eqdec (Thrd c l0) (Thrd c1 l')).
  295. congruence.
  296. destruct (eqdec (Thrd c l0) (Thrd c2 l')).
  297. congruence.
  298. trivial.
  299. Qed.
  300.  
  301. Lemma lemma_invisibility_1 : forall x c l' e x' ts' l,
  302. ~Flows l' l ->
  303. Step x (Thrd c l') e (St x' ts') ->
  304. px x' l = px x l
  305. .
  306. Proof.
  307. intros.
  308. rename H into T1, H0 into T2.
  309. inversion T2; auto.
  310. unfold px, upd, write.
  311. apply extensionality; intro k'.
  312. destruct (eqdec k k'); auto.
  313. simpl.
  314. destruct (Flows_dec l' l); try congruence.
  315. rewrite <- e0.
  316. clear H4.
  317. induction (x k); auto.
  318. simpl.
  319. destruct a.
  320. destruct (Flows_dec l2 l).
  321. - (* This case is copy-pasted below *)
  322. destruct (Flows_dec l' l2).
  323. pose (Flows_trans l' l2 l).
  324. intuition. (* contradiction *)
  325. simpl.
  326. destruct (Flows_dec l2 l); congruence.
  327. - (* This case is copy-pasted from above *)
  328. destruct (Flows_dec l' l2).
  329. pose (Flows_trans l' l2 l).
  330. intuition. (* contradiction *)
  331. simpl.
  332. destruct (Flows_dec l2 l); congruence.
  333. Qed.
  334.  
  335. Lemma lemma_invisibility_2 : forall x c l' e x' ts' l,
  336. ~Flows l' l ->
  337. Step x (Thrd c l') e (St x' ts') ->
  338. pe e l = Epsilon
  339. .
  340. Proof.
  341. intros.
  342. rename H0 into T1.
  343. inversion T1; auto.
  344. simpl.
  345. destruct (Flows_dec (label ch) l); auto.
  346. pose (Flows_trans l' (label ch) l).
  347. intuition. (* There's a contradiction. *)
  348. Qed.
  349.  
  350. Lemma lemma_invisibility_3 : forall x c l' e x' ts' l,
  351. ~Flows l' l ->
  352. Step x (Thrd c l') e (St x' ts') ->
  353. pts ts' l = fun t => 0
  354. .
  355. Proof.
  356. intros.
  357. rename H0 into T1.
  358. apply extensionality; intro t.
  359. destruct t as (c'', l'').
  360. unfold pts, thread_label.
  361. destruct (Flows_dec l'' l); auto.
  362. inversion T1.
  363. - unfold multi_one.
  364. destruct (eqdec (Thrd c'' l'') (Thrd c' l'))
  365. ; congruence.
  366. - unfold multi_one.
  367. destruct (eqdec (Thrd c'' l'') (Thrd (f0 (pS (x' k) l')) l'))
  368. ; congruence.
  369. - unfold multi_one.
  370. destruct (eqdec (Thrd c'' l'') (Thrd c' l'))
  371. ; congruence.
  372. - unfold multi_two.
  373. destruct (eqdec (Thrd c'' l'') (Thrd c1 l'))
  374. ; destruct (eqdec (Thrd c'' l'') (Thrd c2 l'))
  375. ; congruence.
  376. - unfold multi_one.
  377. destruct (eqdec (Thrd c'' l'') (Thrd c' l'0)).
  378. injection e0; intros.
  379. rewrite H8 in *.
  380. pose (Flows_trans l' l'0 l).
  381. intuition. (* it's a contradiction *)
  382. reflexivity.
  383. Qed.
  384.  
  385. Lemma lemma_px_upd : forall l' l x k v,
  386. Flows l' l ->
  387. px (upd x k (write (x k) v l')) l = upd (px x l) k (write ((px x l) k) v l')
  388. .
  389. Proof.
  390. intros.
  391. apply extensionality; intro k'.
  392. unfold px, upd, write.
  393. destruct (eqdec k k'); auto.
  394. simpl.
  395. destruct (Flows_dec l' l); intuition.
  396. simpl.
  397. apply f_equal.
  398. clear.
  399. induction (x k).
  400. reflexivity.
  401. destruct a.
  402. simpl.
  403. destruct (Flows_dec l' l1)
  404. ; simpl
  405. ; destruct (Flows_dec l1 l)
  406. ; simpl
  407. ; destruct (Flows_dec l' l1)
  408. ; intuition congruence.
  409. Qed.
  410.  
  411. Lemma lemma_read_helper : forall x' k l' l,
  412. Flows l' l ->
  413. pS (x' k) l' = pS (px x' l k) l'
  414. .
  415. Proof.
  416. intros.
  417. unfold px.
  418. induction (x' k).
  419. reflexivity.
  420. destruct a.
  421. simpl.
  422. pose (Flows_trans l1 l' l).
  423. destruct (Flows_dec l1 l')
  424. ; simpl
  425. ; destruct (Flows_dec l1 l)
  426. ; simpl
  427. ; destruct (Flows_dec l1 l')
  428. ; intuition congruence.
  429. Qed.
  430.  
  431. Lemma lemma_idemp_px : forall x l,
  432. px (px x l) l = px x l.
  433. Proof.
  434. intros.
  435. apply extensionality; intro k.
  436. unfold px.
  437. induction (x k).
  438. reflexivity.
  439. destruct a.
  440. simpl.
  441. destruct (Flows_dec l1 l)
  442. ; simpl
  443. ; destruct (Flows_dec l1 l)
  444. ; congruence.
  445. Qed.
  446.  
  447. Lemma lemma_idemp_pts : forall ts l,
  448. pts (pts ts l) l = pts ts l.
  449. Proof.
  450. intros.
  451. apply extensionality; intro t; destruct t as (c', l').
  452. unfold pts, thread_label.
  453. destruct (Flows_dec l' l); reflexivity.
  454. Qed.
  455.  
  456. Lemma lemma_pts_multicons_pts : forall ts l t,
  457. pts (multi_cons (pts ts l) t) l = pts (multi_cons ts t) l.
  458. Proof.
  459. intros.
  460. apply extensionality; intro t'; destruct t' as (c', l').
  461. unfold pts, multi_cons, thread_label.
  462. destruct (Flows_dec l' l); destruct (eqdec t (Thrd c' l')); auto.
  463. Qed.
  464.  
  465. Lemma lemma_pts_multiplus_pts : forall ts l ts',
  466. pts (multi_plus (pts ts l) ts') l = pts (multi_plus ts ts') l.
  467. Proof.
  468. intros.
  469. apply extensionality; intro t'; destruct t' as (c', l').
  470. unfold pts, multi_plus, thread_label.
  471. destruct (Flows_dec l' l); auto.
  472. Qed.
  473.  
  474. Lemma lemma_idemp_pX : forall X l,
  475. pX (pX X l) l = pX X l.
  476. Proof.
  477. intros.
  478. destruct X as (x, ts).
  479. simpl.
  480. rewrite lemma_idemp_px.
  481. rewrite lemma_idemp_pts.
  482. reflexivity.
  483. Qed.
  484.  
  485. Lemma lemma_multicons_multiplus_multione : forall ts t,
  486. multi_cons ts t = multi_plus ts (multi_one t).
  487. Proof.
  488. intros.
  489. apply extensionality; intro t'.
  490. unfold multi_cons, multi_plus, multi_one.
  491. destruct (eqdec t t')
  492. ; destruct (eqdec t' t)
  493. ; try congruence
  494. ; omega
  495. .
  496. Qed.
  497.  
  498. Theorem projection_1 : forall X e X' l,
  499. SStep X e X' ->
  500. LSStep (pX X l) (pe e l) l (pX X' l)
  501. .
  502. Proof.
  503. destruct 1 as [| |? ? ? l'].
  504. -
  505. do 2 eexists.
  506. split; [|split].
  507. + apply SSStart.
  508. + reflexivity.
  509. + unfold pX.
  510. rewrite lemma_idemp_px.
  511. rewrite lemma_pts_multicons_pts.
  512. reflexivity.
  513. -
  514. do 2 eexists.
  515. split; [|split].
  516. + apply SSSkip.
  517. + reflexivity.
  518. + apply lemma_idemp_pX.
  519. -
  520. destruct (Flows_dec l' l); cycle 1.
  521. +
  522. do 2 eexists; split; [|split].
  523. *
  524. apply SSSkip.
  525. *
  526. destruct e as [|ch v|].
  527. -- inversion H.
  528. -- inversion H.
  529. simpl.
  530. destruct (Flows_dec (label ch) l); auto.
  531. pose (Flows_trans l' (label ch) l).
  532. intuition. (* contradiction *)
  533. -- reflexivity.
  534. *
  535. simpl.
  536. rewrite lemma_pts_multiplus.
  537. rewrite lemma_idemp_px.
  538. erewrite <- lemma_invisibility_1; cycle 1.
  539. exact n.
  540. exact H.
  541. rewrite lemma_idemp_pts.
  542. rewrite lemma_pts_multicons_2; auto.
  543. erewrite lemma_invisibility_3 with (ts' := ts') ; cycle 1.
  544. exact n.
  545. exact H.
  546. rewrite lemma_multiplus_zero.
  547. reflexivity.
  548. +
  549. simpl.
  550. rewrite lemma_pts_multicons_1; auto.
  551. inversion H.
  552. *
  553. destruct (Flows_dec (label ch) l).
  554. --
  555. do 2 eexists; split; [|split].
  556. ++ apply SSThread.
  557. apply SSend.
  558. exact H5.
  559. assumption.
  560. ++ reflexivity.
  561. ++ simpl.
  562. rewrite lemma_idemp_px.
  563. rewrite lemma_pts_multiplus_pts.
  564. reflexivity.
  565. --
  566. do 2 eexists; split; [|split].
  567. ++ apply SSThread.
  568. apply SSend.
  569. exact H5.
  570. assumption.
  571. ++ unfold pe.
  572. destruct (Flows_dec (label ch) l); intuition.
  573. ++ simpl.
  574. rewrite lemma_idemp_px.
  575. rewrite lemma_pts_multiplus_pts.
  576. reflexivity.
  577. *
  578. do 2 eexists; split; [|split].
  579. -- apply SSThread.
  580. apply SRead.
  581. exact H4.
  582. -- reflexivity.
  583. -- simpl.
  584. rewrite lemma_idemp_px.
  585. rewrite lemma_pts_multiplus_pts.
  586. rewrite <- lemma_read_helper with (l := l); auto.
  587. *
  588. do 2 eexists; split; [|split].
  589. -- apply SSThread.
  590. apply SWrite.
  591. exact H4.
  592. -- reflexivity.
  593. -- simpl.
  594. rewrite lemma_px_upd; auto.
  595. rewrite lemma_px_upd; auto.
  596. rewrite lemma_idemp_px.
  597. rewrite lemma_pts_multiplus_pts.
  598. reflexivity.
  599. *
  600. do 2 eexists; split; [|split].
  601. -- apply SSThread.
  602. apply SFork.
  603. exact H4.
  604. -- reflexivity.
  605. -- simpl.
  606. rewrite lemma_idemp_px.
  607. rewrite lemma_pts_multiplus_pts.
  608. reflexivity.
  609. *
  610. do 2 eexists; split; [|split].
  611. -- apply SSThread.
  612. apply SRaiseLabel.
  613. exact H5.
  614. exact H7.
  615. -- reflexivity.
  616. -- simpl.
  617. rewrite lemma_idemp_px.
  618. rewrite lemma_pts_multiplus_pts.
  619. reflexivity.
  620. Qed.
  621.  
  622. Lemma apply_equation : forall {A}{B} {f g:A->B},
  623. f = g ->
  624. forall x,
  625. f x = g x.
  626. congruence.
  627. Qed.
  628.  
  629. Theorem projection_2 : forall X l e1 X1,
  630. LSStep (pX X l) e1 l X1 ->
  631. exists X2 e2,
  632. SStep X e2 X2
  633. /\
  634. X1 = pX X2 l
  635. /\
  636. e1 = pe e2 l
  637. .
  638. Proof.
  639. destruct X as (x, ts).
  640. destruct 1 as (e', (X', (T8, (T9, T10)))).
  641. inversion T8.
  642. -
  643. destruct t as (c, l0).
  644. exists (St x (multi_cons ts (Thrd c l0))).
  645. exists (Input (Thrd c l0)).
  646. repeat split.
  647. + apply SSStart.
  648. + rewrite <- T10.
  649. rewrite <- H3.
  650. simpl.
  651. rewrite lemma_idemp_px.
  652. rewrite lemma_pts_multicons_pts.
  653. reflexivity.
  654. + rewrite <- T9.
  655. rewrite <- H2.
  656. reflexivity.
  657. -
  658. do 2 eexists.
  659. split; [|split].
  660. + apply SSSkip.
  661. + rewrite <- T10.
  662. rewrite <- H1.
  663. simpl.
  664. rewrite lemma_idemp_px.
  665. rewrite lemma_idemp_pts.
  666. reflexivity.
  667. + rewrite <- T9.
  668. rewrite <- H0.
  669. reflexivity.
  670. -
  671. rename H1 into T2, H3 into T3.
  672. assert (Flows l0 l).
  673. remember (apply_equation T2 (Thrd c l0)) as T4; clear HeqT4.
  674. unfold multi_cons, pts, thread_label in T4.
  675. destruct (eqdec (Thrd c l0) (Thrd c l0)); intuition.
  676. destruct (Flows_dec l0 l); auto.
  677. omega.
  678. pose (ts_ := fun t => if eqdec (Thrd c l0) t then ts t - 1 else ts t).
  679. assert (ts = multi_cons ts_ (Thrd c l0)) as T5.
  680. remember (apply_equation T2 (Thrd c l0)) as T4; clear HeqT4.
  681. unfold multi_cons, pts, thread_label in T4.
  682. destruct (eqdec (Thrd c l0) (Thrd c l0)); destruct (Flows_dec l0 l); intuition.
  683. unfold multi_cons, ts_.
  684. apply extensionality; intro t.
  685. destruct (eqdec (Thrd c l0) t) as [T5|]; auto.
  686. rewrite T5 in T4.
  687. omega.
  688. assert (pts ts_ l = ts0) as T6.
  689. apply extensionality; intro t.
  690. generalize (apply_equation T2 t).
  691. destruct t.
  692. unfold ts_, multi_cons, pts, thread_label.
  693. destruct (eqdec (Thrd c l0) (Thrd c0 l1)); try omega.
  694. destruct (Flows_dec l1 l); omega.
  695. inversion T3.
  696. + (* This case is copy-pasted and copy-paste-edited below. *)
  697. rewrite T5.
  698. do 2 eexists.
  699. repeat split.
  700. * apply SSThread.
  701. apply SSend.
  702. exact H8.
  703. assumption.
  704. * rewrite <- T10.
  705. rewrite <- H2.
  706. simpl.
  707. rewrite <- T6.
  708. rewrite lemma_pts_multiplus_pts.
  709. rewrite <- H6.
  710. rewrite lemma_idemp_px.
  711. rewrite <- H9.
  712. reflexivity.
  713. * congruence.
  714. +
  715. rewrite T5.
  716. do 2 eexists.
  717. repeat split.
  718. * apply SSThread.
  719. apply SRead.
  720. exact H7.
  721. * rewrite <- T10.
  722. rewrite <- H2.
  723. simpl.
  724. rewrite <- T6.
  725. rewrite lemma_pts_multiplus_pts.
  726. rewrite <- H8.
  727. rewrite lemma_idemp_px.
  728. rewrite <- H9.
  729. rewrite lemma_pts_multiplus.
  730. rewrite lemma_pts_multiplus.
  731. rewrite lemma_pts_multione; auto.
  732. rewrite lemma_pts_multione; auto.
  733. rewrite <- lemma_read_helper with (l := l); auto.
  734. * congruence.
  735. +
  736. rewrite T5.
  737. do 2 eexists.
  738. repeat split.
  739. * apply SSThread.
  740. apply SWrite.
  741. exact H7.
  742. * rewrite <- T10.
  743. rewrite <- H2.
  744. simpl.
  745. rewrite <- T6.
  746. rewrite lemma_pts_multiplus_pts.
  747. rewrite <- H8.
  748. rewrite lemma_px_upd; auto.
  749. rewrite lemma_px_upd; auto.
  750. rewrite lemma_idemp_px.
  751. rewrite <- H9.
  752. reflexivity.
  753. * congruence.
  754. +
  755. rewrite T5.
  756. do 2 eexists.
  757. repeat split.
  758. * apply SSThread.
  759. apply SFork.
  760. exact H7.
  761. * rewrite <- T10.
  762. rewrite <- H2.
  763. simpl.
  764. rewrite <- T6.
  765. rewrite lemma_pts_multiplus_pts.
  766. rewrite <- H8.
  767. rewrite lemma_idemp_px.
  768. rewrite <- H9.
  769. reflexivity.
  770. * congruence.
  771. +
  772. rewrite T5.
  773. do 2 eexists.
  774. repeat split.
  775. * apply SSThread.
  776. apply SRaiseLabel.
  777. exact H8.
  778. auto.
  779. * rewrite <- T10.
  780. rewrite <- H2.
  781. simpl.
  782. rewrite <- T6.
  783. rewrite lemma_pts_multiplus_pts.
  784. rewrite <- H6.
  785. rewrite lemma_idemp_px.
  786. rewrite <- H9.
  787. reflexivity.
  788. * congruence.
  789. Qed.
  790.  
  791. Theorem tsni : ConjectureTSNI.
  792. Proof.
  793. unfold ConjectureTSNI.
  794. intros.
  795. rename H into T1, H0 into T2.
  796. apply projection_2.
  797. rewrite <- T1.
  798. apply projection_1.
  799. exact T2.
  800. Qed.
  801.  
  802. Theorem tsni_star : ConjectureTSNIStar.
  803. Proof.
  804. induction 1.
  805. -
  806. do 2 eexists.
  807. split.
  808. apply StarNil.
  809. auto.
  810. -
  811. rename X into X1, X' into X1', X'' into X1'', es into es1, H into T1, H0 into T2.
  812. intros X2 T3.
  813. edestruct tsni as (X2', (e2, (T4, (T5, T6)))).
  814. exact T3.
  815. exact T1.
  816. destruct IHSStepStar with X2' as (X2'', (es2, (T7, (T8, T9)))).
  817. exact T5.
  818. exists X2''.
  819. exists (cons e2 es2).
  820. intuition.
  821. apply StarCons with X2'; assumption.
  822. simpl.
  823. congruence.
  824. Qed.
Add Comment
Please, Sign In to add comment