src/HOL/UNITY/Detects.thy
author paulson
Fri, 24 Jan 2003 14:06:49 +0100
changeset 13785 e2fcd88be55d
parent 8334 7896bcbd8641
child 13798 4c1a53627500
permissions -rw-r--r--
Partial conversion of UNITY to Isar new-style theories
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8334
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Detects
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
     2
    ID:         $Id$
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
     3
    Author:     Tanja Vos, Cambridge University Computer Laboratory
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
     4
    Copyright   2000  University of Cambridge
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
     5
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
     6
Detects definition (Section 3.8 of Chandy & Misra) using LeadsTo
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
     7
*)
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
     8
13785
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
     9
theory Detects = FP + SubstAx:
8334
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    10
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    11
consts
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    12
   op_Detects  :: "['a set, 'a set] => 'a program set"  (infixl "Detects" 60)
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    13
   op_Equality :: "['a set, 'a set] => 'a set"          (infixl "<==>" 60)
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    14
   
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    15
defs
13785
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    16
  Detects_def:  "A Detects B == (Always (-A Un B)) Int (B LeadsTo A)"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    17
  Equality_def: "A <==> B == (-A Un B) Int (A Un -B)"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    18
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    19
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    20
(* Corollary from Sectiom 3.6.4 *)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    21
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    22
lemma Always_at_FP: "F: A LeadsTo B ==> F : Always (-((FP F) Int A Int -B))"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    23
apply (rule LeadsTo_empty)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    24
apply (subgoal_tac "F : (FP F Int A Int - B) LeadsTo (B Int (FP F Int -B))")
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    25
apply (subgoal_tac [2] " (FP F Int A Int - B) = (A Int (FP F Int -B))")
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    26
apply (subgoal_tac "(B Int (FP F Int -B)) = {}")
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    27
apply auto
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    28
apply (blast intro: PSP_Stable stable_imp_Stable stable_FP_Int)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    29
done
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    30
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    31
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    32
lemma Detects_Trans: 
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    33
     "[| F : A Detects B; F : B Detects C |] ==> F : A Detects C"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    34
apply (unfold Detects_def Int_def)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    35
apply (simp (no_asm))
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    36
apply safe
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    37
apply (rule_tac [2] LeadsTo_Trans)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    38
apply auto
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    39
apply (subgoal_tac "F : Always ((-A Un B) Int (-B Un C))")
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    40
 apply (blast intro: Always_weaken)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    41
apply (simp add: Always_Int_distrib)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    42
done
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    43
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    44
lemma Detects_refl: "F : A Detects A"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    45
apply (unfold Detects_def)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    46
apply (simp (no_asm) add: Un_commute Compl_partition subset_imp_LeadsTo)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    47
done
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    48
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    49
lemma Detects_eq_Un: "(A<==>B) = (A Int B) Un (-A Int -B)"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    50
apply (unfold Equality_def)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    51
apply blast
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    52
done
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    53
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    54
(*Not quite antisymmetry: sets A and B agree in all reachable states *)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    55
lemma Detects_antisym: 
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    56
     "[| F : A Detects B;  F : B Detects A|] ==> F : Always (A <==> B)"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    57
apply (unfold Detects_def Equality_def)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    58
apply (simp add: Always_Int_I Un_commute)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    59
done
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    60
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    61
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    62
(* Theorem from Section 3.8 *)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    63
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    64
lemma Detects_Always: 
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    65
     "F : A Detects B ==> F : Always ((-(FP F)) Un (A <==> B))"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    66
apply (unfold Detects_def Equality_def)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    67
apply (simp (no_asm) add: Un_Int_distrib Always_Int_distrib)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    68
apply (blast dest: Always_at_FP intro: Always_weaken)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    69
done
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    70
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    71
(* Theorem from exercise 11.1 Section 11.3.1 *)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    72
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    73
lemma Detects_Imp_LeadstoEQ: 
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    74
     "F : A Detects B ==> F : UNIV LeadsTo (A <==> B)"
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    75
apply (unfold Detects_def Equality_def)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    76
apply (rule_tac B = "B" in LeadsTo_Diff)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    77
prefer 2 apply (blast intro: Always_LeadsTo_weaken)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    78
apply (blast intro: Always_LeadsToI subset_imp_LeadsTo)
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    79
done
e2fcd88be55d Partial conversion of UNITY to Isar new-style theories
paulson
parents: 8334
diff changeset
    80
8334
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    81
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    82
end
7896bcbd8641 Added Tanja's Detects and Reachability theories. Also
paulson
parents:
diff changeset
    83