Quot/Examples/Terms.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 27 Jan 2010 07:45:01 +0100
changeset 949 aa0c572a0718
parent 947 fa810f01f7b5
child 1128 17ca92ab4660
permissions -rw-r--r--
added another example with indirect recursion over lists
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"
947
fa810f01f7b5 added an LamEx example together with the new nominal infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 917
diff changeset
    65
| a3: "\<exists>pi::name prm. (fv_trm1 t - {a} = fv_trm1 s - {b} \<and> 
fa810f01f7b5 added an LamEx example together with the new nominal infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 917
diff changeset
    66
                      (fv_trm1 t - {a})\<sharp>* pi \<and> 
fa810f01f7b5 added an LamEx example together with the new nominal infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 917
diff changeset
    67
                      (pi \<bullet> t) \<approx>1 s \<and> (pi \<bullet> a) = b)
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    68
       \<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
    69
| a4: "\<exists>pi::name prm.(
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    70
         t1 \<approx>1 t2 \<and>
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    71
         (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
    72
         (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
    73
         (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
    74
       ) \<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
    75
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    76
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
    77
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    78
quotient_type qtrm1 = trm1 / alpha1
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    79
  by (rule alpha1_equivp)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
    80
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    81
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    82
section {*** lets with single assignments ***}
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
    83
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
datatype trm2 =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
  Vr2 "name"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
| Ap2 "trm2" "trm2"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
| Lm2 "name" "trm2"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
| Lt2 "assign" "trm2"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
and assign =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
  As "name" "trm2"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    92
(* 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
    93
primrec 
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    94
  bv2
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    95
where
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
    96
  "bv2 (As x t) = {x}"
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
    98
(* 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
    99
primrec
892
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 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
   101
where
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 (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
   103
| "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
   104
| "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
   105
| "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
   106
| "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
   107
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   108
(* 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
   109
overloading
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   110
  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
   111
  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
   112
begin
892
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   113
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   114
primrec
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   115
  perm_trm2 and perm_assign
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   116
where
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   117
  "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
   118
| "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
   119
| "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
   120
| "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
   121
| "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
   122
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   123
end
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   124
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   125
inductive
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   126
  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
   127
where
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   128
  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
   129
| a2: "\<lbrakk>t1 \<approx>2 t2; s1 \<approx>2 s2\<rbrakk> \<Longrightarrow> Ap2 t1 s1 \<approx>2 Ap2 t2 s2"
947
fa810f01f7b5 added an LamEx example together with the new nominal infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 917
diff changeset
   130
| a3: "\<exists>pi::name prm. (fv_trm2 t - {a} = fv_trm2 s - {b} \<and> 
fa810f01f7b5 added an LamEx example together with the new nominal infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 917
diff changeset
   131
                      (fv_trm2 t - {a})\<sharp>* pi \<and> 
fa810f01f7b5 added an LamEx example together with the new nominal infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 917
diff changeset
   132
                      (pi \<bullet> t) \<approx>2 s \<and> 
fa810f01f7b5 added an LamEx example together with the new nominal infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 917
diff changeset
   133
                      (pi \<bullet> a) = b)
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   134
       \<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
   135
| a4: "\<exists>pi::name prm. (
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   136
         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
   137
         (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
   138
         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
   139
       ) \<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
   140
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   141
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
   142
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   143
quotient_type qtrm2 = trm2 / alpha2
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   144
  by (rule alpha2_equivp)
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   145
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   146
section {*** lets with many assignments ***}
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   147
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
datatype trm3 =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
  Vr3 "name"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
| Ap3 "trm3" "trm3"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
| 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
   152
| Lt3 "assigns" "trm3"
872
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
and assigns =
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
  ANil
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
| ACons "name" "trm3" "assigns"
2605ea41bbdd added 3 calculi with interesting binding structure
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   157
(* 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
   158
primrec 
874
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   159
  bv3
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   160
where
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   161
  "bv3 ANil = {}"
ab8a58973861 added bound-variable functions to terms
Christian Urban <urbanc@in.tum.de>
parents: 872
diff changeset
   162
| "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
   163
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   164
primrec
892
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 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
   166
where
693aecde755d added free_variable function (do not know about the algorithm yet)
Christian Urban <urbanc@in.tum.de>
parents: 874
diff changeset
   167
  "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
   168
| "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
   169
| "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
   170
| "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
   171
| "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
   172
| "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
   173
899
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   174
(* 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
   175
overloading
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   176
  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
   177
  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
   178
begin
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   179
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   180
primrec
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   181
  perm_trm3 and perm_assigns
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   182
where
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   183
  "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
   184
| "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
   185
| "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
   186
| "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
   187
| "perm_assigns pi (ANil) = ANil"
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   188
| "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
   189
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   190
end
2468c0f2b276 added permutation functions for the raw calculi
Christian Urban <urbanc@in.tum.de>
parents: 892
diff changeset
   191
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   192
inductive
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   193
  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
   194
where
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   195
  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
   196
| a2: "\<lbrakk>t1 \<approx>3 t2; s1 \<approx>3 s2\<rbrakk> \<Longrightarrow> Ap3 t1 s1 \<approx>3 Ap3 t2 s2"
949
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   197
| a3: "\<exists>pi::name prm. (fv_trm3 t - {a} = fv_trm3 s - {b} \<and> 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   198
                      (fv_trm3 t - {a})\<sharp>* pi \<and> 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   199
                      (pi \<bullet> t) \<approx>3 s \<and> 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   200
                      (pi \<bullet> a) = b)
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   201
       \<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
   202
| a4: "\<exists>pi::name prm. (
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   203
         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
   204
         (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
   205
         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
   206
       ) \<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
   207
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   208
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
   209
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   210
quotient_type qtrm3 = trm3 / alpha3
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   211
  by (rule alpha3_equivp)
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   212
949
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   213
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   214
section {*** lam with indirect list recursion ***}
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   215
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   216
datatype trm4 =
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   217
  Vr4 "name"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   218
| Ap4 "trm4" "trm4 list"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   219
| Lm4 "name" "trm4"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   220
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   221
thm trm4.recs
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   222
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   223
primrec
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   224
  fv_trm4 and fv_trm4_list
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   225
where
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   226
  "fv_trm4 (Vr4 x) = {x}"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   227
| "fv_trm4 (Ap4 t ts) = (fv_trm4 t) \<union> (fv_trm4_list ts)"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   228
| "fv_trm4 (Lm4 x t) = (fv_trm4 t) - {x}"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   229
| "fv_trm4_list ([]) = {}"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   230
| "fv_trm4_list (t#ts) = (fv_trm4 t) \<union> (fv_trm4_list ts)"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   231
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   232
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   233
(* needs to be stated by the package *)
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   234
(* there cannot be a clause for lists, as *) 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   235
(* permutations are  already defined in Nominal (also functions, options, and so on) *)
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   236
overloading
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   237
  perm_trm4 \<equiv> "perm :: 'x prm \<Rightarrow> trm4 \<Rightarrow> trm4"   (unchecked)
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   238
begin
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   239
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   240
primrec
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   241
  perm_trm4 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   242
where
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   243
  "perm_trm4 pi (Vr4 a) = Vr4 (pi \<bullet> a)"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   244
| "perm_trm4 pi (Ap4 t ts) = Ap4 (perm_trm4 pi t) (pi \<bullet> ts)"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   245
| "perm_trm4 pi (Lm4 a t) = Lm4 (pi \<bullet> a) (perm_trm4 pi t)"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   246
917
2cb5745f403e The alpha equivalence relations for structures in 'Terms'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 899
diff changeset
   247
end
949
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   248
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   249
inductive
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   250
    alpha4 :: "trm4 \<Rightarrow> trm4 \<Rightarrow> bool" ("_ \<approx>4 _" [100, 100] 100)
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   251
and alpha4list :: "trm4 list \<Rightarrow> trm4 list \<Rightarrow> bool" ("_ \<approx>4list _" [100, 100] 100) 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   252
where
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   253
  a1: "a = b \<Longrightarrow> (Vr4 a) \<approx>4 (Vr4 b)"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   254
| a2: "\<lbrakk>t1 \<approx>4 t2; s1 \<approx>4list s2\<rbrakk> \<Longrightarrow> Ap4 t1 s1 \<approx>4 Ap4 t2 s2"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   255
| a4: "\<exists>pi::name prm. (fv_trm4 t - {a} = fv_trm4 s - {b} \<and> 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   256
                      (fv_trm4 t - {a})\<sharp>* pi \<and> 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   257
                      (pi \<bullet> t) \<approx>4 s \<and> 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   258
                      (pi \<bullet> a) = b)
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   259
       \<Longrightarrow> Lm4 a t \<approx>4 Lm4 b s"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   260
| a5: "[] \<approx>4list []"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   261
| a6: "\<lbrakk>t \<approx>4 s; ts \<approx>4list ss\<rbrakk> \<Longrightarrow> (t#ts) \<approx>4list (s#ss)"
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   262
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   263
lemma alpha4_equivp: "equivp alpha4" sorry
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   264
lemma alpha4list_equivp: "equivp alpha4list" sorry
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   265
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   266
quotient_type 
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   267
  qtrm4 = trm4 / alpha4 and
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   268
  qtrm4list = "trm4 list" / alpha4list
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   269
  by (simp_all add: alpha4_equivp alpha4list_equivp)
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   270
aa0c572a0718 added another example with indirect recursion over lists
Christian Urban <urbanc@in.tum.de>
parents: 947
diff changeset
   271
end