Skip to content

Commit 00c77ea

Browse files
committed
Fix building after unrep changes
1 parent 94af1a8 commit 00c77ea

File tree

5 files changed

+60
-38
lines changed

5 files changed

+60
-38
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
export/
44
dependencies.dot
55
semantics.tex
6+
tree.tex

Papers/Tree/TreeSnippets.thy

+12-6
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,19 @@ text \<open>
427427
\<close>
428428
snipend -
429429

430+
snipbegin \<open>unique\<close>
431+
text \<open>
432+
\induct{@{thm[mode=Rule] unique.Exists [no_vars]}}{unique:exists}
433+
\induct{@{thm[mode=Rule] unique.New [no_vars]}}{unique:new}
434+
\<close>
435+
snipend -
436+
430437
snipbegin \<open>tree2graph\<close>
431438
text \<open>
432-
\induct{@{thm[mode=Rule] unrep.UnaryNodeSame [no_vars]}}{unrep:unarysame}
433-
\induct{@{thm[mode=Rule] unrep.ConstantNodeNew [no_vars]}}{unrep:constantnew}
434-
\induct{@{thm[mode=Rule] unrep.ParameterNodeNew [no_vars]}}{unrep:parameternew}
435-
\induct{@{thm[mode=Rule] unrep.UnaryNodeNew [no_vars]}}{unrep:unarynew}
436-
\induct{@{thm[mode=Rule] unrep.BinaryNodeNew [no_vars]}}{unrep:binarynew}
439+
\induct{@{thm[mode=Rule] unrep.UnrepConstantNode [no_vars]}}{unrep:constantnew}
440+
\induct{@{thm[mode=Rule] unrep.UnrepParameterNode [no_vars]}}{unrep:parameternew}
441+
\induct{@{thm[mode=Rule] unrep.UnrepUnaryNode [no_vars]}}{unrep:unarynew}
442+
\induct{@{thm[mode=Rule] unrep.UnrepBinaryNode [no_vars]}}{unrep:binarynew}
437443
\induct{@{thm[mode=Rule] unrep.AllLeafNodes [no_vars]}}{unrep:leaf}
438444
\<close>
439445
snipend -
@@ -459,7 +465,7 @@ snipend -
459465
(* definition 9 (well-formed graph) no? *)
460466

461467
snipbegin \<open>graph-semantics\<close>
462-
text \<open>@{thm encodeeval_def}\<close>
468+
text \<open>@{thm encodeeval.intros}\<close>
463469
snipend -
464470

465471
snipbegin \<open>graph-semantics-deterministic\<close>

Proofs/Rewrites.thy

+36-27
Original file line numberDiff line numberDiff line change
@@ -69,46 +69,50 @@ inductive_cases unrepVariableE:
6969
inductive_cases unrepConstVarE:
7070
"unrep g (ConstantVar c) (g', nid)"
7171

