@@ -320,40 +320,43 @@ next
320320 using ST_LetI.IH term . eq_iff ( 5 ) by blast
321321qed
322322
323- inductive Steps_aux :: "term \<Rightarrow> term \<Rightarrow> bool" where
324- refl : "Steps_aux e e "
325- | trans : "\<lbrakk > Step e1 e2 ; Steps_aux e2 e3 \<rbrakk> \<Longrightarrow> Steps_aux e1 e3 "
323+ fun path :: "term \<Rightarrow> term list \<Rightarrow> term \<Rightarrow> bool" where
324+ "path a [] b \<longleftrightarrow> a = b \<or> Step a b "
325+ | "path a (x#xs) b \<longleftrightarrow > Step a x \<and> path x xs b "
326326
327- lemma Steps_aux_concat : "\<lbrakk> Steps_aux e1 e2 ; Steps_aux e2 e3 \<rbrakk> \<Longrightarrow> Steps_aux e1 e3"
328- apply ( induction e1 e2 arbitrary : e3 rule : Steps_aux.induct )
329- using Steps_aux.simps by blast +
327+ lemma path_snoc : "\<lbrakk> path a xs b ; Step b c \<rbrakk> \<Longrightarrow> path a (xs@[b]) c \<or> path a xs c"
328+ by ( induction a xs b arbitrary : c rule : path.induct ) auto
330329
331330lemma Steps_concat : "\<lbrakk> e2 \<longrightarrow>* e3 ; e1 \<longrightarrow>* e2 \<rbrakk> \<Longrightarrow> e1 \<longrightarrow>* e3"
332331 apply ( induction e2 e3 arbitrary : e1 rule : Steps.induct )
333332 using Steps.simps by blast +
334333
335- lemma Steps_Steps_aux_equivalent : "a \<longrightarrow>* b \<longleftrightarrow> Steps_aux a b "
334+ lemma Steps_path : "a \<longrightarrow>* b \<longleftrightarrow> (\<exists>p. path a p b) "
336335proof
337336 assume "a \<longrightarrow>* b"
338- then show "Steps_aux a b"
337+ then show "\<exists>p. path a p b"
339338 proof ( induction a b rule : Steps.induct )
340339 case ( refl e )
341- then show ?case using Steps_aux.refl .
340+ then have "path e [] e" by simp
341+ then show ?case by blast
342342 next
343343 case ( trans e1 e2 e3 )
344- then have "Steps_aux e2 e3" using Steps_aux.simps by blast
345- then show ?case using trans ( 3 ) Steps_aux_concat by blast
344+ then obtain xs where "path e1 xs e2" by blast
345+ then have "path e1 (xs@[e2]) e3 \<or> path e1 xs e3" using trans ( 2 ) path_snoc by simp
346+ then show ?case by blast
346347 qed
347348next
348- assume "Steps_aux a b"
349+ assume "\<exists>p. path a p b"
350+ then obtain p where "path a p b" by blast
349351 then show "a \<longrightarrow>* b"
350- proof ( induction a b rule : Steps_aux .induct)
351- case ( refl e )
352- then show ?case using Steps.refl .
352+ proof ( induction a p b rule : path .induct)
353+ case ( 1 a b )
354+ then show ?case using Steps.intros by auto
353355 next
354- case ( trans e1 e2 e3 )
355- then have "e1 \<longrightarrow>* e2" using Steps.simps by blast
356- then show ?case using trans ( 3 ) Steps_concat by blast
356+ case ( 2 a x xs b )
357+ then have a : "a \<longrightarrow>* x" using Steps.intros by auto
358+ from 2 have b : "x \<longrightarrow>* b" by simp
359+ show ?case using Steps_concat [ OF b a ] .
357360 qed
358361qed
359362
@@ -362,9 +365,27 @@ lemma Steps_fwd_induct[consumes 1, case_names refl trans]:
362365 and "\<And>x. P x x" "\<And>x y z. y \<longrightarrow>* z \<Longrightarrow> P y z \<Longrightarrow> Step x y \<Longrightarrow> P x z"
363366 shows "P a b"
364367proof -
365- from assms ( 1 ) have 1 : "Steps_aux a b" using Steps_Steps_aux_equivalent by simp
366- show ?thesis using Steps_aux.induct [ OF 1 ]
367- by ( simp add : \<open>\<And>P. \<lbrakk>\<And>e. P e e; \<And>e1 e2 e3. \<lbrakk>e1 \<longrightarrow> e2; Steps_aux e2 e3; P e2 e3\<rbrakk> \<Longrightarrow> P e1 e3\<rbrakk> \<Longrightarrow> P a b\<close> Steps_Steps_aux_equivalent assms ( 2 ) assms ( 3 ))
368+ from assms ( 1 ) obtain p where P : "path a p b" using Steps_path by blast
369+ then show ?thesis
370+ proof ( induction a p b rule : path.induct )
371+ case ( 1 a b )
372+ then show ?case
373+ proof ( cases "a = b" )
374+ case True
375+ then show ?thesis using assms ( 2 ) by simp
376+ next
377+ case False
378+ then have 1 : "Step a b" using 1 by simp
379+ have 2 : "b \<longrightarrow>* b" using Steps.refl by simp
380+ show ?thesis using assms ( 3 )[ OF 2 assms ( 2 ) 1 ] .
381+ qed
382+ next
383+ case ( 2 a x xs b )
384+ then have 1 : "P x b" by simp
385+ from 2 have 3 : "x \<longrightarrow>* b" using Steps_path by auto
386+ from 2 have 4 : "Step a x" by simp
387+ show ?case using assms ( 3 )[ OF 3 1 4 ] .
388+ qed
368389qed
369390
370391lemma beta_equivalence : "\<lbrakk> e1 \<longrightarrow>* e1' ; e2 \<longrightarrow>* e2' ; e1 = e2 ; beta_nf e1' ; beta_nf e2' \<rbrakk> \<Longrightarrow> e1' = e2'"
@@ -373,8 +394,7 @@ case (refl x)
373394 then show ?case by simp
374395next
375396 case ( trans x y z )
376- then show ?case
377- by ( metis Steps_Steps_aux_equivalent Steps_aux.simps beta_same step_deterministic )
397+ then show ?case by ( metis Steps.simps Steps_path beta_same path.elims ( 2 ) step_deterministic )
378398qed
379399
380400end
0 commit comments