src/HOL/IMPP/Natural.ML
author wenzelm
Tue, 25 Jul 2000 01:27:36 +0200
changeset 9442 6f089616ae1f
parent 8177 e59e93ad85eb
child 10962 cda180b1e2e0
permissions -rw-r--r--
by (CLASIMPSET auto_tac);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8177
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     1
(*  Title:      HOL/IMPP/Natural.ML
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     2
    ID:         $Id$
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     3
    Author:     David von Oheimb, TUM
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     4
    Copyright   1999 TUM
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     5
*)
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     6
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     7
open Natural;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     8
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
     9
AddIs evalc.intrs;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    10
AddIs evaln.intrs;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    11
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    12
val evalc_elim_cases = map evalc.mk_cases
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    13
   ["<SKIP,s> -c-> t", "<X:==a,s> -c-> t", "<LOCAL Y:=a IN c,s> -c-> t", 
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    14
    "<c1;;c2,s> -c-> t","<IF b THEN c1 ELSE c2,s> -c-> t",
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    15
    "<BODY P,s> -c-> s1", "<X:=CALL P(a),s> -c-> s1"];
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    16
val evaln_elim_cases = map evaln.mk_cases
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    17
   ["<SKIP,s> -n-> t", "<X:==a,s> -n-> t", "<LOCAL Y:=a IN c,s> -n-> t",
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    18
    "<c1;;c2,s> -n-> t","<IF b THEN c1 ELSE c2,s> -n-> t",
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    19
    "<BODY P,s> -n-> s1", "<X:=CALL P(a),s> -n-> s1"];
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    20
val evalc_WHILE_case = evalc.mk_cases "<WHILE b DO c,s> -c-> t";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    21
val evaln_WHILE_case = evaln.mk_cases "<WHILE b DO c,s> -n-> t";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    22
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    23
AddSEs evalc_elim_cases;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    24
AddSEs evaln_elim_cases;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    25
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    26
(* evaluation of com is deterministic *)
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    27
Goal "<c,s> -c-> t ==> (!u. <c,s> -c-> u --> u=t)";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    28
be evalc.induct 1;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    29
by (thin_tac "<?c,s1> -c-> s2" 8);
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    30
(*blast_tac needs Unify.search_bound := 40*)
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    31
by (ALLGOALS (best_tac (claset() addEs [evalc_WHILE_case])));
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    32
qed_spec_mp "com_det";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    33
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    34
Goal "<c,s> -n-> t ==> <c,s> -c-> t";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    35
be evaln.induct 1;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    36
by (ALLGOALS (resolve_tac evalc.intrs THEN_ALL_NEW atac));
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    37
qed "evaln_evalc";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    38
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    39
goal Nat.thy "(Suc n <= m') --> (? m. m' = Suc m)";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    40
by (induct_tac "m'" 1);
9442
6f089616ae1f by (CLASIMPSET auto_tac);
wenzelm
parents: 8177
diff changeset
    41
by (CLASIMPSET auto_tac);
8177
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    42
qed_spec_mp "Suc_le_D";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    43
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    44
Goal "[| Suc n <= m'; (!!m. n <= m ==> P (Suc m)) |] ==> P m'";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    45
by (cut_facts_tac (premises()) 1);
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    46
by (ftac Suc_le_D 1);
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    47
by (Clarify_tac 1);
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    48
by (eresolve_tac (premises()) 1);
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    49
qed "Suc_le_D_lemma";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    50
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    51
Goal "<c,s> -n-> t ==> !m. n<=m --> <c,s> -m-> t";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    52
be evaln.induct 1;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    53
by (ALLGOALS (EVERY'[strip_tac,TRY o etac Suc_le_D_lemma, REPEAT o smp_tac 1]));
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    54
by (ALLGOALS (resolve_tac evaln.intrs THEN_ALL_NEW atac));
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    55
qed_spec_mp "evaln_nonstrict";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    56
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    57
Goal "<c,s> -n-> s' ==> <c,s> -Suc n-> s'";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    58
be evaln_nonstrict 1;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    59
by Auto_tac;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    60
qed "evaln_Suc";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    61
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    62
Goal "[| <c1,s1> -n1-> t1;  <c2,s2> -n2-> t2 |] ==> \
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    63
\   ? n. <c1,s1> -n -> t1 & <c2,s2> -n -> t2";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    64
by (cut_facts_tac [read_instantiate [("m","n1"),("n","n2")] nat_le_linear] 1);
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    65
by (blast_tac (claset() addDs [evaln_nonstrict]) 1);
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    66
qed "evaln_max2";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    67
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    68
Goal "<c,s> -c-> t ==> ? n. <c,s> -n-> t";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    69
be evalc.induct 1;
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    70
by (ALLGOALS (REPEAT o etac exE));
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    71
by (TRYALL(EVERY'[datac evaln_max2 1, REPEAT o eresolve_tac [exE, conjE]]));
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    72
by (ALLGOALS (rtac exI THEN' resolve_tac evaln.intrs THEN_ALL_NEW atac));
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    73
qed "evalc_evaln";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    74
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    75
Goal "<c,s> -c-> t = (? n. <c,s> -n-> t)";
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    76
by (fast_tac (claset() addEs [evalc_evaln, evaln_evalc]) 1);
e59e93ad85eb added IMPP to HOL
oheimb
parents:
diff changeset
    77
qed "eval_eq";