• 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

修订版703331d6e4d103091a82d1698b41e09868565978 (tree)
时间2021-08-17 04:09:26
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Try to unroll primitive recursion.

The egg library does make this very neat. We explain that it is possible
to speculatively unroll primitive recursion for the successor case, but
don't have to worry about whether it will be worthwhile to do so.

更改概述

差异

--- a/compile.sh
+++ b/compile.sh
@@ -29,3 +29,4 @@ csc -O3 -o "$name" "$tmpdir/$name.scm"
2929
3030 # Clean up temporary files.
3131 rm -r "$tmpdir"
32+rm a.out
--- /dev/null
+++ b/hive/nat/lte.cammy
@@ -0,0 +1 @@
1+(curry (comp (uncurry nat/monus) nat/is_zero))
--- /dev/null
+++ b/hive/nat/pot.cammy
@@ -0,0 +1 @@
1+(comp (pair id (comp (comp (comp ignore zero) succ) succ)) (uncurry nat/exp))
--- a/jelly/src/main.rs
+++ b/jelly/src/main.rs
@@ -16,10 +16,15 @@ fn load_tree(handle :&mut Read) -> std::io::Result<RecExpr<SymbolLang>> {
1616 // "free for X" means that the polymorphic type of X implies the underlying equality justifying
1717 // the annotated rule, as in Wadler 1989.
1818
19+// Rules marked "associative!" can cause explosions.
20+
1921 fn main() -> std::io::Result<()> {
2022 let rules :&[Rewrite<SymbolLang, ()>] = &[
2123 rw!("comp-id-left"; "(comp id ?x)" => "?x"),
2224 rw!("comp-id-right"; "(comp ?x id)" => "?x"),
25+
26+ // associative!
27+ rw!("comp-assoc-left"; "(comp ?x (comp ?y ?z))" => "(comp (comp ?x ?y) ?z)"),
2328 rw!("comp-assoc-right"; "(comp (comp ?x ?y) ?z)" => "(comp ?x (comp ?y ?z))"),
2429
2530 rw!("ignore-absorb-left"; "(comp ?x ignore)" => "ignore"),
@@ -62,6 +67,8 @@ fn main() -> std::io::Result<()> {
6267 rw!("name-desugar"; "(name ?f)" => "(curry (comp snd ?f))"),
6368
6469 rw!("nat-elim-pr"; "(pr zero succ)" => "id"),
70+ rw!("nat-unroll-pr-zero"; "(comp zero (pr ?x ?f))" => "?x"),
71+ rw!("nat-unroll-pr-succ"; "(comp succ (pr ?x ?f))" => "(comp (pr ?x ?f) ?f)"),
6572
6673 rw!("list-elim-fold"; "(fold nil cons)" => "id"),
6774
--- a/shell.nix
+++ b/shell.nix
@@ -12,6 +12,8 @@ in pkgs.stdenv.mkDerivation {
1212 ocamlformat
1313 # debugging stub.ml
1414 ocamlPackages.utop
15+ # working with sexps
16+ ocamlPackages.sexp
1517 # running compile.sh
1618 ocaml
1719 # publishing