src/HOL/Lambda/InductTermi.ML
author nipkow
Thu, 06 Aug 1998 14:04:49 +0200
changeset 5276 dd99b958b306
parent 5269 3155ccd9a506
child 5318 72bf8039b53f
permissions -rw-r--r--
Simplified proof!!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5276
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
     1
(*  Title:      HOL/Lambda/InductTermi.ML
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
     2
    ID:         $Id$
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
     3
    Author:     Tobias Nipkow
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
     4
    Copyright   1998 TU Muenchen
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
     5
*)
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
     6
5261
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
     7
(*** Every term in IT terminates ***)
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
     8
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
     9
Goal "s : termi beta ==> !t. t : termi beta --> \
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    10
\     (!r ss. t = r[s/0]$$ss --> Abs r $ s $$ ss : termi beta)";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    11
be acc_induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    12
be thin_rl 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    13
br allI 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    14
br impI 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    15
be acc_induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    16
by(Clarify_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    17
br accI 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    18
by(safe_tac (claset() addSEs [apps_betasE]));
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    19
   ba 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    20
  by(blast_tac (claset() addIs [subst_preserves_beta,apps_preserves_beta]) 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    21
 by(blast_tac (claset()
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    22
    addIs [apps_preserves_beta2,subst_preserves_beta2,rtrancl_converseI]
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    23
    addDs [acc_downwards]) 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    24
(* FIXME: acc_downwards can be replaced by acc(R ^* ) = acc(r) *)
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    25
by(blast_tac (claset() addDs [apps_preserves_betas]) 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    26
qed_spec_mp "double_induction_lemma";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    27
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    28
Goal "t : IT ==> t : termi(beta)";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    29
be IT.induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    30
  bd rev_subsetD 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    31
   br lists_mono 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    32
   br Int_lower2 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    33
  by(Asm_full_simp_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    34
  bd lists_accD 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    35
  be acc_induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    36
  br accI 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    37
  by(blast_tac (claset() addSDs [head_Var_reduction]) 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    38
 be acc_induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    39
 br accI 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    40
 by(Blast_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    41
by(blast_tac (claset() addIs [double_induction_lemma]) 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    42
qed "IT_implies_termi";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    43
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    44
(*** Every terminating term is in IT ***)
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    45
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    46
val IT_cases = map (IT.mk_cases
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    47
 ([Var_apps_eq_Var_apps_conv, Abs_eq_apps_conv, apps_eq_Abs_conv,
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    48
   Abs_apps_eq_Abs_apps_conv,
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    49
   Var_apps_neq_Abs_apps, Var_apps_neq_Abs_apps RS not_sym,
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    50
   hd(tl(get_thms List.thy "foldl.simps")) RS sym ]
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    51
  @ dB.simps @ list.simps))
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    52
    ["Var n $$ ss : IT", "Abs t : IT", "Abs r $ s $$ ts : IT"];
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    53
AddSEs IT_cases;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    54
5276
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
    55
(* Turned out to be redundant:
5261
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    56
Goal "t : termi beta ==> \
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    57
\     !r rs. t = r$$rs --> r : termi beta & rs : termi(step1 beta)";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    58
be acc_induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    59
by(force_tac (claset()
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    60
     addIs [apps_preserves_beta,apps_preserves_betas,accI],simpset()) 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    61
val lemma = result();
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    62
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    63
Goal "r$$rs : termi beta ==> r : termi beta & rs : termi(step1 beta)";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    64
bd lemma 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    65
by(Blast_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    66
qed "apps_in_termi_betaD";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    67
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    68
Goal "t : termi beta ==> !r. t = Abs r --> r : termi beta";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    69
be acc_induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    70
by(force_tac (claset() addIs [accI],simpset()) 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    71
val lemma = result();
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    72
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    73
Goal "Abs r : termi beta ==> r : termi beta";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    74
bd lemma 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    75
by(Blast_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    76
qed "Abs_in_termi_betaD";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    77
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    78
Goal "t : termi beta ==> !r s. t = r$s --> r : termi beta & s : termi beta";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    79
be acc_induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    80
by(force_tac (claset() addIs [accI],simpset()) 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    81
val lemma = result();
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    82
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    83
Goal "r$s : termi beta ==> r : termi beta & s : termi beta";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    84
bd lemma 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    85
by(Blast_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    86
qed "App_in_termi_betaD";
5276
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
    87
*)
5261
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    88
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    89
Goal "r : termi beta ==> r : IT";
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    90
be acc_induct 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    91
by(rename_tac "r" 1);
5276
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
    92
be thin_rl 1;
5261
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    93
be rev_mp 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    94
by(Simp_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    95
by(res_inst_tac [("t","r")] Apps_dB_induct 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    96
 by(rename_tac "n ts" 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    97
 by(Clarify_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    98
 brs IT.intrs 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
    99
 by(Clarify_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   100
 by(EVERY1[dtac bspec, atac]);
5276
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
   101
 be mp 1;
5261
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   102
  by(Clarify_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   103
  bd converseI 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   104
  by(EVERY1[dtac ex_step1I, atac]);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   105
  by(Clarify_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   106
  by(rename_tac "us" 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   107
  by(eres_inst_tac [("x","Var n $$ us")] allE 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   108
  by(Force_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   109
by(rename_tac "u ts" 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   110
by(exhaust_tac "ts" 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   111
 by(Asm_full_simp_tac 1);
5276
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
   112
 by(blast_tac (claset() addIs IT.intrs) 1);
5261
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   113
by(rename_tac "s ss" 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   114
by(Asm_full_simp_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   115
by(Clarify_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   116
brs IT.intrs 1;
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   117
 by(blast_tac (claset() addIs [apps_preserves_beta]) 1);
5276
dd99b958b306 Simplified proof!!
nipkow
parents: 5269
diff changeset
   118
be mp 1;
5261
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   119
 by(Clarify_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   120
 by(rename_tac "t" 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   121
 by(eres_inst_tac [("x","Abs u $ t $$ ss")] allE 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   122
 by(Force_tac 1);
ce3c25c8a694 First steps towards termination of simply typed terms.
nipkow
parents:
diff changeset
   123
qed "termi_implies_IT";