equal
deleted
inserted
replaced
669 syntax |
669 syntax |
670 "_qsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" (\<open>(\<open>indent=2 notation=\<open>binder \<Sum> Collect\<close>\<close>\<Sum>_ | (_)./ _)\<close> [0, 0, 10] 10) |
670 "_qsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" (\<open>(\<open>indent=2 notation=\<open>binder \<Sum> Collect\<close>\<close>\<Sum>_ | (_)./ _)\<close> [0, 0, 10] 10) |
671 |
671 |
672 syntax_consts |
672 syntax_consts |
673 "_qsum" == sum |
673 "_qsum" == sum |
674 |
|
675 translations |
674 translations |
676 "\<Sum>x|P. t" => "CONST sum (\<lambda>x. t) {x. P}" |
675 "\<Sum>x|P. t" => "CONST sum (\<lambda>x. t) {x. P}" |
677 |
|
678 print_translation \<open> |
676 print_translation \<open> |
679 let |
677 [(\<^const_syntax>\<open>sum\<close>, K (Collect_binder_tr' \<^syntax_const>\<open>_qsum\<close>))] |
680 fun sum_tr' [Abs (x, Tx, t), Const (\<^const_syntax>\<open>Collect\<close>, _) $ Abs (y, Ty, P)] = |
|
681 if x <> y then raise Match |
|
682 else |
|
683 let |
|
684 val x' = Syntax_Trans.mark_bound_body (x, Tx); |
|
685 val t' = subst_bound (x', t); |
|
686 val P' = subst_bound (x', P); |
|
687 in |
|
688 Syntax.const \<^syntax_const>\<open>_qsum\<close> $ Syntax_Trans.mark_bound_abs (x, Tx) $ P' $ t' |
|
689 end |
|
690 | sum_tr' _ = raise Match; |
|
691 in [(\<^const_syntax>\<open>sum\<close>, K sum_tr')] end |
|
692 \<close> |
678 \<close> |
693 |
679 |
694 |
680 |
695 subsubsection \<open>Properties in more restricted classes of structures\<close> |
681 subsubsection \<open>Properties in more restricted classes of structures\<close> |
696 |
682 |
1439 syntax |
1425 syntax |
1440 "_qprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" (\<open>(\<open>indent=2 notation=\<open>binder \<Prod> Collect\<close>\<close>\<Prod>_ | (_)./ _)\<close> [0, 0, 10] 10) |
1426 "_qprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" (\<open>(\<open>indent=2 notation=\<open>binder \<Prod> Collect\<close>\<close>\<Prod>_ | (_)./ _)\<close> [0, 0, 10] 10) |
1441 |
1427 |
1442 syntax_consts |
1428 syntax_consts |
1443 "_qprod" == prod |
1429 "_qprod" == prod |
1444 |
|
1445 translations |
1430 translations |
1446 "\<Prod>x|P. t" => "CONST prod (\<lambda>x. t) {x. P}" |
1431 "\<Prod>x|P. t" => "CONST prod (\<lambda>x. t) {x. P}" |
1447 |
|
1448 print_translation \<open> |
1432 print_translation \<open> |
1449 let |
1433 [(\<^const_syntax>\<open>prod\<close>, K (Collect_binder_tr' \<^syntax_const>\<open>_qprod\<close>))] |
1450 fun prod_tr' [Abs (x, Tx, t), Const (\<^const_syntax>\<open>Collect\<close>, _) $ Abs (y, Ty, P)] = |
|
1451 if x <> y then raise Match |
|
1452 else |
|
1453 let |
|
1454 val x' = Syntax_Trans.mark_bound_body (x, Tx); |
|
1455 val t' = subst_bound (x', t); |
|
1456 val P' = subst_bound (x', P); |
|
1457 in |
|
1458 Syntax.const \<^syntax_const>\<open>_qprod\<close> $ Syntax_Trans.mark_bound_abs (x, Tx) $ P' $ t' |
|
1459 end |
|
1460 | prod_tr' _ = raise Match; |
|
1461 in [(\<^const_syntax>\<open>prod\<close>, K prod_tr')] end |
|
1462 \<close> |
1434 \<close> |
1463 |
1435 |
1464 context comm_monoid_mult |
1436 context comm_monoid_mult |
1465 begin |
1437 begin |
1466 |
1438 |