src/CTT/ex/Equality.thy
author wenzelm
Wed, 17 May 2017 13:47:19 +0200
changeset 65851 c103358a5559
parent 61391 2332d9be352b
child 69593 3dda49e08b9d
permissions -rw-r--r--
tuned signature;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
     1
(*  Title:      CTT/ex/Equality.thy
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
     3
    Copyright   1991  University of Cambridge
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
     4
*)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
     5
58889
5b7a9633cfa8 modernized header uniformly as section;
wenzelm
parents: 35762
diff changeset
     6
section "Equality reasoning by rewriting"
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
     7
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
     8
theory Equality
58974
cbc2ac19d783 simplifie sessions;
wenzelm
parents: 58972
diff changeset
     9
imports "../CTT"
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    10
begin
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    11
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58974
diff changeset
    12
lemma split_eq: "p : Sum(A,B) \<Longrightarrow> split(p,pair) = p : Sum(A,B)"
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    13
apply (rule EqE)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    14
apply (rule elim_rls, assumption)
58972
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    15
apply rew
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    16
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    17
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58974
diff changeset
    18
lemma when_eq: "\<lbrakk>A type; B type; p : A+B\<rbrakk> \<Longrightarrow> when(p,inl,inr) = p : A + B"
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    19
apply (rule EqE)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    20
apply (rule elim_rls, assumption)
58972
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    21
apply rew
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    22
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    23
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    24
(*in the "rec" formulation of addition, 0+n=n *)
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58974
diff changeset
    25
lemma "p:N \<Longrightarrow> rec(p,0, \<lambda>y z. succ(y)) = p : N"
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    26
apply (rule EqE)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    27
apply (rule elim_rls, assumption)
58972
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    28
apply rew
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    29
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    30
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    31
(*the harder version, n+0=n: recursive, uses induction hypothesis*)
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58974
diff changeset
    32
lemma "p:N \<Longrightarrow> rec(p,0, \<lambda>y z. succ(z)) = p : N"
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    33
apply (rule EqE)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    34
apply (rule elim_rls, assumption)
58972
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    35
apply hyp_rew
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    36
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    37
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    38
(*Associativity of addition*)
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58974
diff changeset
    39
lemma "\<lbrakk>a:N; b:N; c:N\<rbrakk>
9576b510f6a2 more symbols;
wenzelm
parents: 58974
diff changeset
    40
  \<Longrightarrow> rec(rec(a, b, \<lambda>x y. succ(y)), c, \<lambda>x y. succ(y)) =
9576b510f6a2 more symbols;
wenzelm
parents: 58974
diff changeset
    41
    rec(a, rec(b, c, \<lambda>x y. succ(y)), \<lambda>x y. succ(y)) : N"
58972
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    42
apply (NE a)
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    43
apply hyp_rew
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    44
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    45
61391
2332d9be352b tuned syntax -- more symbols;
wenzelm
parents: 60770
diff changeset
    46
(*Martin-Löf (1984) page 62: pairing is surjective*)
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58974
diff changeset
    47
lemma "p : Sum(A,B) \<Longrightarrow> <split(p,\<lambda>x y. x), split(p,\<lambda>x y. y)> = p : Sum(A,B)"
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    48
apply (rule EqE)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    49
apply (rule elim_rls, assumption)
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58977
diff changeset
    50
apply (tactic \<open>DEPTH_SOLVE_1 (rew_tac @{context} [])\<close>) (*!!!!!!!*)
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    51
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    52
61391
2332d9be352b tuned syntax -- more symbols;
wenzelm
parents: 60770
diff changeset
    53
lemma "\<lbrakk>a : A; b : B\<rbrakk> \<Longrightarrow> (\<^bold>\<lambda>u. split(u, \<lambda>v w.<w,v>)) ` <a,b> = <b,a> : \<Sum>x:B. A"
58972
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    54
apply rew
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    55
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    56
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    57
(*a contrived, complicated simplication, requires sum-elimination also*)
61391
2332d9be352b tuned syntax -- more symbols;
wenzelm
parents: 60770
diff changeset
    58
lemma "(\<^bold>\<lambda>f. \<^bold>\<lambda>x. f`(f`x)) ` (\<^bold>\<lambda>u. split(u, \<lambda>v w.<w,v>)) =
2332d9be352b tuned syntax -- more symbols;
wenzelm
parents: 60770
diff changeset
    59
      \<^bold>\<lambda>x. x  :  \<Prod>x:(\<Sum>y:N. N). (\<Sum>y:N. N)"
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    60
apply (rule reduction_rls)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    61
apply (rule_tac [3] intrL_rls)
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    62
apply (rule_tac [4] EqE)
58972
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    63
apply (erule_tac [4] SumE)
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    64
(*order of unifiers is essential here*)
58972
5b026cfc5f04 more Isar proof methods;
wenzelm
parents: 58963
diff changeset
    65
apply rew
19761
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    66
done
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    67
5cd82054c2c6 removed obsolete ML files;
wenzelm
parents:
diff changeset
    68
end