author | wenzelm |
Thu, 12 Jun 2008 22:29:51 +0200 | |
changeset 27184 | b1483d423512 |
parent 27179 | 8f29fed3dc9a |
child 27187 | 17b63e145986 |
permissions | -rw-r--r-- |
15347 | 1 |
(* Author: Jia Meng, Cambridge University Computer Laboratory |
2 |
ID: $Id$ |
|
3 |
Copyright 2004 University of Cambridge |
|
4 |
||
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
5 |
Transformation of axiom rules (elim/intro/etc) into CNF forms. |
15347 | 6 |
*) |
7 |
||
15997 | 8 |
signature RES_AXIOMS = |
21505 | 9 |
sig |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
10 |
val cnf_axiom: theory -> thm -> thm list |
24669 | 11 |
val pairname: thm -> string * thm |
27184 | 12 |
val multi_base_blacklist: string list |
25243 | 13 |
val bad_for_atp: thm -> bool |
25761 | 14 |
val type_has_empty_sort: typ -> bool |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
15 |
val cnf_rules_pairs: theory -> (string * thm) list -> (thm * (string * int)) list |
24669 | 16 |
val neg_clausify: thm list -> thm list |
17 |
val expand_defs_tac: thm -> tactic |
|
24827 | 18 |
val combinators: thm -> thm |
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
19 |
val neg_conjecture_clauses: thm -> int -> thm list * (string * typ) list |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
20 |
val claset_rules_of: Proof.context -> (string * thm) list (*FIXME DELETE*) |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
21 |
val simpset_rules_of: Proof.context -> (string * thm) list (*FIXME DELETE*) |
21505 | 22 |
val atpset_rules_of: Proof.context -> (string * thm) list |
25256
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
23 |
val suppress_endtheory: bool ref (*for emergency use where endtheory causes problems*) |
24669 | 24 |
val setup: theory -> theory |
21505 | 25 |
end; |
19196
62ee8c10d796
Added functions to retrieve local and global atpset rules.
mengj
parents:
19175
diff
changeset
|
26 |
|
24669 | 27 |
structure ResAxioms: RES_AXIOMS = |
15997 | 28 |
struct |
15347 | 29 |
|
20902 | 30 |
(* FIXME legacy *) |
20863
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
31 |
fun freeze_thm th = #1 (Drule.freeze_thaw th); |
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
32 |
|
25761 | 33 |
fun type_has_empty_sort (TFree (_, [])) = true |
34 |
| type_has_empty_sort (TVar (_, [])) = true |
|
35 |
| type_has_empty_sort (Type (_, Ts)) = exists type_has_empty_sort Ts |
|
36 |
| type_has_empty_sort _ = false; |
|
27184 | 37 |
|
15997 | 38 |
(**** Transformation of Elimination Rules into First-Order Formulas****) |
15347 | 39 |
|
21430
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
40 |
val cfalse = cterm_of HOL.thy HOLogic.false_const; |
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
41 |
val ctp_false = cterm_of HOL.thy (HOLogic.mk_Trueprop HOLogic.false_const); |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
42 |
|
21430
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
43 |
(*Converts an elim-rule into an equivalent theorem that does not have the |
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
44 |
predicate variable. Leaves other theorems unchanged. We simply instantiate the |
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
45 |
conclusion variable to False.*) |
16009 | 46 |
fun transform_elim th = |
21430
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
47 |
case concl_of th of (*conclusion variable*) |
24669 | 48 |
Const("Trueprop",_) $ (v as Var(_,Type("bool",[]))) => |
21430
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
49 |
Thm.instantiate ([], [(cterm_of HOL.thy v, cfalse)]) th |
24669 | 50 |
| v as Var(_, Type("prop",[])) => |
21430
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
51 |
Thm.instantiate ([], [(cterm_of HOL.thy v, ctp_false)]) th |
77651b6d9d6c
New transformation of eliminatino rules: we simply replace the final conclusion variable by False
paulson
parents:
21290
diff
changeset
|
52 |
| _ => th; |
15997 | 53 |
|
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
54 |
(*To enforce single-threading*) |
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
55 |
exception Clausify_failure of theory; |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
56 |
|
16009 | 57 |
(**** SKOLEMIZATION BY INFERENCE (lcp) ****) |
58 |
||
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
59 |
fun rhs_extra_types lhsT rhs = |
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
60 |
let val lhs_vars = Term.add_tfreesT lhsT [] |
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
61 |
fun add_new_TFrees (TFree v) = |
24821
cc55041ca8ba
skolem_cache: ignore internal theorems -- major speedup;
wenzelm
parents:
24785
diff
changeset
|
62 |
if member (op =) lhs_vars v then I else insert (op =) (TFree v) |
cc55041ca8ba
skolem_cache: ignore internal theorems -- major speedup;
wenzelm
parents:
24785
diff
changeset
|
63 |
| add_new_TFrees _ = I |
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
64 |
val rhs_consts = fold_aterms (fn Const c => insert (op =) c | _ => I) rhs [] |
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
65 |
in fold (#2 #> Term.fold_atyps add_new_TFrees) rhs_consts [] end; |
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
66 |
|
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
67 |
(*Traverse a theorem, declaring Skolem function definitions. String s is the suggested |
27174
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
68 |
prefix for the Skolem constant.*) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
69 |
fun declare_skofuns s th = |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
70 |
let |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
71 |
val nref = ref 0 |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
72 |
fun dec_sko (Const ("Ex",_) $ (xtp as Abs (_, T, p))) (axs, thy) = |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
73 |
(*Existential: declare a Skolem function, then insert into body and continue*) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
74 |
let |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
75 |
val cname = "sko_" ^ s ^ "_" ^ Int.toString (inc nref) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
76 |
val args0 = term_frees xtp (*get the formal parameter list*) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
77 |
val Ts = map type_of args0 |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
78 |
val extraTs = rhs_extra_types (Ts ---> T) xtp |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
79 |
val _ = if null extraTs then () else |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
80 |
warning ("Skolemization: extra type vars: " ^ |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
81 |
commas_quote (map (Syntax.string_of_typ_global thy) extraTs)) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
82 |
val argsx = map (fn T => Free (gensym "vsk", T)) extraTs |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
83 |
val args = argsx @ args0 |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
84 |
val cT = extraTs ---> Ts ---> T |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
85 |
val rhs = list_abs_free (map dest_Free args, HOLogic.choice_const T $ xtp) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
86 |
(*Forms a lambda-abstraction over the formal parameters*) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
87 |
val (c, thy') = Sign.declare_const [Markup.property_internal] (cname, cT, NoSyn) thy |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
88 |
val cdef = cname ^ "_def" |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
89 |
val thy'' = Theory.add_defs_i true false [(cdef, equals cT $ c $ rhs)] thy' |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
90 |
handle ERROR _ => raise Clausify_failure thy' |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
91 |
val ax = Thm.get_axiom_i thy'' (Sign.full_name thy'' cdef) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
92 |
in dec_sko (subst_bound (list_comb (c, args), p)) (ax :: axs, thy'') end |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
93 |
| dec_sko (Const ("All", _) $ (xtp as Abs (a, T, p))) thx = |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
94 |
(*Universal quant: insert a free variable into body and continue*) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
95 |
let val fname = Name.variant (add_term_names (p, [])) a |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
96 |
in dec_sko (subst_bound (Free (fname, T), p)) thx end |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
97 |
| dec_sko (Const ("op &", _) $ p $ q) thx = dec_sko q (dec_sko p thx) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
98 |
| dec_sko (Const ("op |", _) $ p $ q) thx = dec_sko q (dec_sko p thx) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
99 |
| dec_sko (Const ("Trueprop", _) $ p) thx = dec_sko p thx |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
100 |
| dec_sko t thx = thx (*Do nothing otherwise*) |
c2c484480f40
declare_skofuns/skolem: canonical argument order;
wenzelm
parents:
26939
diff
changeset
|
101 |
in fn thy => dec_sko (Thm.prop_of th) ([], thy) end; |
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
102 |
|
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
103 |
(*Traverse a theorem, accumulating Skolem function definitions.*) |
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
104 |
fun assume_skofuns s th = |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
105 |
let val sko_count = ref 0 |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
106 |
fun dec_sko (Const ("Ex",_) $ (xtp as Abs(_,T,p))) defs = |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
107 |
(*Existential: declare a Skolem function, then insert into body and continue*) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
108 |
let val skos = map (#1 o Logic.dest_equals) defs (*existing sko fns*) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
109 |
val args = term_frees xtp \\ skos (*the formal parameters*) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
110 |
val Ts = map type_of args |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
111 |
val cT = Ts ---> T |
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
112 |
val id = "sko_" ^ s ^ "_" ^ Int.toString (inc sko_count) |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
113 |
val c = Free (id, cT) |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
114 |
val rhs = list_abs_free (map dest_Free args, |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
115 |
HOLogic.choice_const T $ xtp) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
116 |
(*Forms a lambda-abstraction over the formal parameters*) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
117 |
val def = equals cT $ c $ rhs |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
118 |
in dec_sko (subst_bound (list_comb(c,args), p)) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
119 |
(def :: defs) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
120 |
end |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
121 |
| dec_sko (Const ("All",_) $ (xtp as Abs(a,T,p))) defs = |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
122 |
(*Universal quant: insert a free variable into body and continue*) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
123 |
let val fname = Name.variant (add_term_names (p,[])) a |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
124 |
in dec_sko (subst_bound (Free(fname,T), p)) defs end |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
125 |
| dec_sko (Const ("op &", _) $ p $ q) defs = dec_sko q (dec_sko p defs) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
126 |
| dec_sko (Const ("op |", _) $ p $ q) defs = dec_sko q (dec_sko p defs) |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
127 |
| dec_sko (Const ("Trueprop", _) $ p) defs = dec_sko p defs |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
128 |
| dec_sko t defs = defs (*Do nothing otherwise*) |
20419 | 129 |
in dec_sko (prop_of th) [] end; |
130 |
||
131 |
||
24827 | 132 |
(**** REPLACING ABSTRACTIONS BY COMBINATORS ****) |
20419 | 133 |
|
134 |
(*Returns the vars of a theorem*) |
|
135 |
fun vars_of_thm th = |
|
22691 | 136 |
map (Thm.cterm_of (theory_of_thm th) o Var) (Thm.fold_terms Term.add_vars th []); |
20419 | 137 |
|
138 |
(*Make a version of fun_cong with a given variable name*) |
|
139 |
local |
|
140 |
val fun_cong' = fun_cong RS asm_rl; (*renumber f, g to prevent clashes with (a,0)*) |
|
141 |
val cx = hd (vars_of_thm fun_cong'); |
|
142 |
val ty = typ_of (ctyp_of_term cx); |
|
20445 | 143 |
val thy = theory_of_thm fun_cong; |
20419 | 144 |
fun mkvar a = cterm_of thy (Var((a,0),ty)); |
145 |
in |
|
146 |
fun xfun_cong x = Thm.instantiate ([], [(cx, mkvar x)]) fun_cong' |
|
147 |
end; |
|
148 |
||
20863
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
149 |
(*Removes the lambdas from an equation of the form t = (%x. u). A non-negative n, |
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
150 |
serves as an upper bound on how many to remove.*) |
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
151 |
fun strip_lambdas 0 th = th |
24669 | 152 |
| strip_lambdas n th = |
20863
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
153 |
case prop_of th of |
24669 | 154 |
_ $ (Const ("op =", _) $ _ $ Abs (x,_,_)) => |
155 |
strip_lambdas (n-1) (freeze_thm (th RS xfun_cong x)) |
|
156 |
| _ => th; |
|
20419 | 157 |
|
24669 | 158 |
val lambda_free = not o Term.has_abs; |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
159 |
|
24669 | 160 |
val monomorphic = not o Term.exists_type (Term.exists_subtype Term.is_TVar); |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
161 |
|
27184 | 162 |
val [f_B,g_B] = map (cterm_of @{theory}) (term_vars (prop_of @{thm abs_B})); |
163 |
val [g_C,f_C] = map (cterm_of @{theory}) (term_vars (prop_of @{thm abs_C})); |
|
164 |
val [f_S,g_S] = map (cterm_of @{theory}) (term_vars (prop_of @{thm abs_S})); |
|
20863
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
165 |
|
24827 | 166 |
(*FIXME: requires more use of cterm constructors*) |
167 |
fun abstract ct = |
|
26928 | 168 |
let val _ = Output.debug (fn()=>" abstraction: " ^ Display.string_of_cterm ct) |
25256
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
169 |
val Abs(x,_,body) = term_of ct |
24827 | 170 |
val thy = theory_of_cterm ct |
171 |
val Type("fun",[xT,bodyT]) = typ_of (ctyp_of_term ct) |
|
172 |
val cxT = ctyp_of thy xT and cbodyT = ctyp_of thy bodyT |
|
27184 | 173 |
fun makeK() = instantiate' [SOME cxT, SOME cbodyT] [SOME (cterm_of thy body)] @{thm abs_K} |
24827 | 174 |
in |
175 |
case body of |
|
176 |
Const _ => makeK() |
|
177 |
| Free _ => makeK() |
|
178 |
| Var _ => makeK() (*though Var isn't expected*) |
|
27184 | 179 |
| Bound 0 => instantiate' [SOME cxT] [] @{thm abs_I} (*identity: I*) |
24827 | 180 |
| rator$rand => |
27184 | 181 |
if loose_bvar1 (rator,0) then (*C or S*) |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
182 |
if loose_bvar1 (rand,0) then (*S*) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
183 |
let val crator = cterm_of thy (Abs(x,xT,rator)) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
184 |
val crand = cterm_of thy (Abs(x,xT,rand)) |
27184 | 185 |
val abs_S' = cterm_instantiate [(f_S,crator),(g_S,crand)] @{thm abs_S} |
186 |
val (_,rhs) = Thm.dest_equals (cprop_of abs_S') |
|
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
187 |
in |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
188 |
Thm.transitive abs_S' (Conv.binop_conv abstract rhs) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
189 |
end |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
190 |
else (*C*) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
191 |
let val crator = cterm_of thy (Abs(x,xT,rator)) |
27184 | 192 |
val abs_C' = cterm_instantiate [(f_C,crator),(g_C,cterm_of thy rand)] @{thm abs_C} |
193 |
val (_,rhs) = Thm.dest_equals (cprop_of abs_C') |
|
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
194 |
in |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
195 |
Thm.transitive abs_C' (Conv.fun_conv (Conv.arg_conv abstract) rhs) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
196 |
end |
27184 | 197 |
else if loose_bvar1 (rand,0) then (*B or eta*) |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
198 |
if rand = Bound 0 then eta_conversion ct |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
199 |
else (*B*) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
200 |
let val crand = cterm_of thy (Abs(x,xT,rand)) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
201 |
val crator = cterm_of thy rator |
27184 | 202 |
val abs_B' = cterm_instantiate [(f_B,crator),(g_B,crand)] @{thm abs_B} |
203 |
val (_,rhs) = Thm.dest_equals (cprop_of abs_B') |
|
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
204 |
in |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
205 |
Thm.transitive abs_B' (Conv.arg_conv abstract rhs) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
206 |
end |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
207 |
else makeK() |
24827 | 208 |
| _ => error "abstract: Bad term" |
209 |
end; |
|
20863
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
210 |
|
20419 | 211 |
(*Traverse a theorem, declaring abstraction function definitions. String s is the suggested |
212 |
prefix for the constants. Resulting theory is returned in the first theorem. *) |
|
24827 | 213 |
fun combinators_aux ct = |
214 |
if lambda_free (term_of ct) then reflexive ct |
|
215 |
else |
|
216 |
case term_of ct of |
|
217 |
Abs _ => |
|
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
218 |
let val (cv,cta) = Thm.dest_abs NONE ct |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
219 |
val (v,Tv) = (dest_Free o term_of) cv |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
220 |
val _ = Output.debug (fn()=>" recursion: " ^ Display.string_of_cterm cta); |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
221 |
val u_th = combinators_aux cta |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
222 |
val _ = Output.debug (fn()=>" returned " ^ Display.string_of_thm u_th); |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
223 |
val cu = Thm.rhs_of u_th |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
224 |
val comb_eq = abstract (Thm.cabs cv cu) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
225 |
in Output.debug (fn()=>" abstraction result: " ^ Display.string_of_thm comb_eq); |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
226 |
(transitive (abstract_rule v cv u_th) comb_eq) end |
24827 | 227 |
| t1 $ t2 => |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
228 |
let val (ct1,ct2) = Thm.dest_comb ct |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
229 |
in combination (combinators_aux ct1) (combinators_aux ct2) end; |
27184 | 230 |
|
24827 | 231 |
fun combinators th = |
27184 | 232 |
if lambda_free (prop_of th) then th |
24827 | 233 |
else |
26928 | 234 |
let val _ = Output.debug (fn()=>"Conversion to combinators: " ^ Display.string_of_thm th); |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
235 |
val th = Drule.eta_contraction_rule th |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
236 |
val eqth = combinators_aux (cprop_of th) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
237 |
val _ = Output.debug (fn()=>"Conversion result: " ^ Display.string_of_thm eqth); |
25256
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
238 |
in equal_elim eqth th end |
27184 | 239 |
handle THM (msg,_,_) => |
26928 | 240 |
(warning ("Error in the combinator translation of " ^ Display.string_of_thm th); |
25256
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
241 |
warning (" Exception message: " ^ msg); |
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
242 |
TrueI); (*A type variable of sort {} will cause make abstraction fail.*) |
16009 | 243 |
|
244 |
(*cterms are used throughout for efficiency*) |
|
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
245 |
val cTrueprop = Thm.cterm_of HOL.thy HOLogic.Trueprop; |
16009 | 246 |
|
247 |
(*cterm version of mk_cTrueprop*) |
|
248 |
fun c_mkTrueprop A = Thm.capply cTrueprop A; |
|
249 |
||
250 |
(*Given an abstraction over n variables, replace the bound variables by free |
|
251 |
ones. Return the body, along with the list of free variables.*) |
|
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
252 |
fun c_variant_abs_multi (ct0, vars) = |
16009 | 253 |
let val (cv,ct) = Thm.dest_abs NONE ct0 |
254 |
in c_variant_abs_multi (ct, cv::vars) end |
|
255 |
handle CTERM _ => (ct0, rev vars); |
|
256 |
||
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
257 |
(*Given the definition of a Skolem function, return a theorem to replace |
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
258 |
an existential formula by a use of that function. |
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
259 |
Example: "EX x. x : A & x ~: B ==> sko A B : A & sko A B ~: B" [.] *) |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
260 |
fun skolem_of_def def = |
22902
ac833b4bb7ee
moved some Drule operations to Thm (see more_thm.ML);
wenzelm
parents:
22846
diff
changeset
|
261 |
let val (c,rhs) = Thm.dest_equals (cprop_of (freeze_thm def)) |
16009 | 262 |
val (ch, frees) = c_variant_abs_multi (rhs, []) |
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
263 |
val (chilbert,cabs) = Thm.dest_comb ch |
26627
dac6d56b7c8d
rep_cterm/rep_thm: no longer dereference theory_ref;
wenzelm
parents:
26618
diff
changeset
|
264 |
val thy = Thm.theory_of_cterm chilbert |
dac6d56b7c8d
rep_cterm/rep_thm: no longer dereference theory_ref;
wenzelm
parents:
26618
diff
changeset
|
265 |
val t = Thm.term_of chilbert |
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
266 |
val T = case t of Const ("Hilbert_Choice.Eps", Type("fun",[_,T])) => T |
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
267 |
| _ => raise THM ("skolem_of_def: expected Eps", 0, [def]) |
22596 | 268 |
val cex = Thm.cterm_of thy (HOLogic.exists_const T) |
16009 | 269 |
val ex_tm = c_mkTrueprop (Thm.capply cex cabs) |
270 |
and conc = c_mkTrueprop (Drule.beta_conv cabs (Drule.list_comb(c,frees))); |
|
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
271 |
fun tacf [prem] = rewrite_goals_tac [def] THEN rtac (prem RS someI_ex) 1 |
23352 | 272 |
in Goal.prove_internal [ex_tm] conc tacf |
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
273 |
|> forall_intr_list frees |
26653 | 274 |
|> Thm.forall_elim_vars 0 (*Introduce Vars, but don't discharge defs.*) |
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
275 |
|> Thm.varifyT |
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
276 |
end; |
16009 | 277 |
|
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
278 |
|
20863
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
279 |
(*Converts an Isabelle theorem (intro, elim or simp format, even higher-order) into NNF.*) |
24937
340523598914
context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents:
24854
diff
changeset
|
280 |
fun to_nnf th ctxt0 = |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
281 |
let val th1 = th |> transform_elim |> zero_var_indexes |
27184 | 282 |
val ((_,[th2]),ctxt) = Variable.import_thms true [th1] ctxt0 |
24937
340523598914
context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents:
24854
diff
changeset
|
283 |
val th3 = th2 |> Conv.fconv_rule ObjectLogic.atomize |> Meson.make_nnf |> strip_lambdas ~1 |
340523598914
context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents:
24854
diff
changeset
|
284 |
in (th3, ctxt) end; |
16009 | 285 |
|
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
286 |
(*Generate Skolem functions for a theorem supplied in nnf*) |
24937
340523598914
context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents:
24854
diff
changeset
|
287 |
fun assume_skolem_of_def s th = |
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
288 |
map (skolem_of_def o assume o (cterm_of (theory_of_thm th))) (assume_skofuns s th); |
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
289 |
|
24669 | 290 |
fun assert_lambda_free ths msg = |
20863
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
291 |
case filter (not o lambda_free o prop_of) ths of |
4ee61dbf192d
improvements to abstraction, ensuring more re-use of abstraction functions
paulson
parents:
20789
diff
changeset
|
292 |
[] => () |
26928 | 293 |
| ths' => error (msg ^ "\n" ^ cat_lines (map Display.string_of_thm ths')); |
20457
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20445
diff
changeset
|
294 |
|
25007 | 295 |
|
27184 | 296 |
(*** Blacklisting (duplicated in ResAtp?) ***) |
25007 | 297 |
|
298 |
val max_lambda_nesting = 3; |
|
27184 | 299 |
|
25007 | 300 |
fun excessive_lambdas (f$t, k) = excessive_lambdas (f,k) orelse excessive_lambdas (t,k) |
301 |
| excessive_lambdas (Abs(_,_,t), k) = k=0 orelse excessive_lambdas (t,k-1) |
|
302 |
| excessive_lambdas _ = false; |
|
303 |
||
304 |
fun is_formula_type T = (T = HOLogic.boolT orelse T = propT); |
|
305 |
||
306 |
(*Don't count nested lambdas at the level of formulas, as they are quantifiers*) |
|
307 |
fun excessive_lambdas_fm Ts (Abs(_,T,t)) = excessive_lambdas_fm (T::Ts) t |
|
308 |
| excessive_lambdas_fm Ts t = |
|
309 |
if is_formula_type (fastype_of1 (Ts, t)) |
|
310 |
then exists (excessive_lambdas_fm Ts) (#2 (strip_comb t)) |
|
311 |
else excessive_lambdas (t, max_lambda_nesting); |
|
312 |
||
25256
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
313 |
(*The max apply_depth of any metis call in MetisExamples (on 31-10-2007) was 11.*) |
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
314 |
val max_apply_depth = 15; |
27184 | 315 |
|
25256
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
316 |
fun apply_depth (f$t) = Int.max (apply_depth f, apply_depth t + 1) |
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
317 |
| apply_depth (Abs(_,_,t)) = apply_depth t |
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
318 |
| apply_depth _ = 0; |
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
319 |
|
27184 | 320 |
fun too_complex t = |
321 |
apply_depth t > max_apply_depth orelse |
|
26562
9d25ef112cf6
* Metis: the maximum number of clauses that can be produced from a theorem is now given by the attribute max_clauses. Theorems that exceed this number are ignored, with a warning printed.
paulson
parents:
25761
diff
changeset
|
322 |
Meson.too_many_clauses NONE t orelse |
25256
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
323 |
excessive_lambdas_fm [] t; |
27184 | 324 |
|
25243 | 325 |
fun is_strange_thm th = |
326 |
case head_of (concl_of th) of |
|
327 |
Const (a,_) => (a <> "Trueprop" andalso a <> "==") |
|
328 |
| _ => false; |
|
329 |
||
27184 | 330 |
fun bad_for_atp th = |
331 |
PureThy.is_internal th |
|
332 |
orelse too_complex (prop_of th) |
|
333 |
orelse exists_type type_has_empty_sort (prop_of th) |
|
25761 | 334 |
orelse is_strange_thm th; |
25243 | 335 |
|
25007 | 336 |
val multi_base_blacklist = |
25256
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
337 |
["defs","select_defs","update_defs","induct","inducts","split","splits","split_asm", |
fe467fdf129a
Catch exceptions arising during the abstraction operation.
paulson
parents:
25243
diff
changeset
|
338 |
"cases","ext_cases"]; (*FIXME: put other record thms here, or use the "Internal" marker*) |
25007 | 339 |
|
21071 | 340 |
(*Keep the full complexity of the original name*) |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
21646
diff
changeset
|
341 |
fun flatten_name s = space_implode "_X" (NameSpace.explode s); |
21071 | 342 |
|
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
343 |
fun fake_name th = |
24669 | 344 |
if PureThy.has_name_hint th then flatten_name (PureThy.get_name_hint th) |
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
345 |
else gensym "unknown_thm_"; |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
346 |
|
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
347 |
fun name_or_string th = |
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
348 |
if PureThy.has_name_hint th then PureThy.get_name_hint th |
26928 | 349 |
else Display.string_of_thm th; |
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
350 |
|
27184 | 351 |
(*Skolemize a named theorem, with Skolem functions as additional premises.*) |
352 |
fun skolem_thm (s, th) = |
|
353 |
if member (op =) multi_base_blacklist (Sign.base_name s) orelse bad_for_atp th then [] |
|
354 |
else |
|
355 |
let |
|
356 |
val ctxt0 = Variable.thm_context th |
|
357 |
val (nnfth, ctxt1) = to_nnf th ctxt0 |
|
358 |
val (cnfs, ctxt2) = Meson.make_cnf (assume_skolem_of_def s nnfth) nnfth ctxt1 |
|
359 |
in cnfs |> map combinators |> Variable.export ctxt2 ctxt0 |> Meson.finish_cnf end |
|
360 |
handle THM _ => []; |
|
361 |
||
18510
0a6c24f549c3
the "skolem" attribute and better initialization of the clause database
paulson
parents:
18404
diff
changeset
|
362 |
(*Declare Skolem functions for a theorem, supplied in nnf and with its name. |
0a6c24f549c3
the "skolem" attribute and better initialization of the clause database
paulson
parents:
18404
diff
changeset
|
363 |
It returns a modified theory, unless skolemization fails.*) |
27184 | 364 |
fun skolem (name, th0) thy = |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
365 |
let |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
366 |
val th = Thm.transfer thy th0 |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
367 |
val ctxt0 = Variable.thm_context th |
24937
340523598914
context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents:
24854
diff
changeset
|
368 |
in |
27184 | 369 |
try (to_nnf th) ctxt0 |> Option.map (fn (nnfth, ctxt1) => |
370 |
let |
|
371 |
val s = flatten_name name |
|
372 |
val (defs, thy') = declare_skofuns s nnfth thy |
|
373 |
val (cnfs, ctxt2) = Meson.make_cnf (map skolem_of_def defs) nnfth ctxt1 |
|
374 |
val cnfs' = cnfs |> map combinators |> Variable.export ctxt2 ctxt0 |
|
375 |
|> Meson.finish_cnf |> map Thm.close_derivation |
|
376 |
in (cnfs', thy') end |
|
377 |
handle Clausify_failure thy_e => ([], thy_e)) (* FIXME !? *) |
|
24937
340523598914
context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents:
24854
diff
changeset
|
378 |
end; |
16009 | 379 |
|
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
380 |
(*The cache prevents repeated clausification of a theorem, and also repeated declaration of |
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
381 |
Skolem functions.*) |
22516 | 382 |
structure ThmCache = TheoryDataFun |
22846 | 383 |
( |
27184 | 384 |
type T = thm list Thmtab.table * unit Symtab.table |
385 |
val empty = (Thmtab.empty, Symtab.empty) |
|
26618 | 386 |
val copy = I; |
387 |
val extend = I; |
|
27184 | 388 |
fun merge _ ((cache1, seen1), (cache2, seen2)) : T = |
389 |
(Thmtab.merge (K true) (cache1, cache2), Symtab.merge (K true) (seen1, seen2)); |
|
22846 | 390 |
); |
22516 | 391 |
|
27184 | 392 |
val lookup_cache = Thmtab.lookup o #1 o ThmCache.get; |
393 |
val already_seen = Symtab.defined o #2 o ThmCache.get; |
|
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
394 |
|
27184 | 395 |
val update_cache = ThmCache.map o apfst o Thmtab.update; |
396 |
fun mark_seen name = ThmCache.map (apsnd (Symtab.update (name, ()))); |
|
25007 | 397 |
|
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
398 |
(*Exported function to convert Isabelle theorems into axiom clauses*) |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
399 |
fun cnf_axiom thy th0 = |
27184 | 400 |
let val th = Thm.transfer thy th0 in |
401 |
case lookup_cache thy th of |
|
402 |
NONE => map Thm.close_derivation (skolem_thm (fake_name th, th)) |
|
403 |
| SOME cls => cls |
|
22516 | 404 |
end; |
15347 | 405 |
|
18141
89e2e8bed08f
Skolemization by inference, but not quite finished
paulson
parents:
18009
diff
changeset
|
406 |
|
15872 | 407 |
(**** Extract and Clausify theorems from a theory's claset and simpset ****) |
15347 | 408 |
|
27184 | 409 |
fun pairname th = (PureThy.get_name_hint th, th); |
410 |
||
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
17412
diff
changeset
|
411 |
fun rules_of_claset cs = |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
17412
diff
changeset
|
412 |
let val {safeIs,safeEs,hazIs,hazEs,...} = rep_cs cs |
19175 | 413 |
val intros = safeIs @ hazIs |
18532 | 414 |
val elims = map Classical.classical_rule (safeEs @ hazEs) |
17404
d16c3a62c396
the experimental tagging system, and the usual tidying
paulson
parents:
17279
diff
changeset
|
415 |
in |
22130 | 416 |
Output.debug (fn () => "rules_of_claset intros: " ^ Int.toString(length intros) ^ |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
17412
diff
changeset
|
417 |
" elims: " ^ Int.toString(length elims)); |
20017
a2070352371c
made the conversion of elimination rules more robust
paulson
parents:
19894
diff
changeset
|
418 |
map pairname (intros @ elims) |
17404
d16c3a62c396
the experimental tagging system, and the usual tidying
paulson
parents:
17279
diff
changeset
|
419 |
end; |
15347 | 420 |
|
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
17412
diff
changeset
|
421 |
fun rules_of_simpset ss = |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
17412
diff
changeset
|
422 |
let val ({rules,...}, _) = rep_ss ss |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
17412
diff
changeset
|
423 |
val simps = Net.entries rules |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
424 |
in |
22130 | 425 |
Output.debug (fn () => "rules_of_simpset: " ^ Int.toString(length simps)); |
426 |
map (fn r => (#name r, #thm r)) simps |
|
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
17412
diff
changeset
|
427 |
end; |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
17412
diff
changeset
|
428 |
|
21505 | 429 |
fun claset_rules_of ctxt = rules_of_claset (local_claset_of ctxt); |
430 |
fun simpset_rules_of ctxt = rules_of_simpset (local_simpset_of ctxt); |
|
19196
62ee8c10d796
Added functions to retrieve local and global atpset rules.
mengj
parents:
19175
diff
changeset
|
431 |
|
24042 | 432 |
fun atpset_rules_of ctxt = map pairname (ResAtpset.get ctxt); |
20774 | 433 |
|
15347 | 434 |
|
22471 | 435 |
(**** Translate a set of theorems into CNF ****) |
15347 | 436 |
|
19894 | 437 |
fun pair_name_cls k (n, []) = [] |
438 |
| pair_name_cls k (n, cls::clss) = (cls, (n,k)) :: pair_name_cls (k+1) (n, clss) |
|
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
439 |
|
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
440 |
fun cnf_rules_pairs_aux _ pairs [] = pairs |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
441 |
| cnf_rules_pairs_aux thy pairs ((name,th)::ths) = |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
442 |
let val pairs' = (pair_name_cls 0 (name, cnf_axiom thy th)) @ pairs |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
443 |
handle THM _ => pairs | ResClause.CLAUSE _ => pairs |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
444 |
in cnf_rules_pairs_aux thy pairs' ths end; |
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
445 |
|
21290
33b6bb5d6ab8
Improvement to classrel clauses: now outputs the minimum needed.
paulson
parents:
21254
diff
changeset
|
446 |
(*The combination of rev and tail recursion preserves the original order*) |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
447 |
fun cnf_rules_pairs thy l = cnf_rules_pairs_aux thy [] (rev l); |
19353 | 448 |
|
19196
62ee8c10d796
Added functions to retrieve local and global atpset rules.
mengj
parents:
19175
diff
changeset
|
449 |
|
27184 | 450 |
(**** Convert all facts of the theory into clauses (ResClause.clause, or ResHolClause.clause) ****) |
15347 | 451 |
|
27184 | 452 |
(*Populate the clause cache using the supplied theorem. Return the clausal form |
453 |
and modified theory.*) |
|
454 |
fun skolem_cache_thm (name, th) thy = |
|
455 |
if bad_for_atp th then thy |
|
456 |
else |
|
457 |
(case lookup_cache thy th of |
|
458 |
SOME _ => thy |
|
459 |
| NONE => |
|
460 |
(case skolem (name, th) thy of |
|
461 |
NONE => thy |
|
462 |
| SOME (cls, thy') => update_cache (th, cls) thy')); |
|
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
463 |
|
27184 | 464 |
fun skolem_cache_fact (name, ths) (changed, thy) = |
465 |
if (Sign.base_name name) mem_string multi_base_blacklist orelse already_seen thy name |
|
466 |
then (changed, thy) |
|
467 |
else (true, thy |> mark_seen name |> fold skolem_cache_thm (PureThy.name_multi name ths)); |
|
24742
73b8b42a36b6
removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents:
24669
diff
changeset
|
468 |
|
27184 | 469 |
fun saturate_skolem_cache thy = |
470 |
(case Facts.fold_static skolem_cache_fact (PureThy.facts_of thy) (false, thy) of |
|
471 |
(false, _) => NONE |
|
472 |
| (true, thy') => SOME thy'); |
|
473 |
||
24854 | 474 |
|
27184 | 475 |
val suppress_endtheory = ref false; |
476 |
||
477 |
fun clause_cache_endtheory thy = |
|
478 |
if ! suppress_endtheory then NONE |
|
479 |
else saturate_skolem_cache thy; |
|
480 |
||
20457
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20445
diff
changeset
|
481 |
|
22516 | 482 |
(*The cache can be kept smaller by inspecting the prop of each thm. Can ignore all that are |
483 |
lambda_free, but then the individual theory caches become much bigger.*) |
|
21071 | 484 |
|
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
485 |
|
16563 | 486 |
(*** meson proof methods ***) |
487 |
||
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
488 |
(*Expand all new*definitions of abstraction or Skolem functions in a proof state.*) |
24827 | 489 |
fun is_absko (Const ("==", _) $ Free (a,_) $ u) = String.isPrefix "sko_" a |
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
490 |
| is_absko _ = false; |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
491 |
|
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
492 |
fun is_okdef xs (Const ("==", _) $ t $ u) = (*Definition of Free, not in certain terms*) |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
493 |
is_Free t andalso not (member (op aconv) xs t) |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
494 |
| is_okdef _ _ = false |
22724
3002683a6e0f
Fixes for proof reconstruction, especially involving abstractions and definitions
paulson
parents:
22691
diff
changeset
|
495 |
|
24215 | 496 |
(*This function tries to cope with open locales, which introduce hypotheses of the form |
497 |
Free == t, conjecture clauses, which introduce various hypotheses, and also definitions |
|
24827 | 498 |
of sko_ functions. *) |
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
499 |
fun expand_defs_tac st0 st = |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
500 |
let val hyps0 = #hyps (rep_thm st0) |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
501 |
val hyps = #hyps (crep_thm st) |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
502 |
val newhyps = filter_out (member (op aconv) hyps0 o Thm.term_of) hyps |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
503 |
val defs = filter (is_absko o Thm.term_of) newhyps |
24669 | 504 |
val remaining_hyps = filter_out (member (op aconv) (map Thm.term_of defs)) |
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
505 |
(map Thm.term_of hyps) |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
506 |
val fixed = term_frees (concl_of st) @ |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
507 |
foldl (gen_union (op aconv)) [] (map term_frees remaining_hyps) |
26928 | 508 |
in Output.debug (fn _ => "expand_defs_tac: " ^ Display.string_of_thm st); |
509 |
Output.debug (fn _ => " st0: " ^ Display.string_of_thm st0); |
|
510 |
Output.debug (fn _ => " defs: " ^ commas (map Display.string_of_cterm defs)); |
|
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
511 |
Seq.of_list [LocalDefs.expand (filter (is_okdef fixed o Thm.term_of) defs) st] |
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
512 |
end; |
22724
3002683a6e0f
Fixes for proof reconstruction, especially involving abstractions and definitions
paulson
parents:
22691
diff
changeset
|
513 |
|
22731
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
514 |
|
abfdccaed085
trying to make single-step proofs work better, especially if they contain
paulson
parents:
22724
diff
changeset
|
515 |
fun meson_general_tac ths i st0 = |
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
516 |
let |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
517 |
val thy = Thm.theory_of_thm st0 |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
518 |
val _ = Output.debug (fn () => "Meson called: " ^ cat_lines (map Display.string_of_thm ths)) |
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
519 |
in (Meson.meson_claset_tac (maps (cnf_axiom thy) ths) HOL_cs i THEN expand_defs_tac st0) st0 end; |
22724
3002683a6e0f
Fixes for proof reconstruction, especially involving abstractions and definitions
paulson
parents:
22691
diff
changeset
|
520 |
|
21588 | 521 |
val meson_method_setup = Method.add_methods |
522 |
[("meson", Method.thms_args (fn ths => |
|
22724
3002683a6e0f
Fixes for proof reconstruction, especially involving abstractions and definitions
paulson
parents:
22691
diff
changeset
|
523 |
Method.SIMPLE_METHOD' (CHANGED_PROP o meson_general_tac ths)), |
21588 | 524 |
"MESON resolution proof procedure")]; |
15347 | 525 |
|
27179
8f29fed3dc9a
ResAxioms.cnf_axiom/cnf_rules_pairs: pass explicit theory context;
wenzelm
parents:
27174
diff
changeset
|
526 |
|
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
527 |
(*** Converting a subgoal into negated conjecture clauses. ***) |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
528 |
|
24300 | 529 |
val neg_skolemize_tac = EVERY' [rtac ccontr, ObjectLogic.atomize_prems_tac, Meson.skolemize_tac]; |
22471 | 530 |
|
24937
340523598914
context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents:
24854
diff
changeset
|
531 |
fun neg_clausify sts = |
340523598914
context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents:
24854
diff
changeset
|
532 |
sts |> Meson.make_clauses |> map combinators |> Meson.finish_cnf; |
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
533 |
|
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
534 |
fun neg_conjecture_clauses st0 n = |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
535 |
let val st = Seq.hd (neg_skolemize_tac n st0) |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
536 |
val (params,_,_) = strip_context (Logic.nth_prem (n, Thm.prop_of st)) |
22516 | 537 |
in (neg_clausify (Option.valOf (metahyps_thms n st)), params) end |
538 |
handle Option => raise ERROR "unable to Skolemize subgoal"; |
|
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
539 |
|
24669 | 540 |
(*Conversion of a subgoal to conjecture clauses. Each clause has |
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
541 |
leading !!-bound universal variables, to express generality. *) |
24669 | 542 |
val neg_clausify_tac = |
543 |
neg_skolemize_tac THEN' |
|
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
544 |
SUBGOAL |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
545 |
(fn (prop,_) => |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
546 |
let val ts = Logic.strip_assums_hyp prop |
24669 | 547 |
in EVERY1 |
548 |
[METAHYPS |
|
549 |
(fn hyps => |
|
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
550 |
(Method.insert_tac |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
551 |
(map forall_intr_vars (neg_clausify hyps)) 1)), |
24669 | 552 |
REPEAT_DETERM_N (length ts) o (etac thin_rl)] |
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
553 |
end); |
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
554 |
|
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
555 |
val setup_methods = Method.add_methods |
24669 | 556 |
[("neg_clausify", Method.no_args (Method.SIMPLE_METHOD' neg_clausify_tac), |
21999
0cf192e489e2
improvements to proof reconstruction. Some files loaded in a different order
paulson
parents:
21900
diff
changeset
|
557 |
"conversion of goal to conjecture clauses")]; |
24669 | 558 |
|
27184 | 559 |
|
560 |
(** Attribute for converting a theorem into clauses **) |
|
561 |
||
562 |
val clausify = Attrib.syntax (Scan.lift Args.nat |
|
563 |
>> (fn i => Thm.rule_attribute (fn context => fn th => |
|
564 |
Meson.make_meta_clause (nth (cnf_axiom (Context.theory_of context) th) i)))); |
|
565 |
||
566 |
val setup_attrs = Attrib.add_attributes |
|
567 |
[("clausify", clausify, "conversion of theorem to clauses")]; |
|
568 |
||
569 |
||
570 |
||
571 |
(** setup **) |
|
572 |
||
573 |
val setup = |
|
574 |
meson_method_setup #> |
|
575 |
setup_methods #> |
|
576 |
setup_attrs #> |
|
577 |
perhaps saturate_skolem_cache #> |
|
578 |
Theory.at_end clause_cache_endtheory; |
|
18510
0a6c24f549c3
the "skolem" attribute and better initialization of the clause database
paulson
parents:
18404
diff
changeset
|
579 |
|
20461
d689ad772b2c
skolem_cache_thm: Drule.close_derivation on clauses preserves some space;
wenzelm
parents:
20457
diff
changeset
|
580 |
end; |
27184 | 581 |