72+
lemma uniqueDet:
73+
assumes "unique g e (g'\<^sub>1, nid\<^sub>1)"
74+
assumes "unique g e (g'\<^sub>2, nid\<^sub>2)"
75+
shows "g'\<^sub>1 = g'\<^sub>2 \<and> nid\<^sub>1 = nid\<^sub>2"
76+
using assms apply (induction)
77+
apply (metis Pair_inject assms(1) assms(2) option.distinct(1) option.inject unique.cases)
78+
by (metis Pair_inject assms(1) assms(2) option.discI option.inject unique.cases)
79+
7280
lemma unrepDet:
7381
assumes "unrep g e (g'\<^sub>1, nid\<^sub>1)"
7482
assumes "unrep g e (g'\<^sub>2, nid\<^sub>2)"
7583
shows "g'\<^sub>1 = g'\<^sub>2 \<and> nid\<^sub>1 = nid\<^sub>2"
7684
using assms proof (induction e arbitrary: g g'\<^sub>1 nid\<^sub>1 g'\<^sub>2 nid\<^sub>2)
77-
case (UnaryExpr op e)
78-
then obtain g' x where "g \<oplus> e \<leadsto> (g', x)"
79-
by (meson unrepUnaryE)
80-
then have "\<forall>gg xx. g \<oplus> e \<leadsto> (gg, xx) \<longrightarrow> g' = gg \<and> x = xx"
81-
by (simp add: UnaryExpr.IH)
85+
case (UnaryExpr op e)
8286
then show ?case
83-
by (smt (verit, best) UnaryExpr.prems(1) UnaryExpr.prems(2) option.discI option.inject unrepUnaryE)
87+
by (smt (verit, best) uniqueDet unrepUnaryE)
8488
next
8589
case (BinaryExpr x1 e1 e2)
8690
then show ?case
87-
by (smt (verit) option.distinct(1) option.inject unrepBinaryE)
91+
by (smt (verit, best) uniqueDet unrepBinaryE)
8892
next
8993
case (ConditionalExpr e1 e2 e3)
9094
then show ?case
91-
by (smt (verit) option.distinct(1) option.inject unrepConditionalE)
95+
by (smt (verit, best) uniqueDet unrepConditionalE)
9296
next
9397
case (ParameterExpr x1 x2)
9498
then show ?case
95-
by (smt (verit) option.distinct(1) option.inject unrepParamE)
99+
by (smt (verit, best) uniqueDet unrepParamE)
96100
next
97101
case (LeafExpr x1 x2)
98102
then show ?case
99-
by (smt (verit) option.distinct(1) option.inject unrepLeafE)
103+
by (smt (verit, best) uniqueDet unrepLeafE)
100104
next
101105
case (ConstantExpr x)
102106
then show ?case
103-
by (smt (verit) option.distinct(1) option.inject unrepConstE)
107+
by (smt (verit, best) uniqueDet unrepConstE)
104108
next
105109
case (ConstantVar x)
106110
then show ?case
107-
by (smt (verit) option.distinct(1) option.inject unrepConstVarE)
111+
by (smt (verit, best) uniqueDet unrepConstVarE)
108112
next
109113
case (VariableExpr x1 x2)
110114
then show ?case
111-
by (smt (verit) option.distinct(1) option.inject unrepVariableE)
115+
by (smt (verit, best) uniqueDet unrepVariableE)
112116
qed
113117

114118

@@ -183,9 +187,13 @@ lemma
183187
qed
184188
*)
185189

190+
lemma insertConstUnique:
191+
"\<exists>g' nid'. unique g (ConstantNode c, s) (g', nid')"
192+
by (meson not_None_eq unique.simps)
193+
186194
lemma insertConst:
187195
"\<exists>g' nid'. unrep g (ConstantExpr c) (g', nid')"
188-
by (meson not_None_eq unrep.intros(1) unrep.intros(2))
196+
using UnrepConstantNode insertConstUnique by blast
189197

