equal
deleted
inserted
replaced
296 in |
296 in |
297 (case elem of |
297 (case elem of |
298 Assumes asms => Assumes (asms |> map (fn (a, propps) => |
298 Assumes asms => Assumes (asms |> map (fn (a, propps) => |
299 (a, map (fn (t, ps) => (close_frees t, no_binds ps)) propps))) |
299 (a, map (fn (t, ps) => (close_frees t, no_binds ps)) propps))) |
300 | Defines defs => Defines (defs |> map (fn ((name, atts), (t, ps)) => |
300 | Defines defs => Defines (defs |> map (fn ((name, atts), (t, ps)) => |
301 let val ((c, _), t') = LocalDefs.cert_def ctxt (close_frees t) |
301 let val ((c, _), t') = Local_Defs.cert_def ctxt (close_frees t) |
302 in ((Thm.def_binding_optional (Binding.name c) name, atts), (t', no_binds ps)) end)) |
302 in ((Thm.def_binding_optional (Binding.name c) name, atts), (t', no_binds ps)) end)) |
303 | e => e) |
303 | e => e) |
304 end; |
304 end; |
305 |
305 |
306 fun finish_primitive parms _ (Fixes fixes) = Fixes (map (fn (binding, _, mx) => |
306 fun finish_primitive parms _ (Fixes fixes) = Fixes (map (fn (binding, _, mx) => |
511 |
511 |
512 val norm_term = Envir.beta_norm oo Term.subst_atomic; |
512 val norm_term = Envir.beta_norm oo Term.subst_atomic; |
513 |
513 |
514 fun bind_def ctxt eq (xs, env, eqs) = |
514 fun bind_def ctxt eq (xs, env, eqs) = |
515 let |
515 let |
516 val _ = LocalDefs.cert_def ctxt eq; |
516 val _ = Local_Defs.cert_def ctxt eq; |
517 val ((y, T), b) = LocalDefs.abs_def eq; |
517 val ((y, T), b) = Local_Defs.abs_def eq; |
518 val b' = norm_term env b; |
518 val b' = norm_term env b; |
519 fun err msg = error (msg ^ ": " ^ quote y); |
519 fun err msg = error (msg ^ ": " ^ quote y); |
520 in |
520 in |
521 case filter (fn (Free (y', _), _) => y = y' | _ => false) env of |
521 case filter (fn (Free (y', _), _) => y = y' | _ => false) env of |
522 [] => (Term.add_frees b' xs, (Free (y, T), b') :: env, eq :: eqs) | |
522 [] => (Term.add_frees b' xs, (Free (y, T), b') :: env, eq :: eqs) | |
806 fun note_eqns raw_eqns thy = |
806 fun note_eqns raw_eqns thy = |
807 let |
807 let |
808 val eqns = map (Morphism.thm (export' $> export)) raw_eqns; |
808 val eqns = map (Morphism.thm (export' $> export)) raw_eqns; |
809 val eqn_attrss = map2 (fn attrs => fn eqn => |
809 val eqn_attrss = map2 (fn attrs => fn eqn => |
810 ((apsnd o map) (Attrib.attribute_i thy) attrs, [([eqn], [])])) attrss eqns; |
810 ((apsnd o map) (Attrib.attribute_i thy) attrs, [([eqn], [])])) attrss eqns; |
811 fun meta_rewrite thy = map (LocalDefs.meta_rewrite_rule (ProofContext.init thy) #> |
811 fun meta_rewrite thy = |
812 Drule.abs_def) o maps snd; |
812 map (Local_Defs.meta_rewrite_rule (ProofContext.init thy) #> Drule.abs_def) o maps snd; |
813 in |
813 in |
814 thy |
814 thy |
815 |> PureThy.note_thmss Thm.lemmaK eqn_attrss |
815 |> PureThy.note_thmss Thm.lemmaK eqn_attrss |
816 |-> (fn facts => `(fn thy => meta_rewrite thy facts)) |
816 |-> (fn facts => `(fn thy => meta_rewrite thy facts)) |
817 end; |
817 end; |