equal
deleted
inserted
replaced
47 end |
47 end |
48 |
48 |
49 lemma [code nbe]: |
49 lemma [code nbe]: |
50 "HOL.equal (f :: _ \<Rightarrow> _) f \<longleftrightarrow> True" |
50 "HOL.equal (f :: _ \<Rightarrow> _) f \<longleftrightarrow> True" |
51 by (fact equal_refl) |
51 by (fact equal_refl) |
|
52 |
|
53 lemma [code]: |
|
54 "HOL.equal f g \<longleftrightarrow> list_all (%x. f x = g x) enum" |
|
55 by (auto simp add: list_all_iff enum_all equal fun_eq_iff) |
52 |
56 |
53 lemma order_fun [code]: |
57 lemma order_fun [code]: |
54 fixes f g :: "'a\<Colon>enum \<Rightarrow> 'b\<Colon>order" |
58 fixes f g :: "'a\<Colon>enum \<Rightarrow> 'b\<Colon>order" |
55 shows "f \<le> g \<longleftrightarrow> list_all (\<lambda>x. f x \<le> g x) enum" |
59 shows "f \<le> g \<longleftrightarrow> list_all (\<lambda>x. f x \<le> g x) enum" |
56 and "f < g \<longleftrightarrow> f \<le> g \<and> list_ex (\<lambda>x. f x \<noteq> g x) enum" |
60 and "f < g \<longleftrightarrow> f \<le> g \<and> list_ex (\<lambda>x. f x \<noteq> g x) enum" |
320 instance proof |
324 instance proof |
321 qed (auto simp add: enum_finite_1_def intro: finite_1.exhaust) |
325 qed (auto simp add: enum_finite_1_def intro: finite_1.exhaust) |
322 |
326 |
323 end |
327 end |
324 |
328 |
|
329 instantiation finite_1 :: linorder |
|
330 begin |
|
331 |
|
332 definition less_eq_finite_1 :: "finite_1 \<Rightarrow> finite_1 \<Rightarrow> bool" |
|
333 where |
|
334 "less_eq_finite_1 x y = True" |
|
335 |
|
336 definition less_finite_1 :: "finite_1 \<Rightarrow> finite_1 \<Rightarrow> bool" |
|
337 where |
|
338 "less_finite_1 x y = False" |
|
339 |
|
340 instance |
|
341 apply (intro_classes) |
|
342 apply (auto simp add: less_finite_1_def less_eq_finite_1_def) |
|
343 apply (metis finite_1.exhaust) |
|
344 done |
|
345 |
|
346 end |
|
347 |
325 datatype finite_2 = a\<^isub>1 | a\<^isub>2 |
348 datatype finite_2 = a\<^isub>1 | a\<^isub>2 |
326 |
349 |
327 instantiation finite_2 :: enum |
350 instantiation finite_2 :: enum |
328 begin |
351 begin |
329 |
352 |
333 instance proof |
356 instance proof |
334 qed (auto simp add: enum_finite_2_def intro: finite_2.exhaust) |
357 qed (auto simp add: enum_finite_2_def intro: finite_2.exhaust) |
335 |
358 |
336 end |
359 end |
337 |
360 |
|
361 instantiation finite_2 :: linorder |
|
362 begin |
|
363 |
|
364 definition less_finite_2 :: "finite_2 \<Rightarrow> finite_2 \<Rightarrow> bool" |
|
365 where |
|
366 "less_finite_2 x y = ((x = a\<^isub>1) & (y = a\<^isub>2))" |
|
367 |
|
368 definition less_eq_finite_2 :: "finite_2 \<Rightarrow> finite_2 \<Rightarrow> bool" |
|
369 where |
|
370 "less_eq_finite_2 x y = ((x = y) \<or> (x < y))" |
|
371 |
|
372 |
|
373 instance |
|
374 apply (intro_classes) |
|
375 apply (auto simp add: less_finite_2_def less_eq_finite_2_def) |
|
376 apply (metis finite_2.distinct finite_2.nchotomy)+ |
|
377 done |
|
378 |
|
379 end |
|
380 |
|
381 |
338 datatype finite_3 = a\<^isub>1 | a\<^isub>2 | a\<^isub>3 |
382 datatype finite_3 = a\<^isub>1 | a\<^isub>2 | a\<^isub>3 |
339 |
383 |
340 instantiation finite_3 :: enum |
384 instantiation finite_3 :: enum |
341 begin |
385 begin |
342 |
386 |
346 instance proof |
390 instance proof |
347 qed (auto simp add: enum_finite_3_def intro: finite_3.exhaust) |
391 qed (auto simp add: enum_finite_3_def intro: finite_3.exhaust) |
348 |
392 |
349 end |
393 end |
350 |
394 |
|
395 instantiation finite_3 :: linorder |
|
396 begin |
|
397 |
|
398 definition less_finite_3 :: "finite_3 \<Rightarrow> finite_3 \<Rightarrow> bool" |
|
399 where |
|
400 "less_finite_3 x y = (case x of a\<^isub>1 => (y \<noteq> a\<^isub>1) |
|
401 | a\<^isub>2 => (y = a\<^isub>3)| a\<^isub>3 => False)" |
|
402 |
|
403 definition less_eq_finite_3 :: "finite_3 \<Rightarrow> finite_3 \<Rightarrow> bool" |
|
404 where |
|
405 "less_eq_finite_3 x y = ((x = y) \<or> (x < y))" |
|
406 |
|
407 |
|
408 instance proof (intro_classes) |
|
409 qed (auto simp add: less_finite_3_def less_eq_finite_3_def split: finite_3.split_asm) |
|
410 |
|
411 end |
|
412 |
|
413 |
351 datatype finite_4 = a\<^isub>1 | a\<^isub>2 | a\<^isub>3 | a\<^isub>4 |
414 datatype finite_4 = a\<^isub>1 | a\<^isub>2 | a\<^isub>3 | a\<^isub>4 |
352 |
415 |
353 instantiation finite_4 :: enum |
416 instantiation finite_4 :: enum |
354 begin |
417 begin |
355 |
418 |
359 instance proof |
422 instance proof |
360 qed (auto simp add: enum_finite_4_def intro: finite_4.exhaust) |
423 qed (auto simp add: enum_finite_4_def intro: finite_4.exhaust) |
361 |
424 |
362 end |
425 end |
363 |
426 |
|
427 |
|
428 |
364 datatype finite_5 = a\<^isub>1 | a\<^isub>2 | a\<^isub>3 | a\<^isub>4 | a\<^isub>5 |
429 datatype finite_5 = a\<^isub>1 | a\<^isub>2 | a\<^isub>3 | a\<^isub>4 | a\<^isub>5 |
365 |
430 |
366 instantiation finite_5 :: enum |
431 instantiation finite_5 :: enum |
367 begin |
432 begin |
368 |
433 |
373 qed (auto simp add: enum_finite_5_def intro: finite_5.exhaust) |
438 qed (auto simp add: enum_finite_5_def intro: finite_5.exhaust) |
374 |
439 |
375 end |
440 end |
376 |
441 |
377 hide_type finite_1 finite_2 finite_3 finite_4 finite_5 |
442 hide_type finite_1 finite_2 finite_3 finite_4 finite_5 |
378 |
443 hide_const (open) n_lists product |
379 end |
444 |
|
445 end |