src/HOL/Predicate_Compile_Examples/Examples.thy
author wenzelm
Sat Apr 23 13:00:19 2011 +0200 (2011-04-23)
changeset 42463 f270e3e18be5
parent 42208 02513eb26eb7
child 45970 b6d0cff57d96
permissions -rw-r--r--
modernized specifications;
bulwahn@39655
     1
theory Examples
wenzelm@41413
     2
imports Main "~~/src/HOL/Library/Predicate_Compile_Alternative_Defs"
bulwahn@39655
     3
begin
bulwahn@39655
     4
krauss@42208
     5
declare [[values_timeout = 480.0]]
krauss@42187
     6
bulwahn@39655
     7
section {* Formal Languages *}
bulwahn@39655
     8
bulwahn@39655
     9
subsection {* General Context Free Grammars *}
bulwahn@39655
    10
bulwahn@39655
    11
text {* a contribution by Aditi Barthwal *}
bulwahn@39655
    12
bulwahn@39655
    13
datatype ('nts,'ts) symbol = NTS 'nts
bulwahn@39655
    14
                            | TS 'ts
bulwahn@39655
    15
bulwahn@39655
    16
                            
bulwahn@39655
    17
datatype ('nts,'ts) rule = rule 'nts "('nts,'ts) symbol list"
bulwahn@39655
    18
wenzelm@42463
    19
type_synonym ('nts,'ts) grammar = "('nts,'ts) rule set * 'nts"
bulwahn@39655
    20
bulwahn@39655
    21
fun rules :: "('nts,'ts) grammar => ('nts,'ts) rule set"
bulwahn@39655
    22
where
bulwahn@39655
    23
  "rules (r, s) = r"
bulwahn@39655
    24
bulwahn@39655
    25
definition derives 
bulwahn@39655
    26
where
bulwahn@39655
    27
"derives g = { (lsl,rsl). \<exists>s1 s2 lhs rhs. 
bulwahn@39655
    28
                         (s1 @ [NTS lhs] @ s2 = lsl) \<and>
bulwahn@39655
    29
                         (s1 @ rhs @ s2) = rsl \<and>
bulwahn@39655
    30
                         (rule lhs rhs) \<in> fst g }"
bulwahn@39655
    31
bulwahn@39655
    32
abbreviation "example_grammar == 
bulwahn@39655
    33
({ rule ''S'' [NTS ''A'', NTS ''B''],
bulwahn@39655
    34
   rule ''S'' [TS ''a''],
bulwahn@39655
    35
  rule ''A'' [TS ''b'']}, ''S'')"
bulwahn@39655
    36
bulwahn@39655
    37
bulwahn@39655
    38
code_pred [inductify, skip_proof] derives .
bulwahn@39655
    39
bulwahn@39655
    40
thm derives.equation
bulwahn@39655
    41
bulwahn@39655
    42
definition "test = { rhs. derives example_grammar ([NTS ''S''], rhs) }"
bulwahn@39655
    43
bulwahn@39655
    44
code_pred (modes: o \<Rightarrow> bool) [inductify] test .
bulwahn@39655
    45
thm test.equation
bulwahn@39655
    46
bulwahn@39655
    47
values "{rhs. test rhs}"
bulwahn@39655
    48
bulwahn@39655
    49
declare rtrancl.intros(1)[code_pred_def] converse_rtrancl_into_rtrancl[code_pred_def]
bulwahn@39655
    50
bulwahn@39655
    51
code_pred [inductify] rtrancl .
bulwahn@39655
    52
bulwahn@39655
    53
definition "test2 = { rhs. ([NTS ''S''],rhs) \<in> (derives example_grammar)^*  }"
bulwahn@39655
    54
bulwahn@39655
    55
code_pred [inductify, skip_proof] test2 .
bulwahn@39655
    56
bulwahn@39655
    57
values "{rhs. test2 rhs}"
bulwahn@39655
    58
bulwahn@39655
    59
subsection {* Some concrete Context Free Grammars *}
bulwahn@39655
    60
bulwahn@39655
    61
datatype alphabet = a | b
bulwahn@39655
    62
bulwahn@39655
    63
inductive_set S\<^isub>1 and A\<^isub>1 and B\<^isub>1 where
bulwahn@39655
    64
  "[] \<in> S\<^isub>1"
bulwahn@39655
    65
