equal
deleted
inserted
replaced
226 show "\<dots> = has_edge (G1 * (G2 * G3)) p J q" |
226 show "\<dots> = has_edge (G1 * (G2 * G3)) p J q" |
227 by (simp only:in_grcomp mult_assoc) blast |
227 by (simp only:in_grcomp mult_assoc) blast |
228 qed |
228 qed |
229 qed |
229 qed |
230 |
230 |
231 instantiation graph :: (type, monoid_mult) "{semiring_1, idem_add, recpower, star}" |
231 instance graph :: (type, monoid_mult) "{semiring_1, idem_add, recpower}" |
232 begin |
232 proof |
233 |
|
234 primrec power_graph :: "('a\<Colon>type, 'b\<Colon>monoid_mult) graph \<Rightarrow> nat => ('a, 'b) graph" |
|
235 where |
|
236 "(A \<Colon> ('a, 'b) graph) ^ 0 = 1" |
|
237 | "(A \<Colon> ('a, 'b) graph) ^ Suc n = A * (A ^ n)" |
|
238 |
|
239 definition |
|
240 graph_star_def: "star (G \<Colon> ('a, 'b) graph) = (SUP n. G ^ n)" |
|
241 |
|
242 instance proof |
|
243 fix a b c :: "('a, 'b) graph" |
233 fix a b c :: "('a, 'b) graph" |
244 |
234 |
245 show "1 * a = a" |
235 show "1 * a = a" |
246 by (rule graph_ext) (auto simp:in_grcomp in_grunit) |
236 by (rule graph_ext) (auto simp:in_grcomp in_grunit) |
247 show "a * 1 = a" |
237 show "a * 1 = a" |
256 show "(0::('a,'b) graph) \<noteq> 1" unfolding graph_zero_def graph_one_def |
246 show "(0::('a,'b) graph) \<noteq> 1" unfolding graph_zero_def graph_one_def |
257 by simp |
247 by simp |
258 |
248 |
259 show "a + a = a" unfolding graph_plus_def by simp |
249 show "a + a = a" unfolding graph_plus_def by simp |
260 |
250 |
261 show "a ^ 0 = 1" "\<And>n. a ^ (Suc n) = a * a ^ n" |
251 qed |
262 by simp_all |
252 |
263 qed |
253 instantiation graph :: (type, monoid_mult) star |
|
254 begin |
|
255 |
|
256 definition |
|
257 graph_star_def: "star (G \<Colon> ('a, 'b) graph) = (SUP n. G ^ n)" |
|
258 |
|
259 instance .. |
264 |
260 |
265 end |
261 end |
266 |
262 |
267 lemma graph_leqI: |
263 lemma graph_leqI: |
268 assumes "\<And>n e n'. has_edge G n e n' \<Longrightarrow> has_edge H n e n'" |
264 assumes "\<And>n e n'. has_edge G n e n' \<Longrightarrow> has_edge H n e n'" |
349 by (simp add:power_Suc power_commutes) |
345 by (simp add:power_Suc power_commutes) |
350 |
346 |
351 |
347 |
352 lemma in_tcl: |
348 lemma in_tcl: |
353 "has_edge (tcl G) a x b = (\<exists>n>0. has_edge (G ^ n) a x b)" |
349 "has_edge (tcl G) a x b = (\<exists>n>0. has_edge (G ^ n) a x b)" |
354 apply (auto simp: tcl_is_SUP in_SUP simp del: power_graph.simps power_Suc) |
350 apply (auto simp: tcl_is_SUP in_SUP simp del: power.simps power_Suc) |
355 apply (rule_tac x = "n - 1" in exI, auto) |
351 apply (rule_tac x = "n - 1" in exI, auto) |
356 done |
352 done |
357 |
353 |
358 |
354 |
359 subsection {* Infinite Paths *} |
355 subsection {* Infinite Paths *} |