src/HOL/BCV/Fixpoint.ML
author wenzelm
Tue, 05 Oct 1999 15:30:14 +0200
changeset 7718 86755cc5b83c
parent 7626 5997f35954d7
child 7961 422ac6888c7f
permissions -rw-r--r--
Present.setup;
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)));
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     8
by(asm_full_simp_tac (simpset() addsimps [wf_iff_no_infinite_down_chain]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     9
                                addsplits [split_split]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    10
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    11
br ccontr 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    12
by(Asm_full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    13
by(res_inst_tac[("x","0")] allE 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    14
ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    15
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    16
by(rename_tac "next s0" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    17
by(subgoal_tac "!i. fst(f i) = next" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    18
by(eres_inst_tac[("x","%i. snd(f i)")] allE 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    19
by(Asm_full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    20
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    21
by(eres_inst_tac[("x","i")] allE 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    22
by(eres_inst_tac[("x","i")] allE 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    23
by(Force_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    24
br allI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    25
by(induct_tac "i" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    26
by(Asm_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    27
by(eres_inst_tac[("x","n")] allE 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    28
by(Auto_tac);
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))";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    36
by(stac (fix_tc RS (hd fix.rules)) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    37
by(Simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    38
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    39
by(subgoal_tac "!i. f i : A" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    40
 by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    41
br allI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    42
by(induct_tac "i" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    43
 by(Asm_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    44
by(Auto_tac);
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";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    50
by(Blast_tac 1);
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)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    58
by(subgoal_tac "wf{(y,x::'a::order). x : L & next x = Some y & y ~= x}" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    59
 by(full_simp_tac (simpset() addsimps [acc_def]) 2);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    60
 be wf_subset 2;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    61
 by(simp_tac (simpset() addsimps [order_less_le]) 2);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    62
 by(blast_tac (claset() addDs [lemma]) 2);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    63
by(res_inst_tac [("a","s")] wf_induct 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    64
 ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    65
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    66
by(Full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    67
by(stac fix_unfold 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    68
   ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    69
  ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    70
 ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    71
by(split_tac [option.split] 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    72
br conjI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    73
 by(thin_tac "!a:L. !b. next a = Some b --> a <= b" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    74
 by(Force_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    75
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    76
by(split_tac [split_if] 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    77
br conjI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    78
 by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    79
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    80
by(EVERY[etac allE 1, etac impE 1, etac impE 2, etac trans 3]);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    81
  by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    82
 be lemma 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    83
 by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    84
br iffI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    85
 by(blast_tac (claset() addIs [order_trans]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    86
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    87
by(EVERY[rtac bexI 1, atac 2, rtac conjI 1, atac 2]);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    88
by(thin_tac "!a:L. !b. next a = Some b --> a <= b" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    89
by(Force_tac 1);
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)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   106
by(res_inst_tac [("a","s")] wf_induct 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   107
 ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   108
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   109
by(Full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   110
by(stac fix_unfold 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   111
   ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   112
  ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   113
 ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   114
by(split_tac [option.split] 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   115
br conjI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   116
 by(blast_tac (claset() addDs [sym RS trans]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   117
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   118
by(split_tac [split_if] 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   119
br conjI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   120
 by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   121
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   122
by(EVERY[etac allE 1, etac impE 1, etac impE 2, etac trans 3]);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   123
  by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   124
 be lemma 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   125
 by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   126
br iffI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   127
 by(subgoal_tac "next a ~= None" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   128
  by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   129
  by(EVERY[etac ballE 1, etac ballE 1, etac allE 1, etac impE 1,etac disjE 2]);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   130
      br conjI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   131
       ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   132
      ba 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   133
     by(blast_tac (claset() addDs [sym RS trans]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   134
    by(blast_tac (claset() addIs [order_trans]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   135
   by(blast_tac (claset() addIs [order_trans]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   136
  by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   137
 br notI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   138
 by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   139
 by(blast_tac (claset() addDs [sym RS trans,lemma]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   140
by(blast_tac (claset() addDs [sym RS trans]) 1);
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
*)