Quot/Examples/Terms.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 26 Jan 2010 13:38:42 +0100
changeset 940 a792bfc1be2b
parent 917 2cb5745f403e
child 947 fa810f01f7b5
permissions -rw-r--r--
Combined the simpsets in clean_tac and updated the comment. Now cleaning of splits does work.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory Terms
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports Nominal "../QuotMain" "../QuotList"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
atom_decl name
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
     7
text {* primrec seems to be genarally faster than fun *}
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
     8
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
     9
section {*** lets with binding patterns ***}
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    10
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
datatype trm1 =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
  Vr1 "name"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
| Ap1 "trm1" "trm1"
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    14
| Lm1 "name" "trm1"        --"name is bound in trm1"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    15
| Lt1 "bp" "trm1" "trm1"   --"all variables in bp are bound in the 2nd trm1"
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
and bp =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
  BUnit
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
| BVr "name"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
| BPr "bp" "bp"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    21
(* to be given by the user *)
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    22
primrec 
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    23
  bv1
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    24
where
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    25
  "bv1 (BUnit) = {}"
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    26
| "bv1 (BVr x) = {x}"
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    27
| "bv1 (BPr bp1 bp2) = (bv1 bp1) \<union> (bv1 bp1)"
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    28
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    29
(* needs to be calculated by the package *)
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    30
primrec 
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    31
  fv_trm1 and fv_bp
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    32
where
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    33
  "fv_trm1 (Vr1 x) = {x}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    34
| "fv_trm1 (Ap1 t1 t2) = (fv_trm1 t1) \<union> (fv_trm1 t2)"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    35
| "fv_trm1 (Lm1 x t) = (fv_trm1 t) - {x}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    36
| "fv_trm1 (Lt1 bp t1 t2) = (fv_trm1 t1) \<union> (fv_trm1 t2 - bv1 bp)"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    37
| "fv_bp (BUnit) = {}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    38
| "fv_bp (BVr x) = {x}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    39
| "fv_bp (BPr b1 b2) = (fv_bp b1) \<union> (fv_bp b2)"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    40
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    41
(* needs to be stated by the package *)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    42
overloading
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    43
  perm_trm1 \<equiv> "perm :: 'x prm \<Rightarrow> trm1 \<Rightarrow> trm1"   (unchecked)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    44
  perm_bp \<equiv> "perm :: 'x prm \<Rightarrow> bp \<Rightarrow> bp" (unchecked)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    45
begin
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    46
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    47
primrec
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    48
  perm_trm1 and perm_bp
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    49
where
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    50
  "perm_trm1 pi (Vr1 a) = Vr1 (pi \<bullet> a)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    51
| "perm_trm1 pi (Ap1 t1 t2) = Ap1 (perm_trm1 pi t1) (perm_trm1 pi t2)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    52
| "perm_trm1 pi (Lm1 a t) = Lm1 (pi \<bullet> a) (perm_trm1 pi t)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    53
| "perm_trm1 pi (Lt1 bp t1 t2) = Lt1 (perm_bp pi bp) (perm_trm1 pi t1) (perm_trm1 pi t2)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    54
| "perm_bp pi (BUnit) = BUnit"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    55
| "perm_bp pi (BVr a) = BVr (pi \<bullet> a)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    56
| "perm_bp pi (BPr bp1 bp2) = BPr (perm_bp pi bp1) (perm_bp pi bp2)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    57
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    58
end
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    59
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    60
inductive
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    61
  alpha1 :: "trm1 \<Rightarrow> trm1 \<Rightarrow> bool" ("_ \<approx>1 _" [100, 100] 100)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    62
where
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    63
  a1: "a = b \<Longrightarrow> (Vr1 a) \<approx>1 (Vr1 b)"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    64
| a2: "\<lbrakk>t1 \<approx>1 t2; s1 \<approx>1 s2\<rbrakk> \<Longrightarrow> Ap1 t1 s1 \<approx>1 Ap1 t2 s2"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    65
| a3: "\<exists>pi::name prm. (fv_trm1 t - {a} = fv_trm1 s - {b} \<and> (fv_trm1 t - {a})\<sharp>* pi \<and> (pi \<bullet> t) \<approx>1 s \<and> (pi \<bullet> a) = b)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    66
       \<Longrightarrow> Lm1 a t \<approx>1 Lm1 b s"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    67
