theory DynPDG imports "../Basic/DynDataDependence" "../Basic/CFGExit_wf" "../Basic/DynStandardControlDependence" "../Basic/DynWeakControlDependence" begin
subsection‹The dynamic PDG›
locale DynPDG =
CFGExit_wf sourcenode targetnode kind valid_edge Entry DefUse state_val Exit for sourcenode :: "'edge ==> 'node"and targetnode :: "'edge ==> 'node" and kind :: "'edge ==> 'state edge_kind"and valid_edge :: "'edge ==> bool" and Entry :: "'node" (‹'('_Entry'_')›) andDef :: "'node ==> 'var set" andUse :: "'node ==> 'var set"and state_val :: "'state ==> 'var ==> 'val" andExit :: "'node" (‹'('_Exit'_')›) + fixes dyn_control_dependence :: "'node ==> 'node ==> 'edge list ==> bool"
(‹_ controls _ via _› [51,0,0]) assumes Exit_not_dyn_control_dependent:"n controls n' via as ==> n' ≠ (_Exit_)" assumes dyn_control_dependence_path: "n controls n' via as ==> n -as→* n' ∧ as ≠ []"
begin
inductive cdep_edge :: "'node ==> 'edge list ==> 'node ==> bool"
(‹_ -_→cd _› [51,0,0] 80) and ddep_edge :: "'node ==> 'var ==> 'edge list ==> 'node ==> bool"
(‹_ -'{_'}_→dd _› [51,0,0,0] 80) and DynPDG_edge :: "'node ==> 'var option ==> 'edge list ==> 'node ==> bool"
where
― ‹Syntax› "n -as→cd n' == DynPDG_edge n None as n'"
| "n -{V}as→dd n' == DynPDG_edge n (Some V) as n'"
― ‹Rules›
| DynPDG_cdep_edge: "n controls n' via as ==> n -as→cd n'"
| DynPDG_ddep_edge: "n influences V in n' via as ==> n -{V}as→dd n'"
lemma DynPDG_path_CFG_path: "n -as→d* n' ==> n -as→* n'" proof(induct rule:DynPDG_path.induct) case DynPDG_path_Nil thus ?caseby(rule empty_path) next case (DynPDG_path_Append_cdep n as n'' as' n') from‹n'' -as'→cd n'›have"n'' -as'→* n'" by(rule DynPDG_cdep_edge_CFG_path(1)) with‹n -as→* n''›show ?caseby(rule path_Append) next case (DynPDG_path_Append_ddep n as n'' V as' n') from‹n'' -{V}as'→dd n'›have"n'' -as'→* n'" by(rule DynPDG_ddep_edge_CFG_path(1)) with‹n -as→* n''›show ?caseby(rule path_Append) qed
lemma DynPDG_path_split: "n -as→d* n' ==> (as = [] ∧ n = n') ∨ (∃n'' asx asx'. (n -asx→cd n'') ∧ (n'' -asx'→d* n') ∧ (as = asx@asx')) ∨ (∃n'' V asx asx'. (n -{V}asx→dd n'') ∧ (n'' -asx'→d* n') ∧ (as = asx@asx'))" proof(induct rule:DynPDG_path.induct) case (DynPDG_path_Nil n) thus ?caseby auto next case (DynPDG_path_Append_cdep n as n'' as' n') note IH = ‹as = [] ∧ n = n'' ∨
(∃nx asx asx'. n -asx→cd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx') ∨
(∃nx V asx asx'. n -{V}asx→dd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx')› from IH show ?case proof assume"as = [] ∧ n = n''" with‹n'' -as'→cd n'›have"valid_node n'" by(fastforce intro:path_valid_node(2) DynPDG_path_CFG_path
DynPDG_path_cdep) with‹as = [] ∧ n = n''›‹n'' -as'→cd n'› have"∃n'' asx asx'. n -asx→cd n'' ∧ n'' -asx'→d* n' ∧ as@as' = asx@asx'" by(auto intro:DynPDG_path_Nil) thus ?thesis by simp next assume"(∃nx asx asx'. n -asx→cd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx') ∨ (∃nx V asx asx'. n -{V}asx→dd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx')" thus ?thesis proof assume"∃nx asx asx'. n -asx→cd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx'" thenobtain nx asx asx' where"n -asx→cd nx"and"nx -asx'→d* n''" and"as = asx@asx'"by auto from‹n'' -as'→cd n'›have"n'' -as'→d* n'"by(rule DynPDG_path_cdep) with‹nx -asx'→d* n''›have"nx -asx'@as'→d* n'" by(fastforce intro:DynPDG_path_Append) with‹n -asx→cd nx›‹as = asx@asx'› have"∃n'' asx asx'. n -asx→cd n'' ∧ n'' -asx'→d* n' ∧ as@as' = asx@asx'" by auto thus ?thesis by simp next assume"∃nx V asx asx'. n -{V}asx→dd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx'" thenobtain nx V asx asx' where"n -{V}asx→dd nx"and"nx -asx'→d* n''" and"as = asx@asx'"by auto from‹n'' -as'→cd n'›have"n'' -as'→d* n'"by(rule DynPDG_path_cdep) with‹nx -asx'→d* n''›have"nx -asx'@as'→d* n'" by(fastforce intro:DynPDG_path_Append) with‹n -{V}asx→dd nx›‹as = asx@asx'› have"∃n'' V asx asx'. n -{V}asx→dd n'' ∧ n'' -asx'→d* n' ∧ as@as' = asx@asx'" by auto thus ?thesis by simp qed qed next case (DynPDG_path_Append_ddep n as n'' V as' n') note IH = ‹as = [] ∧ n = n'' ∨
(∃nx asx asx'. n -asx→cd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx') ∨
(∃nx V asx asx'. n -{V}asx→dd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx')› from IH show ?case proof assume"as = [] ∧ n = n''" with‹n'' -{V}as'→dd n'›have"valid_node n'" by(fastforce intro:path_valid_node(2) DynPDG_path_CFG_path
DynPDG_path_ddep) with‹as = [] ∧ n = n''›‹n'' -{V}as'→dd n'› have"∃n'' V asx asx'. n -{V}asx→dd n'' ∧ n'' -asx'→d* n' ∧ as@as' = asx@asx'" by(fastforce intro:DynPDG_path_Nil) thus ?thesis by simp next assume"(∃nx asx asx'. n -asx→cd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx') ∨ (∃nx V asx asx'. n -{V}asx→dd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx')" thus ?thesis proof assume"∃nx asx asx'. n -asx→cd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx'" thenobtain nx asx asx' where"n -asx→cd nx"and"nx -asx'→d* n''" and"as = asx@asx'"by auto from‹n'' -{V}as'→dd n'›have"n'' -as'→d* n'"by(rule DynPDG_path_ddep) with‹nx -asx'→d* n''›have"nx -asx'@as'→d* n'" by(fastforce intro:DynPDG_path_Append) with‹n -asx→cd nx›‹as = asx@asx'› have"∃n'' asx asx'. n -asx→cd n'' ∧ n'' -asx'→d* n' ∧ as@as' = asx@asx'" by auto thus ?thesis by simp next assume"∃nx V asx asx'. n -{V}asx→dd nx ∧ nx -asx'→d* n'' ∧ as = asx@asx'" thenobtain nx V' asx asx' where"n -{V'}asx→dd nx"and"nx -asx'→d* n''" and"as = asx@asx'"by auto from‹n'' -{V}as'→dd n'›have"n'' -as'→d* n'"by(rule DynPDG_path_ddep) with‹nx -asx'→d* n''›have"nx -asx'@as'→d* n'" by(fastforce intro:DynPDG_path_Append) with‹n -{V'}asx→dd nx›‹as = asx@asx'› have"∃n'' V asx asx'. n -{V}asx→dd n'' ∧ n'' -asx'→d* n' ∧ as@as' = asx@asx'" by auto thus ?thesis by simp qed qed qed
lemma DynPDG_ddep_edge_no_shorter_ddep_edge: assumes ddep:"n -{V}as→dd n'" shows"∀as' a as''. tl as = as'@a#as'' ⟶¬ sourcenode a -{V}a#as''→dd n'" proof - from ddep have influence:"n influences V in n' via as" by(auto elim!:DynPDG_edge.cases) thenobtain a asx where as:"as = a#asx" and notin:"n ∉ set (sourcenodes asx)" by(auto dest:dyn_influence_source_notin_tl_edges simp:dyn_data_dependence_def) from influence as have imp:"∀nx ∈ set (sourcenodes asx). V ∉ Def nx" by(auto simp:dyn_data_dependence_def)
{ fix as' a' as'' assume eq:"tl as = as'@a'#as''" and ddep':"sourcenode a' -{V}a'#as''→dd n'" from eq as notin have noteq:"sourcenode a' ≠ n"by(auto simp:sourcenodes_def) from ddep' have"V ∈ Def (sourcenode a')" by(auto elim!:DynPDG_edge.cases simp:dyn_data_dependence_def) with eq as noteq imp have False by(auto simp:sourcenodes_def) } thus ?thesis by blast qed
lemma no_ddep_same_state: assumes path:"n -as→* n'"andUses:"V ∈ Use n'"and preds:"preds (kinds as) s" and no_dep:"∀as' a as''. as = as'@a#as'' ⟶¬ sourcenode a -{V}a#as''→dd n'" shows"state_val (transfers (kinds as) s) V = state_val s V" proof -
{ fix n'' assume inset:"n'' ∈ set (sourcenodes as)"andDefs:"V ∈ Def n''" hence"∃nx ∈ set (sourcenodes as). V ∈ Def nx"by auto thenobtain nx ns' ns'' where nodes:"sourcenodes as = ns'@nx#ns''" andDefs':"V ∈ Def nx"and notDef:"∀nx' ∈ set ns''. V ∉ Def nx'" by(fastforce elim!:rightmost_element_property) from nodes obtain as' a as'' where as'':"sourcenodes as'' = ns''"and as:"as=as'@a#as''" and source:"sourcenode a = nx" by(fastforce elim:map_append_append_maps simp:sourcenodes_def) from as path have path':"sourcenode a -a#as''→* n'" by(fastforce dest:path_split_second) from notDef as'' source have"∀n'' ∈ set (sourcenodes as''). V ∉ Def n''" by(auto simp:sourcenodes_def) with path' Defs' Uses source have influence:"nx influences V in n' via (a#as'')" by(simp add:dyn_data_dependence_def) hence"nx ∉ set (sourcenodes as'')"by(rule dyn_influence_source_notin_tl_edges) with influence source have"∃asx a'. sourcenode a' -{V}a'#asx→dd n' ∧ sourcenode a' = nx ∧ (∃asx'. a#as'' = asx'@a'#asx)" by(fastforce intro:DynPDG_ddep_edge) with nodes no_dep as have False by(auto simp:sourcenodes_def) } hence"∀n ∈ set (sourcenodes as). V ∉ Def n"by auto with wf path preds show ?thesis by(fastforce intro:CFG_path_no_Def_equal) qed
lemma DynPDG_scd: "DynPDG sourcenode targetnode kind valid_edge (_Entry_) Def Use state_val (_Exit_) dyn_standard_control_dependence" proof(unfold_locales) fix n n' as assume"n controlss n' via as" show"n' ≠ (_Exit_)" proof assume"n' = (_Exit_)" with‹n controlss n' via as›show False by(fastforce intro:Exit_not_dyn_standard_control_dependent) qed next fix n n' as assume"n controlss n' via as" thus"n -as→* n' ∧ as ≠ []" by(fastforce simp:dyn_standard_control_dependence_def) qed
lemma DynPDG_wcd: "DynPDG sourcenode targetnode kind valid_edge (_Entry_) Def Use state_val (_Exit_) dyn_weak_control_dependence" proof(unfold_locales) fix n n' as assume"n weakly controls n' via as" show"n' ≠ (_Exit_)" proof assume"n' = (_Exit_)" with‹n weakly controls n' via as›show False by(fastforce intro:Exit_not_dyn_weak_control_dependent) qed next fix n n' as assume"n weakly controls n' via as" thus"n -as→* n' ∧ as ≠ []" by(fastforce simp:dyn_weak_control_dependence_def) qed
end
subsection‹Data slice›
definition (in CFG) empty_control_dependence :: "'node ==> 'node ==> 'edge list ==> bool" where"empty_control_dependence n n' as ≡ False"
lemma (in CFGExit_wf) DynPDG_scd: "DynPDG sourcenode targetnode kind valid_edge (_Entry_) Def Use state_val (_Exit_) empty_control_dependence" proof(unfold_locales) fix n n' as assume"empty_control_dependence n n' as" thus"n' ≠ (_Exit_)"by(simp add:empty_control_dependence_def) next fix n n' as assume"empty_control_dependence n n' as" thus"n -as→* n' ∧ as ≠ []"by(simp add:empty_control_dependence_def) qed
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.