Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
File size: 33,024 Bytes
4365a98 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
(* Title: OInvariants.thy
License: BSD 2-Clause. See LICENSE.
Author: Timothy Bourke
*)
section "Open reachability and invariance"
theory OInvariants
imports Invariants
begin
subsection "Open reachability"
text \<open>
By convention, the states of an open automaton are pairs. The first component is considered
to be the global state and the second is the local state.
A state is `open reachable' under @{term S} and @{term U} if it is the initial state, or it
is the destination of a transition---where the global components satisfy @{term S}---from an
open reachable state, or it is the destination of an interleaved environment step where the
global components satisfy @{term U}.
\<close>
inductive_set oreachable
:: "('g \<times> 'l, 'a) automaton
\<Rightarrow> ('g \<Rightarrow> 'g \<Rightarrow> 'a \<Rightarrow> bool)
\<Rightarrow> ('g \<Rightarrow> 'g \<Rightarrow> bool)
\<Rightarrow> ('g \<times> 'l) set"
for A :: "('g \<times> 'l, 'a) automaton"
and S :: "'g \<Rightarrow> 'g \<Rightarrow> 'a \<Rightarrow> bool"
and U :: "'g \<Rightarrow> 'g \<Rightarrow> bool"
where
oreachable_init: "s \<in> init A \<Longrightarrow> s \<in> oreachable A S U"
| oreachable_local: "\<lbrakk> s \<in> oreachable A S U; (s, a, s') \<in> trans A; S (fst s) (fst s') a \<rbrakk>
\<Longrightarrow> s' \<in> oreachable A S U"
| oreachable_other: "\<lbrakk> s \<in> oreachable A S U; U (fst s) \<sigma>' \<rbrakk>
\<Longrightarrow> (\<sigma>', snd s) \<in> oreachable A S U"
lemma oreachable_local' [elim]:
assumes "(\<sigma>, p) \<in> oreachable A S U"
and "((\<sigma>, p), a, (\<sigma>', p')) \<in> trans A"
and "S \<sigma> \<sigma>' a"
shows "(\<sigma>', p') \<in> oreachable A S U"
using assms by (metis fst_conv oreachable.oreachable_local)
lemma oreachable_other' [elim]:
assumes "(\<sigma>, p) \<in> oreachable A S U"
and "U \<sigma> \<sigma>'"
shows "(\<sigma>', p) \<in> oreachable A S U"
proof -
from \<open>U \<sigma> \<sigma>'\<close> have "U (fst (\<sigma>, p)) \<sigma>'" by simp
with \<open>(\<sigma>, p) \<in> oreachable A S U\<close> have "(\<sigma>', snd (\<sigma>, p)) \<in> oreachable A S U"
by (rule oreachable_other)
thus "(\<sigma>', p) \<in> oreachable A S U" by simp
qed
lemma oreachable_pair_induct [consumes, case_names init other local]:
assumes "(\<sigma>, p) \<in> oreachable A S U"
and "\<And>\<sigma> p. (\<sigma>, p) \<in> init A \<Longrightarrow> P \<sigma> p"
and "(\<And>\<sigma> p \<sigma>'. \<lbrakk> (\<sigma>, p) \<in> oreachable A S U; P \<sigma> p; U \<sigma> \<sigma>' \<rbrakk> \<Longrightarrow> P \<sigma>' p)"
and "(\<And>\<sigma> p \<sigma>' p' a. \<lbrakk> (\<sigma>, p) \<in> oreachable A S U; P \<sigma> p;
((\<sigma>, p), a, (\<sigma>', p')) \<in> trans A; S \<sigma> \<sigma>' a \<rbrakk> \<Longrightarrow> P \<sigma>' p')"
shows "P \<sigma> p"
using assms (1) proof (induction "(\<sigma>, p)" arbitrary: \<sigma> p)
fix \<sigma> p
assume "(\<sigma>, p) \<in> init A"
with assms(2) show "P \<sigma> p" .
next
fix s \<sigma>'
assume "s \<in> oreachable A S U"
and "U (fst s) \<sigma>'"
and IH: "\<And>\<sigma> p. s = (\<sigma>, p) \<Longrightarrow> P \<sigma> p"
from this(1) obtain \<sigma> p where "s = (\<sigma>, p)"
and "(\<sigma>, p) \<in> oreachable A S U"
by (metis surjective_pairing)
note this(2)
moreover from IH and \<open>s = (\<sigma>, p)\<close> have "P \<sigma> p" .
moreover from \<open>U (fst s) \<sigma>'\<close> and \<open>s = (\<sigma>, p)\<close> have "U \<sigma> \<sigma>'" by simp
ultimately have "P \<sigma>' p" by (rule assms(3))
with \<open>s = (\<sigma>, p)\<close> show "P \<sigma>' (snd s)" by simp
next
fix s a \<sigma>' p'
assume "s \<in> oreachable A S U"
and tr: "(s, a, (\<sigma>', p')) \<in> trans A"
and "S (fst s) (fst (\<sigma>', p')) a"
and IH: "\<And>\<sigma> p. s = (\<sigma>, p) \<Longrightarrow> P \<sigma> p"
from this(1) obtain \<sigma> p where "s = (\<sigma>, p)"
and "(\<sigma>, p) \<in> oreachable A S U"
by (metis surjective_pairing)
note this(2)
moreover from IH \<open>s = (\<sigma>, p)\<close> have "P \<sigma> p" .
moreover from tr and \<open>s = (\<sigma>, p)\<close> have "((\<sigma>, p), a, (\<sigma>', p')) \<in> trans A" by simp
moreover from \<open>S (fst s) (fst (\<sigma>', p')) a\<close> and \<open>s = (\<sigma>, p)\<close> have "S \<sigma> \<sigma>' a" by simp
ultimately show "P \<sigma>' p'" by (rule assms(4))
qed
lemma oreachable_weakenE [elim]:
assumes "s \<in> oreachable A PS PU"
and PSQS: "\<And>s s' a. PS s s' a \<Longrightarrow> QS s s' a"
and PUQU: "\<And>s s'. PU s s' \<Longrightarrow> QU s s'"
shows "s \<in> oreachable A QS QU"
using assms(1)
proof (induction)
fix s assume "s \<in> init A"
thus "s \<in> oreachable A QS QU" ..
next
fix s a s'
assume "s \<in> oreachable A QS QU"
and "(s, a, s') \<in> trans A"
and "PS (fst s) (fst s') a"
from \<open>PS (fst s) (fst s') a\<close> have "QS (fst s) (fst s') a" by (rule PSQS)
with \<open>s \<in> oreachable A QS QU\<close> and \<open>(s, a, s') \<in> trans A\<close> show "s' \<in> oreachable A QS QU" ..
next
fix s g'
assume "s \<in> oreachable A QS QU"
and "PU (fst s) g'"
from \<open>PU (fst s) g'\<close> have "QU (fst s) g'" by (rule PUQU)
with \<open>s \<in> oreachable A QS QU\<close> show "(g', snd s) \<in> oreachable A QS QU" ..
qed
definition
act :: "('a \<Rightarrow> bool) \<Rightarrow> 's \<Rightarrow> 's \<Rightarrow> 'a \<Rightarrow> bool"
where
"act I \<equiv> (\<lambda>_ _. I)"
lemma act_simp [iff]: "act I s s' a = I a"
unfolding act_def ..
lemma reachable_in_oreachable [elim]:
fixes s
assumes "s \<in> reachable A I"
shows "s \<in> oreachable A (act I) U"
unfolding act_def using assms proof induction
fix s
assume "s \<in> init A"
thus "s \<in> oreachable A (\<lambda>_ _. I) U" ..
next
fix s a s'
assume "s \<in> oreachable A (\<lambda>_ _. I) U"
and "(s, a, s') \<in> trans A"
and "I a"
thus "s' \<in> oreachable A (\<lambda>_ _. I) U"
by (rule oreachable_local)
qed
subsection "Open Invariance"
definition oinvariant
:: "('g \<times> 'l, 'a) automaton
\<Rightarrow> ('g \<Rightarrow> 'g \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('g \<Rightarrow> 'g \<Rightarrow> bool)
\<Rightarrow> (('g \<times> 'l) \<Rightarrow> bool) \<Rightarrow> bool"
("_ \<Turnstile> (1'((1_),/ (1_) \<rightarrow>')/ _)" [100, 0, 0, 9] 8)
where
"(A \<Turnstile> (S, U \<rightarrow>) P) = (\<forall>s\<in>oreachable A S U. P s)"
lemma oinvariantI [intro]:
fixes T TI S U P
assumes init: "\<And>s. s \<in> init A \<Longrightarrow> P s"
and other: "\<And>g g' l.
\<lbrakk> (g, l) \<in> oreachable A S U; P (g, l); U g g' \<rbrakk> \<Longrightarrow> P (g', l)"
and local: "\<And>s a s'.
\<lbrakk> s \<in> oreachable A S U; P s; (s, a, s') \<in> trans A; S (fst s) (fst s') a \<rbrakk> \<Longrightarrow> P s'"
shows "A \<Turnstile> (S, U \<rightarrow>) P"
unfolding oinvariant_def
proof
fix s
assume "s \<in> oreachable A S U"
thus "P s"
proof induction
fix s assume "s \<in> init A"
thus "P s" by (rule init)
next
fix s a s'
assume "s \<in> oreachable A S U"
and "P s"
and "(s, a, s') \<in> trans A"
and "S (fst s) (fst s') a"
thus "P s'" by (rule local)
next
fix s g'
assume "s \<in> oreachable A S U"
and "P s"
and "U (fst s) g'"
thus "P (g', snd s)"
by - (rule other [where g="fst s"], simp_all)
qed
qed
lemma oinvariant_oreachableI:
assumes "\<And>\<sigma> s. (\<sigma>, s)\<in>oreachable A S U \<Longrightarrow> P (\<sigma>, s)"
shows "A \<Turnstile> (S, U \<rightarrow>) P"
using assms unfolding oinvariant_def by auto
lemma oinvariant_pairI [intro]:
assumes init: "\<And>\<sigma> p. (\<sigma>, p) \<in> init A \<Longrightarrow> P (\<sigma>, p)"
and local: "\<And>\<sigma> p \<sigma>' p' a.
\<lbrakk> (\<sigma>, p) \<in> oreachable A S U; P (\<sigma>, p); ((\<sigma>, p), a, (\<sigma>', p')) \<in> trans A;
S \<sigma> \<sigma>' a \<rbrakk> \<Longrightarrow> P (\<sigma>', p')"
and other: "\<And>\<sigma> \<sigma>' p.
\<lbrakk> (\<sigma>, p) \<in> oreachable A S U; P (\<sigma>, p); U \<sigma> \<sigma>' \<rbrakk> \<Longrightarrow> P (\<sigma>', p)"
shows "A \<Turnstile> (S, U \<rightarrow>) P"
by (rule oinvariantI)
(clarsimp | erule init | erule(3) local | erule(2) other)+
lemma oinvariantD [dest]:
assumes "A \<Turnstile> (S, U \<rightarrow>) P"
and "s \<in> oreachable A S U"
shows "P s"
using assms unfolding oinvariant_def
by clarsimp
lemma oinvariant_initD [dest, elim]:
assumes invP: "A \<Turnstile> (S, U \<rightarrow>) P"
and init: "s \<in> init A"
shows "P s"
proof -
from init have "s \<in> oreachable A S U" ..
with invP show ?thesis ..
qed
lemma oinvariant_weakenE [elim!]:
assumes invP: "A \<Turnstile> (PS, PU \<rightarrow>) P"
and PQ: "\<And>s. P s \<Longrightarrow> Q s"
and QSPS: "\<And>s s' a. QS s s' a \<Longrightarrow> PS s s' a"
and QUPU: "\<And>s s'. QU s s' \<Longrightarrow> PU s s'"
shows "A \<Turnstile> (QS, QU \<rightarrow>) Q"
proof
fix s
assume "s \<in> init A"
with invP have "P s" ..
thus "Q s" by (rule PQ)
next
fix \<sigma> p \<sigma>' p' a
assume "(\<sigma>, p) \<in> oreachable A QS QU"
and "((\<sigma>, p), a, (\<sigma>', p')) \<in> trans A"
and "QS \<sigma> \<sigma>' a"
from this(3) have "PS \<sigma> \<sigma>' a" by (rule QSPS)
from \<open>(\<sigma>, p) \<in> oreachable A QS QU\<close> and QSPS QUPU have "(\<sigma>, p) \<in> oreachable A PS PU" ..
hence "(\<sigma>', p') \<in> oreachable A PS PU" using \<open>((\<sigma>, p), a, (\<sigma>', p')) \<in> trans A\<close> and \<open>PS \<sigma> \<sigma>' a\<close> ..
with invP have "P (\<sigma>', p')" ..
thus "Q (\<sigma>', p')" by (rule PQ)
next
fix \<sigma> \<sigma>' p
assume "(\<sigma>, p) \<in> oreachable A QS QU"
and "Q (\<sigma>, p)"
and "QU \<sigma> \<sigma>'"
from \<open>QU \<sigma> \<sigma>'\<close> have "PU \<sigma> \<sigma>'" by (rule QUPU)
from \<open>(\<sigma>, p) \<in> oreachable A QS QU\<close> and QSPS QUPU have "(\<sigma>, p) \<in> oreachable A PS PU" ..
hence "(\<sigma>', p) \<in> oreachable A PS PU" using \<open>PU \<sigma> \<sigma>'\<close> ..
with invP have "P (\<sigma>', p)" ..
thus "Q (\<sigma>', p)" by (rule PQ)
qed
lemma oinvariant_weakenD [dest]:
assumes "A \<Turnstile> (S', U' \<rightarrow>) P"
and "(\<sigma>, p) \<in> oreachable A S U"
and weakenS: "\<And>s s' a. S s s' a \<Longrightarrow> S' s s' a"
and weakenU: "\<And>s s'. U s s' \<Longrightarrow> U' s s'"
shows "P (\<sigma>, p)"
proof -
from \<open>(\<sigma>, p) \<in> oreachable A S U\<close> have "(\<sigma>, p) \<in> oreachable A S' U'"
by (rule oreachable_weakenE)
(erule weakenS, erule weakenU)
with \<open>A \<Turnstile> (S', U' \<rightarrow>) P\<close> show "P (\<sigma>, p)" ..
qed
lemma close_open_invariant:
assumes oinv: "A \<Turnstile> (act I, U \<rightarrow>) P"
shows "A \<TTurnstile> (I \<rightarrow>) P"
proof
fix s
assume "s \<in> init A"
with oinv show "P s" ..
next
fix \<xi> p \<xi>' p' a
assume sr: "(\<xi>, p) \<in> reachable A I"
and step: "((\<xi>, p), a, (\<xi>', p')) \<in> trans A"
and "I a"
hence "(\<xi>', p') \<in> reachable A I" ..
hence "(\<xi>', p') \<in> oreachable A (act I) U" ..
with oinv show "P (\<xi>', p')" ..
qed
definition local_steps :: "((('i \<Rightarrow> 's1) \<times> 'l1) \<times> 'a \<times> ('i \<Rightarrow> 's2) \<times> 'l2) set \<Rightarrow> 'i set \<Rightarrow> bool"
where "local_steps T J \<equiv>
(\<forall>\<sigma> \<zeta> s a \<sigma>' s'. ((\<sigma>, s), a, (\<sigma>', s')) \<in> T \<and> (\<forall>j\<in>J. \<zeta> j = \<sigma> j)
\<longrightarrow> (\<exists>\<zeta>'. (\<forall>j\<in>J. \<zeta>' j = \<sigma>' j) \<and> ((\<zeta>, s), a, (\<zeta>', s')) \<in> T))"
lemma local_stepsI [intro!]:
assumes "\<And>\<sigma> \<zeta> s a \<sigma>' \<zeta>' s'. \<lbrakk> ((\<sigma>, s), a, (\<sigma>', s')) \<in> T; \<forall>j\<in>J. \<zeta> j = \<sigma> j \<rbrakk>
\<Longrightarrow> (\<exists>\<zeta>'. (\<forall>j\<in>J. \<zeta>' j = \<sigma>' j) \<and> ((\<zeta>, s), a, (\<zeta>', s')) \<in> T)"
shows "local_steps T J"
unfolding local_steps_def using assms by clarsimp
lemma local_stepsE [elim, dest]:
assumes "local_steps T J"
and "((\<sigma>, s), a, (\<sigma>', s')) \<in> T"
and "\<forall>j\<in>J. \<zeta> j = \<sigma> j"
shows "\<exists>\<zeta>'. (\<forall>j\<in>J. \<zeta>' j = \<sigma>' j) \<and> ((\<zeta>, s), a, (\<zeta>', s')) \<in> T"
using assms unfolding local_steps_def by blast
definition other_steps :: "(('i \<Rightarrow> 's) \<Rightarrow> ('i \<Rightarrow> 's) \<Rightarrow> bool) \<Rightarrow> 'i set \<Rightarrow> bool"
where "other_steps U J \<equiv> \<forall>\<sigma> \<sigma>'. U \<sigma> \<sigma>' \<longrightarrow> (\<forall>j\<in>J. \<sigma>' j = \<sigma> j)"
lemma other_stepsI [intro!]:
assumes "\<And>\<sigma> \<sigma>' j. \<lbrakk> U \<sigma> \<sigma>'; j \<in> J \<rbrakk> \<Longrightarrow> \<sigma>' j = \<sigma> j"
shows "other_steps U J"
using assms unfolding other_steps_def by simp
lemma other_stepsE [elim]:
assumes "other_steps U J"
and "U \<sigma> \<sigma>'"
shows "\<forall>j\<in>J. \<sigma>' j = \<sigma> j"
using assms unfolding other_steps_def by simp
definition subreachable
where "subreachable A U J \<equiv> \<forall>I. \<forall>s \<in> oreachable A (\<lambda>s s'. I) U.
(\<exists>\<sigma>. (\<forall>j\<in>J. \<sigma> j = (fst s) j) \<and> (\<sigma>, snd s) \<in> reachable A I)"
lemma subreachableI [intro]:
assumes "local_steps (trans A) J"
and "other_steps U J"
shows "subreachable A U J"
unfolding subreachable_def
proof (rule, rule)
fix I s
assume "s \<in> oreachable A (\<lambda>s s'. I) U"
thus "(\<exists>\<sigma>. (\<forall>j\<in>J. \<sigma> j = (fst s) j) \<and> (\<sigma>, snd s) \<in> reachable A I)"
proof induction
fix s
assume "s \<in> init A"
hence "(fst s, snd s) \<in> reachable A I"
by simp (rule reachable_init)
moreover have "\<forall>j\<in>J. (fst s) j = (fst s) j"
by simp
ultimately show "\<exists>\<sigma>. (\<forall>j\<in>J. \<sigma> j = (fst s) j) \<and> (\<sigma>, snd s) \<in> reachable A I"
by auto
next
fix s a s'
assume "\<exists>\<sigma>. (\<forall>j\<in>J. \<sigma> j = (fst s) j) \<and> (\<sigma>, snd s) \<in> reachable A I"
and "(s, a, s') \<in> trans A"
and "I a"
then obtain \<zeta> where "\<forall>j\<in>J. \<zeta> j = (fst s) j"
and "(\<zeta>, snd s) \<in> reachable A I" by auto
from \<open>(s, a, s') \<in> trans A\<close> have "((fst s, snd s), a, (fst s', snd s')) \<in> trans A"
by simp
with \<open>local_steps (trans A) J\<close> obtain \<zeta>' where "\<forall>j\<in>J. \<zeta>' j = (fst s') j"
and "((\<zeta>, snd s), a, (\<zeta>', snd s')) \<in> trans A"
using \<open>\<forall>j\<in>J. \<zeta> j = (fst s) j\<close> by - (drule(2) local_stepsE, clarsimp)
from \<open>(\<zeta>, snd s) \<in> reachable A I\<close>
and \<open>((\<zeta>, snd s), a, (\<zeta>', snd s')) \<in> trans A\<close>
and \<open>I a\<close>
have "(\<zeta>', snd s') \<in> reachable A I" ..
with \<open>\<forall>j\<in>J. \<zeta>' j = (fst s') j\<close>
show "\<exists>\<sigma>. (\<forall>j\<in>J. \<sigma> j = (fst s') j) \<and> (\<sigma>, snd s') \<in> reachable A I" by auto
next
fix s \<sigma>'
assume "\<exists>\<sigma>. (\<forall>j\<in>J. \<sigma> j = (fst s) j) \<and> (\<sigma>, snd s) \<in> reachable A I"
and "U (fst s) \<sigma>'"
then obtain \<sigma> where "\<forall>j\<in>J. \<sigma> j = (fst s) j"
and "(\<sigma>, snd s) \<in> reachable A I" by auto
from \<open>other_steps U J\<close> and \<open>U (fst s) \<sigma>'\<close> have "\<forall>j\<in>J. \<sigma>' j = (fst s) j"
by - (erule(1) other_stepsE)
with \<open>\<forall>j\<in>J. \<sigma> j = (fst s) j\<close> have "\<forall>j\<in>J. \<sigma> j = \<sigma>' j"
by clarsimp
with \<open>(\<sigma>, snd s) \<in> reachable A I\<close>
show "\<exists>\<sigma>. (\<forall>j\<in>J. \<sigma> j = fst (\<sigma>', snd s) j) \<and> (\<sigma>, snd (\<sigma>', snd s)) \<in> reachable A I"
by auto
qed
qed
lemma subreachableE [elim]:
assumes "subreachable A U J"
and "s \<in> oreachable A (\<lambda>s s'. I) U"
shows "\<exists>\<sigma>. (\<forall>j\<in>J. \<sigma> j = (fst s) j) \<and> (\<sigma>, snd s) \<in> reachable A I"
using assms unfolding subreachable_def by simp
lemma subreachableE_pair [elim]:
assumes "subreachable A U J"
and "(\<sigma>, s) \<in> oreachable A (\<lambda>s s'. I) U"
shows "\<exists>\<zeta>. (\<forall>j\<in>J. \<zeta> j = \<sigma> j) \<and> (\<zeta>, s) \<in> reachable A I"
using assms unfolding subreachable_def by (metis fst_conv snd_conv)
lemma subreachable_otherE [elim]:
assumes "subreachable A U J"
and "(\<sigma>, l) \<in> oreachable A (\<lambda>s s'. I) U"
and "U \<sigma> \<sigma>'"
shows "\<exists>\<zeta>'. (\<forall>j\<in>J. \<zeta>' j = \<sigma>' j) \<and> (\<zeta>', l) \<in> reachable A I"
proof -
from \<open>(\<sigma>, l) \<in> oreachable A (\<lambda>s s'. I) U\<close> and \<open>U \<sigma> \<sigma>'\<close>
have "(\<sigma>', l) \<in> oreachable A (\<lambda>s s'. I) U"
by - (rule oreachable_other')
with \<open>subreachable A U J\<close> show ?thesis
by auto
qed
lemma open_closed_invariant:
fixes J
assumes "A \<TTurnstile> (I \<rightarrow>) P"
and "subreachable A U J"
and localp: "\<And>\<sigma> \<sigma>' s. \<lbrakk> \<forall>j\<in>J. \<sigma>' j = \<sigma> j; P (\<sigma>', s) \<rbrakk> \<Longrightarrow> P (\<sigma>, s)"
shows "A \<Turnstile> (act I, U \<rightarrow>) P"
proof (rule, simp_all only: act_def)
fix s
assume "s \<in> init A"
with \<open>A \<TTurnstile> (I \<rightarrow>) P\<close> show "P s" ..
next
fix s a s'
assume "s \<in> oreachable A (\<lambda>_ _. I) U"
and "P s"
and "(s, a, s') \<in> trans A"
and "I a"
hence "s' \<in> oreachable A (\<lambda>_ _. I) U"
by (metis oreachable_local)
with \<open>subreachable A U J\<close> obtain \<sigma>'
where "\<forall>j\<in>J. \<sigma>' j = (fst s') j"
and "(\<sigma>', snd s') \<in> reachable A I"
by (metis subreachableE)
from \<open>A \<TTurnstile> (I \<rightarrow>) P\<close> and \<open>(\<sigma>', snd s') \<in> reachable A I\<close> have "P (\<sigma>', snd s')" ..
with \<open>\<forall>j\<in>J. \<sigma>' j = (fst s') j\<close> show "P s'"
by (metis localp prod.collapse)
next
fix g g' l
assume or: "(g, l) \<in> oreachable A (\<lambda>s s'. I) U"
and "U g g'"
and "P (g, l)"
from \<open>subreachable A U J\<close> and or and \<open>U g g'\<close>
obtain gg' where "\<forall>j\<in>J. gg' j = g' j"
and "(gg', l) \<in> reachable A I"
by (auto dest!: subreachable_otherE)
from \<open>A \<TTurnstile> (I \<rightarrow>) P\<close> and \<open>(gg', l) \<in> reachable A I\<close>
have "P (gg', l)" ..
with \<open>\<forall>j\<in>J. gg' j = g' j\<close> show "P (g', l)"
by (rule localp)
qed
lemma oinvariant_anyact:
assumes "A \<Turnstile> (act TT, U \<rightarrow>) P"
shows "A \<Turnstile> (S, U \<rightarrow>) P"
using assms by rule auto
definition
ostep_invariant
:: "('g \<times> 'l, 'a) automaton
\<Rightarrow> ('g \<Rightarrow> 'g \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('g \<Rightarrow> 'g \<Rightarrow> bool)
\<Rightarrow> (('g \<times> 'l, 'a) transition \<Rightarrow> bool) \<Rightarrow> bool"
("_ \<Turnstile>\<^sub>A (1'((1_),/ (1_) \<rightarrow>')/ _)" [100, 0, 0, 9] 8)
where
"(A \<Turnstile>\<^sub>A (S, U \<rightarrow>) P) =
(\<forall>s\<in>oreachable A S U. (\<forall>a s'. (s, a, s') \<in> trans A \<and> S (fst s) (fst s') a \<longrightarrow> P (s, a, s')))"
lemma ostep_invariant_def':
"(A \<Turnstile>\<^sub>A (S, U \<rightarrow>) P) = (\<forall>s\<in>oreachable A S U.
(\<forall>a s'. (s, a, s') \<in> trans A \<and> S (fst s) (fst s') a \<longrightarrow> P (s, a, s')))"
unfolding ostep_invariant_def by auto
lemma ostep_invariantI [intro]:
assumes *: "\<And>\<sigma> s a \<sigma>' s'. \<lbrakk> (\<sigma>, s)\<in>oreachable A S U; ((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A; S \<sigma> \<sigma>' a \<rbrakk>
\<Longrightarrow> P ((\<sigma>, s), a, (\<sigma>', s'))"
shows "A \<Turnstile>\<^sub>A (S, U \<rightarrow>) P"
unfolding ostep_invariant_def
using assms by auto
lemma ostep_invariantD [dest]:
assumes "A \<Turnstile>\<^sub>A (S, U \<rightarrow>) P"
and "(\<sigma>, s)\<in>oreachable A S U"
and "((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A"
and "S \<sigma> \<sigma>' a"
shows "P ((\<sigma>, s), a, (\<sigma>', s'))"
using assms unfolding ostep_invariant_def' by clarsimp
lemma ostep_invariantE [elim]:
assumes "A \<Turnstile>\<^sub>A (S, U \<rightarrow>) P"
and "(\<sigma>, s)\<in>oreachable A S U"
and "((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A"
and "S \<sigma> \<sigma>' a"
and "P ((\<sigma>, s), a, (\<sigma>', s')) \<Longrightarrow> Q"
shows "Q"
using assms by auto
lemma ostep_invariant_weakenE [elim!]:
assumes invP: "A \<Turnstile>\<^sub>A (PS, PU \<rightarrow>) P"
and PQ: "\<And>t. P t \<Longrightarrow> Q t"
and QSPS: "\<And>\<sigma> \<sigma>' a. QS \<sigma> \<sigma>' a \<Longrightarrow> PS \<sigma> \<sigma>' a"
and QUPU: "\<And>\<sigma> \<sigma>'. QU \<sigma> \<sigma>' \<Longrightarrow> PU \<sigma> \<sigma>'"
shows "A \<Turnstile>\<^sub>A (QS, QU \<rightarrow>) Q"
proof
fix \<sigma> s \<sigma>' s' a
assume "(\<sigma>, s) \<in> oreachable A QS QU"
and "((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A"
and "QS \<sigma> \<sigma>' a"
from \<open>QS \<sigma> \<sigma>' a\<close> have "PS \<sigma> \<sigma>' a" by (rule QSPS)
from \<open>(\<sigma>, s) \<in> oreachable A QS QU\<close> have "(\<sigma>, s) \<in> oreachable A PS PU" using QSPS QUPU ..
with invP have "P ((\<sigma>, s), a, (\<sigma>', s'))" using \<open>((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A\<close> \<open>PS \<sigma> \<sigma>' a\<close> ..
thus "Q ((\<sigma>, s), a, (\<sigma>', s'))" by (rule PQ)
qed
lemma ostep_invariant_weaken_with_invariantE [elim]:
assumes pinv: "A \<Turnstile> (S, U \<rightarrow>) P"
and qinv: "A \<Turnstile>\<^sub>A (S, U \<rightarrow>) Q"
and wr: "\<And>\<sigma> s a \<sigma>' s'. \<lbrakk> P (\<sigma>, s); P (\<sigma>', s'); Q ((\<sigma>, s), a, (\<sigma>', s')); S \<sigma> \<sigma>' a \<rbrakk>
\<Longrightarrow> R ((\<sigma>, s), a, (\<sigma>', s'))"
shows "A \<Turnstile>\<^sub>A (S, U \<rightarrow>) R"
proof
fix \<sigma> s a \<sigma>' s'
assume sr: "(\<sigma>, s) \<in> oreachable A S U"
and tr: "((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A"
and "S \<sigma> \<sigma>' a"
hence "(\<sigma>', s') \<in> oreachable A S U" ..
with pinv have "P (\<sigma>', s')" ..
from pinv and sr have "P (\<sigma>, s)" ..
from qinv sr tr \<open>S \<sigma> \<sigma>' a\<close> have "Q ((\<sigma>, s), a, (\<sigma>', s'))" ..
with \<open>P (\<sigma>, s)\<close> and \<open>P (\<sigma>', s')\<close> show "R ((\<sigma>, s), a, (\<sigma>', s'))" using \<open>S \<sigma> \<sigma>' a\<close> by (rule wr)
qed
lemma ostep_to_invariantI:
assumes sinv: "A \<Turnstile>\<^sub>A (S, U \<rightarrow>) Q"
and init: "\<And>\<sigma> s. (\<sigma>, s) \<in> init A \<Longrightarrow> P (\<sigma>, s)"
and local: "\<And>\<sigma> s \<sigma>' s' a.
\<lbrakk> (\<sigma>, s) \<in> oreachable A S U;
P (\<sigma>, s);
Q ((\<sigma>, s), a, (\<sigma>', s'));
S \<sigma> \<sigma>' a \<rbrakk> \<Longrightarrow> P (\<sigma>', s')"
and other: "\<And>\<sigma> \<sigma>' s. \<lbrakk> (\<sigma>, s) \<in> oreachable A S U; U \<sigma> \<sigma>'; P (\<sigma>, s) \<rbrakk> \<Longrightarrow> P (\<sigma>', s)"
shows "A \<Turnstile> (S, U \<rightarrow>) P"
proof
fix \<sigma> s assume "(\<sigma>, s) \<in> init A" thus "P (\<sigma>, s)" by (rule init)
next
fix \<sigma> s \<sigma>' s' a
assume "(\<sigma>, s) \<in> oreachable A S U"
and "P (\<sigma>, s)"
and "((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A"
and "S \<sigma> \<sigma>' a"
show "P (\<sigma>', s')"
proof -
from sinv and \<open>(\<sigma>, s)\<in>oreachable A S U\<close> and \<open>((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A\<close> and \<open>S \<sigma> \<sigma>' a\<close>
have "Q ((\<sigma>, s), a, (\<sigma>', s'))" ..
with \<open>(\<sigma>, s)\<in>oreachable A S U\<close> and \<open>P (\<sigma>, s)\<close> show "P (\<sigma>', s')"
using \<open>S \<sigma> \<sigma>' a\<close> by (rule local)
qed
next
fix \<sigma> \<sigma>' l
assume "(\<sigma>, l) \<in> oreachable A S U"
and "U \<sigma> \<sigma>'"
and "P (\<sigma>, l)"
thus "P (\<sigma>', l)" by (rule other)
qed
lemma open_closed_step_invariant:
assumes "A \<TTurnstile>\<^sub>A (I \<rightarrow>) P"
and "local_steps (trans A) J"
and "other_steps U J"
and localp: "\<And>\<sigma> \<zeta> a \<sigma>' \<zeta>' s s'.
\<lbrakk> \<forall>j\<in>J. \<sigma> j = \<zeta> j; \<forall>j\<in>J. \<sigma>' j = \<zeta>' j; P ((\<sigma>, s), a, (\<sigma>', s')) \<rbrakk>
\<Longrightarrow> P ((\<zeta>, s), a, (\<zeta>', s'))"
shows "A \<Turnstile>\<^sub>A (act I, U \<rightarrow>) P"
proof
fix \<sigma> s a \<sigma>' s'
assume or: "(\<sigma>, s) \<in> oreachable A (act I) U"
and tr: "((\<sigma>, s), a, (\<sigma>', s')) \<in> trans A"
and "act I \<sigma> \<sigma>' a"
from \<open>act I \<sigma> \<sigma>' a\<close> have "I a" ..
from \<open>local_steps (trans A) J\<close> and \<open>other_steps U J\<close> have "subreachable A U J" ..
then obtain \<zeta> where "\<forall>j\<in>J. \<zeta> j = \<sigma> j"
and "(\<zeta>, s) \<in> reachable A I"
using or unfolding act_def
by (auto dest!: subreachableE_pair)
from \<open>local_steps (trans A) J\<close> and tr and \<open>\<forall>j\<in>J. \<zeta> j = \<sigma> j\<close>
obtain \<zeta>' where "\<forall>j\<in>J. \<zeta>' j = \<sigma>' j"
and "((\<zeta>, s), a, (\<zeta>', s')) \<in> trans A"
by auto
from \<open>A \<TTurnstile>\<^sub>A (I \<rightarrow>) P\<close> and \<open>(\<zeta>, s) \<in> reachable A I\<close>
and \<open>((\<zeta>, s), a, (\<zeta>', s')) \<in> trans A\<close>
and \<open>I a\<close>
have "P ((\<zeta>, s), a, (\<zeta>', s'))" ..
with \<open>\<forall>j\<in>J. \<zeta> j = \<sigma> j\<close> and \<open>\<forall>j\<in>J. \<zeta>' j = \<sigma>' j\<close> show "P ((\<sigma>, s), a, (\<sigma>', s'))"
by (rule localp)
qed
lemma oinvariant_step_anyact:
assumes "p \<Turnstile>\<^sub>A (act TT, U \<rightarrow>) P"
shows "p \<Turnstile>\<^sub>A (S, U \<rightarrow>) P"
using assms by rule auto
subsection "Standard assumption predicates "
text \<open>otherwith\<close>
definition otherwith :: "('s \<Rightarrow> 's \<Rightarrow> bool)
\<Rightarrow> 'i set
\<Rightarrow> (('i \<Rightarrow> 's) \<Rightarrow> 'a \<Rightarrow> bool)
\<Rightarrow> ('i \<Rightarrow> 's) \<Rightarrow> ('i \<Rightarrow> 's) \<Rightarrow> 'a \<Rightarrow> bool"
where "otherwith Q I P \<sigma> \<sigma>' a \<equiv> (\<forall>i. i\<notin>I \<longrightarrow> Q (\<sigma> i) (\<sigma>' i)) \<and> P \<sigma> a"
lemma otherwithI [intro]:
assumes other: "\<And>j. j\<notin>I \<Longrightarrow> Q (\<sigma> j) (\<sigma>' j)"
and sync: "P \<sigma> a"
shows "otherwith Q I P \<sigma> \<sigma>' a"
unfolding otherwith_def using assms by simp
lemma otherwithE [elim]:
assumes "otherwith Q I P \<sigma> \<sigma>' a"
and "\<lbrakk> P \<sigma> a; \<forall>j. j\<notin>I \<longrightarrow> Q (\<sigma> j) (\<sigma>' j) \<rbrakk> \<Longrightarrow> R \<sigma> \<sigma>' a"
shows "R \<sigma> \<sigma>' a"
using assms unfolding otherwith_def by simp
lemma otherwith_actionD [dest]:
assumes "otherwith Q I P \<sigma> \<sigma>' a"
shows "P \<sigma> a"
using assms by auto
lemma otherwith_syncD [dest]:
assumes "otherwith Q I P \<sigma> \<sigma>' a"
shows "\<forall>j. j\<notin>I \<longrightarrow> Q (\<sigma> j) (\<sigma>' j)"
using assms by auto
lemma otherwithEI [elim]:
assumes "otherwith P I PO \<sigma> \<sigma>' a"
and "\<And>\<sigma> a. PO \<sigma> a \<Longrightarrow> QO \<sigma> a"
shows "otherwith P I QO \<sigma> \<sigma>' a"
using assms(1) unfolding otherwith_def
by (clarsimp elim!: assms(2))
lemma all_but:
assumes "\<And>\<xi>. S \<xi> \<xi>"
and "\<sigma>' i = \<sigma> i"
and "\<forall>j. j \<noteq> i \<longrightarrow> S (\<sigma> j) (\<sigma>' j)"
shows "\<forall>j. S (\<sigma> j) (\<sigma>' j)"
using assms by metis
lemma all_but_eq [dest]:
assumes "\<sigma>' i = \<sigma> i"
and "\<forall>j. j \<noteq> i \<longrightarrow> \<sigma> j = \<sigma>' j"
shows "\<sigma> = \<sigma>'"
using assms by - (rule ext, metis)
text \<open>other\<close>
definition other :: "('s \<Rightarrow> 's \<Rightarrow> bool) \<Rightarrow> 'i set \<Rightarrow> ('i \<Rightarrow> 's) \<Rightarrow> ('i \<Rightarrow> 's) \<Rightarrow> bool"
where "other P I \<sigma> \<sigma>' \<equiv> \<forall>i. if i\<in>I then \<sigma>' i = \<sigma> i else P (\<sigma> i) (\<sigma>' i)"
lemma otherI [intro]:
assumes local: "\<And>i. i\<in>I \<Longrightarrow> \<sigma>' i = \<sigma> i"
and other: "\<And>j. j\<notin>I \<Longrightarrow> P (\<sigma> j) (\<sigma>' j)"
shows "other P I \<sigma> \<sigma>'"
using assms unfolding other_def by clarsimp
lemma otherE [elim]:
assumes "other P I \<sigma> \<sigma>'"
and "\<lbrakk> \<forall>i\<in>I. \<sigma>' i = \<sigma> i; \<forall>j. j\<notin>I \<longrightarrow> P (\<sigma> j) (\<sigma>' j) \<rbrakk> \<Longrightarrow> R \<sigma> \<sigma>'"
shows "R \<sigma> \<sigma>'"
using assms unfolding other_def by simp
lemma other_localD [dest]:
"other P {i} \<sigma> \<sigma>' \<Longrightarrow> \<sigma>' i = \<sigma> i"
by auto
lemma other_otherD [dest]:
"other P {i} \<sigma> \<sigma>' \<Longrightarrow> \<forall>j. j\<noteq>i \<longrightarrow> P (\<sigma> j) (\<sigma>' j)"
by auto
lemma other_bothE [elim]:
assumes "other P {i} \<sigma> \<sigma>'"
obtains "\<sigma>' i = \<sigma> i" and "\<forall>j. j\<noteq>i \<longrightarrow> P (\<sigma> j) (\<sigma>' j)"
using assms by auto
lemma weaken_local [elim]:
assumes "other P I \<sigma> \<sigma>'"
and PQ: "\<And>\<xi> \<xi>'. P \<xi> \<xi>' \<Longrightarrow> Q \<xi> \<xi>'"
shows "other Q I \<sigma> \<sigma>'"
using assms unfolding other_def by auto
definition global :: "((nat \<Rightarrow> 's) \<Rightarrow> bool) \<Rightarrow> (nat \<Rightarrow> 's) \<times> 'local \<Rightarrow> bool"
where "global P \<equiv> (\<lambda>(\<sigma>, _). P \<sigma>)"
lemma globalsimp [simp]: "global P s = P (fst s)"
unfolding global_def by (simp split: prod.split)
definition globala :: "((nat \<Rightarrow> 's, 'action) transition \<Rightarrow> bool)
\<Rightarrow> ((nat \<Rightarrow> 's) \<times> 'local, 'action) transition \<Rightarrow> bool"
where "globala P \<equiv> (\<lambda>((\<sigma>, _), a, (\<sigma>', _)). P (\<sigma>, a, \<sigma>'))"
lemma globalasimp [simp]: "globala P s = P (fst (fst s), fst (snd s), fst (snd (snd s)))"
unfolding globala_def by (simp split: prod.split)
end
|