| a4: "\<exists>pi::name prm.(
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    68
         t1 \<approx>1 t2 \<and>
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    69
         (fv_trm1 s1 - fv_bp b1 = fv_trm1 s2 - fv_bp b2) \<and>
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    70
         (fv_trm1 s1 - fv_bp b1) \<sharp>* pi \<and>
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    71
         (pi \<bullet> s1 = s2)                    (* Optional: \<and> (pi \<bullet> b1 = b2) *)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    72
       ) \<Longrightarrow> Lt1 b1 t1 s1 \<approx>1 Lt1 b2 t2 s2"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    73
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    74
lemma alpha1_equivp: "equivp alpha1" sorry
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    75
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    76
quotient_type qtrm1 = trm1 / alpha1
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    77
  by (rule alpha1_equivp)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    78
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    79
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    80
section {*** lets with single assignments ***}
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    81
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
datatype trm2 =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
  Vr2 "name"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
| Ap2 "trm2" "trm2"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
| Lm2 "name" "trm2"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
| Lt2 "assign" "trm2"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
and assign =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
  As "name" "trm2"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    90
(* to be given by the user *)
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    91
primrec 
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    92
  bv2
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    93
where
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    94
  "bv2 (As x t) = {x}"
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    96
(* needs to be calculated by the package *)
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    97
primrec
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    98
  fv_trm2 and fv_assign
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    99
where
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   100
  "fv_trm2 (Vr2 x) = {x}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   101
| "fv_trm2 (Ap2 t1 t2) = (fv_trm2 t1) \<union> (fv_trm2 t2)"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   102
| "fv_trm2 (Lm2 x t) = (fv_trm2 t) - {x}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   103
| "fv_trm2 (Lt2 as t) = (fv_trm2 t - bv2 as) \<union> (fv_assign as)"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   104
| "fv_assign (As x t) = (fv_trm2 t)"
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   105
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   106
(* needs to be stated by the package *)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   107
overloading
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   108
  perm_trm2 \<equiv> "perm :: 'x prm \<Rightarrow> trm2 \<Rightarrow> trm2"   (unchecked)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   109
  perm_assign \<equiv> "perm :: 'x prm \<Rightarrow> assign \<Rightarrow> assign" (unchecked)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   110
begin
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   111
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   112
primrec
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   113
  perm_trm2 and perm_assign
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   114
where
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   115
  "perm_trm2 pi (Vr2 a) = Vr2 (pi \<bullet> a)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   116
| "perm_trm2 pi (Ap2 t1 t2) = Ap2 (perm_trm2 pi t1) (perm_trm2 pi t2)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   117
| "perm_trm2 pi (Lm2 a t) = Lm2 (pi \<bullet> a) (perm_trm2 pi t)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   118
| "perm_trm2 pi (Lt2 as t) = Lt2 (perm_assign pi as) (perm_trm2 pi t)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   119
| "perm_assign pi (As a t) = As (pi \<bullet> a) (perm_trm2 pi t)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   120
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   121
end
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   122
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   123
inductive
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   124
  alpha2 :: "trm2 \<Rightarrow> trm2 \<Rightarrow> bool" ("_ \<approx>2 _" [100, 100] 100)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   125
where
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   126
  a1: "a = b \<Longrightarrow> (Vr2 a) \<approx>2 (Vr2 b)"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   127
| a2: "\<lbrakk>t1 \<approx>2 t2; s1 \<approx>2 s2\<rbrakk> \<Longrightarrow> Ap2 t1 s1 \<approx>2 Ap2 t2 s2"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   128
| a3: "\<exists>pi::name prm. (fv_trm2 t - {a} = fv_trm2 s - {b} \<and> (fv_trm2 t - {a})\<sharp>* pi \<and> (pi \<bullet> t) \<approx>2 s \<and> (pi \<bullet> a) = b)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   129
       \<Longrightarrow> Lm2 a t \<approx>2 Lm2 b s"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   130
| a4: "\<exists>pi::name prm. (
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   131
         fv_trm2 t1 - fv_assign b1 = fv_trm2 t2 - fv_assign b2 \<and>
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   132
         (fv_trm2 t1 - fv_assign b1) \<sharp>* pi \<and>
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   133
         pi \<bullet> t1 = t2       (* \<and> (pi \<bullet> b1 = b2) *)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   134
       ) \<Longrightarrow> Lt2 b1 t1 \<approx>2 Lt2 b2 t2"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   135
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   136
lemma alpha2_equivp: "equivp alpha2" sorry
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   137
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   138
quotient_type qtrm2 = trm2 / alpha2
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   139
  by (rule alpha2_equivp)
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   140
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   141
section {*** lets with many assignments ***}
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   142
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
datatype trm3 =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
  Vr3 "name"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