| "w \<in> A\<^isub>1 \<Longrightarrow> b # w \<in> S\<^isub>1"
bulwahn@39655
    66
| "w \<in> B\<^isub>1 \<Longrightarrow> a # w \<in> S\<^isub>1"
bulwahn@39655
    67
| "w \<in> S\<^isub>1 \<Longrightarrow> a # w \<in> A\<^isub>1"
bulwahn@39655
    68
| "w \<in> S\<^isub>1 \<Longrightarrow> b # w \<in> S\<^isub>1"
bulwahn@39655
    69
| "\<lbrakk>v \<in> B\<^isub>1; v \<in> B\<^isub>1\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>1"
bulwahn@39655
    70
bulwahn@39655
    71
code_pred [inductify] S\<^isub>1p .
bulwahn@39655
    72
code_pred [random_dseq inductify] S\<^isub>1p .
bulwahn@39655
    73
thm S\<^isub>1p.equation
bulwahn@39655
    74
thm S\<^isub>1p.random_dseq_equation
bulwahn@39655
    75
bulwahn@39655
    76
values [random_dseq 5, 5, 5] 5 "{x. S\<^isub>1p x}"
bulwahn@39655
    77
bulwahn@39655
    78
inductive_set S\<^isub>2 and A\<^isub>2 and B\<^isub>2 where
bulwahn@39655
    79
  "[] \<in> S\<^isub>2"
bulwahn@39655
    80
| "w \<in> A\<^isub>2 \<Longrightarrow> b # w \<in> S\<^isub>2"
bulwahn@39655
    81
| "w \<in> B\<^isub>2 \<Longrightarrow> a # w \<in> S\<^isub>2"
bulwahn@39655
    82
| "w \<in> S\<^isub>2 \<Longrightarrow> a # w \<in> A\<^isub>2"
bulwahn@39655
    83
| "w \<in> S\<^isub>2 \<Longrightarrow> b # w \<in> B\<^isub>2"
bulwahn@39655
    84
| "\<lbrakk>v \<in> B\<^isub>2; v \<in> B\<^isub>2\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>2"
bulwahn@39655
    85
bulwahn@39655
    86
code_pred [random_dseq inductify] S\<^isub>2p .
bulwahn@39655
    87
thm S\<^isub>2p.random_dseq_equation
bulwahn@39655
    88
thm A\<^isub>2p.random_dseq_equation
bulwahn@39655
    89
thm B\<^isub>2p.random_dseq_equation
bulwahn@39655
    90
bulwahn@39655
    91
values [random_dseq 5, 5, 5] 10 "{x. S\<^isub>2p x}"
bulwahn@39655
    92
bulwahn@39655
    93
inductive_set S\<^isub>3 and A\<^isub>3 and B\<^isub>3 where
bulwahn@39655
    94
  "[] \<in> S\<^isub>3"
bulwahn@39655
    95
| "w \<in> A\<^isub>3 \<Longrightarrow> b # w \<in> S\<^isub>3"
bulwahn@39655
    96
| "w \<in> B\<^isub>3 \<Longrightarrow> a # w \<in> S\<^isub>3"
bulwahn@39655
    97
| "w \<in> S\<^isub>3 \<Longrightarrow> a # w \<in> A\<^isub>3"
bulwahn@39655
    98
| "w \<in> S\<^isub>3 \<Longrightarrow> b # w \<in> B\<^isub>3"
bulwahn@39655
    99
| "\<lbrakk>v \<in> B\<^isub>3; w \<in> B\<^isub>3\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>3"
bulwahn@39655
   100
bulwahn@39655
   101
code_pred [inductify, skip_proof] S\<^isub>3p .
bulwahn@39655
   102
thm S\<^isub>3p.equation
bulwahn@39655
   103
bulwahn@39655
   104
values 10 "{x. S\<^isub>3p x}"
bulwahn@39655
   105
bulwahn@39655
   106
inductive_set S\<^isub>4 and A\<^isub>4 and B\<^isub>4 where
bulwahn@39655
   107
  "[] \<in> S\<^isub>4"
bulwahn@39655
   108
| "w \<in> A\<^isub>4 \<Longrightarrow> b # w \<in> S\<^isub>4"
bulwahn@39655
   109
| "w \<in> B\<^isub>4 \<Longrightarrow> a # w \<in> S\<^isub>4"
bulwahn@39655
   110
