equal
deleted
inserted
replaced
130 end |
130 end |
131 |
131 |
132 val def_norm = |
132 val def_norm = |
133 let |
133 let |
134 val cert = cterm_of (sign_of ProtoPure.thy) |
134 val cert = cterm_of (sign_of ProtoPure.thy) |
135 val aT = TFree("'a",logicS) |
135 val aT = TFree("'a",[]) |
136 val bT = TFree("'b",logicS) |
136 val bT = TFree("'b",[]) |
137 val v = Free("v",aT) |
137 val v = Free("v",aT) |
138 val P = Free("P",aT-->bT) |
138 val P = Free("P",aT-->bT) |
139 val Q = Free("Q",aT-->bT) |
139 val Q = Free("Q",aT-->bT) |
140 val cvPQ = cert (list_all ([("v",aT)],Logic.mk_equals(P $ Bound 0,Q $ Bound 0))) |
140 val cvPQ = cert (list_all ([("v",aT)],Logic.mk_equals(P $ Bound 0,Q $ Bound 0))) |
141 val cPQ = cert (Logic.mk_equals(P,Q)) |
141 val cPQ = cert (Logic.mk_equals(P,Q)) |
157 end |
157 end |
158 |
158 |
159 val all_comm = |
159 val all_comm = |
160 let |
160 let |
161 val cert = cterm_of (sign_of ProtoPure.thy) |
161 val cert = cterm_of (sign_of ProtoPure.thy) |
162 val xT = TFree("'a",logicS) |
162 val xT = TFree("'a",[]) |
163 val yT = TFree("'b",logicS) |
163 val yT = TFree("'b",[]) |
164 val P = Free("P",xT-->yT-->propT) |
164 val P = Free("P",xT-->yT-->propT) |
165 val lhs = all xT $ (Abs("x",xT,all yT $ (Abs("y",yT,P $ Bound 1 $ Bound 0)))) |
165 val lhs = all xT $ (Abs("x",xT,all yT $ (Abs("y",yT,P $ Bound 1 $ Bound 0)))) |
166 val rhs = all yT $ (Abs("y",yT,all xT $ (Abs("x",xT,P $ Bound 0 $ Bound 1)))) |
166 val rhs = all yT $ (Abs("y",yT,all xT $ (Abs("x",xT,P $ Bound 0 $ Bound 1)))) |
167 val cl = cert lhs |
167 val cl = cert lhs |
168 val cr = cert rhs |
168 val cr = cert rhs |
402 else None |
402 else None |
403 | _ => (error ("Bad eta_expand argument" ^ (string_of_cterm (cterm_of sg t))); None) |
403 | _ => (error ("Bad eta_expand argument" ^ (string_of_cterm (cterm_of sg t))); None) |
404 end |
404 end |
405 handle e => (writeln "eta_expand internal error";print_exn e) |
405 handle e => (writeln "eta_expand internal error";print_exn e) |
406 |
406 |
407 fun mk_tfree s = TFree("'"^s,logicS) |
407 fun mk_tfree s = TFree("'"^s,[]) |
408 val xT = mk_tfree "a" |
408 val xT = mk_tfree "a" |
409 val yT = mk_tfree "b" |
409 val yT = mk_tfree "b" |
410 val P = Var(("P",0),xT-->yT-->propT) |
410 val P = Var(("P",0),xT-->yT-->propT) |
411 val Q = Var(("Q",0),xT-->yT) |
411 val Q = Var(("Q",0),xT-->yT) |
412 val R = Var(("R",0),xT-->yT) |
412 val R = Var(("R",0),xT-->yT) |
493 in |
493 in |
494 th |
494 th |
495 end |
495 end |
496 handle e => (writeln "norm_term internal error"; print_sign_exn (sign_of thy) e) |
496 handle e => (writeln "norm_term internal error"; print_sign_exn (sign_of thy) e) |
497 |
497 |
498 fun is_logic_var sg v = |
|
499 Type.of_sort (Sign.tsig_of sg) (type_of v,logicS) |
|
500 |
498 |
501 (* Closes a theorem with respect to free and schematic variables (does |
499 (* Closes a theorem with respect to free and schematic variables (does |
502 not touch type variables, though). *) |
500 not touch type variables, though). *) |
503 |
501 |
504 fun close_thm th = |
502 fun close_thm th = |
505 let |
503 let |
506 val sg = sign_of_thm th |
504 val sg = sign_of_thm th |
507 val c = prop_of th |
505 val c = prop_of th |
508 val all_vars = add_term_frees (c,add_term_vars(c,[])) |
506 val vars = add_term_frees (c,add_term_vars(c,[])) |
509 val all_rel_vars = filter (is_logic_var sg) all_vars |
507 in |
510 in |
508 Drule.forall_intr_list (map (cterm_of sg) vars) th |
511 Drule.forall_intr_list (map (cterm_of sg) all_rel_vars) th |
|
512 end |
509 end |
513 handle e => (writeln "close_thm internal error"; print_exn e) |
510 handle e => (writeln "close_thm internal error"; print_exn e) |
514 |
511 |
515 (* Normalizes a theorem's conclusion using norm_term. *) |
512 (* Normalizes a theorem's conclusion using norm_term. *) |
516 |
513 |
570 succeeds, Some theorem is returned, otherwise None. *) |
567 succeeds, Some theorem is returned, otherwise None. *) |
571 |
568 |
572 fun set_prop thy t = |
569 fun set_prop thy t = |
573 let |
570 let |
574 val sg = sign_of thy |
571 val sg = sign_of thy |
575 val all_vars = add_term_frees (t,add_term_vars (t,[])) |
572 val vars = add_term_frees (t,add_term_vars (t,[])) |
576 val all_rel_vars = filter (is_logic_var sg) all_vars |
|
577 val closed_t = foldr (fn (v,body) => let val vT = type_of v |
573 val closed_t = foldr (fn (v,body) => let val vT = type_of v |
578 in all vT $ (Abs("x",vT,abstract_over(v,body))) end) (all_rel_vars,t) |
574 in all vT $ (Abs("x",vT,abstract_over(v,body))) end) (vars,t) |
579 val rew_th = norm_term thy closed_t |
575 val rew_th = norm_term thy closed_t |
580 val rhs = snd (dest_equals (cprop_of rew_th)) |
576 val rhs = snd (dest_equals (cprop_of rew_th)) |
581 |
577 |
582 val shuffles = ShuffleData.get thy |
578 val shuffles = ShuffleData.get thy |
583 fun process [] = None |
579 fun process [] = None |
594 Some mod_th => |
590 Some mod_th => |
595 let |
591 let |
596 val closed_th = equal_elim (symmetric rew_th) mod_th |
592 val closed_th = equal_elim (symmetric rew_th) mod_th |
597 in |
593 in |
598 message ("Shuffler.set_prop succeeded by " ^ name); |
594 message ("Shuffler.set_prop succeeded by " ^ name); |
599 Some (name,forall_elim_list (map (cterm_of sg) all_rel_vars) closed_th) |
595 Some (name,forall_elim_list (map (cterm_of sg) vars) closed_th) |
600 end |
596 end |
601 | None => process thms |
597 | None => process thms |
602 end |
598 end |
603 handle e as THM _ => process thms |
599 handle e as THM _ => process thms |
604 in |
600 in |