QuotMain.thy
author Christian Urban <urbanc@in.tum.de>
Tue, 20 Oct 2009 09:31:34 +0200
changeset 133 5cdb383cef9c
parent 132 a045d9021c61
child 134 72d003e82349
permissions -rw-r--r--
tuned and fixed the earlier fix
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory QuotMain
6
6a1b4c22a386 added the prove command
Christian Urban <urbanc@in.tum.de>
parents: 5
diff changeset
     2
imports QuotScript QuotList Prove
71
35be65791f1d exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents: 70
diff changeset
     3
uses ("quotient.ML")
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
begin
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
127
b054cf6bd179 the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents: 126
diff changeset
     6
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
locale QUOT_TYPE =
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
  and   Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  and   Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  assumes equiv: "EQUIV R"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
  and     rep_prop: "\<And>y. \<exists>x. Rep y = R x"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  and     rep_inverse: "\<And>x. Abs (Rep x) = x"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  and     abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
  and     rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)"
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
    16
begin
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
definition
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
  "ABS x \<equiv> Abs (R x)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
definition
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  "REP a = Eps (Rep a)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
    24
lemma lem9:
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  shows "R (Eps (R x)) = R x"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
proof -
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  have a: "R x x" using equiv by (simp add: EQUIV_REFL_SYM_TRANS REFL_def)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
  then have "R x (Eps (R x))" by (rule someI)
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
    29
  then show "R (Eps (R x)) = R x"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
    using equiv unfolding EQUIV_def by simp
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
qed
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
theorem thm10:
24
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
    34
  shows "ABS (REP a) \<equiv> a"
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
    35
  apply  (rule eq_reflection)
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
    36
  unfolding ABS_def REP_def
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
proof -
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
    38
  from rep_prop
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
  obtain x where eq: "Rep a = R x" by auto
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
  also have "\<dots> = Abs (R x)" using lem9 by simp
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  also have "\<dots> = Abs (Rep a)" using eq by simp
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  also have "\<dots> = a" using rep_inverse by simp
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  finally
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  show "Abs (R (Eps (Rep a))) = a" by simp
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
qed
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
    48
lemma REP_refl:
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  shows "R (REP a) (REP a)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
unfolding REP_def
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
by (simp add: equiv[simplified EQUIV_def])
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
lemma lem7:
22
5023bf36d81a beautification of some proofs
Ning@localhost
parents: 21
diff changeset
    54
  shows "(R x = R y) = (Abs (R x) = Abs (R y))"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
apply(rule iffI)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
apply(simp)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
apply(drule rep_inject[THEN iffD2])
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
apply(simp add: abs_inverse)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
done
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
    60
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
theorem thm11:
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
  shows "R r r' = (ABS r = ABS r')"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
unfolding ABS_def
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
by (simp only: equiv[simplified EQUIV_def] lem7)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
4
Christian Urban <urbanc@in.tum.de>
parents: 3
diff changeset
    66
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
    67
lemma REP_ABS_rsp:
4
Christian Urban <urbanc@in.tum.de>
parents: 3
diff changeset
    68
  shows "R f (REP (ABS g)) = R f g"
Christian Urban <urbanc@in.tum.de>
parents: 3
diff changeset
    69
  and   "R (REP (ABS g)) f = R g f"
23
f6c6cf8c3b98 some more beautification
Ning@localhost
parents: 22
diff changeset
    70
by (simp_all add: thm10 thm11)
4
Christian Urban <urbanc@in.tum.de>
parents: 3
diff changeset
    71
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
lemma QUOTIENT:
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
  "QUOTIENT R ABS REP"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
apply(unfold QUOTIENT_def)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
apply(simp add: thm10)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
apply(simp add: REP_refl)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
apply(subst thm11[symmetric])
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
apply(simp add: equiv[simplified EQUIV_def])
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
done
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    81
lemma R_trans:
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
    82
  assumes ab: "R a b"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
    83
  and     bc: "R b c"
22
5023bf36d81a beautification of some proofs
Ning@localhost
parents: 21
diff changeset
    84
  shows "R a c"
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    85
proof -
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    86
  have tr: "TRANS R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    87
  moreover have ab: "R a b" by fact
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    88
  moreover have bc: "R b c" by fact
22
5023bf36d81a beautification of some proofs
Ning@localhost
parents: 21
diff changeset
    89
  ultimately show "R a c" unfolding TRANS_def by blast
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    90
qed
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    91
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    92
lemma R_sym:
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
    93
  assumes ab: "R a b"
22
5023bf36d81a beautification of some proofs
Ning@localhost
parents: 21
diff changeset
    94
  shows "R b a"
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    95
proof -
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    96
  have re: "SYM R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp
22
5023bf36d81a beautification of some proofs
Ning@localhost
parents: 21
diff changeset
    97
  then show "R b a" using ab unfolding SYM_def by blast
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    98
qed
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
    99
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   100
lemma R_trans2:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   101
  assumes ac: "R a c"
22
5023bf36d81a beautification of some proofs
Ning@localhost
parents: 21
diff changeset
   102
  and     bd: "R b d"
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   103
  shows "R a b = R c d"
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   104
proof
23
f6c6cf8c3b98 some more beautification
Ning@localhost
parents: 22
diff changeset
   105
  assume "R a b"
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   106
  then have "R b a" using R_sym by blast
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   107
  then have "R b c" using ac R_trans by blast
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   108
  then have "R c b" using R_sym by blast
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   109
  then show "R c d" using bd R_trans by blast
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   110
next
23
f6c6cf8c3b98 some more beautification
Ning@localhost
parents: 22
diff changeset
   111
  assume "R c d"
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   112
  then have "R a d" using ac R_trans by blast
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   113
  then have "R d a" using R_sym by blast
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   114
  then have "R b a" using bd R_trans by blast
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   115
  then show "R a b" using R_sym by blast
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   116
qed
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   117
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   118
lemma REPS_same:
25
9020ee23a020 The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 24
diff changeset
   119
  shows "R (REP a) (REP b) \<equiv> (a = b)"
38
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   120
proof -
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   121
  have "R (REP a) (REP b) = (a = b)"
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   122
  proof
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   123
    assume as: "R (REP a) (REP b)"
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   124
    from rep_prop
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   125
    obtain x y
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   126
      where eqs: "Rep a = R x" "Rep b = R y" by blast
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   127
    from eqs have "R (Eps (R x)) (Eps (R y))" using as unfolding REP_def by simp
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   128
    then have "R x (Eps (R y))" using lem9 by simp
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   129
    then have "R (Eps (R y)) x" using R_sym by blast
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   130
    then have "R y x" using lem9 by simp
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   131
    then have "R x y" using R_sym by blast
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   132
    then have "ABS x = ABS y" using thm11 by simp
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   133
    then have "Abs (Rep a) = Abs (Rep b)" using eqs unfolding ABS_def by simp
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   134
    then show "a = b" using rep_inverse by simp
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   135
  next
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   136
    assume ab: "a = b"
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   137
    have "REFL R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   138
    then show "R (REP a) (REP b)" unfolding REFL_def using ab by auto
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   139
  qed
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   140
  then show "R (REP a) (REP b) \<equiv> (a = b)" by simp
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   141
qed
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   142
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
end
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
127
b054cf6bd179 the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents: 126
diff changeset
   145
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
section {* type definition for the quotient type *}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
71
35be65791f1d exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents: 70
diff changeset
   148
