src/HOL/Tools/res_axioms.ML
changeset 20071 8f3e1ddb50e6
parent 20017 a2070352371c
child 20292 6f2b8ed987ec
equal deleted inserted replaced
20070:3f31fb81b83a 20071:8f3e1ddb50e6
   143 	    in dec_sko (subst_bound (list_comb(c,args), p)) 
   143 	    in dec_sko (subst_bound (list_comb(c,args), p)) 
   144 	               (n+1, (thy'', get_axiom thy'' cdef :: axs)) 
   144 	               (n+1, (thy'', get_axiom thy'' cdef :: axs)) 
   145 	    end
   145 	    end
   146 	| dec_sko (Const ("All",_) $ (xtp as Abs(a,T,p))) (n, thx) =
   146 	| dec_sko (Const ("All",_) $ (xtp as Abs(a,T,p))) (n, thx) =
   147 	    (*Universal quant: insert a free variable into body and continue*)
   147 	    (*Universal quant: insert a free variable into body and continue*)
   148 	    let val fname = variant (add_term_names (p,[])) a
   148 	    let val fname = Name.variant (add_term_names (p,[])) a
   149 	    in dec_sko (subst_bound (Free(fname,T), p)) (n, thx) end
   149 	    in dec_sko (subst_bound (Free(fname,T), p)) (n, thx) end
   150 	| dec_sko (Const ("op &", _) $ p $ q) nthy = dec_sko q (dec_sko p nthy)
   150 	| dec_sko (Const ("op &", _) $ p $ q) nthy = dec_sko q (dec_sko p nthy)
   151 	| dec_sko (Const ("op |", _) $ p $ q) nthy = dec_sko q (dec_sko p nthy)
   151 	| dec_sko (Const ("op |", _) $ p $ q) nthy = dec_sko q (dec_sko p nthy)
   152 	| dec_sko (Const ("Trueprop", _) $ p) nthy = dec_sko p nthy
   152 	| dec_sko (Const ("Trueprop", _) $ p) nthy = dec_sko p nthy
   153 	| dec_sko t nthx = nthx (*Do nothing otherwise*)
   153 	| dec_sko t nthx = nthx (*Do nothing otherwise*)
   155 
   155 
   156 (*Traverse a theorem, accumulating Skolem function definitions.*)
   156 (*Traverse a theorem, accumulating Skolem function definitions.*)
   157 fun assume_skofuns th =
   157 fun assume_skofuns th =
   158   let fun dec_sko (Const ("Ex",_) $ (xtp as Abs(_,T,p))) defs =
   158   let fun dec_sko (Const ("Ex",_) $ (xtp as Abs(_,T,p))) defs =
   159 	    (*Existential: declare a Skolem function, then insert into body and continue*)
   159 	    (*Existential: declare a Skolem function, then insert into body and continue*)
   160 	    let val name = variant (add_term_names (p,[])) (gensym "sko_")
   160 	    let val name = Name.variant (add_term_names (p,[])) (gensym "sko_")
   161                 val skos = map (#1 o Logic.dest_equals) defs  (*existing sko fns*)
   161                 val skos = map (#1 o Logic.dest_equals) defs  (*existing sko fns*)
   162 		val args = term_frees xtp \\ skos  (*the formal parameters*)
   162 		val args = term_frees xtp \\ skos  (*the formal parameters*)
   163 		val Ts = map type_of args
   163 		val Ts = map type_of args
   164 		val cT = Ts ---> T
   164 		val cT = Ts ---> T
   165 		val c = Free (name, cT)
   165 		val c = Free (name, cT)
   170 	    in dec_sko (subst_bound (list_comb(c,args), p)) 
   170 	    in dec_sko (subst_bound (list_comb(c,args), p)) 
   171 	               (def :: defs)
   171 	               (def :: defs)
   172 	    end
   172 	    end
   173 	| dec_sko (Const ("All",_) $ (xtp as Abs(a,T,p))) defs =
   173 	| dec_sko (Const ("All",_) $ (xtp as Abs(a,T,p))) defs =
   174 	    (*Universal quant: insert a free variable into body and continue*)
   174 	    (*Universal quant: insert a free variable into body and continue*)
   175 	    let val fname = variant (add_term_names (p,[])) a
   175 	    let val fname = Name.variant (add_term_names (p,[])) a
   176 	    in dec_sko (subst_bound (Free(fname,T), p)) defs end
   176 	    in dec_sko (subst_bound (Free(fname,T), p)) defs end
   177 	| dec_sko (Const ("op &", _) $ p $ q) defs = dec_sko q (dec_sko p defs)
   177 	| dec_sko (Const ("op &", _) $ p $ q) defs = dec_sko q (dec_sko p defs)
   178 	| dec_sko (Const ("op |", _) $ p $ q) defs = dec_sko q (dec_sko p defs)
   178 	| dec_sko (Const ("op |", _) $ p $ q) defs = dec_sko q (dec_sko p defs)
   179 	| dec_sko (Const ("Trueprop", _) $ p) defs = dec_sko p defs
   179 	| dec_sko (Const ("Trueprop", _) $ p) defs = dec_sko p defs
   180 	| dec_sko t defs = defs (*Do nothing otherwise*)
   180 	| dec_sko t defs = defs (*Do nothing otherwise*)