Unification/Swap.thy
author Christian Urban <urbanc@in.tum.de>
Sun, 29 Apr 2012 11:29:56 +0100
changeset 107 5c816239deaa
permissions -rw-r--r--
added Unification subdirectory
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
107
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
theory Swap = Main:
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
consts 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
  swapa   :: "(string \<times> string) \<Rightarrow> string \<Rightarrow> string"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
  swapas  :: "(string \<times> string)list \<Rightarrow> string \<Rightarrow> string"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
primrec
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  "swapa (b,c) a = (if b = a then c else (if c = a then b else a))"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
primrec
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  "swapas []     a = a"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
  "swapas (x#pi) a = swapa x (swapas pi a)"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
lemma [simp]: 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
  "swapas [(a,a)] b=b"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
apply(auto)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
done
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
lemma swapas_append: 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  "swapas (pi1@pi2) a = swapas pi1 (swapas pi2 a)"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
apply(induct_tac pi1, auto)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
done 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
lemma [simp]: 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  "swapas (rev pi) (swapas pi a) = a"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
apply(induct_tac pi)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
apply(simp_all add: swapas_append, auto)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
done
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
lemma swapas_rev_pi_a: 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
  "swapas pi a = b \<Longrightarrow> swapas (rev pi) b = a"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
apply(auto)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
done
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
lemma [simp]: 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
  "swapas pi (swapas (rev pi) a) = a"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
apply(rule swapas_rev_pi_a[of "(rev pi)" _ _,simplified])
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
apply(simp)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
done
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
lemma swapas_rev_pi_b: 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  "swapas (rev pi) a = b \<Longrightarrow> swapas pi b = a"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
apply(auto)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
done
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
lemma swapas_comm: 
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
  "(swapas (pi@[(a,b)]) c) = (swapas ([(swapas pi a,swapas pi b)]@pi) c)"
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
apply(auto)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
apply(simp_all only: swapas_append)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
apply(auto)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
apply(drule swapas_rev_pi_a, simp)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
apply(drule swapas_rev_pi_a, simp)
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
done
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
5c816239deaa added Unification subdirectory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
end