| "w \<in> S\<^isub>4 \<Longrightarrow> a # w \<in> A\<^isub>4"
bulwahn@39655
   111
| "\<lbrakk>v \<in> A\<^isub>4; w \<in> A\<^isub>4\<rbrakk> \<Longrightarrow> b # v @ w \<in> A\<^isub>4"
bulwahn@39655
   112
| "w \<in> S\<^isub>4 \<Longrightarrow> b # w \<in> B\<^isub>4"
bulwahn@39655
   113
| "\<lbrakk>v \<in> B\<^isub>4; w \<in> B\<^isub>4\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>4"
bulwahn@39655
   114
bulwahn@39655
   115
code_pred (expected_modes: o => bool, i => bool) S\<^isub>4p .
bulwahn@39655
   116
bulwahn@39655
   117
hide_const a b
bulwahn@39655
   118
bulwahn@39655
   119
section {* Semantics of programming languages *}
bulwahn@39655
   120
bulwahn@39655
   121
subsection {* IMP *}
bulwahn@39655
   122
wenzelm@42463
   123
type_synonym var = nat
wenzelm@42463
   124
type_synonym state = "int list"
bulwahn@39655
   125
bulwahn@39655
   126
datatype com =
bulwahn@39655
   127
  Skip |
bulwahn@39655
   128
  Ass var "state => int" |
bulwahn@39655
   129
  Seq com com |
bulwahn@39655
   130
  IF "state => bool" com com |
bulwahn@39655
   131
  While "state => bool" com
bulwahn@39655
   132
bulwahn@39655
   133
inductive exec :: "com => state => state => bool" where
bulwahn@39655
   134
"exec Skip s s" |
bulwahn@39655
   135
"exec (Ass x e) s (s[x := e(s)])" |
bulwahn@39655
   136
"exec c1 s1 s2 ==> exec c2 s2 s3 ==> exec (Seq c1 c2) s1 s3" |
bulwahn@39655
   137
"b s ==> exec c1 s t ==> exec (IF b c1 c2) s t" |
bulwahn@39655
   138
"~b s ==> exec c2 s t ==> exec (IF b c1 c2) s t" |
bulwahn@39655
   139
"~b s ==> exec (While b c) s s" |
bulwahn@39655
   140
"b s1 ==> exec c s1 s2 ==> exec (While b c) s2 s3 ==> exec (While b c) s1 s3"
bulwahn@39655
   141
bulwahn@39655
   142
code_pred exec .
bulwahn@39655
   143
bulwahn@39655
   144
values "{t. exec
bulwahn@39655
   145
 (While (%s. s!0 > 0) (Seq (Ass 0 (%s. s!0 - 1)) (Ass 1 (%s. s!1 + 1))))
bulwahn@39655
   146
 [3,5] t}"
bulwahn@39655
   147
bulwahn@39655
   148
subsection {* Lambda *}
bulwahn@39655
   149
bulwahn@39655
   150
datatype type =
bulwahn@39655
   151
    Atom nat
bulwahn@39655
   152
  | Fun type type    (infixr "\<Rightarrow>" 200)
bulwahn@39655
   153
bulwahn@39655
   154
datatype dB =
bulwahn@39655
   155
    Var nat
bulwahn@39655
   156
  | App dB dB (infixl "\<degree>" 200)
bulwahn@39655
   157
  | Abs type dB
bulwahn@39655
   158
bulwahn@39655
   159
primrec
bulwahn@39655
   160
  nth_el :: "'a list \<Rightarrow> nat \<Rightarrow> 'a option" ("_\<langle>_\<rangle>" [90, 0] 91)
bulwahn@39655
   161
where
bulwahn@39655
   162
  "[]\<langle>i\<rangle> = None"
bulwahn@39655
   163
| "(x # xs)\<langle>i\<rangle> = (case i of 0 \<Rightarrow> Some x | Suc j \<Rightarrow> xs \<langle>j\<rangle>)"
bulwahn@39655
   164
bulwahn@39655
   165
inductive nth_el' :: "'a list \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> bool"
bulwahn@39655
   166
where
bulwahn@39655
   167
  "nth_el' (x # xs) 0 x"
bulwahn@39655
   168
| "nth_el' xs i y \<Longrightarrow> nth_el' (x # xs) (Suc i) y"
bulwahn@39655
   169
bulwahn@39655
   170