| Ap3 "trm3" "trm3"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
| Lm3 "name" "trm3"
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   147
| Lt3 "assigns" "trm3"
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
and assigns =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
  ANil
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
| ACons "name" "trm3" "assigns"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   152
(* to be given by the user *)
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   153
primrec 
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   154
  bv3
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   155
where
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   156
  "bv3 ANil = {}"
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   157
| "bv3 (ACons x t as) = {x} \<union> (bv3 as)"
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   158
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   159
primrec
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   160
  fv_trm3 and fv_assigns
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   161
where
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   162
  "fv_trm3 (Vr3 x) = {x}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   163
| "fv_trm3 (Ap3 t1 t2) = (fv_trm3 t1) \<union> (fv_trm3 t2)"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   164
| "fv_trm3 (Lm3 x t) = (fv_trm3 t) - {x}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   165
| "fv_trm3 (Lt3 as t) = (fv_trm3 t - bv3 as) \<union> (fv_assigns as)"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   166
| "fv_assigns (ANil) = {}"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   167
| "fv_assigns (ACons x t as) = (fv_trm3 t) \<union> (fv_assigns as)"
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   168
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   169
(* needs to be stated by the package *)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   170
overloading
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   171
  perm_trm3 \<equiv> "perm :: 'x prm \<Rightarrow> trm3 \<Rightarrow> trm3"   (unchecked)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   172
  perm_assigns \<equiv> "perm :: 'x prm \<Rightarrow> assigns \<Rightarrow> assigns" (unchecked)
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   173
begin
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   174
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   175
primrec
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   176
  perm_trm3 and perm_assigns
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   177
where
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   178
  "perm_trm3 pi (Vr3 a) = Vr3 (pi \<bullet> a)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   179
| "perm_trm3 pi (Ap3 t1 t2) = Ap3 (perm_trm3 pi t1) (perm_trm3 pi t2)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   180
| "perm_trm3 pi (Lm3 a t) = Lm3 (pi \<bullet> a) (perm_trm3 pi t)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   181
| "perm_trm3 pi (Lt3 as t) = Lt3 (perm_assigns pi as) (perm_trm3 pi t)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   182
| "perm_assigns pi (ANil) = ANil"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   183
| "perm_assigns pi (ACons a t as) = ACons (pi \<bullet> a) (perm_trm3 pi t) (perm_assigns pi as)"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   184
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   185
end
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   186
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   187
inductive
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   188
  alpha3 :: "trm3 \<Rightarrow> trm3 \<Rightarrow> bool" ("_ \<approx>3 _" [100, 100] 100)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   189
where
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   190
  a1: "a = b \<Longrightarrow> (Vr3 a) \<approx>3 (Vr3 b)"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   191
| a2: "\<lbrakk>t1 \<approx>3 t2; s1 \<approx>3 s2\<rbrakk> \<Longrightarrow> Ap3 t1 s1 \<approx>3 Ap3 t2 s2"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   192
| a3: "\<exists>pi::name prm. (fv_trm3 t - {a} = fv_trm3 s - {b} \<and> (fv_trm3 t - {a})\<sharp>* pi \<and> (pi \<bullet> t) \<approx>3 s \<and> (pi \<bullet> a) = b)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   193
       \<Longrightarrow> Lm3 a t \<approx>3 Lm3 b s"
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   194
| a4: "\<exists>pi::name prm. (
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   195
         fv_trm3 t1 - fv_assigns b1 = fv_trm3 t2 - fv_assigns b2 \<and>
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   196
         (fv_trm3 t1 - fv_assigns b1) \<sharp>* pi \<and>
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   197
         pi \<bullet> t1 = t2      (* \<and> (pi \<bullet> b1 = b2)  *)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   198
       ) \<Longrightarrow> Lt3 b1 t1 \<approx>3 Lt3 b2 t2"
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   199
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   200
lemma alpha3_equivp: "equivp alpha3" sorry
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   201
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   202
quotient_type qtrm3 = trm3 / alpha3
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   203
  by (rule alpha3_equivp)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   204
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   205
end