Theory SemanticsSnippets
theory SemanticsSnippets
imports
Semantics.IRStepObj Semantics.Form Proofs.Stuttering Snippets.Snipping
begin
declare [[show_types=false]]
notation (latex)
kind ("_⟪_⟫")
notation (latex)
stamp_expr ("\<^latex>‹\\pitchfork› _")
notation (latex)
val_to_bool ("_\<^latex>‹\\ensuremath{_{\\mathit{›bool\<^latex>‹}}}›")
syntax (spaced_type_def output)
"_constrain" :: "logic => type => logic" ("_ :: _" [4, 0] 3)
snipbegin ‹isbinary›
text ‹\begin{center}
@{term_type[mode=spaced_type_def] is_BinaryArithmeticNode}
\end{center}›
snipend -
snipbegin ‹inputsof›
text_raw ‹
@{term_type[mode=spaced_type_def] inputs_of}
@{thm inputs_of_ConstantNode}
@{thm inputs_of_ParameterNode}
@{thm inputs_of_ValuePhiNode}
@{thm inputs_of_AddNode}
@{thm inputs_of_IfNode}›
snipend -
snipbegin ‹graphdefnostamp›
text_raw ‹
@{bold ‹typedef›} @{term[source] ‹IRGraph = {g :: ID ⇀ IRNode . finite (dom g)}›}
›
snipend -
fun ids_fake :: "(ID ⇀ IRNode) ⇒ ID set" where
"ids_fake g = {nid ∈ dom g . g nid ≠ (Some NoNode)}"
fun kind_fake :: "(ID ⇀ IRNode) ⇒ (ID ⇒ IRNode)" where
"kind_fake g = (λnid. (case g nid of None ⇒ NoNode | Some v ⇒ v))"
snipbegin ‹helpersdisplay›
text_raw ‹
@{term_type[mode=spaced_type_def] ids_fake}
@{thm ids_fake.simps}\\[0.75em]
@{term_type[mode=spaced_type_def] kind_fake}
@{thm kind_fake.simps}\\[0.75em]
@{term_type[mode=spaced_type_def] inputs}
@{thm inputs.simps}\\[0.75em]
@{term_type[mode=spaced_type_def] succ}
@{thm succ.simps}\\[0.75em]
@{term_type[mode=spaced_type_def] input_edges}
@{thm input_edges.simps}\\[0.75em]
@{term_type[mode=spaced_type_def] usages}
@{thm usages.simps}\\[0.75em]
@{term_type[mode=spaced_type_def] successor_edges}
@{thm successor_edges.simps}\\[0.75em]
@{term_type[mode=spaced_type_def] predecessors}
@{thm predecessors.simps}\\[0.75em]
›
snipend -
snipbegin ‹wf_start_def›
text_raw ‹
@{thm[display,margin=40] wf_start_def}
›
snipend -
snipbegin ‹wf_closed_def›
text_raw ‹
@{thm[display,margin=40] wf_closed_def}
›
snipend -
snipbegin ‹wf_phis_def›
text_raw ‹
@{thm[display,margin=40] wf_phis_def}
›
snipend -
snipbegin ‹wf_ends_def›
text_raw ‹
@{thm[display,margin=40] wf_ends_def}
›
snipend -
snipbegin ‹wf_graph_def›
text_raw ‹
@{term_type[mode=spaced_type_def] wf_graph}
@{thm wf_graph.simps}
›
snipend -
text_raw ‹@{bold ‹type-synonym›} Signature = @{typ string}›
snipbegin ‹programdef›
text_raw ‹
@{bold ‹type-synonym›} Program = @{typ "Signature ⇀ IRGraph"}
›
snipend -
print_antiquotations
snipbegin ‹heapdef›
type_synonym Heap = "string ⇒ objref ⇒ Value"
type_synonym Free = "nat"
type_synonym DynamicHeap = "Heap × Free"
text_raw ‹
\\[0.75em]
@{text ‹h_load_field :: ›} @{typ[source] "string ⇒ objref ⇒ DynamicHeap ⇒ Value"}
@{thm h_load_field.simps}\\[0.75em]
@{text ‹h_store_field :: ›} @{typ[source] "string ⇒ objref ⇒ Value ⇒ DynamicHeap ⇒ DynamicHeap"}
@{thm h_store_field.simps}\\[0.75em]
@{text ‹h_new_inst :: ›} @{typ[source] "DynamicHeap ⇒ (DynamicHeap × Value)"}
@{thm h_new_inst.simps}
›
snipend -
snipbegin ‹StepSemantics›
text ‹
\begin{center}
\induct{@{thm[mode=Rule] step.SequentialNode [no_vars]}}{step:seq}
\induct{@{thm[mode=Rule] step.IfNode [no_vars]}}{step:if}
\induct{@{thm[mode=Rule] step.EndNodes [no_vars]}}{step:end}
\induct{@{thm[mode=Rule] step.NewInstanceNode [no_vars]}}{step:newinst}
\induct{@{thm[mode=Rule] step.LoadFieldNode [no_vars]}}{step:load}
\induct{@{thm[mode=Rule] step.StoreFieldNode [no_vars]}}{step:store}
\induct{@{thm[mode=Rule] step.StaticLoadFieldNode [no_vars]}}{step:load-static}
\induct{@{thm[mode=Rule] step.StaticStoreFieldNode [no_vars]}}{step:store-static}
\end{center}
›
snipend -
snipbegin ‹TopStepSemantics›
text ‹
\begin{center}
\induct{@{thm[mode=Rule] step_top.Lift [no_vars]}}{top:lift}
\induct{@{thm[mode=Rule] step_top.InvokeNodeStep [no_vars]}}{top:invoke}
\induct{@{thm[mode=Rule] step_top.ReturnNode [no_vars]}}{top:return}
\induct{@{thm[mode=Rule] step_top.ReturnNodeVoid [no_vars]}}{top:return-void}
\induct{@{thm[mode=Rule] step_top.UnwindNode [no_vars]}}{top:unwind}
\end{center}
›
snipend -
snipbegin ‹Stutter›
text ‹
\begin{center}
@{thm[mode=Rule] stutter.StutterStep [no_vars]}\\[8px]
@{thm[mode=Rule] stutter.Transitive [no_vars]}
\end{center}
›
snipend -
notation (latex output)
filtered_inputs ("inputs\<^latex>‹\\ensuremath{^{\\mathit{›_⟪_⟫\<^latex>‹}}}›\<^latex>‹\\ensuremath{_{\\mathit{›_\<^latex>‹}}}›")
notation (latex output)
filtered_successors ("succ\<^latex>‹\\ensuremath{^{\\mathit{›_⟪_⟫\<^latex>‹}}}›\<^latex>‹\\ensuremath{_{\\mathit{›_\<^latex>‹}}}›")
notation (latex output)
filtered_usages ("usages\<^latex>‹\\ensuremath{^{\\mathit{›_⟪_⟫\<^latex>‹}}}›\<^latex>‹\\ensuremath{_{\\mathit{›_\<^latex>‹}}}›")
snipbegin ‹example2›
text_raw ‹
@{term[display] ‹filtered_inputs g nid f›}
›
snipend -
notation (latex output)
Pure.dummy_pattern ("-")
notation (latex output)
IntVal ("IntVal (2 _)")
end