src/HOL/BCV/Fixpoint.ML
author paulson
Thu, 28 Oct 1999 14:55:23 +0200
changeset 7961 422ac6888c7f
parent 7626 5997f35954d7
child 8624 69619f870939
permissions -rw-r--r--
expandshort
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/BCV/Fixpoint.ML
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     4
    Copyright   1999 TUM
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     5
*)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     6
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     7
goalw_cterm [] (cterm_of (sign_of thy) (HOLogic.mk_Trueprop (hd fix.tcs)));
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
     8
by (asm_full_simp_tac (simpset() addsimps [wf_iff_no_infinite_down_chain]
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     9
                                addsplits [split_split]) 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    10
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    11
by (rtac ccontr 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    12
by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    13
by (res_inst_tac[("x","0")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    14
by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    15
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    16
by (rename_tac "next s0" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    17
by (subgoal_tac "!i. fst(f i) = next" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    18
by (eres_inst_tac[("x","%i. snd(f i)")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    19
by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    20
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    21
by (eres_inst_tac[("x","i")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    22
by (eres_inst_tac[("x","i")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    23
by (Force_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    24
by (rtac allI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    25
by (induct_tac "i" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    26
by (Asm_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    27
by (eres_inst_tac[("x","n")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    28
by (Auto_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    29
val fix_tc = result();
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    30
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    31
Goalw [wf_iff_no_infinite_down_chain RS eq_reflection]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    32
 "[| wf{(t,s). s:A & next s = Some t & t ~= s}; \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    33
\    !a:A. next a : option A; s:A |] ==> \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    34
\ fix(next,s) = (case next s of None => False \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    35
\                | Some t => if t=s then True else fix(next,t))";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    36
by (stac (fix_tc RS (hd fix.rules)) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    37
by (Simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    38
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    39
by (subgoal_tac "!i. f i : A" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    40
 by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    41
by (rtac allI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    42
by (induct_tac "i" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    43
 by (Asm_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    44
by (Auto_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    45
qed "fix_unfold";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    46
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    47
(* Thm: next has fixpoint above s iff fix(next,s) *)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    48
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    49
Goal "[| x = Some y; x : option A |] ==> y : A";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    50
by (Blast_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    51
val lemma = result();
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    52
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    53
Goal
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    54
"[| acc L; \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    55
\   !t:L. !s:L. next t = Some t & s <= t --> (? u. next s = Some u & u <= t); \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    56
\   !a:L. next a : option L; !a:L. !b. next a = Some b --> a <= b |] \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    57
\ ==> s:L --> fix(next,s) = (? t:L. s <= t & next t = Some t)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    58
by (subgoal_tac "wf{(y,x::'a::order). x : L & next x = Some y & y ~= x}" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    59
 by (full_simp_tac (simpset() addsimps [acc_def]) 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    60
 by (etac wf_subset 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    61
 by (simp_tac (simpset() addsimps [order_less_le]) 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    62
 by (blast_tac (claset() addDs [lemma]) 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    63
by (res_inst_tac [("a","s")] wf_induct 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    64
 by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    65
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    66
by (Full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    67
by (stac fix_unfold 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    68
   by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    69
  by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    70
 by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    71
by (split_tac [option.split] 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    72
by (rtac conjI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    73
 by (thin_tac "!a:L. !b. next a = Some b --> a <= b" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    74
 by (Force_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    75
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    76
by (split_tac [split_if] 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    77
by (rtac conjI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    78
 by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    79
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    80
by (EVERY[etac allE 1, etac impE 1, etac impE 2, etac trans 3]);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    81
  by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    82
 by (etac lemma 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    83
 by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    84
by (rtac iffI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    85
 by (blast_tac (claset() addIs [order_trans]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    86
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    87
by (EVERY[rtac bexI 1, atac 2, rtac conjI 1, atac 2]);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    88
by (thin_tac "!a:L. !b. next a = Some b --> a <= b" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    89
by (Force_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    90
qed_spec_mp "fix_iff_has_fixpoint";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    91
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    92
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    93
(* This lemma looks more pleasing to the eye, because of the monotonicity
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    94
assumption for next, instead of the strange assumption above.
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    95
However, function next as defined in DFAimpl is NOT monotone because
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    96
None is not required to be detected as early as possible. Thus the following
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    97
does not hold: sos <= tos & next sos = None ==> next tos = None
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    98
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    99
Goal
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   100
"[| wf{(y,x::'a::order). x : L & next x = Some y & y ~= x}; \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   101
\   !t:L. !s:L. s <= t & next s = None --> next t = None; \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   102
\   !t:L. !s:L. !u. s <= t & next s = Some u --> \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   103
\                   next t = None | (? v. next t = Some v & u <= v); \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   104
\   !a:L. next a : option L; !a:L. !b. next a = Some b --> a <= b |] \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   105
\ ==> s:L --> fix(next,s) = (? t:L. s <= t & next t = Some t)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   106
by (res_inst_tac [("a","s")] wf_induct 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   107
 by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   108
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   109
by (Full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   110
by (stac fix_unfold 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   111
   by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   112
  by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   113
 by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   114
by (split_tac [option.split] 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   115
by (rtac conjI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   116
 by (blast_tac (claset() addDs [sym RS trans]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   117
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   118
by (split_tac [split_if] 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   119
by (rtac conjI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   120
 by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   121
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   122
by (EVERY[etac allE 1, etac impE 1, etac impE 2, etac trans 3]);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   123
  by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   124
 by (etac lemma 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   125
 by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   126
by (rtac iffI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   127
 by (subgoal_tac "next a ~= None" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   128
  by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   129
  by (EVERY[etac ballE 1, etac ballE 1, etac allE 1, etac impE 1,etac disjE 2]);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   130
      by (rtac conjI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   131
       by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   132
      by (assume_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   133
     by (blast_tac (claset() addDs [sym RS trans]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   134
    by (blast_tac (claset() addIs [order_trans]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   135
   by (blast_tac (claset() addIs [order_trans]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   136
  by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   137
 by (rtac notI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   138
 by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   139
 by (blast_tac (claset() addDs [sym RS trans,lemma]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   140
by (blast_tac (claset() addDs [sym RS trans]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   141
qed_spec_mp "fix_iff_has_fixpoint";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   142
*)