• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

A categorical programming language


Commit MetaInfo

修订版f877dbc0f85c6e12ed2f9fbadabbcf4037ddb240 (tree)
时间2022-03-15 14:29:41
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Generalize an optimization for pair/case.

更改概述

  • delete: hive/fun/app-10.cammy
  • delete: hive/fun/app-20.cammy
  • delete: hive/fun/app-40.cammy
  • delete: hive/fun/app-5.cammy
  • delete: hive/fun/app-80.cammy
  • delete: hive/fun/app-thrice.cammy
  • delete: hive/fun/app-twice.cammy
  • add: hive/int/abs.cammy (diff)
  • modified: jelly/src/main.rs (diff)

差异

--- a/hive/fun/app-10.cammy
+++ /dev/null
@@ -1 +0,0 @@
1-(comp (pair fst fun/app-5) fun/app-5)
--- a/hive/fun/app-20.cammy
+++ /dev/null
@@ -1 +0,0 @@
1-(comp (pair fst fun/app-10) fun/app-10)
--- a/hive/fun/app-40.cammy
+++ /dev/null
@@ -1 +0,0 @@
1-(comp (pair fst fun/app-20) fun/app-20)
--- a/hive/fun/app-5.cammy
+++ /dev/null
@@ -1 +0,0 @@
1-(comp (pair fst fun/app-twice) fun/app-thrice)
--- a/hive/fun/app-80.cammy
+++ /dev/null
@@ -1 +0,0 @@
1-(comp (pair fst fun/app-40) fun/app-40)
--- a/hive/fun/app-thrice.cammy
+++ /dev/null
@@ -1,2 +0,0 @@
1-(comp (pair fst fun/app-twice) fun/app)
2-
--- a/hive/fun/app-twice.cammy
+++ /dev/null
@@ -1 +0,0 @@
1-(comp (pair fst fun/app) fun/app)
--- /dev/null
+++ b/hive/int/abs.cammy
@@ -0,0 +1,3 @@
1+(case id id)
2+
3+The absolute value of an integer.
--- a/jelly/src/main.rs
+++ b/jelly/src/main.rs
@@ -58,8 +58,9 @@ fn main() -> std::io::Result<()> {
5858 // pair-precompose when ?f and ?g are id
5959 rw!("pair-factor-both"; "(pair ?r ?r)" => "(comp ?r (pair id id))"),
6060
61- // Turn braided products into symmetric products.
62- rw!("pair-swap-invo"; "(comp (pair snd fst) (pair snd fst))" => "id"),
61+ // This implies the old rule pair-swap-invo: (comp pair/swap pair/swap) => id
62+ // So, like pair-swap-invo, this turns braided products into symmetric products.
63+ rw!("pair-swap-pair"; "(comp (pair ?f ?g) (pair snd fst))" => "(pair ?g ?f)"),
6364
6465 // free for left
6566 rw!("left-elim-case"; "(comp left (case ?f ?g))" => "?f"),
@@ -67,6 +68,10 @@ fn main() -> std::io::Result<()> {
6768 rw!("right-elim-case"; "(comp right (case ?f ?g))" => "?g"),
6869 rw!("case-left-right"; "(case left right)" => "id"),
6970
71+ // dual of pair-swap-pair
72+ // By abstract nonsense, this turns braided sums into symmetric sums.
73+ rw!("case-swap-case"; "(comp (case right left) (case ?f ?g))" => "(case ?g ?f)"),
74+
7075 // dual of Elliott 2013
7176 rw!("case-postcompose"; "(case (comp ?f ?r) (comp ?g ?r))" => "(comp (case ?f ?g) ?r)"),
7277 rw!("case-factor"; "(case ?r ?r)" => "(comp (case id id) ?r)"),