inductive typing :: "type list \<Rightarrow> dB \<Rightarrow> type \<Rightarrow> bool"  ("_ \<turnstile> _ : _" [50, 50, 50] 50)
bulwahn@39655
   171
  where
bulwahn@39655
   172
    Var [intro!]: "nth_el' env x T \<Longrightarrow> env \<turnstile> Var x : T"
bulwahn@39655
   173
  | Abs [intro!]: "T # env \<turnstile> t : U \<Longrightarrow> env \<turnstile> Abs T t : (T \<Rightarrow> U)"
bulwahn@39655
   174
  | App [intro!]: "env \<turnstile> s : T \<Rightarrow> U \<Longrightarrow> env \<turnstile> t : T \<Longrightarrow> env \<turnstile> (s \<degree> t) : U"
bulwahn@39655
   175
bulwahn@39655
   176
primrec
bulwahn@39655
   177
  lift :: "[dB, nat] => dB"
bulwahn@39655
   178
where
bulwahn@39655
   179
    "lift (Var i) k = (if i < k then Var i else Var (i + 1))"
bulwahn@39655
   180
  | "lift (s \<degree> t) k = lift s k \<degree> lift t k"
bulwahn@39655
   181
  | "lift (Abs T s) k = Abs T (lift s (k + 1))"
bulwahn@39655
   182
bulwahn@39655
   183
primrec
bulwahn@39655
   184
  subst :: "[dB, dB, nat] => dB"  ("_[_'/_]" [300, 0, 0] 300)
bulwahn@39655
   185
where
bulwahn@39655
   186
    subst_Var: "(Var i)[s/k] =
bulwahn@39655
   187
      (if k < i then Var (i - 1) else if i = k then s else Var i)"
bulwahn@39655
   188
  | subst_App: "(t \<degree> u)[s/k] = t[s/k] \<degree> u[s/k]"
bulwahn@39655
   189
  | subst_Abs: "(Abs T t)[s/k] = Abs T (t[lift s 0 / k+1])"
bulwahn@39655
   190
bulwahn@39655
   191
inductive beta :: "[dB, dB] => bool"  (infixl "\<rightarrow>\<^sub>\<beta>" 50)
bulwahn@39655
   192
  where
bulwahn@39655
   193
    beta [simp, intro!]: "Abs T s \<degree> t \<rightarrow>\<^sub>\<beta> s[t/0]"