use "quotient.ML"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
130
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   150
(* mapfuns for some standard types *)
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   151
setup {*
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   152
  maps_update @{type_name "list"} {mapfun = @{const_name "map"},      relfun = @{const_name "LIST_REL"}} #>
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   153
  maps_update @{type_name "*"}    {mapfun = @{const_name "prod_fun"}, relfun = @{const_name "prod_rel"}} #>
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   154
  maps_update @{type_name "fun"}  {mapfun = @{const_name "fun_map"},  relfun = @{const_name "FUN_REL"}}
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   155
*}
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   156
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   157
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   158
ML {* maps_lookup @{theory} @{type_name list} *}
79
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   159
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   160
ML {*
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   161
val no_vars = Thm.rule_attribute (fn context => fn th =>
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   162
  let
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   163
    val ctxt = Variable.set_body false (Context.proof_of context);
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   164
    val ((_, [th']), _) = Variable.import true [th] ctxt;
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   165
  in th' end);
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   166
*}
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   167
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
section {* various tests for quotient types*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
datatype trm =
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   170
  var  "nat"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
| app  "trm" "trm"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
| lam  "nat" "trm"
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   173
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   174
axiomatization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   175
  RR :: "trm \<Rightarrow> trm \<Rightarrow> bool"
26
68d64432623e slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 24
diff changeset
   176
where
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   177
  r_eq: "EQUIV RR"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
81
c8d58e2cda58 slightly modified the parser
Christian Urban <urbanc@in.tum.de>
parents: 80
diff changeset
   179
quotient qtrm = trm / "RR"
79
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   180
  apply(rule r_eq)
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   181
  done
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   182
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   183
typ qtrm
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
term Rep_qtrm
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   185
term REP_qtrm
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
term Abs_qtrm
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
term ABS_qtrm
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
thm QUOT_TYPE_qtrm
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
thm QUOTIENT_qtrm
79
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   190
thm REP_qtrm_def
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   191
16
06b158ee1545 Code cleanup
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 15
diff changeset
   192
(* Test interpretation *)
06b158ee1545 Code cleanup
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 15
diff changeset
   193
thm QUOT_TYPE_I_qtrm.thm11
26
68d64432623e slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 24
diff changeset
   194
thm QUOT_TYPE.thm11
16
06b158ee1545 Code cleanup
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 15
diff changeset
   195
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   196
print_theorems
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   197
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
thm Rep_qtrm
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
text {* another test *}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
datatype 'a trm' =
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   202
  var'  "'a"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
| app'  "'a trm'" "'a trm'"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
| lam'  "'a" "'a trm'"
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   205
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
consts R' :: "'a trm' \<Rightarrow> 'a trm' \<Rightarrow> bool"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
axioms r_eq': "EQUIV R'"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
81
c8d58e2cda58 slightly modified the parser
Christian Urban <urbanc@in.tum.de>
parents: 80
diff changeset
   209
quotient qtrm' = "'a trm'" / "R'"
79
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   210
  apply(rule r_eq')
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   211
  done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   213
print_theorems
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   214
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
term ABS_qtrm'
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
term REP_qtrm'
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
thm QUOT_TYPE_qtrm'
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   218
thm QUOTIENT_qtrm'
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   219
thm Rep_qtrm'
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   220
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   221
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
text {* a test with lists of terms *}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
datatype t =
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   224
  vr "string"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   225
| ap "t list"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
| lm "string" "t"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   227
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
consts Rt :: "t \<Rightarrow> t \<Rightarrow> bool"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   229
axioms t_eq: "EQUIV Rt"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   230
81
c8d58e2cda58 slightly modified the parser
Christian Urban <urbanc@in.tum.de>
parents: 80
diff changeset
   231
quotient qt = "t" / "Rt"
79
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   232
  by (rule t_eq)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   233
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   234
section {* lifting of constants *}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   236
ML {*
118
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   237
(* calculates the aggregate abs and rep functions for a given type; 
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   238
   repF is for constants' arguments; absF is for constants;
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   239
   function types need to be treated specially, since repF and absF
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   240
   change   
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   241
*)
46
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   242
datatype flag = absF | repF
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   243
109
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   244
fun negF absF = repF
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   245
  | negF repF = absF
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   246
46
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   247
fun get_fun flag rty qty lthy ty =
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   248
let
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   249
  val qty_name = Long_Name.base_name (fst (dest_Type qty))
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   250
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   251
  fun get_fun_aux s fs_tys =
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   252
  let
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
    val (fs, tys) = split_list fs_tys
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   254
    val (otys, ntys) = split_list tys
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   255
    val oty = Type (s, otys)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   256
    val nty = Type (s, ntys)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   257
    val ftys = map (op -->) tys
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   258
  in
130
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   259
   (case (maps_lookup (ProofContext.theory_of lthy) s) of
110
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   260
      SOME info => (list_comb (Const (#mapfun info, ftys ---> (oty --> nty)), fs), (oty, nty))
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   261
    | NONE      => raise ERROR ("no map association for type " ^ s))
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   262
  end
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   263
118
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   264
  fun get_fun_fun fs_tys =
110
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   265
  let
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   266
    val (fs, tys) = split_list fs_tys
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   267
    val ([oty1, oty2], [nty1, nty2]) = split_list tys
128
6ddb2f99be1d slight fix and tuning
Christian Urban <urbanc@in.tum.de>
parents: 127
diff changeset
   268
    val oty = nty1 --> oty2
6ddb2f99be1d slight fix and tuning
Christian Urban <urbanc@in.tum.de>
parents: 127
diff changeset
   269
    val nty = oty1 --> nty2
110
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   270
    val ftys = map (op -->) tys
f5f641c05794 A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 109
diff changeset
   271
  in
118
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   272
    (list_comb (Const (@{const_name "fun_map"}, ftys ---> oty --> nty), fs), (oty, nty))
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   273
  end
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   274
46
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   275
  fun get_const absF = (Const ("QuotMain.ABS_" ^ qty_name, rty --> qty), (rty, qty))
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   276
    | get_const repF = (Const ("QuotMain.REP_" ^ qty_name, qty --> rty), (qty, rty))
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   277
70
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   278
  fun mk_identity ty = Abs ("", ty, Bound 0)
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   279
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   280
in
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   281
  if ty = qty
46
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   282
  then (get_const flag)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   283
  else (case ty of
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   284
          TFree _ => (mk_identity ty, (ty, ty))
118
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   285
        | Type (_, []) => (mk_identity ty, (ty, ty)) 
109
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   286
        | Type ("fun" , [ty1, ty2]) => 
118
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   287
                 get_fun_fun [get_fun (negF flag) rty qty lthy ty1, get_fun flag rty qty lthy ty2]
46
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   288
        | Type (s, tys) => get_fun_aux s (map (get_fun flag rty qty lthy) tys)
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   289
        | _ => raise ERROR ("no type variables")
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   290
       )
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   291
end
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   292
*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   293
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   294
ML {*
118
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   295
  get_fun repF @{typ t} @{typ qt} @{context} @{typ "((((qt \<Rightarrow> qt) \<Rightarrow> qt) \<Rightarrow> qt) list) * nat"}
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   296
  |> fst
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   297
  |> Syntax.string_of_term @{context}
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   298
  |> writeln
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   299
*}
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   300
46
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   301
ML {*
109
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   302
  get_fun absF @{typ t} @{typ qt} @{context} @{typ "qt * nat"}
46
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   303
  |> fst
118
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   304
  |> Syntax.string_of_term @{context}
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   305
  |> writeln
109
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   306
*}
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   307
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   308
ML {*
118
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   309
  get_fun absF @{typ t} @{typ qt} @{context} @{typ "(qt \<Rightarrow> qt) \<Rightarrow> qt"}
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   310
  |> fst
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   311
  |> Syntax.pretty_term @{context}
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   312
  |> Pretty.string_of
1c30d48bfc15 slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents: 117
diff changeset
   313
  |> writeln
109
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   314
*}
386671ef36bd fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents: 108
diff changeset
   315
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   316
text {* produces the definition for a lifted constant *}
86
133af7260a12 Regularizing HOL all.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 85
diff changeset
   317
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   318
ML {*
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   319
fun get_const_def nconst oconst rty qty lthy =
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   320
let
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   321
  val ty = fastype_of nconst
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   322
  val (arg_tys, res_ty) = strip_type ty
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   323
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   324
  val fresh_args = arg_tys |> map (pair "x")
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   325
                           |> Variable.variant_frees lthy [nconst, oconst]
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   326
                           |> map Free
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   327
46
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   328
  val rep_fns = map (fst o get_fun repF rty qty lthy) arg_tys
e801b929216b some tuning of my code
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   329
  val abs_fn  = (fst o get_fun absF rty qty lthy) res_ty
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   330
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   331
in
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   332
  map (op $) (rep_fns ~~ fresh_args)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   333
  |> curry list_comb oconst
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   334
  |> curry (op $) abs_fn
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   335
  |> fold_rev lambda fresh_args
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   336
end
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   337
*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   338
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   339
ML {*
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   340
fun exchange_ty rty qty ty =
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   341
  if ty = rty
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   342
  then qty
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   343
  else
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   344
    (case ty of
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   345
       Type (s, tys) => Type (s, map (exchange_ty rty qty) tys)
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   346
      | _ => ty
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   347
    )
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   348
*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   349
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   350
ML {*
17
55b646c6c4cd More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 16
diff changeset
   351
fun make_const_def nconst_bname oconst mx rty qty lthy =
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   352
let
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   353
  val oconst_ty = fastype_of oconst
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   354
  val nconst_ty = exchange_ty rty qty oconst_ty
17
55b646c6c4cd More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 16
diff changeset
   355
  val nconst = Const (Binding.name_of nconst_bname, nconst_ty)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   356
  val def_trm = get_const_def nconst oconst rty qty lthy
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   357
in
79
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   358
  define (nconst_bname, mx, def_trm) lthy
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   359
end
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   360
*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   361
111
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   362
(* A test whether get_fun works properly
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   363
consts bla :: "(t \<Rightarrow> t) \<Rightarrow> t"
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   364
local_setup {*
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   365
  fn lthy => (Toplevel.program (fn () =>
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   366
    make_const_def @{binding bla'} @{term "bla"} NoSyn @{typ "t"} @{typ "qt"} lthy
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   367
  )) |> snd
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   368
*}
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   369
*)
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
   370
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   371
local_setup {*
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   372
  make_const_def @{binding VR} @{term "vr"} NoSyn @{typ "t"} @{typ "qt"} #> snd #>
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   373
  make_const_def @{binding AP} @{term "ap"} NoSyn @{typ "t"} @{typ "qt"} #> snd #>
17
55b646c6c4cd More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 16
diff changeset
   374
  make_const_def @{binding LM} @{term "lm"} NoSyn @{typ "t"} @{typ "qt"} #> snd
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   375
*}
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   376
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   377
term vr
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   378
term ap
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   379
term lm
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   380
thm VR_def AP_def LM_def
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   381
term LM
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   382
term VR
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   383
term AP
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   384
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   385
text {* a test with functions *}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   386
datatype 'a t' =
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   387
  vr' "string"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   388
| ap' "('a t') * ('a t')"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   389
| lm' "'a" "string \<Rightarrow> ('a t')"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   390
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   391
consts Rt' :: "('a t') \<Rightarrow> ('a t') \<Rightarrow> bool"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   392
axioms t_eq': "EQUIV Rt'"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   393
81
c8d58e2cda58 slightly modified the parser
Christian Urban <urbanc@in.tum.de>
parents: 80
diff changeset
   394
quotient qt' = "'a t'" / "Rt'"
79
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   395
  apply(rule t_eq')
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   396
  done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   397
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   398
print_theorems
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   399
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   400
local_setup {*
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   401
  make_const_def @{binding VR'} @{term "vr'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd #>
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   402
  make_const_def @{binding AP'} @{term "ap'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd #>
17
55b646c6c4cd More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 16
diff changeset
   403
  make_const_def @{binding LM'} @{term "lm'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   404
*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   405
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   406
term vr'
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   407
term ap'
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   408
term ap'
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   409
thm VR'_def AP'_def LM'_def
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   410
term LM'
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   411
term VR'
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   412
term AP'
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   413
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   414
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   415
text {* finite set example *}
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   416
print_syntax
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   417
inductive
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   418
  list_eq (infix "\<approx>" 50)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   419
where
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   420
  "a#b#xs \<approx> b#a#xs"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   421
| "[] \<approx> []"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   422
| "xs \<approx> ys \<Longrightarrow> ys \<approx> xs"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   423
| "a#a#xs \<approx> a#xs"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   424
| "xs \<approx> ys \<Longrightarrow> a#xs \<approx> a#ys"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   425
| "\<lbrakk>xs1 \<approx> xs2; xs2 \<approx> xs3\<rbrakk> \<Longrightarrow> xs1 \<approx> xs3"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   426
47
6a51704204e5 consistent state
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   427
lemma list_eq_refl:
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   428
  shows "xs \<approx> xs"
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   429
  apply (induct xs)
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   430
   apply (auto intro: list_eq.intros)
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   431
  done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   432
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   433
lemma equiv_list_eq:
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   434
  shows "EQUIV list_eq"
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   435
  unfolding EQUIV_REFL_SYM_TRANS REFL_def SYM_def TRANS_def
47
6a51704204e5 consistent state
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   436
  apply(auto intro: list_eq.intros list_eq_refl)
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   437
  done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   438
81
c8d58e2cda58 slightly modified the parser
Christian Urban <urbanc@in.tum.de>
parents: 80
diff changeset
   439
quotient fset = "'a list" / "list_eq"
79
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   440
  apply(rule equiv_list_eq)
c0c41fefeb06 added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents: 77
diff changeset
   441
  done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   442
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   443
print_theorems
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   444
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   445
typ "'a fset"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   446
thm "Rep_fset"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   447
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   448
local_setup {*
17
55b646c6c4cd More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 16
diff changeset
   449
  make_const_def @{binding EMPTY} @{term "[]"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   450
*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   451
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   452
term Nil
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   453
term EMPTY
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   454
thm EMPTY_def
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   455
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   456
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   457
local_setup {*
17
55b646c6c4cd More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 16
diff changeset
   458
  make_const_def @{binding INSERT} @{term "op #"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   459
*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   460
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   461
term Cons
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   462
term INSERT
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   463
thm INSERT_def
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   464
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   465
local_setup {*
17
55b646c6c4cd More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 16
diff changeset
   466
  make_const_def @{binding UNION} @{term "op @"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   467
*}
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   468
15
f46eddb570a3 Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 14
diff changeset
   469
term append
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   470
term UNION
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   471
thm UNION_def
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   472
7
3e77ad0abc6a - Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 6
diff changeset
   473
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   474
thm QUOTIENT_fset
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   475
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   476
thm QUOT_TYPE_I_fset.thm11
9
eac147a5eb33 Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 8
diff changeset
   477
eac147a5eb33 Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 8
diff changeset
   478
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   479
fun
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   480
  membship :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" (infix "memb" 100)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   481
where
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   482
  m1: "(x memb []) = False"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   483
| m2: "(x memb (y#xs)) = ((x=y) \<or> (x memb xs))"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   484
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   485
lemma mem_respects:
9
eac147a5eb33 Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 8
diff changeset
   486
  fixes z
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   487
  assumes a: "list_eq x y"
9
eac147a5eb33 Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 8
diff changeset
   488
  shows "(z memb x) = (z memb y)"
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   489
  using a by induct auto
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   490
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   491
29
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   492
fun
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   493
  card1 :: "'a list \<Rightarrow> nat"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   494
where
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   495
  card1_nil: "(card1 []) = 0"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   496
| card1_cons: "(card1 (x # xs)) = (if (x memb xs) then (card1 xs) else (Suc (card1 xs)))"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   497
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   498
local_setup {*
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   499
  make_const_def @{binding card} @{term "card1"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   500
*}
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   501
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   502
term card1
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   503
term card
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   504
thm card_def
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   505
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   506
(* text {*
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   507
 Maybe make_const_def should require a theorem that says that the particular lifted function
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   508
 respects the relation. With it such a definition would be impossible:
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   509
 make_const_def @{binding CARD} @{term "length"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd
41
72d63aa8af68 added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents: 40
diff changeset
   510
*}*)
29
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   511
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   512
lemma card1_rsp:
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   513
  fixes a b :: "'a list"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   514
  assumes e: "a \<approx> b"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   515
  shows "card1 a = card1 b"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   516
  using e apply induct
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   517
  apply (simp_all add:mem_respects)
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   518
  done
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   519
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   520
lemma card1_0:
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   521
  fixes a :: "'a list"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   522
  shows "(card1 a = 0) = (a = [])"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   523
  apply (induct a)
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   524
   apply (simp)
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   525
  apply (simp_all)
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   526
   apply meson
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   527
  apply (simp_all)
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   528
  done
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   529
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   530
lemma not_mem_card1:
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   531
  fixes x :: "'a"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   532
  fixes xs :: "'a list"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   533
  shows "~(x memb xs) \<Longrightarrow> card1 (x # xs) = Suc (card1 xs)"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   534
  by simp
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   535
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   536
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   537
lemma mem_cons:
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   538
  fixes x :: "'a"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   539
  fixes xs :: "'a list"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   540
  assumes a : "x memb xs"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   541
  shows "x # xs \<approx> xs"
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   542
  using a
38
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   543
  apply (induct xs)
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   544
  apply (auto intro: list_eq.intros)
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   545
  done
29
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   546
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   547
lemma card1_suc:
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   548
  fixes xs :: "'a list"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   549
  fixes n :: "nat"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   550
  assumes c: "card1 xs = Suc n"
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   551
  shows "\<exists>a ys. ~(a memb ys) \<and> xs \<approx> (a # ys)"
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   552
  using c
38
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   553
apply(induct xs)
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   554
apply (metis Suc_neq_Zero card1_0)
47
6a51704204e5 consistent state
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   555
apply (metis QUOT_TYPE_I_fset.R_trans QuotMain.card1_cons list_eq_refl mem_cons)
38
cac00e8b972b tuned slightly one proof
Christian Urban <urbanc@in.tum.de>
parents: 37
diff changeset
   556
done
29
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   557
97
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   558
primrec
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   559
  fold1
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   560
where
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   561
  "fold1 f (g :: 'a \<Rightarrow> 'b) (z :: 'b) [] = z"
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   562
| "fold1 f g z (a # A) =
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   563
     (if ((!u v. (f u v = f v u))
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   564
      \<and> (!u v w. ((f u (f v w) = f (f u v) w))))
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   565
     then (
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   566
       if (a memb A) then (fold1 f g z A) else (f (g a) (fold1 f g z A))
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   567
     ) else z)"
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   568
100
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   569
(* fold1_def is not usable, but: *)
97
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   570
thm fold1.simps
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   571
12
13b527da2157 More examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 11
diff changeset
   572
lemma cons_preserves:
13b527da2157 More examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 11
diff changeset
   573
  fixes z
13b527da2157 More examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 11
diff changeset
   574
  assumes a: "xs \<approx> ys"
13b527da2157 More examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 11
diff changeset
   575
  shows "(z # xs) \<approx> (z # ys)"
13
c13bb9e02eb7 Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 12
diff changeset
   576
  using a by (rule QuotMain.list_eq.intros(5))
12
13b527da2157 More examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 11
diff changeset
   577
60
4826ad24f772 First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 58
diff changeset
   578
lemma fs1_strong_cases:
4826ad24f772 First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 58
diff changeset
   579
  fixes X :: "'a list"
4826ad24f772 First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 58
diff changeset
   580
  shows "(X = []) \<or> (\<exists>a. \<exists> Y. (~(a memb Y) \<and> (X \<approx> a # Y)))"
4826ad24f772 First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 58
diff changeset
   581
  apply (induct X)
4826ad24f772 First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 58
diff changeset
   582
  apply (simp)
72
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
   583
  apply (metis QUOT_TYPE_I_fset.thm11 list_eq_refl mem_cons QuotMain.m1)
60
4826ad24f772 First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 58
diff changeset
   584
  done
29
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   585
10
b11b405b8271 Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 9
diff changeset
   586
local_setup {*
17
55b646c6c4cd More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 16
diff changeset
   587
  make_const_def @{binding IN} @{term "membship"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd
10
b11b405b8271 Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 9
diff changeset
   588
*}
b11b405b8271 Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 9
diff changeset
   589
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   590
term membship
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   591
term IN
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   592
thm IN_def
66
564bf4343f63 another improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
   593
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   594
lemmas a = QUOT_TYPE.ABS_def[OF QUOT_TYPE_fset]
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   595
thm QUOT_TYPE.thm11[OF QUOT_TYPE_fset, THEN iffD1, simplified a]
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   596
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   597
lemma yy:
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   598
  shows "(False = x memb []) = (False = IN (x::nat) EMPTY)"
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   599
unfolding IN_def EMPTY_def
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   600
apply(rule_tac f="(op =) False" in arg_cong)
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   601
apply(rule mem_respects)
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   602
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp)
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   603
apply(rule list_eq.intros)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   604
done
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   605
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   606
lemma
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   607
  shows "IN (x::nat) EMPTY = False"
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   608
using m1
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   609
apply -
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   610
apply(rule yy[THEN iffD1, symmetric])
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   611
apply(simp)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   612
done
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   613
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   614
lemma
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   615
  shows "((x=y) \<or> (IN x xs) = (IN (x::nat) (INSERT y xs))) =
23
f6c6cf8c3b98 some more beautification
Ning@localhost
parents: 22
diff changeset
   616
         ((x=y) \<or> x memb REP_fset xs = x memb (y # REP_fset xs))"
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   617
unfolding IN_def INSERT_def
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   618
apply(rule_tac f="(op \<or>) (x=y)" in arg_cong)
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   619
apply(rule_tac f="(op =) (x memb REP_fset xs)" in arg_cong)
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   620
apply(rule mem_respects)
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   621
apply(rule list_eq.intros(3))
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   622
apply(unfold REP_fset_def ABS_fset_def)
5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 4
diff changeset
   623
apply(simp only: QUOT_TYPE.REP_ABS_rsp[OF QUOT_TYPE_fset])
47
6a51704204e5 consistent state
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   624
apply(rule list_eq_refl)
2
Christian Urban <urbanc@in.tum.de>
parents: 1
diff changeset
   625
done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   626
7
3e77ad0abc6a - Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 6
diff changeset
   627
lemma append_respects_fst:
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   628
  assumes a : "list_eq l1 l2"
4
Christian Urban <urbanc@in.tum.de>
parents: 3
diff changeset
   629
  shows "list_eq (l1 @ s) (l2 @ s)"
3
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   630
  using a
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   631
  apply(induct)
4
Christian Urban <urbanc@in.tum.de>
parents: 3
diff changeset
   632
  apply(auto intro: list_eq.intros)
47
6a51704204e5 consistent state
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   633
  apply(simp add: list_eq_refl)
3
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   634
done
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   635
18
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
   636
lemma yyy:
3
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   637
  shows "
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   638
    (
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   639
     (UNION EMPTY s = s) &
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   640
     ((UNION (INSERT e s1) s2) = (INSERT e (UNION s1 s2)))
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   641
    ) = (
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   642
     ((ABS_fset ([] @ REP_fset s)) = s) &
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   643
     ((ABS_fset ((e # (REP_fset s1)) @ REP_fset s2)) = ABS_fset (e # (REP_fset s1 @ REP_fset s2)))
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   644
    )"
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   645
  unfolding UNION_def EMPTY_def INSERT_def
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   646
  apply(rule_tac f="(op &)" in arg_cong2)
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   647
  apply(rule_tac f="(op =)" in arg_cong2)
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   648
  apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric])
7
3e77ad0abc6a - Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 6
diff changeset
   649
  apply(rule append_respects_fst)
18
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
   650
  apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp)
47
6a51704204e5 consistent state
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   651
  apply(rule list_eq_refl)
3
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   652
  apply(simp)
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   653
  apply(rule_tac f="(op =)" in arg_cong2)
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   654
  apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric])
7
3e77ad0abc6a - Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 6
diff changeset
   655
  apply(rule append_respects_fst)
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   656
  apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp)
47
6a51704204e5 consistent state
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   657
  apply(rule list_eq_refl)
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   658
  apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric])
3
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   659
  apply(rule list_eq.intros(5))
14
5f6ee943c697 Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 13
diff changeset
   660
  apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp)
47
6a51704204e5 consistent state
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   661
  apply(rule list_eq_refl)
3
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   662
done
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   663
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   664
lemma
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   665
  shows "
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   666
     (UNION EMPTY s = s) &
7
3e77ad0abc6a - Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 6
diff changeset
   667
     ((UNION (INSERT e s1) s2) = (INSERT e (UNION s1 s2)))"
3e77ad0abc6a - Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 6
diff changeset
   668
  apply (simp add: yyy)
24
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
   669
  apply (simp add: QUOT_TYPE_I_fset.thm10)
7
3e77ad0abc6a - Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 6
diff changeset
   670
  done
3
672e14609e6e UNION - Append theorem
cek@localhost.localdomain
parents: 2
diff changeset
   671
8
54afbcf2a758 Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 7
diff changeset
   672
ML {*
55
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   673
  fun mk_rep x = @{term REP_fset} $ x;
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   674
  fun mk_abs x = @{term ABS_fset} $ x;
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   675
  val consts = [@{const_name "Nil"}, @{const_name "Cons"},
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   676
                @{const_name "membship"}, @{const_name "card1"},
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   677
                @{const_name "append"}, @{const_name "fold1"}];
8
54afbcf2a758 Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 7
diff changeset
   678
*}
54afbcf2a758 Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 7
diff changeset
   679
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   680
ML {* val tm = @{term "x :: 'a list"} *}
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   681
ML {* val ty = exchange_ty @{typ "'a list"} @{typ "'a fset"} (fastype_of tm) *}
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   682
ML {* (fst (get_fun repF @{typ "'a list"} @{typ "'a fset"} @{context} ty)) $ tm *}
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   683
56
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   684
ML {* val qty = @{typ "'a fset"} *}
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   685
ML {* val tt = Type ("fun", [Type ("fun", [qty, @{typ "prop"}]), @{typ "prop"}]) *}
58
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   686
ML {* val fall = Const(@{const_name all}, dummyT) *}
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   687
8
54afbcf2a758 Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 7
diff changeset
   688
ML {*
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   689
fun needs_lift (rty as Type (rty_s, _)) ty =
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   690
  case ty of
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   691
    Type (s, tys) =>
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   692
      (s = rty_s) orelse (exists (needs_lift rty) tys)
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   693
  | _ => false
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   694
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   695
*}
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   696
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   697
ML {*
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   698
fun build_goal_term lthy thm constructors rty qty =
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   699
  let
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   700
    fun mk_rep tm =
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   701
      let
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   702
        val ty = exchange_ty rty qty (fastype_of tm)
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   703
      in fst (get_fun repF rty qty lthy ty) $ tm end
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   704
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   705
    fun mk_abs tm =
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   706
      let
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   707
        val _ = tracing (Syntax.string_of_term @{context} tm)
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   708
        val _ = tracing (Syntax.string_of_typ @{context} (fastype_of tm))
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   709
        val ty = exchange_ty rty qty (fastype_of tm) in
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   710
      fst (get_fun absF rty qty lthy ty) $ tm end
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   711
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   712
    fun is_constructor (Const (x, _)) = member (op =) constructors x
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   713
      | is_constructor _ = false;
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   714
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   715
    fun build_aux lthy tm =
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   716
      case tm of
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   717
      Abs (a as (_, vty, _)) =>
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   718
      let
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   719
        val (vs, t) = Term.dest_abs a;
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   720
        val v = Free(vs, vty);
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   721
        val t' = lambda v (build_aux lthy t)
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   722
      in
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   723
      if (not (needs_lift rty (fastype_of tm))) then t'
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   724
      else mk_rep (mk_abs (
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   725
        if not (needs_lift rty vty) then t'
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   726
        else
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   727
          let
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   728
            val v' = mk_rep (mk_abs v);
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   729
            val t1 = Envir.beta_norm (t' $ v')
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   730
          in
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   731
            lambda v t1
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   732
          end
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   733
      ))
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   734
      end
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   735
    | x =>
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   736
      let
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   737
        val _ = tracing (">>" ^ Syntax.string_of_term @{context} tm)
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   738
        val (opp, tms0) = Term.strip_comb tm
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   739
        val tms = map (build_aux lthy) tms0
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   740
        val ty = fastype_of tm
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   741
      in
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   742
        if (((fst (Term.dest_Const opp)) = @{const_name Respects}) handle _ => false)
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   743
          then (list_comb (opp, (hd tms0) :: (tl tms)))
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   744
      else if (is_constructor opp andalso needs_lift rty ty) then
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   745
          mk_rep (mk_abs (list_comb (opp,tms)))
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   746
        else if ((Term.is_Free opp) andalso (length tms > 0) andalso (needs_lift rty ty)) then
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   747
            mk_rep(mk_abs(list_comb(opp,tms)))
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   748
        else if tms = [] then opp
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   749
        else list_comb(opp, tms)
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   750
      end
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   751
  in
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   752
    build_aux lthy (Thm.prop_of thm)
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   753
  end
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   754
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   755
*}
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   756
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   757
ML {*
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   758
fun build_goal_term_old ctxt thm constructors rty qty mk_rep mk_abs =
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   759
  let
55
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   760
    fun mk_rep_abs x = mk_rep (mk_abs x);
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   761
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   762
    fun is_constructor (Const (x, _)) = member (op =) constructors x
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   763
      | is_constructor _ = false;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   764
43
e51af8bace65 Cleaning the code with Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 42
diff changeset
   765
    fun maybe_mk_rep_abs t =
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   766
      let
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   767
        val _ = writeln ("Maybe: " ^ Syntax.string_of_term ctxt t)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   768
      in
55
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   769
        if fastype_of t = rty then mk_rep_abs t else t
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   770
      end;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   771
56
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   772
    fun is_all (Const ("all", Type("fun", [Type("fun", [ty, _]), _]))) = ty = rty
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   773
      | is_all _ = false;
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   774
58
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   775
    fun is_ex (Const ("Ex", Type("fun", [Type("fun", [ty, _]), _]))) = ty = rty
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   776
      | is_ex _ = false;
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   777
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   778
    fun build_aux ctxt1 tm =
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   779
      let
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   780
        val (head, args) = Term.strip_comb tm;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   781
        val args' = map (build_aux ctxt1) args;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   782
      in
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   783
        (case head of
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   784
          Abs (x, T, t) =>
55
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   785
            if T = rty then let
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   786
              val ([x'], ctxt2) = Variable.variant_fixes [x] ctxt1;
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   787
              val v = Free (x', qty);
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   788
              val t' = subst_bound (mk_rep v, t);
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   789
              val rec_term = build_aux ctxt2 t';
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   790
              val _ = tracing (Syntax.string_of_term ctxt2 t')
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   791
              val _ = tracing (Syntax.string_of_term ctxt2 (Term.lambda_name (x, v) rec_term))
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   792
            in
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   793
              Term.lambda_name (x, v) rec_term
b2ab3ba388a0 Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 54
diff changeset
   794
            end else let
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   795
              val ([x'], ctxt2) = Variable.variant_fixes [x] ctxt1;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   796
              val v = Free (x', T);
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   797
              val t' = subst_bound (v, t);
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   798
              val rec_term = build_aux ctxt2 t';
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   799
            in Term.lambda_name (x, v) rec_term end
58
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   800
        | _ =>  (* I assume that we never lift 'prop' since it is not of sort type *)
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   801
            if is_all head then
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   802
              list_comb (Const(@{const_name all}, dummyT), args') |> Syntax.check_term ctxt1
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   803
            else if is_ex head then
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   804
              list_comb (Const(@{const_name Ex}, dummyT), args') |> Syntax.check_term ctxt1
56
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   805
            else if is_constructor head then
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   806
              maybe_mk_rep_abs (list_comb (head, map maybe_mk_rep_abs args'))
56
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   807
            else
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   808
              maybe_mk_rep_abs (list_comb (head, args'))
ec5fbe7ab427 First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 55
diff changeset
   809
        )
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   810
      end;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   811
  in
58
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   812
    build_aux ctxt (Thm.prop_of thm)
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   813
  end
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   814
*}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   815
58
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   816
ML {*
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   817
fun build_goal ctxt thm cons rty qty =
114
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
   818
  Logic.mk_equals ((Thm.prop_of thm), (build_goal_term ctxt thm cons rty qty))
58
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   819
*}
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   820
67
221e926da073 tuned; nothing serious
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   821
ML {*
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   822
  val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm m2}))
67
221e926da073 tuned; nothing serious
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   823
*}
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   824
67
221e926da073 tuned; nothing serious
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   825
ML {*
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   826
cterm_of @{theory} (prop_of m1_novars);
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   827
cterm_of @{theory} (build_goal_term @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"});
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   828
cterm_of @{theory} (build_goal_term_old @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs)
67
221e926da073 tuned; nothing serious
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   829
*}
221e926da073 tuned; nothing serious
Christian Urban <urbanc@in.tum.de>
parents: 66
diff changeset
   830
58
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
   831
100
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   832
text {*
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   833
  Unabs_def converts a definition given as
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   834
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   835
    c \<equiv> %x. %y. f x y
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   836
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   837
  to a theorem of the form
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   838
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   839
    c x y \<equiv> f x y
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   840
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   841
  This function is needed to rewrite the right-hand
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   842
  side to the left-hand side.
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   843
*}
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   844
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   845
ML {*
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   846
fun unabs_def ctxt def =
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   847
let
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   848
  val (lhs, rhs) = Thm.dest_equals (cprop_of def)
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   849
  val xs = strip_abs_vars (term_of rhs)
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   850
  val (_, ctxt') = Variable.add_fixes (map fst xs) ctxt
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   851
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   852
  val thy = ProofContext.theory_of ctxt'
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   853
  val cxs = map (cterm_of thy o Free) xs
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   854
  val new_lhs = Drule.list_comb (lhs, cxs)
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   855
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   856
  fun get_conv [] = Conv.rewr_conv def
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   857
    | get_conv (x::xs) = Conv.fun_conv (get_conv xs)
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   858
in
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   859
  get_conv xs new_lhs |>
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   860
  singleton (ProofContext.export ctxt' ctxt)
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   861
end
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   862
*}
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   863
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   864
ML {* (* Test: *) @{thm IN_def}; unabs_def @{context} @{thm IN_def} *}
09f4d69f7b66 Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 99
diff changeset
   865
29
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
   866
ML {* val fset_defs = @{thms EMPTY_def IN_def UNION_def card_def INSERT_def} *}
68
e8660818c755 renamed unlam_def to unabs_def (matching the function abs_def in drule.ML)
Christian Urban <urbanc@in.tum.de>
parents: 67
diff changeset
   867
ML {* val fset_defs_sym = map (fn t => symmetric (unabs_def @{context} t)) fset_defs *}
18
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
   868
70
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   869
lemma atomize_eqv[atomize]: 
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   870
  shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" 
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   871
proof
70
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   872
  assume "A \<equiv> B" 
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   873
  then show "Trueprop A \<equiv> Trueprop B" by unfold
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   874
next
70
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   875
  assume *: "Trueprop A \<equiv> Trueprop B"
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   876
  have "A = B"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   877
  proof (cases A)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   878
    case True
70
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   879
    have "A" by fact
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   880
    then show "A = B" using * by simp
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   881
  next
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   882
    case False
70
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   883
    have "\<not>A" by fact
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   884
    then show "A = B" using * by auto
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   885
  qed
70
f3cbda066c3a consistent usage of rty (for the raw, unquotient type); tuned a bit the Isar
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   886
  then show "A \<equiv> B" by (rule eq_reflection)
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   887
qed
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   888
103
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   889
(* Has all the theorems about fset plugged in. These should be parameters to the tactic *)
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   890
ML {*
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   891
  fun transconv_fset_tac' ctxt =
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   892
    (LocalDefs.unfold_tac @{context} fset_defs) THEN
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   893
    ObjectLogic.full_atomize_tac 1 THEN
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   894
    REPEAT_ALL_NEW (FIRST' [
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   895
      rtac @{thm list_eq_refl},
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   896
      rtac @{thm cons_preserves},
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   897
      rtac @{thm mem_respects},
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   898
      rtac @{thm card1_rsp},
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   899
      rtac @{thm QUOT_TYPE_I_fset.R_trans2},
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   900
      CHANGED o (simp_tac ((Simplifier.context ctxt HOL_ss) addsimps @{thms QUOT_TYPE_I_fset.REP_ABS_rsp})),
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   901
      Cong_Tac.cong_tac @{thm cong},
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   902
      rtac @{thm ext}
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   903
    ]) 1
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   904
*}
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   905
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   906
ML {*
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   907
  val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm m1}))
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   908
  val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"}
103
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   909
  val cgoal = cterm_of @{theory} goal
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   910
  val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal)
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   911
*}
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   912
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   913
(*notation ( output) "prop" ("#_" [1000] 1000) *)
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   914
notation ( output) "Trueprop" ("#_" [1000] 1000)
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   915
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   916
30
e35198635d64 Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 29
diff changeset
   917
prove {* (Thm.term_of cgoal2) *}
103
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   918
  apply (tactic {* transconv_fset_tac' @{context} *})
30
e35198635d64 Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 29
diff changeset
   919
  done
18
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
   920
20
ccc220a23887 Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 19
diff changeset
   921
thm length_append (* Not true but worth checking that the goal is correct *)
ccc220a23887 Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 19
diff changeset
   922
ML {*
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   923
  val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm length_append}))
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   924
  val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"}
20
ccc220a23887 Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 19
diff changeset
   925
  val cgoal = cterm_of @{theory} goal
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   926
  val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal)
20
ccc220a23887 Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 19
diff changeset
   927
*}
30
e35198635d64 Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 29
diff changeset
   928
prove {* Thm.term_of cgoal2 *}
103
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   929
  apply (tactic {* transconv_fset_tac' @{context} *})
25
9020ee23a020 The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 24
diff changeset
   930
  sorry
19
55aefc2d524a The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 18
diff changeset
   931
20
ccc220a23887 Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 19
diff changeset
   932
thm m2
ccc220a23887 Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 19
diff changeset
   933
ML {*
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   934
  val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm m2}))
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   935
  val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"}
20
ccc220a23887 Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 19
diff changeset
   936
  val cgoal = cterm_of @{theory} goal
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   937
  val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal)
20
ccc220a23887 Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 19
diff changeset
   938
*}
30
e35198635d64 Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 29
diff changeset
   939
prove {* Thm.term_of cgoal2 *}
103
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   940
  apply (tactic {* transconv_fset_tac' @{context} *})
30
e35198635d64 Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 29
diff changeset
   941
  done
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   942
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   943
thm list_eq.intros(4)
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   944
ML {*
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   945
  val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm list_eq.intros(4)}))
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   946
  val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"}
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   947
  val cgoal = cterm_of @{theory} goal
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   948
  val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal)
24
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
   949
  val cgoal3 = Thm.rhs_of (MetaSimplifier.rewrite true @{thms QUOT_TYPE_I_fset.thm10} cgoal2)
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   950
*}
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   951
24
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
   952
(* It is the same, but we need a name for it. *)
52
6584b1ceedce Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 51
diff changeset
   953
prove zzz : {* Thm.term_of cgoal3 *}
103
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   954
  apply (tactic {* transconv_fset_tac' @{context} *})
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   955
  done
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   956
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   957
(*lemma zzz' :
24
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
   958
  "(REP_fset (INSERT a (INSERT a (ABS_fset xs))) \<approx> REP_fset (INSERT a (ABS_fset xs)))"
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
   959
  using list_eq.intros(4) by (simp only: zzz)
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
   960
6885fa184e89 Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 23
diff changeset
   961
thm QUOT_TYPE_I_fset.REPS_same
25
9020ee23a020 The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 24
diff changeset
   962
ML {* val zzz'' = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same} @{thm zzz'} *}
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   963
*)
25
9020ee23a020 The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 24
diff changeset
   964
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   965
thm list_eq.intros(5)
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   966
ML {*
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   967
  val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm list_eq.intros(5)}))
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
   968
  val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"}
103
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   969
  val cgoal = cterm_of @{theory} goal
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
   970
  val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite true fset_defs_sym cgoal)
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   971
*}
30
e35198635d64 Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 29
diff changeset
   972
prove {* Thm.term_of cgoal2 *}
103
4aef3882b436 Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   973
  apply (tactic {* transconv_fset_tac' @{context} *})
21
d15121412caa Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 20
diff changeset
   974
  done
18
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
   975
99
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   976
section {* handling quantifiers - regularize *}
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   977
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   978
text {* tyRel takes a type and builds a relation that a quantifier over this
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   979
  type needs to respect. *}
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   980
ML {*
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   981
fun tyRel ty rty rel lthy =
102
9d41f680d755 slightly improved tyRel
Christian Urban <urbanc@in.tum.de>
parents: 101
diff changeset
   982
  if ty = rty 
9d41f680d755 slightly improved tyRel
Christian Urban <urbanc@in.tum.de>
parents: 101
diff changeset
   983
  then rel
99
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   984
  else (case ty of
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   985
          Type (s, tys) =>
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   986
            let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   987
              val tys_rel = map (fn ty => ty --> ty --> @{typ bool}) tys;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   988
              val ty_out = ty --> ty --> @{typ bool};
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   989
              val tys_out = tys_rel ---> ty_out;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   990
            in
130
8e8ba210f0f7 moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents: 129
diff changeset
   991
            (case (maps_lookup (ProofContext.theory_of lthy) s) of
99
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   992
               SOME (info) => list_comb (Const (#relfun info, tys_out), map (fn ty => tyRel ty rty rel lthy) tys)
102
9d41f680d755 slightly improved tyRel
Christian Urban <urbanc@in.tum.de>
parents: 101
diff changeset
   993
             | NONE  => HOLogic.eq_const ty
99
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   994
            )
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   995
            end
102
9d41f680d755 slightly improved tyRel
Christian Urban <urbanc@in.tum.de>
parents: 101
diff changeset
   996
        | _ => HOLogic.eq_const ty)
99
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   997
*}
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   998
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
   999
ML {*
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1000
  cterm_of @{theory} (tyRel @{typ "trm \<Rightarrow> bool"} @{typ "trm"} @{term "RR"} @{context})
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1001
*}
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1002
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1003
definition
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1004
  Babs :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1005
where
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1006
  "(x \<in> p) \<Longrightarrow> (Babs p m x = m x)"
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1007
(* TODO: Consider defining it with an "if"; sth like:
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1008
   Babs p m = \<lambda>x. if x \<in> p then m x else undefined
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1009
*)
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1010
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1011
ML {*
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1012
(* trm \<Rightarrow> new_trm *)
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1013
fun regularise trm rty rel lthy =
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1014
  case trm of
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1015
    Abs (x, T, t) =>
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1016
      if (needs_lift rty T) then let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1017
        val ([x'], lthy2) = Variable.variant_fixes [x] lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1018
        val v = Free (x', T);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1019
        val t' = subst_bound (v, t);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1020
        val rec_term = regularise t' rty rel lthy2;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1021
        val lam_term = Term.lambda_name (x, v) rec_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1022
        val sub_res_term = tyRel T rty rel lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1023
        val respects = Const (@{const_name Respects}, (fastype_of sub_res_term) --> T --> @{typ bool});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1024
        val res_term = respects $ sub_res_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1025
        val ty = fastype_of trm;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1026
        val rabs = Const (@{const_name Babs}, (fastype_of res_term) --> ty --> ty);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1027
        val rabs_term = (rabs $ res_term) $ lam_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1028
      in
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1029
        rabs_term
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1030
      end else let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1031
        val ([x'], lthy2) = Variable.variant_fixes [x] lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1032
        val v = Free (x', T);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1033
        val t' = subst_bound (v, t);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1034
        val rec_term = regularise t' rty rel lthy2;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1035
      in
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1036
        Term.lambda_name (x, v) rec_term
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1037
      end
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1038
  | ((Const (@{const_name "All"}, at)) $ (Abs (x, T, t))) =>
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1039
      if (needs_lift rty T) then let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1040
        val ([x'], lthy2) = Variable.variant_fixes [x] lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1041
        val v = Free (x', T);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1042
        val t' = subst_bound (v, t);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1043
        val rec_term = regularise t' rty rel lthy2;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1044
        val lam_term = Term.lambda_name (x, v) rec_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1045
        val sub_res_term = tyRel T rty rel lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1046
        val respects = Const (@{const_name Respects}, (fastype_of sub_res_term) --> T --> @{typ bool});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1047
        val res_term = respects $ sub_res_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1048
        val ty = fastype_of lam_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1049
        val rall = Const (@{const_name Ball}, (fastype_of res_term) --> ty --> @{typ bool});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1050
        val rall_term = (rall $ res_term) $ lam_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1051
      in
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1052
        rall_term
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1053
      end else let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1054
        val ([x'], lthy2) = Variable.variant_fixes [x] lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1055
        val v = Free (x', T);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1056
        val t' = subst_bound (v, t);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1057
        val rec_term = regularise t' rty rel lthy2;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1058
        val lam_term = Term.lambda_name (x, v) rec_term
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1059
      in
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1060
        Const(@{const_name "All"}, at) $ lam_term
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1061
      end
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1062
  | ((Const (@{const_name "All"}, at)) $ P) =>
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1063
      let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1064
        val (_, [al, _]) = dest_Type (fastype_of P);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1065
        val ([x], lthy2) = Variable.variant_fixes [""] lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1066
        val v = (Free (x, al));
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1067
        val abs = Term.lambda_name (x, v) (P $ v);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1068
      in regularise ((Const (@{const_name "All"}, at)) $ abs) rty rel lthy2 end
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1069
  | ((Const (@{const_name "Ex"}, at)) $ (Abs (x, T, t))) =>
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1070
      if (needs_lift rty T) then let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1071
        val ([x'], lthy2) = Variable.variant_fixes [x] lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1072
        val v = Free (x', T);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1073
        val t' = subst_bound (v, t);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1074
        val rec_term = regularise t' rty rel lthy2;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1075
        val lam_term = Term.lambda_name (x, v) rec_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1076
        val sub_res_term = tyRel T rty rel lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1077
        val respects = Const (@{const_name Respects}, (fastype_of sub_res_term) --> T --> @{typ bool});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1078
        val res_term = respects $ sub_res_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1079
        val ty = fastype_of lam_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1080
        val rall = Const (@{const_name Bex}, (fastype_of res_term) --> ty --> @{typ bool});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1081
        val rall_term = (rall $ res_term) $ lam_term;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1082
      in
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1083
        rall_term
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1084
      end else let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1085
        val ([x'], lthy2) = Variable.variant_fixes [x] lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1086
        val v = Free (x', T);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1087
        val t' = subst_bound (v, t);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1088
        val rec_term = regularise t' rty rel lthy2;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1089
        val lam_term = Term.lambda_name (x, v) rec_term
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1090
      in
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1091
        Const(@{const_name "Ex"}, at) $ lam_term
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1092
      end
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1093
  | ((Const (@{const_name "Ex"}, at)) $ P) =>
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1094
      let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1095
        val (_, [al, _]) = dest_Type (fastype_of P);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1096
        val ([x], lthy2) = Variable.variant_fixes [""] lthy;
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1097
        val v = (Free (x, al));
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1098
        val abs = Term.lambda_name (x, v) (P $ v);
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1099
      in regularise ((Const (@{const_name "Ex"}, at)) $ abs) rty rel lthy2 end
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1100
  | a $ b => (regularise a rty rel lthy) $ (regularise b rty rel lthy)
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1101
  | _ => trm
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1102
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1103
*}
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1104
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1105
ML {*
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1106
  cterm_of @{theory} (regularise @{term "\<lambda>x :: int. x"} @{typ "trm"} @{term "RR"} @{context});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1107
  cterm_of @{theory} (regularise @{term "\<lambda>x :: trm. x"} @{typ "trm"} @{term "RR"} @{context});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1108
  cterm_of @{theory} (regularise @{term "\<forall>x :: trm. P x"} @{typ "trm"} @{term "RR"} @{context});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1109
  cterm_of @{theory} (regularise @{term "\<exists>x :: trm. P x"} @{typ "trm"} @{term "RR"} @{context});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1110
  cterm_of @{theory} (regularise @{term "All (P :: trm \<Rightarrow> bool)"} @{typ "trm"} @{term "RR"} @{context});
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1111
*}
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1112
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1113
(* my version of regularise *)
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1114
(****************************)
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1115
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1116
(* some helper functions *)
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1117
ML {*
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1118
fun mk_babs ty ty' = Const (@{const_name "Babs"}, (ty' --> @{typ bool}) --> ty --> ty)
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1119
fun mk_ball ty = Const (@{const_name "Ball"}, [ty, ty] ---> @{typ bool})
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1120
fun mk_bex ty = Const (@{const_name "Bex"}, [ty, ty] ---> @{typ bool})
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1121
fun mk_resp ty = Const (@{const_name Respects}, ([ty, ty] ---> @{typ bool}) --> ty --> @{typ bool})
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1122
*}
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1123
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1124
(* applies f to the subterm of an abstractions, otherwise to the given term *)
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1125
ML {*
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1126
fun apply_subt f trm =
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1127
  case trm of
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1128
    Abs (x, T, t) => Abs (x, T, f t)
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1129
  | _ => f trm
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1130
*}
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1131
133
5cdb383cef9c tuned and fixed the earlier fix
Christian Urban <urbanc@in.tum.de>
parents: 132
diff changeset
  1132
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1133
(* FIXME: assumes always the typ is qty! *)
133
5cdb383cef9c tuned and fixed the earlier fix
Christian Urban <urbanc@in.tum.de>
parents: 132
diff changeset
  1134
(* FIXME: if there are more than one quotient, then you have to look up the relation *)
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1135
ML {*
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1136
fun my_reg rel trm =
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1137
  case trm of
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1138
    Abs (x, T, t) =>
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1139
       let 
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1140
          val ty1 = fastype_of trm
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1141
       in
133
5cdb383cef9c tuned and fixed the earlier fix
Christian Urban <urbanc@in.tum.de>
parents: 132
diff changeset
  1142
         (mk_babs ty1 T) $ (mk_resp T $ rel) $ (Abs (x, T, my_reg rel t))    
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1143
       end
133
5cdb383cef9c tuned and fixed the earlier fix
Christian Urban <urbanc@in.tum.de>
parents: 132
diff changeset
  1144
  | Const (@{const_name "All"}, ty) $ t =>
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1145
       let 
133
5cdb383cef9c tuned and fixed the earlier fix
Christian Urban <urbanc@in.tum.de>
parents: 132
diff changeset
  1146
          val ty1 = domain_type ty
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1147
          val ty2 = domain_type ty1
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1148
       in
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1149
         (mk_ball ty1) $ (mk_resp ty2 $ rel) $ (apply_subt (my_reg rel) t)      
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1150
       end
133
5cdb383cef9c tuned and fixed the earlier fix
Christian Urban <urbanc@in.tum.de>
parents: 132
diff changeset
  1151
  | Const (@{const_name "Ex"}, ty) $ t =>
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1152
       let 
133
5cdb383cef9c tuned and fixed the earlier fix
Christian Urban <urbanc@in.tum.de>
parents: 132
diff changeset
  1153
          val ty1 = domain_type ty
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1154
          val ty2 = domain_type ty1
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1155
       in
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1156
         (mk_bex ty1) $ (mk_resp ty2 $ rel) $ (apply_subt (my_reg rel) t)    
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1157
       end
132
a045d9021c61 fixed the abs case in my_reg and added an app case
Christian Urban <urbanc@in.tum.de>
parents: 131
diff changeset
  1158
  | t1 $ t2 => (my_reg rel t1) $ (my_reg rel t2)
131
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1159
  | _ => trm
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1160
*}
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1161
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1162
ML {*  
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1163
  cterm_of @{theory} (regularise @{term "\<lambda>x::trm. x"} @{typ "trm"} @{term "RR"} @{context});
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1164
  cterm_of @{theory} (my_reg @{term "RR"} @{term "\<lambda>x::trm. x"})
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1165
*}
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1166
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1167
ML {*  
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1168
  cterm_of @{theory} (regularise @{term "\<forall>(x::trm) (y::trm). P x y"} @{typ "trm"} @{term "RR"} @{context});
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1169
  cterm_of @{theory} (my_reg @{term "RR"} @{term "\<forall>(x::trm) (y::trm). P x y"})
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1170
*}
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1171
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1172
ML {*  
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1173
  cterm_of @{theory} (regularise @{term "\<forall>x::trm. P x"} @{typ "trm"} @{term "RR"} @{context});
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1174
  cterm_of @{theory} (my_reg @{term "RR"} @{term "\<forall>x::trm. P x"})
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1175
*}
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1176
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1177
ML {*  
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1178
  cterm_of @{theory} (regularise @{term "\<exists>x::trm. P x"} @{typ "trm"} @{term "RR"} @{context});
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1179
  cterm_of @{theory} (my_reg @{term "RR"} @{term "\<exists>x::trm. P x"})
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1180
*}
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1181
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1182
(* my version is not eta-expanded *)
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1183
ML {*  
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1184
  cterm_of @{theory} (regularise @{term "All (P::trm \<Rightarrow> bool)"} @{typ "trm"} @{term "RR"} @{context});
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1185
  cterm_of @{theory} (my_reg @{term "RR"} @{term "All (P::trm \<Rightarrow> bool)"})
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1186
*}
0842a38dcf01 my version of regularise (still needs to be completed)
Christian Urban <urbanc@in.tum.de>
parents: 130
diff changeset
  1187
99
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1188
ML {*
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1189
fun atomize_thm thm =
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1190
let
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1191
  val thm' = forall_intr_vars thm
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1192
  val thm'' = ObjectLogic.atomize (cprop_of thm')
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1193
in
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1194
  Simplifier.rewrite_rule [thm''] thm'
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1195
end
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1196
*}
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1197
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1198
thm list.induct
114
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1199
lemma list_induct_hol4:
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1200
  fixes P :: "'a list \<Rightarrow> bool"
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1201
  assumes "((P []) \<and> (\<forall>t. (P t) \<longrightarrow> (\<forall>h. (P (h # t)))))"
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1202
  shows "(\<forall>l. (P l))"
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1203
  sorry
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1204
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1205
ML {* atomize_thm @{thm list_induct_hol4} *}
99
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1206
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1207
(*fun prove_reg trm \<Rightarrow> thm (we might need some facts to do this)
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1208
  trm == new_trm
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1209
*)
19e5aceb8c2d Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 98
diff changeset
  1210
114
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1211
ML {* val li = Thm.freezeT (atomize_thm @{thm list_induct_hol4}) *}
87
9220c51e5155 atomize_thm and meta_quantify.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 86
diff changeset
  1212
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
  1213
prove list_induct_r: {*
93
ec29be471518 Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 92
diff changeset
  1214
 Logic.mk_implies
94
ecfc2e1fd15e Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 93
diff changeset
  1215
   ((prop_of li),
ecfc2e1fd15e Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 93
diff changeset
  1216
   (regularise (prop_of li) @{typ "'a List.list"} @{term "op \<approx>"} @{context})) *}
93
ec29be471518 Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 92
diff changeset
  1217
  apply (simp only: equiv_res_forall[OF equiv_list_eq])
94
ecfc2e1fd15e Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 93
diff changeset
  1218
  thm RIGHT_RES_FORALL_REGULAR
ecfc2e1fd15e Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 93
diff changeset
  1219
  apply (rule RIGHT_RES_FORALL_REGULAR)
93
ec29be471518 Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 92
diff changeset
  1220
  prefer 2
ec29be471518 Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 92
diff changeset
  1221
  apply (assumption)
104
41a2ab50dd89 Cleaning the proofs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 103
diff changeset
  1222
  apply (metis)
94
ecfc2e1fd15e Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 93
diff changeset
  1223
  done
87
9220c51e5155 atomize_thm and meta_quantify.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 86
diff changeset
  1224
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
  1225
ML {* val thm = @{thm list_induct_r} OF [li] *}
129
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1226
ML {* val trm_r = build_goal @{context} thm consts @{typ "'a list"} @{typ "'a fset"} *}
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1227
lemmas APPLY_RSP_I = APPLY_RSP[of "(op \<approx> ===> op =) ===> op =" "(ABS_fset ---> id) ---> id" "(REP_fset ---> id) ---> id" "op =" "id" "id"]
114
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1228
lemmas REP_ABS_RSP_I = REP_ABS_RSP(1)[of "(op \<approx> ===> op =) ===> op =" "(ABS_fset ---> id) ---> id" "(REP_fset ---> id) ---> id"]
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1229
129
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1230
ML {* val trm = build_goal_term @{context} thm consts @{typ "'a list"} @{typ "'a fset"} *}
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1231
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1232
prove list_induct_tr: trm_r
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1233
apply (atomize(full))
113
e3a963e6418b Symmetric version of REP_ABS_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 112
diff changeset
  1234
apply (simp only: id_def[symmetric])
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1235
114
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1236
(* APPLY_RSP_TAC *)
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1237
ML_prf {*
114
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1238
  val (_, gc') = Thm.dest_comb (Subgoal.focus @{context} 1 (Isar.goal ()) |> fst |> #concl)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1239
  val (_, tc') = Thm.dest_comb (cterm_of @{theory} (concl_of @{thm "APPLY_RSP_I" }))
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1240
  val m = Thm.match (tc', gc')
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1241
  val t2 = Drule.instantiate m @{thm "APPLY_RSP_I" }
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1242
 *}
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1243
thm APPLY_RSP_I
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1244
apply (tactic {* rtac t2 1 *})
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1245
prefer 2
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1246
apply (rule IDENTITY_QUOTIENT)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1247
prefer 3
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1248
(* ABS_REP_RSP_TAC *)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1249
ML_prf {*
114
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1250
  val (_, gc') = Thm.dest_comb (Subgoal.focus @{context} 1 (Isar.goal ()) |> fst |> #concl)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1251
  val (_, tc') = Thm.dest_comb (cterm_of @{theory} (concl_of @{thm "REP_ABS_RSP_I" }))
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1252
  val m = Thm.match (tc', gc')
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1253
  val t2 = Drule.instantiate m @{thm "REP_ABS_RSP_I" }
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1254
 *}
114
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1255
apply (tactic {* rtac t2 1 *})
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1256
prefer 2
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1257
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1258
(* LAMBDA_RES_TAC *)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1259
apply (simp only: FUN_REL.simps)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1260
apply (rule allI)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1261
apply (rule allI)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1262
apply (rule impI)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1263
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1264
(* MK_COMB_TAC *)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1265
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1266
(* MK_COMB_TAC *)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1267
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1268
(* REFL_TAC *)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1269
apply (simp)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1270
(* MK_COMB_TAC *)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1271
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1272
(* MK_COMB_TAC *)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1273
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1274
(* REFL_TAC *)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1275
apply (simp)
3cdb743b7605 Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
  1276
(* APPLY_RSP_TAC *)
121
25268329d3b7 Simplified
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 120
diff changeset
  1277
apply (rule_tac APPLY_RSP[of "op \<approx>" "ABS_fset" "REP_fset" "op =" "id" "id"])
120
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1278
apply (rule QUOTIENT_fset)
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1279
apply (rule IDENTITY_QUOTIENT)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1280
prefer 2
120
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1281
(* ABS_REP_RSP *)
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1282
apply (rule REP_ABS_RSP(1)[of "op \<approx>" "ABS_fset" "REP_fset"])
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1283
apply (rule QUOTIENT_fset)
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1284
(* MINE *)
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1285
apply (rule list_eq_refl )
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1286
(* ABS_REP_RSP *)
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1287
apply (rule REP_ABS_RSP(1)[of "op \<approx> ===> op =" "REP_fset ---> id" "ABS_fset ---> id"])
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1288
prefer 2
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1289
(* MINE *)
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1290
apply (simp only: FUN_REL.simps)
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1291
prefer 2
120
b441019d457d Further in the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 119
diff changeset
  1292
(* APPLY_RSP *)
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1293
apply (rule_tac APPLY_RSP[of "op \<approx> ===> op =" "REP_fset ---> id" "ABS_fset ---> id" "op =" "id" "id" "Ball (Respects op \<approx>)" "Ball (Respects op \<approx>)"])
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1294
prefer 2
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1295
apply (rule IDENTITY_QUOTIENT)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1296
(* 2: ho_respects *)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1297
prefer 3
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1298
(* ABS_REP_RSP *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1299
apply (rule REP_ABS_RSP(1)[of "op \<approx> ===> op =" "REP_fset ---> id" "ABS_fset ---> id"])
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1300
prefer 2
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1301
(* LAMBDA_RSP *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1302
apply (simp only: FUN_REL.simps)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1303
apply (rule allI)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1304
apply (rule allI)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1305
apply (rule impI)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1306
(* MK_COMB_TAC *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1307
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1308
(* MK_COMB_TAC *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1309
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1310
(* REFL_TAC *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1311
apply (simp)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1312
(* APPLY_RSP *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1313
apply (rule APPLY_RSP[of "op \<approx>" "ABS_fset" "REP_fset" "op =" "id" "id"])
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1314
apply (rule QUOTIENT_fset)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1315
apply (rule IDENTITY_QUOTIENT)
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1316
apply (rule REP_ABS_RSP(1)[of "op \<approx> ===> op =" "REP_fset ---> id" "ABS_fset ---> id"])
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1317
prefer 2
123
50219e796e05 More higher order unification problems
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 122
diff changeset
  1318
(* MINE *)
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1319
apply (simp only: FUN_REL.simps)
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1320
prefer 2
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1321
apply (rule REP_ABS_RSP(1)[of "op \<approx>" "ABS_fset" "REP_fset"])
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1322
apply (rule QUOTIENT_fset)
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1323
(* FIRST_ASSUM MATCH_ACCEPT_TAC *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1324
apply (assumption)
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1325
prefer 2
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1326
(* MK_COMB_TAC *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1327
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *})
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1328
(* REFL_TAC *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1329
apply (simp)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1330
(* W(C (curry op THEN) (G... *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1331
apply (rule ext)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1332
(* APPLY_RSP *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1333
apply (rule APPLY_RSP[of "op \<approx>" "ABS_fset" "REP_fset" "op =" "id" "id"])
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1334
apply (rule QUOTIENT_fset)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1335
apply (rule IDENTITY_QUOTIENT)
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1336
apply (rule REP_ABS_RSP(1)[of "op \<approx> ===> op =" "REP_fset ---> id" "ABS_fset ---> id"])
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1337
prefer 2
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1338
apply (simp only: FUN_REL.simps)
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1339
prefer 2
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1340
apply (rule REP_ABS_RSP(1)[of "op \<approx>" "ABS_fset" "REP_fset"])
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1341
apply (rule QUOTIENT_fset)
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1342
(* APPLY_RSP *)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1343
apply (rule_tac ?f="\<lambda>x. h # x" and ?g="\<lambda>x. h # x" in APPLY_RSP[of "op \<approx>" "ABS_fset" "REP_fset" "op \<approx>" "ABS_fset" "REP_fset"] )
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1344
apply (rule QUOTIENT_fset)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1345
apply (rule QUOTIENT_fset)
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1346
apply (rule_tac ?f="op #" and ?g="op #" in APPLY_RSP[of "op =" "id" "id" "op \<approx> ===> op \<approx>" "REP_fset ---> ABS_fset" "ABS_fset ---> REP_fset"])
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1347
apply (rule IDENTITY_QUOTIENT)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1348
(* CONS respects *)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1349
prefer 2
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1350
apply (simp add: FUN_REL.simps)
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1351
apply (rule allI)
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1352
apply (rule allI)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1353
apply (rule allI)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1354
apply (rule impI)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1355
apply (rule cons_preserves)
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1356
apply (assumption)
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 125
diff changeset
  1357
prefer 2
124
de944fcd6a05 Only QUOTIENSs are left to fnish proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 123
diff changeset
  1358
apply (simp)
111
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
  1359
sorry
107
ab53ddefc542 A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 106
diff changeset
  1360
129
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1361
prove list_induct_t: trm
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1362
apply (simp only: list_induct_tr[symmetric])
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1363
apply (tactic {* rtac thm 1 *})
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1364
done
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1365
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1366
ML {* val nthm = MetaSimplifier.rewrite_rule fset_defs_sym (snd (no_vars (Context.Theory @{theory}, @{thm list_induct_t}))) *}
89283c1dbba7 Test if we can already do sth with the transformed theorem.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 128
diff changeset
  1367
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1368
thm list.recs(2)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1369
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1370
106
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1371
ML {* val card1_suc_f = Thm.freezeT (atomize_thm @{thm card1_suc}) *}
96
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
  1372
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
  1373
prove card1_suc_r: {*
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
  1374
 Logic.mk_implies
106
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1375
   ((prop_of card1_suc_f),
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1376
   (regularise (prop_of card1_suc_f) @{typ "'a List.list"} @{term "op \<approx>"} @{context})) *}
104
41a2ab50dd89 Cleaning the proofs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 103
diff changeset
  1377
  apply (simp add: equiv_res_forall[OF equiv_list_eq] equiv_res_exists[OF equiv_list_eq])
96
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
  1378
  done
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
  1379
106
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1380
ML {* @{thm card1_suc_r} OF [card1_suc_f] *}
96
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
  1381
97
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1382
ML {* val li = Thm.freezeT (atomize_thm @{thm fold1.simps(2)}) *}
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1383
prove fold1_def_2_r: {*
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1384
 Logic.mk_implies
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1385
   ((prop_of li),
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1386
   (regularise (prop_of li) @{typ "'a List.list"} @{term "op \<approx>"} @{context})) *}
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1387
  apply (simp add: equiv_res_forall[OF equiv_list_eq])
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1388
  done
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1389
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1390
ML {* @{thm fold1_def_2_r} OF [li] *}
0d34f2e60d5d The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
  1391
29
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
  1392
ML {*
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1393
  fun lift_theorem_fset_aux thm lthy =
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1394
    let
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1395
      val ((_, [novars]), lthy2) = Variable.import true [thm] lthy;
111
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
  1396
      val goal = build_goal @{context} novars consts @{typ "'a list"} @{typ "'a fset"};
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1397
      val cgoal = cterm_of @{theory} goal;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1398
      val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite true fset_defs_sym cgoal);
106
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1399
      val tac = transconv_fset_tac' @{context};
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1400
      val cthm = Goal.prove_internal [] cgoal2 (fn _ => tac);
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1401
      val nthm = MetaSimplifier.rewrite_rule [symmetric cthm] (snd (no_vars (Context.Theory @{theory}, thm)))
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1402
      val nthm2 = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same QUOT_TYPE_I_fset.thm10} nthm;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1403
      val [nthm3] = ProofContext.export lthy2 lthy [nthm2]
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1404
    in
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1405
      nthm3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1406
    end
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1407
*}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1408
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1409
ML {* lift_theorem_fset_aux @{thm m1} @{context} *}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1410
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1411
ML {*
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1412
  fun lift_theorem_fset name thm lthy =
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1413
    let
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1414
      val lifted_thm = lift_theorem_fset_aux thm lthy;
88
19d3856abb81 slight simplification of atomize_thm
Christian Urban <urbanc@in.tum.de>
parents: 87
diff changeset
  1415
      val (_, lthy2) = note (name, lifted_thm) lthy;
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1416
    in
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1417
      lthy2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1418
    end;
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1419
*}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1420
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1421
local_setup {* lift_theorem_fset @{binding "m1_lift"} @{thm m1} *}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1422
local_setup {* lift_theorem_fset @{binding "leqi4_lift"} @{thm list_eq.intros(4)} *}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1423
local_setup {* lift_theorem_fset @{binding "leqi5_lift"} @{thm list_eq.intros(5)} *}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1424
local_setup {* lift_theorem_fset @{binding "m2_lift"} @{thm m2} *}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1425
thm m1_lift
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1426
thm leqi4_lift
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1427
thm leqi5_lift
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1428
thm m2_lift
106
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1429
ML {* @{thm card1_suc_r} OF [card1_suc_f] *}
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1430
(*ML {* Toplevel.program (fn () => lift_theorem_fset @{binding "card_suc"}
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1431
     (@{thm card1_suc_r} OF [card1_suc_f]) @{context}) *}*)
a250b56e7f2a Cleaning the code
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 105
diff changeset
  1432
(*local_setup {* lift_theorem_fset @{binding "card_suc"} @{thm card1_suc} *}*)
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1433
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1434
thm leqi4_lift
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1435
ML {*
62
58384c90a5e5 used prop_of to get the term of a theorem (replaces crep_thm)
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
  1436
  val (nam, typ) = hd (Term.add_vars (prop_of @{thm leqi4_lift}) [])
49
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1437
  val (_, l) = dest_Type typ
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1438
  val t = Type ("QuotMain.fset", l)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1439
  val v = Var (nam, t)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1440
  val cv = cterm_of @{theory} ((term_of @{cpat "REP_fset"}) $ v)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1441
*}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1442
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1443
ML {*
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1444
  Toplevel.program (fn () =>
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1445
    MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.thm10} (
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1446
      Drule.instantiate' [] [NONE, SOME (cv)] @{thm leqi4_lift}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1447
    )
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1448
  )
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1449
*}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 47
diff changeset
  1450
77
cb74afa437d7 Bounded quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 76
diff changeset
  1451
lemma "(Ball (Respects ((op \<approx>) ===> (op =)))
72
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1452
         (((REP_fset ---> id) ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1453
             (((ABS_fset ---> id) ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1454
               (\<lambda>P.
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1455
                  (ABS_fset ---> id) ((REP_fset ---> id) P)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1456
                    (REP_fset (ABS_fset [])) \<and>
77
cb74afa437d7 Bounded quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 76
diff changeset
  1457
                  Ball (Respects (op \<approx>))
72
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1458
                    ((ABS_fset ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1459
                       ((REP_fset ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1460
                          (\<lambda>t.
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1461
                             ((ABS_fset ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1462
                               ((REP_fset ---> id) P)
73
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1463
                               (REP_fset (ABS_fset t))) \<longrightarrow>
72
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1464
                             (!h.
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1465
                               (ABS_fset ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1466
                                 ((REP_fset ---> id) P)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1467
                                 (REP_fset
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1468
                                    (ABS_fset
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1469
                                       (h #
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1470
                                            REP_fset
73
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1471
                                              (ABS_fset t)))))))) \<longrightarrow>
77
cb74afa437d7 Bounded quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 76
diff changeset
  1472
                  Ball (Respects (op \<approx>))
72
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1473
                    ((ABS_fset ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1474
                       ((REP_fset ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1475
                          (\<lambda>l.
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1476
                             (ABS_fset ---> id)
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1477
                               ((REP_fset ---> id) P)
74
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1478
                               (REP_fset (ABS_fset l)))))))))
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1479
77
cb74afa437d7 Bounded quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 76
diff changeset
  1480
   = Ball (Respects ((op \<approx>) ===> (op =)))
cb74afa437d7 Bounded quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 76
diff changeset
  1481
     (\<lambda>P. ((P []) \<and> (Ball (Respects (op \<approx>)) (\<lambda>t. P t \<longrightarrow> (\<forall>h. (P (h # t)))))) \<longrightarrow>
cb74afa437d7 Bounded quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 76
diff changeset
  1482
     (Ball (Respects (op \<approx>)) (\<lambda>l. P l)))"
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1483
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1484
thm APPLY_RSP[of "op \<approx> ===> (op = ===> op =)" "REP_fset ---> (id ---> id)" "ABS_fset ---> (id ---> id)" "op =" "id" "id"]
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1485
proof -
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1486
note APPLY_RSP_I = APPLY_RSP[of "op \<approx> ===> (op = ===> op =)" "REP_fset ---> (id ---> id)" "ABS_fset ---> (id ---> id)" "op =" "id" "id"]
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1487
show ?thesis apply -
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1488
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1489
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1490
ML_prf {*
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1491
  val gc = Subgoal.focus @{context} 1 (Isar.goal ())
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1492
  |> fst
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1493
  |> #concl
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1494
  val tc = cterm_of @{theory} (concl_of ( @{thm "APPLY_RSP" }))
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1495
  val (_, tc') = Thm.dest_comb tc
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1496
  val (_, gc') = Thm.dest_comb gc
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1497
 *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1498
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1499
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1500
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1501
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1502
ML_prf {*
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1503
  (gc', tc')
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1504
*}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1505
ML_prf {* Pattern.first_order_match *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1506
ML_prf {* Thm.match (@{cpat "?P::?'a"}, @{cterm "1::nat"}) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1507
ML_prf {* Pattern.match @{theory} (term_of @{cpat "?P::nat"}, term_of @{cterm "1::nat"}) (Vartab.empty, Vartab.empty) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1508
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1509
ML_prf {* val (op1, (l1, r1)) = dest_cbinop tc' *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1510
ML_prf {* val (op2, (l2, r2)) = dest_cbinop gc' *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1511
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1512
ML_prf {* val mo = Thm.match (op1, op2) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1513
ML_prf {* val t1 = Drule.instantiate mo @{thm "APPLY_RSP" } *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1514
ML_prf {* val tc = cterm_of @{theory} (concl_of t1) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1515
ML_prf {* val (_, tc') = Thm.dest_comb tc *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1516
ML_prf {* val (op1, (l1, r1)) = dest_cbinop tc' *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1517
ML_prf {* val (mlty, mlt) = Thm.match (l1, l2) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1518
ML_prf {* val t2 = Drule.instantiate (mlty, []) t1 *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1519
ML_prf {* val tc = cterm_of @{theory} (concl_of t2) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1520
ML_prf {* val (_, tc') = Thm.dest_comb tc *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1521
ML_prf {* val (op1, (l1, r1)) = dest_cbinop tc' *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1522
ML_prf {* val mr = Thm.match (r1, r2) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1523
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1524
ML_prf {* val t3 = Drule.instantiate ml t2 *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1525
ML_prf {* val tc = cterm_of @{theory} (concl_of t3) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1526
ML_prf {* val (_, tc') = Thm.dest_comb tc *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1527
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1528
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1529
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1530
ML_prf {* mtyl; mtyr *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1531
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1532
ML_prf {* val ol1 = Thm.capply op1 l1 *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1533
ML_prf {* val ol2 = Thm.capply op2 l2 *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1534
ML_prf {* (ol1, ol2); Thm.match (ol1, ol2) *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1535
ML_prf {* val w1 = Thm.capply ol1 r1 *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1536
ML_prf {* val w2 = Thm.capply ol2 r2 *}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1537
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1538
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1539
.
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1540
(*ML_prf {* (w1, w2); Thm.match (w1, w2) *}*)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1541
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1542
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1543
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1544
ML_prf {*
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1545
   (tc', gc')
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1546
*}
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1547
95
8c3a35da4560 Proving the proper RepAbs version
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 94
diff changeset
  1548
thm APPLY_RSP
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1549
thm APPLY_RSP[of "op \<approx> ===> (op = ===> op =)"]
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1550
term "(op \<approx> ===> op =) ===> op ="
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1551
proof -
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1552
note APPLY_RSP_I2 = APPLY_RSP[of "(op \<approx> ===> op =) ===> op =" "(ABS_fset ---> id) ---> id" "(REP_fset ---> id) ---> id" "op =" "id" "id" "Ball (Respects op \<approx> ===> op =)" "Ball (Respects op \<approx> ===> op =)"]
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1553
show ?thesis apply -
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1554
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1555
thm APPLY_RSP_I2[of _ "\<lambda>P. (P [] \<and> (\<forall>t\<Colon>'b list\<in>Respects op \<approx>. P t \<longrightarrow> (\<forall>h\<Colon>'b. P (h # t))) \<longrightarrow>
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1556
          (\<forall>l\<Colon>'b list\<in>Respects op \<approx>. P l))"]
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1557
proof -
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1558
note APPLY_RSP_I3=APPLY_RSP_I2[of _ "\<lambda>P. (P [] \<and> (\<forall>t\<Colon>'b list\<in>Respects op \<approx>. P t \<longrightarrow> (\<forall>h\<Colon>'b. P (h # t))) \<longrightarrow>
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1559
          (\<forall>l\<Colon>'b list\<in>Respects op \<approx>. P l))"]
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1560
show ?thesis apply -
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1561
term "(REP_fset ---> id ---> id
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1562
         (ABS_fset ---> id ---> id
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1563
           (\<lambda>P\<Colon>'a list \<Rightarrow> bool.
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1564
               ABS_fset ---> id (REP_fset ---> id P)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1565
                (REP_fset (ABS_fset [])) \<and>
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1566
               Ball (Respects op \<approx>)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1567
                (ABS_fset ---> id
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1568
                  (REP_fset ---> id
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1569
                    (\<lambda>t\<Colon>'a list.
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1570
                        ABS_fset ---> id (REP_fset ---> id P)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1571
                         (REP_fset (ABS_fset t)) \<longrightarrow>
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1572
                        (\<forall>h\<Colon>'a.
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1573
                            ABS_fset ---> id (REP_fset ---> id P)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1574
                             (REP_fset
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1575
                               (ABS_fset
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1576
                                 (h # REP_fset (ABS_fset t)))))))) \<longrightarrow>
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1577
               Ball (Respects op \<approx>)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1578
                (ABS_fset ---> id
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1579
                  (REP_fset ---> id
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1580
                    (\<lambda>l\<Colon>'a list.
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1581
                        ABS_fset ---> id (REP_fset ---> id P)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1582
                         (REP_fset (ABS_fset l))))))))"
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1583
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1584
apply (rule APPLY_RSP_I3)
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1585
term "Ball (Respects op \<approx> ===> op =)"
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1586
thm APPLY_RSP_I [of _ "Ball (Respects op \<approx> ===> op =)"]
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1587
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1588
thm APPLY_RSP
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1589
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1590
.
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1591
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1592
apply (tactic {* Cong_Tac.cong_tac @{thm APPLY_RSP_I} 1 *} )
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1593
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1594
apply (tactic {* match_tac @{thms APPLY_RSP_I} 1 *})
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1595
  .
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1596
111
4683292581bc Finally fix get_fun.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 110
diff changeset
  1597
apply (rule APPLY_RSP[of "op \<approx> ===> (op = ===> op =)" "REP_fset ---> (id ---> id)" "ABS_fset ---> (id ---> id)" "op =" "id" "id"])
95
8c3a35da4560 Proving the proper RepAbs version
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 94
diff changeset
  1598
apply (rule APPLY_RSP[of "op \<approx> ===> (op = ===> op =)" _ _ "op ="])
74
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1599
term "(\<forall>P. (((P []) \<and> (\<forall>t. (P t \<longrightarrow> (\<forall>h. P (h # t))))) \<longrightarrow> (\<forall>l. (P l))))"
73
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1600
thm LAMBDA_PRS1[symmetric]
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1601
(*apply (simp only:LAMBDA_PRS1[symmetric] FUN_QUOTIENT IDENTITY_QUOTIENT QUOT_TYPE_I_fset.QUOTIENT)*)
77
cb74afa437d7 Bounded quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 76
diff changeset
  1602
apply (unfold Ball_def)
74
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1603
apply (simp only: IN_RESPECTS)
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1604
apply (simp only:list_eq_refl)
72
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1605
apply (unfold id_def)
74
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1606
(*apply (simp only: FUN_MAP_I)*)
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1607
apply (simp)
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1608
apply (simp only: QUOT_TYPE_I_fset.thm10)
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1609
..
73
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1610
apply (simp add:IN_RESPECTS)
74
0370493040f3 Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 73
diff changeset
  1611
73
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1612
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1613
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1614
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1615
apply (simp add: QUOT_TYPE_I_fset.R_trans2)
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1616
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1617
apply (rule ext)
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1618
apply (simp add:QUOT_TYPE_I_fset.REP_ABS_rsp)
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1619
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *} )
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1620
apply (simp add:cons_preserves)
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1621
fdaf1466daf0 Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 72
diff changeset
  1622
72
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1623
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1624
(*prove aaa: {* (Thm.term_of cgoal2) *}
45
d98224cafb86 Cleanup
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 44
diff changeset
  1625
  apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} )
58
f2565006dc5a Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 57
diff changeset
  1626
  apply (atomize(full))
101
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 100
diff changeset
  1627
  apply (tactic {* transconv_fset_tac' @{context} 1 *})
72
4efc9e6661a4 Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 71
diff changeset
  1628
  done*)
29
2b59bf690633 Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 28
diff changeset
  1629
18
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
  1630
(*
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
  1631
datatype obj1 =
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
  1632
  OVAR1 "string"
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
  1633
| OBJ1 "(string * (string \<Rightarrow> obj1)) list"
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
  1634
| INVOKE1 "obj1 \<Rightarrow> string"
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
  1635
| UPDATE1 "obj1 \<Rightarrow> string \<Rightarrow> (string \<Rightarrow> obj1)"
ce522150c1f7 Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 17
diff changeset
  1636
*)
53
a036f6fb1516 Test line
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 52
diff changeset
  1637
57
13be92f5b638 used new cong_tac
Christian Urban <urbanc@in.tum.de>
parents: 56
diff changeset
  1638
end
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 111
diff changeset
  1639