Nominal/Ex/ExLetRec.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Mon, 10 May 2010 15:54:16 +0200
changeset 2094 56b849d348ae
parent 2091 1f38489f1cf0
child 2101 e417be53916e
permissions -rw-r--r--
Recursive examples with relation composition
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1604
5ab97f43ec24 More modification needed for compilation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1603
diff changeset
     1
theory ExLetRec
2041
3842464ee03b Move 2 more to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1773
diff changeset
     2
imports "../NewParser"
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
1685
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
     5
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
text {* example 3 or example 5 from Terms.thy *}
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
atom_decl name
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
2091
1f38489f1cf0 ExLetRec
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2082
diff changeset
    10
ML {* val _ = cheat_equivp := true *}
1f38489f1cf0 ExLetRec
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2082
diff changeset
    11
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
nominal_datatype trm =
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
  Vr "name"
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
| Ap "trm" "trm"
2041
3842464ee03b Move 2 more to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1773
diff changeset
    15
| Lm x::"name" t::"trm"  bind_set x in t
3842464ee03b Move 2 more to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1773
diff changeset
    16
| Lt a::"lts" t::"trm"   bind "bn a" in a t
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
and lts =
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  Lnil
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
| Lcons "name" "trm" "lts"
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
binder
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
  bn
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
where
1685
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    23
  "bn Lnil = []"
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    24
| "bn (Lcons x t l) = (atom x) # (bn l)"
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
thm trm_lts.fv
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
thm trm_lts.eq_iff
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
thm trm_lts.bn
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
thm trm_lts.perm
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
thm trm_lts.induct
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
thm trm_lts.distinct
1685
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    32
thm trm_lts.supp
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
thm trm_lts.fv[simplified trm_lts.supp]
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
2082
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 2067
diff changeset
    35
declare permute_trm_raw_permute_lts_raw.simps[eqvt]
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 2067
diff changeset
    36
declare alpha_gen_eqvt[eqvt]
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 2067
diff changeset
    37
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 2067
diff changeset
    38
equivariance alpha_trm_raw
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 2067
diff changeset
    39
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
(* why is this not in HOL simpset? *)
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
lemma set_sub: "{a, b} - {b} = {a} - {b}"
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
by auto
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
lemma lets_bla:
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  "x \<noteq> z \<Longrightarrow> y \<noteq> z \<Longrightarrow> x \<noteq> y \<Longrightarrow>(Lt (Lcons x (Vr y) Lnil) (Vr x)) \<noteq> (Lt (Lcons x (Vr z) Lnil) (Vr x))"
2041
3842464ee03b Move 2 more to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1773
diff changeset
    46
  by (simp add: trm_lts.eq_iff alphas2 set_sub supp_at_base)
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
lemma lets_ok:
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  "(Lt (Lcons x (Vr x) Lnil) (Vr x)) = (Lt (Lcons y (Vr y) Lnil) (Vr y))"
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
  apply (simp add: trm_lts.eq_iff)
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
  apply (rule_tac x="(x \<leftrightarrow> y)" in exI)
2041
3842464ee03b Move 2 more to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1773
diff changeset
    52
  apply (simp_all add: alphas2 fresh_star_def eqvts supp_at_base)
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
  done
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
lemma lets_ok3:
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
  "x \<noteq> y \<Longrightarrow>
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
   (Lt (Lcons x (Ap (Vr y) (Vr x)) (Lcons y (Vr y) Lnil)) (Ap (Vr x) (Vr y))) \<noteq>
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
   (Lt (Lcons y (Ap (Vr x) (Vr y)) (Lcons x (Vr x) Lnil)) (Ap (Vr x) (Vr y)))"
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
  apply (simp add: alphas trm_lts.eq_iff)
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
  done
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
lemma lets_not_ok1:
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
  "x \<noteq> y \<Longrightarrow>
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
   (Lt (Lcons x (Vr x) (Lcons y (Vr y) Lnil)) (Ap (Vr x) (Vr y))) \<noteq>
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
   (Lt (Lcons y (Vr x) (Lcons x (Vr y) Lnil)) (Ap (Vr x) (Vr y)))"
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
  apply (simp add: alphas trm_lts.eq_iff)
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
  done
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
lemma lets_nok:
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  "x \<noteq> y \<Longrightarrow> x \<noteq> z \<Longrightarrow> z \<noteq> y \<Longrightarrow>
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
   (Lt (Lcons x (Ap (Vr z) (Vr z)) (Lcons y (Vr z) Lnil)) (Ap (Vr x) (Vr y))) \<noteq>
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
   (Lt (Lcons y (Vr z) (Lcons x (Ap (Vr z) (Vr z)) Lnil)) (Ap (Vr x) (Vr y)))"
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
  apply (simp add: alphas trm_lts.eq_iff fresh_star_def)
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
  done
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
1685
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    77
lemma lets_ok4:
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    78
  "(Lt (Lcons x (Ap (Vr y) (Vr x)) (Lcons y (Vr y) Lnil)) (Ap (Vr x) (Vr y))) =
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    79
   (Lt (Lcons y (Ap (Vr x) (Vr y)) (Lcons x (Vr x) Lnil)) (Ap (Vr y) (Vr x)))"
2041
3842464ee03b Move 2 more to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1773
diff changeset
    80
  apply (simp add: alphas trm_lts.eq_iff supp_at_base)
1685
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    81
  apply (rule_tac x="(x \<leftrightarrow> y)" in exI)
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    82
  apply (simp add: atom_eqvt fresh_star_def)
721d92623c9d Lets finally abstract lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1674
diff changeset
    83
  done
1603
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
end
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
2b367c80c0d7 Moved let properties from Term5 to ExLetRec.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88