(* Title: Blackboard.thy Author: Diego Marmsoler *) section "A Theory of Blackboard Architectures" text\ In the following, we formalize the specification of the blackboard pattern as described in~\cite{Marmsoler2018c}. \ theory Blackboard imports Publisher_Subscriber begin subsection "Problems and Solutions" text \ Blackboards work with problems and solutions for them. \ typedecl PROB consts sb :: "(PROB \ PROB) set" axiomatization where sbWF: "wf sb" typedecl SOL consts solve:: "PROB \ SOL" subsection "Blackboard Architectures" text \ In the following, we describe the locale for the blackboard pattern. \ locale blackboard = publisher_subscriber bbactive bbcmp ksactive kscmp bbrp bbcs kscs ksrp for bbactive :: "'bid \ cnf \ bool" ("\_\\<^bsub>_\<^esub>" [0,110]60) and bbcmp :: "'bid \ cnf \ 'BB" ("\\<^bsub>_\<^esub>(_)" [0,110]60) and ksactive :: "'kid \ cnf \ bool" ("\_\\<^bsub>_\<^esub>" [0,110]60) and kscmp :: "'kid \ cnf \ 'KS" ("\\<^bsub>_\<^esub>(_)" [0,110]60) and bbrp :: "'BB \ (PROB set) subscription set" and bbcs :: "'BB \ (PROB \ SOL)" and kscs :: "'KS \ (PROB \ SOL) set" and ksrp :: "'KS \ (PROB set) subscription" + fixes bbns :: "'BB \ (PROB \ SOL) set" and ksns :: "'KS \ (PROB \ SOL)" and bbop :: "'BB \ PROB" and ksop :: "'KS \ PROB set" and prob :: "'kid \ PROB" assumes ks1: "\p. \ks. p=prob ks" \ \Component Parameter\ \ \Assertions about component behavior.\ and bhvbb1: "\t t' bId p s. \t \ arch\ \ pb.eval bId t t' 0 (\\<^sub>b ([\bb. (p,s)\bbns bb]\<^sub>b \\<^sup>b (\\<^sub>b [\bb. (p,s) = bbcs bb]\<^sub>b)))" and bhvbb2: "\t t' bId P q. \t\arch\ \ pb.eval bId t t' 0 (\\<^sub>b ([\bb. sub P \ bbrp bb \ q \ P]\<^sub>b \\<^sup>b (\\<^sub>b [\bb. q = bbop bb]\<^sub>b)))" and bhvbb3: "\t t' bId p . \t\arch\ \ pb.eval bId t t' 0 (\\<^sub>b ([\bb. p = bbop(bb)]\<^sub>b \\<^sup>b ([\bb. p=bbop(bb)]\<^sub>b \\<^sub>b [\bb. (p,solve(p)) = bbcs(bb)]\<^sub>b)))" and bhvks1: "\t t' kId p P. \t\arch; p = prob kId\ \ sb.eval kId t t' 0 (\\<^sub>b ([\ks. sub P = ksrp ks]\<^sub>b \\<^sup>b (\\<^sub>b q. ((sb.pred (q\P)) \\<^sup>b (\\<^sub>b ([\ks. (q,solve(q)) \ kscs ks]\<^sub>b)))) \\<^sup>b (\\<^sub>b [\ks. (p, solve p) = ksns ks]\<^sub>b)))" and bhvks2: "\t t' kId p P q. \t \ arch;p = prob kId\ \ sb.eval kId t t' 0 (\\<^sub>b [\ks. sub P = ksrp ks \ q \ P \ (q,p) \ sb]\<^sub>b)" and bhvks3: "\t t' kId p. \t\arch;p = prob kId\ \ sb.eval kId t t' 0 (\\<^sub>b ([\ks. p\ksop ks]\<^sub>b \\<^sup>b (\\<^sub>b [\ks. (\P. sub P = ksrp ks)]\<^sub>b)))" and bhvks4: "\t t' kId p P. \t\arch; p\P\ \ sb.eval kId t t' 0 (\\<^sub>b ([\ks. sub P = ksrp ks]\<^sub>b \\<^sup>b ((\\<^sup>b (\\<^sub>b P'. (sb.pred (p\P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b))) \\<^sub>b [\ks. (p,solve p) \ kscs ks]\<^sub>b)))" \ \Assertions about component activation.\ and actks: "\t n kid p. \t \ arch; \kid\\<^bsub>t n\<^esub>; p=prob kid; p\ksop (\\<^bsub>kid\<^esub>(t n))\ \ (\n'\n. \kid\\<^bsub>t n'\<^esub> \ (p, solve p) = ksns (\\<^bsub>kid\<^esub>(t n')) \ (\n''\n. n'' \kid\\<^bsub>t n''\<^esub>)) \ (\n'\n. (\kid\\<^bsub>t n'\<^esub> \ (\(p, solve p) = ksns (\\<^bsub>kid\<^esub>(t n')))))" \ \Assertions about connections.\ and conn1: "\k bid. \bid\\<^bsub>k\<^esub> \ bbns (\\<^bsub>bid\<^esub>(k)) = (\kid\{kid. \kid\\<^bsub>k\<^esub>}. {ksns (\\<^bsub>kid\<^esub>(k))})" and conn2: "\k kid. \kid\\<^bsub>k\<^esub> \ ksop (\\<^bsub>kid\<^esub>(k)) = (\bid\{bid. \bid\\<^bsub>k\<^esub>}. {bbop (\\<^bsub>bid\<^esub>(k))})" begin notation sb.lNAct ("\_ \ _\\<^bsub>_\<^esub>") notation sb.nxtAct ("\_ \ _\\<^bsub>_\<^esub>") notation pb.lNAct ("\_ \ _\\<^bsub>_\<^esub>") notation pb.nxtAct ("\_ \ _\\<^bsub>_\<^esub>") subsubsection "Calculus Interpretation" text \ \noindent @{thm[source] pb.baIA}: @{thm pb.baIA [no_vars]} \ text \ \noindent @{thm[source] sb.baIA}: @{thm sb.baIA [no_vars]} \ subsubsection "Results from Singleton" abbreviation "the_bb \ the_pb" text \ \noindent @{thm[source] pb.ts_prop(1)}: @{thm pb.ts_prop(1) [no_vars]} \ text \ \noindent @{thm[source] pb.ts_prop(2)}: @{thm pb.ts_prop(2) [no_vars]} \ subsubsection "Results from Publisher Subscriber" text \ \noindent @{thm[source] msgDelivery}: @{thm msgDelivery [no_vars]} \ lemma conn2_bb: fixes k and kid::'kid assumes "\kid\\<^bsub>k\<^esub>" shows "bbop (\\<^bsub>the_bb\<^esub>(k))\ksop (\\<^bsub>kid\<^esub>(k))" proof - from assms have "ksop (\\<^bsub>kid\<^esub>(k)) = (\bid\{bid. \bid\\<^bsub>k\<^esub>}. {bbop (\\<^bsub>bid\<^esub>(k))})" using conn2 by simp moreover have "(\bid.{bid. \bid\\<^bsub>k\<^esub>})={the_bb}" using pb.ts_prop(1) by auto hence "(\bid\{bid. \bid\\<^bsub>k\<^esub>}. {bbop (\\<^bsub>bid\<^esub>(k))}) = {bbop (\\<^bsub>the_bb\<^esub>(k))}" by auto ultimately show ?thesis by simp qed subsubsection "Knowledge Sources" text \ In the following we introduce an abbreviation for knowledge sources which are able to solve a specific problem. \ definition sKs:: "PROB \ 'kid" where "sKs p \ (SOME kid. p = prob kid)" lemma sks_prob: "p = prob (sKs p)" using sKs_def someI_ex[of "\kid. p = prob kid"] ks1 by auto subsubsection "Architectural Guarantees" text\ The following theorem verifies that a problem is eventually solved by the pattern even if no knowledge source exist which can solve the problem on its own. It assumes, however, that for every open sub problem, a corresponding knowledge source able to solve the problem will be eventually activated. \ lemma pSolved_Ind: fixes t and t'::"nat \'BB" and p and t''::"nat \'KS" assumes "t\arch" and "\n. (\n'\n. \sKs (bbop(\\<^bsub>the_bb\<^esub>(t n)))\\<^bsub>t n'\<^esub>)" shows "\n. (\P. sub P \ bbrp(\\<^bsub>the_bb\<^esub>(t n)) \ p \ P) \ (\m\n. (p,solve(p)) = bbcs (\\<^bsub>the_bb\<^esub>(t m)))" (*\eqref{eq:bb:g}*) \ \The proof is by well-founded induction over the subproblem relation @{term sb}\ proof (rule wf_induct[where r=sb]) \ \We first show that the subproblem relation is indeed well-founded ...\ show "wf sb" by (simp add: sbWF) next \ \... then we show that a problem @{term p} is indeed solved\ \ \if all its sub-problems @{term p'} are eventually solved\ fix p assume indH: "\p'. (p', p) \ sb \ (\n. (\P. sub P \ bbrp (\\<^bsub>the_bb\<^esub>(t n)) \ p'\P) \ (\m\n. (p',solve(p')) = bbcs (\\<^bsub>the_bb\<^esub>(t m))))" show "\n. (\P. sub P \ bbrp (\\<^bsub>the_bb\<^esub>(t n)) \ p \ P) \ (\m\n. (p,solve(p)) = bbcs (\\<^bsub>the_bb\<^esub>(t m)))" proof fix n\<^sub>0 show "(\P. sub P \ bbrp (\\<^bsub>the_bb\<^esub>(t n\<^sub>0)) \ p \ P) \ (\m\n\<^sub>0. (p,solve(p)) = bbcs (\\<^bsub>the_bb\<^esub>(t m)))" proof assume "\P. sub P \ bbrp (\\<^bsub>the_bb\<^esub>(t n\<^sub>0)) \ p \ P" moreover have "(\P. sub P \ bbrp (\\<^bsub>the_bb\<^esub>(t n\<^sub>0)) \ p \ P) \ (\n'\n\<^sub>0. p=bbop(\\<^bsub>the_bb\<^esub>(t n')))" proof assume "\P. sub P \ bbrp (\\<^bsub>the_bb\<^esub>(t n\<^sub>0)) \ p \ P" then obtain P where "sub P \ bbrp (\\<^bsub>the_bb\<^esub>(t n\<^sub>0))" and "p \ P" by auto hence "pb.eval the_bb t t' n\<^sub>0 [\bb. sub P \ bbrp bb \ p \ P]\<^sub>b" using pb.baI by simp moreover from pb.globE[OF bhvbb2] have "pb.eval the_bb t t' n\<^sub>0 ([\bb. sub P \ bbrp bb \ p \ P]\<^sub>b \\<^sup>b \\<^sub>b [\bb. p = bbop bb]\<^sub>b)" using \t\arch\ by simp ultimately have "pb.eval the_bb t t' n\<^sub>0 (\\<^sub>b [\bb. p = bbop bb]\<^sub>b)" using pb.impE by blast then obtain n' where "n'\n\<^sub>0" and "pb.eval the_bb t t' n' [\bb. p = bbop bb]\<^sub>b" using pb.evtE by blast hence "p=bbop(\\<^bsub>the_bb\<^esub>(t n'))" using pb.baE by auto with \n'\n\<^sub>0\ show "\n'\n\<^sub>0. p=bbop(\\<^bsub>the_bb\<^esub>(t n'))" by auto qed ultimately obtain n where "n\n\<^sub>0" and "p=bbop(\\<^bsub>the_bb\<^esub>(t n))" by auto \ \Problem p is provided at the output of the blackboard until it is solved\ \ \or forever...\ from pb.globE[OF bhvbb3] have "pb.eval the_bb t t' n ([\ bb. p = bbop(bb)]\<^sub>b \\<^sup>b ([\ bb. p=bbop(bb)]\<^sub>b \\<^sub>b [\bb. (p,solve(p)) = bbcs(bb)]\<^sub>b))" using \t\arch\ by auto moreover from \p = bbop (\\<^bsub>the_bb\<^esub>(t n))\ have "pb.eval the_bb t t' n [\ bb. p=bbop bb]\<^sub>b" using \t\arch\ pb.baI by simp ultimately have "pb.eval the_bb t t' n ([\ bb. p=bbop(bb)]\<^sub>b \\<^sub>b [\ bb. (p,solve(p)) = bbcs(bb)]\<^sub>b)" using pb.impE by blast hence "pb.eval the_bb t t' n (([\ bb. p=bbop bb]\<^sub>b \\<^sub>b [\ bb. (p,solve(p)) = bbcs bb]\<^sub>b) \\<^sup>b (\\<^sub>b [\ bb. p=bbop bb]\<^sub>b))" using pb.wuntil_def by simp hence "pb.eval the_bb t t' n ([\bb. p=bbop bb]\<^sub>b \\<^sub>b [\bb. (p,solve(p)) = bbcs bb]\<^sub>b) \ (pb.eval the_bb t t' n (\\<^sub>b [\ bb. p=bbop bb]\<^sub>b))" using pb.disjE by simp thus "\m\n\<^sub>0. (p,solve p) = bbcs(\\<^bsub>the_bb\<^esub>(t m))" \ \We need to consider both cases, the case in which the problem is eventually\ \ \solved and the case in which the problem is always provided as an output\ proof \ \First we consider the case in which the problem is eventually solved:\ assume "pb.eval the_bb t t' n ([\bb. p=bbop bb]\<^sub>b \\<^sub>b [\bb. (p,solve(p)) = bbcs bb]\<^sub>b)" hence "\i\n. (pb.eval the_bb t t' i [\bb. (p,solve(p)) = bbcs bb]\<^sub>b \ (\k\n. k pb.eval the_bb t t' k [\bb. p = bbop bb]\<^sub>b))" using \t\arch\ pb.untilE by simp then obtain i where "i\n" and "pb.eval the_bb t t' i [\bb. (p,solve(p)) = bbcs bb]\<^sub>b" by auto hence "(p,solve(p)) = bbcs(\\<^bsub>the_bb\<^esub>(t i))" using \t\arch\ pb.baEA by auto moreover from \i\n\ \n\n\<^sub>0\ have "i\n\<^sub>0" by simp ultimately show ?thesis by auto next \ \Now we consider the case in which p is always provided at the output\ \ \of the blackboard:\ assume "pb.eval the_bb t t' n (\\<^sub>b [\bb. p=bbop bb]\<^sub>b)" hence "\n'\n. (pb.eval the_bb t t' n' [\bb. p = bbop bb]\<^sub>b)" using \t\arch\ pb.globE by auto hence outp: "\n'\n. (p = bbop (\\<^bsub>the_bb\<^esub>(t n')))" using \t\arch\ pb.baE by blast \ \thus, by assumption there exists a KS which is able to solve p and which\ \ \is active at @{text n'}...\ with assms(2) have "\n'\n. \sKs p\\<^bsub>t n'\<^esub>" by auto then obtain n\<^sub>k where "n\<^sub>k\n" and "\sKs p\\<^bsub>t n\<^sub>k\<^esub>" by auto \ \... and get the problem as its input.\ moreover from \n\<^sub>k\n\ have "p = bbop (\\<^bsub>the_bb\<^esub>(t n\<^sub>k))" using outp by simp ultimately have "p\ksop(\\<^bsub>sKs p\<^esub>(t n\<^sub>k))" using conn2_bb[of "sKs p" "t n\<^sub>k"] by simp \ \thus the ks will either solve the problem or not solve it and\ \ \be activated forever\ hence "(\n'\n\<^sub>k. \sKs p\\<^bsub>t n'\<^esub> \ (p, solve p) = ksns (\\<^bsub>sKs p\<^esub>(t n')) \ (\n''\n\<^sub>k. n'' \sKs p\\<^bsub>t n''\<^esub>)) \ (\n'\n\<^sub>k. (\sKs p\\<^bsub>t n'\<^esub> \ (\(p, solve p) = ksns (\\<^bsub>sKs p\<^esub>(t n')))))" using \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ actks[of t "sKs p"] \t\arch\ sks_prob by simp thus ?thesis proof \ \if the ks solves it\ assume "\n'\n\<^sub>k. \sKs p\\<^bsub>t n'\<^esub> \ (p, solve p) = ksns (\\<^bsub>sKs p\<^esub>t n') \ (\n''\n\<^sub>k. n'' < n' \ \sKs p\\<^bsub>t n''\<^esub>)" \ \it is forwarded to the blackboard\ then obtain n\<^sub>s where "n\<^sub>s\n\<^sub>k" and "\sKs p\\<^bsub>t n\<^sub>s\<^esub>" and "(p, solve p) = ksns (\\<^bsub>sKs p\<^esub>t n\<^sub>s)" by auto moreover have "\sKs p \ t\\<^bsub>n\<^sub>s\<^esub> = n\<^sub>s" by (simp add: \\sKs p\\<^bsub>t n\<^sub>s\<^esub>\ sb.nxtAct_active) ultimately have "(p,solve(p)) \ bbns (\\<^bsub>the_bb\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>)))" using conn1[OF pb.ts_prop(2)] \\sKs p\\<^bsub>t n\<^sub>s\<^esub>\ by auto \ \finally, the blackboard will forward the solution which finishes the proof.\ with bhvbb1 have "pb.eval the_bb t t' (\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>) (\\<^sub>b [\bb. (p, solve p) = bbcs bb]\<^sub>b)" using \t\arch\ pb.globE pb.impE[of the_bb t t'] by blast then obtain n\<^sub>f where "n\<^sub>f\\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>" and "pb.eval the_bb t t' n\<^sub>f [\bb. (p, solve p) = bbcs bb]\<^sub>b" using \t\arch\ pb.evtE[of t t' "\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>"] by auto hence "(p, solve p) = bbcs (\\<^bsub>the_bb\<^esub>(t n\<^sub>f))" using \t \ arch\ pb.baEA by auto moreover have "n\<^sub>f\n\<^sub>0" proof - from \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ have "\sKs p \ t\\<^bsub>n\<^sub>k\<^esub>\n\<^sub>k" using sb.nxtActI by blast with \\sKs p \ t\\<^bsub>n\<^sub>s\<^esub> = n\<^sub>s\ show ?thesis using \n\<^sub>f\\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>\ \n\<^sub>s\n\<^sub>k\ \n\<^sub>k\n\ \n\n\<^sub>0\ by arith qed ultimately show ?thesis by auto next \ \otherwise, we derive a contradiction\ assume case_ass: "\n'\n\<^sub>k. \sKs p\\<^bsub>t n'\<^esub> \ \(p, solve p) = ksns (\\<^bsub>sKs p\<^esub>t n')" \ \first, the KS will eventually register for the subproblems P it requires to solve p...\ from \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ have "\i\0. \sKs p\\<^bsub>t i\<^esub>" by auto moreover have "\sKs p \ t\\<^bsub>0\<^esub> \ n\<^sub>k" by simp ultimately have "sb.eval (sKs p) t t'' n\<^sub>k ([\ks. p\ksop ks]\<^sub>b \\<^sup>b (\\<^sub>b [\ks. \P. sub P = ksrp ks]\<^sub>b))" using sb.globEA[OF _ bhvks3[of t p "sKs p" t'']] \t\arch\ sks_prob by simp moreover have "sb.eval (sKs p) t t'' n\<^sub>k [\ks. p \ ksop ks]\<^sub>b" proof - from \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ have "\n'\n\<^sub>k. \sKs p\\<^bsub>t n'\<^esub>" by auto moreover have "p \ ksop (\\<^bsub>sKs p\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>k\<^esub>)))" proof - from \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ have "\sKs p \ t\\<^bsub>n\<^sub>k\<^esub>=n\<^sub>k" using sb.nxtAct_active by blast with \p\ksop(\\<^bsub>sKs p\<^esub>(t n\<^sub>k))\ show ?thesis by simp qed ultimately show ?thesis using sb.baIA[of n\<^sub>k "sKs p" t] by blast qed ultimately have "sb.eval (sKs p) t t'' n\<^sub>k (\\<^sub>b [\ks. \P. sub P = ksrp ks]\<^sub>b)" using sb.impE by blast then obtain n\<^sub>r where "n\<^sub>r\\sKs p \ t\\<^bsub>n\<^sub>k\<^esub>" and "\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub> \ (\n''\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>. n'' \ \sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ sb.eval (sKs p) t t'' n'' [\ks. \P. sub P = ksrp ks]\<^sub>b) \ \ (\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>) \ sb.eval (sKs p) t t'' n\<^sub>r [\ks. \P. sub P = ksrp ks]\<^sub>b" using \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ sb.evtEA[of n\<^sub>k "sKs p" t] by blast moreover from case_ass have "\sKs p \ t\\<^bsub>n\<^sub>k\<^esub>\n\<^sub>k" using sb.nxtActI by blast with \n\<^sub>r\\sKs p \ t\\<^bsub>n\<^sub>k\<^esub>\ have "n\<^sub>r\n\<^sub>k" by arith hence "\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>" using case_ass by auto hence "n\<^sub>r \ \sKs p \ t\\<^bsub>n\<^sub>r\<^esub>" using sb.nxtActLe by simp moreover have "n\<^sub>r \ \sKs p \ t\\<^bsub>n\<^sub>r\<^esub>" by simp ultimately have "sb.eval (sKs p) t t'' n\<^sub>r [\ks. \P. sub P = ksrp ks]\<^sub>b" by blast with \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ obtain P where "sub P = ksrp (\\<^bsub>sKs p\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)))" using sb.baEA by blast hence "sb.eval (sKs p) t t'' n\<^sub>r [\ks. sub P = ksrp ks]\<^sub>b" using \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ sb.baIA sks_prob by blast \ \the knowledgesource will eventually get a solution for each required subproblem:\ moreover have "sb.eval (sKs p) t t'' n\<^sub>r (\\<^sub>b p'. (sb.pred (p'\P) \\<^sup>b (\\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b)))" proof - have "\p'. sb.eval (sKs p) t t'' n\<^sub>r (sb.pred (p'\P) \\<^sup>b (\\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b))" proof \ \by induction hypothesis, the blackboard will eventually provide solutions for subproblems\ fix p' have "sb.eval (sKs p) t t'' n\<^sub>r (sb.pred (p'\P)) \ (sb.eval (sKs p) t t'' n\<^sub>r (\\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b))" proof assume "sb.eval (sKs p) t t'' n\<^sub>r (sb.pred (p'\P))" hence "p' \ P" using sb.predE by blast thus "(sb.eval (sKs p) t t'' n\<^sub>r (\\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b))" proof - have "\sKs p \ t\\<^bsub>0\<^esub> \ n\<^sub>r" by simp moreover from \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ have "\i\0. \sKs p\\<^bsub>t i\<^esub>" by auto ultimately have "sb.eval (sKs p) t t'' n\<^sub>r ([\ks. sub P = ksrp ks]\<^sub>b \\<^sup>b ((\\<^sup>b (\\<^sub>b P'. (sb.pred (p'\P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b))) \\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b))" using sb.globEA[OF _ bhvks4[of t p' P "sKs p" t'']] \t\arch\ \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ \p'\P\ by simp with \sb.eval (sKs p) t t'' n\<^sub>r [\ks. sub P = ksrp ks]\<^sub>b\ have "sb.eval (sKs p) t t'' n\<^sub>r ((\\<^sup>b (\\<^sub>b P'. (sb.pred (p'\P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b))) \\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b)" using sb.impE[of "(sKs p)" t t'' n\<^sub>r "[\ks. sub P = ksrp ks]\<^sub>b"] by blast hence "sb.eval (sKs p) t t'' n\<^sub>r ((\\<^sup>b (\\<^sub>b P'. (sb.pred (p'\P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b))) \\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b) \ sb.eval (sKs p) t t'' n\<^sub>r (\\<^sub>b (\\<^sup>b (\\<^sub>b P'. (sb.pred (p'\P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b))))" using sb.wuntil_def by auto thus "(sb.eval (sKs p) t t'' n\<^sub>r (\\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b))" proof let ?\'="\\<^sup>b (\\<^sub>b P'. (sb.pred (p'\P') \\<^sup>b ([\ks. unsub P' = ksrp ks]\<^sub>b)))" let ?\="[\ks. (p',solve p') \ kscs ks]\<^sub>b" assume "sb.eval (sKs p) t t'' n\<^sub>r (?\' \\<^sub>b ?\)" with \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ obtain n' where "n'\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>" and lass: "(\i\n'. \sKs p\\<^bsub>t i\<^esub>) \ (\n''\\sKs p \ t\\<^bsub>n'\<^esub>. n'' \ \sKs p \ t\\<^bsub>n'\<^esub> \ sb.eval (sKs p) t t'' n'' ?\) \ (\n''\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>. n'' < \sKs p \ t\\<^bsub>n'\<^esub> \ sb.eval (sKs p) t t'' n'' ?\') \ \ (\i\n'. \sKs p\\<^bsub>t i\<^esub>) \ sb.eval (sKs p) t t'' n' ?\ \ (\n''\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>. n'' < n' \ sb.eval (sKs p) t t'' n'' ?\')" using sb.untilEA[of n\<^sub>r "sKs p" t t''] \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ by blast thus "?thesis" proof cases assume "\i\n'. \sKs p\\<^bsub>t i\<^esub>" with lass have "\n''\\sKs p \ t\\<^bsub>n'\<^esub>. n'' \ \sKs p \ t\\<^bsub>n'\<^esub> \ sb.eval (sKs p) t t'' n'' ?\" by auto moreover have "n'\\sKs p \ t\\<^bsub>n'\<^esub>" by simp moreover have "n' \ \sKs p \ t\\<^bsub>n'\<^esub>" using \\i\n'. \sKs p\\<^bsub>t i\<^esub>\ sb.nxtActLe by simp ultimately have "sb.eval (sKs p) t t'' n' ?\" by simp moreover have "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n'" using \n\<^sub>r \ \sKs p \ t\\<^bsub>n\<^sub>r\<^esub>\ \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n\<^sub>r\ \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n'\ by linarith ultimately show ?thesis using \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ \\i\n'. \sKs p\\<^bsub>t i\<^esub>\ \n'\\sKs p \ t\\<^bsub>n'\<^esub>\ \n' \ \sKs p \ t\\<^bsub>n'\<^esub>\ sb.evtIA[of n\<^sub>r "sKs p" t n' t'' ?\] by blast next assume "\ (\i\n'. \sKs p\\<^bsub>t i\<^esub>)" with lass have "sb.eval (sKs p) t t'' n' ?\ \ (\n''\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>. n'' < n' \ sb.eval (sKs p) t t'' n'' ?\')" by auto moreover have "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n'" using \n\<^sub>r \ \sKs p \ t\\<^bsub>n\<^sub>r\<^esub>\ \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n\<^sub>r\ \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n'\ by linarith ultimately show ?thesis using \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ \\ (\i\n'. \sKs p\\<^bsub>t i\<^esub>)\ sb.evtIA[of n\<^sub>r "sKs p" t n' t'' ?\] by blast qed next assume cass: "sb.eval (sKs p) t t'' n\<^sub>r (\\<^sub>b (\\<^sup>b (\\<^sub>b P'. (sb.pred (p'\P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b))))" have "sub P = ksrp (\\<^bsub>sKs p\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>))) \ p' \ P \ (p', p) \ sb" proof - have "\i\0. \sKs p\\<^bsub>t i\<^esub>" using \\i\0. \sKs p\\<^bsub>t i\<^esub>\ by auto moreover have "\sKs p \ t\\<^bsub>0\<^esub> \ (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)" by simp ultimately have "sb.eval (sKs p) t t'' (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>) [\ks. sub P = ksrp ks \ p' \ P \ (p', p) \ sb]\<^sub>b" using sb.globEA[OF _ bhvks2[of t p "sKs p" t'' P]] \t \ arch\ sks_prob by blast moreover from \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ have "\sKs p\\<^bsub>t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)\<^esub>" using sb.nxtActI by blast ultimately show ?thesis using sb.baEANow[of "sKs p" t t'' "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>"] by simp qed with \p' \ P\ have "(p', p) \ sb" using \sub P = ksrp (\\<^bsub>sKs p\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)))\ sks_prob by simp moreover from \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ have "\sKs p\\<^bsub>t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)\<^esub>" using sb.nxtActI by blast with \sub P = ksrp (\\<^bsub>sKs p\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)))\ have "sub P \ bbrp (\\<^bsub>the_bb\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)))" using conn1A by auto with \ p' \ P\ have "sub P \ bbrp (\\<^bsub>the_bb\<^esub>t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)) \ p' \ P" by auto ultimately obtain m where "m\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>" and "(p', solve p') = bbcs (\\<^bsub>the_bb\<^esub>(t m))" using indH by auto \ \and due to the publisher subscriber property,\ \ \the knowledge source will receive them\ moreover have "\n P. \sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n \ n \ m \ \sKs p\\<^bsub>t n\<^esub> \ unsub P = ksrp (\\<^bsub>sKs p\<^esub>(t n)) \ p' \ P" proof assume "\n P'. \sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n \ n \ m \ \sKs p\\<^bsub>t n\<^esub> \ unsub P' = ksrp (\\<^bsub>sKs p\<^esub>(t n)) \ p' \ P'" then obtain n P' where "\sKs p\\<^bsub>t n\<^esub>" and "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n" and "n \ m" and "unsub P' = ksrp (\\<^bsub>sKs p\<^esub>(t n))" and "p' \ P'" by auto hence "sb.eval (sKs p) t t'' n (\\<^sub>b P'. sb.pred (p'\P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b)" by blast moreover have "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n" using \n\<^sub>r \ \sKs p \ t\\<^bsub>n\<^sub>r\<^esub>\ \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n\<^sub>r\ \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n\ by linarith with cass have "sb.eval (sKs p) t t'' n (\\<^sup>b (\\<^sub>b P'. (sb.pred (p'\P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b)))" using sb.globEA[of n\<^sub>r "sKs p" t t'' "\\<^sup>b (\\<^sub>bP'. sb.pred (p' \ P') \\<^sup>b [\ks. unsub P' = ksrp ks]\<^sub>b)" n] \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ by auto ultimately show False using sb.negE by auto qed moreover from \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ have "\sKs p\\<^bsub>t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)\<^esub>" using sb.nxtActI by blast moreover have "sub P = ksrp (\\<^bsub>sKs p\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)))" using \sub P = ksrp (\\<^bsub>sKs p\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>)))\ . moreover from \m\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>\ have "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ m" by simp moreover from \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ have "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>\n\<^sub>r" using sb.nxtActI by blast hence "m\n\<^sub>k" using \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ m\ \\sKs p \ t\\<^bsub>n\<^sub>k\<^esub> \ n\<^sub>r\ \\sKs p \ t\\<^bsub>n\<^sub>k\<^esub> \ n\<^sub>k\ by simp with case_ass have "\sKs p\\<^bsub>t m\<^esub>" by simp ultimately have "(p', solve p') \ kscs (\\<^bsub>sKs p\<^esub>(t m))" and "\sKs p\\<^bsub>t m\<^esub>" using \t \ arch\ msgDelivery[of t "sKs p" "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>" P m p' "solve p'"] \p' \ P\ by auto hence "sb.eval (sKs p) t t'' m [\ks. (p',solve p') \ kscs ks]\<^sub>b" using sb.baIANow by simp moreover have "m \ \sKs p \ t\\<^bsub>m\<^esub>" by simp moreover from \\sKs p\\<^bsub>t m\<^esub>\ have "m \ \sKs p \ t\\<^bsub>m\<^esub>" using sb.nxtActLe by auto moreover from \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ have "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ \sKs p \ t\\<^bsub>n\<^sub>r\<^esub>" by simp with \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ m\ have "\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ m" by arith ultimately show "sb.eval (sKs p) t t'' n\<^sub>r (\\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b)" using \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ sb.evtIA by blast qed qed qed thus "sb.eval (sKs p) t t'' n\<^sub>r (sb.pred (p'\P) \\<^sup>b (\\<^sub>b [\ks. (p',solve p') \ kscs ks]\<^sub>b))" using sb.impI by auto qed thus ?thesis using sb.allI by blast qed \ \Thus, the knowlege source will eventually solve the problem at hand...\ ultimately have "sb.eval (sKs p) t t'' n\<^sub>r ([\ks. sub P = ksrp ks]\<^sub>b \\<^sup>b (\\<^sub>b q. (sb.pred (q \ P) \\<^sup>b \\<^sub>b [\ks. (q, solve q) \ kscs ks]\<^sub>b)))" using sb.conjI by simp moreover from \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ have "\i\0. \sKs p\\<^bsub>t i\<^esub>" by blast hence "sb.eval (sKs p) t t'' n\<^sub>r (([\ks. sub P = ksrp ks]\<^sub>b \\<^sup>b (\\<^sub>b q. (sb.pred (q \ P) \\<^sup>b \\<^sub>b [\ks. (q, solve q) \ kscs ks]\<^sub>b))) \\<^sup>b (\\<^sub>b [\ks. (p, solve p) = ksns ks]\<^sub>b))" using \t \ arch\ sb.globEA[OF _ bhvks1[of t p "sKs p" t'' P]] sks_prob by simp ultimately have "sb.eval (sKs p) t t'' n\<^sub>r (\\<^sub>b [\ks. (p,solve(p))=ksns(ks)]\<^sub>b)" using sb.impE[of "sKs p" t t'' n\<^sub>r] by blast \ \and forward it to the blackboard\ then obtain n\<^sub>s where "n\<^sub>s\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>" and "(\i\n\<^sub>s. \sKs p\\<^bsub>t i\<^esub> \ (\n''\\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>. n'' \ \sKs p \ t\\<^bsub>n\<^sub>s\<^esub> \ sb.eval (sKs p) t t'' n'' [\ks. (p,solve(p))=ksns(ks)]\<^sub>b)) \ \ (\i\n\<^sub>s. \sKs p\\<^bsub>t i\<^esub>) \ sb.eval (sKs p) t t'' n\<^sub>s [\ks. (p,solve(p))=ksns(ks)]\<^sub>b" using sb.evtEA[of n\<^sub>r "sKs p" t] \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ by blast moreover from \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub> \ n\<^sub>r\ \n\<^sub>r\n\<^sub>k\ \n\<^sub>s\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>\ have "n\<^sub>s\n\<^sub>k" by arith with case_ass have "\i\n\<^sub>s. \sKs p\\<^bsub>t i\<^esub>" by auto moreover have "n\<^sub>s\\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>" by simp moreover from \\i\n\<^sub>s. \sKs p\\<^bsub>t i\<^esub>\ have "n\<^sub>s \ \sKs p \ t\\<^bsub>n\<^sub>s\<^esub>" using sb.nxtActLe by simp ultimately have "sb.eval (sKs p) t t'' n\<^sub>s [\ks. (p,solve(p))=ksns(ks)]\<^sub>b" using sb.evtEA[of n\<^sub>r "sKs p" t] \\i\n\<^sub>r. \sKs p\\<^bsub>t i\<^esub>\ by blast with \\i\n\<^sub>s. \sKs p\\<^bsub>t i\<^esub>\ have "(p,solve(p)) = ksns (\\<^bsub>sKs p\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>)))" using sb.baEA[of n\<^sub>s "sKs p" t t'' "\ks. (p, solve p) = ksns ks"] by auto moreover from \\i\n\<^sub>s. \sKs p\\<^bsub>t i\<^esub>\ have "\sKs p\\<^bsub>t (\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>)\<^esub>" using sb.nxtActI by simp ultimately have "(p,solve(p)) \ bbns (\\<^bsub>the_bb\<^esub>(t (\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>)))" using conn1[OF pb.ts_prop(2)[of "t (\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>)"]] by auto hence "pb.eval the_bb t t' \sKs p \ t\\<^bsub>n\<^sub>s\<^esub> [\bb. (p,solve(p)) \ bbns bb]\<^sub>b" using \t\arch\ pb.baI by simp \ \finally, the blackboard will forward the solution which finishes the proof.\ with bhvbb1 have "pb.eval the_bb t t' \sKs p \ t\\<^bsub>n\<^sub>s\<^esub> (\\<^sub>b [\bb. (p, solve p) = bbcs bb]\<^sub>b)" using \t\arch\ pb.globE pb.impE[of the_bb t t'] by blast then obtain n\<^sub>f where "n\<^sub>f\\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>" and "pb.eval the_bb t t' n\<^sub>f [\bb. (p, solve p) = bbcs bb]\<^sub>b" using \t\arch\ pb.evtE[of t t' "\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>"] by auto hence "(p, solve p) = bbcs (\\<^bsub>the_bb\<^esub>(t n\<^sub>f))" using \t \ arch\ pb.baEA by auto moreover have "n\<^sub>f\n\<^sub>0" proof - from \\n'''\n\<^sub>s. \sKs p\\<^bsub>t n'''\<^esub>\ have "\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>\n\<^sub>s" using sb.nxtActLe by simp moreover from \n\<^sub>k\n\ and \\sKs p\\<^bsub>t n\<^sub>k\<^esub>\ have "\sKs p \ t\\<^bsub>n\<^sub>k\<^esub>\n\<^sub>k" using sb.nxtActI by blast ultimately show ?thesis using \n\<^sub>f\\sKs p \ t\\<^bsub>n\<^sub>s\<^esub>\ \n\<^sub>s\\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>\ \\sKs p \ t\\<^bsub>n\<^sub>r\<^esub>\n\<^sub>r\ \n\<^sub>r\\sKs p \ t\\<^bsub>n\<^sub>k\<^esub>\ \n\<^sub>k\n\ \n\n\<^sub>0\ by arith qed ultimately show ?thesis by auto qed qed qed qed qed theorem pSolved: fixes t and t'::"nat \'BB" and t''::"nat \'KS" assumes "t\arch" and "\n. (\n'\n. \sKs (bbop(\\<^bsub>the_bb\<^esub>(t n)))\\<^bsub>t n'\<^esub>)" shows "\n. (\P. (sub P \ bbrp(\\<^bsub>the_bb\<^esub>(t n)) \ (\p \ P. (\m\n. (p,solve(p)) = bbcs (\\<^bsub>the_bb\<^esub>(t m))))))" using assms pSolved_Ind by blast end end