src/HOL/Induct/Comb.thy
author haftmann
Fri, 17 Jun 2005 16:12:49 +0200
changeset 16417 9bc16273c2d4
parent 15816 4575c87dd25b
child 16563 a92f96951355
permissions -rw-r--r--
migrated theory headers to new format
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
     1
(*  Title:      HOL/Induct/Comb.thy
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
     2
    ID:         $Id$
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
     5
*)
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
     6
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
     7
header {* Combinatory Logic example: the Church-Rosser Theorem *}
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
     8
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15816
diff changeset
     9
theory Comb imports Main begin
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    10
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    11
text {*
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    12
  Curiously, combinators do not include free variables.
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    13
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    14
  Example taken from \cite{camilleri-melham}.
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    15
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    16
HOL system proofs may be found in the HOL distribution at
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    17
   .../contrib/rule-induction/cl.ml
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    18
*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    19
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    20
subsection {* Definitions *}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    21
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    22
text {* Datatype definition of combinators @{text S} and @{text K}. *}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    23
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    24
datatype comb = K
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    25
              | S
11359
29f8b00d7e1f renamed # to ## to avoid clashing with List cons
paulson
parents: 9101
diff changeset
    26
              | "##" comb comb (infixl 90)
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    27
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    28
text {*
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    29
  Inductive definition of contractions, @{text "-1->"} and
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    30
  (multi-step) reductions, @{text "--->"}.
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    31
*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    32
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    33
consts
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    34
  contract  :: "(comb*comb) set"
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    35
  "-1->"    :: "[comb,comb] => bool"   (infixl 50)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    36
  "--->"    :: "[comb,comb] => bool"   (infixl 50)
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    37
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    38
translations
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    39
  "x -1-> y" == "(x,y) \<in> contract"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    40
  "x ---> y" == "(x,y) \<in> contract^*"
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    41
15816
4575c87dd25b x-symbol syntax
paulson
parents: 13075
diff changeset
    42
syntax (xsymbols)
4575c87dd25b x-symbol syntax
paulson
parents: 13075
diff changeset
    43
  "op ##" :: "[comb,comb] => comb"  (infixl "\<bullet>" 90)
4575c87dd25b x-symbol syntax
paulson
parents: 13075
diff changeset
    44
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    45
inductive contract
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    46
  intros
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    47
    K:     "K##x##y -1-> x"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    48
    S:     "S##x##y##z -1-> (x##z)##(y##z)"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    49
    Ap1:   "x-1->y ==> x##z -1-> y##z"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    50
    Ap2:   "x-1->y ==> z##x -1-> z##y"
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    51
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    52
text {*
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    53
  Inductive definition of parallel contractions, @{text "=1=>"} and
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    54
  (multi-step) parallel reductions, @{text "===>"}.
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    55
*}
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    56
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    57
consts
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    58
  parcontract :: "(comb*comb) set"
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    59
  "=1=>"      :: "[comb,comb] => bool"   (infixl 50)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    60
  "===>"      :: "[comb,comb] => bool"   (infixl 50)
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    61
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    62
translations
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    63
  "x =1=> y" == "(x,y) \<in> parcontract"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    64
  "x ===> y" == "(x,y) \<in> parcontract^*"
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    65
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    66
inductive parcontract
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    67
  intros
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    68
    refl:  "x =1=> x"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    69
    K:     "K##x##y =1=> x"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    70
    S:     "S##x##y##z =1=> (x##z)##(y##z)"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    71
    Ap:    "[| x=1=>y;  z=1=>w |] ==> x##z =1=> y##w"
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    72
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    73
text {*
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    74
  Misc definitions.
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    75
*}
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    76
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    77
constdefs
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    78
  I :: comb
11359
29f8b00d7e1f renamed # to ## to avoid clashing with List cons
paulson
parents: 9101
diff changeset
    79
  "I == S##K##K"
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    80
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
    81
  diamond   :: "('a * 'a)set => bool"	
13075
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    82
    --{*confluence; Lambda/Commutation treats this more abstractly*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    83
  "diamond(r) == \<forall>x y. (x,y) \<in> r --> 
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    84
                  (\<forall>y'. (x,y') \<in> r --> 
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    85
                    (\<exists>z. (y,z) \<in> r & (y',z) \<in> r))"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    86
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    87
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    88
subsection {*Reflexive/Transitive closure preserves Church-Rosser property*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    89
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    90
text{*So does the Transitive closure, with a similar proof*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    91
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    92
text{*Strip lemma.  
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    93
   The induction hypothesis covers all but the last diamond of the strip.*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    94
lemma diamond_strip_lemmaE [rule_format]: 
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    95
    "[| diamond(r);  (x,y) \<in> r^* |] ==>   
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    96
          \<forall>y'. (x,y') \<in> r --> (\<exists>z. (y',z) \<in> r^* & (y,z) \<in> r)"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    97
apply (unfold diamond_def)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    98
apply (erule rtrancl_induct, blast, clarify)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
    99
apply (drule spec, drule mp, assumption)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   100
apply (blast intro: rtrancl_trans [OF _ r_into_rtrancl])
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   101
done
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   102
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   103
lemma diamond_rtrancl: "diamond(r) ==> diamond(r^*)"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   104
apply (simp (no_asm_simp) add: diamond_def)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   105
apply (rule impI [THEN allI, THEN allI])
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   106
apply (erule rtrancl_induct, blast)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   107
apply (best intro: rtrancl_trans [OF _ r_into_rtrancl] 
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   108
            elim: diamond_strip_lemmaE [THEN exE])
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   109
done
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   110
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   111
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   112
subsection {* Non-contraction results *}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   113
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   114
text {* Derive a case for each combinator constructor. *}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   115
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   116
inductive_cases
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   117
      K_contractE [elim!]: "K -1-> r"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   118
  and S_contractE [elim!]: "S -1-> r"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   119
  and Ap_contractE [elim!]: "p##q -1-> r"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   120
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   121
declare contract.K [intro!] contract.S [intro!]
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   122
declare contract.Ap1 [intro] contract.Ap2 [intro]
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   123
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   124
lemma I_contract_E [elim!]: "I -1-> z ==> P"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   125
by (unfold I_def, blast)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   126
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   127
lemma K1_contractD [elim!]: "K##x -1-> z ==> (\<exists>x'. z = K##x' & x -1-> x')"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   128
by blast
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   129
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   130
lemma Ap_reduce1 [intro]: "x ---> y ==> x##z ---> y##z"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   131
apply (erule rtrancl_induct)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   132
apply (blast intro: rtrancl_trans)+
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   133
done
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   134
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   135
lemma Ap_reduce2 [intro]: "x ---> y ==> z##x ---> z##y"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   136
apply (erule rtrancl_induct)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   137
apply (blast intro: rtrancl_trans)+
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   138
done
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   139
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   140
(** Counterexample to the diamond property for -1-> **)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   141
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   142
lemma KIII_contract1: "K##I##(I##I) -1-> I"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   143
by (rule contract.K)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   144
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   145
lemma KIII_contract2: "K##I##(I##I) -1-> K##I##((K##I)##(K##I))"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   146
by (unfold I_def, blast)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   147
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   148
lemma KIII_contract3: "K##I##((K##I)##(K##I)) -1-> I"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   149
by blast
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   150
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   151
lemma not_diamond_contract: "~ diamond(contract)"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   152
apply (unfold diamond_def) 
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   153
apply (best intro: KIII_contract1 KIII_contract2 KIII_contract3)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   154
done
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   155
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   156
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   157
subsection {* Results about Parallel Contraction *}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   158
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   159
text {* Derive a case for each combinator constructor. *}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   160
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   161
inductive_cases
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   162
      K_parcontractE [elim!]: "K =1=> r"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   163
  and S_parcontractE [elim!]: "S =1=> r"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   164
  and Ap_parcontractE [elim!]: "p##q =1=> r"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   165
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   166
declare parcontract.intros [intro]
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   167
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   168
(*** Basic properties of parallel contraction ***)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   169
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   170
subsection {* Basic properties of parallel contraction *}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   171
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   172
lemma K1_parcontractD [dest!]: "K##x =1=> z ==> (\<exists>x'. z = K##x' & x =1=> x')"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   173
by blast
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   174
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   175
lemma S1_parcontractD [dest!]: "S##x =1=> z ==> (\<exists>x'. z = S##x' & x =1=> x')"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   176
by blast
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   177
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   178
lemma S2_parcontractD [dest!]:
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   179
     "S##x##y =1=> z ==> (\<exists>x' y'. z = S##x'##y' & x =1=> x' & y =1=> y')"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   180
by blast
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   181
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   182
text{*The rules above are not essential but make proofs much faster*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   183
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   184
text{*Church-Rosser property for parallel contraction*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   185
lemma diamond_parcontract: "diamond parcontract"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   186
apply (unfold diamond_def)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   187
apply (rule impI [THEN allI, THEN allI])
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   188
apply (erule parcontract.induct, fast+)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   189
done
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   190
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   191
text {*
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   192
  \medskip Equivalence of @{prop "p ---> q"} and @{prop "p ===> q"}.
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   193
*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   194
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   195
lemma contract_subset_parcontract: "contract <= parcontract"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   196
apply (rule subsetI)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   197
apply (simp only: split_tupled_all)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   198
apply (erule contract.induct, blast+)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   199
done
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   200
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   201
text{*Reductions: simply throw together reflexivity, transitivity and
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   202
  the one-step reductions*}
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   203
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   204
declare r_into_rtrancl [intro]  rtrancl_trans [intro]
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   205
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   206
(*Example only: not used*)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   207
lemma reduce_I: "I##x ---> x"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   208
by (unfold I_def, blast)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   209
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   210
lemma parcontract_subset_reduce: "parcontract <= contract^*"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   211
apply (rule subsetI)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   212
apply (simp only: split_tupled_all)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   213
apply (erule parcontract.induct , blast+)
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   214
done
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   215
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   216
lemma reduce_eq_parreduce: "contract^* = parcontract^*"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   217
by (rule equalityI contract_subset_parcontract [THEN rtrancl_mono] 
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   218
         parcontract_subset_reduce [THEN rtrancl_subset_rtrancl])+
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   219
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   220
lemma diamond_reduce: "diamond(contract^*)"
d3e1d554cd6d conversion of some HOL/Induct proof scripts to Isar
paulson
parents: 11359
diff changeset
   221
by (simp add: reduce_eq_parreduce diamond_rtrancl diamond_parcontract)
3120
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
   222
c58423c20740 New directory to contain examples of (co)inductive definitions
paulson
parents:
diff changeset
   223
end