392 val compat = lookup_compat_thm i j cts |
390 val compat = lookup_compat_thm i j cts |
393 (* val _ = tracing ("XXXX compat clause else:\n" ^ @{make_string} compat) *) |
391 (* val _ = tracing ("XXXX compat clause else:\n" ^ @{make_string} compat) *) |
394 in |
392 in |
395 compat (* "!!qi qj. Gsi => Gsj => lhsi = lhsj ==> rhsi = rhsj" *) |
393 compat (* "!!qi qj. Gsi => Gsj => lhsi = lhsj ==> rhsi = rhsj" *) |
396 |> fold Thm.forall_elim (cqsi @ cqsj) (* "Gsi => Gsj => lhsi = lhsj ==> rhsi = rhsj" *) |
394 |> fold Thm.forall_elim (cqsi @ cqsj) (* "Gsi => Gsj => lhsi = lhsj ==> rhsi = rhsj" *) |
397 |> fold Thm.elim_implies (rev eqvtsi) (* HERE *) |
395 |> fold Thm.elim_implies (rev eqvtsi) (* HERE *) |
398 (* |> eqvt_at_elim thy eqvts *) |
396 (* |> eqvt_at_elim thy eqvtsi *) |
399 |> fold Thm.elim_implies agsi |
397 |> fold Thm.elim_implies agsi |
400 |> fold Thm.elim_implies agsj |
398 |> fold Thm.elim_implies agsj |
401 |> Thm.elim_implies (Thm.assume lhsi_eq_lhsj) |
399 |> Thm.elim_implies (Thm.assume lhsi_eq_lhsj) |
402 |> (fn thm => thm RS sym) (* "Gsi, Gsj, lhsi = lhsj |-- rhsj = rhsi" *) |
400 |> (fn thm => thm RS sym) (* "Gsi, Gsj, lhsi = lhsj |-- rhsj = rhsi" *) |
403 end |
401 end |
452 (llRI RS ih_eqvt_case) |
450 (llRI RS ih_eqvt_case) |
453 |> fold_rev (Thm.implies_intr o cprop_of) CCas |
451 |> fold_rev (Thm.implies_intr o cprop_of) CCas |
454 |> fold_rev (Thm.forall_intr o cterm_of thy o Free) RIvs |
452 |> fold_rev (Thm.forall_intr o cterm_of thy o Free) RIvs |
455 in |
453 in |
456 map prep_eqvt RCs |
454 map prep_eqvt RCs |
|
455 |> map (fold_rev (Thm.implies_intr o cprop_of) ags) |
457 |> map (Thm.implies_intr (cprop_of case_hyp)) |
456 |> map (Thm.implies_intr (cprop_of case_hyp)) |
458 |> map (fold_rev Thm.forall_intr cqs) |
457 |> map (fold_rev Thm.forall_intr cqs) |
459 |> map (Thm.close_derivation) |
458 |> map (Thm.close_derivation) |
460 end |
459 end |
461 *} |
460 *} |
462 |
461 |
463 ML {* |
462 ML {* |
464 fun mk_uniqueness_clause thy globals compat_store eqvts clausei clausej RLj = |
463 fun mk_uniqueness_clause thy globals compat_store eqvts clausei clausej RLj = |
465 let |
464 let |
|
465 val _ = tracing "START" |
|
466 |
466 val Globals {h, y, x, fvar, ...} = globals |
467 val Globals {h, y, x, fvar, ...} = globals |
467 val ClauseInfo {no=i, cdata=cctxi as ClauseContext {ctxt=ctxti, lhs=lhsi, case_hyp, cqs = cqsi, ...}, ...} = clausei |
468 val ClauseInfo {no=i, cdata=cctxi as ClauseContext {ctxt=ctxti, lhs=lhsi, case_hyp, cqs = cqsi, ags = agsi, ...}, ...} = clausei |
468 val ClauseInfo {no=j, qglr=cdescj, RCs=RCsj, ...} = clausej |
469 val ClauseInfo {no=j, qglr=cdescj, RCs=RCsj, ...} = clausej |
469 |
470 |
470 val cctxj as ClauseContext {ags = agsj', lhs = lhsj', rhs = rhsj', qs = qsj', cqs = cqsj', ...} = |
471 val cctxj as ClauseContext {ags = agsj', lhs = lhsj', rhs = rhsj', qs = qsj', cqs = cqsj', ...} = |
471 mk_clause_context x ctxti cdescj |
472 mk_clause_context x ctxti cdescj |
472 |
473 |
476 (fn RCInfo {h_assum, ...} => Thm.assume (cterm_of thy (subst_bounds (rev qsj', h_assum)))) RCsj |
477 (fn RCInfo {h_assum, ...} => Thm.assume (cterm_of thy (subst_bounds (rev qsj', h_assum)))) RCsj |
477 |
478 |
478 val y_eq_rhsj'h = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (mk_eq (y, rhsj'h)))) |
479 val y_eq_rhsj'h = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (mk_eq (y, rhsj'h)))) |
479 val lhsi_eq_lhsj' = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (mk_eq (lhsi, lhsj')))) |
480 val lhsi_eq_lhsj' = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (mk_eq (lhsi, lhsj')))) |
480 (* lhs_i = lhs_j' |-- lhs_i = lhs_j' *) |
481 (* lhs_i = lhs_j' |-- lhs_i = lhs_j' *) |
|
482 |
|
483 val _ = tracing "POINT B" |
481 |
484 |
482 val case_hypj' = trans OF [case_hyp, lhsi_eq_lhsj'] |
485 val case_hypj' = trans OF [case_hyp, lhsi_eq_lhsj'] |
483 |
486 |
484 val RLj_import = RLj |
487 val RLj_import = RLj |
485 |> fold Thm.forall_elim cqsj' |
488 |> fold Thm.forall_elim cqsj' |
486 |> fold Thm.elim_implies agsj' |
489 |> fold Thm.elim_implies agsj' |
487 |> fold Thm.elim_implies Ghsj' |
490 |> fold Thm.elim_implies Ghsj' |
488 |
491 |
|
492 val _ = tracing "POINT C" |
|
493 |
489 val eqvtsi = nth eqvts (i - 1) |
494 val eqvtsi = nth eqvts (i - 1) |
490 |> map (fold Thm.forall_elim cqsi) |
495 |> map (fold Thm.forall_elim cqsi) |
491 |> map (fold Thm.elim_implies [case_hyp]) |
496 |> map (fold Thm.elim_implies [case_hyp]) |
|
497 |> map (fold Thm.elim_implies agsi) |
|
498 |
|
499 val _ = tracing "POINT D" |
492 |
500 |
493 val eqvtsj = nth eqvts (j - 1) |
501 val eqvtsj = nth eqvts (j - 1) |
|
502 |> tap (fn thms => tracing ("O1:\n" ^ cat_lines (map @{make_string} thms))) |
494 |> map (fold Thm.forall_elim cqsj') |
503 |> map (fold Thm.forall_elim cqsj') |
|
504 |> tap (fn thms => tracing ("O2:\n" ^ cat_lines (map @{make_string} thms))) |
495 |> map (fold Thm.elim_implies [case_hypj']) |
505 |> map (fold Thm.elim_implies [case_hypj']) |
|
506 |> tap (fn thms => tracing ("O3:\n" ^ cat_lines (map @{make_string} thms))) |
|
507 |> map (fold Thm.elim_implies agsj') |
496 |
508 |
497 val _ = tracing ("eqvtsi:\n" ^ cat_lines (map @{make_string} eqvtsi)) |
509 val _ = tracing ("eqvtsi:\n" ^ cat_lines (map @{make_string} eqvtsi)) |
498 val _ = tracing ("eqvtsj:\n" ^ cat_lines (map @{make_string} eqvtsj)) |
510 val _ = tracing ("eqvtsj:\n" ^ cat_lines (map @{make_string} eqvtsj)) |
499 val _ = tracing ("case_hypi:\n" ^ @{make_string} case_hyp) |
511 val _ = tracing ("case_hypi:\n" ^ @{make_string} case_hyp) |
500 val _ = tracing ("case_hypj:\n" ^ @{make_string} case_hypj') |
512 val _ = tracing ("case_hypj:\n" ^ @{make_string} case_hypj') |
501 |
513 |
502 val compat = get_compat_thm thy compat_store eqvtsi eqvtsj i j cctxi cctxj |
514 val compat = get_compat_thm thy compat_store eqvtsi eqvtsj i j cctxi cctxj |
503 |
515 |
504 (* val _ = tracing ("compats:\n" ^ pp_thm compat) *) |
516 val _ = tracing ("compats:\n" ^ pp_thm compat) |
505 |
517 |
506 |
518 |
507 fun pppp str = tap (fn thm => tracing (str ^ ": " ^ pp_thm thm)) |
519 fun pppp str = tap (fn thm => tracing (str ^ ": " ^ pp_thm thm)) |
508 fun ppp str = I |
520 fun ppp str = I |
509 in |
521 in |
510 (trans OF [case_hyp, lhsi_eq_lhsj']) (* lhs_i = lhs_j' |-- x = lhs_j' *) |
522 (trans OF [case_hyp, lhsi_eq_lhsj']) (* lhs_i = lhs_j' |-- x = lhs_j' *) |
511 |> ppp "A" |
523 |> pppp "A" |
512 |> Thm.implies_elim RLj_import |
524 |> Thm.implies_elim RLj_import |
513 (* Rj1' ... Rjk', lhs_i = lhs_j' |-- rhs_j'_h = rhs_j'_f *) |
525 (* Rj1' ... Rjk', lhs_i = lhs_j' |-- rhs_j'_h = rhs_j'_f *) |
514 |> ppp "B" |
526 |> pppp "B" |
515 |> (fn it => trans OF [it, compat]) |
527 |> (fn it => trans OF [it, compat]) |
516 (* lhs_i = lhs_j', Gj', Rj1' ... Rjk' |-- rhs_j'_h = rhs_i_f *) |
528 (* lhs_i = lhs_j', Gj', Rj1' ... Rjk' |-- rhs_j'_h = rhs_i_f *) |
517 |> ppp "C" |
529 |> pppp "C" |
518 |> (fn it => trans OF [y_eq_rhsj'h, it]) |
530 |> (fn it => trans OF [y_eq_rhsj'h, it]) |
519 (* lhs_i = lhs_j', Gj', Rj1' ... Rjk', y = rhs_j_h' |-- y = rhs_i_f *) |
531 (* lhs_i = lhs_j', Gj', Rj1' ... Rjk', y = rhs_j_h' |-- y = rhs_i_f *) |
520 |> ppp "D" |
532 |> pppp "D" |
521 |> fold_rev (Thm.implies_intr o cprop_of) Ghsj' |
533 |> fold_rev (Thm.implies_intr o cprop_of) Ghsj' |
522 |> ppp "E" |
534 |> pppp "E" |
523 |> fold_rev (Thm.implies_intr o cprop_of) agsj' |
535 |> fold_rev (Thm.implies_intr o cprop_of) agsj' |
524 (* lhs_i = lhs_j' , y = rhs_j_h' |-- Gj', Rj1'...Rjk' ==> y = rhs_i_f *) |
536 (* lhs_i = lhs_j' , y = rhs_j_h' |-- Gj', Rj1'...Rjk' ==> y = rhs_i_f *) |
525 |> ppp "F" |
537 |> pppp "F" |
526 |> Thm.implies_intr (cprop_of y_eq_rhsj'h) |
538 |> Thm.implies_intr (cprop_of y_eq_rhsj'h) |
527 |> ppp "G" |
539 |> pppp "G" |
528 |> Thm.implies_intr (cprop_of lhsi_eq_lhsj') |
540 |> Thm.implies_intr (cprop_of lhsi_eq_lhsj') |
529 |> ppp "H" |
541 |> pppp "H" |
530 |> fold_rev Thm.forall_intr (cterm_of thy h :: cqsj') |
542 |> fold_rev Thm.forall_intr (cterm_of thy h :: cqsj') |
531 |> ppp "I" |
543 |> pppp "I" |
532 end |
544 end |
533 *} |
545 *} |
534 |
546 |
535 |
547 |
536 ML {* |
548 ML {* |