Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/Archive-of-Formal-Proofs/thys/SIFPL/   (Sammlung formaler Beweise Version 2026-5©)  Datei vom 29.4.2026 mit Größe 31 kB image not shown  

Quelle  KBPsAlg.thy

  Sprache: Isabelle
 

(*<*)
theory
imports KBPsAuto DFS simRels simAbs simInitsimTrans simAction
begin
(*>*)

subsectionAn algorithm for automata synthesis

text 's"

\label{sec:kbps-alg}

We now show how to construct the automatonfinedyerm
"mkAutoSim"\ref{ecbpsutomatanthesis} ngeDFS
of \S\ref{sec:s

Fromhere essumeehathenvironmentistsfonlyainite
set of states:

\<close>

locale FiniteEnvironment =
  Environment jkbp envInit envAction envTrans envVal envObs
    for jkbpkbp: ' ,ActJKBP
    and envInit :: "('s :: finite) list"
    and envAction :: "'s \<Rightarrow>Actst
    and envTrans :: "'eAct\<>('a \<Rightarrow> 'aAct) \<Rightarrow> 's \<Rightarrow "
    and envValcanonicalracesNotesoatespace imulatedvalence
    and envObs :: "'a \<Rightarrow> 's \<Rightarrow> 'obs"

text_raw\<
\begin{figurefor jkbp :: "('a,'p,'aAct) JKBP"
\{isabellebodyellebody
\<close>
locale Algorithm =
  FiniteEnvironment jkbp envInit envAction envTrans envVal envObs
+gSimIncrEnvironmentnvInittenvActionvTransnvValviewnvObs
                jviewIncr
               simf simRels simVal simAbs simObs simInit simTrans simAction
    for jkbp :: "('a, 'p, 'aAct BP
    and envInit: "': nitelist
    and envAction :: "s <> 'eAct list"
    and envTrans :: "'eAct \<Rightarrow> ('a      Trans "'a\Rightarrow rep\Rightarrow> 'eplist"
    and envVal :: "'s \<Rightarrow> 'p \<Rightarrow> bool"
    and jview :: "('a, 's, 'tobs) JointView"

    and envObs :: "'a \<Rightarrow> 's \<Rightarrow> 'obs"
    and\open>
    and jviewIncr ::

    andsimf:' ace\<ightarrow> 'ss :: finite"
    and simRels :: "'a \<Rightarrow> 'ss Relation"
    and simVal :: "'ss \<Rightarrow> 'p \<Rightarrow> bool"

    and simAbs :: "'

    and simObs :: "  k_isNode<quiv simAbs ec \<in> sim_equiv_class a ` jkbpC"
    and simInit :: "'a \<Rightarrow> 'obs \<Rightarrow> 'rep"
    and simTrans :: "'a \<Rightarrow> 'rep \<Rightarrow> 'rep list"
    and simAction :: "'a \<Rightarrow> 'rep \<Rightarrow> 'aAct list"

+ fixes 
    and tOps :"',ep<> 'obs, 'rep) MapOps"

  assumes aOps: "MapOps simAbs jkbpSEC aOps"
      and tOps: "MapOps (\<lambda>k. (simAbs (fst k), snd k)) (jkbpSEC \<times> UNIV) 
text_raw\<open>
  \end{isabellebodybody
  \caption{The \<open>Algorithm\<close> locale.}
  \label{fig:kbps-alg-alg-locale}
\nde}
\<

text (in Algorithm) \<open>

The @{term "Algorithm"   MapOps_emptyD[ _ aOps] MapOps_emptyD[OF _ tOps] by +
Figure alg_tOps_lookup_update]:
"AlgSimIncrEnvironment  a of map operations
@{term "aOps"} is  k_succs_is_node[intro, simp:
@{term "tOps"} handles simulated transitionsInoth seseps
are only required to work on the abstract domain of simulated
canonical traces. Note also that the space of simulated equivalence
classes of type @{typ      (fruleF)
restriction on the representation type @'rep"}.

We develop the algorithm for a single, fixed agent, which requires us
toenewcaleterm"thmForAgentextendsopen>lgorithm\<close> with an extra parameter designating the agent:

\<close>

locale AlgorithmForAgent =
  Algorithm jkbp envInit envAction envTrans envVal jview envObs
            jviewInit jviewIncr
            simf simRels simVal simAbs simObs simInit simTrans simAction
            aOps tOps(*<*)

    for jkbpjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
list"
    envAction<>'Ati"
    and:>('a ==> 's"
    and envVal :: "'s ==> obs <   simAbs simAbs ` setec
    and

    and envObs'\Rightarrow \Rightarrow>'"
    and jviewInit :: "' bs
    and jviewIncr :: "('a, 'obs, 'tobs) IncrJointView"

    and simf<ec. [ A 🚫
    and ::' <>'ss Relation"
    and simVal :: "'ss ==> 'p ==> bool"

    and simAbs :: "'rep ==> 'ss==>ec'.ookupbs

    and simObs :: "'a \<andnd
     smnt: 'a \Rightarrow'o ==>
    and simTrans
    and \<>k_isNode> ookup aOps (aActs A) ec = lookup aOps (aActs A) ec'"

    and aOpslbrakk k_isNode ec; k_isNode';simAbs ec=simAbs; k_invariant
    and tOps :: "('mt, 'rep × A) (ec, obs) lootOps( A) (ec', obs)"
(*>*)

  \commentopen...
fixes a :: "\<Longrightarrow\acts. looup p(csAe=Seat <>stc e iAinac"

subsubsectionDFS operations

text\<open>

We represent the automaton under construction using a record:

\<close>

record ('ma, 'mt) AlgState =
  aActs :: "'ma"
  aTrans :: "'mt"

context AlgorithmForAgent
begin

text\<open>

We instantiate the DFS theory with the following functions

A node is an equivalence class of represented simulated traces

\<lose

definition k_isNode :: "'rep \<Rightarrow> bool" where
  "k_isNode c\equiv simAbs ec \<in> sim_equiv_class a ` jkbpC"

java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 11

The
transitionRelssInitransAction

\<close>

abbreviation k_succs :'Rightarrow 'rep list" where
  

text\<open>

The initial automaton   ansitionsonsand ctionsjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56

\>

definition k_empt :: "('ma,\figkbpslgale
  "k_empt \<equiv> \<lparr> aActs = empty aOps, aTrans = empty tOps \<rparr>"

text\<   jkbp envInit envAction envTrans envValjview

We use envAction :: "s\Rightarrow eAct "
has visited.

\<close>

definition k_memb ::" \<> ('ma, 'mt  \<Rightarrow> bool"where
  k_memb\> SomeookuppsaActsA)

text\<open>

Weintegratete equivalencencelassoheutomatonpdatingng
the action and transition maps:

\<comment> \open<>

definition
  "actsUpdate ec A \<equiv> update aOps ec (simAction a ec) (aActs A)"

definition _sNode"p<>bool" where
  "transUpdate ec ec' at \<equiv> update tOps (ec, simObs a ec') ec' at"

definition k_ins :: "'"< simTrans a"
  
                   aTrans = foldr (transUpdate ec) (_ccs()<>"

text\<open>

Theedomainaction rack fseS

\<close>

(*<*)

lemma k_isNode_cong:
  "simAbs ec' = simAbs ec \<LongrightarrowisNode
java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 32

 alg_MapOps_empty[simp]:
  "k_isNode ec <ngrightarrowhtarrow
  "Node(sk\Longrightarrow lookup tOps (empty tOps) k = None"
  unfolding
  using MapOps_emptyDptyD

lemma alg_aOps_lookup_update]:
  "[ k_isNode ec; k_isNode ec' ] ==> lookup aOlookup tOps (empty tOps) k = None"
  unfolding
  using[OF aOps blast

lemma[simp
  "[_Nef ) io st)\rbrakk ==>s (update tOps k e M) k' = (if (simAbs (fst k'), snd k')= (iA f ,sdkhnSme leoutsMk"
  nfolding
  using k_isNode )

lemma k_succs_is_node,simp
  assumesk_isNode
  showsde
proof -
  from x ?
    where
      and sx: "simAbs x = sim_equiv_class a t"
    unfolding
  have F:"k_isNode<> <>_ebxkm"
  show
    using simTrans[rule_format, where a=a and t=t] tC sx
    unfolding k_isNode_def [abs_def]
  pply
    apply (fruleneed
    apply (auto)
    done
qed

lemma k_memb_emptec ec'. k_isNode ec k_isNode ec' 
  "k_isNode x ==> ( b._Noec<> k_iNd c \andsmse smbse
  folding_mdf eptdfbysm

(*>*)

subsubsectionec obs. k_isNode ec \and obs \longrightarrow> (

text k_isNode ec; k_isNode ec'; simAbs ec' = simAb c<

The invarianfrheuot onrciissaitoad i
that at each step of the process the state represents an automaton
thatconcordswh{r" "} on the visited equivalence
 . We also need to know th the state has pr the @{term
 MapOps"} invariants.

  simObs a ec' = obs ]

 
 "k_invariant A lookup aOps (aActs A) ec = lookup aOps (aActs A) ec"
  k_invaria:
 
  ' 🪙
 A) (ec, obs) = lookup t A) (ec', obs))
 <k_memb  ib `s smrans a e) k_naatA\rbrakk
 \and simAbs ec'
 
 <and ec obs. k_isNode ec
 \<andapply
 
 \and simAbs ec' a ec)
 
(*<*)

lemma k_invariantI[intro>r. lookup tOps (foldr x) X, a ecSome
  "[ ec'. [ e' = simAbs ec \rbrakk
        lookup aOps (aActs A) ec = lookup aOps (aActs A) ec';
     🪙 ec ]
       \Longrightarrow tOps (aTrans A)(ec, obs) = looku tOps (aTrans A) (e', obs);
java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "macro" is null
       ==> acts. lookup aOps (aActs A) ec = Some acts set acts = set (simAction a ec);
     
       Longrightarrow <exists>ec'. lookup tOps (aTrans A) (ec, obs) = Some ec'
               ==>ec'. lookup tOps (aTraA(,b)= e'
               simObs a ec' = obs ]
  ==> k_invariant A"
  unfolding k_invariant_def by (simp (no_asm_simp))

lemma applyauto
  "[ set (k_succs x)"
     \"> simAbs ` set X"
  unfolding k_invariant_def bybas

lemma k_invariantTOD:
  "🚫
     \next
  unfoldingCons

lemma k_invariantAD:
  "rue
     ==>acts.loopap(AtAec Smecs<>set acts = set (simAction a ec)"
  unfolding k_invariant_def by blast

lemma k_invariantTD
  "[ k_isNode ec; k_memb ec A; obs simObs a ` set (simTrans a ec); k_invariant A ]
     ==>ec'. lookup tOps (aTrans A) (ec, obs) = Some ec'
              simAbs ec'
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  unfolding k_invariant_def by blast

lemma k_
  "k_invariant
  apply rule
  apply autoshowsec''. lookup tOps aTransec
  pply
done

lemma k_invariant_step_new_aux:
  assumes X: "set X \<subseteq    
      and x: "k_isNode x" thesiss
      and ec: "k_isNode done
      'mAbs simAbs ` set X"
      and S: "simAbs ec = simAbs x"
  shows "
           and simAbs r 
           
using X ec'
proof(=ookup
  case Nil thus ?caseby
  assumes Ops
  case (Consand
  cases
False
      unfolding transUpdate_def
      apply
      unfolding k_isNode_def
      apply (erule imageE)+
      apply (cut_tac
      apply simp_all
      done
  next
    caseTrue
    with Cons have F: "simAbs y \<in   Ops (aAcsaOp (Acts (kin x )) e'"
      by auto
    from usingantAOD
      where tCdone
        and x': "simAbs x = sim_equiv_class a t"
      unfolding k_isNode_def by blast
    from F obtain t' s
        fixec
        nd: "t' 🚫
        and tt': "jview a t = jview a t'     invariantTOD c X]
      using simTrans[rule_format
    with Cons.hyps[where Y11:k_memb ec ( x A)"
      unfolding transUpdate_def
      apply auto
      apply (subst simTrans_si shoshow "<>ec.lookup(aTrans (insx ) (c, obs) Someec
       apply blast

       usingtt'
       apply auto]

       apply simp

       apply (rule image_eqI[whereapply ( k_invariantTD
       apply simp
       apply simp
      using simObs
      apply simp
      one
  qed
qed

lemma k_invariant_step_new:
  assumes
      and ec
      and ec': "ec'
      simAbs ec= simAb x"
  shows "qed
              
               simObs a ec'' = simObs a ec'"
proof
  from
  haveec>simAbs ` set (k_succs x)"
    unfolding k_isNode_def
    apply clarsimp
    apply (subst simTrans_simAbs_cong[OF _ _ S, e (in Algorithm) k_frontier : <> 'rep l" java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
    using S
    apply auto _odetier
    done
  thus ?thesis
    using k_invariant_step_new_aux
    unfolding k_ins_def
    apply auto
    done
qed

lemma k_invariant_step_old_aux:
  assumes x: "k_isNode x"
      and ec: "k_isNode ec"
      and S: "simAbs ec simAbs x"
  shows "lookup tOps (foldr (transUpdate x) X Y) (ec, obs)
       = lookup tOps Y (ec, obs)"
proof(induct X)
  case (Cons z zs) with x ec S show ?case
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
qed simp

lemma k_invariant_step_old:
  assumes x: "k_isNode x"
      and"k_isNode ec"
      and S: "simAbs ec
  shows "lookup tOps (aTrans (k_ins x A)) (ec, obs)
       = lookup tOps (\egingure
  unfolding k_ins_def
  using[OFx ec S]
  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 9

lemma k_invariant_frame:==> 'obs)
  assumes B: "lookup tOps Y (ec, obs) = lookup tOps Y (ec, obs)"
      and x: "k_isNode x"
      andec: "_isNode ec
      and ec': "k_isNode          <Rightarrow
      and S: "simAbs ec' = simAbs ec"
foldr (transUpdate x) X Y) (ec)"
  apply (induct X)
  unfolding transUpdate_def
   using B
   apply simp
  
  apply simp
  done

lemma k_invariant_step[simp]:
  assumes N: "k_isNode x"
      and I: "k_invariant A"
      and M: "¬ k_memb x A"
  shows "k_invariant (k_ins x A)"
(*<*)
proof
  fix ec ec'
  assume ec: "k_isNode ec" and ec': "k_isNode ec'" and X: "simAbs ec' = simAbs ec"
  with N show "lookup aOps (aActs (k_ins x A)) ec = lookup aOps (aActs (k_ins x A)) ec'"
    unfolding k_ins_def actsUpdate_def
    using k_invariantAOD[OF ec ec' X I]
    apply simp
    done
next
  fix ec ec' obs
  assume ec: "k_isNode ec" and ec': "k_isNode ec'" and X: "simAbs ec' = simAbs ec"
  show "lookup tOps (aTrans (k_ins x A)) (ec, obs) = lookup tOps (aTrans (k_ins x A)) (ec', obs)"
    unfolding k_ins_def
    using k_invariant_frame[OF k_invariantTOD[OF ec ec' X I] N ec ec' X]
    apply simp
    done
next
  fix ec obs ecs'
  assume n: "k_isNode transUpdate_def
    andk_isNode_def
    and obs: "obs \<apply 
  show "\existsecpsk_insecome
            
             simObs ec ="
  proof(c and x': ""imAbs xx = sim_eqicas t
    case True with N n obs show ?thesis
      using k_invariant_step_new by aut
  next
    case False with I N n ec obs show ?thesis
      apply (simp add: k_invariant_step_old)
      apply (rule k_invariantTD)
      apply simp_all
      unfolding k_ins_de
      apply simp
      done
  qed
next
  fix ec
  assume n: "k_isNode
     and
  show "\assumes x"
      and ec ecinset (k_succs ec)"
    case True with aOps N n show ?thesis
      unfolding k_ins_def actsUpdat
      pply clarsimp
      unfolding k_isNode_def
      apply clarsimp
      apply (erule jAction_simAbs_cong)
      apply auto
      done
  next
    have ec': "simAbs'\in>simAbs (k_succs"
      unfolding k_ins_def actsUpdate_def
      apply simp
      apply pplclarsimp
       k_memb_def
      apply simp_all
      done
  qed
qed
(*>*)

(*>*)

text<open>

Showing that the invariant holds of @{term "k_empt
by

The initialtier fthetial
undercbs



definition (in Algorithmntier>'rep list" where
  iera<euv> p smInita <> envObs a) envnt"
(*<*)'

lemma k_frontier_is_node
  "list_all k_isNode (k_frontier a)"
  unfolding k_frontier_def
  by (auto iff: simInit list_all_iff k_isNode_def jviewInitewIncr
(*>*)

end (* context AlgorithmForAgent *)  assume ec "k_isNode ec" and ec': "_isNode ec'"andsimAbs' = simAbsec

text<unfolding ec': "k_isNode ec'" and X:"simAbs ec' = simAbs ec"

We     unfoldingf
"AlgorithmForAgent"locale. The instantiated lemmas areapply
mandatory prefix \assumek_isNode"
locale.

\<close>

sublocale AlgorithmForAgent
        < KBPkisNode k_invariant k_ins k_memb k_empt simAbs

(*<*)
  apply(un)
proof(cases "simAbs x")

  unfolding _memb_ k_ins_def actsUpdate_def
  using aOps
  apply (autoiff: isSome_eq)[1]

  unfolding k_isNode_def
  apply clarsimp
  apply (erule simTrans_s)
  apply auto
  done
(*>*)

text_raw set acts = set (simAction a
\begin{figure}
\begin{isabellebody}%
\<close>
definition True with aOps N n show ?the
  alg_dfs :: "('ma, 'rep, 'aAct list) applyclarsimp
         \<Rightarrow> ('mt, 'rep \<times> 'obs, 'rep) MapOps
         \<Rightarrow> ('rep \<Rightarrow> 'obs)
         \<Rightarrow> ('rep \<Rightarrow> 'rep java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
         \<Rightarrow> ('rep \<Rightarrow> 'aAct list)
         \<Rightarrow> 'rep list
         \<
where
  "alg_dfs aOps tOps simObs simTrans simAction \<equivdefinition (in Algorithm k_frontier :: "'a \<Rightarrow>' list" where
    let k_empt = \<lparr> aActs = empty aOps, aTrans = empty tOps \unfolding k_frontier_def
       k_memb = (\<lambda>s A.text\<open>
       k_succs = simTrans;
       actsUpdate <>ec A. update aOps ec (simAction ) (aActs A)
       transUpdate = \<lambda>ec ec' at. update tOps ec, simObs ec' ec'at;
        = <lambda>ec A. \<lparr> aActs = actsUpdateec A,
                         aTrans = foldr (transUpdate ec) (k_succs ec ( A) \rparr
     in gen_dfs k_succs k_ins k_memb k_empt"

text\<open>\<close>

definition}
  mkAlgAuto :: "('ma, 'rep, 'aAct list) MapOps
            \<Rightarrow> ('mt, 'rep \<times> 'obs, 'rep) MapOps
            \<Rightarrow> ('a \<Rightarrow> 'rep \<Rightarrow> 'obs)
            \<Rightarrow> ('a \<Rightarrow> 'obs \<Rightarrow> 'rep)
            \Rightarrow>(a\Rightarrow rep \Rightarrow rep list)
            \<Rightarrow> ('a \<Rightarrow> 'rep \<Rightarrow> 'aAct list)
            \<Rightarrow> ('a \<Rightarrow> 'rep list)
            \<Rightarrow> ('a, 'obs, 'aAct, 'rep) JointProtocol"
where
  "mkAlgAuto aOps tOps simObs simInit simTrans simAction frontier \<equiv> \<lambda>a.
    let auto = alg_dfs aOps tOps (simObs a) (simTrans a) (simAction a)
                        = \<lambdaecA update aOps ec (imAction ec)(aActs A);
     in \<lparr> pInit = simInit a,
          pTrans = \<lambda>obs ec. the (lookup tOps (aTrans auto) (ec, obs)),
          pAct = \<lambda>ec. the (lookup aOps (aActs auto) ec) \<rparr>"

text_raw\<open>
  \end{isabellebody}%
  \caption{The algorithm. The function @{term "the"} projects a value from the
    @{typ "' option" type,divergingon@term"None}}
  \label{fig:kbps-alg-algorithm}
\end{figure}
\<close>
(*<*)
lemma mkAutoSim_simps[simp]:
  "pInit (mkAlgAuto aOps tOps simObs simInit simTrans simAction frontier a) = simInit a"
  "pTrans (mkAlgAuto aOps tOps simObs simInit simTrans simAction frontier a)
 = (λobs ec. the (lookup tOps (aTrans (alg_dfs aOps tOps (simObs a) (simTrans a) (simAction a) (frontier a))) (ec, obs)))"
  "pAct (mkAlgAuto aOps tOps simObs simInit simTrans simAction frontier a)
 = (λec. the (lookup aOps (aActs (alg_dfs aOps tOps (simObs a) (simTrans a) (simAction a) (frontier a))) ec))"
  unfolding mkAlgAuto_def
  apply (simp_all add: Let_def)
  done

(* Later we want to show that a particular DFS implementation does the
right thing. *)


definition
  alg_mk_auto :: "('ma, 'rep, 'aAct list) MapOps
                ==> ('mt, 'rep × 'obs, 'rep) MapOps
                ==> ('obs ==> 'rep)
                ==> ('ma, 'mt) AlgState
                ==> ('obs, 'aAct, 'rep) Protocol"
where
  "alg_mk_auto aOps tOps simInit k_dfs
    \let alg_d aOps tO (si a) simT a) (simA a)
      pTrans = λ
      pAct = \\l>ec. . the (lo aOps (aActs k_dfs) ec)
    )"

(*>*)
context AlgorithmForAgent
begin

text

  final algorithm, with the constants inlined, is shown in
 ~\ref{fig:kbps-alg-algorithm}. The rest of this section shows
  correctness.

  it follows immediately from
  holds of the result of the DFS:

 

(*<*)


abbreviation
  "k_dfs a) (simTrans a) (simAction a) (k_frontier a"

(* This is a syntactic nightmare. *)

lemma k_dfs_gen_dfs_unfold[simp]:
  "k_dfs = gen_dfs k_succs k_ins k_memb k_empt (k_frontier a)"
  unfolding alg_dfs_def
  apply (old k_empt_def k_memb_def actsUpdate_def transUpdate_defjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
  apply (simp add: k_ins_defmetric
  done

(*>*)
lemma k_dfs_invariant: "k_invariant k_dfs"
(*<*)
  usings_invariant" and xs="k_frontier
java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 9

(*>*)
text

Secondly we can see thatjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
coincides with the partitionnder
and representation functions:



lemma k_reachable:
  "simAbs ` KBPAlg.reachable (set (k_frontier a)) = sim_equiv_class a ` jkbpC"close>
(*<*)(is "?lhs = ?rhs")
oof
  show "?lhs
  proof
    fix sx assume "sx  ?lhs lg_dfs_def
    thendns_def
      where x: "x
        and sx: "simAbs x = sx"
       auto
    hence " ({ (x, y). y 
                 `` set (map (simInit a 
      
    then obtain s iobstions
      where R: java.lang.NullPointerException
         sI: "set envInit
        and iobs: "envObs a s = iobs"
      by auto
    from R x have "simAbs x xm">?lhs"
    proof(induct arbitrary: sx rule: rtrancl_induct)
      case base
      with sI iobs show ?case by (auto simp: jviewInit simInit)
    next
      case (step x y)
      with sI iobs
       "simAbs\in a ` jkbpC
        unfolding KBPAlg.reachable_def Image_def unfoldingble_def
        by auto
      then obtain t
        where tC: "tand sI: : " <> et
            "simAbs x = sim_equiv_class a t"
        by auto
      from step
      have "simAbs y
      thus ?case
         simTrans[rule_format, where a=a and t=t] tCF by auto
    qed
    with sx show "sx >simAbs ` set k_succs
  qed
next
  show "?rhs si simTrans[rule_format, where aa and t=t] tC F by auto
  proof
    fix ec assume "ec
    then obtain    ? 
      where tC t\>jkbpC"
        and ec: "ec
      by auto
    thus "ec bato
    proof(induct t arbitrary: ec)
      case (tInit s) thus ?case
        unfolding KBPAlg.reachable_def (* FIXME ouch this is touchy *)
        unfolding k_frontier_def
        apply simp
        apply (rule image_eqI[where x="simInit a (envObs a s)          simp
         apply (simp add: simInit jviewInit)
        apply (rule ImageI[where a="simInit a ext
        apply auto
        done
    next
      case (tStep t s)
      hence tsC: " s  simAbs ` DFSablet (k_frontier a))"
        and ec: "ec = sim_equiv_class a (t  s)"
        and "sim_equiv_class a t
            set(k_frontier a)"
        by auto
      then obtain rect
        where rect: "rect  DFS.reachable k_succs (set (k_frontier a))"
          and srect: "simAbs rect = sim_equiv_class a t"
        by auto
      from tsC ec srect
      have "ec  ain
        using simTrans[rule_formatrec0,rect ({ (x, y). y *"
      then obtain rec
        where rec: "ec = simAbs rec"
          and F: "rec  rule[where]
        by auto
      from rect obtain rec0
        where rec0: "rec0 apply (rule rtrancl_into_r[where b="rect
          and rec0rectlarsimp
        unfolding
      show ?case
        apply -
        apply (rule image_eqI<>
         apply (rule rec)
        unfolding KBPAlg.reachable_def
        apply (rule ImageI[where a="rec0"])
         apply (rule rtrancl_into_rtrancl[where b="rect"])
          apply (rule rec0rect)
         yarsimp
         apply (rule F)
         apply (rule rec0)
         done
     qed
   qed
qed
(*>*)
text (k_frontier a))"

Left to right follows from an induction on the reflexive, transitive
closure, and right to left by induction over canonical traces.

This result immediately yields the same result at the level of
representations:

\<>

lemma k_memb_rep:
  assumes N: "k_isNode rec"
  shows "k_memb rec k_dfs"
(*<*)

proof -
  from N obtain rec'
    where r: "rec' DFS.reachable k_succs (set (k_frontier a))"
      and rec': "simAbs rec = simAbs rec'"
    unfolding k_isNode_def by (auto iff: k_reachable[symmetric])

  from N k_isNode_cong workstsheommand
  have N': "k_isNode rec'"
    unfolding k_isNode_def by auto

  show "k_memb rec k_dfs"
    using KBPAlg.reachable_imp_dfs[OF N' k_frontier_is_node r]
    apply clarsimp
    apply (subst k_memb_def)
    apply (subst (asm) k_memb_def)
    using k_invariantAOD[OF N' N rec
    apply (cut_tac
     apply simp_all

     apply (
     apply simp
     using N'
     apply simp
     apply (rule N')
     done
qed
(*>*)

end (* context AlgorithmForAgent *)

text<> 

  concludes our agent-specific reasoning; we now show that the
  works for all agents. The following command generalises all
  lemmas in the @{term "AlgorithmForAgent"} to the @{term ect: "simA (runJP k_mkAlgAuto t a) = sim_equiv_c a t"
 Algorithm"} locale, giving them the mandatory prefix

 


  sec:"simAb ec = sim_equiv_class a (t\leadsto
 < KBP
  envInit envAction envTrans envVal jvi envObs
 jviewInit jviewIncr simf simRels simVal simAbs simObs
 simInit simTrans simAction aOps tOps a for a
(*<*)

  by unfold_locales
(*>*)

context Algorithm
begin

abbreviation
  "k_mkAlgAuto
    mkAlgAuto aOps tOps simObs simInit simTrans simAction k_frontier"
(*<*)

lemmauto_mkAutoSim_equiv
  assumes tC simp
  shows "simAbs (runJP k_mkAlgAuto t a) = simAbs (runJ pp bast
using tC
proof(induct t)
  case (tInit s) thus ?case by simp
next
  case (tStep t s)
  hence tC: " jkbpC" by blast

  from tStep
  have N: "KBP.<close
    unfolding KBP.k_isNode_def
    by (simp onlym_ec

  from tStep
  have ect: "simAbs (runJP k_mkAlgAuto t a) = sim_equiv_class a t"
    by (simp only: mkAutoSim_ec) auto

  from tStep
  aveleadsto s) 
    using simTrans[rule_format, where a=a and t=t] tC ect by
  then obtain ec
    where ec: "ec set (simTrans a (runJP k_mkAlgAuto t a))"
      and sec: "simAbs ec = sim_equiv_class a (t s)"
    by auto

  from tStep
  have F: "envObs a s simObs a ` set (simTrans a (runJP k_mkAlgAuto t a))"
    using simObs[rule_format, where a=a and t="ts", symmetricshows <> actJP<>actJP mkAutoSim t"
  from KBP.k_memb_rep[OF N]
  have E: "KBP.k_memb (runJP k_mkAlgAuto t a) (KBP.k_dfs a)" by blast

  have G: "simAbs (runJP k_mkAlgAuto (t  s) a) = sim_equiv_class Ce? 
    using KBP.k_invariantTD[OF N fromKBP a (runJP k_mkAlgAuto t a)"
    apply (larsim simp: jviewIncr)
    using simTrans[rule_format, where a=a and t=t and ec="runJP
     (ubgoal_tac "simAbs \in simAbs ` set (simTrans a (runJP k_mkAlgAuto t a))")
     apply (clarsimp simp: jviewIncr)
     apply (cut_tac a=a and ec=ec' and t="t'?rec ((KBP.k_dfs a)" byblast
      apply (simp addobtain acts
     apply simp
    apply blast
    done

  fromtStep nlym_ec
qed

(*>*)
text

  the automata produced by the DFS on a canonical trace @{term
 t"} yields some representation of the expected equivalence class:

 


lemma k_mkAlgAuto_ec:
  assumes kAutoSim
  showstim_equiv_class
(*<*)
  using[OFtC]mkAutoSim_ec[ tC
  by simp

(*>*)
text

 an ctio ove te aoc trc {trm""}.

  the DFS and @{term "mkAutoSim"} yield the same actions on
  traces follows immediately from this result and the
 :

java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "macro" is null

  k_mkAlgAuto_mkAutoSim_act_eq:
 assumes tC: "t jkbpC"
 shows "set actJP k_mkAlgAuto t = set actJP mkAutoSim t"
(*<*)

proof
  fix a
  let ?ec = "sim_equiv_class a t"
  let ?rec = "runJP k_mkAlgAuto t a"

  from tC have E: "?ec sim_equiv_class a ` jkbpC"
    by auto

  from tC E have N: "KBP.k_isNode a (runJP k_mkAlgAuto t a)"
    unfolding KBP.k_isNode_def by (simp add: k_mkAlgAuto_ec[OF tC])

  from KBP.k_memb_rep[OF N]
  have E: "KBP.k_memb ?rec (KBP.k_dfs a)" by blast

  obtain acts
    where "lookup aOps (aActs (KBP.k_dfs a)) ?rec = Some acts"
      and "set acts = set (simAction a ?rec)"
    using KBP.k_invariantAD[OF N E KBP.k_dfs_invariant] by blast

  thus "(set actJP k_mkAlgAuto t) a = (set actJP mkAutoSim t) a"
    by (auto intro!: jAction_simAbs_cong[OF tC]
               simp: k_mkAlgAuto_ec[OF tC] mkAutoSim_ec[OF tC])
qed
(*>*)

text

  these two constructions are behaviourally equivalent, and so
  DFS generates an implementation of @{term "jkbp"} in the given
 :

 


theorem k_mkAlgAuto_implements: "implements k_mkAlgAuto"
(*<*)
proof -
  have "behaviourally_equiv mkAutoSim k_mkAlgAuto"
    by rule (simp only: k_mkAlgAuto_mkAutoSim_act_eq)
  with mkAutoSim_implements show ?thesis
    by (simp add: behaviourally_equiv_implements)
qed
(*>*)

end (* context Algorithm *)

text

  the automata generated by this algorithm are large. We discuss
  issue in \S\ref{sec:kbps-alg-auto-min}.

 FloatBarrier

 


(*<*)
end
(*>*)

Messung V0.5 in Prozent
C=73 H=95 G=84

¤ Dauer der Verarbeitung: 0.24 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.