definition wmap :: "[i==>i,i set] ==> i set" where"wmap(f,R) == {p. EX x y. p=<x,y> ∧ <f(x),f(y)> : R}"
definition lex :: "[i set,i set] => i set" (infixl‹**›70) where"ra**rb == {p. EX a a' b b'. p = <<a,b>,<a',b'>> ∧ (<a,a'> : ra | (a=a' ∧ <b,b'> : rb))}"
definition NatPR :: "i set" where"NatPR == {p. EX x:Nat. p=<x,succ(x)>}"
definition ListPR :: "i set ==> i set" where"ListPR(A) == {p. EX h:A. EX t:List(A). p=<t,h$t>}"
lemma wfd_induct: assumes1: "Wfd(R)" and2: "∧x. ALL y. <y,x>: R ⟶ P(y) ==> P(x)" shows"P(a)" apply (rule 1 [unfolded Wfd_def, rule_format, THEN CollectD]) using2apply blast done
lemma wfd_strengthen_lemma: assumes1: "∧x y.<x,y> : R ==> Q(x)" and2: "ALL x. (ALL y. <y,x> : R ⟶ y : P) ⟶ x : P" and3: "∧x. Q(x) ==> x:P" shows"a:P" apply (rule 2 [rule_format]) using13 apply blast done
method_setup wfd_strengthen = ‹
Scan.lift Parse.embedded_inner_syntax >> (fn s => fn ctxt =>
SIMPLE_METHOD' (fn i =>
Rule_Insts.res_inst_tac ctxt [((("Q", 0), Position.none), s)] [] @{thm wfd_strengthen_lemma} i
THEN assume_tac ctxt (i + 1))) ›
lemma rmIH2: "[ALL x:A. ALL y:{y:B.<<x,y>,<p,q>>:wf(R)}.g(x,y):D(x,y); P]==> P" .
lemma rmIH3: "[ALL x:A. ALL y:B. ALL z:{z:C.<<x,<y,z>>,<p,<q,r>>>:wf(R)}.g(x,y,z):D(x,y,z); P]==> P" .
lemmas rmIHs = rmIH1 rmIH2 rmIH3
subsection‹Lemmas for constructors and subtypes›
(* 0-ary constructors do not need additional rules as they are handled *) (* correctly by applying SubtypeI *)
lemma Subtype_canTs: "∧a b A B P. a : {x:A. b:{y:B(a).P(<x,y>)}} ==> <a,b> : {x:Sigma(A,B).P(x)}" "∧a A B P. a : {x:A. P(inl(x))} ==> inl(a) : {x:A+B. P(x)}" "∧b A B P. b : {x:B. P(inr(x))} ==> inr(b) : {x:A+B. P(x)}" "∧a P. a : {x:Nat. P(succ(x))} ==> succ(a) : {x:Nat. P(x)}" "∧h t A P. h : {x:A. t : {y:List(A).P(x$y)}} ==> h$t : {x:List(A).P(x)}" by (assumption | rule SubtypeI canTs icanTs | erule SubtypeE)+
lemma letT: "[f(t):B; ¬t=bot]==> let x be t in f(x) : B" apply (erule letB [THEN ssubst]) apply assumption done
lemma applyT2: "[a:A; f : Pi(A,B)]==> f ` a : B(a)" apply (erule applyT) apply assumption done
lemma rcall_lemma1: "[a:A; a:A ==> P(a)]==> a : {x:A. P(x)}" by blast
lemma rcall_lemma2: "[a:{x:A. Q(x)}; [a:A; Q(a)]==> P(a)]==> a : {x:A. P(x)}" by blast
bvars 🍋‹Pure.all _ for ‹Abs(s,_,t)›› l = bvars t (s::l)
| bvars _ l = l
get_bno l n 🍋‹Pure.all _ for ‹Abs(s,_,t)›› = get_bno (s::l) n t
| get_bno l n 🍋‹Trueprop for t› = get_bno l n t
| get_bno l n 🍋‹Ball _ for _ ‹Abs(s,_,t)›› = get_bno (s::l) (n+1) t
| get_bno l n 🍋‹mem _ for t _› = get_bno l n t
| get_bno l n (t $ s) = get_bno l n t
| get_bno l n (Bound m) = (m-length(l),n)
(* Not a great way of identifying induction hypothesis! *) fun could_IH x = Term.could_unify(x,hd (Thm.take_prems_of 1 @{thm rcallT})) orelse Term.could_unify(x,hd (Thm.take_prems_of 1 @{thm rcall2T})) orelse Term.could_unify(x,hd (Thm.take_prems_of 1 @{thm rcall3T}))
fun IHinst tac rls = SUBGOAL (fn (Bi,i) => let val bvs = bvars Bi []
val ihs = filter could_IH (Logic.strip_assums_hyp Bi)
val rnames = map (fn x => let val (a,b) = get_bno [] 0 x in (nth bvs a, b) end) ihs fun try_IHs [] = no_tac
| try_IHs ((x,y)::xs) =
tac [((("g", 0), Position.none), x)] (nth rls (y - 1)) i ORELSE (try_IHs xs) in try_IHs rnames end)
fun is_rigid_prog t =
(case (Logic.strip_assums_concl t) of 🍋‹Trueprop for 🍋‹mem _ for a _›› => null (Term.add_vars a [])
| _ => false)
in
fun rcall_tac ctxt i = letfun tac ps rl i = Rule_Insts.res_inst_tac ctxt ps [] rl i THEN assume_tac ctxt i in IHinst tac @{thms rcallTs} i end THEN eresolve_tac ctxt @{thms rcall_lemmas} i
fun raw_step_tac ctxt prems i =
assume_tac ctxt i ORELSE
resolve_tac ctxt (prems @ type_rls) i ORELSE
rcall_tac ctxt i ORELSE
ematch_tac ctxt @{thms SubtypeE} i ORELSE
match_tac ctxt @{thms SubtypeI} i
fun tc_step_tac ctxt prems = SUBGOAL (fn (Bi,i) => if is_rigid_prog Bi then raw_step_tac ctxt prems i else no_tac)
fun typechk_tac ctxt rls i = SELECT_GOAL (REPEAT_FIRST (tc_step_tac ctxt rls)) i
(*** Clean up Correctness Condictions ***)
fun clean_ccs_tac ctxt = letfun tac ps rl i = Rule_Insts.eres_inst_tac ctxt ps [] rl i THEN assume_tac ctxt i in
TRY (REPEAT_FIRST (IHinst tac @{thms hyprcallTs} ORELSE'
eresolve_tac ctxt ([asm_rl, @{thm SubtypeE}] @ @{thms rmIHs}) ORELSE'
hyp_subst_tac ctxt)) end
fun gen_ccs_tac ctxt rls i =
SELECT_GOAL (REPEAT_FIRST (tc_step_tac ctxt rls) THEN clean_ccs_tac ctxt) i
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.