bulwahn@39655
   194
  | appL [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> s \<degree> u \<rightarrow>\<^sub>\<beta> t \<degree> u"
bulwahn@39655
   195
  | appR [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> u \<degree> s \<rightarrow>\<^sub>\<beta> u \<degree> t"
bulwahn@39655
   196
  | abs [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> Abs T s \<rightarrow>\<^sub>\<beta> Abs T t"
bulwahn@39655
   197
bulwahn@39655
   198
code_pred (expected_modes: i => i => o => bool, i => i => i => bool) typing .
bulwahn@39655
   199
thm typing.equation
bulwahn@39655
   200
bulwahn@39655
   201
code_pred (modes: i => i => bool,  i => o => bool as reduce') beta .
bulwahn@39655
   202
thm beta.equation
bulwahn@39655
   203
bulwahn@39655
   204
values "{x. App (Abs (Atom 0) (Var 0)) (Var 1) \<rightarrow>\<^sub>\<beta> x}"
bulwahn@39655
   205
bulwahn@39655
   206
definition "reduce t = Predicate.the (reduce' t)"
bulwahn@39655
   207
bulwahn@39655
   208
value "reduce (App (Abs (Atom 0) (Var 0)) (Var 1))"
bulwahn@39655
   209
bulwahn@39655
   210
code_pred [dseq] typing .
bulwahn@39655
   211
code_pred [random_dseq] typing .
bulwahn@39655
   212
bulwahn@39655
   213
values [random_dseq 1,1,5] 10 "{(\<Gamma>, t, T). \<Gamma> \<turnstile> t : T}"
bulwahn@39655
   214
bulwahn@39655
   215
subsection {* A minimal example of yet another semantics *}
bulwahn@39655
   216
bulwahn@39655
   217
text {* thanks to Elke Salecker *}
bulwahn@39655
   218
wenzelm@42463
   219
type_synonym vname = nat
wenzelm@42463
   220
type_synonym vvalue = int
wenzelm@42463
   221
type_synonym var_assign = "vname \<Rightarrow> vvalue"  --"variable assignment"
bulwahn@39655
   222
bulwahn@39655
   223
datatype ir_expr = 
bulwahn@39655
   224
  IrConst vvalue
bulwahn@39655
   225
| ObjAddr vname
bulwahn@39655
   226
| Add ir_expr ir_expr
bulwahn@39655
   227
bulwahn@39655
   228
datatype val =
bulwahn@39655
   229
  IntVal  vvalue
bulwahn@39655
   230
bulwahn@39655
   231
record  configuration =
bulwahn@39655
   232
  Env :: var_assign
bulwahn@39655
   233
bulwahn@39655
   234
inductive eval_var ::
bulwahn@39655
   235
  "ir_expr \<Rightarrow> configuration \<Rightarrow> val \<Rightarrow> bool"
bulwahn@39655
   236
where
bulwahn@39655
   237
  irconst: "eval_var (IrConst i) conf (IntVal i)"
bulwahn@39655
   238
| objaddr: "\<lbrakk> Env conf n = i \<rbrakk> \<Longrightarrow> eval_var (ObjAddr n) conf (IntVal i)"
bulwahn@39655
   239
| plus: "\<lbrakk> eval_var l conf (IntVal vl); eval_var r conf (IntVal vr) \<rbrakk> \<Longrightarrow> eval_var (Add l r) conf (IntVal (vl+vr))"
bulwahn@39655
   240
bulwahn@39655
   241
bulwahn@39655
   242
code_pred eval_var .
bulwahn@39655
   243
thm eval_var.equation
bulwahn@39655
   244
bulwahn@39655
   245
values "{val. eval_var (Add (IrConst 1) (IrConst 2)) (| Env = (\<lambda>x. 0)|) val}"
bulwahn@39655
   246
bulwahn@39655
   247
subsection {* Another semantics *}
bulwahn@39655
   248
wenzelm@42463
   249
type_synonym name = nat --"For simplicity in examples"
wenzelm@42463
   250
type_synonym state' = "name \<Rightarrow> nat"
bulwahn@39655
   251
bulwahn@39655
   252
datatype aexp = N nat | V name | Plus aexp aexp
bulwahn@39655
   253
bulwahn@39655
   254
fun aval :: "aexp \<Rightarrow> state' \<Rightarrow> nat" where
bulwahn@39655
   255
"aval (N n) _ = n" |
bulwahn@39655
   256
"aval (V x) st = st x" |
bulwahn@39655
   257
"aval (Plus e\<^isub>1 e\<^isub>2) st = aval e\<^isub>1 st + aval e\<^isub>2 st"
bulwahn@39655
   258
bulwahn@39655
   259
datatype bexp = B bool | Not bexp | And bexp bexp | Less aexp aexp
bulwahn@39655
   260
bulwahn@39655
   261
primrec bval :: "bexp \<Rightarrow> state' \<Rightarrow> bool" where
bulwahn@39655
   262
"bval (B b) _ = b" |
bulwahn@39655
   263
"bval (Not b) st = (\<not> bval b st)" |
bulwahn@39655
   264
"bval (And b1 b2) st = (bval b1 st \<and> bval b2 st)" |
bulwahn@39655
   265
"bval (Less a\<^isub>1 a\<^isub>2) st = (aval a\<^isub>1 st < aval a\<^isub>2 st)"
bulwahn@39655
   266
bulwahn@39655
   267
datatype
bulwahn@39655
   268
  com' = SKIP 
bulwahn@39655
   269
      | Assign name aexp         ("_ ::= _" [1000, 61] 61)
bulwahn@39655
   270
      | Semi   com'  com'          ("_; _"  [60, 61] 60)
bulwahn@39655
   271
      | If     bexp com' com'     ("IF _ THEN _ ELSE _"  [0, 0, 61] 61)
bulwahn@39655
   272
      | While  bexp com'         ("WHILE _ DO _"  [0, 61] 61)
bulwahn@39655
   273
bulwahn@39655
   274
inductive
bulwahn@39655
   275
  big_step :: "com' * state' \<Rightarrow> state' \<Rightarrow> bool" (infix "\<Rightarrow>" 55)
bulwahn@39655
   276
where
bulwahn@39655
   277
  Skip:    "(SKIP,s) \<Rightarrow> s"
bulwahn@39655
   278
| Assign:  "(x ::= a,s) \<Rightarrow> s(x := aval a s)"
bulwahn@39655
   279
bulwahn@39655
   280
| Semi:    "(c\<^isub>1,s\<^isub>1) \<Rightarrow> s\<^isub>2  \<Longrightarrow>  (c\<^isub>2,s\<^isub>2) \<Rightarrow> s\<^isub>3  \<Longrightarrow> (c\<^isub>1;c\<^isub>2, s\<^isub>1) \<Rightarrow> s\<^isub>3"
bulwahn@39655
   281
bulwahn@39655
   282
| IfTrue:  "bval b s  \<Longrightarrow>  (c\<^isub>1,s) \<Rightarrow> t  \<Longrightarrow>  (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t"
bulwahn@39655
   283
| IfFalse: "\<not>bval b s  \<Longrightarrow>  (c\<^isub>2,s) \<Rightarrow> t  \<Longrightarrow>  (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t"
bulwahn@39655
   284
bulwahn@39655
   285
| WhileFalse: "\<not>bval b s \<Longrightarrow> (WHILE b DO c,s) \<Rightarrow> s"
bulwahn@39655
   286
| WhileTrue:  "bval b s\<^isub>1  \<Longrightarrow>  (c,s\<^isub>1) \<Rightarrow> s\<^isub>2  \<Longrightarrow>  (WHILE b DO c, s\<^isub>2) \<Rightarrow> s\<^isub>3
bulwahn@39655
   287
               \<Longrightarrow> (WHILE b DO c, s\<^isub>1) \<Rightarrow> s\<^isub>3"
bulwahn@39655
   288
bulwahn@39655
   289
code_pred big_step .
bulwahn@39655
   290
bulwahn@39655
   291
thm big_step.equation
bulwahn@39655
   292
bulwahn@42094
   293
definition list :: "(nat \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> 'a list" where
bulwahn@42094
   294
  "list s n = map s [0 ..< n]"
bulwahn@42094
   295
bulwahn@42094
   296
values [expected "{[42, (43 :: nat)]}"] "{list s 2|s. (SKIP, nth [42, 43]) \<Rightarrow> s}"
bulwahn@42094
   297
bulwahn@42094
   298
bulwahn@39655
   299
subsection {* CCS *}
bulwahn@39655
   300
bulwahn@39655
   301
text{* This example formalizes finite CCS processes without communication or
bulwahn@39655
   302
recursion. For simplicity, labels are natural numbers. *}
bulwahn@39655
   303
bulwahn@39655
   304
datatype proc = nil | pre nat proc | or proc proc | par proc proc
bulwahn@39655
   305
bulwahn@39655
   306
inductive step :: "proc \<Rightarrow> nat \<Rightarrow> proc \<Rightarrow> bool" where
bulwahn@39655
   307
"step (pre n p) n p" |
bulwahn@39655
   308
"step p1 a q \<Longrightarrow> step (or p1 p2) a q" |
bulwahn@39655
   309
"step p2 a q \<Longrightarrow> step (or p1 p2) a q" |
bulwahn@39655
   310
"step p1 a q \<Longrightarrow> step (par p1 p2) a (par q p2)" |
bulwahn@39655
   311
"step p2 a q \<Longrightarrow> step (par p1 p2) a (par p1 q)"
bulwahn@39655
   312
bulwahn@39655
   313
code_pred step .
bulwahn@39655
   314
bulwahn@39655
   315
inductive steps where
bulwahn@39655
   316
"steps p [] p" |
bulwahn@39655
   317
"step p a q \<Longrightarrow> steps q as r \<Longrightarrow> steps p (a#as) r"
bulwahn@39655
   318
bulwahn@39655
   319
code_pred steps .
bulwahn@39655
   320
bulwahn@39655
   321
values 3 
bulwahn@39655
   322
 "{as . steps (par (or (pre 0 nil) (pre 1 nil)) (pre 2 nil)) as (par nil nil)}"
bulwahn@39655
   323
bulwahn@39655
   324
values 5
bulwahn@39655
   325
 "{as . steps (par (or (pre 0 nil) (pre 1 nil)) (pre 2 nil)) as (par nil nil)}"
bulwahn@39655
   326
bulwahn@39655
   327
values 3 "{(a,q). step (par nil nil) a q}"
bulwahn@39655
   328
bulwahn@39655
   329
bulwahn@39655
   330
end
bulwahn@39655
   331