190198
lemma constantConditionTrue:
191199
assumes "kind g ifcond = IfNode cond t f"
@@ -197,9 +205,9 @@ proof -
197205
obtain g'' nid' where unrep: "unrep g (ConstantExpr (bool_to_val_width1 True)) (g'', nid')"
198206
using insertConst by blast
199207
then have "kind g'' nid' = ConstantNode (bool_to_val_width1 True)"
200-
by (smt (verit) ConstUnrepE IRExpr.simps(18) IRExpr.simps(30) IRExpr.simps(40) IRExpr.simps(48) IRExpr.simps(54) IRExpr.simps(6) IRNode.simps(1141) find_exists_kind find_new_kind option.distinct(1) option.inject unrep.simps)
208+
by (meson ConstUnrepE IRNode.distinct(1077) unique_kind)
201209
also have "nid' \<noteq> ifcond"
202-
by (smt (verit) IRExpr.simps(18) IRExpr.simps(30) IRExpr.simps(40) IRNode.distinct(981) \<open>g::IRGraph \<oplus> ConstantExpr (bool_to_val_width1 True) \<leadsto> (g''::IRGraph, nid'::nat)\<close> assms(1) calculation fresh_ids ifn not_in_g prod.inject unrep.simps)
210+
by (metis ConstUnrepE IRNode.distinct(981) assms(1) calculation fresh_ids ids_some ifn unique.cases unrep unrepDet)
203211
moreover have "g' = replace_node ifcond (IfNode nid' t f, stamp g ifcond) g''"
204212
using assms constantCondition_sem unrep by presburger
205213
moreover have "kind g' nid' = ConstantNode (bool_to_val_width1 True)"
@@ -223,10 +231,10 @@ proof -
223231
by fastforce
224232
then have "[g', m, p] \<turnstile> nid' \<mapsto> IntVal 1 1"
225233
using Value.distinct(1) \<open>kind g' nid' = ConstantNode (bool_to_val_width1 True)\<close>
226-
by (metis bool_to_val_width1.simps(1) wf_value_def encodeeval_def ConstantExpr ConstantNode)
234+
by (metis bool_to_val_width1.simps(1) wf_value_def encodeeval.simps ConstantExpr ConstantNode)
227235
from if' c' show ?thesis
228236
by (metis (no_types, opaque_lifting) val_to_bool.simps(1) \<open>[g',m,p] \<turnstile> nid' \<mapsto> IntVal 1 1\<close>
229-
encodeeval_def zero_neq_one IfNode)
237+
zero_neq_one IfNode)
230238
qed
231239

232240
lemma constantConditionFalse:
@@ -239,11 +247,11 @@ proof -
239247
obtain g'' nid' where unrep: "unrep g (ConstantExpr (bool_to_val_width1 False)) (g'', nid')"
240248
using insertConst by blast
241249
also have "kind g'' nid' = ConstantNode (bool_to_val_width1 False)"
242-
by (smt (verit) IRExpr.sel(14) IRExpr.simps(18) IRExpr.simps(30) IRExpr.simps(40) IRExpr.simps(48) IRExpr.simps(54) IRNode.distinct(1077) find_exists_kind find_new_kind unrep unrep.simps unrepDet)
250+
by (meson ConstUnrepE IRNode.distinct(1077) unique_kind unrep)
243251
moreover have "nid' \<noteq> ifcond"
244-
by (smt (verit) IRExpr.simps(18) IRExpr.simps(30) IRExpr.simps(40) IRNode.distinct(981) assms(1) calculation fresh_ids ifn not_in_g prod.inject unrep.simps)
252+
by (metis ConstUnrepE IRNode.distinct(981) assms(1) calculation(2) fresh_ids ids_some ifn unique.cases unrep unrepDet)
245253
moreover have "g' = replace_node ifcond (IfNode nid' t f, stamp g ifcond) g''"
246-
using assms constantCondition_sem unrep by presburger
254+
using assms(1) assms(2) constantCondition_sem unrep by presburger
247255
moreover have "kind g' nid' = ConstantNode (bool_to_val_width1 False)"
248256
using assms constantCondition.simps(1) replace_node_unchanged
249257
by (metis DiffI calculation(2) calculation(3) calculation(4) emptyE insert_iff unrep unrep_contains)
@@ -257,9 +265,9 @@ proof -
257265
have "valid_value (IntVal 1 0) (constantAsStamp (IntVal 1 0))"
258266
by auto
259267
then have "[g', m, p] \<turnstile> nid' \<mapsto> IntVal 1 0"
260-
by (meson ConstantExpr ConstantNode c' encodeeval_def wf_value_def)
268+
by (meson ConstantExpr ConstantNode c' encodeeval.simps wf_value_def)
261269
from if' c' show ?thesis
262-
by (meson IfNode \<open>[g'::IRGraph,m::nat \<Rightarrow> Value,p::Value list] \<turnstile> nid'::nat \<mapsto> IntVal (1::nat) (0::64 word)\<close> encodeeval_def val_to_bool.simps(1))
270+
by (meson IfNode \<open>[g'::IRGraph,m::nat \<Rightarrow> Value,p::Value list] \<turnstile> nid'::nat \<mapsto> IntVal (1::nat) (0::64 word)\<close> encodeeval.simps val_to_bool.simps(1))
263271
qed
264272

265273
lemma diff_forall:
@@ -299,8 +307,9 @@ lemma changeonly_ConstantExpr:
299307
shows "changeonly {} g g'"
300308
using assms
301309
apply (cases "find_node_and_stamp g (ConstantNode c, constantAsStamp c) = None")
302-
apply (smt (verit, del_insts) ConstantNodeNew add_changed changeonly.simps fresh_ids insertE unrepDet)
303-
by (smt (verit) IRExpr.sel(14) IRExpr.simps(18) IRExpr.simps(30) IRExpr.simps(40) IRExpr.simps(48) changeonly.simps unrep.simps unrepDet)
310+
apply (smt (verit, ccfv_threshold) New add_node_as_set_eq changeonly.simps fresh_ids new_def not_excluded_keep_type order.refl uniqueDet unrepConstE unrep_preserves_contains)
311+
by (metis changeonly.simps unique.cases unrepConstE unrepDet)
312+
304313

305314
lemma constantCondition_changeonly:
306315
assumes "nid \<in> ids g"
@@ -346,15 +355,15 @@ lemma constantConditionValid:
346355
proof (cases "const")
347356
case True
348357
have ifstep: "g, p \<turnstile> (ifcond, m, h) \<rightarrow> (t, m, h)"
349-
by (meson IfNode True assms(1,2,3) encodeeval_def)
358+
by (meson IfNode True assms(1,2,3) encodeeval.simps)
350359
have ifstep': "g', p \<turnstile> (ifcond, m, h) \<rightarrow> (t, m, h)"
351360
using constantConditionTrue True assms(1,4) by presburger
352361
from ifstep ifstep' show ?thesis
353362
using StutterStep by blast
354363
next
355364
case False
356365
have ifstep: "g, p \<turnstile> (ifcond, m, h) \<rightarrow> (f, m, h)"
357-
by (meson IfNode False assms(1,2,3) encodeeval_def)
366+
by (meson IfNode False assms(1,2,3) encodeeval.simps)
358367
have ifstep': "g', p \<turnstile> (ifcond, m, h) \<rightarrow> (f, m, h)"
359368
using constantConditionFalse False assms(1,4) by presburger
360369
from ifstep ifstep' show ?thesis

ROOT

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ session Semantics in Semantics = Graph +
2828
show_question_marks = false, quick_and_dirty]
2929
sessions
3030
"HOL-Eisbach"
31+
Snippets
3132
theories
3233
Form
3334
IRGraphFrames

Semantics/TreeToGraph.thy

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ theory TreeToGraph
44
imports
55
Semantics.IRTreeEval
66
Graph.IRGraph
7+
Snippets.Snipping
78
begin
89

910
subsection \<open>Subgraph to Data-flow Tree\<close>
@@ -480,14 +481,17 @@ code_pred (modes: i \<Rightarrow> i \<Rightarrow> o \<Rightarrow> bool as unrepE
480481
[show_steps,show_mode_inference,show_intermediate_results]
481482
*) unrep .
482483

483-
text_raw \<open>\Snip{unique}%
484+
snipbegin \<open>uniqueRules\<close>
485+
text \<open>
484486
\begin{center}
485487
@{thm[mode=Rule] unique.Exists [no_vars]}\\[8px]
486488
@{thm[mode=Rule] unique.New [no_vars]}\\[8px]
487489
\end{center}
488-
\EndSnip\<close>
490+
\<close>
491+
snipend -
489492

490-
text_raw \<open>\Snip{unrepRules}%
493+
snipbegin \<open>unrepRules\<close>
494+
text \<open>
491495
\begin{center}
492496
@{thm[mode=Rule] unrep.UnrepConstantNode [no_vars]}\\[8px]
493497
@{thm[mode=Rule] unrep.UnrepParameterNode [no_vars]}\\[8px]
@@ -496,7 +500,8 @@ text_raw \<open>\Snip{unrepRules}%
496500
@{thm[mode=Rule] unrep.UnrepUnaryNode [no_vars]}\\[8px]
497501
@{thm[mode=Rule] unrep.AllLeafNodes [no_vars]}\\[8px]
498502
\end{center}
499-
\EndSnip\<close>
503+
\<close>
504+
snipend -
500505

501506
(*
502507
instantiation IRGraph :: equal begin
@@ -513,7 +518,7 @@ qed
513518
end
514519
*)
515520

516-
values "{(n, g) . (eg2_sq \<oplus> sq_param0 \<leadsto> (g, n))}"
521+
(*values "{(n, g) . (eg2_sq \<oplus> sq_param0 \<leadsto> (g, n))}"*)
517522

518523
subsection \<open>Lift Data-flow Tree Semantics\<close>
519524

0 commit comments

Comments
 (0)