equal
deleted
inserted
replaced
8 theory QuoNestedDataType imports Main begin |
8 theory QuoNestedDataType imports Main begin |
9 |
9 |
10 subsection{*Defining the Free Algebra*} |
10 subsection{*Defining the Free Algebra*} |
11 |
11 |
12 text{*Messages with encryption and decryption as free constructors.*} |
12 text{*Messages with encryption and decryption as free constructors.*} |
13 datatype |
13 datatype_new |
14 freeExp = VAR nat |
14 freeExp = VAR nat |
15 | PLUS freeExp freeExp |
15 | PLUS freeExp freeExp |
16 | FNCALL nat "freeExp list" |
16 | FNCALL nat "freeExp list" |
|
17 |
|
18 datatype_compat freeExp |
17 |
19 |
18 text{*The equivalence relation, which makes PLUS associative.*} |
20 text{*The equivalence relation, which makes PLUS associative.*} |
19 |
21 |
20 text{*The first rule is the desired equation. The next three rules |
22 text{*The first rule is the desired equation. The next three rules |
21 make the equations applicable to subterms. The last two rules are symmetry |
23 make the equations applicable to subterms. The last two rules are symmetry |
36 |
38 |
37 text{*Proving that it is an equivalence relation*} |
39 text{*Proving that it is an equivalence relation*} |
38 |
40 |
39 lemma exprel_refl: "X \<sim> X" |
41 lemma exprel_refl: "X \<sim> X" |
40 and list_exprel_refl: "(Xs,Xs) \<in> listrel(exprel)" |
42 and list_exprel_refl: "(Xs,Xs) \<in> listrel(exprel)" |
41 by (induct X and Xs) (blast intro: exprel.intros listrel.intros)+ |
43 by (induct X and Xs rule: compat_freeExp.induct compat_freeExp_list.induct) |
|
44 (blast intro: exprel.intros listrel.intros)+ |
42 |
45 |
43 theorem equiv_exprel: "equiv UNIV exprel" |
46 theorem equiv_exprel: "equiv UNIV exprel" |
44 proof - |
47 proof - |
45 have "refl exprel" by (simp add: refl_on_def exprel_refl) |
48 have "refl exprel" by (simp add: refl_on_def exprel_refl) |
46 moreover have "sym exprel" by (simp add: sym_def, blast intro: exprel.SYM) |
49 moreover have "sym exprel" by (simp add: sym_def, blast intro: exprel.SYM) |
304 done |
307 done |
305 |
308 |
306 lemma vars_FnCall [simp]: "vars (FnCall F Xs) = vars_list Xs" |
309 lemma vars_FnCall [simp]: "vars (FnCall F Xs) = vars_list Xs" |
307 apply (cases Xs rule: eq_Abs_ExpList) |
310 apply (cases Xs rule: eq_Abs_ExpList) |
308 apply (simp add: FnCall) |
311 apply (simp add: FnCall) |
309 apply (induct_tac Us) |
312 apply (induct_tac Us) |
310 apply (simp_all add: vars_def UN_equiv_class [OF equiv_exprel vars_respects]) |
313 apply (simp_all add: vars_def UN_equiv_class [OF equiv_exprel vars_respects]) |
311 done |
314 done |
312 |
315 |
313 lemma vars_FnCall_Nil: "vars (FnCall F Nil) = {}" |
316 lemma vars_FnCall_Nil: "vars (FnCall F Nil) = {}" |
314 by simp |
317 by simp |
426 shows "P1 exp" and "P2 list" |
429 shows "P1 exp" and "P2 list" |
427 proof - |
430 proof - |
428 obtain U where exp: "exp = (Abs_Exp (exprel `` {U}))" by (cases exp) |
431 obtain U where exp: "exp = (Abs_Exp (exprel `` {U}))" by (cases exp) |
429 obtain Us where list: "list = Abs_ExpList Us" by (rule eq_Abs_ExpList) |
432 obtain Us where list: "list = Abs_ExpList Us" by (rule eq_Abs_ExpList) |
430 have "P1 (Abs_Exp (exprel `` {U}))" and "P2 (Abs_ExpList Us)" |
433 have "P1 (Abs_Exp (exprel `` {U}))" and "P2 (Abs_ExpList Us)" |
431 proof (induct U and Us) |
434 proof (induct U and Us rule: compat_freeExp.induct compat_freeExp_list.induct) |
432 case (VAR nat) |
435 case (VAR nat) |
433 with V show ?case by (simp add: Var_def) |
436 with V show ?case by (simp add: Var_def) |
434 next |
437 next |
435 case (PLUS X Y) |
438 case (PLUS X Y) |
436 with P [of "Abs_Exp (exprel `` {X})" "Abs_Exp (exprel `` {Y})"] |
439 with P [of "Abs_Exp (exprel `` {X})" "Abs_Exp (exprel `` {Y})"] |