phino 0.0.165 → 0.0.166
raw patch · 154 files changed
+2719/−1084 lines, 154 files
Files
- README.md +101/−84
- benchmark/Main.hs +7/−3
- compiled/generated/Compiled.hs +76/−68
- phino.cabal +2/−1
- src/AST.hs +90/−18
- src/Builder.hs +0/−3
- src/CLI/Helpers.hs +8/−6
- src/CLI/Parsers.hs +6/−0
- src/CLI/Runners.hs +32/−18
- src/CLI/Types.hs +3/−0
- src/CLI/Validators.hs +5/−4
- src/Canonizer.hs +7/−2
- src/Contextualize.hs +2/−0
- src/Dataize.hs +2/−1
- src/Deps.hs +113/−24
- src/Emit.hs +36/−38
- src/Engine.hs +5/−2
- src/Evaluate.hs +52/−24
- src/Forks.hs +41/−12
- src/Functions.hs +20/−13
- src/LaTeX.hs +27/−9
- src/Lambdas.hs +13/−13
- src/Margin.hs +21/−108
- src/Morph.hs +342/−47
- src/Parser.hs +5/−8
- src/Regexp.hs +9/−2
- src/Render.hs +271/−128
- src/Rewriter.hs +21/−14
- src/Rule.hs +14/−7
- src/Sides.hs +85/−0
- src/XMIR.hs +11/−8
- test-resources/cli/rules/drop-x.yaml +6/−0
- test-resources/evaluate-packs/answers-a-firing-whose-operand-loops.yaml +5/−3
- test-resources/evaluate-packs/answers-a-symbol-nobody-has-worked-out.yaml +3/−2
- test-resources/evaluate-packs/answers-a-whole-family-of-names-with-one-entry.yaml +6/−4
- test-resources/evaluate-packs/answers-an-operand-that-dataizes-in-circles-with-a-symbol.yaml +3/−2
- test-resources/evaluate-packs/answers-bottom-for-a-meta-that-raises.yaml +1/−0
- test-resources/evaluate-packs/answers-its-own-sides-on-a-condition-another-join-read.yaml +23/−16
- test-resources/evaluate-packs/answers-the-same-dataization-loop-under-partial.yaml +3/−2
- test-resources/evaluate-packs/answers-the-same-under-acyclic.yaml +3/−2
- test-resources/evaluate-packs/binds-a-copy-over-no-bare-symbol-as-it-is.yaml +2/−1
- test-resources/evaluate-packs/binds-a-copy-whose-method-alone-reads-to-a-bare-symbol-as-it-is.yaml +34/−0
- test-resources/evaluate-packs/binds-a-copy-whose-phi-repeats-the-formation-fired-as-it-is.yaml +13/−9
- test-resources/evaluate-packs/blames-the-lambda-the-operand-was-parked-on.yaml +1/−1
- test-resources/evaluate-packs/cuts-a-loop-met-at-a-dispatch-off-an-atom.yaml +5/−3
- test-resources/evaluate-packs/cuts-a-recursion-running-through-evaluate-lines.yaml +5/−4
- test-resources/evaluate-packs/cuts-a-recursion-that-differs-by-symbols-only.yaml +2/−1
- test-resources/evaluate-packs/cuts-an-entry-that-answers-with-a-firing-of-itself.yaml +2/−1
- test-resources/evaluate-packs/dataizes-what-a-morph-operand-of-the-same-entry-brought-down.yaml +4/−3
- test-resources/evaluate-packs/defers-a-copy-a-join-passed-through-stay-and-symbolize.yaml +4/−2
- test-resources/evaluate-packs/defers-a-copy-whose-phi-reads-nothing-of-its-own.yaml +3/−2
- test-resources/evaluate-packs/diverges-on-two-sides-that-do-not-join.yaml +9/−6
- test-resources/evaluate-packs/fabricates-a-formation-holding-the-bytes-its-condition-came-down-to.yaml +2/−1
- test-resources/evaluate-packs/fabricates-a-formation-holding-the-symbol-a-path-of-its-condition-reaches.yaml +2/−1
- test-resources/evaluate-packs/fabricates-a-formation-of-two-sides-of-different-shapes.yaml +2/−1
- test-resources/evaluate-packs/fails-on-a-lambda-no-entry-answers.yaml +1/−1
- test-resources/evaluate-packs/fails-on-a-side-whose-morph-got-stuck.yaml +1/−1
- test-resources/evaluate-packs/fails-on-an-operand-that-reaches-the-terminator.yaml +3/−2
- test-resources/evaluate-packs/fires-a-formation-once-however-often-it-is-met.yaml +20/−15
- test-resources/evaluate-packs/fires-a-formation-written-in-place-after-a-stay-line.yaml +8/−6
- test-resources/evaluate-packs/fires-a-formation-written-in-place-with-its-voids-filled.yaml +6/−4
- test-resources/evaluate-packs/fires-the-answer-of-an-evaluate-line-on-the-next-line.yaml +11/−8
- test-resources/evaluate-packs/fires-the-arguments-of-a-copy-a-defer-line-defers.yaml +7/−4
- test-resources/evaluate-packs/fires-what-a-rewrite-line-unwrapped.yaml +8/−6
- test-resources/evaluate-packs/guards-a-side-holding-no-symbol-against-a-bottom.yaml +2/−1
- test-resources/evaluate-packs/hands-a-named-argument-to-both-sides-of-an-attribute-of-a-fabricated-formation.yaml +4/−2
- test-resources/evaluate-packs/hands-a-positional-argument-to-both-sides-of-an-attribute-of-a-fabricated-formation.yaml +4/−2
- test-resources/evaluate-packs/hands-a-side-of-a-fabricated-formation-only-the-voids-its-attribute-leaves.yaml +6/−3
- test-resources/evaluate-packs/heads-the-block-of-a-dataize-operand-with-the-operand.yaml +3/−2
- test-resources/evaluate-packs/heads-the-block-of-a-morph-operand-with-the-operand.yaml +3/−2
- test-resources/evaluate-packs/joins-a-bare-symbol-a-cast-brought-down-two-decorators.yaml +2/−1
- test-resources/evaluate-packs/joins-a-bare-symbol-a-cast-brought-into-a-decorator-of-a-fork.yaml +7/−4
- test-resources/evaluate-packs/joins-a-bare-symbol-a-cast-brought-into-a-side-holding-a-symbol-off-its-phi-chain.yaml +2/−1
- test-resources/evaluate-packs/joins-a-bare-symbol-a-cast-brought-into-the-shape-of-a-decorator.yaml +2/−1
- test-resources/evaluate-packs/joins-a-bool-literal-a-rewrite-line-brought-into-the-shape-of-the-other-side.yaml +3/−2
- test-resources/evaluate-packs/joins-a-bottom-into-the-shape-of-the-other-side.yaml +2/−1
- test-resources/evaluate-packs/joins-a-number-with-a-formation-an-undress-took-the-number-out-of.yaml +4/−3
- test-resources/evaluate-packs/joins-a-side-a-morph-line-brought-down-from-what-a-rewrite-line-unwrapped.yaml +4/−3
- test-resources/evaluate-packs/joins-a-side-an-evaluate-line-fired-with-a-bool-it-left-as-it-is.yaml +6/−4
- test-resources/evaluate-packs/joins-a-side-holding-a-datum-a-symbolize-turned-into-a-symbol.yaml +3/−2
- test-resources/evaluate-packs/joins-a-side-reading-the-rho-it-binds-in-a-fabricated-formation.yaml +4/−2
- test-resources/evaluate-packs/joins-a-side-that-dispatches-on-a-terminator.yaml +2/−1
- test-resources/evaluate-packs/joins-a-side-that-raises-through-a-terminator.yaml +2/−1
- test-resources/evaluate-packs/joins-a-side-whose-operand-raises.yaml +3/−1
- test-resources/evaluate-packs/joins-a-side-whose-void-the-fabricated-formation-holds.yaml +4/−2
- test-resources/evaluate-packs/joins-again-the-attribute-of-a-fabricated-formation.yaml +4/−2
- test-resources/evaluate-packs/joins-an-attribute-named-left-of-a-copy-in-a-fabricated-formation.yaml +4/−2
- test-resources/evaluate-packs/joins-two-numbers-into-one-symbol-keeping-the-constant-a-method-holds.yaml +3/−2
- test-resources/evaluate-packs/joins-two-sides-a-stay-brought-to-one-shape.yaml +3/−2
- test-resources/evaluate-packs/joins-two-sides-differing-in-a-datum-a-symbolize-found-off-the-phi-chain.yaml +3/−2
- test-resources/evaluate-packs/joins-two-sides-that-differ-only-in-symbols.yaml +19/−12
- test-resources/evaluate-packs/keeps-the-answer-a-firing-already-gave.yaml +3/−2
- test-resources/evaluate-packs/keeps-the-rho-bindings-a-pack-asks-for.yaml +2/−1
- test-resources/evaluate-packs/leaves-a-bare-symbol-an-evaluate-line-meets-as-it-is.yaml +2/−1
- test-resources/evaluate-packs/leaves-a-formation-with-an-attribute-of-its-own-as-it-is.yaml +1/−0
- test-resources/evaluate-packs/mints-a-fresh-symbol-for-every-firing.yaml +6/−4
- test-resources/evaluate-packs/morphs-a-program-that-already-carries-a-symbol.yaml +3/−2
- test-resources/evaluate-packs/morphs-two-branches-spelling-one-term-through-one-firing.yaml +19/−13
- test-resources/evaluate-packs/names-a-reshaped-side-of-a-fabricated-formation-by-its-meta.yaml +3/−2
- test-resources/evaluate-packs/nests-the-firing-an-operand-brought-down.yaml +9/−6
- test-resources/evaluate-packs/parks-a-dispatch-off-a-symbol.yaml +1/−1
- test-resources/evaluate-packs/parks-a-firing-whose-deferred-argument-got-stuck.yaml +5/−4
- test-resources/evaluate-packs/parks-a-firing-whose-join-side-got-stuck.yaml +1/−1
- test-resources/evaluate-packs/parks-a-firing-whose-morph-operand-got-stuck.yaml +1/−1
- test-resources/evaluate-packs/parks-a-firing-whose-operand-never-came-down.yaml +1/−1
- test-resources/evaluate-packs/parks-a-firing-whose-operand-reaches-the-terminator.yaml +3/−2
- test-resources/evaluate-packs/parks-a-lambda-no-entry-answers.yaml +1/−1
- test-resources/evaluate-packs/parks-an-evaluate-line-over-a-term-that-is-no-formation.yaml +1/−1
- test-resources/evaluate-packs/passes-a-side-that-is-no-formation-through-an-evaluate-line-to-the-join.yaml +2/−2
- test-resources/evaluate-packs/reduces-a-carried-symbol-through-morphing.yaml +3/−2
- test-resources/evaluate-packs/refuses-a-meta-bound-to-a-term-that-is-not-a-normal-form.yaml +1/−1
- test-resources/evaluate-packs/renames-the-answer-of-a-firing-alike-up-to-the-symbols-of-its-positions.yaml +114/−0
- test-resources/evaluate-packs/spends-a-step-on-every-firing-of-an-evaluate-line.yaml +1/−1
- test-resources/evaluate-packs/spends-the-step-budget-on-an-entry-answering-itself.yaml +11/−6
- test-resources/evaluate-packs/starts-minting-after-the-symbols-the-program-carries.yaml +3/−2
- test-resources/evaluate-packs/takes-the-answer-of-a-firing-with-the-same-operands.yaml +11/−8
- test-resources/evaluate-packs/takes-the-one-term-both-sides-of-a-join-come-to.yaml +12/−8
- test-resources/evaluate-packs/tells-two-carried-symbols-apart-in-one-firing.yaml +3/−2
- test-resources/evaluate-packs/tells-two-symbols-of-one-datum-apart-between-firings.yaml +17/−12
- test-resources/evaluate-packs/tells-why-a-join-fabricated-nothing-of-a-side-that-is-no-formation.yaml +1/−1
- test-resources/evaluate-packs/undresses-a-formation-twice-to-reach-what-it-wraps.yaml +4/−3
- test-resources/evaluate-packs/work-out-an-argument-that-comes-to-a-hanging-object.yaml +4/−2
- test-resources/evaluate-packs/writes-no-joined-line-for-a-join-the-memo-answered.yaml +33/−22
- test-resources/latex-packs/empty-string.yaml +10/−0
- test-resources/latex-packs/string-with-arrow.yaml +10/−0
- test-resources/latex-packs/string-with-lone-letter.yaml +10/−0
- test-resources/latex-packs/string-with-question-mark.yaml +10/−0
- test-resources/xmir-parsing-packs/phi-with-application.yaml +2/−2
- test-resources/xmir-parsing-packs/xi-with-application.yaml +1/−2
- test/ASTSpec.hs +19/−0
- test/BuilderSpec.hs +2/−2
- test/CLISpec.hs +272/−54
- test/CanonizerSpec.hs +12/−3
- test/CompiledSpec.hs +7/−2
- test/DataizeSpec.hs +16/−10
- test/DepsSpec.hs +59/−8
- test/EmitSpec.hs +7/−9
- test/EngineSpec.hs +17/−3
- test/EvaluateSpec.hs +18/−2
- test/Fixtures.hs +3/−1
- test/ForksSpec.hs +3/−1
- test/FunctionsSpec.hs +25/−1
- test/Grown.hs +1/−3
- test/InferenceSpec.hs +1/−1
- test/LaTeXSpec.hs +17/−0
- test/LambdasSpec.hs +16/−2
- test/MarginSpec.hs +19/−1
- test/MorphSpec.hs +8/−2
- test/ParserSpec.hs +13/−2
- test/RegexpSpec.hs +29/−0
- test/RenderSpec.hs +32/−1
- test/RewriterSpec.hs +23/−6
- test/RuleSpec.hs +18/−9
- test/XMIRSpec.hs +14/−0
README.md view
@@ -34,7 +34,7 @@ ```bash cabal update-cabal install --overwrite-policy=always phino-0.0.161+cabal install --overwrite-policy=always phino-0.0.165 phino --version ``` @@ -59,7 +59,7 @@ for the runner and puts it on the `PATH`: ```yaml-- uses: objectionary/phino@0.0.161+- uses: objectionary/phino@0.0.165 with: version-file: phino-version.txt - run: phino --version@@ -322,7 +322,7 @@ 𝔻(ξ.x): 𝛿·1·1 := 𝔻(𝜎1:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.x)- 𝑛·1·1 := Φ.down( x ↦ 𝜎2:λ ) # 𝑛+ 𝑛·1·1 := Φ.down( x ↦ 𝜎2:λ ) # 𝑛 of L_down 𝕄(𝑛·1·1): 𝑛·1·2 := Φ.down( x ↦ 𝜎2:λ ) 𝑛·1·3 := ⟦ x ↦ 𝜎2:λ, λ ⤍ L_down ⟧@@ -330,6 +330,7 @@ morphed 𝑛·1·4 := 𝑛·1·3 𝑛·1·5 := 𝑛·1·3 # 𝕄(𝑛·1·1) remembered 𝑛·1·3 ≡ 𝑛·0·3+ evaluated 𝑛·1·6 := 𝑛·1·3 # 𝑛·0·3 recalled 𝑛·1·3 ⇒ 𝑛·0·3 recalled 𝑛·0·3 ⇒ 𝑛·0·1( x ↦ 𝜎1:λ ) recalled 𝑛·0·1 ⇒ Φ.down@@ -355,9 +356,13 @@ commented with `𝕄(𝑛·1·1)` is its normal form. * `boxed …` is dataization stepping into the `φ` of a formation. * `undressed …` is an `undress` line taking the `φ` of a formation.+* `shared 𝑛·1 := …` names an argument a recursion keeps wrapping, so later+ lines spell it by that name. * `𝛿·1·1 := …` closes a `𝔻` block with the data it found, or with `𝔻(𝜎1:λ)` where it came down to a symbol. * `morphed …` closes a `𝕄` block with the term it came to.+* `evaluated …` closes an `𝔼` block with what the firing answered, and the+ comment names the formation fired. * `normalized …` is the term a normalization came to, where no line named it before, and the comment names the term it came from. * `joined …`, `fabricated …`, `diverged …` and `unripe …` are what a `join`@@ -366,7 +371,8 @@ line minted. * `cast …` binds a meta to the copy a `cast` block made of a bare symbol, and the comment names the meta it read and the meta whose shape it took.-* `unanswered …` is a λ name no entry answers.+* `unanswered …` is a λ name no entry answers, and `opaque …` a symbol+ nothing can fire; the comment names the term 𝕄 or 𝔻 worked on. * `stuck …` closes a firing that got stuck, and `stall …` stands under one that `--acyclic=plausible` answered with an earlier stall. * `remembered 𝑛·0·1 ≡ Φ.down` is a fact the run keeps: the term on the@@ -374,10 +380,14 @@ a formation it was the answer of. * `memoized 𝑛·0·5 ⇛ 𝑛·1·9` is what `--acyclic=plausible` keeps: the formation on the left fired to the term on the right.+* `renamed 𝑛·1·10 ⇛ 𝜎5:λ` is a memo entry used for a formation alike it up+ to symbols, with the symbols the comment lists renamed. * `recalled 𝑛·0·3 ⇒ 𝑛·0·1( x ↦ ⟦⟧ )` is a fact or a memo entry used again, spelled as its `remembered` or `memoized` line spelled it. * `looped …` is where `--acyclic` cut a loop, and `looped 𝜎1 := …` names the call of the object it answered with that symbol, when a fact names it.+* `passed 𝑛·1·2 := …` is where an operand came to an object `--acyclic`+ takes for a loop, handed on as it is. * `starved …`, `spent …`, `timeout …`, `oversized …` and `blown …` are where `--max-steps`, `--max-firings`, `--max-seconds`, `--max-nodes` and `--max-memory` ran out.@@ -618,6 +628,13 @@ | Attribute' # !t ``` +Regular expressions in `matches` and `sed` are limited to 1,000,000 match+calls and 256 levels of recursion per execution. Exceeding either limit+stops the command with `Regex execution failed` and exit code 1. The recursion+limit protects small native thread stacks; a repeated capturing group such as+`(a|b)*` can reach it even on a string of a few hundred characters. Long strings+can still be matched with patterns that need little recursion, such as `[ab]*`.+ Here's list of functions that are supported for extensions: * `contextualize` - function of two arguments, that rewrites given expression@@ -717,119 +734,119 @@ === parse/phi === warmup: 3 iterations batches: 10 x 1- total: 2471508.678 μs- avg: 247150.868 μs- min: 221146.358 μs- max: 280070.951 μs- std dev: 22173.343 μs+ total: 1624060.124 μs+ avg: 162406.012 μs+ min: 144277.371 μs+ max: 194535.221 μs+ std dev: 21570.423 μs === parse/xmir === warmup: 3 iterations batches: 10 x 1- total: 9900009.942 μs- avg: 990000.994 μs- min: 913216.401 μs- max: 1064034.163 μs- std dev: 51646.433 μs+ total: 7009151.691 μs+ avg: 700915.169 μs+ min: 651934.228 μs+ max: 762411.055 μs+ std dev: 44745.118 μs === rewrite/normalize === warmup: 3 iterations batches: 10 x 1- total: 20.277 μs- avg: 2.028 μs- min: 1.763 μs- max: 2.444 μs- std dev: 0.206 μs+ total: 12.959 μs+ avg: 1.296 μs+ min: 1.166 μs+ max: 1.418 μs+ std dev: 0.091 μs === print/sweet/multiline === warmup: 3 iterations batches: 10 x 1- total: 5893919.071 μs- avg: 589391.907 μs- min: 546710.930 μs- max: 622324.691 μs- std dev: 22402.952 μs+ total: 4217518.009 μs+ avg: 421751.801 μs+ min: 403493.618 μs+ max: 457424.859 μs+ std dev: 16536.568 μs === print/sweet/flat === warmup: 3 iterations batches: 10 x 1- total: 745153.374 μs- avg: 74515.337 μs- min: 64906.612 μs- max: 87781.583 μs- std dev: 10272.240 μs+ total: 545770.341 μs+ avg: 54577.034 μs+ min: 49166.277 μs+ max: 63498.089 μs+ std dev: 5148.406 μs === print/salty/multiline === warmup: 3 iterations batches: 10 x 1- total: 18806006.234 μs- avg: 1880600.623 μs- min: 1829320.397 μs- max: 1936784.646 μs- std dev: 32771.969 μs+ total: 13219408.124 μs+ avg: 1321940.812 μs+ min: 1272904.132 μs+ max: 1364186.958 μs+ std dev: 31154.946 μs === morph/symbolic/demo/e1 === warmup: 3 iterations- batches: 10 x 9- total: 12166.226 μs- avg: 135.180 μs- min: 131.121 μs- max: 144.901 μs- std dev: 3.769 μs+ batches: 10 x 12+ total: 11083.017 μs+ avg: 92.358 μs+ min: 90.596 μs+ max: 97.264 μs+ std dev: 1.942 μs === morph/symbolic/demo/e2 === warmup: 3 iterations- batches: 10 x 129- total: 173694.366 μs- avg: 134.647 μs- min: 133.356 μs- max: 136.014 μs- std dev: 0.741 μs+ batches: 10 x 183+ total: 169227.669 μs+ avg: 92.474 μs+ min: 92.145 μs+ max: 93.183 μs+ std dev: 0.311 μs === morph/symbolic/demo/e3 === warmup: 3 iterations- batches: 10 x 129- total: 178632.645 μs- avg: 138.475 μs- min: 133.065 μs- max: 163.122 μs- std dev: 9.065 μs+ batches: 10 x 185+ total: 173845.799 μs+ avg: 93.971 μs+ min: 93.445 μs+ max: 94.542 μs+ std dev: 0.317 μs === morph/symbolic/demo/e4 === warmup: 3 iterations- batches: 10 x 113- total: 158155.239 μs- avg: 139.960 μs- min: 133.878 μs- max: 168.699 μs- std dev: 10.055 μs+ batches: 10 x 189+ total: 176636.558 μs+ avg: 93.458 μs+ min: 92.301 μs+ max: 97.186 μs+ std dev: 1.478 μs === morph/symbolic/demo/e5 === warmup: 3 iterations- batches: 10 x 126- total: 172774.638 μs- avg: 137.123 μs- min: 136.318 μs- max: 138.811 μs- std dev: 0.767 μs+ batches: 10 x 186+ total: 176437.359 μs+ avg: 94.859 μs+ min: 94.521 μs+ max: 95.173 μs+ std dev: 0.205 μs === morph/symbolic/native/e5 === warmup: 3 iterations- batches: 10 x 4- total: 53810.789 μs- avg: 1345.270 μs- min: 1165.754 μs- max: 2105.284 μs- std dev: 261.412 μs+ batches: 10 x 6+ total: 80211.099 μs+ avg: 1336.852 μs+ min: 1211.536 μs+ max: 1384.878 μs+ std dev: 55.380 μs === morph/symbolic/accum/0 === warmup: 3 iterations- batches: 10 x 76- total: 85572.821 μs- avg: 112.596 μs- min: 111.501 μs- max: 114.714 μs- std dev: 1.060 μs+ batches: 10 x 107+ total: 83668.975 μs+ avg: 78.195 μs+ min: 77.496 μs+ max: 78.759 μs+ std dev: 0.356 μs === morph/symbolic/accum/400 === warmup: 3 iterations- batches: 10 x 65- total: 85508.304 μs- avg: 131.551 μs- min: 131.274 μs- max: 131.842 μs- std dev: 0.180 μs+ batches: 10 x 77+ total: 70478.596 μs+ avg: 91.531 μs+ min: 90.598 μs+ max: 92.469 μs+ std dev: 0.645 μs ``` The results were calculated in [this GHA job][benchmark-gha]-on 2026-11-10 at 19:10,+on 2026-11-16 at 09:21, on Linux with 4 CPUs. <!-- benchmark_end -->@@ -872,4 +889,4 @@ [jna]: https://github.com/java-native-access/jna [jna-native]: https://github.com/java-native-access/jna/blob/master/src/com/sun/jna/Native.java [jeo]: https://github.com/objectionary/jeo-maven-plugin-[benchmark-gha]: https://github.com/objectionary/phino/actions/runs/42882136890+[benchmark-gha]: https://github.com/objectionary/phino/actions/runs/43835713699
benchmark/Main.hs view
@@ -28,6 +28,7 @@ import Parser (parseExpressionThrows) import Printer (printExpression') import Rewriter (RewriteContext (RewriteContext), rewrite)+import Sides (Sides, sides) import Sugar (SugarType (SALTY, SWEET)) import Tau (seedTaus) import Text.Printf (printf)@@ -62,8 +63,8 @@ dontSaveStep dontSaveMade -symbolicCtx :: Acyclic -> Maybe Memo -> Maybe Facts -> IORef Int -> Lambdas -> Expression -> ReduceContext-symbolicCtx acyclic memo facts minted lambdas locator =+symbolicCtx :: Acyclic -> Maybe Memo -> Maybe Facts -> IORef Int -> Sides -> Lambdas -> Expression -> ReduceContext+symbolicCtx acyclic memo facts minted named lambdas locator = ReduceContext locator locator@@ -75,6 +76,7 @@ (Steps 1000 0) Nothing minted+ named Nothing memo 1@@ -91,6 +93,7 @@ lambdas [] False+ Nothing (building linked) reduction evaluation@@ -201,7 +204,8 @@ memo <- memoized (Just acyclic) facts <- Just <$> factual minted <- newIORef 0- let ctx = symbolicCtx acyclic memo facts minted lambdas locator+ named <- sides+ let ctx = symbolicCtx acyclic memo facts minted named lambdas locator started universe ctx (answer, _, _) <- morph universe emptyState ctx pure (hashExpression answer)
compiled/generated/Compiled.hs view
@@ -54,31 +54,39 @@ -- Whether the term is a normal form: no built-in rule of normalization -- matches anywhere inside it.+-- A rule asking a meta for a normal form asks it of a part of the term,+-- and a part that is no normal form holds a match the walk meets anyway,+-- so the walk takes every such part for a normal form (#2409). nf :: Expression -> Bool-nf = Ru.normalWith (not . null . matching Nothing)+nf = Ru.normalWith (not . null . matchingBy (const True) Nothing) -- The numbers of the built-in rules of normalization matching somewhere in -- the term, in the order one walk over it meets them, told the world the -- term stands in. matching :: Maybe Expression -> Expression -> [Int]-matching =+matching = matchingBy nf++-- The numbers of the built-in rules of normalization matching somewhere in+-- the term, a rule asking a meta for a normal form told it by the test.+matchingBy :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Int]+matchingBy normal = M.hits- [ (0, True, rewriteAlpha)- , (1, True, rewriteAmiss)- , (2, True, rewriteCopy)- , (3, True, rewriteDc)- , (4, True, rewriteDca)- , (5, True, rewriteDd)- , (6, True, rewriteDl)- , (7, True, rewriteDot)- , (8, True, rewriteMiss)- , (9, True, rewriteNorho)- , (10, True, rewriteNull)- , (11, True, rewriteOver)- , (12, True, rewriteOvera)- , (13, True, rewriteSkip)- , (14, True, rewriteStay)- , (15, True, rewriteStop)+ [ (0, True, rewriteAlpha normal)+ , (1, True, rewriteAmiss normal)+ , (2, True, rewriteCopy normal)+ , (3, True, rewriteDc normal)+ , (4, True, rewriteDca normal)+ , (5, True, rewriteDd normal)+ , (6, True, rewriteDl normal)+ , (7, True, rewriteDot normal)+ , (8, True, rewriteMiss normal)+ , (9, True, rewriteNorho normal)+ , (10, True, rewriteNull normal)+ , (11, True, rewriteOver normal)+ , (12, True, rewriteOvera normal)+ , (13, True, rewriteSkip normal)+ , (14, True, rewriteStay normal)+ , (15, True, rewriteStop normal) ] -- The Contextualization function 𝒞, the conclusion of the one rule matching@@ -100,10 +108,10 @@ -- The rule 'alpha'. stepAlpha :: Ru.Step-stepAlpha = R.direct "alpha" True rewriteAlpha+stepAlpha = R.direct "alpha" True (rewriteAlpha nf) -rewriteAlpha :: Maybe Expression -> Expression -> [Expression]-rewriteAlpha _ term =+rewriteAlpha :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteAlpha _ _ term = [ ExApplication (B.formed (concat [x5, [BiVoid x9], x8])) (ArTau x9 x3) | ExApplication x1 (ArAlpha x2 x3) <- [term] , ExFormation x4 <- [x1]@@ -116,10 +124,10 @@ -- The rule 'amiss'. stepAmiss :: Ru.Step-stepAmiss = R.direct "amiss" True rewriteAmiss+stepAmiss = R.direct "amiss" True (rewriteAmiss nf) -rewriteAmiss :: Maybe Expression -> Expression -> [Expression]-rewriteAmiss _ term =+rewriteAmiss :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteAmiss _ _ term = [ ExTermination | ExApplication x1 (ArAlpha x2 _) <- [term] , ExFormation x4 <- [x1]@@ -129,10 +137,10 @@ -- The rule 'copy'. stepCopy :: Ru.Step-stepCopy = R.direct "copy" True rewriteCopy+stepCopy = R.direct "copy" True (rewriteCopy nf) -rewriteCopy :: Maybe Expression -> Expression -> [Expression]-rewriteCopy _ term =+rewriteCopy :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteCopy normal _ term = [ B.formed (concat [x5, [BiTau x2 x3], x8]) | ExApplication x1 (ArTau x2 x3) <- [term] , ExFormation x4 <- [x1]@@ -141,15 +149,15 @@ , BiVoid x9 <- [x7] , x2 == x9 , Ru.xiFree x3- , Ru.normalHeld nf x3+ , Ru.normalHeld normal x3 ] -- The rule 'dc'. stepDc :: Ru.Step-stepDc = R.direct "dc" True rewriteDc+stepDc = R.direct "dc" True (rewriteDc nf) -rewriteDc :: Maybe Expression -> Expression -> [Expression]-rewriteDc _ term =+rewriteDc :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteDc _ _ term = [ ExTermination | ExApplication x1 (ArTau _ _) <- [term] , ExTermination <- [x1]@@ -157,10 +165,10 @@ -- The rule 'dca'. stepDca :: Ru.Step-stepDca = R.direct "dca" True rewriteDca+stepDca = R.direct "dca" True (rewriteDca nf) -rewriteDca :: Maybe Expression -> Expression -> [Expression]-rewriteDca _ term =+rewriteDca :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteDca _ _ term = [ ExTermination | ExApplication x1 (ArAlpha x2 _) <- [term] , ExTermination <- [x1]@@ -169,10 +177,10 @@ -- The rule 'dd'. stepDd :: Ru.Step-stepDd = R.direct "dd" True rewriteDd+stepDd = R.direct "dd" True (rewriteDd nf) -rewriteDd :: Maybe Expression -> Expression -> [Expression]-rewriteDd _ term =+rewriteDd :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteDd _ _ term = [ ExTermination | ExDispatch x1 _ <- [term] , ExTermination <- [x1]@@ -180,10 +188,10 @@ -- The rule 'dl'. stepDl :: Ru.Step-stepDl = R.direct "dl" True rewriteDl+stepDl = R.direct "dl" True (rewriteDl nf) -rewriteDl :: Maybe Expression -> Expression -> [Expression]-rewriteDl _ term =+rewriteDl :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteDl _ _ term = [ ExTermination | ExFormation x1 <- [term] , (x2, x3) <- M.splits x1@@ -195,10 +203,10 @@ -- The rule 'dot'. stepDot :: Ru.Step-stepDot = R.direct "dot" True rewriteDot+stepDot = R.direct "dot" True (rewriteDot nf) -rewriteDot :: Maybe Expression -> Expression -> [Expression]-rewriteDot universe term =+rewriteDot :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteDot normal universe term = [ ExApplication e1 (ArTau AtRho e2) | ExDispatch x1 x2 <- [term] , ExFormation x3 <- [x1]@@ -207,17 +215,17 @@ , BiTau x8 x9 <- [x6] , x2 == x8 , not (all (`Ru.presentIn` concat [x4, x7]) [AtDelta, AtLambda])- , Ru.normalHeld nf x9+ , Ru.normalHeld normal x9 , let e1 = either E.throw id (contextualize x9 (B.formed (concat [x4, x7]))) , let e2 = B.nameIn universe (B.formed (concat [x4, [BiTau x2 x9], x7])) ] -- The rule 'miss'. stepMiss :: Ru.Step-stepMiss = R.direct "miss" True rewriteMiss+stepMiss = R.direct "miss" True (rewriteMiss nf) -rewriteMiss :: Maybe Expression -> Expression -> [Expression]-rewriteMiss _ term =+rewriteMiss :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteMiss _ _ term = [ ExTermination | ExApplication x1 (ArTau x2 _) <- [term] , ExFormation x4 <- [x1]@@ -226,10 +234,10 @@ -- The rule 'norho'. stepNorho :: Ru.Step-stepNorho = R.direct "norho" True rewriteNorho+stepNorho = R.direct "norho" True (rewriteNorho nf) -rewriteNorho :: Maybe Expression -> Expression -> [Expression]-rewriteNorho _ term =+rewriteNorho :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteNorho _ _ term = [ ExTermination | ExDispatch x1 x2 <- [term] , x2 == AtRho@@ -239,10 +247,10 @@ -- The rule 'null'. stepNull :: Ru.Step-stepNull = R.direct "null" True rewriteNull+stepNull = R.direct "null" True (rewriteNull nf) -rewriteNull :: Maybe Expression -> Expression -> [Expression]-rewriteNull _ term =+rewriteNull :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteNull _ _ term = [ ExTermination | ExDispatch x1 x2 <- [term] , ExFormation x3 <- [x1]@@ -254,10 +262,10 @@ -- The rule 'over'. stepOver :: Ru.Step-stepOver = R.direct "over" True rewriteOver+stepOver = R.direct "over" True (rewriteOver nf) -rewriteOver :: Maybe Expression -> Expression -> [Expression]-rewriteOver _ term =+rewriteOver :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteOver _ _ term = [ ExTermination | ExApplication x1 (ArTau x2 _) <- [term] , ExFormation x4 <- [x1]@@ -270,10 +278,10 @@ -- The rule 'overa'. stepOvera :: Ru.Step-stepOvera = R.direct "overa" True rewriteOvera+stepOvera = R.direct "overa" True (rewriteOvera nf) -rewriteOvera :: Maybe Expression -> Expression -> [Expression]-rewriteOvera _ term =+rewriteOvera :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteOvera _ _ term = [ ExTermination | ExApplication x1 (ArAlpha x2 _) <- [term] , ExFormation x4 <- [x1]@@ -286,10 +294,10 @@ -- The rule 'skip'. stepSkip :: Ru.Step-stepSkip = R.direct "skip" True rewriteSkip+stepSkip = R.direct "skip" True (rewriteSkip nf) -rewriteSkip :: Maybe Expression -> Expression -> [Expression]-rewriteSkip _ term =+rewriteSkip :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteSkip _ _ term = [ B.formed x4 | ExApplication x1 (ArTau x2 _) <- [term] , x2 == AtRho@@ -299,10 +307,10 @@ -- The rule 'stay'. stepStay :: Ru.Step-stepStay = R.direct "stay" True rewriteStay+stepStay = R.direct "stay" True (rewriteStay nf) -rewriteStay :: Maybe Expression -> Expression -> [Expression]-rewriteStay _ term =+rewriteStay :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteStay _ _ term = [ B.formed (concat [x5, [BiTau AtRho x10], x8]) | ExApplication x1 (ArTau x2 _) <- [term] , x2 == AtRho@@ -315,10 +323,10 @@ -- The rule 'stop'. stepStop :: Ru.Step-stepStop = R.direct "stop" True rewriteStop+stepStop = R.direct "stop" True (rewriteStop nf) -rewriteStop :: Maybe Expression -> Expression -> [Expression]-rewriteStop _ term =+rewriteStop :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]+rewriteStop _ _ term = [ ExTermination | ExDispatch x1 x2 <- [term] , ExFormation x3 <- [x1]
phino.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: phino-version: 0.0.165+version: 0.0.166 license: MIT synopsis: Command-Line Manipulator of 𝜑-Calculus Expressions description: Please see the README on GitHub at <https://github.com/objectionary/phino#readme>@@ -89,6 +89,7 @@ Replacer Rewriter Rule+ Sides Slots Sugar Tau
src/AST.hs view
@@ -25,9 +25,17 @@ , repeated , attributeFromBinding , alike+ , alike'+ , bijection+ , bijection' , akin+ , akin' , boxed+ , intact+ , suffixed , within+ , within'+ , isName , symbols , lifted , denoted@@ -68,7 +76,7 @@ | ExPhiAgain (Maybe String) Int Expression | ExBytes Bytes -data Facts = Facts !Int Int !Bool Bool+data Facts = Facts !Int !Int !Bool !Bool {-# COMPLETE ExFormation, ExXi, ExRoot, ExTermination, ExApplication, ExDispatch, ExMeta, ExAny, ExPhiMeet, ExPhiAgain, ExBytes #-} @@ -87,6 +95,21 @@ where ExDispatch expr attr = cached (\facts -> Dispatched facts expr attr) +intact :: (Eq part) => part -> whole -> (part -> whole) -> part -> whole+intact old whole make new+ | new == old = whole+ | otherwise = make new++suffixed :: (Monad walk, Eq item) => (item -> walk item) -> [item] -> walk [item]+suffixed change items = snd <$> go change items+ where+ go :: (Monad walk, Eq item) => (item -> walk item) -> [item] -> walk (Bool, [item])+ go _ [] = pure (True, [])+ go turn whole@(item : rest) = do+ item' <- turn item+ (same, rest') <- go turn rest+ pure (if same && item' == item then (True, whole) else (False, item' : rest'))+ cached :: (Facts -> Expression) -> Expression cached node = let term = node (established term) in term @@ -100,7 +123,7 @@ established term = Facts (layer id hashExpression term) (tally term) (calm term) (unrepeated term) instance Eq Expression where- left == right = isTrue# (reallyUnsafePtrEquality# left right) || congruent left right+ left == right = left `seq` right `seq` (isTrue# (reallyUnsafePtrEquality# left right) || congruent left right) where congruent :: Expression -> Expression -> Bool congruent (Formed facts bds) (Formed facts' bds') = alongside facts facts' && bds == bds'@@ -224,6 +247,9 @@ hashShape :: Expression -> Int hashShape = layer (const 0) hashShape +isName :: Text -> Bool+isName = T.isPrefixOf "n·"+ hashSkeleton :: Expression -> Int hashSkeleton = hashShape . \case@@ -264,7 +290,9 @@ ExTermination -> step h 4 ExApplication ex arg -> goArgument (step (step h 5) (child ex)) arg ExDispatch ex at -> goAttribute (step (step h 6) (child ex)) at- ExMeta t -> hashText (step h 7) t+ ExMeta t+ | isName t -> step (step h 40) (symbol (hashText fnvOffset t))+ | otherwise -> hashText (step h 7) t ExAny slot -> goSlot (step h 32) slot ExPhiMeet ms i ex -> step (hashMaybeString (step (step h 9) i) ms) (child ex) ExPhiAgain ms i ex -> step (hashMaybeString (step (step h 10) i) ms) (child ex)@@ -311,13 +339,19 @@ FnFresh slot -> goSlot (step h 39) slot alike :: Expression -> Expression -> Bool-alike = likened (\_ _ -> False)+alike = alike' (const Nothing) +alike' :: (Text -> Maybe Expression) -> Expression -> Expression -> Bool+alike' look = likened look (\_ _ -> False)+ akin :: Expression -> Expression -> Bool-akin = likened grown+akin = akin' (const Nothing)++akin' :: (Text -> Maybe Expression) -> Expression -> Expression -> Bool+akin' look = likened look grown where grown :: Expression -> Expression -> Bool- grown before@(ExFormation left) after@(ExFormation right) = boxed left && boxed right && within before after+ grown before@(ExFormation left) after@(ExFormation right) = boxed left && boxed right && within' look before after grown _ _ = False boxed :: [Binding] -> Bool@@ -333,12 +367,32 @@ delta (BiDelta _) = True delta _ = False -likened :: (Expression -> Expression -> Bool) -> Expression -> Expression -> Bool-likened loose one two = isJust (goExpr (Map.empty, Map.empty) one two)+bijection :: Expression -> Expression -> Maybe (Map.Map Int Int)+bijection = bijection' (const Nothing)++bijection' :: (Text -> Maybe Expression) -> Expression -> Expression -> Maybe (Map.Map Int Int)+bijection' look one two = fst <$> matching look (\_ _ -> False) one two++likened :: (Text -> Maybe Expression) -> (Expression -> Expression -> Bool) -> Expression -> Expression -> Bool+likened look loose one two = isJust (matching look loose one two)++type Pairing = (Map.Map Int Int, Map.Map Int Int, Map.Map (Text, Text) ())++matching :: (Text -> Maybe Expression) -> (Expression -> Expression -> Bool) -> Expression -> Expression -> Maybe (Map.Map Int Int, Map.Map Int Int)+matching look loose one two = (\(forward, backward, _) -> (forward, backward)) <$> goExpr (Map.empty, Map.empty, Map.empty) one two where- goExpr :: (Map.Map Int Int, Map.Map Int Int) -> Expression -> Expression -> Maybe (Map.Map Int Int, Map.Map Int Int)+ goExpr :: Pairing -> Expression -> Expression -> Maybe Pairing goExpr pairing left right | loose left right = Just pairing+ goExpr pairing@(forward, backward, met) (ExMeta left) (ExMeta right)+ | Map.member (left, right) met = Just pairing+ | Just left' <- look left+ , Just right' <- look right =+ goExpr (forward, backward, Map.insert (left, right) () met) left' right'+ goExpr pairing (ExMeta left) right+ | Just left' <- look left = goExpr pairing left' right+ goExpr pairing left (ExMeta right)+ | Just right' <- look right = goExpr pairing left right' goExpr pairing (ExFormation left) (ExFormation right) = goList goBinding pairing left right goExpr pairing (ExApplication left arg) (ExApplication right arg') = goExpr pairing left right >>= \next -> goArgument next arg arg' goExpr pairing (ExDispatch left attr) (ExDispatch right attr')@@ -348,12 +402,12 @@ goExpr pairing (ExPhiAgain prefix idx left) (ExPhiAgain prefix' idx' right) | prefix == prefix' && idx == idx' = goExpr pairing left right goExpr pairing left right = same pairing left right- goBinding :: (Map.Map Int Int, Map.Map Int Int) -> Binding -> Binding -> Maybe (Map.Map Int Int, Map.Map Int Int)+ goBinding :: Pairing -> Binding -> Binding -> Maybe Pairing goBinding pairing (BiTau attr left) (BiTau attr' right) | attr == attr' = goExpr pairing left right- goBinding pairing (BiLambda (FnSymbol left)) (BiLambda (FnSymbol right)) = paired pairing left right+ goBinding pairing (BiLambda (FnSymbol left)) (BiLambda (FnSymbol right)) = twinned pairing left right goBinding pairing left right = same pairing left right- goArgument :: (Map.Map Int Int, Map.Map Int Int) -> Argument -> Argument -> Maybe (Map.Map Int Int, Map.Map Int Int)+ goArgument :: Pairing -> Argument -> Argument -> Maybe Pairing goArgument pairing (ArTau attr left) (ArTau attr' right) | attr == attr' = goExpr pairing left right goArgument pairing (ArAlpha alpha left) (ArAlpha alpha' right)@@ -367,10 +421,10 @@ same pairing left right | left == right = Just pairing | otherwise = Nothing- paired :: (Map.Map Int Int, Map.Map Int Int) -> Int -> Int -> Maybe (Map.Map Int Int, Map.Map Int Int)- paired (forward, backward) left right = case (Map.lookup left forward, Map.lookup right backward) of- (Nothing, Nothing) -> Just (Map.insert left right forward, Map.insert right left backward)- (Just right', Just _) | right' == right -> Just (forward, backward)+ twinned :: Pairing -> Int -> Int -> Maybe Pairing+ twinned (forward, backward, met) left right = case (Map.lookup left forward, Map.lookup right backward) of+ (Nothing, Nothing) -> Just (Map.insert left right forward, Map.insert right left backward, met)+ (Just right', Just _) | right' == right -> Just (forward, backward, met) _ -> Nothing type Searched = Map.Map (Int, Int) [(Expression, Expression, Bool)]@@ -378,12 +432,25 @@ type Search = Searched -> (Bool, Searched) within :: Expression -> Expression -> Bool-within before after = fst (coupled before after Map.empty)+within = within' (const Nothing)++within' :: (Text -> Maybe Expression) -> Expression -> Expression -> Bool+within' look before after = fst (coupled (opened before) (opened after) Map.empty) where+ opened :: Expression -> Expression+ opened term = maybe term opened (through term)+ through :: Expression -> Maybe Expression+ through (ExMeta name) = look name+ through _ = Nothing embedded :: Expression -> Expression -> Search- embedded inner outer searched = case recalled inner outer searched of+ embedded inner' outer' searched = case recalled inner outer searched of Just found -> (found, searched) Nothing -> remembered inner outer (some [answered (general inner outer), coupled inner outer, some (map (embedded inner) (children outer))] searched)+ where+ inner :: Expression+ inner = opened inner'+ outer :: Expression+ outer = opened outer' recalled :: Expression -> Expression -> Searched -> Maybe Bool recalled inner outer searched = listToMaybe [found | (inner', outer', found) <- Map.findWithDefault [] (digests inner outer) searched, inner' == inner, outer' == outer] remembered :: Expression -> Expression -> (Bool, Searched) -> (Bool, Searched)@@ -413,6 +480,11 @@ coupled (ExDispatch left attr) (ExDispatch right attr') = every [answered (attr == attr'), embedded left right] coupled (ExPhiMeet prefix idx left) (ExPhiMeet prefix' idx' right) = every [answered (prefix == prefix' && idx == idx'), embedded left right] coupled (ExPhiAgain prefix idx left) (ExPhiAgain prefix' idx' right) = every [answered (prefix == prefix' && idx == idx'), embedded left right]+ coupled (ExMeta left) (ExMeta right) | left == right = answered True+ coupled left@(ExMeta _) right+ | Just left' <- through left = coupled left' right+ coupled left right@(ExMeta _)+ | Just right' <- through right = coupled left right' coupled left right = answered (left == right) goBinding :: Binding -> Binding -> Search goBinding (BiTau attr left) (BiTau attr' right) = every [answered (attr == attr'), embedded left right]
src/Builder.hs view
@@ -198,9 +198,6 @@ dispatched <- buildExpression ex subst at' <- buildAttribute at subst Right (ExDispatch dispatched at')-buildExpression (ExApplication ExRoot (ArTau AtRho expr)) subst = do- _ <- buildExpression expr subst- Right ExRoot buildExpression (ExApplication expr arg) subst = do applied <- buildExpression expr subst arg' <- buildArgument arg subst
src/CLI/Helpers.hs view
@@ -12,10 +12,10 @@ import CLI.Types import CLI.Validators (invalidCLIArguments) import CST (EXPRESSION)-import Canonizer (canonizeExpr, lambdaNames)+import Canonizer (canonize, canonizeExpr, lambdaNames) import Compiled (compiled) import Control.Exception-import Control.Monad (mfilter, when, (>=>))+import Control.Monad (mfilter, when, zipWithM, (>=>)) import qualified Data.ByteString as BS import Data.Char (isDigit) import Data.Functor ((<&>))@@ -231,6 +231,7 @@ printRewrittens :: PrintContext -> Rewrittens' -> IO String printRewrittens ctx@PrintCtx{..} rewrittens@(chain, _) | _outputFormat == LATEX && _sequence = rewrittensToLatex rewrittens (printCtxToLatexCtx ctx)+ | _canonize = withHeaders <$> zipWithM (printCanonized ctx) (map fst chain) (map fst (canonize chain)) | otherwise = withHeaders <$> mapM (printAnswer ctx . fst) chain where withHeaders :: [String] -> String@@ -243,11 +244,12 @@ printAnswer :: PrintContext -> Expression -> IO String printAnswer ctx@PrintCtx{..} expr- | _canonize = printFocused ctx{_xmirCtx = renameAtoms (zip (lambdaNames expr) (lambdaNames canonized)) _xmirCtx} canonized+ | _canonize = printCanonized ctx expr (canonizeExpr expr) | otherwise = printFocused ctx expr- where- canonized :: Expression- canonized = canonizeExpr expr++printCanonized :: PrintContext -> Expression -> Expression -> IO String+printCanonized ctx@PrintCtx{..} expr canonized =+ printFocused ctx{_xmirCtx = renameAtoms (zip (lambdaNames expr) (lambdaNames canonized)) _xmirCtx} canonized printFocused :: PrintContext -> Expression -> IO String printFocused ctx@PrintCtx{..} expr
src/CLI/Parsers.hs view
@@ -379,6 +379,9 @@ optSugar :: Parser SugarType optSugar = flag SALTY SWEET (long "sweet" <> help (printf "Print result and intermediate (see %s option(s)) 𝜑-expressions using syntax sugar" _intermediateOptions)) +optCheat :: Parser Bool+optCheat = switch (long "cheat" <> help "Let normalization take shortcuts its rules do not spell, such as dropping a ρ applied to a term that already ends with one; the steps then differ from what the rules prescribe")+ optHideRho :: Parser Bool optHideRho = switch (long "hide-rho" <> help "Remove every ρ binding from result and intermediate 𝜑-expressions for cleaner output") @@ -449,6 +452,7 @@ <*> optHeaders <*> optCanonize <*> optDepthSensitive+ <*> optCheat <*> optShuffle <*> optSeed <*> switch (long "quiet" <> help "Don't print the result of dataization")@@ -502,6 +506,7 @@ <*> optHeaders <*> optCanonize <*> optDepthSensitive+ <*> optCheat <*> optShuffle <*> optSeed <*> switch (long "quiet" <> help "Don't print the result of morphing")@@ -555,6 +560,7 @@ <*> optOmitListing <*> optOmitComments <*> optDepthSensitive+ <*> optCheat <*> optNonumber <*> switch (long "in-place" <> help "Edit file in-place instead of printing to output") <*> switch (long "update" <> help "Skip rewriting if --target file is newer than the input file")
src/CLI/Runners.hs view
@@ -26,11 +26,12 @@ import Deps (Judgment (..), dontSaveMade) import Emit (emitted) import Encoding-import Engine (Engine (..), building, current, stepOf)+import Engine (Engine (..), building, cheat, current, stepOf) import Evaluate (evaluation) import Files (overwrite) import qualified Filter as F import LaTeX (explainContextualizeRules, explainDataizeRules, explainMorphRules, explainRules)+import Locator (withLocatedExpression) import Logger import Margin (defaultMargin) import Merge (merge)@@ -41,6 +42,7 @@ import qualified Random as R import Rewriter import Rule (RuleContext (..), matchExpressionWithRule)+import Sides (sides) import Slots (anonymous) import System.Directory (canonicalizePath, doesFileExist, getModificationTime) import System.Exit (exitSuccess)@@ -62,7 +64,7 @@ validateNoOverlap "show" included "hide" excluded setStdGen (mkStdGen _seed) rules <- getRules _normalize _shuffle _rules- linked <- engine+ linked <- (if _cheat then cheat else id) <$> engine validateBreakpoint _breakpoint rules input <- readInput _inputFile (expr, atoms) <- parseInputWithAtoms input _inputFormat _monoform@@ -77,7 +79,7 @@ exclude = (`F.exclude` excluded) include = (`F.include` included) save <- saveStepFunc _stepsDir printCtx included excluded- let steps = map (stepOf linked) rules+ let steps = map ((if _cheat then cheating else id) . stepOf linked) rules (rewrittens, exceeded) <- rewrite expr steps (RewriteContext loc _maxDepth _maxCycles _depthSensitive Nothing (building linked) linked._normal (every steps) _must _breakpoint save dontSaveMade) when (isJust _breakpoint && NE.length rewrittens == 1) (clearedStepsDir _stepsDir) rewrittens' <- exclude (if _sequence then NE.toList rewrittens else [NE.last rewrittens]) >>= include@@ -182,9 +184,10 @@ save <- saveStepFunc _stepsDir printCtx included excluded tally <- tallied _maxFirings minted <- newIORef 0+ named <- sides memo <- memoized _acyclic facts <- factual- linked <- engine+ linked <- (if _cheat then cheat else id) <$> engine header <- headerOf args _inputFile input expr _symbolic lambdas ((outcome, chain, _), universe, aim) <- withEvalFunc@@ -192,19 +195,23 @@ _minutes printCtx ( \record -> do- let ctx = ReduceContext loc loc Nothing _maxDepth _maxCycles _maxNodes _maxMemory (Steps _maxSteps 0) tally minted deadline memo 1 (Just (1, Dataization, loc)) _depthSensitive _shuffle _partial _acyclic _maxLoops Dataization [] Map.empty (Just facts) lambdas [] False (building linked) reduction evaluation save record linked+ let ctx = ReduceContext loc loc Nothing _maxDepth _maxCycles _maxNodes _maxMemory (Steps _maxSteps 0) tally minted named deadline memo 1 (Just (1, Dataization, loc)) _depthSensitive _shuffle _partial _acyclic _maxLoops Dataization [] Map.empty (Just facts) lambdas [] False Nothing (building linked) reduction evaluation save record linked (universe, aiming) <- aimed printCtx Dataization header _inside expr ctx started universe aiming (,universe,aiming._locator) <$> dataize universe emptyState aiming )+ printed <-+ if _quiet+ then pure Nothing+ else Just <$> printOutcome printCtx (resolvedAnswer foc aim universe chain excluded included) outcome when _sequence (exclude chain >>= include >>= \shown -> printRewrittens printCtx (shown, False) >>= putStrLn)- unless _quiet (printOutcome printCtx (filteredAt aim universe excluded included) outcome >>= putStrLn)+ mapM_ putStrLn printed where printOutcome :: PrintContext -> (Expression -> IO Expression) -> Outcome -> IO String printOutcome _ _ (Dataized bytes) = pure (P.printBytes bytes)- printOutcome ctx narrowed (Residual residue) = do+ printOutcome ctx resolve (Residual residue) = do logDebug "Dataization got stuck on a λ function that cannot fire, printing the residual program (--partial)"- answer <- narrowed residue+ answer <- resolve residue validateXmirTopLevel _outputFormat answer printAnswer ctx answer validateOpts :: IO ()@@ -269,9 +276,10 @@ save <- saveStepFunc _stepsDir printCtx included excluded tally <- tallied _maxFirings minted <- newIORef 0+ named <- sides memo <- memoized _acyclic facts <- factual- linked <- engine+ linked <- (if _cheat then cheat else id) <$> engine header <- headerOf args _inputFile input expr _symbolic lambdas ((morphed, chain, _), universe, aim) <- withEvalFunc@@ -279,7 +287,7 @@ _minutes printCtx ( \record -> do- let ctx = ReduceContext loc loc Nothing _maxDepth _maxCycles _maxNodes _maxMemory (Steps _maxSteps 0) tally minted deadline memo 1 (Just (1, Morphing, loc)) _depthSensitive _shuffle _partial _acyclic _maxLoops Morphing [] Map.empty (Just facts) lambdas [] False (building linked) reduction evaluation save record linked+ let ctx = ReduceContext loc loc Nothing _maxDepth _maxCycles _maxNodes _maxMemory (Steps _maxSteps 0) tally minted named deadline memo 1 (Just (1, Morphing, loc)) _depthSensitive _shuffle _partial _acyclic _maxLoops Morphing [] Map.empty (Just facts) lambdas [] False Nothing (building linked) reduction evaluation save record linked (universe, aiming) <- aimed printCtx Morphing header _inside expr ctx started universe aiming (,universe,aiming._locator) <$> morph universe emptyState aiming@@ -288,18 +296,12 @@ if _quiet then pure Nothing else do- answer <-- if foc == ExRoot- then filteredAt aim universe excluded included morphed- else F.exclude' (maybe morphed fst (lastMaybe chain)) excluded >>= (`F.include'` included)+ answer <- resolvedAnswer foc aim universe chain excluded included morphed validateXmirTopLevel _outputFormat answer Just <$> printAnswer printCtx answer when _sequence (exclude chain >>= include >>= \shown -> printRewrittens printCtx (shown, False) >>= putStrLn) mapM_ putStrLn printed where- lastMaybe :: [a] -> Maybe a- lastMaybe [] = Nothing- lastMaybe items = Just (last items) validateOpts :: IO () validateOpts = do validateLatexOptions@@ -421,7 +423,7 @@ traverse_ (throwIO . AnonymousMetaInCondition . T.unpack) (anonymous condition) traverse_ (throwIO . UnboundMetaInCondition . T.unpack) (listToMaybe (unboundMetas ptn condition)) linked <- engine- substs <- matchExpressionWithRule expr (rule ptn condition) (RuleContext (building linked) Nothing linked._normal)+ substs <- matchExpressionWithRule expr (rule ptn condition) (RuleContext (building linked) Nothing linked._normal False) if null substs then throwIO EmptySubstsOnMatch else putStrLn (P.printSubsts' substs (_sugarType, UNICODE, _flat, defaultMargin))@@ -459,3 +461,15 @@ if found then pure (Just full) else if parent == full then pure Nothing else projectRootOf parent++resolvedAnswer :: Expression -> Expression -> Expression -> [(Expression, b)] -> [Expression] -> [Expression] -> Expression -> IO Expression+resolvedAnswer foc aim universe chain excluded included expr =+ if foc == ExRoot+ then filteredAt aim universe excluded included expr+ else do+ located <- withLocatedExpression aim expr (maybe universe fst (lastMaybe chain))+ F.exclude' located excluded >>= (`F.include'` included)++lastMaybe :: [a] -> Maybe a+lastMaybe [] = Nothing+lastMaybe items = Just (last items)
src/CLI/Types.hs view
@@ -107,6 +107,7 @@ , _headers :: Bool , _canonize :: Bool , _depthSensitive :: Bool+ , _cheat :: Bool , _shuffle :: Bool , _seed :: Int , _quiet :: Bool@@ -157,6 +158,7 @@ , _headers :: Bool , _canonize :: Bool , _depthSensitive :: Bool+ , _cheat :: Bool , _shuffle :: Bool , _seed :: Int , _quiet :: Bool@@ -220,6 +222,7 @@ , _omitListing :: Bool , _omitComments :: Bool , _depthSensitive :: Bool+ , _cheat :: Bool , _nonumber :: Bool , _inPlace :: Bool , _update :: Bool
src/CLI/Validators.hs view
@@ -67,10 +67,11 @@ validateLatexOptions :: IOFormat -> [(Bool, String)] -> [(Maybe String, String)] -> [(Maybe Int, String)] -> IO () validateLatexOptions LATEX _ strings _ = forM_ strings validateLatexString where- validateLatexString (Just label, "label") =- unless (all safeLabelCharacter label) $- invalidCLIArguments- "The --label option must contain only letters, numbers, colons, periods, underscores, and hyphens"+ validateLatexString (Just value, opt)+ | opt `elem` ["label", "meet-prefix"] =+ unless (all safeLabelCharacter value) $+ invalidCLIArguments+ (printf "The --%s option must contain only letters, numbers, colons, periods, underscores, and hyphens" opt) validateLatexString _ = pure () safeLabelCharacter character = isAlphaNum character || character `elem` ":._-" validateLatexOptions _ bools strings ints = do
src/Canonizer.hs view
@@ -78,5 +78,10 @@ canonizeExpr expr = fst (canonizeExpression expr (Map.empty, 1)) canonize :: [Rewritten] -> [Rewritten]-canonize [] = []-canonize ((expr, maybeRule) : rest) = (canonizeExpr expr, maybeRule) : canonize rest+canonize rewrittens = go rewrittens (Map.empty, 1)+ where+ go :: [Rewritten] -> CanonState -> [Rewritten]+ go [] _ = []+ go ((expr, maybeRule) : rest) st =+ let (expr', st') = canonizeExpression expr st+ in (expr', maybeRule) : go rest st'
src/Contextualize.hs view
@@ -26,6 +26,8 @@ concluded :: Expression -> [(String, Either ContextualizeException Expression)] -> Either ContextualizeException Expression concluded _ [(_, answer)] = answer+concluded term@(ExMeta meta) []+ | isName meta = Right term concluded term [] = Left (Uncontextualizable term "no contextualization rule matches the term") concluded term several = Left (Uncontextualizable term (printf "the contextualization rules %s all match the term" (intercalate ", " (map fst several))))
src/Dataize.hs view
@@ -22,6 +22,7 @@ import Locator (locatedExpression) import Morph (Morphed, ReduceContext (..), ReduceException (..), ReductionFunc, carried, deeper, inferred, insideUniverse, leadsTo, onward, opening, parking, severing, universed, vetted) import Rewriter (Rewritten)+import Sides (spelled) type Dataized = (Bytes, [Rewritten]) @@ -52,7 +53,7 @@ dead = "⊥" residual :: NonEmpty Rewritten -> State -> IO (Outcome, [Rewritten], State) residual seq parked = do- residue <- locatedExpression _locator (fst (NE.head seq))+ residue <- spelled _sides =<< locatedExpression _locator (fst (NE.head seq)) pure (Residual residue, reverse (NE.toList seq), parked) dataize' :: Dataizable -> Expression -> State -> ReduceContext -> IO (Dataized, State)
src/Deps.hs view
@@ -132,9 +132,12 @@ | EvDelta Int Bytes | EvManufactured Int Int | EvBoxed Int Expression+ | EvShared Int Expression Expression | EvUndressed Int Expression | EvLooped Int Judgment Acyclic Expression Expression (Maybe (Int, Maybe Expression))+ | EvPassed Int Judgment Acyclic Expression Expression Expression (Maybe Expression) | EvStuck Int T.Text Judgment Expression+ | EvOpaque Int Int Judgment Expression | EvStall Int T.Text | EvStuckOn Int T.Text | EvStarved Int Int Judgment Expression@@ -160,11 +163,13 @@ | EvGuarded Int (Either T.Text Expression) (Expression, Expression) (Expression, Expression) Side (Maybe Expression) | EvDiverged Int (Expression, Expression) (Expression, Expression) [Attribute] Refusal | EvUnripe Int (Expression, Expression) (Expression, Expression) Side Attribute- | EvFabricated Int (Expression, Expression) (Expression, Expression) Expression+ | EvFabricated Int (Expression, Expression) (Expression, Expression) [(Expression, Expression)] Expression | EvTaken Int Expression | EvRemembered Int Expression Expression | EvMemoized Int Expression Expression+ | EvEvaluated Int Expression Expression | EvRecalled Int Expression Expression+ | EvRenamed Int Expression Expression Expression [(Int, Int)] | EvWorld Expression | EvHeader Header Expression Expression @@ -181,6 +186,7 @@ record (EvFiring depth key judgment site) = EvFiring depth key judgment (moved site) record (EvStarted depth judgment site) = EvStarted depth judgment (moved site) record (EvLooped depth judgment mode self site answered) = EvLooped depth judgment mode self (moved site) answered+ record (EvPassed depth judgment mode self site term call) = EvPassed depth judgment mode self (moved site) term call record (EvStarved depth limit judgment site) = EvStarved depth limit judgment (moved site) record (EvTimeout depth limit judgment site) = EvTimeout depth limit judgment (moved site) record (EvSpent depth limit judgment site) = EvSpent depth limit judgment (moved site)@@ -207,9 +213,12 @@ tier (EvDelta depth _) = depth tier (EvManufactured depth _) = depth tier (EvBoxed depth _) = depth+tier (EvShared depth _ _) = depth tier (EvUndressed depth _) = depth tier (EvLooped depth _ _ _ _ _) = depth+tier (EvPassed depth _ _ _ _ _ _) = depth tier (EvStuck depth _ _ _) = depth+tier (EvOpaque depth _ _ _) = depth tier (EvStall depth _) = depth tier (EvStuckOn depth _) = depth tier (EvStarved depth _ _ _) = depth@@ -235,11 +244,13 @@ tier (EvGuarded depth _ _ _ _ _) = depth tier (EvDiverged depth _ _ _ _) = depth tier (EvUnripe depth _ _ _ _) = depth-tier (EvFabricated depth _ _ _) = depth+tier (EvFabricated depth _ _ _ _) = depth tier (EvTaken depth _) = depth tier (EvRemembered depth _ _) = depth tier (EvMemoized depth _ _) = depth+tier (EvEvaluated depth _ _) = depth tier (EvRecalled depth _ _) = depth+tier (EvRenamed depth _ _ _ _) = depth tier EvWorld{} = maxBound tier EvHeader{} = 0 @@ -296,12 +307,13 @@ , _blocks :: [(Int, Maybe (Judgment, String), String, Bool)] , _answered :: [(Int, Expression, String)] , _unwritten :: Map.Map Int (Named Expression)- , _stated :: Named [(Expression, (String, String))]+ , _stated :: Named [(Expression, (T.Text, T.Text))] , _spelt :: Map.Map Int (Map.Map Bytes String)+ , _lambdas :: Map.Map Int T.Text } emptyProtocol :: Protocol-emptyProtocol = Protocol 0 Map.empty [] False Map.empty Map.empty Map.empty Map.empty Nothing [] [] Map.empty Map.empty Map.empty+emptyProtocol = Protocol 0 Map.empty [] False Map.empty Map.empty Map.empty Map.empty Nothing [] [] Map.empty Map.empty Map.empty Map.empty data Nesting = Nesting { _fires :: Int@@ -319,7 +331,7 @@ , _shapes :: Map.Map [Maybe Attribute] [(Expression, [Binding])] , _opaque :: Int , _unmarked :: Map.Map Int (Named Expression)- , _attested :: Named [(Expression, (String, String))]+ , _attested :: Named [(Expression, (T.Text, T.Text))] } type Naming = StateT (Nesting, [String]) IO@@ -327,11 +339,14 @@ emptyNesting :: Nesting emptyNesting = Nesting 0 [] [] Map.empty Map.empty Map.empty Map.empty Nothing [] [] [] Map.empty Map.empty 0 Map.empty Map.empty -stated :: Expression -> Expression -> String -> String -> Named [(Expression, (String, String))] -> Named [(Expression, (String, String))]-stated object source left right facts = namedInsert object ((source, (left, right)) : fromMaybe [] (namedLookup object facts)) facts+stated :: Expression -> Expression -> String -> String -> Named [(Expression, (T.Text, T.Text))] -> Named [(Expression, (T.Text, T.Text))]+stated object source left right facts = packed `seq` namedInsert object ((source, packed) : fromMaybe [] (namedLookup object facts)) facts+ where+ packed :: (T.Text, T.Text)+ packed = ((,) $! T.pack left) $! T.pack right -statement :: Expression -> Expression -> Named [(Expression, (String, String))] -> Maybe (String, String)-statement object source facts = namedLookup object facts >>= lookup source+statement :: Expression -> Expression -> Named [(Expression, (T.Text, T.Text))] -> Maybe (String, String)+statement object source facts = bimap T.unpack T.unpack <$> (namedLookup object facts >>= lookup source) saveEval :: Handle -> IORef Protocol -> (Expression -> IO String) -> (Expression -> IO String) -> SaveEvalFunc saveEval handle cursor printed printed' report = do@@ -367,7 +382,7 @@ context protocol judgment site = do locator <- located protocol site let said = printf "%s(%s)" (letter judgment) locator- pure [said | innermost protocol /= Just said]+ pure [printf "%s(%s)" (letter judgment) (owned protocol site locator) | innermost protocol /= Just said] innermost :: Protocol -> Maybe String innermost protocol = case protocol._blocks of (_, heading, _, _) : _ -> snd <$> heading@@ -384,18 +399,20 @@ hPutStrLn handle line logDebug (printf "Saved one line of the protocol: %s" (dropWhile (== ' ') line)) stating :: Int -> String -> String -> Expression -> Expression -> Protocol -> IO (Protocol, Maybe String)- stating at word arrow object source protocol = do+ stating at word arrow object source = stating' at word arrow object source []+ stating' :: Int -> String -> String -> Expression -> Expression -> [String] -> Protocol -> IO (Protocol, Maybe String)+ stating' at word arrow object source remarks protocol = do origin <- render source case namedLookup object protocol._made of Just _ -> do known <- render object- pure (protocol{_stated = stated object source known origin protocol._stated}, Just (indented at (printf "%s %s %s %s" word known arrow origin)))+ pure (protocol{_stated = stated object source known origin protocol._stated}, Just (indented at (remarked (printf "%s %s %s %s" word known arrow origin) remarks))) Nothing -> do let (index, counted) = numbered protocol naming :: String naming = printf "%s·%d" (labelled protocol answer) index body <- printed (abbreviatedInside protocol._made object)- pure (counted{_made = namedInsert object (alias (opener protocol) index) counted._made, _stated = stated object source naming origin counted._stated}, Just (indented at (printf "%s %s %s %s # %s" word naming arrow origin body)))+ pure (counted{_made = namedInsert object (alias (opener protocol) index) counted._made, _stated = stated object source naming origin counted._stated}, Just (indented at (remarked (printf "%s %s %s %s" word naming arrow origin) (body : remarks)))) written :: Int -> Evaluation -> Protocol -> IO (Protocol, Maybe String) written _ (EvRun judgment locator) protocol = pure (protocol{_begun = True, _blocks = [(0, Just (judgment, heading), heading ++ ":", True)]}, Just (heading ++ ":"))@@ -408,6 +425,7 @@ ( protocol { _fired = firings , _open = (depth, firings) : protocol._open+ , _lambdas = Map.insert firings key protocol._lambdas , _blocks = (at, Nothing, opening, True) : protocol._blocks } , Just opening@@ -431,6 +449,10 @@ let (naming, protocol') = stored (Left symbol) protocol pure (protocol', Just (indented at (printf "%s := %s" naming datum))) written at (EvBoxed _ term) protocol = taking at "boxed" term protocol+ written at (EvShared _ name term) protocol = do+ label <- render name+ value <- printed (abbreviatedInside protocol._made term)+ pure (protocol, Just (indented at (printf "shared %s := %s" label value))) written at (EvUndressed _ term) protocol = taking at "undressed" term protocol written at (EvLooped _ judgment mode self site answered) protocol = do form <- render self@@ -442,9 +464,20 @@ severed form (symbol, call) = do made <- traverse (printed . abbreviatedInside protocol._made) call pure (printf "looped %s%s" (printFunction (FnSymbol symbol)) (maybe "" (" := " ++) made), [printf "repeats %s" form])+ written at (EvPassed _ judgment mode self site term call) protocol = do+ form <- render self+ remarks <- context protocol judgment site+ let (index, counted) = numbered protocol+ naming :: String+ naming = printf "%s·%d" (labelled protocol answer) index+ value <- maybe (borrowed protocol term) (printed . abbreviatedInside protocol._made) call+ pure (counted{_made = namedFormation term (alias (opener protocol) index) counted._made}, Just (indented at (remarked (printf "passed %s := %s" naming value) (remarks ++ [certainty mode, printf "repeats %s" form])))) written at (EvStuck _ key judgment self) protocol = do form <- render self pure (protocol, Just (indented at (printf "unanswered %s # %s(%s)" (T.unpack key) (letter judgment) form)))+ written at (EvOpaque _ symbol judgment self) protocol = do+ form <- render self+ pure (protocol, Just (indented at (printf "opaque %s # %s(%s)" (printFunction (FnSymbol symbol)) (letter judgment) form))) written at (EvStall _ key) protocol = pure (protocol, Just (indented at (printf "stall %s" (T.unpack key)))) written at (EvStuckOn _ key) protocol =@@ -481,7 +514,7 @@ written at (EvReshaped _ spelling block source term) protocol = do let naming = labelled protocol spelling (protocol', value) <- inscribed protocol naming term- line <- printf "%s := %s # %s(%s)" naming value (T.unpack block) <$> salted (unwritten protocol source)+ line <- printf "%s := %s # %s(%s)" naming value (T.unpack block) . owned protocol source <$> salted (unwritten protocol source) pure (protocol', Just (indented at line)) written at (EvSymbolized _ symbol bytes) protocol = do datum <- render (ExBytes bytes)@@ -513,7 +546,7 @@ let (index, counted) = numbered protocol value <- borrowed protocol term let naming = printf "%s·%d" (labelled protocol answer) index- pure (counted{_built = Map.insert (opener protocol) index counted._built, _answered = (depth, term, naming) : counted._answered}, Just (indented at (printf "%s := %s # %s" naming value (T.unpack answer))))+ pure (counted{_built = Map.insert (opener protocol) index counted._built, _answered = (depth, term, naming) : counted._answered}, Just (indented at (printf "%s := %s # %s" naming value (entered protocol (T.unpack answer))))) written at (EvAnswer _ term) protocol = do let (index, counted) = numbered protocol stem :: String@@ -549,10 +582,10 @@ one <- sided protocol left two <- sided protocol right pure (protocol, Just (indented at (printf "unripe %s vs %s # %s" one two (refused (Unripe side attr)))))- written at (EvFabricated _ left right term) protocol = do+ written at (EvFabricated _ left right names term) protocol = do one <- sided protocol left two <- sided protocol right- body <- printed (abbreviatedInside protocol._made term)+ body <- printed (abbreviatedInside protocol._made (unnamed names term)) let (index, counted) = numbered protocol pure (counted{_made = namedInsert term (alias (opener protocol) index) counted._made}, Just (indented at (printf "fabricated %s·%d := %s and %s # %s" (labelled protocol answer) index one two body))) written at (EvTaken _ term) protocol = do@@ -563,9 +596,15 @@ pure (protocol'{_made = namedFormation term (alias (opener protocol) index) protocol'._made}, Just (indented at (printf "%s := %s" naming value))) written at (EvRemembered _ object source) protocol = stating at "remembered" "≡" object source protocol written at (EvMemoized _ form reply) protocol = stating at "memoized" "⇛" form reply protocol+ written at (EvEvaluated _ form reply) protocol = do+ origin <- render form+ second (fmap (`remarked` [origin])) <$> concluding at "evaluated" reply protocol written at (EvRecalled _ term reply) protocol = do (known, given) <- maybe ((,) <$> render term <*> render reply) pure (statement term reply protocol._stated) pure (protocol, Just (indented at (printf "recalled %s ⇒ %s" known given)))+ written at (EvRenamed _ form reply source pairs) protocol = do+ origin <- render source+ stating' at "renamed" "⇛" form reply (("from " ++ origin) : [printf "%s as %s" (printFunction (FnSymbol old)) (printFunction (FnSymbol new)) | (old, new) <- pairs]) protocol written _ (EvWorld world) protocol = pure (protocol{_made = namedInsert world ExRoot protocol._made}, Nothing) written _ (EvHeader (Header release revision dated command (World file count size tops bindings) table) locator expression) protocol = do place <- printed locator@@ -620,13 +659,19 @@ spoken :: Protocol -> Expression -> IO String spoken protocol meta = maybe (labelled protocol . T.pack <$> salted meta) (borrowed protocol) (namedLookup meta (held protocol)) commented :: Protocol -> String -> Judgment -> Expression -> IO String- commented protocol line judgment operand = printf "%s # %s(%s)" line (letter judgment) <$> salted (unwritten protocol operand)+ commented protocol line judgment operand = printf "%s # %s(%s)" line (letter judgment) . owned protocol operand <$> salted (unwritten protocol operand)+ owned :: Protocol -> Expression -> String -> String+ owned protocol term spelling = case unwritten protocol term of+ ExMeta meta | not (T.any (== '·') meta) -> entered protocol spelling+ _ -> spelling+ entered :: Protocol -> String -> String+ entered protocol spelling = maybe spelling (printf "%s of %s" spelling . T.unpack) (Map.lookup (opener protocol) protocol._lambdas) unwritten :: Protocol -> Expression -> Expression unwritten protocol = abbreviated (held protocol) held :: Protocol -> Named Expression held protocol = Map.findWithDefault Map.empty (opener protocol) protocol._unwritten outer :: Int -> Protocol -> Protocol- outer depth protocol = protocol{_open = dropWhile ((>= depth) . fst) protocol._open, _answered = dropWhile (\(level, _, _) -> level > depth) protocol._answered, _unwritten = foldr (Map.delete . snd) protocol._unwritten (takeWhile ((>= depth) . fst) protocol._open), _spelt = foldr (Map.delete . snd) protocol._spelt (takeWhile ((>= depth) . fst) protocol._open)}+ outer depth protocol = protocol{_open = dropWhile ((>= depth) . fst) protocol._open, _answered = dropWhile (\(level, _, _) -> level > depth) protocol._answered, _unwritten = foldr (Map.delete . snd) protocol._unwritten (takeWhile ((>= depth) . fst) protocol._open), _spelt = foldr (Map.delete . snd) protocol._spelt (takeWhile ((>= depth) . fst) protocol._open), _lambdas = foldr (Map.delete . snd) protocol._lambdas (takeWhile ((>= depth) . fst) protocol._open)} labelled :: Protocol -> T.Text -> String labelled protocol spelling = printf "%s·%d" (T.unpack spelling) (opener protocol) opener :: Protocol -> Int@@ -770,8 +815,23 @@ origin <- leaf depth self (object, given) <- called depth call pure (printf "<looped symbol=\"%s\" by=\"%s\" match=\"%s\" at=\"%s\" of=\"%s\" object=\"%s\"%s>%s</looped>" (sigma symbol) (opened judgment) (certainty mode) (escapeXML locator) (escapeXML origin) (escapeXML object) (trailed call) given)+ elements at (EvPassed depth judgment mode self site term call) nesting =+ placed at nesting $ do+ locator <- located depth site+ origin <- leaf depth self+ (object, given) <- maybe ((,"") <$> leaf depth term) (called depth) call+ (naming, aliased) <- counted+ modify (first (\nesting' -> nesting'{_objects = namedFormation term aliased nesting'._objects}))+ pure (printf "<passed meta=\"%s\" by=\"%s\" match=\"%s\" at=\"%s\" of=\"%s\" object=\"%s\"%s%s" (escapeXML naming) (opened judgment) (certainty mode) (escapeXML locator) (escapeXML origin) (escapeXML object) (maybe "" trailed call) (closing given))+ where+ closing :: String -> String+ closing "" = "/>"+ closing "<with></with>" = "/>"+ closing given = printf ">%s</passed>" given elements at (EvStuck depth key judgment self) nesting = placed at nesting (printf "<unanswered λ=\"%s\" by=\"%s\">%s</unanswered>" (quoted key) (opened judgment) . escapeXMLText <$> leaf depth self)+ elements at (EvOpaque depth symbol judgment self) nesting =+ placed at nesting (printf "<opaque symbol=\"%s\" by=\"%s\">%s</opaque>" (sigma symbol) (opened judgment) . escapeXMLText <$> leaf depth self) elements at (EvStall _ key) nesting = placed at nesting (pure (printf "<stalled λ=\"%s\"/>" (quoted key))) elements at (EvStuckOn _ key) nesting =@@ -796,6 +856,11 @@ where (naming, nesting') = stored (Left symbol) nesting elements at (EvBoxed depth term) nesting = taken at "boxed" depth term nesting+ elements at (EvShared depth name term) nesting =+ placed at nesting $ do+ label <- leaf depth name+ body <- coined depth term >>= lift . spelled+ pure (printf "<shared meta=\"%s\">%s</shared>" (escapeXML label) (escapeXMLText body)) elements at (EvUndressed depth term) nesting = taken at "undressed" depth term nesting elements at (EvData _ spelling _ value) nesting = placed at nesting $ case (found value nesting._held, value) of@@ -875,20 +940,26 @@ one <- sided depth nesting left two <- sided depth nesting right pure (printf "<unripe left=\"%s\" right=\"%s\" at=\"%s\"/>" (escapeXML one) (escapeXML two) (escapeXML (printAttribute attr)))- elements at (EvFabricated depth left right term) nesting =+ elements at (EvFabricated depth left right names term) nesting = placed at nesting $ do one <- sided depth nesting left two <- sided depth nesting right- body <- leaf depth term+ body <- leaf depth (unnamed names term) (naming, _) <- counted pure (printf "<fabricated meta=\"%s\" left=\"%s\" right=\"%s\">%s</fabricated>" (escapeXML naming) (escapeXML one) (escapeXML two) (escapeXMLText body)) elements at (EvTaken depth term) nesting = placed at nesting (concluded "answered" "" depth term) elements at (EvRemembered depth object source) nesting = placed at nesting (attesting "remembered" depth nesting object source) elements at (EvMemoized depth form reply) nesting = placed at nesting (attesting "memoized" depth nesting form reply)+ elements at (EvEvaluated depth form reply) nesting = placed at nesting (leaf depth form >>= \origin -> concluded "evaluated" (printf " of=\"%s\"" (escapeXML origin)) depth reply) elements at (EvRecalled depth term reply) nesting = placed at nesting $ do (asked, given) <- maybe ((,) <$> leaf depth term <*> leaf depth reply) pure (statement term reply nesting._attested) pure (printf "<recalled of=\"%s\" as=\"%s\"/>" (escapeXML asked) (escapeXML given))+ elements at (EvRenamed depth form reply source pairs) nesting =+ placed at nesting $ do+ origin <- leaf depth source+ told <- testified depth nesting form reply+ pure (printf "<renamed %s from=\"%s\">%s</renamed>" told (escapeXML origin) (concat [printf "<as symbol=\"%s\" by=\"%s\"/>" (sigma old) (sigma new) :: String | (old, new) <- pairs])) elements _ (EvWorld world) nesting = pure (known world nesting, []) prologue :: Nesting -> [String] prologue nesting@@ -924,17 +995,19 @@ index :: Int index = maybe 1 (+ 1) (Map.lookup (opener nesting) nesting._numbered) attesting :: String -> Int -> Nesting -> Expression -> Expression -> Naming String- attesting word depth nesting object source = do+ attesting word depth nesting object source = printf "<%s %s/>" word <$> testified depth nesting object source+ testified :: Int -> Nesting -> Expression -> Expression -> Naming String+ testified depth nesting object source = do origin <- leaf depth source case namedLookup object nesting._objects of Just _ -> do kept <- leaf depth object modify (first (\nesting' -> nesting'{_attested = stated object source kept origin nesting'._attested}))- pure (printf "<%s of=\"%s\" as=\"%s\"/>" word (escapeXML kept) (escapeXML origin))+ pure (printf "of=\"%s\" as=\"%s\"" (escapeXML kept) (escapeXML origin)) Nothing -> do (naming, aliased) <- counted modify (first (\nesting' -> nesting'{_objects = namedInsert object aliased nesting'._objects, _attested = stated object source naming origin nesting'._attested}))- pure (printf "<%s meta=\"%s\" as=\"%s\"/>" word (escapeXML naming) (escapeXML origin))+ pure (printf "meta=\"%s\" as=\"%s\"" (escapeXML naming) (escapeXML origin)) counted :: Naming (String, Expression) counted = do (nesting, records) <- get@@ -1277,3 +1350,19 @@ logInfo (printf "Started %d dataizations and fired %d λ functions in %.0fs, now at %s" progress._formations progress._firings (now - progress._began) locator) writeIORef cursor progress{_told = Just now} else writeIORef cursor progress++unnamed :: [(Expression, Expression)] -> Expression -> Expression+unnamed names = goExpr+ where+ goExpr :: Expression -> Expression+ goExpr term@(ExMeta _) = fromMaybe term (lookup term names)+ goExpr (ExFormation bds) = ExFormation (map goBinding bds)+ goExpr (ExApplication term arg) = ExApplication (goExpr term) (goArgument arg)+ goExpr (ExDispatch term attr) = ExDispatch (goExpr term) attr+ goExpr term = term+ goBinding :: Binding -> Binding+ goBinding (BiTau attr term) = BiTau attr (goExpr term)+ goBinding bd = bd+ goArgument :: Argument -> Argument+ goArgument (ArTau attr term) = ArTau attr (goExpr term)+ goArgument (ArAlpha alpha term) = ArAlpha alpha (goExpr term)
src/Emit.hs view
@@ -101,16 +101,24 @@ , "" , "-- Whether the term is a normal form: no built-in rule of normalization" , "-- matches anywhere inside it."+ , "-- A rule asking a meta for a normal form asks it of a part of the term,"+ , "-- and a part that is no normal form holds a match the walk meets anyway,"+ , "-- so the walk takes every such part for a normal form (#2409)." , "nf :: Expression -> Bool"- , "nf = Ru.normalWith (not . null . matching Nothing)"+ , "nf = Ru.normalWith (not . null . matchingBy (const True) Nothing)" , "" , "-- The numbers of the built-in rules of normalization matching somewhere in" , "-- the term, in the order one walk over it meets them, told the world the" , "-- term stands in." , "matching :: Maybe Expression -> Expression -> [Int]"- , "matching ="+ , "matching = matchingBy nf"+ , ""+ , "-- The numbers of the built-in rules of normalization matching somewhere in"+ , "-- the term, a rule asking a meta for a normal form told it by the test."+ , "matchingBy :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Int]"+ , "matchingBy normal =" , " M.hits"- , " " ++ listed' 4 [printf "(%d, %s, rewrite%s)" idx (show (redex rule)) name | (idx, (name, rule)) <- zip [0 :: Int ..] (take (length builtin) rules)]+ , " " ++ listed' 4 [printf "(%d, %s, rewrite%s normal)" idx (show (redex rule)) name | (idx, (name, rule)) <- zip [0 :: Int ..] (take (length builtin) rules)] , "" , "-- The Contextualization function 𝒞, the conclusion of the one rule matching" , "-- the term and the context."@@ -203,9 +211,9 @@ refused (quals, result) <- walked $ do pattern' <- matching rule.pattern "term"- when' <- maybe (pure []) (fmap (pure . Guard) . condition) rule.when+ when' <- maybe (pure []) (fmap (pure . Guard) . condition "normal") rule.when absolute <- mapM (fmap (\var -> Guard ("Ru.xiFree " ++ var)) . held) (prefixed "k" rule.pattern)- normal <- mapM (fmap (\var -> Guard ("Ru.normalHeld nf " ++ var)) . held) (prefixed "n" rule.pattern ++ prefixed "k" rule.pattern)+ normal <- mapM (fmap (\var -> Guard ("Ru.normalHeld normal " ++ var)) . held) (prefixed "n" rule.pattern ++ prefixed "k" rule.pattern) extras <- concat <$> mapM extended (fromMaybe [] rule.where_) result <- built True rule.result >>= maybe (refuse "its result names a meta its pattern does not bind") pure pure (pattern' ++ when' ++ absolute ++ normal ++ extras, result)@@ -215,10 +223,10 @@ ( unlines [ printf "-- The rule '%s'." (unwords (lines rule.name)) , printf "step%s :: Ru.Step" name- , printf "step%s = R.direct %s %s rewrite%s" name (show rule.name) (show (redex rule)) name+ , printf "step%s = R.direct %s %s (rewrite%s nf)" name (show rule.name) (show (redex rule)) name , ""- , printf "rewrite%s :: Maybe Expression -> Expression -> [Expression]" name- , printf "rewrite%s %s %s =" name universe (if "term" `elem` tokens body then "term" else "_")+ , printf "rewrite%s :: (Expression -> Bool) -> Maybe Expression -> Expression -> [Expression]" name+ , printf "rewrite%s %s %s %s =" name (if "normal" `elem` tokens body then "normal" else "_") universe (if "term" `elem` tokens body then "term" else "_") , body ] )@@ -227,7 +235,6 @@ refused | isJust rule.having = Left (printf "The rule '%s' cannot be compiled, since it has a 'having' condition" rule.name) | isNothing rule.when && fast rule.pattern rule.result = Left (printf "The rule '%s' cannot be compiled, since it rewrites a formation into a formation the fast way" rule.name)- | rooted rule.pattern = Left (printf "The rule '%s' cannot be compiled, since its pattern applies Φ to a ρ" rule.name) | otherwise = Right () walked :: Emitting a -> Either String a walked (Emitting walk) = either (Left . printf "The rule '%s' cannot be compiled, since %s" rule.name) (Right . fst) (walk (Scope Map.empty 1))@@ -301,7 +308,7 @@ (quals, result) <- walked $ do universe <- matching ematch "universe" term <- matching rule.pattern "term"- when' <- maybe (pure []) (fmap (pure . Guard) . condition) rule.when+ when' <- maybe (pure []) (fmap (pure . Guard) . condition "nf") rule.when absolute <- mapM (fmap (\var -> Guard ("Ru.xiFree " ++ var)) . held) (prefixed "k" rule.pattern) normal <- mapM (fmap (\var -> Guard ("Ru.normalHeld nf " ++ var)) . held) (prefixed "n" rule.pattern ++ prefixed "k" rule.pattern) result <- premised sides conclusion@@ -495,30 +502,30 @@ go (ExDispatch expr _) = go expr go _ = [] -condition :: Y.Condition -> Emitting String-condition (Y.And conds) = parens . intercalate " && " <$> mapM condition conds-condition (Y.Or conds) = parens . intercalate " || " <$> mapM condition conds-condition (Y.Not cond) = ("not " ++) . parens <$> condition cond-condition (Y.In attrs bds) = present True attrs bds-condition (Y.Disjoint attrs bds) = present False attrs bds-condition (Y.Eq (Y.CmpNum left) (Y.CmpNum right)) = compared "==" <$> number left <*> number right-condition (Y.Gt (Y.CmpNum left) (Y.CmpNum right)) = compared ">" <$> number left <*> number right-condition (Y.Eq (Y.CmpAttr left) (Y.CmpAttr right)) = compared "==" <$> attr' left <*> attr' right+condition :: String -> Y.Condition -> Emitting String+condition test (Y.And conds) = parens . intercalate " && " <$> mapM (condition test) conds+condition test (Y.Or conds) = parens . intercalate " || " <$> mapM (condition test) conds+condition test (Y.Not cond) = ("not " ++) . parens <$> condition test cond+condition _ (Y.In attrs bds) = present True attrs bds+condition _ (Y.Disjoint attrs bds) = present False attrs bds+condition _ (Y.Eq (Y.CmpNum left) (Y.CmpNum right)) = compared "==" <$> number left <*> number right+condition _ (Y.Gt (Y.CmpNum left) (Y.CmpNum right)) = compared ">" <$> number left <*> number right+condition _ (Y.Eq (Y.CmpAttr left) (Y.CmpAttr right)) = compared "==" <$> attr' left <*> attr' right where attr' :: Attribute -> Emitting (Maybe String) attr' (AtMeta meta) = known (Named meta) attr' (AtAny _) = pure Nothing attr' attr = Just <$> attributed attr-condition (Y.Eq (Y.CmpExpr left) (Y.CmpExpr right)) = compared "==" <$> built False left <*> built False right-condition (Y.Eq _ _) = pure "False"-condition (Y.Gt _ _) = pure "False"-condition (Y.NF expr) = asked "Ru.normalHeld nf" expr-condition (Y.Absolute expr) = asked "Ru.xiFree" expr-condition (Y.IsFormation (ExMeta meta)) = maybe "False" ("Ru.isFormation " ++) <$> known (Named meta)-condition (Y.IsFormation (ExFormation _)) = pure "True"-condition (Y.IsFormation _) = pure "False"-condition (Y.Matches _ _) = refuse "its condition 'matches' needs a run of dataization"-condition (Y.PartOf _ _) = refuse "its condition 'part-of' is not compiled yet"+condition _ (Y.Eq (Y.CmpExpr left) (Y.CmpExpr right)) = compared "==" <$> built False left <*> built False right+condition _ (Y.Eq _ _) = pure "False"+condition _ (Y.Gt _ _) = pure "False"+condition test (Y.NF expr) = asked ("Ru.normalHeld " ++ test) expr+condition _ (Y.Absolute expr) = asked "Ru.xiFree" expr+condition _ (Y.IsFormation (ExMeta meta)) = maybe "False" ("Ru.isFormation " ++) <$> known (Named meta)+condition _ (Y.IsFormation (ExFormation _)) = pure "True"+condition _ (Y.IsFormation _) = pure "False"+condition _ (Y.Matches _ _) = refuse "its condition 'matches' needs a run of dataization"+condition _ (Y.PartOf _ _) = refuse "its condition 'part-of' is not compiled yet" present :: Bool -> [Attribute] -> [Binding] -> Emitting String present every attrs bds = do@@ -559,7 +566,6 @@ built _ ExXi = pure (Just "ExXi") built _ ExRoot = pure (Just "ExRoot") built _ ExTermination = pure (Just "ExTermination")-built checked (ExApplication ExRoot (ArTau AtRho expr)) = fmap (const "ExRoot") <$> built checked expr built checked (ExFormation bds) = do parts <- mapM part bds pure (formation <$> sequence parts)@@ -640,14 +646,6 @@ texted :: T.Text -> String texted text = "T.pack " ++ show (T.unpack text)--rooted :: Expression -> Bool-rooted (ExApplication ExRoot (ArTau AtRho _)) = True-rooted (ExApplication expr (ArTau _ arg)) = rooted expr || rooted arg-rooted (ExApplication expr (ArAlpha _ arg)) = rooted expr || rooted arg-rooted (ExDispatch expr _) = rooted expr-rooted (ExFormation bds) = or [rooted expr | BiTau _ expr <- bds]-rooted _ = False known :: Meta -> Emitting (Maybe String) known key = Emitting (\scope@(Scope bound _) -> Right (Map.lookup key bound, scope))
src/Engine.hs view
@@ -3,7 +3,7 @@ -- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com -- SPDX-License-Identifier: MIT -module Engine (Engine (..), building, current, fresh, stepOf, yaml) where+module Engine (Engine (..), building, cheat, current, fresh, stepOf, yaml) where import AST import Contextualize (contextualize)@@ -14,7 +14,7 @@ import Deps (BuildTermFunc) import Functions (buildTerm, contextualizing) import Inference (Inference, dataizationOf, morphingOf)-import Rewriter (every, interpreted)+import Rewriter (cheating, every, interpreted) import Rule (Step, normal) import qualified Yaml as Y @@ -34,6 +34,9 @@ where steps :: [Step] steps = map interpreted Y.normalizationRules++cheat :: Engine -> Engine+cheat engine = engine{_normalization = map cheating engine._normalization, _rules = Map.map cheating engine._rules} stepOf :: Engine -> Y.Rule -> Step stepOf engine rule = fromMaybe (interpreted rule) (Map.lookup (show rule) engine._rules)
src/Evaluate.hs view
@@ -18,6 +18,7 @@ import Data.IORef (readIORef, writeIORef) import Data.List (partition) import Data.List.NonEmpty (NonEmpty (..))+import qualified Data.Map.Strict as Map import Data.Maybe (fromMaybe, isJust, listToMaybe) import qualified Data.Text as T import Deps (Evaluation (..), Judgment (Evaluation, Morphing), State (..), dontSaveEval, dontSaveStep, resited)@@ -25,32 +26,37 @@ import Forks (Refusal (Unnamed, Unripe), Side (Lefthand, Righthand), forked, joined) import Lambdas (Ending (..), Lambda (..), Line (..), Meta (..), cast, emptyLambdas, matched, minted, rewritten, stayed, symbolized, thrown) import Matcher (MetaValue (..), Subst, combine, substEmpty, substSingle, substSlot)-import Morph (Answer (..), Budget (..), Firing (..), Kept (..), ReduceContext (..), ReduceException (..), Steps (..), argued, awaited, called, charged, coined, counted, deeper, ended, expired, fired, isLambda, lambda, morphing, normalized, noted, opening, recalled, remember, remembered, remembering, repeats, retained, settled, starved, unparked, voided)+import Morph (Answer (..), Budget (..), Firing (..), Kept (..), Kindred, ReduceContext (..), ReduceException (..), Steps (..), adopted, argued, awaited, called, charged, coined, counted, deeper, ended, expired, fired, isLambda, kindle, kindred, lambda, minting, morphing, normalized, noted, opening, placed, recalled, remember, remembered, remembering, repeats, retained, settled, starved, unparked, voided) import Printer (printExpression, printFunction) import Rule (RuleContext (RuleContext))+import qualified Sides import Text.Printf (printf) evaluation :: ReduceContext -> State -> Expression -> Expression -> IO (Expression, State)-evaluation ctx state form univ = case form of+evaluation asked state form univ = case form of ExFormation bds | not (any isLambda bds) -> pure (form, state) | otherwise -> case lambda bds of Just (func, args) -> do- (raw, state') <- symbol func form args univ state ctx+ (raw, state') <- symbol func form worked args univ state ctx (normal, _) <- normalized raw ((univ, Nothing) :| []) ctx pure (normal, state') Nothing -> case unknown bds of- Just idx -> stuck idx form+ Just idx -> opaque idx Nothing -> throwIO (userError "Function evaluate() expects a formation with a single λ binding naming a function") _ -> throwIO (userError "Function evaluate() expects a formation") where+ ctx :: ReduceContext+ ctx = asked{_working = Nothing}+ worked :: Expression+ worked = fromMaybe form asked._working unknown :: [Binding] -> Maybe Int unknown bindings = case partition isLambda bindings of ([BiLambda (FnSymbol idx)], _) -> Just idx _ -> Nothing- stuck :: Int -> Expression -> IO (Expression, State)- stuck idx form = do- unless (name `elem` ctx._parked) (ctx._saveEval (EvStuck ctx._nesting name ctx._judgment form))+ opaque :: Int -> IO (Expression, State)+ opaque idx = do+ unless (name `elem` ctx._parked) (ctx._saveEval (EvOpaque ctx._nesting idx ctx._judgment worked)) throwIO (Stuck name) where name :: T.Text@@ -60,16 +66,23 @@ deriving stock (Show) deriving anyclass (Exception) -symbol :: T.Text -> Expression -> Expression -> Expression -> State -> ReduceContext -> IO (Expression, State)-symbol func form self univ state caller = case matched caller._symbolic func of+symbol :: T.Text -> Expression -> Expression -> Expression -> Expression -> State -> ReduceContext -> IO (Expression, State)+symbol func form whole self univ state caller = case matched caller._symbolic func of Nothing -> do- unless (func `elem` caller._parked) (caller._saveEval (EvStuck caller._nesting func caller._judgment form))+ unless (func `elem` caller._parked) (caller._saveEval (EvStuck caller._nesting func caller._judgment whole)) throwIO (Stuck func) Just entry -> do charged caller known <- recalled caller._memo form caller._steps._spent- maybe (made entry) told known+ maybe (kindred caller form >>= maybe (made entry) adopting) told known where+ adopting :: (Kindred, Map.Map Int Int, [(Int, Expression)]) -> IO (Expression, State)+ adopting kin = do+ caller._saveEval (EvFiring caller._nesting func caller._judgment caller._site)+ answer <- adopted caller kin form+ shown (caller._nesting + 1) answer+ closed answer+ pure (ended answer, state) made :: Lambda -> IO (Expression, State) made entry = do stamp <- counted caller._memo@@ -82,11 +95,13 @@ (bound'', undressed, normals') <- foldM (through ctx "undress" (peeled ctx)) (bound', morphed, normals) entry._undressed firing <- Firing func (reverse conditions) . (reverse normals' ++) <$> sides entry._ending known <- remembered caller._memo firing- maybe (worked ctx entry firing bound'' undressed) (\(first, answer) -> (answer, undressed) <$ recited ctx._nesting first answer) known+ (answer, state') <- maybe (worked ctx entry firing bound'' undressed) (\(first, answer) -> (answer, undressed) <$ recited ctx._nesting first answer) known+ (answer, state') <$ kindle caller._sides caller._memo form firing answer case outcome of Right (answer, state') -> do retained caller._memo form stamp (Answered answer) when (isJust caller._memo) (caller._saveEval (EvMemoized (caller._nesting + 1) form (ended answer)))+ closed answer pure (ended answer, state') Left failure -> do exhausted' <- starved caller._memo@@ -98,6 +113,7 @@ (lined, state'') <- foldM (passing ctx entry) (bound, state') entry._lines (answer, state''') <- concluded ctx entry operands lined state'' remember caller._memo firing form answer+ minting caller._memo firing answer known <- remembering caller._facts form when (known && spoken (ended answer)) (noted ctx (ended answer) form) pure (answer, state''')@@ -136,7 +152,7 @@ line ctx ending held (Evaluated meta source) = evaluated ctx ending held meta source line ctx _ (bound, state') (Deferred meta source) = (,state') <$> deferred ctx state' meta source bound line ctx _ held (Stayed meta source) = reshaped ctx "stay" (still (pure . stayed)) meta source held- line ctx _ held (Rewritten meta source rules) = reshaped ctx "rewrite" (still (awaited ctx . rewritten (RuleContext ctx._buildTerm ctx._universe ctx._engine._normal) rules)) meta source held+ line ctx _ held (Rewritten meta source rules) = reshaped ctx "rewrite" (still (awaited ctx . rewritten (RuleContext ctx._buildTerm ctx._universe ctx._engine._normal False) rules)) meta source held line ctx _ held (Symbolized meta source) = reshaped ctx "symbolize" (still (masked ctx)) meta source held line ctx _ held (Undressed meta source) = reshaped ctx "undress" (peeled ctx) meta source held line ctx _ held (Cast one first two second) = casting ctx held (one, first) (two, second)@@ -170,6 +186,7 @@ told (Answered answer) = do caller._saveEval (EvFiring caller._nesting func caller._judgment caller._site) recited (caller._nesting + 1) form answer+ closed answer pure (ended answer, state) told (Looped term) = do caller._saveEval (EvFiring caller._nesting func caller._judgment caller._site)@@ -179,6 +196,8 @@ caller._saveEval (EvFiring caller._nesting func caller._judgment caller._site) caller._saveEval (EvStall (caller._nesting + 1) name) throwIO (Stuck name)+ closed :: Answer -> IO ()+ closed answer = caller._saveEval (EvEvaluated (caller._nesting + 1) form (ended answer)) recited :: Int -> Expression -> Answer -> IO () recited depth term answer = do caller._saveEval (EvRecalled depth term (ended answer))@@ -203,6 +222,7 @@ Nothing -> throwIO (Stuck (fromMaybe func state''._stuck)) Just bytes -> do let datum = maybe (Right bytes) Left state''._manufactured+ mapM_ (placed caller._memo (fromMaybe term (walked term))) state''._manufactured ctx._saveEval (EvData ctx._nesting meta._spelling origin datum) bound' <- bind meta (MvBytes bytes) bound pure (datum, bound', state'')@@ -314,7 +334,8 @@ postponing :: ReduceContext -> State -> Expression -> Expression -> IO (Maybe Expression) postponing ctx state' site (ExFormation bds) | copied bds = do- known <- mapM resolved bds+ voids <- voided ctx{_saveEval = dontSaveEval} (ExFormation bds)+ known <- mapM (\bd -> if argument voids bd then resolved bd else pure bd) bds if any bare known then bool (Just <$> postponed known) (pure Nothing) =<< recursive else pure Nothing where recursive :: IO Bool@@ -339,6 +360,10 @@ formed :: Expression -> Bool formed (ExFormation _) = True formed _ = False+ argument :: Maybe [Attribute] -> Binding -> Bool+ argument Nothing _ = True+ argument (Just voids) (BiTau attr _) = attr `elem` voids+ argument _ _ = False bare :: Binding -> Bool bare (BiTau attr (ExFormation [BiLambda (FnSymbol _)])) = attr /= AtPhi && attr /= AtRho bare _ = False@@ -401,16 +426,19 @@ mapM_ (\side -> ctx._saveEval (EvGuarded ctx._nesting (either (Left . _spelling) Right on) (left, one) (right, two) side raised)) [side | null made, term /= ExTermination, (side, ExTermination) <- [(Lefthand, stopped one), (Righthand, stopped two)]] ctx._saveEval (EvTaken ctx._nesting term) pure (Joined term, state''')- Left path -> case maybe (Left Unnamed) (\name -> forked name condition one two) fallback of- Right term -> do- ctx._saveEval (EvFabricated ctx._nesting (left, one) (right, two) term)- pure (Joined term, state''')- Left (Unripe side attr) -> do- ctx._saveEval (EvUnripe ctx._nesting (left, one) (right, two) side attr)- throwIO (Diverged func)- Left refusal -> do- ctx._saveEval (EvDiverged ctx._nesting (left, one) (right, two) path refusal)- throwIO (Diverged func)+ Left path -> do+ leftName <- Sides.named ctx._sides one+ rightName <- Sides.named ctx._sides two+ case maybe (Left Unnamed) (\name -> forked name condition (leftName, one) (rightName, two)) fallback of+ Right term -> do+ ctx._saveEval (EvFabricated ctx._nesting (left, one) (right, two) [(leftName, one), (rightName, two)] term)+ pure (Joined term, state''')+ Left (Unripe side attr) -> do+ ctx._saveEval (EvUnripe ctx._nesting (left, one) (right, two) side attr)+ throwIO (Diverged func)+ Left refusal -> do+ ctx._saveEval (EvDiverged ctx._nesting (left, one) (right, two) path refusal)+ throwIO (Diverged func) weighed :: [(T.Text, Either Int Bytes)] -> Either Meta Expression -> IO (Either Int Bytes) weighed operands (Left meta) = maybe
src/Forks.hs view
@@ -13,6 +13,8 @@ import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Maybe (fromMaybe, listToMaybe, mapMaybe)+import Data.Set (Set)+import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as T @@ -102,8 +104,8 @@ Just name -> (name, joining) Nothing -> (succ spent', (succ spent', bottom, Map.insert pair (succ spent') names, (succ spent', pair) : made)) -forked :: Function -> Either Int Bytes -> Expression -> Expression -> Either Refusal Expression-forked func condition left right = do+forked :: Function -> Either Int Bytes -> (Expression, Expression) -> (Expression, Expression) -> Either Refusal Expression+forked func condition (leftName, left) (rightName, right) = do one <- inlined <$> formed Lefthand left two <- inlined <$> formed Righthand right maybe (Right (fabricated one two)) Left (listToMaybe (unripe Lefthand one two ++ unripe Righthand two one))@@ -112,29 +114,46 @@ formed side (ExFormation bds) = maybe (Right bds) (Left . Holding side) (listToMaybe [attr | Just attr <- map attributeFromBinding bds, attr == AtDelta || attr == AtLambda]) formed side _ = Left (Unformed side) fabricated :: [Binding] -> [Binding] -> Expression- fabricated one two = ExFormation (map BiVoid voids ++ [copy "left🌵" left one, copy "right🌵" right two] ++ map branch (filter (`notElem` voids) (nub (attributes one ++ attributes two))))+ fabricated one two = ExFormation (map BiVoid voids ++ [copy "left🌵" leftName one, copy "right🌵" rightName two] ++ map branch (filter (`Set.notMember` vacated) (distinct (attributes one ++ attributes two)))) where voids :: [Attribute]- voids = nub (vacant one ++ vacant two)+ voids = distinct (vacant one ++ vacant two)+ vacated :: Set Attribute+ vacated = Set.fromList voids+ heldOne :: Map Attribute [Attribute]+ heldOne = held one+ heldTwo :: Map Attribute [Attribute]+ heldTwo = held two branch :: Attribute -> Binding- branch attr = BiTau attr (ExFormation ([BiVoid AtRho, BiLambda func] ++ map BiVoid (inner attr) ++ [BiTau (AtLabel "on🌵") (ExFormation [either (BiLambda . FnSymbol) BiDelta condition]), ask "left🌵" one attr, ask "right🌵" two attr]))+ branch attr = BiTau attr (ExFormation ([BiVoid AtRho, BiLambda func] ++ map BiVoid (inner attr) ++ [weighing, ask "left🌵" leftward heldOne attr, ask "right🌵" rightward heldTwo attr]))+ weighing :: Binding+ weighing = BiTau (AtLabel "on🌵") (ExFormation [either (BiLambda . FnSymbol) BiDelta condition])+ leftward :: Expression+ leftward = ExDispatch (ExDispatch ExXi AtRho) (AtLabel "left🌵")+ rightward :: Expression+ rightward = ExDispatch (ExDispatch ExXi AtRho) (AtLabel "right🌵") inner :: Attribute -> [Attribute]- inner attr = nub (concat (mapMaybe (`held` attr) [one, two]))- ask :: Text -> [Binding] -> Attribute -> Binding- ask name bds attr = BiTau (AtLabel name) (applied (ExDispatch (ExDispatch (ExDispatch ExXi AtRho) (AtLabel name)) attr) (fromMaybe (inner attr) (held bds attr)))+ inner attr = nub (concat (mapMaybe (Map.lookup attr) [heldOne, heldTwo]))+ ask :: Text -> Expression -> Map Attribute [Attribute] -> Attribute -> Binding+ ask name side holding attr = BiTau (AtLabel name) (applied (ExDispatch side attr) (fromMaybe (inner attr) (Map.lookup attr holding))) inlined :: [Binding] -> [Binding] inlined bds = map goBinding bds where+ bodies :: Map Attribute Expression+ bodies = firsts [(label, bound) | BiTau label bound <- bds] goBinding :: Binding -> Binding goBinding (BiTau attr term) = BiTau attr (fromMaybe term (goTerm [attr] term)) goBinding bd = bd goTerm :: [Attribute] -> Expression -> Maybe Expression goTerm seen term@(ExDispatch ExXi name) | name `elem` seen = Nothing- | otherwise = maybe (Just term) (goTerm (name : seen)) (listToMaybe [bound | BiTau label bound <- bds, label == name])+ | otherwise = maybe (Just term) (goTerm (name : seen)) (Map.lookup name bodies) goTerm _ term = Just term unripe :: Side -> [Binding] -> [Binding] -> [Refusal]- unripe side bds others = [Unripe side attr | attr <- vacant bds, attr `elem` [label | BiTau label _ <- others]]+ unripe side bds others = [Unripe side attr | attr <- vacant bds, attr `Set.member` bound]+ where+ bound :: Set Attribute+ bound = Set.fromList [label | BiTau label _ <- others] vacant :: [Binding] -> [Attribute] vacant bds = [attr | BiVoid attr <- bds, own attr] attributes :: [Binding] -> [Attribute]@@ -146,5 +165,15 @@ copy name side bds = BiTau (AtLabel name) (applied side (vacant bds)) applied :: Expression -> [Attribute] -> Expression applied = foldl (\term attr -> ExApplication term (ArTau attr (ExDispatch ExXi attr)))- held :: [Binding] -> Attribute -> Maybe [Attribute]- held bds attr = listToMaybe [vacant inside | BiTau label (ExFormation inside) <- bds, label == attr]+ held :: [Binding] -> Map Attribute [Attribute]+ held bds = firsts [(label, vacant inside) | BiTau label (ExFormation inside) <- bds]+ firsts :: [(Attribute, value)] -> Map Attribute value+ firsts = Map.fromListWith (\_ earlier -> earlier)+ distinct :: [Attribute] -> [Attribute]+ distinct = go Set.empty+ where+ go :: Set Attribute -> [Attribute] -> [Attribute]+ go _ [] = []+ go seen (attr : rest)+ | attr `Set.member` seen = go seen rest+ | otherwise = attr : go (Set.insert attr seen) rest
src/Functions.hs view
@@ -309,20 +309,27 @@ (rest, used, next) <- renameBindings bds attrs unavailable changes pure (bd : rest, used, next) renameValue :: Map.Map Attribute Attribute -> Binding -> Binding- renameValue changes (BiTau attr expr) = BiTau attr (renameExpression changes expr)- renameValue _ binding = binding- renameExpression :: Map.Map Attribute Attribute -> Expression -> Expression- renameExpression changes expression = case expression of- ExFormation _ -> expression- ExApplication expr arg -> ExApplication (renameExpression changes expr) (renameArgument changes arg)- ExDispatch ExXi attr -> ExDispatch ExXi (Map.findWithDefault attr attr changes)- ExDispatch expr attr -> ExDispatch (renameExpression changes expr) attr- ExPhiMeet prefix idx expr -> ExPhiMeet prefix idx (renameExpression changes expr)- ExPhiAgain prefix idx expr -> ExPhiAgain prefix idx (renameExpression changes expr)+ renameValue changes = renameBinding changes 0+ renameBinding :: Map.Map Attribute Attribute -> Int -> Binding -> Binding+ renameBinding changes depth (BiTau attr expr) = BiTau attr (renameExpression changes depth expr)+ renameBinding _ _ binding = binding+ renameExpression :: Map.Map Attribute Attribute -> Int -> Expression -> Expression+ renameExpression changes depth expression = case expression of+ ExFormation bds -> ExFormation (map (renameBinding changes (depth + 1)) bds)+ ExApplication expr arg -> ExApplication (renameExpression changes depth expr) (renameArgument changes depth arg)+ ExDispatch expr attr+ | rhos depth expr -> ExDispatch expr (Map.findWithDefault attr attr changes)+ | otherwise -> ExDispatch (renameExpression changes depth expr) attr+ ExPhiMeet prefix idx expr -> ExPhiMeet prefix idx (renameExpression changes depth expr)+ ExPhiAgain prefix idx expr -> ExPhiAgain prefix idx (renameExpression changes depth expr) other -> other- renameArgument :: Map.Map Attribute Attribute -> Argument -> Argument- renameArgument changes (ArTau attr expr) = ArTau attr (renameExpression changes expr)- renameArgument changes (ArAlpha alpha expr) = ArAlpha alpha (renameExpression changes expr)+ rhos :: Int -> Expression -> Bool+ rhos 0 ExXi = True+ rhos depth (ExDispatch expr AtRho) | depth > 0 = rhos (depth - 1) expr+ rhos _ _ = False+ renameArgument :: Map.Map Attribute Attribute -> Int -> Argument -> Argument+ renameArgument changes depth (ArTau attr expr) = ArTau attr (renameExpression changes depth expr)+ renameArgument changes depth (ArAlpha alpha expr) = ArAlpha alpha (renameExpression changes depth expr) freshAttr :: Set.Set Attribute -> IO Attribute freshAttr unavailable = do term <- _randomTau [] subst
src/LaTeX.hs view
@@ -27,9 +27,9 @@ import AST import Bytes (nonFiniteName) import CST-import Canonizer (canonize, canonizeExpr)-import Data.Char (isAscii, ord)-import Data.List (intercalate, nub, zipWith4)+import Canonizer (canonize)+import Data.Char (isAscii, isAsciiLower, isAsciiUpper, isDigit, ord)+import Data.List (intercalate, isInfixOf, nub, zipWith4) import Data.Maybe (isJust) import qualified Data.Text as T import Deps (Judgment (..))@@ -209,10 +209,6 @@ canonizedRewrittens rewrittens LatexContext{_canonize = shouldCanonize} = if shouldCanonize then canonize rewrittens else rewrittens -canonizedExpressions :: [Expression] -> LatexContext -> [Expression]-canonizedExpressions exprs LatexContext{_canonize = shouldCanonize} =- if shouldCanonize then map canonizeExpr exprs else exprs- compressedExpressions :: [Expression] -> LatexContext -> [Expression] compressedExpressions exprs ctx@LatexContext{..} = if _compress then meetInExpressions exprs ctx else exprs@@ -232,7 +228,7 @@ pure ( concat [ preamble ctx- , body (stepComments rewrittens ctx) (zip (canonizedExpressions (compressedExpressions focused ctx) ctx) rules) (\tabs expr -> renderToLatex (shown ctx (expressionToCSTFrom tabs expr)) ctx)+ , body (stepComments rewrittens ctx) (canonizedRewrittens (zip (compressedExpressions focused ctx) rules) ctx) (\tabs expr -> renderToLatex (shown ctx (expressionToCSTFrom tabs expr)) ctx) , ending exceeded (last (arrows (map snd rewrittens))) ctx ] )@@ -268,9 +264,31 @@ toLaTeX EX_NONFINITE{..} = EX_DISPATCH (EX_GLOBAL global) SPACE (toLaTeX (AT_LABEL (nonFiniteName nonfinite))) toLaTeX EX_BYTES{..} = EX_BYTES (toLaTeX bytes) toLaTeX EX_SINGLE{..} = EX_SINGLE (toLaTeX pair) SPACE (toLaTeX formation)- toLaTeX EX_STRING{..} = EX_STRING (T.unpack (toLaTeX (T.pack str))) tab rhos+ toLaTeX EX_STRING{..}+ | plain str = EX_STRING (T.unpack (toLaTeX (T.pack str))) tab rhos+ | otherwise = EX_ATTR (AT_LABEL (T.pack ("|\\char34{}" ++ concatMap protected str ++ "\\char34{}|"))) toLaTeX num@EX_NUMBER{} = EX_ATTR (toLaTeX (AT_LABEL (render num))) toLaTeX expr = expr++plain :: String -> Bool+plain str =+ not (null str)+ && not (any (`elem` ("?|\">" :: String)) str)+ && not (any (`isInfixOf` str) ["<<", "==", ":=", "[[", "]]"])+ && not (any letter (zip3 (' ' : str) str (drop 1 str ++ " ")))+ where+ letter :: (Char, Char, Char) -> Bool+ letter (before, ch, after) = ch `elem` ("QTDL" :: String) && not (alnum before) && not (alnum after)++alnum :: Char -> Bool+alnum ch = isAsciiUpper ch || isAsciiLower ch || isDigit ch++protected :: Char -> String+protected ch+ | alnum ch && ch `notElem` ("QTDL" :: String) = [ch]+ | ch == ' ' = "\\space{}"+ | isAscii ch = printf "\\char%d{}" (ord ch)+ | otherwise = concatMap protected (printf "[U+%04X]" (ord ch) :: String) instance ToLaTeX ATTRIBUTE where toLaTeX AT_LABEL{..} = AT_LABEL (piped label)
src/Lambdas.hs view
@@ -434,20 +434,20 @@ stayed = goExpr where goExpr :: Expression -> Expression- goExpr (ExFormation bds) = ExFormation (map goBinding bds)- goExpr (ExApplication expr arg) = case (goExpr expr, arg) of+ goExpr term@(ExFormation bds) = intact bds term ExFormation (map goBinding bds)+ goExpr term@(ExApplication expr arg) = case (goExpr expr, arg) of (target, ArTau AtRho _) | dispatched target -> target- (target, _) -> ExApplication target (goArgument arg)- goExpr (ExDispatch expr attr) = ExDispatch (goExpr expr) attr+ (target, _) -> intact (expr, arg) term (uncurry ExApplication) (target, goArgument arg)+ goExpr term@(ExDispatch expr attr) = intact expr term (`ExDispatch` attr) (goExpr expr) goExpr (ExPhiMeet prefix idx expr) = ExPhiMeet prefix idx (goExpr expr) goExpr (ExPhiAgain prefix idx expr) = ExPhiAgain prefix idx (goExpr expr) goExpr expr = expr goBinding :: Binding -> Binding- goBinding (BiTau attr expr) = BiTau attr (goExpr expr)+ goBinding bd@(BiTau attr expr) = intact expr bd (BiTau attr) (goExpr expr) goBinding bd = bd goArgument :: Argument -> Argument- goArgument (ArTau attr expr) = ArTau attr (goExpr expr)- goArgument (ArAlpha alpha expr) = ArAlpha alpha (goExpr expr)+ goArgument arg@(ArTau attr expr) = intact expr arg (ArTau attr) (goExpr expr)+ goArgument arg@(ArAlpha alpha expr) = intact expr arg (ArAlpha alpha) (goExpr expr) dispatched :: Expression -> Bool dispatched (ExDispatch _ _) = True dispatched (ExApplication expr _) = dispatched expr@@ -505,16 +505,16 @@ (masked, (spent', known)) -> (masked, reverse known, spent') where goExpr :: Expression -> State Minting Expression- goExpr (ExFormation bds) = ExFormation <$> mapM (goBinding (Just AtLambda `elem` map attributeFromBinding bds)) bds- goExpr (ExApplication expr arg) = ExApplication <$> goExpr expr <*> goArgument arg- goExpr (ExDispatch expr attr) = (`ExDispatch` attr) <$> goExpr expr+ goExpr whole@(ExFormation bds) = intact bds whole ExFormation <$> mapM (goBinding (Just AtLambda `elem` map attributeFromBinding bds)) bds+ goExpr whole@(ExApplication expr arg) = intact (expr, arg) whole (uncurry ExApplication) <$> ((,) <$> goExpr expr <*> goArgument arg)+ goExpr whole@(ExDispatch expr attr) = intact expr whole (`ExDispatch` attr) <$> goExpr expr goExpr (ExPhiMeet prefix idx expr) = ExPhiMeet prefix idx <$> goExpr expr goExpr (ExPhiAgain prefix idx expr) = ExPhiAgain prefix idx <$> goExpr expr goExpr expr = pure expr goBinding :: Bool -> Binding -> State Minting Binding goBinding _ (BiDelta bts) = state (\(count, known) -> (BiLambda (FnSymbol (succ count)), (succ count, (succ count, bts) : known)))- goBinding atom (BiTau attr expr) | atom || attr == AtPhi = BiTau attr <$> goExpr expr+ goBinding atom bd@(BiTau attr expr) | atom || attr == AtPhi = intact expr bd (BiTau attr) <$> goExpr expr goBinding _ bd = pure bd goArgument :: Argument -> State Minting Argument- goArgument (ArTau attr expr) = ArTau attr <$> goExpr expr- goArgument (ArAlpha alpha expr) = ArAlpha alpha <$> goExpr expr+ goArgument arg@(ArTau attr expr) = intact expr arg (ArTau attr) <$> goExpr expr+ goArgument arg@(ArAlpha alpha expr) = intact expr arg (ArAlpha alpha) <$> goExpr expr
src/Margin.hs view
@@ -8,10 +8,8 @@ module Margin (defaultMargin, withMargin, withLines, WithMargin) where import CST-import Data.Char (GeneralCategory (..), generalCategory)-import qualified Data.Text as T import Lining (LineFormat (..), ToSingleLine (..))-import Render (Render (..))+import Render (Render (..), displayWidth, lastLineWidthAtMost, widthAtMost) defaultMargin :: Int defaultMargin = 80@@ -31,7 +29,7 @@ withMargin' (extra, margin) ex@EX_FORMATION{tab = tab@(TAB indent), ..} = let single = toSingleLine ex ex' = EX_FORMATION lsb EOL tab (withMargin' (2 * indent, margin) binding) EOL tab' rsb- in if lengthOf single + extra <= margin then single else ex'+ in if fits extra margin single then single else ex' withMargin' _ num@EX_NUMBER{} = num withMargin' _ str@EX_STRING{} = str withMargin' (extra, margin) EX_DISPATCH{..} = EX_DISPATCH (withMargin' (extra, margin - lengthOf attr - 1) expr) space attr@@ -41,19 +39,19 @@ let single = toSingleLine ex wide = withMargin' (extra + lengthOf attr + 1, margin) expr narrow = withMargin' (extra, margin - lengthOf attr - 1) expr- asset = if displayWidth (last (T.lines (render wide))) + lengthOf attr + 1 <= margin then wide else narrow- in if lengthOf single + extra <= margin then single else EX_SINGLE (PA_TAU attr arrow asset) space (withMargin' cfg formation)+ asset = if lastLineWidthAtMost margin wide + lengthOf attr + 1 <= margin then wide else narrow+ in if fits extra margin single then single else EX_SINGLE (PA_TAU attr arrow asset) space (withMargin' cfg formation) withMargin' cfg@(extra, margin) ex@EX_APPLICATION{tab = tab@(TAB indt), ..} = let single = toSingleLine ex main = withMargin' cfg expr singleMain = toSingleLine main- extra' = displayWidth (last (T.lines (render main))) + 4+ extra' = lastLineWidthAtMost margin main + 4 arg' = withMargin' (2 * indt, margin) argument singleArg = toSingleLine arg' in if- | lengthOf single + extra <= margin -> single- | lengthOf singleMain + extra + 1 <= margin -> EX_APPLICATION singleMain space EOL tab arg' EOL tab' indent- | lengthOf singleArg + extra' <= margin -> EX_APPLICATION main space NO_EOL TAB' singleArg NO_EOL TAB' indent+ | fits extra margin single -> single+ | fits (extra + 1) margin singleMain -> EX_APPLICATION singleMain space EOL tab arg' EOL tab' indent+ | fits extra' margin singleArg -> EX_APPLICATION main space NO_EOL TAB' singleArg NO_EOL TAB' indent | otherwise -> EX_APPLICATION main space EOL tab arg' EOL tab' indent withMargin' _ ex = ex @@ -68,7 +66,7 @@ instance WithMargin APP_ARG where withMargin' cfg@(extra, margin) arg@APP_ARG{..} = let single = toSingleLine arg- in if lengthOf single + extra <= margin then single else APP_ARG (withMargin' cfg expr) (withMargin' cfg args)+ in if fits extra margin single then single else APP_ARG (withMargin' cfg expr) (withMargin' cfg args) instance WithMargin APP_ARGS where withMargin' cfg AAS_EXPR{..} = AAS_EXPR EOL tab (withMargin' cfg expr) (withMargin' cfg args)@@ -97,17 +95,17 @@ let single = toSingleLine pa extra' = extra + lengthOf attr + lengthOf arrow + 2 pa' = PA_TAU attr arrow (withMargin' (extra', margin) expr)- in if lengthOf single + extra <= margin then single else pa'+ in if fits extra margin single then single else pa' withMargin' (extra, margin) pa@PA_ALPHA{..} = let single = toSingleLine pa extra' = extra + lengthOf alpha + lengthOf arrow + 2 pa' = PA_ALPHA alpha arrow (withMargin' (extra', margin) expr)- in if lengthOf single + extra <= margin then single else pa'+ in if fits extra margin single then single else pa' withMargin' (extra, margin) pa@PA_FORMATION{..} = let single = toSingleLine pa extra' = extra + lengthOf attr + lengthOf voids + lengthOf arrow + 4 pa' = PA_FORMATION attr voids arrow (withMargin' (extra', margin) expr)- in if lengthOf single + extra <= margin then single else pa'+ in if fits extra margin single then single else pa' withMargin' _ pa = pa instance WithMargin CONDITION where@@ -119,98 +117,13 @@ lengthOf :: Render a => a -> Int lengthOf renderable = displayWidth (render renderable) -displayWidth :: T.Text -> Int-displayWidth = T.foldl' addWidth 0- where- addWidth :: Int -> Char -> Int- addWidth acc character = acc + charWidth character--charWidth :: Char -> Int-charWidth character- | fromEnum character < 0x300 = 1- | blank = 0- | isWideCodePoint (fromEnum character) = 2- | otherwise = 1+fits :: Render a => Int -> Int -> a -> Bool+fits extra margin node+ | available < 0 = False+ | available >= toInteger (maxBound :: Int) = True+ | otherwise = widthAtMost limit node <= limit where- blank :: Bool- blank = generalCategory character `elem` [NonSpacingMark, EnclosingMark, Format]-- isWideCodePoint :: Int -> Bool- isWideCodePoint codePoint = any (inRange codePoint) wideRanges-- inRange :: Int -> (Int, Int) -> Bool- inRange codePoint (lo, hi) = codePoint >= lo && codePoint <= hi-- wideRanges :: [(Int, Int)]- wideRanges =- [ (0x1100, 0x115F)- , (0x231A, 0x231B)- , (0x2329, 0x232A)- , (0x23E9, 0x23EC)- , (0x23F0, 0x23F0)- , (0x23F3, 0x23F3)- , (0x25FD, 0x25FE)- , (0x2614, 0x2615)- , (0x2648, 0x2653)- , (0x267F, 0x267F)- , (0x2693, 0x2693)- , (0x26A1, 0x26A1)- , (0x26AA, 0x26AB)- , (0x26BD, 0x26BE)- , (0x26C4, 0x26C5)- , (0x26CE, 0x26CE)- , (0x26D4, 0x26D4)- , (0x26EA, 0x26EA)- , (0x26F2, 0x26F3)- , (0x26F5, 0x26F5)- , (0x26FA, 0x26FA)- , (0x26FD, 0x26FD)- , (0x2705, 0x2705)- , (0x270A, 0x270B)- , (0x2728, 0x2728)- , (0x274C, 0x274C)- , (0x274E, 0x274E)- , (0x2753, 0x2755)- , (0x2757, 0x2757)- , (0x2795, 0x2797)- , (0x27B0, 0x27B0)- , (0x27BF, 0x27BF)- , (0x2B1B, 0x2B1C)- , (0x2B50, 0x2B50)- , (0x2B55, 0x2B55)- , (0x2E80, 0x303E)- , (0x3041, 0x33FF)- , (0x3400, 0x4DBF)- , (0x4E00, 0x9FFF)- , (0xA000, 0xA4CF)- , (0xA960, 0xA97C)- , (0xAC00, 0xD7A3)- , (0xF900, 0xFAFF)- , (0xFE10, 0xFE19)- , (0xFE30, 0xFE4F)- , (0xFE50, 0xFE52)- , (0xFE54, 0xFE66)- , (0xFE68, 0xFE6B)- , (0xFF00, 0xFF60)- , (0xFFE0, 0xFFE6)- , (0x16FE0, 0x16FE4)- , (0x16FF0, 0x16FF1)- , (0x17000, 0x187F7)- , (0x18800, 0x18CD5)- , (0x18D00, 0x18D08)- , (0x1B000, 0x1B11E)- , (0x1B150, 0x1B152)- , (0x1B164, 0x1B167)- , (0x1B170, 0x1B2FB)- , (0x1F004, 0x1F004)- , (0x1F0CF, 0x1F0CF)- , (0x1F18E, 0x1F18E)- , (0x1F191, 0x1F19A)- , (0x1F200, 0x1F202)- , (0x1F210, 0x1F23B)- , (0x1F240, 0x1F248)- , (0x1F250, 0x1F251)- , (0x1F260, 0x1F265)- , (0x1F300, 0x1FAFF)- , (0x20000, 0x3FFFD)- ]+ available :: Integer+ available = toInteger margin - toInteger extra+ limit :: Int+ limit = fromInteger available
src/Morph.hs view
@@ -11,7 +11,7 @@ -- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com -- SPDX-License-Identifier: MIT -module Morph (Answer (..), Budget (..), Deadline (..), Firing (..), Facts, Kept (..), ReduceContext (..), ReduceException (..), EvaluationFunc, Memo (..), ReductionFunc, Morphed, Steps (..), Tally (..), admitting, argued, awaited, called, carried, charged, coined, counted, declared, deeper, emptyState, ended, enter, execBuildTerm, expired, fired, inferred, insideUniverse, isLambda, lambda, leadsTo, factual, memoized, morph, noted, remembering, morph', morphing, normalized, onward, opening, parking, recalled, refused, remember, remembered, repeats, retained, settled, severing, starved, tallied, timed, universed, unparked, vetted, voided) where+module Morph (Answer (..), Budget (..), Deadline (..), Firing (..), Facts, Kept (..), ReduceContext (..), ReduceException (..), EvaluationFunc, Memo (..), Kindred, ReductionFunc, adopted, kindle, kindred, minting, placed, Morphed, Steps (..), Tally (..), admitting, argued, awaited, called, carried, charged, coined, counted, declared, deeper, emptyState, ended, enter, execBuildTerm, expired, fired, inferred, insideUniverse, isLambda, lambda, leadsTo, factual, memoized, morph, noted, remembering, morph', morphing, normalized, onward, opening, parking, recalled, refused, remember, remembered, repeats, retained, settled, severing, starved, tallied, timed, universed, unparked, vetted, voided) where import AST import Builder (buildExpressionThrows, nameIn)@@ -19,6 +19,7 @@ import Control.Exception (Exception, catch, evaluate, throwIO, try) import Control.Monad (forM_, guard, unless, when) import Data.Bifunctor (first, second)+import Data.Either (lefts) import Data.IORef (IORef, atomicModifyIORef', modifyIORef', newIORef, readIORef, writeIORef) import Data.List (find, partition, sortOn) import qualified Data.List as List@@ -33,7 +34,7 @@ import GHC.Clock (getMonotonicTime) import GHC.Stats (GCDetails (..), RTSStats (..), getRTSStats, getRTSStatsEnabled) import qualified Inference as In-import Lambdas (Lambdas, thrown)+import Lambdas (Lambdas, stayed, thrown) import Locator (locatedExpression, withLocatedExpression) import Matcher (substEmpty) import Must (Must (..))@@ -41,6 +42,7 @@ import Random (shuffle) import Rewriter (RewriteContext (RewriteContext), Rewritten, Seen, rewrite, seenInsert) import Rule (RuleContext (RuleContext), xiFree)+import Sides (Sides, minted, named, opened, resolver, spelled) import System.Timeout (timeout) import Text.Printf (printf) import Yaml (ExtraArgument (..))@@ -69,8 +71,16 @@ , _until :: Double } -data Memo = Memo (IORef (Store (Int, Kept))) (IORef (Map.Map Firing (Expression, Answer))) (IORef Int) (IORef Int)+data Memo = Memo (IORef (Store (Int, Kept))) (IORef (Map.Map Firing (Expression, Answer))) (IORef Int) (IORef Int) Kin +data Kin = Kin (IORef Spots) (IORef (Map.Map Int [Kindred])) (IORef (Map.Map Int Firing))++data Spots = Spots (Store Int) (Map.Map Int Expression)++data Kindred = Kindred Expression Expression Firing Answer++data Renaming = Renaming (IORef (Map.Map Int Int)) Spots (IORef (Set.Set Firing))+ data Answer = Answer Expression Expression | Joined Expression@@ -108,6 +118,7 @@ , _steps :: Steps , _tally :: Maybe Tally , _minted :: IORef Int+ , _sides :: Sides , _deadline :: Maybe Deadline , _memo :: Maybe Memo , _nesting :: Int@@ -124,6 +135,7 @@ , _symbolic :: Lambdas , _raising :: [T.Text] , _reckoning :: Bool+ , _working :: Maybe Expression , _buildTerm :: BuildTermFunc , _reduce :: ReductionFunc , _evaluate :: EvaluationFunc@@ -189,7 +201,7 @@ where starve :: Maybe Memo -> IO () starve Nothing = pure ()- starve (Just (Memo _ _ _ exhausted)) = modifyIORef' exhausted (+ 1)+ starve (Just (Memo _ _ _ exhausted _)) = modifyIORef' exhausted (+ 1) measured :: ReduceContext -> Expression -> IO () measured ctx term = do@@ -246,12 +258,12 @@ maybe (expired ctx cap) pure =<< timeout (ceiling (max 0 (due - now) * 1000000)) action memoized :: Maybe Acyclic -> IO (Maybe Memo)-memoized (Just Plausible) = Just <$> (Memo <$> newIORef Map.empty <*> newIORef Map.empty <*> newIORef 0 <*> newIORef 0)+memoized (Just Plausible) = Just <$> (Memo <$> newIORef Map.empty <*> newIORef Map.empty <*> newIORef 0 <*> newIORef 0 <*> (Kin <$> newIORef (Spots Map.empty Map.empty) <*> newIORef Map.empty <*> newIORef Map.empty)) memoized _ = pure Nothing recalled :: Maybe Memo -> Expression -> Int -> IO (Maybe Kept) recalled Nothing _ _ = pure Nothing-recalled (Just (Memo store _ answers _)) form spent = do+recalled (Just (Memo store _ answers _ _)) form spent = do kept <- readIORef store count <- readIORef answers let live = [known | (term, (stamp, known)) <- Map.findWithDefault [] (hashExpression form) kept, term == form, current count stamp known]@@ -266,27 +278,223 @@ counted :: Maybe Memo -> IO Int counted Nothing = pure 0-counted (Just (Memo _ _ answers _)) = readIORef answers+counted (Just (Memo _ _ answers _ _)) = readIORef answers starved :: Maybe Memo -> IO Int starved Nothing = pure 0-starved (Just (Memo _ _ _ exhausted)) = readIORef exhausted+starved (Just (Memo _ _ _ exhausted _)) = readIORef exhausted retained :: Maybe Memo -> Expression -> Int -> Kept -> IO () retained Nothing _ _ _ = pure ()-retained (Just (Memo store _ _ _)) form stamp kept =+retained (Just (Memo store _ _ _ _)) form stamp kept = modifyIORef' store (Map.insertWith (++) (hashExpression form) [(form, (stamp, kept))]) remembered :: Maybe Memo -> Firing -> IO (Maybe (Expression, Answer)) remembered Nothing _ = pure Nothing-remembered (Just (Memo _ firings _ _)) firing = Map.lookup firing <$> readIORef firings+remembered (Just (Memo _ firings _ _ _)) firing = Map.lookup firing <$> readIORef firings remember :: Maybe Memo -> Firing -> Expression -> Answer -> IO () remember Nothing _ _ _ = pure ()-remember (Just (Memo _ firings answers _)) firing form answer = do+remember (Just (Memo _ firings answers _ _)) firing form answer = do modifyIORef' firings (Map.insert firing (form, answer)) modifyIORef' answers (+ 1) +placed :: Maybe Memo -> Expression -> Int -> IO ()+placed (Just (Memo _ _ _ _ (Kin places _ _))) term idx+ | not (bare term) = modifyIORef' places (\spots -> List.foldl' spot spots (List.nub [term, stayed term]))+ where+ spot :: Spots -> Expression -> Spots+ spot spots@(Spots known spelt) spelling = maybe (Spots (Map.insertWith (++) (hashExpression spelling) [(spelling, idx)] known) (Map.insertWith (\_ old -> old) idx spelling spelt)) (const spots) (spotted spots spelling)+ bare :: Expression -> Bool+ bare (ExFormation [BiLambda (FnSymbol _)]) = True+ bare _ = False+placed _ _ _ = pure ()++spotted :: Spots -> Expression -> Maybe Int+spotted (Spots known _) term = lookup term (Map.findWithDefault [] (hashExpression term) known)++abstracted :: Sides -> Spots -> Expression -> IO (Expression, [(Int, Expression)])+abstracted store spots form = do+ cache <- newIORef Map.empty+ goExpr cache form+ where+ goExpr :: IORef (Map.Map T.Text (Expression, [(Int, Expression)])) -> Expression -> IO (Expression, [(Int, Expression)])+ goExpr cache term = maybe (nested cache term) (\idx -> pure (ExFormation [BiLambda (FnSymbol idx)], [(idx, term)])) (spotted spots term)+ nested :: IORef (Map.Map T.Text (Expression, [(Int, Expression)])) -> Expression -> IO (Expression, [(Int, Expression)])+ nested cache term@(ExMeta name)+ | isName name = do+ done <- readIORef cache+ case Map.lookup name done of+ Just again -> pure again+ Nothing -> do+ side <- opened store term+ made <-+ if side == term+ then pure (term, [])+ else do+ (side', posed) <- goExpr cache side+ if side' == side then pure (term, posed) else (,posed) <$> named store side'+ made <$ modifyIORef' cache (Map.insert name made)+ nested cache term@(ExFormation bds) = do+ parts <- mapM (goBinding cache) bds+ pure (intact bds term ExFormation (map fst parts), concatMap snd parts)+ nested cache term@(ExApplication expr arg) = do+ (expr', one) <- goExpr cache expr+ (arg', two) <- goArgument cache arg+ pure (intact (expr, arg) term (uncurry ExApplication) (expr', arg'), one ++ two)+ nested cache term@(ExDispatch expr attr) = first (intact expr term (`ExDispatch` attr)) <$> goExpr cache expr+ nested _ term = pure (term, [])+ goBinding :: IORef (Map.Map T.Text (Expression, [(Int, Expression)])) -> Binding -> IO (Binding, [(Int, Expression)])+ goBinding cache bd@(BiTau attr expr) = first (intact expr bd (BiTau attr)) <$> goExpr cache expr+ goBinding _ bd = pure (bd, [])+ goArgument :: IORef (Map.Map T.Text (Expression, [(Int, Expression)])) -> Argument -> IO (Argument, [(Int, Expression)])+ goArgument cache arg@(ArTau attr expr) = first (intact expr arg (ArTau attr)) <$> goExpr cache expr+ goArgument cache arg@(ArAlpha alpha expr) = first (intact expr arg (ArAlpha alpha)) <$> goExpr cache expr++kindle :: Sides -> Maybe Memo -> Expression -> Firing -> Answer -> IO ()+kindle store (Just (Memo _ _ _ _ (Kin places likes _))) form firing answer = do+ spots <- readIORef places+ key <- fst <$> abstracted store spots form+ modifyIORef' likes (Map.insertWith (++) (hashShape key) [Kindred key form firing answer])+kindle _ _ _ _ _ = pure ()++minting :: Maybe Memo -> Firing -> Answer -> IO ()+minting (Just (Memo _ _ _ _ (Kin _ _ minters))) firing@(Firing _ operands normals) answer =+ modifyIORef' minters (\known -> List.foldl' (\held idx -> Map.insertWith (\_ old -> old) idx firing held) known [idx | idx <- answered answer, idx `notElem` inputs])+ where+ inputs :: [Int]+ inputs = lefts operands ++ concatMap symbols normals+minting _ _ _ = pure ()++answered :: Answer -> [Int]+answered (Answer built normal) = List.nub (symbols built ++ symbols normal)+answered (Joined normal) = List.nub (symbols normal)+answered Raised = []++kindred :: ReduceContext -> Expression -> IO (Maybe (Kindred, Map.Map Int Int, [(Int, Expression)]))+kindred ctx@ReduceContext{_memo = Just (Memo _ _ _ _ (Kin places likes _))} form = do+ spots <- readIORef places+ known <- readIORef likes+ (key, posed) <- abstracted ctx._sides spots form+ look <- resolver ctx._sides+ let found = listToMaybe [(kin, pairing, posed) | kin@(Kindred before _ _ _) <- Map.findWithDefault [] (hashShape key) known, Just pairing <- [bijection' look before key]]+ awaited ctx (evaluate (isJust found `seq` found))+kindred _ _ = pure Nothing++adopted :: ReduceContext -> (Kindred, Map.Map Int Int, [(Int, Expression)]) -> Expression -> IO Answer+adopted ctx@ReduceContext{_memo = Just (Memo _ _ _ _ (Kin places _ _))} (Kindred key form firing answer, pairing, posed) target = do+ table <- newIORef pairing+ visiting <- newIORef Set.empty+ Spots known _ <- readIORef places+ adopt ctx (Renaming table (Spots known (Map.fromList [(idx, fromMaybe (ExFormation [BiLambda (FnSymbol idx')]) (lookup idx' posed)) | idx <- symbols key, Just idx' <- [Map.lookup idx pairing]])) visiting) firing key form answer (Just target)+adopted _ _ _ = throwIO (userError "A renamed answer needs the memo of --acyclic=plausible")++adopt :: ReduceContext -> Renaming -> Firing -> Expression -> Expression -> Answer -> Maybe Expression -> IO Answer+adopt ctx renaming@(Renaming table _ visiting) firing key form answer target = do+ modifyIORef' visiting (Set.insert firing)+ firing' <- refired ctx renaming firing+ existing <- remembered ctx._memo firing'+ look <- resolver ctx._sides+ case existing >>= \(first', answer') -> (first',answer',) <$> bijection' look (ended answer) (ended answer') of+ Just (first', answer', pairing) -> do+ modifyIORef' table (`Map.union` pairing)+ forM_ target $ \form' -> do+ ctx._saveEval (EvRecalled (ctx._nesting + 1) first' (ended answer'))+ stamp <- counted ctx._memo+ retained ctx._memo form' stamp (Answered answer')+ ctx._saveEval (EvMemoized (ctx._nesting + 1) form' (ended answer'))+ pure answer'+ Nothing -> do+ minters <- held ctx._memo+ let own = [idx | idx <- answered answer, Map.lookup idx minters == Just firing]+ known <- readIORef table+ forM_ [idx | idx <- own, Map.notMember idx known] $ \idx -> do+ fresh <- coined ctx+ modifyIORef' table (Map.insert idx fresh)+ answer' <- reanswered answer+ form' <- maybe (renamedTerm ctx renaming form) pure target+ remember ctx._memo firing' form' answer'+ table' <- readIORef table+ minted' ctx._memo firing' [fresh | idx <- own, Just fresh <- [Map.lookup idx table']]+ stamp <- counted ctx._memo+ retained ctx._memo form' stamp (Answered answer')+ ctx._saveEval (EvRenamed (ctx._nesting + 1) form' (ended answer') form [(idx, idx') | idx <- List.nub (symbols key ++ answered answer), Just idx' <- [Map.lookup idx table'], idx' /= idx])+ pure answer'+ where+ reanswered :: Answer -> IO Answer+ reanswered (Answer built normal) = Answer <$> renamedTerm ctx renaming built <*> renamedTerm ctx renaming normal+ reanswered (Joined normal) = Joined <$> renamedTerm ctx renaming normal+ reanswered Raised = pure Raised+ held :: Maybe Memo -> IO (Map.Map Int Firing)+ held (Just (Memo _ _ _ _ (Kin _ _ minters))) = readIORef minters+ held Nothing = pure Map.empty+ minted' :: Maybe Memo -> Firing -> [Int] -> IO ()+ minted' (Just (Memo _ _ _ _ (Kin _ _ minters))) firing' fresh = modifyIORef' minters (\known -> List.foldl' (\kept idx -> Map.insert idx firing' kept) known fresh)+ minted' Nothing _ _ = pure ()++refired :: ReduceContext -> Renaming -> Firing -> IO Firing+refired ctx renaming (Firing func operands normals) = Firing func <$> mapM operand operands <*> mapM (renamedTerm ctx renaming) normals+ where+ operand :: Either Int Bytes -> IO (Either Int Bytes)+ operand (Left idx) = Left <$> renamedSymbol ctx renaming idx+ operand bytes = pure bytes++renamedTerm :: ReduceContext -> Renaming -> Expression -> IO Expression+renamedTerm ctx renaming@(Renaming _ spots@(Spots _ spelt) _) term = do+ renamed <- newIORef Map.empty+ goExpr renamed term+ where+ goExpr :: IORef (Map.Map T.Text Expression) -> Expression -> IO Expression+ goExpr renamed expr = maybe (nested renamed expr) (spot renamed expr) (spotted spots expr)+ spot :: IORef (Map.Map T.Text Expression) -> Expression -> Int -> IO Expression+ spot renamed expr idx = maybe (nested renamed expr) pure (Map.lookup idx spelt)+ nested :: IORef (Map.Map T.Text Expression) -> Expression -> IO Expression+ nested renamed expr@(ExMeta name)+ | isName name = do+ done <- readIORef renamed+ case Map.lookup name done of+ Just again -> pure again+ Nothing -> do+ side <- opened ctx._sides expr+ made <- if side == expr then pure expr else named ctx._sides =<< goExpr renamed side+ made <$ modifyIORef' renamed (Map.insert name made)+ nested renamed expr = walked renamed expr+ walked :: IORef (Map.Map T.Text Expression) -> Expression -> IO Expression+ walked renamed whole@(ExFormation bds) = intact bds whole ExFormation <$> suffixed (goBinding renamed) bds+ walked renamed whole@(ExApplication expr arg) = intact (expr, arg) whole (uncurry ExApplication) <$> ((,) <$> goExpr renamed expr <*> goArgument renamed arg)+ walked renamed whole@(ExDispatch expr attr) = intact expr whole (`ExDispatch` attr) <$> goExpr renamed expr+ walked _ expr = pure expr+ goBinding :: IORef (Map.Map T.Text Expression) -> Binding -> IO Binding+ goBinding renamed bd@(BiTau attr expr) = intact expr bd (BiTau attr) <$> goExpr renamed expr+ goBinding _ (BiLambda (FnSymbol idx)) = BiLambda . FnSymbol <$> renamedSymbol ctx renaming idx+ goBinding _ bd = pure bd+ goArgument :: IORef (Map.Map T.Text Expression) -> Argument -> IO Argument+ goArgument renamed arg@(ArTau attr expr) = intact expr arg (ArTau attr) <$> goExpr renamed expr+ goArgument renamed arg@(ArAlpha alpha expr) = intact expr arg (ArAlpha alpha) <$> goExpr renamed expr++renamedSymbol :: ReduceContext -> Renaming -> Int -> IO Int+renamedSymbol ctx renaming@(Renaming table _ visiting) idx = do+ known <- readIORef table+ maybe unknown pure (Map.lookup idx known)+ where+ unknown :: IO Int+ unknown = do+ minter <- case ctx._memo of+ Just (Memo _ _ _ _ (Kin _ _ minters)) -> Map.lookup idx <$> readIORef minters+ Nothing -> pure Nothing+ seen <- readIORef visiting+ case minter of+ Just firing | Set.notMember firing seen -> do+ kept <- remembered ctx._memo firing+ forM_ kept (\(form, answer) -> adopt ctx renaming firing form form answer Nothing)+ maybe fresh pure . Map.lookup idx =<< readIORef table+ Just _ -> fresh+ Nothing -> idx <$ modifyIORef' table (Map.insert idx idx)+ fresh :: IO Int+ fresh = do+ made <- coined ctx+ made <$ modifyIORef' table (Map.insert idx made)+ parking :: NonEmpty Rewritten -> State -> IO a -> IO a parking seq state action = action `catch` rethrow where@@ -335,9 +543,8 @@ severed :: Maybe Attribute -> Expression -> ReduceContext -> State -> Expression -> [Binding] -> (Acyclic, Expression) -> IO Expression severed taken univ ctx state form bds (mode, before) = do- call <- awaited ctx (evaluate =<< ((<|>) <$> traced ctx._facts form <*> traced ctx._facts before))- forM_ call (recited ctx . snd)- reckoned <- traverse (spelled taken . fst) call+ call <- tracing ctx form before+ reckoned <- traverse (spelled taken) call fresh <- coined ctx ctx._saveEval (EvLooped ctx._nesting ctx._judgment mode before ctx._site (Just (fresh, reckoned))) pure (ExFormation [BiLambda (FnSymbol fresh)])@@ -348,6 +555,17 @@ | ctx._reckoning = pure found | otherwise = argued univ ctx{_reckoning = True} state form bds found +passing :: ReduceContext -> Expression -> (Acyclic, Expression) -> IO ()+passing ctx form (mode, before) = do+ call <- tracing ctx form before+ ctx._saveEval (EvPassed ctx._nesting ctx._judgment mode before ctx._site form call)++tracing :: ReduceContext -> Expression -> Expression -> IO (Maybe Expression)+tracing ctx form before = do+ call <- awaited ctx (evaluate =<< ((<|>) <$> traced ctx._facts form <*> traced ctx._facts before))+ forM_ call (recited ctx . snd)+ pure (fst <$> call)+ recited :: ReduceContext -> [(Expression, Expression)] -> IO () recited ctx = mapM_ (\(term, source) -> ctx._saveEval (EvRecalled ctx._nesting term source)) @@ -536,15 +754,16 @@ remembered mode = maybe (Right ctx{_entered = seenInsert (digest mode form) form ctx._entered}) (\before -> Left (mode, before)) . listToMaybe . drop ctx._maxLoops <$> repeats mode form ctx repeats :: Acyclic -> Expression -> ReduceContext -> IO [Expression]-repeats mode form ctx = awaited ctx (evaluate (length hits `seq` hits))+repeats mode form ctx = do+ look <- resolver ctx._sides+ let hits = take (succ ctx._maxLoops) (filter (repeated look mode) (Map.findWithDefault [] (digest mode form) ctx._entered))+ awaited ctx (evaluate (length hits `seq` hits)) where- hits :: [Expression]- hits = take (succ ctx._maxLoops) (filter (repeated mode) (Map.findWithDefault [] (digest mode form) ctx._entered))- repeated :: Acyclic -> Expression -> Bool- repeated Proven before = alike form before- repeated Plausible before- | atomic form = akin before form- | otherwise = within before form+ repeated :: (T.Text -> Maybe Expression) -> Acyclic -> Expression -> Bool+ repeated look Proven before = alike' look form before+ repeated look Plausible before+ | atomic form = akin' look before form+ | otherwise = within' look before form atomic :: Expression -> Bool atomic (ExFormation bds) = any isLambda bds atomic _ = False@@ -557,7 +776,7 @@ entrance Dataization term@(ExFormation bds) | boxed bds || isJust (lambda bds) = Just term entrance Morphing (ExDispatch form@(ExFormation bds) _)- | isJust (lambda bds) = Just form+ | isJust (lambda bds) || boxed bds = Just form entrance Evaluation term@(ExFormation bds) | isJust (lambda bds) = Just term entrance _ _ = Nothing@@ -578,6 +797,10 @@ morph'' owner start univ state entry = go start univ state entry where go :: Morphed -> Expression -> State -> ReduceContext -> IO (Morphed, State)+ go (expr@(ExMeta name), seq) univ state caller+ | isName name = do+ side <- opened caller._sides expr+ if side == expr then throwIO (Unmorphable expr) else go (side, seq) univ state caller go (expr, seq) univ state caller = do (term, entered) <- severing expr univ state =<< parking seq state (universed univ caller{_judgment = Morphing}) ctx <- opening Morphing =<< deeper entered@@ -612,7 +835,7 @@ reduced expr ctx = do result <- try (morph' (expr, (universe, Nothing) :| []) universe state ctx) case result of- Right ((morphed, seq), state') -> pure (morphed, reverse (NE.toList seq), state')+ Right ((morphed, seq), state') -> (,reverse (NE.toList seq),state') <$> spelled _sides morphed Left (StuckAt func seq parked) | _partial -> residue seq parked{_stuck = Just func} Left (OutOfStepsAt _ seq parked) | _partial -> residue seq parked Left (OutOfSteps _) | _partial -> pure (expr, [(universe, Nothing)], state)@@ -620,7 +843,7 @@ Left failure -> throwIO (failure :: ReduceException) residue :: NonEmpty Rewritten -> State -> IO (Expression, [Rewritten], State) residue seq parked = do- expr <- locatedExpression _locator (fst (NE.head seq))+ expr <- spelled _sides =<< locatedExpression _locator (fst (NE.head seq)) pure (expr, reverse (NE.toList seq), parked) vetted :: Judgment -> Expression -> ReduceContext -> IO ()@@ -634,14 +857,14 @@ where go :: [In.Inference value] -> IO (Maybe (In.Premises value)) go [] = pure Nothing- go (rule : rest) = rule (RuleContext (execBuildTerm univ ctx) (Just univ) ctx._engine._normal) expr univ >>= maybe (go rest) (pure . Just)+ go (rule : rest) = rule (RuleContext (execBuildTerm univ ctx) (Just univ) ctx._engine._normal False) expr univ >>= maybe (go rest) (pure . Just) premised :: State -> In.Premises value -> IO (In.Conclusion value, State) premised state' (In.Concludes conclusion) = pure (conclusion, state') premised state' (In.Morphs term world next) = do (morphed, state'') <- detached term world state' ctx next morphed >>= premised state'' premised state' (In.Evaluates form world next) = do- (answer, state'') <- ctx._evaluate ctx state' form world+ (answer, state'') <- ctx._evaluate ctx{_working = Just expr} state' form world next answer >>= premised state'' premised state' (In.Contextualizes term context next) = ctx._engine._contextualize term context >>= next >>= premised state' @@ -649,7 +872,8 @@ onward seq state (In.Taken step) _ expr ctx = do seq' <- leadsTo seq step expr ctx pure ((expr, seq'), state)-onward seq state (In.Normalized step) univ expr ctx = do+onward seq state (In.Normalized step) univ expr' ctx = do+ expr <- shared ctx expr' labelled <- leadsTo seq step expr ctx normal@(term, _) <- normalized expr labelled ctx unless (term `elem` [expr, bare expr]) (ctx._saveEval (EvNormalized ctx._nesting (rooted expr) term))@@ -669,6 +893,62 @@ Nothing -> onward seq state (In.Normalized step) univ expr ctx onward seq state (In.Staged stage) _ expr ctx = morph' (expr, seq) stage state ctx +shared :: ReduceContext -> Expression -> IO Expression+shared ctx = go+ where+ go :: Expression -> IO Expression+ go term@(ExApplication head' arg) = do+ head'' <- go head'+ arg' <- goArgument arg+ pure (if head'' == head' && arg' == arg then term else ExApplication head'' arg')+ go term@(ExDispatch inner attr) = do+ inner' <- go inner+ pure (if inner' == inner then term else ExDispatch inner' attr)+ go term = pure term+ goArgument :: Argument -> IO Argument+ goArgument arg@(ArTau AtRho _) = pure arg+ goArgument arg@(ArTau attr expr) = intact expr arg (ArTau attr) <$> (goValue =<< go expr)+ goArgument arg@(ArAlpha alpha expr) = intact expr arg (ArAlpha alpha) <$> (goValue =<< go expr)+ goValue :: Expression -> IO Expression+ goValue value@(ExMeta _) = pure value+ goValue value@(ExApplication inner (ArTau AtRho _))+ | closed value && growing value = do+ look <- resolver ctx._sides+ if dispatching look inner then goValue inner else kept value+ goValue value = kept value+ dispatching :: (T.Text -> Maybe Expression) -> Expression -> Bool+ dispatching _ (ExDispatch _ _) = True+ dispatching look (ExApplication inner _) = dispatching look inner+ dispatching look (ExMeta name) = maybe False (dispatching look) (look name)+ dispatching _ _ = False+ kept :: Expression -> IO Expression+ kept value+ | closed value && growing value = do+ (name, fresh) <- minted ctx._sides value+ when fresh (ctx._saveEval (EvShared ctx._nesting name value))+ pure name+ | otherwise = pure value+ growing :: Expression -> Bool+ growing (ExMeta _) = True+ growing (ExDispatch inner _) = not (path inner) || growing inner+ growing (ExApplication inner (ArTau _ arg)) = growing inner || growing arg+ growing (ExApplication inner (ArAlpha _ arg)) = growing inner || growing arg+ growing _ = False+ path :: Expression -> Bool+ path (ExDispatch inner _) = path inner+ path ExRoot = True+ path _ = False+ closed :: Expression -> Bool+ closed (ExApplication inner (ArTau _ arg)) = closed inner && closed arg+ closed (ExApplication inner (ArAlpha _ arg)) = closed inner && closed arg+ closed (ExDispatch inner _) = closed inner+ closed (ExFormation _) = True+ closed ExRoot = True+ closed (ExBytes _) = True+ closed ExTermination = True+ closed (ExMeta name) = isName name+ closed _ = False+ leadsTo :: NonEmpty Rewritten -> (Judgment, String) -> Expression -> ReduceContext -> IO (NonEmpty Rewritten) leadsTo ((current, _) :| rest) rule expr ReduceContext{..} = do updated <- withLocatedExpression _locator expr current@@ -677,22 +957,32 @@ normalized :: Expression -> NonEmpty Rewritten -> ReduceContext -> IO (Expression, NonEmpty Rewritten) normalized expr seq ctx@ReduceContext{..} = do measured ctx expr- whole <- withLocatedExpression _locator expr (fst (NE.head seq)) taken <- newIORef Map.empty peeled <- newIORef Map.empty copies <- newIORef Map.empty- (rewrittens, exceeded) <- rewrite whole _engine._normalization (rewriteContext taken peeled copies ctx)- when exceeded $ do- _saveEval (EvExceeded _nesting _maxCycles _judgment _site)- throwIO (OutOfSteps (Cycles _maxCycles))- let (rw :| rws) = NE.reverse rewrittens- seq' = rw :| rws <> NE.tail seq- expr' <- locatedExpression _locator (fst rw)- pure (expr', seq')+ go taken peeled copies expr seq where+ go :: IORef (Store Expression) -> IORef (Store Expression) -> IORef (Store Expression) -> Expression -> NonEmpty Rewritten -> IO (Expression, NonEmpty Rewritten)+ go taken peeled copies term chain = do+ whole <- withLocatedExpression _locator term (fst (NE.head chain))+ (rewrittens, exceeded) <- rewrite whole _engine._normalization (rewriteContext taken peeled copies ctx)+ when exceeded $ do+ _saveEval (EvExceeded _nesting _maxCycles _judgment _site)+ throwIO (OutOfSteps (Cycles _maxCycles))+ let (rw :| rws) = NE.reverse rewrittens+ chain' = rw :| rws <> NE.tail chain+ term' <- locatedExpression _locator (fst rw)+ look <- resolver _sides+ let unfolded = spined look False term'+ if unfolded == term' then pure (term', chain') else go taken peeled copies unfolded chain'+ spined :: (T.Text -> Maybe Expression) -> Bool -> Expression -> Expression+ spined look _ (ExDispatch term attr) = ExDispatch (spined look True term) attr+ spined look _ (ExApplication term arg) = ExApplication (spined look True term) arg+ spined look True term@(ExMeta name) = fromMaybe term (look name)+ spined _ _ term = term rewriteContext :: IORef (Store Expression) -> IORef (Store Expression) -> IORef (Store Expression) -> ReduceContext -> RewriteContext rewriteContext taken peeled copies whole@ReduceContext{..} =- RewriteContext _locator _maxDepth _maxCycles _depthSensitive _universe _buildTerm _engine._normal _engine._matching MtDisabled Nothing (\term -> (measured whole =<< locatedExpression _locator term) >> _saveStep term) (made taken peeled copies whole)+ RewriteContext _locator _maxDepth _maxCycles _depthSensitive _universe _buildTerm _engine._normal _engine._matching MtDisabled Nothing (\term -> clocked whole >> (measured whole =<< locatedExpression _locator term) >> _saveStep term) (made taken peeled copies whole) made :: IORef (Store Expression) -> IORef (Store Expression) -> IORef (Store Expression) -> ReduceContext -> Expression -> Expression -> IO () made _ _ copies whole redex@(ExApplication head' (ArTau attr _)) object@(ExFormation bds) | attr /= AtRho && object /= head' = do@@ -726,6 +1016,14 @@ | copied bds = sourced peeled whole redex >>= mapM_ (\path -> modifyIORef' taken (Map.insertWith (++) (hashExpression object) [(object, path)])) dispatched _ peeled whole redex object@(ExFormation bds) | copied bds = sourced peeled whole redex >>= mapM_ (noted whole object)+ dispatched taken peeled whole redex (ExApplication name@(ExMeta _) rho@(ArTau AtRho _)) = do+ side <- opened whole._sides name+ case side of+ ExFormation bds+ | copied bds && side /= name ->+ let object = ExApplication side rho+ in sourced peeled whole redex >>= mapM_ (\path -> modifyIORef' taken (Map.insertWith (++) (hashExpression object) [(object, path)]))+ _ -> pure () dispatched _ _ _ _ _ = pure () sourced :: IORef (Store Expression) -> ReduceContext -> Expression -> IO (Maybe Expression) sourced peeled whole redex@(ExDispatch target attr) = case worldly whole._universe redex of@@ -787,19 +1085,16 @@ unparked $ do opened <- opening Morphing =<< universed universe aiming ((morphed, _), state') <- morph' (normal, (universe, Nothing) :| []) universe state{_copies = []} opened- recurring morphed universe state'{_copies = state._copies ++ state'._copies} opened+ recurring morphed state'{_copies = state._copies ++ state'._copies} opened where- recurring :: Expression -> Expression -> State -> ReduceContext -> IO (Expression, State)- recurring term@(ExFormation bds) world state' opened+ recurring :: Expression -> State -> ReduceContext -> IO (Expression, State)+ recurring term@(ExFormation bds) state' opened | Just mode <- opened._acyclic , boxed bds = do hits <- repeats mode term opened- case drop opened._maxLoops hits of- before : _ -> (,state') <$> severed Nothing world opened state' term bds (mode, before)- []- | null hits -> pure (term, state')- | otherwise -> pure (term, state'{_copies = state'._copies ++ [term]})- recurring term _ state' _ = pure (term, state')+ forM_ (listToMaybe (drop opened._maxLoops hits)) (passing opened term . (mode,))+ pure (term, if null hits then state' else state'{_copies = state'._copies ++ [term]})+ recurring term state' _ = pure (term, state') carried :: State -> ReduceContext -> (State, ReduceContext) carried state ctx = (state{_copies = []}, maybe ctx (\mode -> ctx{_entered = foldr (\form -> seenInsert (digest mode form) form) ctx._entered state._copies}) ctx._acyclic)
src/Parser.hs view
@@ -27,7 +27,7 @@ import AST import Bytes (nonFiniteBts, nonFiniteOf, numToBts, strToBts) import Control.Exception (Exception)-import Control.Monad (guard, when)+import Control.Monad (void, when) import Control.Monad.Trans.State.Strict (StateT, evalStateT, get, put) import Data.Char (isAsciiLower, isAsciiUpper, isDigit) import Data.Scientific (scientific, toRealFloat)@@ -500,16 +500,10 @@ _ <- symbol "." ExDispatch expr <$> attribute , do- guard- ( case expr of- ExXi -> False- ExRoot -> False- _ -> True- ) _ <- symbol "(" bds <- choice- [ try $ argument `sepBy1` symbol ","+ [ lookAhead (try named) >> argument `sepBy1` symbol "," , do exprs <- expression `sepBy1` symbol "," return (zipWith (ArAlpha . Alpha) [0 ..] exprs)@@ -524,6 +518,9 @@ exTail next , return expr ]+ where+ named :: Parser String+ named = choice [void (try alpha), void attribute] >> arrow expression :: Parser Expression expression = do
src/Regexp.hs view
@@ -14,6 +14,13 @@ data Regex = Regex R.Regex R.Regex +newtype RegexExecutionException = RegexExecutionException String++instance Show RegexExecutionException where+ show (RegexExecutionException err) = "Regex execution failed: " ++ err++instance Exception RegexExecutionException+ compile :: B.ByteString -> IO Regex compile pat = do first <- compileWith R.execBlank@@ -21,7 +28,7 @@ pure (Regex first continuation) where compileWith option = do- compiled <- R.compile R.compUTF8 option (B.pack "(*UCP)" `B.append` pat)+ compiled <- R.compile R.compUTF8 option (B.pack "(*UCP)(*LIMIT_MATCH=1000000)(*LIMIT_RECURSION=256)" `B.append` pat) case compiled of Left (_, err) -> throwIO (userError ("Regex compilation failed: " ++ err)) Right regex -> pure regex@@ -133,4 +140,4 @@ isContinuation byte = ord byte >= 0x80 && ord byte < 0xC0 regexExecutionFailed :: Show err => err -> IO value-regexExecutionFailed err = throwIO (userError ("Regex execution failed: " ++ show err))+regexExecutionFailed err = throwIO (RegexExecutionException (show err))
src/Render.hs view
@@ -6,18 +6,68 @@ -- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com -- SPDX-License-Identifier: MIT -module Render where+module Render (Render (..), Rendering, union, displayWidth, lastLineWidthAtMost, widthAtMost) where import Bytes (nonFiniteName) import CST+import Data.Char (GeneralCategory (..), generalCategory)+import Data.List (intersperse)+import Data.String (IsString (..)) import Data.Text (Text) import qualified Data.Text as T-import qualified Data.Text.Lazy as TL-import qualified Data.Text.Lazy.Builder as TLB +data Rendering = Rendering+ { forwards :: [Text] -> [Text]+ , backwards :: [Text] -> [Text]+ }++instance Semigroup Rendering where+ left <> right = Rendering (forwards left . forwards right) (backwards right . backwards left)++instance Monoid Rendering where+ mempty = Rendering id id++instance IsString Rendering where+ fromString = text . T.pack++text :: Text -> Rendering+text value = Rendering (value :) (value :)++intercalate :: Rendering -> [Rendering] -> Rendering+intercalate separator = mconcat . intersperse separator+ class Render a where render :: a -> Text+ render = T.concat . flip (forwards . rendering) [] + rendering :: a -> Rendering+ rendering = text . render++ {-# MINIMAL render | rendering #-}++widthAtMost :: Render a => Int -> a -> Int+widthAtMost limit = go 0 . flip (backwards . rendering) []+ where+ go :: Int -> [Text] -> Int+ go width [] = width+ go width (chunk : rest) = case T.unsnoc chunk of+ Nothing -> go width rest+ Just (prefix, character)+ | width + charWidth character > limit -> limit + 1+ | otherwise -> go (width + charWidth character) (prefix : rest)++lastLineWidthAtMost :: Render a => Int -> a -> Int+lastLineWidthAtMost limit = go True 0 . flip (backwards . rendering) []+ where+ go :: Bool -> Int -> [Text] -> Int+ go _ width [] = width+ go atEnd width (chunk : rest) = case T.unsnoc chunk of+ Nothing -> go atEnd width rest+ Just (prefix, character)+ | character == '\n' -> if atEnd then go False width (prefix : rest) else width+ | width + charWidth character > limit -> limit + 1+ | otherwise -> go False (width + charWidth character) (prefix : rest)+ instance Render String where render = T.pack @@ -104,12 +154,12 @@ render DOTS' = "\\dots" instance Render BYTES where- render BT_EMPTY = "--"- render (BT_ONE bte) = render bte <> "-"- render (BT_MANY bts) = T.intercalate "-" (map render bts)- render (BT_META mt) = render mt- render (BT_PIPED bts) = "|" <> render bts <> "|"- render (BT_CUT opening omitted closing) = T.intercalate "-" (map render opening) <> "-..(" <> render omitted <> "b)..-" <> T.intercalate "-" (map render closing)+ rendering BT_EMPTY = "--"+ rendering (BT_ONE bte) = rendering bte <> "-"+ rendering (BT_MANY bts) = intercalate "-" (map rendering bts)+ rendering (BT_META mt) = rendering mt+ rendering (BT_PIPED bts) = "|" <> rendering bts <> "|"+ rendering (BT_CUT opening omitted closing) = intercalate "-" (map rendering opening) <> "-..(" <> rendering omitted <> "b)..-" <> intercalate "-" (map rendering closing) instance Render EXCLAMATION where render EXCL = "!"@@ -140,15 +190,15 @@ render S'' = "\\sigma" instance Render META where- render META{..} = render excl <> render hd <> render rest+ rendering META{..} = rendering excl <> rendering hd <> rendering rest instance Render ALPHA' where render ALPHA = "α" render ALPHA' = "~" instance Render ALPHA where- render AL_IDX{..} = render sym <> render idx- render AL_META{..} = render sym <> render meta+ rendering AL_IDX{..} = rendering sym <> rendering idx+ rendering AL_META{..} = rendering sym <> rendering meta instance Render TAB where render TAB{..} = T.replicate indent " "@@ -156,120 +206,114 @@ render NO_TAB = "" instance Render PAIR where- render PA_TAU{..} = render attr <> render SPACE <> render arrow <> render SPACE <> render expr- render PA_ALPHA{..} = render alpha <> render SPACE <> render arrow <> render SPACE <> render expr- render PA_FORMATION{voids = [], attr, arrow, expr} = render (PA_TAU attr arrow expr)- render PA_FORMATION{..} = render attr <> "(" <> render voids <> ")" <> render SPACE <> render arrow <> render SPACE <> render expr- render PA_LAMBDA{..} = render LAMBDA <> render SPACE <> render DASHED_ARROW <> render SPACE <> render func- render PA_LAMBDA'{..} = "L> " <> render func- render PA_VOID{..} = render attr <> render SPACE <> render arrow <> render SPACE <> render void- render PA_DELTA{..} = render DELTA <> render SPACE <> render DASHED_ARROW <> render SPACE <> render bytes- render PA_DELTA'{..} = "D> " <> render bytes- render PA_META_LAMBDA{..} = render LAMBDA <> render SPACE <> render DASHED_ARROW <> render SPACE <> render meta- render PA_META_LAMBDA'{..} = "L> " <> render meta- render PA_META_DELTA{..} = render DELTA <> render SPACE <> render DASHED_ARROW <> render SPACE <> render meta- render PA_META_DELTA'{..} = "D> " <> render meta- render PA_FOLDED{..} = "+" <> render count+ rendering PA_TAU{..} = rendering attr <> rendering SPACE <> rendering arrow <> rendering SPACE <> rendering expr+ rendering PA_ALPHA{..} = rendering alpha <> rendering SPACE <> rendering arrow <> rendering SPACE <> rendering expr+ rendering PA_FORMATION{voids = [], attr, arrow, expr} = rendering (PA_TAU attr arrow expr)+ rendering PA_FORMATION{..} = rendering attr <> "(" <> rendering voids <> ")" <> rendering SPACE <> rendering arrow <> rendering SPACE <> rendering expr+ rendering PA_LAMBDA{..} = rendering LAMBDA <> rendering SPACE <> rendering DASHED_ARROW <> rendering SPACE <> rendering func+ rendering PA_LAMBDA'{..} = "L> " <> rendering func+ rendering PA_VOID{..} = rendering attr <> rendering SPACE <> rendering arrow <> rendering SPACE <> rendering void+ rendering PA_DELTA{..} = rendering DELTA <> rendering SPACE <> rendering DASHED_ARROW <> rendering SPACE <> rendering bytes+ rendering PA_DELTA'{..} = "D> " <> rendering bytes+ rendering PA_META_LAMBDA{..} = rendering LAMBDA <> rendering SPACE <> rendering DASHED_ARROW <> rendering SPACE <> rendering meta+ rendering PA_META_LAMBDA'{..} = "L> " <> rendering meta+ rendering PA_META_DELTA{..} = rendering DELTA <> rendering SPACE <> rendering DASHED_ARROW <> rendering SPACE <> rendering meta+ rendering PA_META_DELTA'{..} = "D> " <> rendering meta+ rendering PA_FOLDED{..} = "+" <> rendering count instance Render BINDINGS where- render = TL.toStrict . TLB.toLazyText . binds- where- binds :: BINDINGS -> TLB.Builder- binds BDS_EMPTY{} = mempty- binds BDS_PAIR{..} = TLB.fromText (render COMMA <> render eol <> render tab <> render pair) <> binds bindings- binds BDS_META{..} = TLB.fromText (render COMMA <> render eol <> render tab <> render meta) <> binds bindings+ rendering BDS_EMPTY{} = mempty+ rendering BDS_PAIR{..} = rendering COMMA <> rendering eol <> rendering tab <> rendering pair <> rendering bindings+ rendering BDS_META{..} = rendering COMMA <> rendering eol <> rendering tab <> rendering meta <> rendering bindings instance Render APP_BINDING where- render APP_BINDING{..} = render pair+ rendering APP_BINDING{..} = rendering pair instance Render BINDING where- render BI_EMPTY{} = ""- render BI_PAIR{..} = render pair <> render bindings- render BI_META{..} = render meta <> render bindings+ rendering BI_EMPTY{} = ""+ rendering BI_PAIR{..} = rendering pair <> rendering bindings+ rendering BI_META{..} = rendering meta <> rendering bindings instance Render APP_ARGUMENT where- render (AA_TAU tau) = render tau- render (AA_TAUS taus) = render taus- render (AA_EXPRS args) = render args+ rendering (AA_TAU tau) = rendering tau+ rendering (AA_TAUS taus) = rendering taus+ rendering (AA_EXPRS args) = rendering args instance Render APP_ARG where- render APP_ARG{..} = render expr <> render args+ rendering APP_ARG{..} = rendering expr <> rendering args instance Render APP_ARGS where- render = TL.toStrict . TLB.toLazyText . arguments- where- arguments :: APP_ARGS -> TLB.Builder- arguments AAS_EMPTY = mempty- arguments AAS_EXPR{..} = TLB.fromText (render COMMA <> render eol <> render tab <> render expr) <> arguments args+ rendering AAS_EMPTY = mempty+ rendering AAS_EXPR{..} = rendering COMMA <> rendering eol <> rendering tab <> rendering expr <> rendering args instance Render EXPRESSION where- render EX_GLOBAL{..} = render global- render EX_XI{..} = render xi- render EX_ATTR{..} = render attr- render EX_TERMINATION{..} = render termination- render EX_FORMATION{..} = render lsb <> render eol <> render tab <> render binding <> render eol' <> render tab' <> render rsb- render EX_DISPATCH{..} = render expr <> render space <> "." <> render space <> render attr- render EX_APPLICATION{..} = render expr <> render space <> "(" <> render eol <> render tab <> render argument <> render eol' <> render tab' <> ")"- render EX_STRING{..} = "\"" <> render str <> "\""- render EX_NUMBER{..} = case properFraction num :: (Int, Double) of- (whole, 0.0) | abs num < 1.0e7 && not (isNegativeZero num) -> T.pack (show whole) <> ".0"- _ -> T.pack (show num)- render EX_NONFINITE{..} = render global <> "." <> nonFiniteName nonfinite- render EX_META{..} = render meta- render EX_PHI_MEET{..} = "\\phinoMeet{" <> maybe "" (\p -> T.pack p <> ":") prefix <> render idx <> "}{ " <> render expr <> " }"- render EX_PHI_AGAIN{..} = "\\phinoAgain{" <> maybe "" (\p -> T.pack p <> ":") prefix <> render idx <> "}"- render EX_BYTES{..} = render bytes- render EX_SINGLE{..} = case pair of- PA_TAU{..} -> render expr <> colon <> render attr- PA_FORMATION{voids = [], ..} -> render expr <> colon <> render attr- PA_VOID{..} -> render void <> colon <> render attr- PA_DELTA{..} -> render bytes <> colon <> render DELTA- PA_DELTA'{..} -> render bytes <> colon <> render DELTA'- PA_META_DELTA{..} -> render meta <> colon <> render DELTA- PA_META_DELTA'{..} -> render meta <> colon <> render DELTA'- PA_LAMBDA{..} -> render func <> colon <> render LAMBDA- PA_LAMBDA'{..} -> render func <> colon <> render LAMBDA'- PA_META_LAMBDA{..} -> render meta <> colon <> render LAMBDA- PA_META_LAMBDA'{..} -> render meta <> colon <> render LAMBDA'- _ -> render formation+ rendering EX_GLOBAL{..} = rendering global+ rendering EX_XI{..} = rendering xi+ rendering EX_ATTR{..} = rendering attr+ rendering EX_TERMINATION{..} = rendering termination+ rendering EX_FORMATION{..} = rendering lsb <> rendering eol <> rendering tab <> rendering binding <> rendering eol' <> rendering tab' <> rendering rsb+ rendering EX_DISPATCH{..} = rendering expr <> rendering space <> "." <> rendering space <> rendering attr+ rendering EX_APPLICATION{..} = rendering expr <> rendering space <> "(" <> rendering eol <> rendering tab <> rendering argument <> rendering eol' <> rendering tab' <> ")"+ rendering EX_STRING{..} = "\"" <> rendering str <> "\""+ rendering EX_NUMBER{..} = case properFraction num :: (Int, Double) of+ (whole, 0.0) | abs num < 1.0e7 && not (isNegativeZero num) -> fromString (show whole) <> ".0"+ _ -> fromString (show num)+ rendering EX_NONFINITE{..} = rendering global <> "." <> text (nonFiniteName nonfinite)+ rendering EX_META{..} = rendering meta+ rendering EX_PHI_MEET{..} = "\\phinoMeet{" <> maybe "" (\p -> fromString p <> ":") prefix <> rendering idx <> "}{ " <> rendering expr <> " }"+ rendering EX_PHI_AGAIN{..} = "\\phinoAgain{" <> maybe "" (\p -> fromString p <> ":") prefix <> rendering idx <> "}"+ rendering EX_BYTES{..} = rendering bytes+ rendering EX_SINGLE{..} = case pair of+ PA_TAU{..} -> rendering expr <> colon <> rendering attr+ PA_FORMATION{voids = [], ..} -> rendering expr <> colon <> rendering attr+ PA_VOID{..} -> rendering void <> colon <> rendering attr+ PA_DELTA{..} -> rendering bytes <> colon <> rendering DELTA+ PA_DELTA'{..} -> rendering bytes <> colon <> rendering DELTA'+ PA_META_DELTA{..} -> rendering meta <> colon <> rendering DELTA+ PA_META_DELTA'{..} -> rendering meta <> colon <> rendering DELTA'+ PA_LAMBDA{..} -> rendering func <> colon <> rendering LAMBDA+ PA_LAMBDA'{..} -> rendering func <> colon <> rendering LAMBDA'+ PA_META_LAMBDA{..} -> rendering meta <> colon <> rendering LAMBDA+ PA_META_LAMBDA'{..} -> rendering meta <> colon <> rendering LAMBDA'+ _ -> rendering formation where- colon :: T.Text- colon = render space <> ":" <> render space+ colon :: Rendering+ colon = rendering space <> ":" <> rendering space instance Render [ATTRIBUTE] where- render attrs = T.intercalate ", " (map render attrs)+ rendering attrs = intercalate ", " (map rendering attrs) instance Render ATTRIBUTE where- render AT_LABEL{..} = render label- render AT_RHO{..} = render rho- render AT_PHI{..} = render phi- render AT_LAMBDA{..} = render lambda- render AT_DELTA{..} = render delta- render AT_META{..} = render meta- render AT_REST{..} = render dots+ rendering AT_LABEL{..} = rendering label+ rendering AT_RHO{..} = rendering rho+ rendering AT_PHI{..} = rendering phi+ rendering AT_LAMBDA{..} = rendering lambda+ rendering AT_DELTA{..} = rendering delta+ rendering AT_META{..} = rendering meta+ rendering AT_REST{..} = rendering dots instance Render BELONGING where render IN = "\\in" render NOT_IN = "\\notin" instance Render SET where- render ST_BINDING{..} = render binding- render ST_ATTRIBUTES{..} = "[ " <> T.intercalate " \\char44{} " (map render attrs) <> " ]"+ rendering ST_BINDING{..} = rendering binding+ rendering ST_ATTRIBUTES{..} = "[ " <> intercalate " \\char44{} " (map rendering attrs) <> " ]" instance Render LOGIC_OPERATOR where render AND = "\\phiText{and}" render OR = "\\phiText{or}" instance Render NUMBER where- render IDX_META{..} = render meta- render LENGTH{..} = "\\vert " <> render binding <> " \\vert"- render DOMAIN{..} = "\\vert \\overline{ " <> render binding <> " } \\vert"- render LITERAL{..} = T.pack (show num)+ rendering IDX_META{..} = rendering meta+ rendering LENGTH{..} = "\\vert " <> rendering binding <> " \\vert"+ rendering DOMAIN{..} = "\\vert \\overline{ " <> rendering binding <> " } \\vert"+ rendering LITERAL{..} = fromString (show num) instance Render COMPARABLE where- render CMP_ATTR{..} = render attr- render CMP_EXPR{..} = render expr- render CMP_NUM{..} = render num+ rendering CMP_ATTR{..} = rendering attr+ rendering CMP_EXPR{..} = rendering expr+ rendering CMP_NUM{..} = rendering num instance Render EQUAL where render EQUAL = "="@@ -278,55 +322,154 @@ render NOT_GREATER = "\\leq" instance Render CONDITION where- render CO_BELONGS{..} = render attr <> " " <> render belongs <> " " <> render set- render CO_LOGIC{conditions = [cond]} = render cond- render CO_LOGIC{..} = T.intercalate (" " <> render operator <> " ") (map renderWrapped conditions)+ rendering CO_BELONGS{..} = rendering attr <> " " <> rendering belongs <> " " <> rendering set+ rendering CO_LOGIC{conditions = [cond]} = rendering cond+ rendering CO_LOGIC{..} = intercalate (" " <> rendering operator <> " ") (map renderingWrapped conditions) where- renderWrapped :: CONDITION -> Text- renderWrapped CO_LOGIC{conditions = [cond]} = render cond- renderWrapped cond@CO_LOGIC{} = "\\lparen " <> render cond <> " \\rparen"- renderWrapped cond = render cond- render CO_NF{..} = "\\isnormal{ " <> render expr <> " }"- render CO_ABSOLUTE{belongs = NOT_IN, ..} = "\\phinoNotAbsolute{ " <> render expr <> " }"- render CO_ABSOLUTE{..} = "\\phinoAbsolute{ " <> render expr <> " }"- render CO_NOT{condition = CO_FORMATION{..}} = "\\phinoNotFormation{ " <> render expr <> " }"- render CO_NOT{..} = renderFunc "not" condition+ renderingWrapped :: CONDITION -> Rendering+ renderingWrapped CO_LOGIC{conditions = [cond]} = rendering cond+ renderingWrapped cond@CO_LOGIC{} = "\\lparen " <> rendering cond <> " \\rparen"+ renderingWrapped cond = rendering cond+ rendering CO_NF{..} = "\\isnormal{ " <> rendering expr <> " }"+ rendering CO_ABSOLUTE{belongs = NOT_IN, ..} = "\\phinoNotAbsolute{ " <> rendering expr <> " }"+ rendering CO_ABSOLUTE{..} = "\\phinoAbsolute{ " <> rendering expr <> " }"+ rendering CO_NOT{condition = CO_FORMATION{..}} = "\\phinoNotFormation{ " <> rendering expr <> " }"+ rendering CO_NOT{..} = renderingFunc "not" condition where- renderFunc :: Render a => Text -> a -> Text- renderFunc func renderable = func <> "\\lparen " <> render renderable <> " \\rparen"- render CO_COMPARE{..} = render left <> " " <> render equal <> " " <> render right- render CO_MATCHES{..} = "matches\\lparen " <> T.pack regex <> ", " <> render expr <> " \\rparen"- render CO_PART_OF{..} = "part-of\\lparen " <> render expr <> ", " <> render binding <> " \\rparen"- render CO_FORMATION{..} = "\\phinoIsFormation{ " <> render expr <> " }"- render CO_DISJOINT{..} = render (ST_ATTRIBUTES attrs) <> " \\cap " <> union groups <> " = \\emptyset"- render CO_SUBSET{attrs = [attr], ..} = render attr <> " " <> render belongs <> " " <> union groups- render CO_SUBSET{belongs = NOT_IN, ..} = render (ST_ATTRIBUTES attrs) <> " \\not\\subseteq " <> union groups- render CO_SUBSET{..} = render (ST_ATTRIBUTES attrs) <> " \\subseteq " <> union groups- render CO_EMPTY = ""+ renderingFunc :: Render a => Rendering -> a -> Rendering+ renderingFunc func renderable = func <> "\\lparen " <> rendering renderable <> " \\rparen"+ rendering CO_COMPARE{..} = rendering left <> " " <> rendering equal <> " " <> rendering right+ rendering CO_MATCHES{..} = "matches\\lparen " <> fromString regex <> ", " <> rendering expr <> " \\rparen"+ rendering CO_PART_OF{..} = "part-of\\lparen " <> rendering expr <> ", " <> rendering binding <> " \\rparen"+ rendering CO_FORMATION{..} = "\\phinoIsFormation{ " <> rendering expr <> " }"+ rendering CO_DISJOINT{..} = rendering (ST_ATTRIBUTES attrs) <> " \\cap " <> renderingUnion groups <> " = \\emptyset"+ rendering CO_SUBSET{attrs = [attr], ..} = rendering attr <> " " <> rendering belongs <> " " <> renderingUnion groups+ rendering CO_SUBSET{belongs = NOT_IN, ..} = rendering (ST_ATTRIBUTES attrs) <> " \\not\\subseteq " <> renderingUnion groups+ rendering CO_SUBSET{..} = rendering (ST_ATTRIBUTES attrs) <> " \\subseteq " <> renderingUnion groups+ rendering CO_EMPTY = "" union :: [BINDING] -> Text-union [group] = render group-union groups = "\\lparen " <> T.intercalate " \\cup " (map render groups) <> " \\rparen"+union = T.concat . flip (forwards . renderingUnion) [] +renderingUnion :: [BINDING] -> Rendering+renderingUnion [group] = rendering group+renderingUnion groups = "\\lparen " <> intercalate " \\cup " (map rendering groups) <> " \\rparen"+ instance Render EXTRA_ARG where- render ARG_ATTR{..} = render attr- render ARG_EXPR{..} = render expr- render ARG_BINDING{..} = render binding- render ARG_BYTES{..} = render bytes+ rendering ARG_ATTR{..} = rendering attr+ rendering ARG_EXPR{..} = rendering expr+ rendering ARG_BINDING{..} = rendering binding+ rendering ARG_BYTES{..} = rendering bytes instance Render EXTRA where- render EXTRA{func = "contextualize", args = arg : rest, ..} = "\\phinoContextualize{ " <> render arg <> " }{ " <> T.intercalate ", " (map render rest) <> " }{ " <> render meta <> " }"- render EXTRA{func = "morph", ..} = render meta <> " \\coloneqq \\phinoMorph{ " <> T.intercalate ", " (map render args) <> " }{ e }{ s_1 }"- render EXTRA{func = "named", args = [form], ..} = "\\phinoNamed{ " <> render meta <> " }{ " <> render form <> " }"- render EXTRA{..} = render meta <> " \\coloneqq " <> macro func <> "{ " <> T.intercalate ", " (map render args) <> " }"+ rendering EXTRA{func = "contextualize", args = arg : rest, ..} = "\\phinoContextualize{ " <> rendering arg <> " }{ " <> intercalate ", " (map rendering rest) <> " }{ " <> rendering meta <> " }"+ rendering EXTRA{func = "morph", ..} = rendering meta <> " \\coloneqq \\phinoMorph{ " <> intercalate ", " (map rendering args) <> " }{ e }{ s_1 }"+ rendering EXTRA{func = "named", args = [form], ..} = "\\phinoNamed{ " <> rendering meta <> " }{ " <> rendering form <> " }"+ rendering EXTRA{..} = rendering meta <> " \\coloneqq " <> macro func <> "{ " <> intercalate ", " (map rendering args) <> " }" where- macro :: String -> Text+ macro :: String -> Rendering macro "evaluate" = "\\phinoEvaluate" macro "number" = "\\phinoNumber" macro "string" = "\\phinoString" macro "sum" = "\\phinoSum" macro "tau" = "\\phinoTau"- macro name = "\\" <> T.concat (zipWith camel [0 :: Int ..] (T.splitOn "-" (T.pack name)))+ macro name = "\\" <> text (T.concat (zipWith camel [0 :: Int ..] (T.splitOn "-" (T.pack name)))) camel :: Int -> Text -> Text camel 0 part = part camel _ part = T.toTitle part++displayWidth :: T.Text -> Int+displayWidth = T.foldl' addWidth 0+ where+ addWidth :: Int -> Char -> Int+ addWidth acc character = acc + charWidth character++charWidth :: Char -> Int+charWidth character+ | fromEnum character < 0x300 = 1+ | blank = 0+ | isWideCodePoint (fromEnum character) = 2+ | otherwise = 1+ where+ blank :: Bool+ blank = generalCategory character `elem` [NonSpacingMark, EnclosingMark, Format]++ isWideCodePoint :: Int -> Bool+ isWideCodePoint codePoint = any (inRange codePoint) wideRanges++ inRange :: Int -> (Int, Int) -> Bool+ inRange codePoint (lo, hi) = codePoint >= lo && codePoint <= hi++ wideRanges :: [(Int, Int)]+ wideRanges =+ [ (0x1100, 0x115F)+ , (0x231A, 0x231B)+ , (0x2329, 0x232A)+ , (0x23E9, 0x23EC)+ , (0x23F0, 0x23F0)+ , (0x23F3, 0x23F3)+ , (0x25FD, 0x25FE)+ , (0x2614, 0x2615)+ , (0x2648, 0x2653)+ , (0x267F, 0x267F)+ , (0x2693, 0x2693)+ , (0x26A1, 0x26A1)+ , (0x26AA, 0x26AB)+ , (0x26BD, 0x26BE)+ , (0x26C4, 0x26C5)+ , (0x26CE, 0x26CE)+ , (0x26D4, 0x26D4)+ , (0x26EA, 0x26EA)+ , (0x26F2, 0x26F3)+ , (0x26F5, 0x26F5)+ , (0x26FA, 0x26FA)+ , (0x26FD, 0x26FD)+ , (0x2705, 0x2705)+ , (0x270A, 0x270B)+ , (0x2728, 0x2728)+ , (0x274C, 0x274C)+ , (0x274E, 0x274E)+ , (0x2753, 0x2755)+ , (0x2757, 0x2757)+ , (0x2795, 0x2797)+ , (0x27B0, 0x27B0)+ , (0x27BF, 0x27BF)+ , (0x2B1B, 0x2B1C)+ , (0x2B50, 0x2B50)+ , (0x2B55, 0x2B55)+ , (0x2E80, 0x303E)+ , (0x3041, 0x33FF)+ , (0x3400, 0x4DBF)+ , (0x4E00, 0x9FFF)+ , (0xA000, 0xA4CF)+ , (0xA960, 0xA97C)+ , (0xAC00, 0xD7A3)+ , (0xF900, 0xFAFF)+ , (0xFE10, 0xFE19)+ , (0xFE30, 0xFE4F)+ , (0xFE50, 0xFE52)+ , (0xFE54, 0xFE66)+ , (0xFE68, 0xFE6B)+ , (0xFF00, 0xFF60)+ , (0xFFE0, 0xFFE6)+ , (0x16FE0, 0x16FE4)+ , (0x16FF0, 0x16FF1)+ , (0x17000, 0x187F7)+ , (0x18800, 0x18CD5)+ , (0x18D00, 0x18D08)+ , (0x1B000, 0x1B11E)+ , (0x1B150, 0x1B152)+ , (0x1B164, 0x1B167)+ , (0x1B170, 0x1B2FB)+ , (0x1F004, 0x1F004)+ , (0x1F0CF, 0x1F0CF)+ , (0x1F18E, 0x1F18E)+ , (0x1F191, 0x1F19A)+ , (0x1F200, 0x1F202)+ , (0x1F210, 0x1F23B)+ , (0x1F240, 0x1F248)+ , (0x1F250, 0x1F251)+ , (0x1F260, 0x1F265)+ , (0x1F300, 0x1FAFF)+ , (0x20000, 0x3FFFD)+ ]
src/Rewriter.hs view
@@ -9,7 +9,7 @@ -- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com -- SPDX-License-Identifier: MIT -module Rewriter (Seen, direct, every, fast, interpreted, rewrite, RewriteContext (..), Rewritten, Rewrittens, Rewrittens', seenInsert, seenMember, stepHeaders) where+module Rewriter (Seen, cheating, direct, every, fast, interpreted, rewrite, RewriteContext (..), Rewritten, Rewrittens, Rewrittens', seenInsert, seenMember, stepHeaders) where import AST import Builder@@ -110,22 +110,29 @@ rul expr -buildAndReplace' :: ToReplace -> ReplaceExpressionFunc -> IO (Expression, [(Expression, Expression)])-buildAndReplace' (expr, ptn, res, substs) func = do+buildAndReplace' :: Bool -> ToReplace -> ReplaceExpressionFunc -> IO (Expression, [(Expression, Expression)])+buildAndReplace' cheat (expr, ptn, res, substs) func = do ptns <- buildExpressionsThrows ptn substs- repls <- buildExpressionsThrows res substs+ repls <- map (cheated cheat) <$> buildExpressionsThrows res substs pure (func (expr, ptns, map const repls), zip ptns repls) -tryBuildAndReplaceFast :: ToReplace -> IO (Expression, [(Expression, Expression)])-tryBuildAndReplaceFast state@(expr, ptn@(ExFormation (_ : pbds)), res@(ExFormation (_ : rbds)), substs)+tryBuildAndReplaceFast :: Bool -> ToReplace -> IO (Expression, [(Expression, Expression)])+tryBuildAndReplaceFast cheat state@(expr, ptn@(ExFormation (_ : pbds)), res@(ExFormation (_ : rbds)), substs) | fast ptn res = do logDebug "Applying fast replacing since 'pattern' and 'result' are suitable for this..."- buildAndReplace' (expr, ExFormation (init pbds), ExFormation (init rbds), substs) replaceExpressionFast+ buildAndReplace' cheat (expr, ExFormation (init pbds), ExFormation (init rbds), substs) replaceExpressionFast | otherwise = do logDebug "Applying regular replacing..."- buildAndReplace' state replaceExpression-tryBuildAndReplaceFast state = buildAndReplace' state replaceExpression+ buildAndReplace' cheat state replaceExpression+tryBuildAndReplaceFast cheat state = buildAndReplace' cheat state replaceExpression +cheated :: Bool -> Expression -> Expression+cheated True (ExApplication inner@(ExApplication _ (ArTau AtRho _)) (ArTau AtRho _)) = cheated True inner+cheated _ expr = expr++cheating :: Step -> Step+cheating (Step name applied) = Step name (\ctx -> applied ctx{R._cheat = True})+ fast :: Expression -> Expression -> Bool fast (ExFormation _pbds@(pbd : pbds)) (ExFormation _rbds@(rbd : rbds)) = startsAndEndsWithMeta _pbds@@ -159,14 +166,14 @@ R.matchExpressionWithRule expr rule ctx >>= \case [] -> pure Nothing matched- | isNothing rule.when && isNothing rule.having -> Just <$> tryBuildAndReplaceFast (expr, rule.pattern, rule.result, matched)- | otherwise -> Just <$> buildAndReplace' (expr, rule.pattern, rule.result, matched) replaceExpression+ | isNothing rule.when && isNothing rule.having -> Just <$> tryBuildAndReplaceFast ctx._cheat (expr, rule.pattern, rule.result, matched)+ | otherwise -> Just <$> buildAndReplace' ctx._cheat (expr, rule.pattern, rule.result, matched) replaceExpression direct :: String -> Bool -> (Maybe Expression -> Expression -> [Expression]) -> Step direct name redex rewritten = Step name applied where applied :: RuleContext -> Expression -> IO (Maybe (Expression, [(Expression, Expression)]))- applied (RuleContext _ universe _) expr = pure $ case sites redex (rewritten universe) expr of+ applied (RuleContext _ universe _ cheat) expr = pure $ case [(site, cheated cheat made) | (site, made) <- sites redex (rewritten universe) expr] of [] -> Nothing found -> Just (replaceExpression (expr, map fst found, map (const . snd) found), found) @@ -199,7 +206,7 @@ else pure (_rewrittens, expression, _unique, False, _found) else do logDebug (printf "Starting rewriting cycle for rule '%s': %d out of %d" ruleName _count _maxDepth)- _applied rule (RuleContext _buildTerm _universe _normal) expression >>= \case+ _applied rule (RuleContext _buildTerm _universe _normal False) expression >>= \case Nothing -> do logDebug (printf "Rule '%s' does not match, rewriting is stopped" ruleName) if _breakpoint == Just ruleName && ruleName `notElem` [fired | (_, Just (_, fired)) <- NE.toList _rewrittens]@@ -246,7 +253,7 @@ where probe :: Step -> IO Bool probe rule =- _applied rule (RuleContext _buildTerm _universe _normal) expression >>= \case+ _applied rule (RuleContext _buildTerm _universe _normal False) expression >>= \case Just (changed, _) | changed /= expression -> pure True _ -> pure False onIOException :: IOException -> IO Bool
src/Rule.hs view
@@ -18,7 +18,7 @@ ) import Bytes (btsToUnescapedStr) import Control.Exception (Exception (displayException), throwIO)-import Control.Exception.Base (SomeException, try)+import Control.Exception.Base (SomeException, fromException, tryJust) import Control.Monad (when) import Data.Foldable (foldlM) import Data.List (intersect, nub)@@ -33,7 +33,7 @@ import Logger (logDebug) import Matcher import Printer-import Regexp (match)+import Regexp (RegexExecutionException, match) import Text.Printf (printf) import Yaml (normalizationRules) import qualified Yaml as Y@@ -42,6 +42,7 @@ { _buildTerm :: BuildTermFunc , _universe :: Maybe Expression , _normal :: Expression -> Bool+ , _cheat :: Bool } data Step = Step@@ -62,7 +63,7 @@ isNF expr ctx = normalWith (`matchesAnyNormalizationRule` ctx) expr normal :: Expression -> Bool-normal expr = isNF expr (RuleContext buildTerm Nothing normal)+normal expr = isNF expr (RuleContext buildTerm Nothing (const True) False) normalWith :: (Expression -> Bool) -> Expression -> Bool normalWith _ ExXi = True@@ -91,7 +92,7 @@ normalWith matching expr = not (matching expr) normalHeld :: (Expression -> Bool) -> Expression -> Bool-normalHeld _ (ExMeta _) = False+normalHeld _ (ExMeta meta) = isName meta normalHeld _ (ExAny _) = False normalHeld test expr = test expr @@ -101,7 +102,7 @@ loop :: Maybe SomeException -> [Y.Condition] -> IO [Subst] loop raised [] = maybe (pure []) throwIO raised loop raised (cond : rest) = do- met <- try (meetCondition' cond subst ctx) :: IO (Either SomeException [Subst])+ met <- tryJust recoverableConditionException (meetCondition' cond subst ctx) :: IO (Either SomeException [Subst]) case met of Right [] -> loop raised rest Right mets -> pure mets@@ -207,7 +208,7 @@ pure [subst | xiFree built] bound :: Expression -> Bool-bound (ExMeta _) = False+bound (ExMeta meta) = isName meta bound (ExAny _) = False bound _ = True @@ -215,6 +216,7 @@ xiFree (ExFormation _) = True xiFree ExRoot = True xiFree ExTermination = True+xiFree (ExMeta meta) = isName meta xiFree (ExApplication e (ArTau _ te)) = xiFree e && xiFree te xiFree (ExApplication e (ArAlpha _ te)) = xiFree e && xiFree te xiFree (ExDispatch e _) = xiFree e@@ -288,10 +290,15 @@ meetCondition' (Y.Disjoint attrs bds) = _disjoint attrs bds meetCondition' (Y.IsFormation expr) = _isFormation expr +recoverableConditionException :: SomeException -> Maybe SomeException+recoverableConditionException err = case fromException err :: Maybe RegexExecutionException of+ Just _ -> Nothing+ Nothing -> Just err+ meetCondition :: Y.Condition -> [Subst] -> RuleContext -> IO [Subst] meetCondition _ [] _ = pure [] meetCondition cond (subst : rest) ctx = do- met <- try (meetCondition' cond subst ctx) :: IO (Either SomeException [Subst])+ met <- tryJust recoverableConditionException (meetCondition' cond subst ctx) :: IO (Either SomeException [Subst]) case met of Right first -> do next <- meetCondition cond rest ctx
+ src/Sides.hs view
@@ -0,0 +1,85 @@+{-# LANGUAGE OverloadedStrings #-}++-- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+-- SPDX-License-Identifier: MIT++module Sides (Sides, minted, opened, named, resolver, sides, spelled) where++import AST+import Data.IORef (IORef, atomicModifyIORef', modifyIORef', newIORef, readIORef)+import qualified Data.IntMap.Strict as IntMap+import qualified Data.Map.Strict as Map+import Data.Maybe (fromMaybe)+import qualified Data.Set as Set+import Data.Text (Text)+import qualified Data.Text as T++data Store = Store+ { _terms :: !(Map.Map Text Expression)+ , _names :: !(IntMap.IntMap [(Expression, Text)])+ , _count :: !Int+ , _spelt :: !(Set.Set Text)+ }++newtype Sides = Sides (IORef Store)++sides :: IO Sides+sides = Sides <$> newIORef (Store Map.empty IntMap.empty 0 Set.empty)++named :: Sides -> Expression -> IO Expression+named store term = fst <$> given False store term++minted :: Sides -> Expression -> IO (Expression, Bool)+minted = given True++given :: Bool -> Sides -> Expression -> IO (Expression, Bool)+given _ _ term@(ExMeta meta) | isName meta = pure (term, False)+given spelt (Sides store) term = atomicModifyIORef' store found+ where+ digest :: Int+ digest = hashExpression term+ found :: Store -> (Store, (Expression, Bool))+ found known@(Store terms names count kept) = case lookup term (IntMap.findWithDefault [] digest names) of+ Just name -> (known, (ExMeta name, False))+ Nothing ->+ let name = T.pack ("n·" ++ show (succ count))+ in (Store (Map.insert name term terms) (IntMap.insertWith (++) digest [(term, name)] names) (succ count) (if spelt then Set.insert name kept else kept), (ExMeta name, True))++spelled :: Sides -> Expression -> IO Expression+spelled (Sides store) whole = do+ Store terms _ _ kept <- readIORef store+ cache <- newIORef Map.empty+ let goExpr :: Expression -> IO Expression+ goExpr term@(ExMeta name)+ | Set.member name kept = do+ done <- readIORef cache+ case Map.lookup name done of+ Just again -> pure again+ Nothing -> do+ made <- maybe (pure term) goExpr (Map.lookup name terms)+ made <$ modifyIORef' cache (Map.insert name made)+ goExpr term@(ExFormation bds) = intact bds term ExFormation <$> mapM goBinding bds+ goExpr term@(ExApplication inner arg) = intact (inner, arg) term (uncurry ExApplication) <$> ((,) <$> goExpr inner <*> goArgument arg)+ goExpr term@(ExDispatch inner attr) = intact inner term (`ExDispatch` attr) <$> goExpr inner+ goExpr term = pure term+ goBinding :: Binding -> IO Binding+ goBinding bd@(BiTau attr term) = intact term bd (BiTau attr) <$> goExpr term+ goBinding bd = pure bd+ goArgument :: Argument -> IO Argument+ goArgument arg@(ArTau attr term) = intact term arg (ArTau attr) <$> goExpr term+ goArgument arg@(ArAlpha alpha term) = intact term arg (ArAlpha alpha) <$> goExpr term+ goExpr whole++opened :: Sides -> Expression -> IO Expression+opened store term = do+ look <- resolver store+ pure (fromMaybe term (look =<< meta term))+ where+ meta :: Expression -> Maybe Text+ meta (ExMeta name) = Just name+ meta _ = Nothing++resolver :: Sides -> IO (Text -> Maybe Expression)+resolver (Sides store) = do+ Store terms _ _ _ <- readIORef store+ pure (`Map.lookup` terms)
src/XMIR.hs view
@@ -109,6 +109,8 @@ expression (ExFormation bds) ctx = do nested <- nestedBindings bds ctx pure ("", nested)+expression dispatch@(ExDispatch _ attr) _+ | metaAttribute attr = throwIO (UnsupportedExpression dispatch) expression (ExDispatch expr attr) ctx = do (base, children) <- expression expr ctx let attr' = printAttribute attr@@ -149,6 +151,8 @@ expression app@(ExApplication expr (ArTau AtRho _)) ctx@XmirContext{..} | _hideRho = expression expr ctx | otherwise = throwIO (UnsupportedExpression app)+expression app@(ExApplication _ (ArTau attr _)) _+ | metaAttribute attr = throwIO (UnsupportedExpression app) expression app@(ExApplication expr arg) ctx = do (base, children) <- expression expr ctx when (null base) (throwIO (UnsupportedExpression app))@@ -164,6 +168,11 @@ ArAlpha alpha value -> (printAlpha alpha, value) expression expr _ = throwIO (UnsupportedExpression expr) +metaAttribute :: Attribute -> Bool+metaAttribute (AtMeta _) = True+metaAttribute (AtAny _) = True+metaAttribute _ = False+ formationBinding :: Binding -> XmirContext -> IO (Maybe Node) formationBinding (BiTau (AtLabel label) expr) ctx = Just <$> namedBinding (T.unpack label) expr ctx formationBinding (BiTau AtRho expr) ctx = Just <$> namedBinding (show AtRho) expr ctx@@ -605,14 +614,8 @@ attr <- toAttr rest cur let disp = ExDispatch expr attr xmirToApplication derived disp args' fqn- "ξ" ->- if null (cur C.$/ C.element (toName "o"))- then pure ExXi- else throwIO (InvalidXMIRFormat "Application of 'ξ' is illegal in XMIR" cur)- "Φ" ->- if null (cur C.$/ C.element (toName "o"))- then pure ExRoot- else throwIO (InvalidXMIRFormat "Application of 'Φ' is illegal in XMIR" cur)+ "ξ" -> xmirToApplication derived ExXi (cur C.$/ C.element (toName "o")) fqn+ "Φ" -> xmirToApplication derived ExRoot (cur C.$/ C.element (toName "o")) fqn "⊥" -> xmirToApplication derived ExTermination (cur C.$/ C.element (toName "o")) fqn '⊥' : '.' : rest -> xmirToExpression' ExTermination "⊥" rest cur fqn 'Φ' : '.' : rest -> xmirToExpression' ExRoot "Φ" rest cur fqn
+ test-resources/cli/rules/drop-x.yaml view
@@ -0,0 +1,6 @@+# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+# SPDX-License-Identifier: MIT+---+name: drop-x+pattern: ⟦ 𝐵1, x ↦ 𝑒1, 𝐵2 ⟧+result: ⟦ 𝐵1, 𝐵2 ⟧
test-resources/evaluate-packs/answers-a-firing-whose-operand-loops.yaml view
@@ -28,16 +28,18 @@ 𝔻(ξ.arg): 𝕄(ξ.arg): 𝔼(L_loop):- 𝑛·2·1 := L_loop:λ # 𝑛+ 𝑛·2·1 := L_loop:λ # 𝑛 of L_loop 𝕄(𝑛·2·1): morphed 𝑛·2·2 := L_loop:λ 𝑛·2·3 := L_loop:λ # 𝕄(𝑛·2·1)+ evaluated 𝑛·2·4 := L_loop:λ # L_loop:λ looped 𝜎1 # proven, repeats L_loop:λ morphed 𝑛·1·1 := 𝜎1:λ 𝛿·1·1 := 𝔻(𝜎1:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.arg)- 𝑛·1·2 := 𝜎2:λ # 𝑛+ 𝑛·1·2 := 𝜎2:λ # 𝑛 of L_outer 𝕄(𝑛·1·2): morphed 𝑛·1·3 := 𝜎2:λ 𝑛·1·4 := 𝑛·1·3 # 𝕄(𝑛·1·2)- unanswered 𝜎2 # 𝕄(𝜎2:λ)+ evaluated 𝑛·1·5 := 𝑛·1·4 # ⟦ arg ↦ L_loop:λ.foo, λ ⤍ L_outer ⟧+ opaque 𝜎2 # 𝕄(𝜎2:λ.bar)
test-resources/evaluate-packs/answers-a-symbol-nobody-has-worked-out.yaml view
@@ -58,11 +58,12 @@ normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·22): 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ ) 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·1·25 := 𝑛·1·24 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := 𝜎1:λ # 𝑛·1·26.φ+ evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·6+ normalized 𝑛·0·7 := 𝜎1:λ # 𝑛·1·27.φ morphed 𝑛·0·8 := 𝑛·0·7
test-resources/evaluate-packs/answers-a-whole-family-of-names-with-one-entry.yaml view
@@ -58,13 +58,14 @@ normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·22): 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ ) 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ, times(x) ↦ L_number_times:λ ⟧ morphed 𝑛·1·25 := 𝑛·1·24 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := ⟦ x ↦ ∅, λ ⤍ L_number_times ⟧ # 𝑛·1·26.times+ evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·6+ normalized 𝑛·0·7 := ⟦ x ↦ ∅, λ ⤍ L_number_times ⟧ # 𝑛·1·27.times 𝑛·0·8 := 𝑛·1·23.times( x ↦ 7.0 ) 𝑛·0·9 := ⟦ x ↦ 7.0, λ ⤍ L_number_times ⟧ 𝔼(L_number_times):@@ -92,11 +93,12 @@ normalized 𝑛·2·15 := 40-1C-00-00-00-00-00-00:Δ # 𝑛·2·14 𝛿·2·2 := 40-1C-00-00-00-00-00-00 # 7.0 𝛿2·2 := 𝛿·2·2 # 𝔻(ξ.x)- 𝑛·2·16 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·2·16 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_times 𝕄(𝑛·2·16): 𝑛·2·17 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·2·18 := ⟦ φ ↦ 𝜎2:λ, plus(x) ↦ L_number_plus:λ, times(x) ↦ L_number_times:λ ⟧ morphed 𝑛·2·19 := 𝑛·2·18 𝑛·2·20 := 𝑛·2·19 # 𝕄(𝑛·2·16)- normalized 𝑛·0·10 := 𝜎2:λ # 𝑛·2·20.φ+ evaluated 𝑛·2·21 := 𝑛·2·20 # 𝑛·0·9+ normalized 𝑛·0·10 := 𝜎2:λ # 𝑛·2·21.φ morphed 𝑛·0·11 := 𝑛·0·10
test-resources/evaluate-packs/answers-an-operand-that-dataizes-in-circles-with-a-symbol.yaml view
@@ -45,9 +45,10 @@ looped 𝜎1 := Φ.cyc( x ↦ 𝑛·1·10 ) # 𝔻(𝑛·1·5), proven, repeats 𝑛·1·9 𝛿·1·1 := 𝔻(𝜎1:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.arg)- 𝑛·1·11 := 𝜎2:λ:bar # 𝑛+ 𝑛·1·11 := 𝜎2:λ:bar # 𝑛 of L_outer 𝕄(𝑛·1·11): morphed 𝑛·1·12 := 𝜎2:λ:bar 𝑛·1·13 := 𝑛·1·12 # 𝕄(𝑛·1·11)- normalized 𝑛·0·1 := 𝜎2:λ # 𝑛·1·13.bar+ evaluated 𝑛·1·14 := 𝑛·1·13 # ⟦ arg ↦ Φ.cyc( 𝑛·1·10 ), λ ⤍ L_outer ⟧+ normalized 𝑛·0·1 := 𝜎2:λ # 𝑛·1·14.bar morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/answers-bottom-for-a-meta-that-raises.yaml view
@@ -28,5 +28,6 @@ morphed 𝑛·1·1 := L_throw:λ 𝑛1·1 := L_throw:λ # 𝕄(ξ.x) 𝑛·1·2 := ⊥+ evaluated 𝑛·1·3 := ⊥ # 𝑛·0·3 normalized 𝑛·0·4 := ⊥ # ⊥.φ morphed 𝑛·0·5 := ⊥
test-resources/evaluate-packs/answers-its-own-sides-on-a-condition-another-join-read.yaml view
@@ -40,12 +40,14 @@ protocol: | 𝕄(Φ.φ): remembered 𝑛·0·1 ≡ Φ.pick # ⟦ x ↦ ∅, y ↦ ∅, λ ⤍ L_pick ⟧- 𝑛·0·2 := Φ.pick( x ↦ 5.0.gt( 0.0 ).if( 7.0, 7.0 ) )- 𝑛·0·3 := ⟦ x ↦ 5.0.gt( 0.0 ).if( 7.0, 7.0 ), y ↦ ∅, λ ⤍ L_pick ⟧- remembered 𝑛·0·3 ≡ 𝑛·0·1( x ↦ 5.0.gt( 0.0 ).if( 7.0, 7.0 ) )- 𝑛·0·4 := 𝑛·0·2( y ↦ 5.0.gt( 0.0 ).if( 70.0, 70.0 ) )- 𝑛·0·5 := ⟦ x ↦ 5.0.gt( 0.0 ).if( 7.0, 7.0 ), y ↦ 5.0.gt( 0.0 ).if( 70.0, 70.0 ), λ ⤍ L_pick ⟧- remembered 𝑛·0·5 ≡ 𝑛·0·3( y ↦ 5.0.gt( 0.0 ).if( 70.0, 70.0 ) )+ shared 𝑛·1 := 5.0.gt( 0.0 ).if( 7.0, 7.0 )+ 𝑛·0·2 := Φ.pick( x ↦ 𝑛·1 )+ 𝑛·0·3 := ⟦ x ↦ 𝑛·1, y ↦ ∅, λ ⤍ L_pick ⟧+ remembered 𝑛·0·3 ≡ 𝑛·0·1( x ↦ 𝑛·1 )+ shared 𝑛·2 := 5.0.gt( 0.0 ).if( 70.0, 70.0 )+ 𝑛·0·4 := 𝑛·0·3( y ↦ 𝑛·2 )+ 𝑛·0·5 := ⟦ x ↦ 𝑛·1, y ↦ 𝑛·2, λ ⤍ L_pick ⟧+ remembered 𝑛·0·5 ≡ 𝑛·0·4 𝔼(L_pick): 𝔻(ξ.x): 𝕄(ξ.x):@@ -87,7 +89,7 @@ normalized 𝑛·2·21 := 00-00-00-00-00-00-00-00:Δ # 𝑛·2·20 𝛿·2·2 := 00-00-00-00-00-00-00-00 # 0.0 𝛿2·2 := 𝛿·2·2 # 𝔻(ξ.x)- 𝑛·2·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·2·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_gt 𝕄(𝑛·2·22): normalized 𝑛·2·23 := ⟦ φ ↦ ∅, if(then, else) ↦ L_fork:λ ⟧ # Φ.bool 𝑛·2·24 := Φ.bool( φ ↦ 𝜎1:λ )@@ -95,7 +97,8 @@ morphed 𝑛·2·26 := 𝑛·2·25 𝑛·2·27 := 𝑛·2·26 # 𝕄(𝑛·2·22) memoized 𝑛·1·6 ⇛ 𝑛·2·27- normalized 𝑛·1·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·2·27.if+ evaluated 𝑛·2·28 := 𝑛·2·27 # 𝑛·1·6+ normalized 𝑛·1·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·2·28.if 𝑛·1·8 := 𝑛·2·24.if( then ↦ 7.0 ) 𝑛·1·9 := ⟦ then ↦ 7.0, else ↦ ∅, λ ⤍ L_fork ⟧ 𝑛·1·10 := 𝑛·1·8( else ↦ 7.0 )@@ -121,7 +124,8 @@ morphed 𝑛·3·11 := 𝑛·3·10 𝑛·3·12 := 𝑛·3·11 memoized 𝑛·1·11 ⇛ 𝑛·3·12- boxed 𝑛·1·13 := 𝑛·3·12.φ+ evaluated 𝑛·3·13 := 𝑛·3·12 # 𝑛·1·11+ boxed 𝑛·1·13 := 𝑛·3·13.φ normalized 𝑛·1·14 := Φ.bytes( φ ↦ 40-1C-00-00-00-00-00-00:Δ ) # 𝑛·1·13 𝕄(𝑛·1·13): 𝑛·1·15 := Φ.bytes( φ ↦ 40-1C-00-00-00-00-00-00:Δ )@@ -139,16 +143,17 @@ 𝑛·1·24 := ⟦ x ↦ 𝑛·2·12, λ ⤍ L_number_gt ⟧ 𝔼(L_number_gt): recalled 𝑛·1·6 ⇒ 𝑛·2·27- 𝑛·4·1 := 𝑛·3·1 # 𝑛+ 𝑛·4·1 := 𝑛·3·1 # 𝑛 of L_number_gt 𝑛·4·2 := 𝑛·2·27 # 𝕄(𝑛·4·1)- normalized 𝑛·1·25 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·4·2.if+ evaluated 𝑛·4·3 := 𝑛·4·2 # 𝑛·1·24+ normalized 𝑛·1·25 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·4·3.if 𝑛·1·26 := 𝑛·3·1.if( then ↦ 70.0 ) 𝑛·1·27 := ⟦ then ↦ 70.0, else ↦ ∅, λ ⤍ L_fork ⟧ 𝑛·1·28 := 𝑛·1·26( else ↦ 70.0 ) 𝑛·1·29 := ⟦ then ↦ 70.0, else ↦ 70.0, λ ⤍ L_fork ⟧ morphed 𝑛·1·30 := 𝑛·1·29 𝑛1·1 := 𝑛·1·29 # 𝕄(ξ.y)- 𝔼(L_fork): # 𝔼(𝑛1)+ 𝔼(L_fork): # 𝔼(𝑛1 of L_pick) 𝔻(ξ.ρ): 𝕄(ξ.ρ): 𝑛·5·1 := Φ.bool( φ ↦ 𝜎1:λ )@@ -167,14 +172,16 @@ morphed 𝑛·5·10 := 𝑛·5·9 𝑛·5·11 := 𝑛·5·10 memoized 𝑛·1·29 ⇛ 𝑛·5·11- 𝑛2·1 := 𝑛·5·11 # 𝔼(𝑛1)- 𝑛·1·31 := 𝑛·5·11 # 𝑛+ evaluated 𝑛·5·12 := 𝑛·5·11 # 𝑛·1·29+ 𝑛2·1 := 𝑛·5·12 # 𝔼(𝑛1 of L_pick)+ 𝑛·1·31 := 𝑛·5·12 # 𝑛 of L_pick 𝕄(𝑛·1·31):- morphed 𝑛·1·32 := 𝑛·5·11+ morphed 𝑛·1·32 := 𝑛·5·12 𝑛·1·33 := 𝑛·1·32 # 𝕄(𝑛·1·31) remembered 𝑛·1·33 ≡ 𝑛·0·5 memoized 𝑛·0·5 ⇛ 𝑛·1·33- normalized 𝑛·0·6 := Φ.bytes( φ ↦ 40-51-80-00-00-00-00-00:Δ ) # 𝑛·1·33.φ+ evaluated 𝑛·1·34 := 𝑛·1·33 # 𝑛·0·5+ normalized 𝑛·0·6 := Φ.bytes( φ ↦ 40-51-80-00-00-00-00-00:Δ ) # 𝑛·1·34.φ 𝑛·0·7 := Φ.bytes( φ ↦ 40-51-80-00-00-00-00-00:Δ ) 𝑛·0·8 := 40-51-80-00-00-00-00-00:Δ:φ morphed 𝑛·0·9 := 𝑛·0·8
test-resources/evaluate-packs/answers-the-same-dataization-loop-under-partial.yaml view
@@ -42,9 +42,10 @@ looped 𝜎1 := Φ.cyc( x ↦ 𝑛·1·10 ) # 𝔻(𝑛·1·5), proven, repeats 𝑛·1·9 𝛿·1·1 := 𝔻(𝜎1:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.arg)- 𝑛·1·11 := 𝜎2:λ:bar # 𝑛+ 𝑛·1·11 := 𝜎2:λ:bar # 𝑛 of L_outer 𝕄(𝑛·1·11): morphed 𝑛·1·12 := 𝜎2:λ:bar 𝑛·1·13 := 𝑛·1·12 # 𝕄(𝑛·1·11)- normalized 𝑛·0·1 := 𝜎2:λ # 𝑛·1·13.bar+ evaluated 𝑛·1·14 := 𝑛·1·13 # ⟦ arg ↦ Φ.cyc( 𝑛·1·10 ), λ ⤍ L_outer ⟧+ normalized 𝑛·0·1 := 𝜎2:λ # 𝑛·1·14.bar morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/answers-the-same-under-acyclic.yaml view
@@ -59,11 +59,12 @@ normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·22): 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ ) 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·1·25 := 𝑛·1·24 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := 𝜎1:λ # 𝑛·1·26.φ+ evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·6+ normalized 𝑛·0·7 := 𝜎1:λ # 𝑛·1·27.φ morphed 𝑛·0·8 := 𝑛·0·7
test-resources/evaluate-packs/binds-a-copy-over-no-bare-symbol-as-it-is.yaml view
@@ -26,8 +26,9 @@ remembered 𝑛·1·3 ≡ 𝑛·1·1( tup ↦ Φ.items.tail ) morphed 𝑛·1·4 := 𝑛·1·3 𝑛1·1 := 𝑛·1·4 # 𝕄(ξ.b)- 𝑛·1·5 := 𝑛·1·4:φ # 𝑛+ 𝑛·1·5 := 𝑛·1·4:φ # 𝑛 of L_hold 𝕄(𝑛·1·5): morphed 𝑛·1·6 := 𝑛·1·4:φ 𝑛·1·7 := 𝑛·1·6 # 𝕄(𝑛·1·5)+ evaluated 𝑛·1·8 := 𝑛·1·7 # ⟦ b ↦ 𝑛·1·2, λ ⤍ L_hold ⟧ morphed 𝑛·0·1 := 𝑛·1·4
+ test-resources/evaluate-packs/binds-a-copy-whose-method-alone-reads-to-a-bare-symbol-as-it-is.yaml view
@@ -0,0 +1,34 @@+# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+# SPDX-License-Identifier: MIT+---+# yamllint disable rule:line-length+# A 'defer' line reduces only the arguments of a copy, never its methods+# (#2379). Here the method 'm' of 'step' reads to the bare symbol '𝜎1', but+# the argument 'tup' reads to an empty object, so the line binds the copy as+# it is, writes no 'deferred' line and mints no symbol.+symbolic: |+ - λ: L_hold+ morph:+ 𝑛1: $.b+ defer:+ 𝑛2: 𝑛1+ 𝑛: ⟦ φ ↦ 𝑛2 ⟧+location: 'Q.y'+input: '⟦ done ↦ ⟦⟧, step(tup) ↦ ⟦ φ ↦ Φ.done, m ↦ Φ.items.tail ⟧, items ↦ ⟦ tail ↦ ⟦ λ ⤍ 𝜎1 ⟧, head ↦ ⟦⟧ ⟧, y ↦ ⟦ b ↦ Φ.step( tup ↦ Φ.items.head ), λ ⤍ L_hold ⟧.φ ⟧'+result: '⟦ tup ↦ Φ.items.head, φ ↦ Φ.done, m ↦ Φ.items.tail ⟧'+protocol: |+ 𝕄(Φ.y):+ 𝔼(L_hold):+ 𝕄(ξ.b):+ remembered 𝑛·1·1 ≡ Φ.step # ⟦ tup ↦ ∅, φ ↦ Φ.done, m ↦ Φ.items.tail ⟧+ 𝑛·1·2 := Φ.step( tup ↦ Φ.items.head )+ 𝑛·1·3 := ⟦ tup ↦ Φ.items.head, φ ↦ Φ.done, m ↦ Φ.items.tail ⟧+ remembered 𝑛·1·3 ≡ 𝑛·1·1( tup ↦ Φ.items.head )+ morphed 𝑛·1·4 := 𝑛·1·3+ 𝑛1·1 := 𝑛·1·4 # 𝕄(ξ.b)+ 𝑛·1·5 := 𝑛·1·4:φ # 𝑛 of L_hold+ 𝕄(𝑛·1·5):+ morphed 𝑛·1·6 := 𝑛·1·4:φ+ 𝑛·1·7 := 𝑛·1·6 # 𝕄(𝑛·1·5)+ evaluated 𝑛·1·8 := 𝑛·1·7 # ⟦ b ↦ 𝑛·1·2, λ ⤍ L_hold ⟧+ morphed 𝑛·0·1 := 𝑛·1·4
test-resources/evaluate-packs/binds-a-copy-whose-phi-repeats-the-formation-fired-as-it-is.yaml view
@@ -65,15 +65,19 @@ 𝑛·1·2 := ⟦ i ↦ 𝜎2:λ, φ ↦ Φ.fork( 𝜎1:λ, Φ.down( i ↦ 𝜎2:λ ), Φ.no ) ⟧ remembered 𝑛·1·2 ≡ 𝑛·0·1( i ↦ 𝜎2:λ ) morphed 𝑛·1·3 := 𝑛·1·2- 𝑛1·1 := 𝑛·1·3 # 𝕄(ξ.left🌵)+ recalled 𝑛·1·2 ⇒ 𝑛·0·1( i ↦ 𝜎2:λ )+ recalled 𝑛·0·1 ⇒ Φ.down+ passed 𝑛·1·4 := Φ.down( i ↦ 𝜎2:λ ) # plausible, repeats 𝑛·0·3+ 𝑛1·1 := 𝑛·1·4 # 𝕄(ξ.left🌵) 𝕄(ξ.right🌵):- remembered 𝑛·1·4 ≡ Φ.no # ⟦ φ ↦ 00-:Δ, not ↦ FF-:Δ ⟧- morphed 𝑛·1·5 := 𝑛·1·4- 𝑛2·1 := 𝑛·1·5 # 𝕄(ξ.right🌵)+ remembered 𝑛·1·5 ≡ Φ.no # ⟦ φ ↦ 00-:Δ, not ↦ FF-:Δ ⟧+ morphed 𝑛·1·6 := 𝑛·1·5+ 𝑛2·1 := 𝑛·1·6 # 𝕄(ξ.right🌵) symbolized 𝜎4 := 00-- 𝑛4·1 := ⟦ φ ↦ 𝜎4:λ, not ↦ FF-:Δ ⟧ # symbolize(𝑛2)- fabricated 𝑛·1·6 := 𝑛·1·3 and 𝑛4·1 # ⟦ left🌵 ↦ 𝑛·1·3, right🌵 ↦ 𝑛4·1, i ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.i, right🌵 ↦ ρ.right🌵.i ⟧, φ ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, not ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.not, right🌵 ↦ ρ.right🌵.not ⟧ ⟧- remembered 𝑛·1·6 ≡ 𝑛·0·11- memoized 𝑛·0·11 ⇛ 𝑛·1·6- remembered 𝑛·0·12 ≡ 𝑛·1·6.not # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.not, right🌵 ↦ ρ.right🌵.not ⟧+ 𝑛4·1 := ⟦ φ ↦ 𝜎4:λ, not ↦ FF-:Δ ⟧ # symbolize(𝑛2 of L_fork)+ fabricated 𝑛·1·7 := 𝑛·1·4 and 𝑛4·1 # ⟦ left🌵 ↦ 𝑛·1·4, right🌵 ↦ 𝑛4·1, i ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.i, right🌵 ↦ ρ.right🌵.i ⟧, φ ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, not ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.not, right🌵 ↦ ρ.right🌵.not ⟧ ⟧+ remembered 𝑛·1·7 ≡ 𝑛·0·11+ memoized 𝑛·0·11 ⇛ 𝑛·1·7+ evaluated 𝑛·1·8 := 𝑛·1·7 # 𝑛·0·11+ remembered 𝑛·0·12 ≡ 𝑛·1·8.not # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.not, right🌵 ↦ ρ.right🌵.not ⟧ morphed 𝑛·0·13 := 𝑛·0·12
test-resources/evaluate-packs/blames-the-lambda-the-operand-was-parked-on.yaml view
@@ -18,5 +18,5 @@ 𝔼(L_entry): 𝔻(ξ.v): 𝕄(ξ.v):- unanswered L_none # 𝕄(L_none:λ)+ unanswered L_none # 𝕄(L_none:λ.foo) stuck L_none
test-resources/evaluate-packs/cuts-a-loop-met-at-a-dispatch-off-an-atom.yaml view
@@ -53,16 +53,18 @@ morphed 𝑛·2·4 := 𝜎1:λ 𝛿·2·1 := 𝔻(𝜎1:λ) 𝛿1·2 := 𝛿·2·1 # 𝔻(ξ.target)- 𝑛·2·5 := 𝜎2:λ # 𝑛+ 𝑛·2·5 := 𝜎2:λ # 𝑛 of L_dataized 𝕄(𝑛·2·5): morphed 𝑛·2·6 := 𝜎2:λ 𝑛·2·7 := 𝑛·2·6 # 𝕄(𝑛·2·5) memoized 𝑛·1·3 ⇛ 𝜎2:λ+ evaluated 𝑛·2·8 := 𝑛·2·7 # 𝑛·1·3 𝛿·1·1 := 𝔻(𝜎2:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.b)- 𝑛·1·5 := 𝜎3:λ # 𝑛+ 𝑛·1·5 := 𝜎3:λ # 𝑛 of L_times 𝕄(𝑛·1·5): morphed 𝑛·1·6 := 𝜎3:λ 𝑛·1·7 := 𝑛·1·6 # 𝕄(𝑛·1·5) memoized 𝑛·2·3 ⇛ 𝜎3:λ- unanswered 𝜎3 # 𝕄(𝜎3:λ)+ evaluated 𝑛·1·8 := 𝑛·1·7 # 𝑛·2·3+ opaque 𝜎3 # 𝕄(𝜎3:λ.q)
test-resources/evaluate-packs/cuts-a-recursion-running-through-evaluate-lines.yaml view
@@ -33,10 +33,11 @@ 𝑛1·1 := 𝑛·0·1 # 𝕄(ξ.next🌵) recalled 𝑛·0·1 ⇒ Φ.loop recalled 𝑛·0·1 ⇒ Φ.loop- looped 𝜎1 := Φ.loop # 𝔼(𝑛1), proven, repeats 𝑛·0·1- 𝑛2·1 := 𝜎1:λ # 𝔼(𝑛1)- 𝑛·1·2 := 𝑛2·1 # 𝑛+ looped 𝜎1 := Φ.loop # 𝔼(𝑛1 of L_loop), proven, repeats 𝑛·0·1+ 𝑛2·1 := 𝜎1:λ # 𝔼(𝑛1 of L_loop)+ 𝑛·1·2 := 𝑛2·1 # 𝑛 of L_loop 𝕄(𝑛·1·2): morphed 𝑛·1·3 := 𝑛2·1 𝑛·1·4 := 𝑛2·1 # 𝕄(𝑛·1·2)- unanswered 𝜎1 # 𝕄(𝜎1:λ)+ evaluated 𝑛·1·5 := 𝑛·1·4 # 𝑛·0·1+ opaque 𝜎1 # 𝕄(𝜎1:λ.φ)
test-resources/evaluate-packs/cuts-a-recursion-that-differs-by-symbols-only.yaml view
@@ -33,7 +33,7 @@ 𝔻(ξ.x): 𝛿·1·1 := 𝔻(𝜎1:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.x)- 𝑛·1·1 := Φ.down( x ↦ 𝜎2:λ ) # 𝑛+ 𝑛·1·1 := Φ.down( x ↦ 𝜎2:λ ) # 𝑛 of L_down 𝕄(𝑛·1·1): 𝑛·1·2 := Φ.down( x ↦ 𝜎2:λ ) 𝑛·1·3 := ⟦ x ↦ 𝜎2:λ, λ ⤍ L_down ⟧@@ -41,6 +41,7 @@ morphed 𝑛·1·4 := 𝑛·1·3 𝑛·1·5 := 𝑛·1·3 # 𝕄(𝑛·1·1) remembered 𝑛·1·3 ≡ 𝑛·0·3+ evaluated 𝑛·1·6 := 𝑛·1·3 # 𝑛·0·3 recalled 𝑛·1·3 ⇒ 𝑛·0·3 recalled 𝑛·0·3 ⇒ 𝑛·0·1( x ↦ 𝜎1:λ ) recalled 𝑛·0·1 ⇒ Φ.down
test-resources/evaluate-packs/cuts-an-entry-that-answers-with-a-firing-of-itself.yaml view
@@ -17,9 +17,10 @@ protocol: | 𝕄(Φ.x): 𝔼(L_loop):- 𝑛·1·1 := L_loop:λ # 𝑛+ 𝑛·1·1 := L_loop:λ # 𝑛 of L_loop 𝕄(𝑛·1·1): morphed 𝑛·1·2 := L_loop:λ 𝑛·1·3 := L_loop:λ # 𝕄(𝑛·1·1)+ evaluated 𝑛·1·4 := L_loop:λ # L_loop:λ looped 𝜎1 # proven, repeats L_loop:λ morphed 𝑛·0·1 := 𝜎1:λ
test-resources/evaluate-packs/dataizes-what-a-morph-operand-of-the-same-entry-brought-down.yaml view
@@ -33,10 +33,11 @@ 𝑛1·1 := 2A-:Δ # 𝕄(ξ.v.φ) 𝔻(𝑛1): 𝛿·1·2 := 2A-- 𝛿2·1 := 𝛿·1·2 # 𝔻(𝑛1)- 𝑛·1·3 := 𝜎2:λ:φ # 𝑛+ 𝛿2·1 := 𝛿·1·2 # 𝔻(𝑛1 of L_entry)+ 𝑛·1·3 := 𝜎2:λ:φ # 𝑛 of L_entry 𝕄(𝑛·1·3): morphed 𝑛·1·4 := 𝜎2:λ:φ 𝑛·1·5 := 𝑛·1·4 # 𝕄(𝑛·1·3)- normalized 𝑛·0·1 := 𝜎2:λ # 𝑛·1·5.φ+ evaluated 𝑛·1·6 := 𝑛·1·5 # ⟦ n ↦ 𝜎1:λ, v ↦ Φ.t:φ, λ ⤍ L_entry ⟧+ normalized 𝑛·0·1 := 𝜎2:λ # 𝑛·1·6.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/defers-a-copy-a-join-passed-through-stay-and-symbolize.yaml view
@@ -63,14 +63,16 @@ deferred 𝜎4 := Φ.step( tup ↦ 𝜎1:λ ) # 𝕄(𝑛·2·5.φ) joined 𝜎5 := 𝛿1·2 ? 𝜎3 : 𝜎4 𝑛·2·6 := 𝜎5:λ+ evaluated 𝑛·2·7 := 𝑛·2·6 # ⟦ c ↦ 𝜎2:λ, a ↦ 01-:Δ, b ↦ 𝑛·2·3, λ ⤍ L_fork ⟧ 𝛿·1·1 := 𝔻(𝜎5:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.x)- 𝑛·1·1 := Φ.num( φ ↦ 𝜎6:λ ) # 𝑛+ 𝑛·1·1 := Φ.num( φ ↦ 𝜎6:λ ) # 𝑛 of L_use 𝕄(𝑛·1·1): normalized 𝑛·1·2 := ∅:φ # Φ.num 𝑛·1·3 := Φ.num( φ ↦ 𝜎6:λ ) 𝑛·1·4 := 𝜎6:λ:φ morphed 𝑛·1·5 := 𝑛·1·4 𝑛·1·6 := 𝑛·1·5 # 𝕄(𝑛·1·1)- normalized 𝑛·0·1 := 𝜎6:λ # 𝑛·1·6.φ+ evaluated 𝑛·1·7 := 𝑛·1·6 # ⟦ x ↦ ⟦ c ↦ 𝜎2:λ, a ↦ 01-:Δ, b ↦ 𝑛·2·3, λ ⤍ L_fork ⟧, λ ⤍ L_use ⟧+ normalized 𝑛·0·1 := 𝜎6:λ # 𝑛·1·7.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/defers-a-copy-whose-phi-reads-nothing-of-its-own.yaml view
@@ -30,9 +30,10 @@ recalled 𝑛·1·3 ⇒ 𝑛·1·1( tup ↦ Φ.items.tail ) recalled 𝑛·1·1 ⇒ Φ.step deferred 𝜎2 := Φ.step( tup ↦ 𝜎1:λ ) # 𝕄(𝑛1.φ)- 𝑛·1·5 := 𝜎2:λ:φ # 𝑛+ 𝑛·1·5 := 𝜎2:λ:φ # 𝑛 of L_hold 𝕄(𝑛·1·5): morphed 𝑛·1·6 := 𝜎2:λ:φ 𝑛·1·7 := 𝑛·1·6 # 𝕄(𝑛·1·5)- normalized 𝑛·0·1 := 𝜎2:λ # 𝑛·1·7.φ+ evaluated 𝑛·1·8 := 𝑛·1·7 # ⟦ b ↦ 𝑛·1·2, λ ⤍ L_hold ⟧+ normalized 𝑛·0·1 := 𝜎2:λ # 𝑛·1·8.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/diverges-on-two-sides-that-do-not-join.yaml view
@@ -77,18 +77,21 @@ normalized 𝑛·1·21 := 00-00-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 00-00-00-00-00-00-00-00 # 0.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_gt 𝕄(𝑛·1·22): normalized 𝑛·1·23 := ⟦ φ ↦ ∅, if(then, else) ↦ L_fork:λ ⟧ # Φ.bool 𝑛·1·24 := Φ.bool( φ ↦ 𝜎1:λ ) 𝑛·1·25 := ⟦ φ ↦ 𝜎1:λ, if(then, else) ↦ L_fork:λ ⟧ morphed 𝑛·1·26 := 𝑛·1·25 𝑛·1·27 := 𝑛·1·26 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·27.if- 𝑛·0·8 := 𝑛·1·24.if( then ↦ 1.0.plus( 2.0 ) )- 𝑛·0·9 := ⟦ then ↦ 1.0.plus( 2.0 ), else ↦ ∅, λ ⤍ L_fork ⟧- 𝑛·0·10 := 𝑛·0·8( else ↦ 3.0.plus( 4.0 ) )- 𝑛·0·11 := ⟦ then ↦ 1.0.plus( 2.0 ), else ↦ 3.0.plus( 4.0 ), λ ⤍ L_fork ⟧+ evaluated 𝑛·1·28 := 𝑛·1·27 # 𝑛·0·6+ normalized 𝑛·0·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·28.if+ shared 𝑛·1 := 1.0.plus( 2.0 )+ 𝑛·0·8 := 𝑛·1·24.if( then ↦ 𝑛·1 )+ 𝑛·0·9 := ⟦ then ↦ 𝑛·1, else ↦ ∅, λ ⤍ L_fork ⟧+ shared 𝑛·2 := 3.0.plus( 4.0 )+ 𝑛·0·10 := 𝑛·0·9( else ↦ 𝑛·2 )+ 𝑛·0·11 := ⟦ then ↦ 𝑛·1, else ↦ 𝑛·2, λ ⤍ L_fork ⟧ 𝔼(L_fork): 𝔻(ξ.ρ): 𝕄(ξ.ρ):
test-resources/evaluate-packs/fabricates-a-formation-holding-the-bytes-its-condition-came-down-to.yaml view
@@ -30,5 +30,6 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := ⟦ φ ↦ Φ.ol, pe ↦ Φ.ki ⟧ fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 3A-:Δ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, pe ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 3A-:Δ, left🌵 ↦ ρ.left🌵.pe, right🌵 ↦ ρ.right🌵.pe ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 3A-:Δ, left🌵 ↦ ρ.left🌵.pe, right🌵 ↦ ρ.right🌵.pe ⟧ # 𝑛·1·3.pe+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 3A-:Δ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 3A-:Δ, left🌵 ↦ ρ.left🌵.pe, right🌵 ↦ ρ.right🌵.pe ⟧ # 𝑛·1·4.pe morphed 𝑛·0·2 := ⟦ λ ⤍ L_join, on🌵 ↦ 3A-:Δ, left🌵 ↦ ρ.left🌵.pe, right🌵 ↦ ρ.right🌵.pe ⟧
test-resources/evaluate-packs/fabricates-a-formation-holding-the-symbol-a-path-of-its-condition-reaches.yaml view
@@ -26,5 +26,6 @@ 𝕄(ξ.right🌵): morphed 𝑛·1·2 := ⟦ φ ↦ Φ.ma, tu ↦ Φ.ip ⟧ fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎5:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, tu ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎5:λ, left🌵 ↦ ρ.left🌵.tu, right🌵 ↦ ρ.right🌵.tu ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎5:λ, left🌵 ↦ ρ.left🌵.tu, right🌵 ↦ ρ.right🌵.tu ⟧ # 𝑛·1·3.tu+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ on🌵 ↦ 𝜎5:λ, left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, λ ⤍ L_join ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎5:λ, left🌵 ↦ ρ.left🌵.tu, right🌵 ↦ ρ.right🌵.tu ⟧ # 𝑛·1·4.tu morphed 𝑛·0·2 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎5:λ, left🌵 ↦ ρ.left🌵.tu, right🌵 ↦ ρ.right🌵.tu ⟧
test-resources/evaluate-packs/fabricates-a-formation-of-two-sides-of-different-shapes.yaml view
@@ -36,5 +36,6 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := Φ.zu:φ fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, ke ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke, right🌵 ↦ ρ.right🌵.ke ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke, right🌵 ↦ ρ.right🌵.ke ⟧ # 𝑛·1·3.ke+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke, right🌵 ↦ ρ.right🌵.ke ⟧ # 𝑛·1·4.ke morphed 𝑛·0·2 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke, right🌵 ↦ ρ.right🌵.ke ⟧
test-resources/evaluate-packs/fails-on-a-lambda-no-entry-answers.yaml view
@@ -14,4 +14,4 @@ fails: "No entry of --symbolic answers the λ function 'L_none'" protocol: | 𝕄(Φ.x):- unanswered L_none # 𝕄(L_none:λ)+ unanswered L_none # 𝕄(L_none:λ.foo)
test-resources/evaluate-packs/fails-on-a-side-whose-morph-got-stuck.yaml view
@@ -26,5 +26,5 @@ 𝛿·1·1 := 𝔻(𝜎1:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.c) 𝕄(ξ.a):- unanswered L_none # 𝕄(L_none:λ)+ unanswered L_none # 𝕄(L_none:λ.x) stuck L_none
test-resources/evaluate-packs/fails-on-an-operand-that-reaches-the-terminator.yaml view
@@ -40,8 +40,9 @@ normalized 𝑛·0·2 := ⟦ n ↦ ∅, v ↦ ∅, λ ⤍ L_entry ⟧ # 𝑛·0·1.mark 𝑛·0·3 := ⟦ n ↦ ∅, v ↦ ∅, λ ⤍ L_entry ⟧( n ↦ 1.0 ) 𝑛·0·4 := ⟦ n ↦ 1.0, v ↦ ∅, λ ⤍ L_entry ⟧- 𝑛·0·5 := 𝑛·0·4( v ↦ Φ.block( buffer ↦ Φ.bytes( φ ↦ 𝜎1:λ ) ).read )- 𝑛·0·6 := ⟦ n ↦ 1.0, v ↦ Φ.block( buffer ↦ Φ.bytes( φ ↦ 𝜎1:λ ) ).read, λ ⤍ L_entry ⟧+ shared 𝑛·1 := Φ.block( buffer ↦ Φ.bytes( φ ↦ 𝜎1:λ ) ).read+ 𝑛·0·5 := 𝑛·0·4( v ↦ 𝑛·1 )+ 𝑛·0·6 := ⟦ n ↦ 1.0, v ↦ 𝑛·1, λ ⤍ L_entry ⟧ 𝔼(L_entry): 𝔻(ξ.n): 𝕄(ξ.n):
test-resources/evaluate-packs/fires-a-formation-once-however-often-it-is-met.yaml view
@@ -46,19 +46,20 @@ 𝑛·1·2 := 7.0 𝑛·1·3 := ⟦ φ ↦ Φ.bytes( φ ↦ 40-1C-00-00-00-00-00-00:Δ ), plus(x) ↦ L_number_plus:λ ⟧ normalized 𝑛·1·4 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·3.plus- 𝑛·1·5 := 𝑛·1·2.plus( x ↦ 5.0.plus( 6.0 ) )- 𝑛·1·6 := ⟦ x ↦ 5.0.plus( 6.0 ), λ ⤍ L_number_plus ⟧+ shared 𝑛·1 := 5.0.plus( 6.0 )+ 𝑛·1·5 := 𝑛·1·2.plus( x ↦ 𝑛·1 )+ 𝑛·1·6 := ⟦ x ↦ 𝑛·1, λ ⤍ L_number_plus ⟧ morphed 𝑛·1·7 := 𝑛·1·6 𝑛1·1 := 𝑛·1·6 # 𝕄(ξ.a) 𝕄(ξ.b): 𝑛·1·8 := 7.0 𝑛·1·9 := ⟦ φ ↦ Φ.bytes( φ ↦ 40-1C-00-00-00-00-00-00:Δ ), plus(x) ↦ L_number_plus:λ ⟧ normalized 𝑛·1·10 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·9.plus- 𝑛·1·11 := 𝑛·1·8.plus( x ↦ 5.0.plus( 6.0 ) )- 𝑛·1·12 := ⟦ x ↦ 5.0.plus( 6.0 ), λ ⤍ L_number_plus ⟧+ 𝑛·1·11 := 𝑛·1·8.plus( x ↦ 𝑛·1 )+ 𝑛·1·12 := ⟦ x ↦ 𝑛·1, λ ⤍ L_number_plus ⟧ morphed 𝑛·1·13 := 𝑛·1·12 𝑛2·1 := 𝑛·1·12 # 𝕄(ξ.b)- 𝔼(L_number_plus): # 𝔼(𝑛1)+ 𝔼(L_number_plus): # 𝔼(𝑛1 of L_pair) 𝔻(ξ.ρ): 𝕄(ξ.ρ): 𝑛·2·1 := 7.0@@ -114,34 +115,38 @@ normalized 𝑛·3·20 := 40-18-00-00-00-00-00-00:Δ # 𝑛·3·19 𝛿·3·2 := 40-18-00-00-00-00-00-00 # 6.0 𝛿2·3 := 𝛿·3·2 # 𝔻(ξ.x)- 𝑛·3·21 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·3·21 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·3·21): 𝑛·3·22 := Φ.number( φ ↦ 𝜎1:λ ) 𝑛·3·23 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·3·24 := 𝑛·3·23 𝑛·3·25 := 𝑛·3·24 # 𝕄(𝑛·3·21) memoized 𝑛·2·16 ⇛ 𝑛·3·25- boxed 𝑛·2·18 := 𝑛·3·25.φ+ evaluated 𝑛·3·26 := 𝑛·3·25 # 𝑛·2·16+ boxed 𝑛·2·18 := 𝑛·3·26.φ normalized 𝑛·2·19 := 𝜎1:λ # 𝑛·2·18 𝛿·2·2 := 𝔻(𝜎1:λ) 𝛿2·2 := 𝛿·2·2 # 𝔻(ξ.x)- 𝑛·2·20 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·2·20 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·2·20): 𝑛·2·21 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·2·22 := ⟦ φ ↦ 𝜎2:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·2·23 := 𝑛·2·22 𝑛·2·24 := 𝑛·2·23 # 𝕄(𝑛·2·20) memoized 𝑛·1·12 ⇛ 𝑛·2·24- 𝑛3·1 := 𝑛·2·24 # 𝔼(𝑛1)- 𝔼(L_number_plus): # 𝔼(𝑛2)+ evaluated 𝑛·2·25 := 𝑛·2·24 # 𝑛·1·12+ 𝑛3·1 := 𝑛·2·24 # 𝔼(𝑛1 of L_pair)+ 𝔼(L_number_plus): # 𝔼(𝑛2 of L_pair) recalled 𝑛·1·12 ⇒ 𝑛·2·24- 𝑛·4·1 := 𝑛·2·21 # 𝑛+ 𝑛·4·1 := 𝑛·2·21 # 𝑛 of L_number_plus 𝑛·4·2 := 𝑛3·1 # 𝕄(𝑛·4·1)- 𝑛4·1 := 𝑛·4·2 # 𝔼(𝑛2)- 𝑛·1·14 := ⟦ a ↦ 𝑛·4·2, b ↦ 𝑛·4·2 ⟧:φ # 𝑛+ evaluated 𝑛·4·3 := 𝑛·4·2 # 𝑛·1·12+ 𝑛4·1 := 𝑛·4·2 # 𝔼(𝑛2 of L_pair)+ 𝑛·1·14 := ⟦ a ↦ 𝑛·4·3, b ↦ 𝑛·4·3 ⟧:φ # 𝑛 of L_pair 𝕄(𝑛·1·14):- morphed 𝑛·1·15 := ⟦ a ↦ 𝑛·4·2, b ↦ 𝑛·4·2 ⟧:φ+ morphed 𝑛·1·15 := ⟦ a ↦ 𝑛·4·3, b ↦ 𝑛·4·3 ⟧:φ 𝑛·1·16 := 𝑛·1·15 # 𝕄(𝑛·1·14) memoized 𝑛·1·17 ⇛ 𝑛·1·16 # ⟦ a ↦ 𝑛·2·1.plus( 𝑛·3·1.plus( 𝑛·3·11 ) ), b ↦ 𝑛·2·1.plus( 𝑛·3·1.plus( 𝑛·3·11 ) ), λ ⤍ L_pair ⟧- normalized 𝑛·0·1 := ⟦ a ↦ 𝑛·4·2, b ↦ 𝑛·4·2 ⟧ # 𝑛·1·16.φ+ evaluated 𝑛·1·18 := 𝑛·1·16 # 𝑛·1·17+ normalized 𝑛·0·1 := ⟦ a ↦ 𝑛·4·3, b ↦ 𝑛·4·3 ⟧ # 𝑛·1·18.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/fires-a-formation-written-in-place-after-a-stay-line.yaml view
@@ -34,15 +34,17 @@ 𝕄(ξ.side🌵): morphed 𝑛·1·1 := 𝑛·0·2 𝑛1·1 := 𝑛·0·2 # 𝕄(ξ.side🌵)- 𝑛2·1 := ⟦ v ↦ Φ.k, λ ⤍ L_box ⟧ # stay(𝑛1)- 𝔼(L_box): # 𝔼(𝑛2)- 𝑛·2·1 := 𝜎2:λ # 𝑛+ 𝑛2·1 := ⟦ v ↦ Φ.k, λ ⤍ L_box ⟧ # stay(𝑛1 of L_probe)+ 𝔼(L_box): # 𝔼(𝑛2 of L_probe)+ 𝑛·2·1 := 𝜎2:λ # 𝑛 of L_box 𝕄(𝑛·2·1): morphed 𝑛·2·2 := 𝜎2:λ 𝑛·2·3 := 𝑛·2·2 # 𝕄(𝑛·2·1)- 𝑛3·1 := 𝑛·2·3 # 𝔼(𝑛2)- 𝑛·1·2 := 𝑛3·1 # 𝑛+ evaluated 𝑛·2·4 := 𝑛·2·3 # ⟦ v ↦ Φ.k, λ ⤍ L_box ⟧+ 𝑛3·1 := 𝑛·2·3 # 𝔼(𝑛2 of L_probe)+ 𝑛·1·2 := 𝑛3·1 # 𝑛 of L_probe 𝕄(𝑛·1·2): morphed 𝑛·1·3 := 𝑛3·1 𝑛·1·4 := 𝑛3·1 # 𝕄(𝑛·1·2)- unanswered 𝜎2 # 𝕄(𝜎2:λ)+ evaluated 𝑛·1·5 := 𝑛·1·4 # 𝑛·0·3+ opaque 𝜎2 # 𝕄(𝜎2:λ.φ)
test-resources/evaluate-packs/fires-a-formation-written-in-place-with-its-voids-filled.yaml view
@@ -45,12 +45,14 @@ 𝕄(ξ.right🌵): morphed 𝑛·1·2 := 𝜎3:λ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.right🌵)- 𝔼(L_box): # 𝔼(𝑛1)- 𝑛·2·1 := 𝜎4:λ # 𝑛+ 𝔼(L_box): # 𝔼(𝑛1 of L_fork)+ 𝑛·2·1 := 𝜎4:λ # 𝑛 of L_box 𝕄(𝑛·2·1): morphed 𝑛·2·2 := 𝜎4:λ 𝑛·2·3 := 𝑛·2·2 # 𝕄(𝑛·2·1)- 𝑛3·1 := 𝑛·2·3 # 𝔼(𝑛1)+ evaluated 𝑛·2·4 := 𝑛·2·3 # 𝑛·0·2+ 𝑛3·1 := 𝑛·2·3 # 𝔼(𝑛1 of L_fork) joined 𝜎5 := 𝛿1·1 ? 𝜎4 : 𝜎3 𝑛·1·3 := 𝜎5:λ- unanswered 𝜎5 # 𝕄(𝜎5:λ)+ evaluated 𝑛·1·4 := 𝑛·1·3 # 𝑛·0·3+ opaque 𝜎5 # 𝕄(𝜎5:λ.φ)
test-resources/evaluate-packs/fires-the-answer-of-an-evaluate-line-on-the-next-line.yaml view
@@ -26,21 +26,24 @@ 𝕄(ξ.a): morphed 𝑛·1·1 := L_first:λ 𝑛1·1 := L_first:λ # 𝕄(ξ.a)- 𝔼(L_first): # 𝔼(𝑛1)- 𝑛·2·1 := L_second:λ # 𝑛+ 𝔼(L_first): # 𝔼(𝑛1 of L_twice)+ 𝑛·2·1 := L_second:λ # 𝑛 of L_first 𝕄(𝑛·2·1): morphed 𝑛·2·2 := L_second:λ 𝑛·2·3 := L_second:λ # 𝕄(𝑛·2·1)- 𝑛2·1 := L_second:λ # 𝔼(𝑛1)- 𝔼(L_second): # 𝔼(𝑛2)- 𝑛·3·1 := 𝜎1:λ:φ # 𝑛+ evaluated 𝑛·2·4 := L_second:λ # L_first:λ+ 𝑛2·1 := L_second:λ # 𝔼(𝑛1 of L_twice)+ 𝔼(L_second): # 𝔼(𝑛2 of L_twice)+ 𝑛·3·1 := 𝜎1:λ:φ # 𝑛 of L_second 𝕄(𝑛·3·1): morphed 𝑛·3·2 := 𝜎1:λ:φ 𝑛·3·3 := 𝑛·3·2 # 𝕄(𝑛·3·1)- 𝑛3·1 := 𝑛·3·3 # 𝔼(𝑛2)- 𝑛·1·2 := 𝑛3·1 # 𝑛+ evaluated 𝑛·3·4 := 𝑛·3·3 # L_second:λ+ 𝑛3·1 := 𝑛·3·3 # 𝔼(𝑛2 of L_twice)+ 𝑛·1·2 := 𝑛3·1 # 𝑛 of L_twice 𝕄(𝑛·1·2): morphed 𝑛·1·3 := 𝑛3·1 𝑛·1·4 := 𝑛3·1 # 𝕄(𝑛·1·2)- normalized 𝑛·0·1 := 𝜎1:λ # 𝑛·1·4.φ+ evaluated 𝑛·1·5 := 𝑛·1·4 # ⟦ a ↦ L_first:λ, λ ⤍ L_twice ⟧+ normalized 𝑛·0·1 := 𝜎1:λ # 𝑛·1·5.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/fires-the-arguments-of-a-copy-a-defer-line-defers.yaml view
@@ -64,7 +64,7 @@ 𝔻(ξ.x): 𝛿·3·1 := 2A- 𝛿1·3 := 𝛿·3·1 # 𝔻(ξ.x)- 𝑛·3·1 := Φ.num( φ ↦ 𝜎4:λ ) # 𝑛+ 𝑛·3·1 := Φ.num( φ ↦ 𝜎4:λ ) # 𝑛 of L_inc 𝕄(𝑛·3·1): normalized 𝑛·3·2 := ∅:φ # Φ.num 𝑛·3·3 := Φ.num( φ ↦ 𝜎4:λ )@@ -72,16 +72,19 @@ morphed 𝑛·3·5 := 𝑛·3·4 𝑛·3·6 := 𝑛·3·5 # 𝕄(𝑛·3·1) remembered 𝑛·3·6 ≡ 𝑛·2·10- deferred 𝜎5 := Φ.box( x ↦ 𝜎1:λ, w ↦ 𝑛·3·6 ) # 𝕄(𝑛2.φ)+ evaluated 𝑛·3·7 := 𝑛·3·6 # 𝑛·2·10+ deferred 𝜎5 := Φ.box( x ↦ 𝜎1:λ, w ↦ 𝑛·3·7 ) # 𝕄(𝑛2.φ) joined 𝜎6 := 𝛿1·2 ? 𝜎3 : 𝜎5 𝑛·2·12 := 𝜎6:λ+ evaluated 𝑛·2·13 := 𝑛·2·12 # ⟦ c ↦ 𝜎2:λ, a ↦ 𝜎3:λ, b ↦ 𝑛·2·5, λ ⤍ L_fork ⟧ 𝛿·1·1 := 𝔻(𝜎6:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.x)- 𝑛·1·1 := Φ.num( φ ↦ 𝜎7:λ ) # 𝑛+ 𝑛·1·1 := Φ.num( φ ↦ 𝜎7:λ ) # 𝑛 of L_inc 𝕄(𝑛·1·1): 𝑛·1·2 := Φ.num( φ ↦ 𝜎7:λ ) 𝑛·1·3 := 𝜎7:λ:φ morphed 𝑛·1·4 := 𝑛·1·3 𝑛·1·5 := 𝑛·1·4 # 𝕄(𝑛·1·1)- normalized 𝑛·0·1 := 𝜎7:λ # 𝑛·1·5.φ+ evaluated 𝑛·1·6 := 𝑛·1·5 # ⟦ x ↦ ⟦ c ↦ 𝜎2:λ, a ↦ 𝜎3:λ, b ↦ 𝑛·2·5, λ ⤍ L_fork ⟧, λ ⤍ L_inc ⟧+ normalized 𝑛·0·1 := 𝜎7:λ # 𝑛·1·6.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/fires-what-a-rewrite-line-unwrapped.yaml view
@@ -32,16 +32,18 @@ 𝕄(ξ.x): morphed 𝑛·1·1 := L_inner:λ:φ 𝑛1·1 := 𝑛·1·1 # 𝕄(ξ.x)- 𝑛2·1 := L_inner:λ # rewrite(𝑛1)- 𝔼(L_inner): # 𝔼(𝑛2)- 𝑛·2·1 := 𝜎1:λ:φ # 𝑛+ 𝑛2·1 := L_inner:λ # rewrite(𝑛1 of L_pick)+ 𝔼(L_inner): # 𝔼(𝑛2 of L_pick)+ 𝑛·2·1 := 𝜎1:λ:φ # 𝑛 of L_inner 𝕄(𝑛·2·1): morphed 𝑛·2·2 := 𝜎1:λ:φ 𝑛·2·3 := 𝑛·2·2 # 𝕄(𝑛·2·1)- 𝑛3·1 := 𝑛·2·3 # 𝔼(𝑛2)- 𝑛·1·2 := 𝑛3·1 # 𝑛+ evaluated 𝑛·2·4 := 𝑛·2·3 # L_inner:λ+ 𝑛3·1 := 𝑛·2·3 # 𝔼(𝑛2 of L_pick)+ 𝑛·1·2 := 𝑛3·1 # 𝑛 of L_pick 𝕄(𝑛·1·2): morphed 𝑛·1·3 := 𝑛3·1 𝑛·1·4 := 𝑛3·1 # 𝕄(𝑛·1·2)- normalized 𝑛·0·1 := 𝜎1:λ # 𝑛·1·4.φ+ evaluated 𝑛·1·5 := 𝑛·1·4 # ⟦ x ↦ 𝑛·1·1, λ ⤍ L_pick ⟧+ normalized 𝑛·0·1 := 𝜎1:λ # 𝑛·1·5.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/guards-a-side-holding-no-symbol-against-a-bottom.yaml view
@@ -35,6 +35,7 @@ 𝑛2·1 := ⊥ # 𝕄(ξ.right🌵) guarded 𝛿1·1 ? 𝑛1·1 : 𝑛2·1 # where 𝑛2·1 is ⊥ 𝑛·1·3 := 𝑛·1·1- normalized 𝑛·0·1 := Φ.k # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ λ ⤍ L_fork, on🌵 ↦ 00-:Δ, left🌵 ↦ 𝑛·1·3, right🌵 ↦ ⊥ ⟧+ normalized 𝑛·0·1 := Φ.k # 𝑛·1·4.φ normalized 𝑛·0·2 := ⟦⟧:q # Φ.k morphed 𝑛·0·3 := 𝑛·0·2
test-resources/evaluate-packs/hands-a-named-argument-to-both-sides-of-an-attribute-of-a-fabricated-formation.yaml view
@@ -37,7 +37,8 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := ⟦ ke(x) ↦ x:k ⟧ fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, ke(x) ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧ # 𝑛·1·3.ke+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧ # 𝑛·1·4.ke 𝑛·0·2 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧( x ↦ 𝜎2:λ ) 𝑛·0·3 := ⟦ λ ⤍ L_join, x ↦ 𝜎2:λ, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧ 𝔼(L_join):@@ -50,5 +51,6 @@ 𝕄(ξ.right🌵): morphed 𝑛·2·6 := 𝑛·2·5 𝑛·2·7 := 𝑛·2·6- normalized 𝑛·0·4 := 𝜎2:λ # 𝑛·2·7.k+ evaluated 𝑛·2·8 := 𝑛·2·7 # 𝑛·0·3+ normalized 𝑛·0·4 := 𝜎2:λ # 𝑛·2·8.k morphed 𝑛·0·5 := 𝑛·0·4
test-resources/evaluate-packs/hands-a-positional-argument-to-both-sides-of-an-attribute-of-a-fabricated-formation.yaml view
@@ -37,7 +37,8 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := ⟦ ke(x) ↦ x:k ⟧ fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, ke(x) ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧ # 𝑛·1·3.ke+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧ # 𝑛·1·4.ke 𝑛·0·2 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧( x ↦ 𝜎2:λ ) 𝑛·0·3 := ⟦ λ ⤍ L_join, x ↦ 𝜎2:λ, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x ) ⟧ 𝔼(L_join):@@ -50,5 +51,6 @@ 𝕄(ξ.right🌵): morphed 𝑛·2·6 := 𝑛·2·5 𝑛·2·7 := 𝑛·2·6- normalized 𝑛·0·4 := 𝜎2:λ # 𝑛·2·7.k+ evaluated 𝑛·2·8 := 𝑛·2·7 # 𝑛·0·3+ normalized 𝑛·0·4 := 𝜎2:λ # 𝑛·2·8.k morphed 𝑛·0·5 := 𝑛·0·4
test-resources/evaluate-packs/hands-a-side-of-a-fabricated-formation-only-the-voids-its-attribute-leaves.yaml view
@@ -40,7 +40,8 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := ⟦ ke(x, w) ↦ x:k ⟧ fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, ke(x, w) ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x, w ↦ w ) ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, x ↦ ∅, w ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x, w ↦ w ) ⟧ # 𝑛·1·3.ke+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, x ↦ ∅, w ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x, w ↦ w ) ⟧ # 𝑛·1·4.ke 𝑛·0·2 := ⟦ λ ⤍ L_join, x ↦ ∅, w ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x, w ↦ w ) ⟧( x ↦ 𝜎2:λ:φ ) 𝑛·0·3 := ⟦ λ ⤍ L_join, x ↦ 𝜎2:λ:φ, w ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke( x ↦ x ), right🌵 ↦ ρ.right🌵.ke( x ↦ x, w ↦ w ) ⟧ 𝔼(L_join):@@ -55,12 +56,14 @@ 𝕄(ξ.right🌵): morphed 𝑛·2·8 := 𝑛·2·7 fabricated 𝑛·2·9 := 𝑛·2·3 and 𝑛·2·8 # ⟦ left🌵 ↦ 𝑛·2·3, right🌵 ↦ 𝑛·2·8, x ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.x, right🌵 ↦ ρ.right🌵.x ⟧, k ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.k, right🌵 ↦ ρ.right🌵.k ⟧, w ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.w, right🌵 ↦ ρ.right🌵.w ⟧ ⟧- normalized 𝑛·0·4 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.k, right🌵 ↦ ρ.right🌵.k ⟧ # 𝑛·2·9.k+ evaluated 𝑛·2·10 := 𝑛·2·9 # 𝑛·0·3+ normalized 𝑛·0·4 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.k, right🌵 ↦ ρ.right🌵.k ⟧ # 𝑛·2·10.k 𝔼(L_join): 𝕄(ξ.left🌵): morphed 𝑛·3·1 := 𝜎2:λ:φ 𝕄(ξ.right🌵): morphed 𝑛·3·2 := 𝑛·3·1 𝑛·3·3 := 𝑛·3·1- normalized 𝑛·0·5 := 𝜎2:λ # 𝑛·3·3.φ+ evaluated 𝑛·3·4 := 𝑛·3·3 # ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.k, right🌵 ↦ ρ.right🌵.k ⟧+ normalized 𝑛·0·5 := 𝜎2:λ # 𝑛·3·4.φ morphed 𝑛·0·6 := 𝑛·0·5
test-resources/evaluate-packs/heads-the-block-of-a-dataize-operand-with-the-operand.yaml view
@@ -58,11 +58,12 @@ normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·22): 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ ) 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·1·25 := 𝑛·1·24 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := 𝜎1:λ # 𝑛·1·26.φ+ evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·6+ normalized 𝑛·0·7 := 𝜎1:λ # 𝑛·1·27.φ morphed 𝑛·0·8 := 𝑛·0·7
test-resources/evaluate-packs/heads-the-block-of-a-morph-operand-with-the-operand.yaml view
@@ -23,9 +23,10 @@ 𝑛·1·3 := ⟦ φ ↦ Φ.bytes( φ ↦ 40-14-00-00-00-00-00-00:Δ ), neg ↦ ⟦⟧ ⟧ morphed 𝑛·1·4 := 𝑛·1·3 𝑛1·1 := 𝑛·1·4 # 𝕄(ξ.x)- 𝑛·1·5 := 𝜎1:λ:φ # 𝑛+ 𝑛·1·5 := 𝜎1:λ:φ # 𝑛 of L_kept 𝕄(𝑛·1·5): morphed 𝑛·1·6 := 𝜎1:λ:φ 𝑛·1·7 := 𝑛·1·6 # 𝕄(𝑛·1·5)- normalized 𝑛·0·1 := 𝜎1:λ # 𝑛·1·7.φ+ evaluated 𝑛·1·8 := 𝑛·1·7 # ⟦ x ↦ 𝑛·1·2, λ ⤍ L_kept ⟧+ normalized 𝑛·0·1 := 𝜎1:λ # 𝑛·1·8.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-bare-symbol-a-cast-brought-down-two-decorators.yaml view
@@ -42,5 +42,6 @@ cast 𝑛3·1 := ⟦ φ ↦ ⟦ φ ↦ 𝜎2:λ, if ↦ Φ.zu ⟧, x ↦ Φ.ty ⟧ # 𝑛1·1 up to 𝑛2·1 joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 𝑛·1·3 := ⟦ φ ↦ ⟦ φ ↦ 𝜎4:λ, if ↦ Φ.zu ⟧, x ↦ Φ.ty ⟧- normalized 𝑛·0·1 := ⟦ φ ↦ 𝜎4:λ, if ↦ Φ.zu ⟧ # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝜎2:λ, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ φ ↦ 𝜎4:λ, if ↦ Φ.zu ⟧ # 𝑛·1·4.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-bare-symbol-a-cast-brought-into-a-decorator-of-a-fork.yaml view
@@ -47,7 +47,8 @@ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.right🌵) cast 𝑛6·1 := ⟦ k ↦ ⟦⟧, φ ↦ 𝜎3:λ ⟧ # 𝑛2·1 up to 𝑛·1·1 fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛6·1 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛6·1, k ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.k, right🌵 ↦ ρ.right🌵.k ⟧, φ ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝜎3:λ ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ # 𝑛·1·4.φ 𝔼(L_fork): 𝔻(ξ.on🌵): 𝛿·2·1 := 𝔻(𝜎1:λ)@@ -58,7 +59,7 @@ 𝕄(ξ.right🌵): morphed 𝑛·2·2 := 𝑛2·1 𝑛2·2 := 𝑛2·1 # 𝕄(ξ.right🌵)- 𝔼(L_fork): # 𝔼(𝑛1)+ 𝔼(L_fork): # 𝔼(𝑛1 of L_fork) 𝔻(ξ.on🌵): 𝛿·3·1 := 𝔻(𝜎4:λ) 𝛿1·3 := 𝛿·3·1 # 𝔻(ξ.on🌵)@@ -70,9 +71,11 @@ 𝑛2·3 := 𝑛·3·2 # 𝕄(ξ.right🌵) joined 𝜎7 := 𝛿1·3 ? 𝜎5 : 𝜎6 𝑛·3·3 := 𝜎7:λ:φ- 𝑛3·2 := 𝑛·3·3 # 𝔼(𝑛1)+ evaluated 𝑛·3·4 := 𝑛·3·3 # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎4:λ, left🌵 ↦ 𝑛·3·1, right🌵 ↦ 𝑛·3·2 ⟧+ 𝑛3·2 := 𝑛·3·3 # 𝔼(𝑛1 of L_fork) cast 𝑛6·2 := 𝜎3:λ:φ # 𝑛2·2 up to 𝑛3·2 joined 𝜎8 := 𝛿1·2 ? 𝜎7 : 𝜎3 𝑛·2·3 := 𝜎8:λ:φ- normalized 𝑛·0·2 := 𝜎8:λ # 𝑛·2·3.φ+ evaluated 𝑛·2·4 := 𝑛·2·3 # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧+ normalized 𝑛·0·2 := 𝜎8:λ # 𝑛·2·4.φ morphed 𝑛·0·3 := 𝑛·0·2
test-resources/evaluate-packs/joins-a-bare-symbol-a-cast-brought-into-a-side-holding-a-symbol-off-its-phi-chain.yaml view
@@ -40,5 +40,6 @@ cast 𝑛3·1 := ⟦ φ ↦ 𝜎2:λ, ke ↦ 𝜎4:λ ⟧ # 𝑛1·1 up to 𝑛2·1 joined 𝜎5 := 𝛿1·1 ? 𝜎2 : 𝜎3 𝑛·1·3 := ⟦ φ ↦ 𝜎5:λ, ke ↦ 𝜎4:λ ⟧- normalized 𝑛·0·1 := 𝜎5:λ # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝜎2:λ, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := 𝜎5:λ # 𝑛·1·4.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-bare-symbol-a-cast-brought-into-the-shape-of-a-decorator.yaml view
@@ -46,5 +46,6 @@ cast 𝑛20·1 := ⟦ k ↦ ⟦⟧, φ ↦ 𝜎3:λ ⟧ # 𝑛14·1 up to 𝑛13·1 joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 𝑛·1·3 := ⟦ k ↦ ⟦⟧, φ ↦ 𝜎4:λ ⟧- normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝜎3:λ ⟧+ normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·4.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-bool-literal-a-rewrite-line-brought-into-the-shape-of-the-other-side.yaml view
@@ -52,8 +52,9 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := ⟦ φ ↦ 𝜎3:λ, kq ↦ Φ.bool( if ↦ 01-:Δ ) ⟧ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.b)- 𝑛3·1 := ⟦ φ ↦ 𝜎2:λ, kq ↦ Φ.bool( if ↦ 01-:Δ ) ⟧ # rewrite(𝑛1)+ 𝑛3·1 := ⟦ φ ↦ 𝜎2:λ, kq ↦ Φ.bool( if ↦ 01-:Δ ) ⟧ # rewrite(𝑛1 of L_fork) joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 𝑛·1·3 := ⟦ φ ↦ 𝜎4:λ, kq ↦ Φ.bool( if ↦ 01-:Δ ) ⟧- normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·4.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-bottom-into-the-shape-of-the-other-side.yaml view
@@ -38,5 +38,6 @@ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.right🌵) joined 𝜎4 := 𝛿1·1 ? 𝜎3 : 𝜎2 # where 𝜎3 is ⊥ 𝑛·1·3 := ⟦ k ↦ ⟦⟧, φ ↦ 𝜎4:λ ⟧- normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ⊥, right🌵 ↦ 𝑛·1·2 ⟧+ normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·4.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-number-with-a-formation-an-undress-took-the-number-out-of.yaml view
@@ -49,12 +49,13 @@ morphed 𝑛·1·9 := 𝑛·1·8 𝑛2·1 := 𝑛·1·9 # undress(ξ.right🌵) symbolized 𝜎2 := 40-45-00-00-00-00-00-00 # 42.0- 𝑛3·1 := ⟦ φ ↦ Φ.bytes( φ ↦ 𝜎2:λ ), neg ↦ ρ:φ ⟧ # symbolize(𝑛1)+ 𝑛3·1 := ⟦ φ ↦ Φ.bytes( φ ↦ 𝜎2:λ ), neg ↦ ρ:φ ⟧ # symbolize(𝑛1 of L_fork) symbolized 𝜎3 := 40-1C-00-00-00-00-00-00 # 7.0- 𝑛4·1 := ⟦ φ ↦ Φ.bytes( φ ↦ 𝜎3:λ ), neg ↦ ρ:φ ⟧ # symbolize(𝑛2)+ 𝑛4·1 := ⟦ φ ↦ Φ.bytes( φ ↦ 𝜎3:λ ), neg ↦ ρ:φ ⟧ # symbolize(𝑛2 of L_fork) joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 𝑛·1·10 := ⟦ φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ), neg ↦ ρ:φ ⟧- normalized 𝑛·0·1 := Φ.bytes( φ ↦ 𝜎4:λ ) # 𝑛·1·10.φ+ evaluated 𝑛·1·11 := 𝑛·1·10 # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ 𝑛·1·2, right🌵 ↦ 𝑛·1·5 ⟧+ normalized 𝑛·0·1 := Φ.bytes( φ ↦ 𝜎4:λ ) # 𝑛·1·11.φ normalized 𝑛·0·2 := ∅:φ # Φ.bytes 𝑛·0·3 := Φ.bytes( φ ↦ 𝜎4:λ ) 𝑛·0·4 := 𝜎4:λ:φ
test-resources/evaluate-packs/joins-a-side-a-morph-line-brought-down-from-what-a-rewrite-line-unwrapped.yaml view
@@ -46,12 +46,13 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := Φ.t:φ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.b)- 𝑛3·1 := Φ.t # rewrite(𝑛2)+ 𝑛3·1 := Φ.t # rewrite(𝑛2 of L_fork) 𝕄(𝑛3): remembered 𝑛·1·3 ≡ Φ.t # 𝜎3:λ:φ morphed 𝑛·1·4 := 𝑛·1·3- 𝑛4·1 := 𝑛·1·4 # 𝕄(𝑛3)+ 𝑛4·1 := 𝑛·1·4 # 𝕄(𝑛3 of L_fork) joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 𝑛·1·5 := 𝜎4:λ:φ- normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·5.φ+ evaluated 𝑛·1·6 := 𝑛·1·5 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·6.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-side-an-evaluate-line-fired-with-a-bool-it-left-as-it-is.yaml view
@@ -42,15 +42,17 @@ 𝑛·1·4 := 𝜎2:λ:φ morphed 𝑛·1·5 := 𝑛·1·4 𝑛2·1 := 𝑛·1·5 # 𝕄(ξ.b)- 𝔼(L_eq): # 𝔼(𝑛1)- 𝑛·2·1 := Φ.bool( φ ↦ 𝜎3:λ ) # 𝑛+ 𝔼(L_eq): # 𝔼(𝑛1 of L_fork)+ 𝑛·2·1 := Φ.bool( φ ↦ 𝜎3:λ ) # 𝑛 of L_eq 𝕄(𝑛·2·1): 𝑛·2·2 := Φ.bool( φ ↦ 𝜎3:λ ) 𝑛·2·3 := 𝜎3:λ:φ morphed 𝑛·2·4 := 𝑛·2·3 𝑛·2·5 := 𝑛·2·4 # 𝕄(𝑛·2·1)- 𝑛3·1 := 𝑛·2·5 # 𝔼(𝑛1)+ evaluated 𝑛·2·6 := 𝑛·2·5 # L_eq:λ+ 𝑛3·1 := 𝑛·2·5 # 𝔼(𝑛1 of L_fork) joined 𝜎4 := 𝛿1·1 ? 𝜎3 : 𝜎2 𝑛·1·6 := 𝜎4:λ:φ- normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·6.φ+ evaluated 𝑛·1·7 := 𝑛·1·6 # ⟦ c ↦ 𝜎1:λ, a ↦ L_eq:λ, b ↦ 𝑛·1·3, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·7.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-side-holding-a-datum-a-symbolize-turned-into-a-symbol.yaml view
@@ -41,10 +41,11 @@ morphed 𝑛·1·2 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎2:λ ) ):φ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.b) symbolized 𝜎4 := 3F-F0-00-00-00-00-00-00 # 1.0- 𝑛3·1 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ) ):φ # symbolize(𝑛1)+ 𝑛3·1 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ) ):φ # symbolize(𝑛1 of L_fork) joined 𝜎5 := 𝛿1·1 ? 𝜎4 : 𝜎2 𝑛·1·3 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎5:λ ) ):φ- normalized 𝑛·0·1 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎5:λ ) ) # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎3:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎5:λ ) ) # 𝑛·1·4.φ normalized 𝑛·0·2 := ∅:φ # Φ.number 𝑛·0·3 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎5:λ ) ) 𝑛·0·4 := Φ.bytes( φ ↦ 𝜎5:λ ):φ
test-resources/evaluate-packs/joins-a-side-reading-the-rho-it-binds-in-a-fabricated-formation.yaml view
@@ -39,7 +39,8 @@ 𝕄(ξ.b): morphed 𝑛·1·3 := 𝜎3:λ:k:φ fabricated 𝑛·1·4 := 𝑛·1·2 and 𝑛·1·3 # ⟦ tu ↦ ∅, left🌵 ↦ 𝑛·1·2( tu ↦ tu ), right🌵 ↦ 𝑛·1·3, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ # 𝑛·1·4.φ+ evaluated 𝑛·1·5 := 𝑛·1·4 # ⟦ c ↦ 𝜎1:λ, a ↦ Φ.t, b ↦ 𝑛·1·3, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ # 𝑛·1·5.φ 𝔼(L_join): 𝑛·2·1 := Φ.t( tu ↦ ⊥ ) # 𝕄(ξ.left🌵) 𝑛·2·2 := ⟦ tu ↦ ⊥, φ ↦ ρ.s ⟧@@ -51,5 +52,6 @@ morphed 𝑛·2·5 := 𝜎3:λ:k joined 𝜎4 := ξ.on🌵 ? 𝜎2 : 𝜎3 𝑛·2·6 := 𝜎4:λ:k- normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·2·6.k+ evaluated 𝑛·2·7 := 𝑛·2·6 # ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧+ normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·2·7.k morphed 𝑛·0·3 := 𝑛·0·2
test-resources/evaluate-packs/joins-a-side-that-dispatches-on-a-terminator.yaml view
@@ -41,5 +41,6 @@ 𝑛2·1 := 𝑛·1·4 # 𝕄(ξ.right🌵) joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 # where 𝜎3 is ⊥ raised by 𝑛·1·4 𝑛·1·6 := ⟦ k ↦ ⟦⟧, φ ↦ 𝜎4:λ ⟧- normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·6.φ+ evaluated 𝑛·1·7 := 𝑛·1·6 # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ 𝑛·1·1, right🌵 ↦ Φ.throw( "bad" ).q ⟧+ normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·7.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-side-that-raises-through-a-terminator.yaml view
@@ -55,5 +55,6 @@ 𝑛2·1 := 𝑛·1·4 # 𝕄(ξ.right🌵) joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 # where 𝜎3 is ⊥ raised by 𝑛·1·4 𝑛·1·6 := ⟦ k ↦ ⟦⟧, φ ↦ 𝜎4:λ ⟧- normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·6.φ+ evaluated 𝑛·1·7 := 𝑛·1·6 # ⟦ λ ⤍ L_fork, on🌵 ↦ 𝜎1:λ, left🌵 ↦ 𝑛·1·1, right🌵 ↦ Φ.throw( "bad" ) ⟧+ normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·7.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-side-whose-operand-raises.yaml view
@@ -43,10 +43,12 @@ remembered 𝑛·1·4 ≡ 𝑛·1·2( x ↦ L_throw:λ ) 𝔼(L_wrap): 𝑛·2·1 := ⊥+ evaluated 𝑛·2·2 := ⊥ # 𝑛·1·4 normalized 𝑛·1·5 := ⊥ # ⊥.φ morphed 𝑛·1·6 := ⊥ 𝑛2·1 := ⊥ # 𝕄(ξ.r) joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 # where 𝜎3 is ⊥ 𝑛·1·7 := 𝜎4:λ:φ- normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·7.φ+ evaluated 𝑛·1·8 := 𝑛·1·7 # ⟦ λ ⤍ L_pick, c ↦ 𝜎1:λ, l ↦ 𝑛·1·1, r ↦ Φ.wrap( L_throw:λ ).φ ⟧+ normalized 𝑛·0·1 := 𝜎4:λ # 𝑛·1·8.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/joins-a-side-whose-void-the-fabricated-formation-holds.yaml view
@@ -39,7 +39,8 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := 𝜎3:λ:k:φ fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ tu ↦ ∅, left🌵 ↦ 𝑛·1·1( tu ↦ tu ), right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ # 𝑛·1·4.φ 𝔼(L_join): 𝑛·2·1 := 𝑛·1·1( tu ↦ ⊥ ) # 𝕄(ξ.left🌵) 𝑛·2·2 := ⟦ φ ↦ 𝜎2:λ:k, tu ↦ ⊥ ⟧@@ -49,5 +50,6 @@ morphed 𝑛·2·4 := 𝜎3:λ:k joined 𝜎4 := ξ.on🌵 ? 𝜎2 : 𝜎3 𝑛·2·5 := 𝜎4:λ:k- normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·2·5.k+ evaluated 𝑛·2·6 := 𝑛·2·5 # ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧+ normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·2·6.k morphed 𝑛·0·3 := 𝑛·0·2
test-resources/evaluate-packs/joins-again-the-attribute-of-a-fabricated-formation.yaml view
@@ -38,7 +38,8 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := Φ.hx( 𝜎3:λ ):φ fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, ob ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ob, right🌵 ↦ ρ.right🌵.ob ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧ # 𝑛·1·4.φ 𝔼(L_join): 𝕄(ξ.left🌵): remembered 𝑛·2·1 ≡ Φ.hx # ⟦ ke ↦ ∅, φ ↦ ke ⟧@@ -53,5 +54,6 @@ morphed 𝑛·2·7 := 𝑛·2·6 joined 𝜎4 := ξ.on🌵 ? 𝜎2 : 𝜎3 𝑛·2·8 := ⟦ ke ↦ 𝜎4:λ, φ ↦ ke ⟧- normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·2·8.φ+ evaluated 𝑛·2·9 := 𝑛·2·8 # ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧+ normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·2·9.φ morphed 𝑛·0·3 := 𝑛·0·2
test-resources/evaluate-packs/joins-an-attribute-named-left-of-a-copy-in-a-fabricated-formation.yaml view
@@ -39,7 +39,8 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := 𝜎3:λ:left:ke fabricated 𝑛·1·3 := 𝑛·1·1 and 𝑛·1·2 # ⟦ left🌵 ↦ 𝑛·1·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, ke ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke, right🌵 ↦ ρ.right🌵.ke ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke, right🌵 ↦ ρ.right🌵.ke ⟧ # 𝑛·1·3.ke+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke, right🌵 ↦ ρ.right🌵.ke ⟧ # 𝑛·1·4.ke 𝔼(L_join): 𝕄(ξ.left🌵): morphed 𝑛·2·1 := 𝜎2:λ:left@@ -47,5 +48,6 @@ morphed 𝑛·2·2 := 𝜎3:λ:left joined 𝜎4 := ξ.on🌵 ? 𝜎2 : 𝜎3 𝑛·2·3 := 𝜎4:λ:left- normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·2·3.left+ evaluated 𝑛·2·4 := 𝑛·2·3 # ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.ke, right🌵 ↦ ρ.right🌵.ke ⟧+ normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·2·4.left morphed 𝑛·0·3 := 𝑛·0·2
test-resources/evaluate-packs/joins-two-numbers-into-one-symbol-keeping-the-constant-a-method-holds.yaml view
@@ -45,10 +45,11 @@ morphed 𝑛·1·7 := 𝑛·1·6 𝑛2·1 := 𝑛·1·7 # 𝕄(ξ.b) symbolized 𝜎4 := 40-45-00-00-00-00-00-00 # 42.0- 𝑛3·1 := ⟦ φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ), neg ↦ ρ.times( x ↦ -1.0 ):φ ⟧ # symbolize(𝑛1)+ 𝑛3·1 := ⟦ φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ), neg ↦ ρ.times( x ↦ -1.0 ):φ ⟧ # symbolize(𝑛1 of L_fork) joined 𝜎5 := 𝛿1·1 ? 𝜎4 : 𝜎2 𝑛·1·8 := ⟦ φ ↦ Φ.bytes( φ ↦ 𝜎5:λ ), neg ↦ ρ.times( x ↦ -1.0 ):φ ⟧- normalized 𝑛·0·1 := Φ.bytes( φ ↦ 𝜎5:λ ) # 𝑛·1·8.φ+ evaluated 𝑛·1·9 := 𝑛·1·8 # ⟦ c ↦ 𝜎3:λ, a ↦ 𝑛·1·2, b ↦ 𝑛·1·5, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := Φ.bytes( φ ↦ 𝜎5:λ ) # 𝑛·1·9.φ normalized 𝑛·0·2 := ∅:φ # Φ.bytes 𝑛·0·3 := Φ.bytes( φ ↦ 𝜎5:λ ) 𝑛·0·4 := 𝜎5:λ:φ
test-resources/evaluate-packs/joins-two-sides-a-stay-brought-to-one-shape.yaml view
@@ -44,11 +44,12 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎2:λ ) ):φ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.b)- 𝑛3·1 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎1:λ ) ):φ # stay(𝑛1)+ 𝑛3·1 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎1:λ ) ):φ # stay(𝑛1 of L_fork) joined 𝜎4 := 𝛿1·1 ? 𝜎1 : 𝜎2 𝑛·1·3 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ) ):φ remembered 𝑛·1·3 ≡ 𝑛·0·1- normalized 𝑛·0·2 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ), ρ ↦ Φ.number( φ ↦ Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ) ) ) ) # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # 𝑛·0·1+ normalized 𝑛·0·2 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ), ρ ↦ Φ.number( φ ↦ Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ) ) ) ) # 𝑛·1·4.φ normalized 𝑛·0·3 := ∅:φ # Φ.number 𝑛·0·4 := Φ.number( φ ↦ Φ.bytes( φ ↦ 𝜎4:λ ) ) 𝑛·0·5 := Φ.bytes( φ ↦ 𝜎4:λ ):φ
test-resources/evaluate-packs/joins-two-sides-differing-in-a-datum-a-symbolize-found-off-the-phi-chain.yaml view
@@ -41,10 +41,11 @@ morphed 𝑛·1·2 := Φ.bool( if ↦ 𝜎2:λ:φ ):φ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.b) symbolized 𝜎3 := FF-- 𝑛3·1 := Φ.bool( if ↦ 𝜎3:λ:φ ):φ # symbolize(𝑛1)+ 𝑛3·1 := Φ.bool( if ↦ 𝜎3:λ:φ ):φ # symbolize(𝑛1 of L_fork) joined 𝜎4 := 𝛿1·1 ? 𝜎3 : 𝜎2 𝑛·1·3 := Φ.bool( if ↦ 𝜎4:λ:φ ):φ- normalized 𝑛·0·1 := Φ.bool( if ↦ 𝜎4:λ:φ, ρ ↦ 𝑛·1·3 ) # 𝑛·1·3.φ+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := Φ.bool( if ↦ 𝜎4:λ:φ, ρ ↦ 𝑛·1·4 ) # 𝑛·1·4.φ remembered 𝑛·0·2 ≡ Φ.bool # ⟦ if ↦ ∅, φ ↦ if ⟧ 𝑛·0·3 := Φ.bool( if ↦ 𝜎4:λ:φ ) 𝑛·0·4 := ⟦ if ↦ 𝜎4:λ:φ, φ ↦ if ⟧
test-resources/evaluate-packs/joins-two-sides-that-differ-only-in-symbols.yaml view
@@ -75,18 +75,21 @@ normalized 𝑛·1·21 := 00-00-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 00-00-00-00-00-00-00-00 # 0.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_gt 𝕄(𝑛·1·22): normalized 𝑛·1·23 := ⟦ φ ↦ ∅, if(then, else) ↦ L_fork:λ ⟧ # Φ.bool 𝑛·1·24 := Φ.bool( φ ↦ 𝜎1:λ ) 𝑛·1·25 := ⟦ φ ↦ 𝜎1:λ, if(then, else) ↦ L_fork:λ ⟧ morphed 𝑛·1·26 := 𝑛·1·25 𝑛·1·27 := 𝑛·1·26 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·27.if- 𝑛·0·8 := 𝑛·1·24.if( then ↦ 1.0.plus( 2.0 ).plus( 𝑛·1·12 ) )- 𝑛·0·9 := ⟦ then ↦ 1.0.plus( 2.0 ).plus( 𝑛·1·12 ), else ↦ ∅, λ ⤍ L_fork ⟧- 𝑛·0·10 := 𝑛·0·8( else ↦ 3.0.plus( 4.0 ).plus( 𝑛·1·12 ) )- 𝑛·0·11 := ⟦ then ↦ 1.0.plus( 2.0 ).plus( 𝑛·1·12 ), else ↦ 3.0.plus( 4.0 ).plus( 𝑛·1·12 ), λ ⤍ L_fork ⟧+ evaluated 𝑛·1·28 := 𝑛·1·27 # 𝑛·0·6+ normalized 𝑛·0·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·28.if+ shared 𝑛·1 := 1.0.plus( 2.0 ).plus( 𝑛·1·12 )+ 𝑛·0·8 := 𝑛·1·24.if( then ↦ 𝑛·1 )+ 𝑛·0·9 := ⟦ then ↦ 𝑛·1, else ↦ ∅, λ ⤍ L_fork ⟧+ shared 𝑛·2 := 3.0.plus( 4.0 ).plus( 𝑛·1·12 )+ 𝑛·0·10 := 𝑛·0·9( else ↦ 𝑛·2 )+ 𝑛·0·11 := ⟦ then ↦ 𝑛·1, else ↦ 𝑛·2, λ ⤍ L_fork ⟧ 𝔼(L_fork): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -134,13 +137,14 @@ normalized 𝑛·3·20 := 40-00-00-00-00-00-00-00:Δ # 𝑛·3·19 𝛿·3·2 := 40-00-00-00-00-00-00-00 # 2.0 𝛿2·3 := 𝛿·3·2 # 𝔻(ξ.x)- 𝑛·3·21 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·3·21 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·3·21): 𝑛·3·22 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·3·23 := ⟦ φ ↦ 𝜎2:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·3·24 := 𝑛·3·23 𝑛·3·25 := 𝑛·3·24 # 𝕄(𝑛·3·21)- normalized 𝑛·2·11 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·3·25.plus+ evaluated 𝑛·3·26 := 𝑛·3·25 # 𝑛·2·10+ normalized 𝑛·2·11 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·3·26.plus 𝑛·2·12 := 𝑛·3·22.plus( x ↦ 𝑛·1·12 ) 𝑛·2·13 := ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧ morphed 𝑛·2·14 := 𝑛·2·13@@ -181,18 +185,20 @@ normalized 𝑛·4·20 := 40-10-00-00-00-00-00-00:Δ # 𝑛·4·19 𝛿·4·2 := 40-10-00-00-00-00-00-00 # 4.0 𝛿2·4 := 𝛿·4·2 # 𝔻(ξ.x)- 𝑛·4·21 := Φ.number( φ ↦ 𝜎3:λ ) # 𝑛+ 𝑛·4·21 := Φ.number( φ ↦ 𝜎3:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·4·21): 𝑛·4·22 := Φ.number( φ ↦ 𝜎3:λ ) 𝑛·4·23 := ⟦ φ ↦ 𝜎3:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·4·24 := 𝑛·4·23 𝑛·4·25 := 𝑛·4·24 # 𝕄(𝑛·4·21)- normalized 𝑛·2·20 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·4·25.plus+ evaluated 𝑛·4·26 := 𝑛·4·25 # 𝑛·2·19+ normalized 𝑛·2·20 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·4·26.plus 𝑛·2·21 := 𝑛·4·22.plus( x ↦ 𝑛·1·12 ) 𝑛·2·22 := ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧ morphed 𝑛·2·23 := 𝑛·2·22 joined 𝜎4 := 𝛿1·2 ? 𝜎2 : 𝜎3 𝑛·2·24 := ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧+ evaluated 𝑛·2·25 := ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧ # 𝑛·0·11 𝔼(L_number_plus): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -218,11 +224,12 @@ normalized 𝑛·5·15 := 00-00-00-00-00-00-00-00:Δ # 𝑛·5·14 𝛿·5·2 := 00-00-00-00-00-00-00-00 # 0.0 𝛿2·5 := 𝛿·5·2 # 𝔻(ξ.x)- 𝑛·5·16 := Φ.number( φ ↦ 𝜎5:λ ) # 𝑛+ 𝑛·5·16 := Φ.number( φ ↦ 𝜎5:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·5·16): 𝑛·5·17 := Φ.number( φ ↦ 𝜎5:λ ) 𝑛·5·18 := ⟦ φ ↦ 𝜎5:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·5·19 := 𝑛·5·18 𝑛·5·20 := 𝑛·5·19 # 𝕄(𝑛·5·16)- normalized 𝑛·0·12 := 𝜎5:λ # 𝑛·5·20.φ+ evaluated 𝑛·5·21 := 𝑛·5·20 # ⟦ x ↦ 𝑛·5·6, λ ⤍ L_number_plus ⟧+ normalized 𝑛·0·12 := 𝜎5:λ # 𝑛·5·21.φ morphed 𝑛·0·13 := 𝑛·0·12
test-resources/evaluate-packs/keeps-the-answer-a-firing-already-gave.yaml view
@@ -14,8 +14,9 @@ protocol: | 𝕄(Φ.x): 𝔼(L_answers):- 𝑛·1·1 := L_none:λ # 𝑛+ 𝑛·1·1 := L_none:λ # 𝑛 of L_answers 𝕄(𝑛·1·1): morphed 𝑛·1·2 := L_none:λ 𝑛·1·3 := L_none:λ # 𝕄(𝑛·1·1)- unanswered L_none # 𝕄(L_none:λ)+ evaluated 𝑛·1·4 := L_none:λ # L_answers:λ+ unanswered L_none # 𝕄(L_none:λ.foo)
test-resources/evaluate-packs/keeps-the-rho-bindings-a-pack-asks-for.yaml view
@@ -21,8 +21,9 @@ 𝕄(ξ.x): morphed 𝑛·1·1 := ⟦ λ ⤍ 𝜎1, ρ ↦ ⟦ x(ρ) ↦ 𝜎1:λ ⟧ ⟧ 𝑛1·1 := 𝑛·1·1 # 𝕄(ξ.x)- 𝑛·1·2 := ⟦ λ ⤍ 𝜎1, ρ ↦ ⟦ x(ρ) ↦ 𝜎1:λ ⟧ ⟧:z # 𝑛+ 𝑛·1·2 := ⟦ λ ⤍ 𝜎1, ρ ↦ ⟦ x(ρ) ↦ 𝜎1:λ ⟧ ⟧:z # 𝑛 of L_keep 𝕄(𝑛·1·2): morphed 𝑛·1·3 := ⟦ λ ⤍ 𝜎1, ρ ↦ ⟦ x(ρ) ↦ 𝜎1:λ ⟧ ⟧:z 𝑛·1·4 := 𝑛·1·3 # 𝕄(𝑛·1·2)+ evaluated 𝑛·1·5 := 𝑛·1·4 # ⟦ x(ρ) ↦ 𝜎1:λ, λ ⤍ L_keep ⟧ morphed 𝑛·0·1 := 𝑛1·1
test-resources/evaluate-packs/leaves-a-bare-symbol-an-evaluate-line-meets-as-it-is.yaml view
@@ -22,8 +22,9 @@ 𝕄(ξ.x): morphed 𝑛·1·1 := 𝜎4:λ 𝑛1·1 := 𝑛·1·1 # 𝕄(ξ.x)- 𝑛·1·2 := 𝜎4:λ:φ # 𝑛+ 𝑛·1·2 := 𝜎4:λ:φ # 𝑛 of L_keep 𝕄(𝑛·1·2): morphed 𝑛·1·3 := 𝜎4:λ:φ 𝑛·1·4 := 𝑛·1·3 # 𝕄(𝑛·1·2)+ evaluated 𝑛·1·5 := 𝑛·1·4 # ⟦ x ↦ 𝜎4:λ, λ ⤍ L_keep ⟧ morphed 𝑛·0·1 := 𝑛1·1
test-resources/evaluate-packs/leaves-a-formation-with-an-attribute-of-its-own-as-it-is.yaml view
@@ -59,5 +59,6 @@ joined 𝜎4 := 𝛿1·1 ? 𝜎2 : 𝜎3 𝑛·1·8 := ⟦ v ↦ 𝜎4:λ, tag ↦ v, λ ⤍ L_box ⟧ remembered 𝑛·1·9 ≡ 𝑛·0·1 # ⟦ v ↦ 𝜎4:λ, tag ↦ v, λ ⤍ L_box ⟧+ evaluated 𝑛·1·10 := 𝑛·1·9 # 𝑛·0·1 normalized 𝑛·0·2 := 𝜎4:λ # 𝑛·1·9.tag morphed 𝑛·0·3 := 𝑛·0·2
test-resources/evaluate-packs/mints-a-fresh-symbol-for-every-firing.yaml view
@@ -58,13 +58,14 @@ normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·22): 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ ) 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·1·25 := 𝑛·1·24 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·26.plus+ evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·6+ normalized 𝑛·0·7 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·27.plus 𝑛·0·8 := 𝑛·1·23.plus( x ↦ 7.0 ) 𝑛·0·9 := ⟦ x ↦ 7.0, λ ⤍ L_number_plus ⟧ 𝔼(L_number_plus):@@ -92,11 +93,12 @@ normalized 𝑛·2·15 := 40-1C-00-00-00-00-00-00:Δ # 𝑛·2·14 𝛿·2·2 := 40-1C-00-00-00-00-00-00 # 7.0 𝛿2·2 := 𝛿·2·2 # 𝔻(ξ.x)- 𝑛·2·16 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·2·16 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·2·16): 𝑛·2·17 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·2·18 := ⟦ φ ↦ 𝜎2:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·2·19 := 𝑛·2·18 𝑛·2·20 := 𝑛·2·19 # 𝕄(𝑛·2·16)- normalized 𝑛·0·10 := 𝜎2:λ # 𝑛·2·20.φ+ evaluated 𝑛·2·21 := 𝑛·2·20 # 𝑛·0·9+ normalized 𝑛·0·10 := 𝜎2:λ # 𝑛·2·21.φ morphed 𝑛·0·11 := 𝑛·0·10
test-resources/evaluate-packs/morphs-a-program-that-already-carries-a-symbol.yaml view
@@ -52,11 +52,12 @@ normalized 𝑛·1·16 := 40-1C-00-00-00-00-00-00:Δ # 𝑛·1·15 𝛿·1·2 := 40-1C-00-00-00-00-00-00 # 7.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·17 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·1·17 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·17): 𝑛·1·18 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·1·19 := ⟦ φ ↦ 𝜎2:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·1·20 := 𝑛·1·19 𝑛·1·21 := 𝑛·1·20 # 𝕄(𝑛·1·17)- normalized 𝑛·0·7 := 𝜎2:λ # 𝑛·1·21.φ+ evaluated 𝑛·1·22 := 𝑛·1·21 # 𝑛·0·6+ normalized 𝑛·0·7 := 𝜎2:λ # 𝑛·1·22.φ morphed 𝑛·0·8 := 𝑛·0·7
test-resources/evaluate-packs/morphs-two-branches-spelling-one-term-through-one-firing.yaml view
@@ -78,7 +78,7 @@ normalized 𝑛·1·21 := 00-00-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 00-00-00-00-00-00-00-00 # 0.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_gt 𝕄(𝑛·1·22): normalized 𝑛·1·23 := ⟦ φ ↦ ∅, if(then, else) ↦ L_fork:λ ⟧ # Φ.bool 𝑛·1·24 := Φ.bool( φ ↦ 𝜎1:λ )@@ -86,11 +86,13 @@ morphed 𝑛·1·26 := 𝑛·1·25 𝑛·1·27 := 𝑛·1·26 # 𝕄(𝑛·1·22) memoized 𝑛·0·6 ⇛ 𝑛·1·27- normalized 𝑛·0·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·27.if- 𝑛·0·8 := 𝑛·1·24.if( then ↦ 1.0.plus( 2.0 ).plus( 3.0 ) )- 𝑛·0·9 := ⟦ then ↦ 1.0.plus( 2.0 ).plus( 3.0 ), else ↦ ∅, λ ⤍ L_fork ⟧- 𝑛·0·10 := 𝑛·0·8( else ↦ 1.0.plus( 2.0 ).plus( 3.0 ) )- 𝑛·0·11 := ⟦ then ↦ 1.0.plus( 2.0 ).plus( 3.0 ), else ↦ 1.0.plus( 2.0 ).plus( 3.0 ), λ ⤍ L_fork ⟧+ evaluated 𝑛·1·28 := 𝑛·1·27 # 𝑛·0·6+ normalized 𝑛·0·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·28.if+ shared 𝑛·1 := 1.0.plus( 2.0 ).plus( 3.0 )+ 𝑛·0·8 := 𝑛·1·24.if( then ↦ 𝑛·1 )+ 𝑛·0·9 := ⟦ then ↦ 𝑛·1, else ↦ ∅, λ ⤍ L_fork ⟧+ 𝑛·0·10 := 𝑛·0·9( else ↦ 𝑛·1 )+ 𝑛·0·11 := ⟦ then ↦ 𝑛·1, else ↦ 𝑛·1, λ ⤍ L_fork ⟧ 𝔼(L_fork): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -138,14 +140,15 @@ normalized 𝑛·3·20 := 40-00-00-00-00-00-00-00:Δ # 𝑛·3·19 𝛿·3·2 := 40-00-00-00-00-00-00-00 # 2.0 𝛿2·3 := 𝛿·3·2 # 𝔻(ξ.x)- 𝑛·3·21 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·3·21 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·3·21): 𝑛·3·22 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·3·23 := ⟦ φ ↦ 𝜎2:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·3·24 := 𝑛·3·23 𝑛·3·25 := 𝑛·3·24 # 𝕄(𝑛·3·21) memoized 𝑛·2·10 ⇛ 𝑛·3·25- normalized 𝑛·2·11 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·3·25.plus+ evaluated 𝑛·3·26 := 𝑛·3·25 # 𝑛·2·10+ normalized 𝑛·2·11 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·3·26.plus 𝑛·2·12 := 𝑛·3·22.plus( x ↦ 3.0 ) 𝑛·2·13 := ⟦ x ↦ 3.0, λ ⤍ L_number_plus ⟧ morphed 𝑛·2·14 := 𝑛·2·13@@ -158,18 +161,20 @@ 𝑛·2·19 := ⟦ x ↦ 𝑛·3·11, λ ⤍ L_number_plus ⟧ 𝔼(L_number_plus): recalled 𝑛·2·10 ⇒ 𝑛·3·25- 𝑛·4·1 := 𝑛·3·22 # 𝑛+ 𝑛·4·1 := 𝑛·3·22 # 𝑛 of L_number_plus 𝑛·4·2 := 𝑛·3·25 # 𝕄(𝑛·4·1)- normalized 𝑛·2·20 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·4·2.plus+ evaluated 𝑛·4·3 := 𝑛·4·2 # 𝑛·2·19+ normalized 𝑛·2·20 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·4·3.plus 𝑛·2·21 := 𝑛·3·22.plus( x ↦ 3.0 ) 𝑛·2·22 := ⟦ x ↦ 3.0, λ ⤍ L_number_plus ⟧ morphed 𝑛·2·23 := 𝑛·2·22 𝑛2·2 := 𝑛·2·22 # 𝕄(ξ.else)- 𝑛·2·24 := 𝑛·2·22 # 𝑛+ 𝑛·2·24 := 𝑛·2·22 # 𝑛 of L_fork 𝕄(𝑛·2·24): morphed 𝑛·2·25 := 𝑛·2·22 𝑛·2·26 := 𝑛·2·22 # 𝕄(𝑛·2·24) memoized 𝑛·0·11 ⇛ 𝑛·2·22+ evaluated 𝑛·2·27 := 𝑛·2·22 # 𝑛·0·11 𝔼(L_number_plus): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -195,14 +200,15 @@ normalized 𝑛·5·15 := 40-08-00-00-00-00-00-00:Δ # 𝑛·5·14 𝛿·5·2 := 40-08-00-00-00-00-00-00 # 3.0 𝛿2·5 := 𝛿·5·2 # 𝔻(ξ.x)- 𝑛·5·16 := Φ.number( φ ↦ 𝜎3:λ ) # 𝑛+ 𝑛·5·16 := Φ.number( φ ↦ 𝜎3:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·5·16): 𝑛·5·17 := Φ.number( φ ↦ 𝜎3:λ ) 𝑛·5·18 := ⟦ φ ↦ 𝜎3:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·5·19 := 𝑛·5·18 𝑛·5·20 := 𝑛·5·19 # 𝕄(𝑛·5·16) memoized 𝑛·2·22 ⇛ 𝑛·5·20- normalized 𝑛·0·12 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·5·20.plus+ evaluated 𝑛·5·21 := 𝑛·5·20 # 𝑛·2·22+ normalized 𝑛·0·12 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·5·21.plus 𝑛·0·13 := 𝑛·5·17.plus( x ↦ 9.0 ) 𝑛·0·14 := ⟦ x ↦ 9.0, λ ⤍ L_number_plus ⟧ morphed 𝑛·0·15 := 𝑛·0·14
test-resources/evaluate-packs/names-a-reshaped-side-of-a-fabricated-formation-by-its-meta.yaml view
@@ -42,7 +42,8 @@ morphed 𝑛·1·2 := Φ.zu:φ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.b) symbolized 𝜎2 := 01-- 𝑛3·1 := ⟦ φ ↦ f( x ↦ 𝜎2:λ ), f(x) ↦ ⟦⟧ ⟧ # symbolize(𝑛1)+ 𝑛3·1 := ⟦ φ ↦ f( x ↦ 𝜎2:λ ), f(x) ↦ ⟦⟧ ⟧ # symbolize(𝑛1 of L_fork) fabricated 𝑛·1·3 := 𝑛3·1 and 𝑛2·1 # ⟦ left🌵 ↦ 𝑛3·1, right🌵 ↦ 𝑛·1·2, φ ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.φ, right🌵 ↦ ρ.right🌵.φ ⟧, f(x) ↦ ⟦ λ ⤍ L_join, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.f( x ↦ x ), right🌵 ↦ ρ.right🌵.f( x ↦ x ) ⟧ ⟧- normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.f( x ↦ x ), right🌵 ↦ ρ.right🌵.f( x ↦ x ) ⟧ # 𝑛·1·3.f+ evaluated 𝑛·1·4 := 𝑛·1·3 # ⟦ c ↦ 𝜎1:λ, a ↦ 𝑛·1·1, b ↦ 𝑛·1·2, λ ⤍ L_fork ⟧+ normalized 𝑛·0·1 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.f( x ↦ x ), right🌵 ↦ ρ.right🌵.f( x ↦ x ) ⟧ # 𝑛·1·4.f morphed 𝑛·0·2 := ⟦ λ ⤍ L_join, x ↦ ∅, on🌵 ↦ 𝜎1:λ, left🌵 ↦ ρ.left🌵.f( x ↦ x ), right🌵 ↦ ρ.right🌵.f( x ↦ x ) ⟧
test-resources/evaluate-packs/nests-the-firing-an-operand-brought-down.yaml view
@@ -25,8 +25,9 @@ 𝑛·0·2 := 5.0 𝑛·0·3 := ⟦ φ ↦ Φ.bytes( φ ↦ 40-14-00-00-00-00-00-00:Δ ), plus(x) ↦ L_number_plus:λ ⟧ normalized 𝑛·0·4 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·0·3.plus- 𝑛·0·5 := 𝑛·0·2.plus( x ↦ 6.0.plus( 7.0 ) )- 𝑛·0·6 := ⟦ x ↦ 6.0.plus( 7.0 ), λ ⤍ L_number_plus ⟧+ shared 𝑛·1 := 6.0.plus( 7.0 )+ 𝑛·0·5 := 𝑛·0·2.plus( x ↦ 𝑛·1 )+ 𝑛·0·6 := ⟦ x ↦ 𝑛·1, λ ⤍ L_number_plus ⟧ 𝔼(L_number_plus): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -83,23 +84,25 @@ normalized 𝑛·2·20 := 40-1C-00-00-00-00-00-00:Δ # 𝑛·2·19 𝛿·2·2 := 40-1C-00-00-00-00-00-00 # 7.0 𝛿2·2 := 𝛿·2·2 # 𝔻(ξ.x)- 𝑛·2·21 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·2·21 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·2·21): 𝑛·2·22 := Φ.number( φ ↦ 𝜎1:λ ) 𝑛·2·23 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·2·24 := 𝑛·2·23 𝑛·2·25 := 𝑛·2·24 # 𝕄(𝑛·2·21)- boxed 𝑛·1·18 := 𝑛·2·25.φ+ evaluated 𝑛·2·26 := 𝑛·2·25 # 𝑛·1·16+ boxed 𝑛·1·18 := 𝑛·2·26.φ normalized 𝑛·1·19 := 𝜎1:λ # 𝑛·1·18 𝛿·1·2 := 𝔻(𝜎1:λ) 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·20 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·1·20 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·20): 𝑛·1·21 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·1·22 := ⟦ φ ↦ 𝜎2:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·1·23 := 𝑛·1·22 𝑛·1·24 := 𝑛·1·23 # 𝕄(𝑛·1·20)- normalized 𝑛·0·7 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·24.plus+ evaluated 𝑛·1·25 := 𝑛·1·24 # 𝑛·0·6+ normalized 𝑛·0·7 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·25.plus 𝑛·0·8 := 𝑛·1·21.plus( x ↦ 8.0 ) 𝑛·0·9 := ⟦ x ↦ 8.0, λ ⤍ L_number_plus ⟧ morphed 𝑛·0·10 := 𝑛·0·9
test-resources/evaluate-packs/parks-a-dispatch-off-a-symbol.yaml view
@@ -18,4 +18,4 @@ result: '𝜎1:λ.plus( 5 )' protocol: | 𝕄(Φ.a):- unanswered 𝜎1 # 𝕄(𝜎1:λ)+ opaque 𝜎1 # 𝕄(𝜎1:λ.plus)
test-resources/evaluate-packs/parks-a-firing-whose-deferred-argument-got-stuck.yaml view
@@ -35,12 +35,13 @@ 𝑛·1·2 := Φ.box( s ↦ 𝜎1:λ ) 𝑛·1·3 := ⟦ s ↦ 𝜎1:λ, x ↦ ∅, φ ↦ s.next ⟧ remembered 𝑛·1·3 ≡ 𝑛·1·1( s ↦ 𝜎1:λ )- 𝑛·1·4 := 𝑛·1·2( x ↦ ⟦ arg ↦ L_none:λ, λ ⤍ L_outer ⟧.φ )- 𝑛·1·5 := ⟦ s ↦ 𝜎1:λ, x ↦ ⟦ arg ↦ L_none:λ, λ ⤍ L_outer ⟧.φ, φ ↦ s.next ⟧- remembered 𝑛·1·5 ≡ 𝑛·1·3( x ↦ ⟦ arg ↦ L_none:λ, λ ⤍ L_outer ⟧.φ )+ shared 𝑛·1 := ⟦ arg ↦ L_none:λ, λ ⤍ L_outer ⟧.φ+ 𝑛·1·4 := 𝑛·1·2( x ↦ 𝑛·1 )+ 𝑛·1·5 := ⟦ s ↦ 𝜎1:λ, x ↦ 𝑛·1, φ ↦ s.next ⟧+ remembered 𝑛·1·5 ≡ 𝑛·1·3( x ↦ 𝑛·1 ) morphed 𝑛·1·6 := 𝑛·1·5 𝑛1·1 := 𝑛·1·6 # 𝕄(ξ.c)- recalled 𝑛·1·5 ⇒ 𝑛·1·3( x ↦ ⟦ arg ↦ L_none:λ, λ ⤍ L_outer ⟧.φ )+ recalled 𝑛·1·5 ⇒ 𝑛·1·3( x ↦ 𝑛·1 ) recalled 𝑛·1·3 ⇒ 𝑛·1·1( s ↦ 𝜎1:λ ) recalled 𝑛·1·1 ⇒ Φ.box 𝕄(𝑛1.x):
test-resources/evaluate-packs/parks-a-firing-whose-join-side-got-stuck.yaml view
@@ -25,5 +25,5 @@ 𝛿·1·1 := 𝔻(𝜎1:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.c) 𝕄(ξ.a):- unanswered L_none # 𝕄(L_none:λ)+ unanswered L_none # 𝕄(L_none:λ.x) stuck L_none
test-resources/evaluate-packs/parks-a-firing-whose-morph-operand-got-stuck.yaml view
@@ -29,5 +29,5 @@ 𝛿·1·1 := 𝔻(𝜎1:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.c) 𝕄(ξ.a):- unanswered L_none # 𝕄(L_none:λ)+ unanswered L_none # 𝕄(L_none:λ.x) stuck L_none
test-resources/evaluate-packs/parks-a-firing-whose-operand-never-came-down.yaml view
@@ -20,5 +20,5 @@ 𝔼(L_pair): 𝔻(ξ.x): 𝕄(ξ.x):- unanswered L_none # 𝕄(L_none:λ)+ unanswered L_none # 𝕄(L_none:λ.foo) stuck L_none
test-resources/evaluate-packs/parks-a-firing-whose-operand-reaches-the-terminator.yaml view
@@ -41,8 +41,9 @@ normalized 𝑛·0·2 := ⟦ n ↦ ∅, v ↦ ∅, λ ⤍ L_entry ⟧ # 𝑛·0·1.mark 𝑛·0·3 := ⟦ n ↦ ∅, v ↦ ∅, λ ⤍ L_entry ⟧( n ↦ 1.0 ) 𝑛·0·4 := ⟦ n ↦ 1.0, v ↦ ∅, λ ⤍ L_entry ⟧- 𝑛·0·5 := 𝑛·0·4( v ↦ Φ.block( buffer ↦ Φ.bytes( φ ↦ 𝜎1:λ ) ).read )- 𝑛·0·6 := ⟦ n ↦ 1.0, v ↦ Φ.block( buffer ↦ Φ.bytes( φ ↦ 𝜎1:λ ) ).read, λ ⤍ L_entry ⟧+ shared 𝑛·1 := Φ.block( buffer ↦ Φ.bytes( φ ↦ 𝜎1:λ ) ).read+ 𝑛·0·5 := 𝑛·0·4( v ↦ 𝑛·1 )+ 𝑛·0·6 := ⟦ n ↦ 1.0, v ↦ 𝑛·1, λ ⤍ L_entry ⟧ 𝔼(L_entry): 𝔻(ξ.n): 𝕄(ξ.n):
test-resources/evaluate-packs/parks-a-lambda-no-entry-answers.yaml view
@@ -15,4 +15,4 @@ result: 'L_none:λ.foo' protocol: | 𝕄(Φ.x):- unanswered L_none # 𝕄(L_none:λ)+ unanswered L_none # 𝕄(L_none:λ.foo)
test-resources/evaluate-packs/parks-an-evaluate-line-over-a-term-that-is-no-formation.yaml view
@@ -31,5 +31,5 @@ 𝕄(ξ.a): morphed 𝑛·1·1 := Φ.k:φ 𝑛1·1 := 𝑛·1·1 # 𝕄(ξ.a)- 𝑛2·1 := Φ.k # rewrite(𝑛1)+ 𝑛2·1 := Φ.k # rewrite(𝑛1 of L_fork) stuck L_fork
test-resources/evaluate-packs/passes-a-side-that-is-no-formation-through-an-evaluate-line-to-the-join.yaml view
@@ -48,6 +48,6 @@ 𝕄(ξ.b): morphed 𝑛·1·2 := Φ.j:φ 𝑛2·1 := 𝑛·1·2 # 𝕄(ξ.b)- 𝑛3·1 := Φ.k # rewrite(𝑛1)- 𝑛4·1 := Φ.j # rewrite(𝑛2)+ 𝑛3·1 := Φ.k # rewrite(𝑛1 of L_fork)+ 𝑛4·1 := Φ.j # rewrite(𝑛2 of L_fork) diverged Φ.k vs Φ.j # cannot join: the left side is Φ.k and the right side is Φ.j; cannot fabricate: the join names no otherwise
test-resources/evaluate-packs/reduces-a-carried-symbol-through-morphing.yaml view
@@ -18,9 +18,10 @@ 𝕄(ξ.x): morphed 𝑛·1·1 := 𝜎4:λ 𝑛1·1 := 𝑛·1·1 # 𝕄(ξ.x)- 𝑛·1·2 := 𝜎5:λ:z # 𝑛+ 𝑛·1·2 := 𝜎5:λ:z # 𝑛 of L_keep 𝕄(𝑛·1·2): morphed 𝑛·1·3 := 𝜎5:λ:z 𝑛·1·4 := 𝑛·1·3 # 𝕄(𝑛·1·2)- normalized 𝑛·0·1 := 𝜎5:λ # 𝑛·1·4.z+ evaluated 𝑛·1·5 := 𝑛·1·4 # ⟦ x ↦ 𝜎4:λ, λ ⤍ L_keep ⟧+ normalized 𝑛·0·1 := 𝜎5:λ # 𝑛·1·5.z morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/refuses-a-meta-bound-to-a-term-that-is-not-a-normal-form.yaml view
@@ -27,4 +27,4 @@ 𝕄(ξ.x): morphed 𝑛·1·1 := 01-:Δ 𝑛1·1 := 01-:Δ # 𝕄(ξ.x)- 𝑛2·1 := 01-:Δ:k.k # rewrite(𝑛1)+ 𝑛2·1 := 01-:Δ:k.k # rewrite(𝑛1 of L_wrap)
+ test-resources/evaluate-packs/renames-the-answer-of-a-firing-alike-up-to-the-symbols-of-its-positions.yaml view
@@ -0,0 +1,114 @@+# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+# SPDX-License-Identifier: MIT+---+# yamllint disable rule:line-length+# The memo of '--acyclic=plausible' names a position by the symbol 𝔻 brought+# it down to. The firing of 'b' brings 'Φ.v' down to '𝜎2', so the formation+# of 'c', '⟦ target ↦ Φ.v, λ ⤍ L_dataized ⟧', is the formation of 'a' with+# '𝜎2' in place of '𝜎1'. The memo of formations misses it, yet the firing of+# 'c' fires nothing: it takes the answer of 'a' with every symbol renamed,+# '𝜎1' as '𝜎2', and with a fresh '𝜎5' for the '𝜎3' the firing of 'a' minted,+# and writes it as 'renamed' (#2374).+symbolic: |+ - λ: L_dataized+ dataize:+ 𝛿1: $.target+ 𝑛: ⟦ λ ⤍ 𝜎 ⟧+ - λ: L_peek+ dataize:+ 𝛿1: $.target+ 𝑛: ⟦ λ ⤍ 𝜎 ⟧+ - λ: L_triple+ morph:+ 𝑛1: $.a+ 𝑛2: $.b+ 𝑛3: $.c+ evaluate:+ 𝑛4: 𝑛1+ 𝑛5: 𝑛2+ 𝑛6: 𝑛3+ 𝑛: ⟦ φ ↦ ⟦ a ↦ 𝑛4, b ↦ 𝑛5, c ↦ 𝑛6 ⟧ ⟧+location: 'Q.p'+acyclic: plausible+input: >+ ⟦ dataized(target) ↦ L_dataized:λ,+ peek(target) ↦ L_peek:λ,+ p ↦ ⟦+ a ↦ Φ.dataized( target ↦ Φ.u ),+ b ↦ Φ.peek( target ↦ Φ.v ),+ c ↦ Φ.dataized( target ↦ Φ.v ),+ λ ⤍ L_triple ⟧.φ,+ u ↦ ⟦ λ ⤍ 𝜎1 ⟧,+ v ↦ ⟦ λ ⤍ 𝜎2 ⟧ ⟧+result: '⟦ a ↦ 𝜎3:λ, b ↦ 𝜎4:λ, c ↦ 𝜎5:λ ⟧'+protocol: |+ 𝕄(Φ.p):+ 𝔼(L_triple):+ 𝕄(ξ.a):+ remembered 𝑛·1·1 ≡ Φ.dataized # ⟦ target ↦ ∅, λ ⤍ L_dataized ⟧+ 𝑛·1·2 := Φ.dataized( target ↦ Φ.u )+ 𝑛·1·3 := ⟦ target ↦ Φ.u, λ ⤍ L_dataized ⟧+ remembered 𝑛·1·3 ≡ 𝑛·1·1( target ↦ Φ.u )+ morphed 𝑛·1·4 := 𝑛·1·3+ 𝑛1·1 := 𝑛·1·3 # 𝕄(ξ.a)+ 𝕄(ξ.b):+ remembered 𝑛·1·5 ≡ Φ.peek # ⟦ target ↦ ∅, λ ⤍ L_peek ⟧+ 𝑛·1·6 := Φ.peek( target ↦ Φ.v )+ 𝑛·1·7 := ⟦ target ↦ Φ.v, λ ⤍ L_peek ⟧+ remembered 𝑛·1·7 ≡ 𝑛·1·5( target ↦ Φ.v )+ morphed 𝑛·1·8 := 𝑛·1·7+ 𝑛2·1 := 𝑛·1·7 # 𝕄(ξ.b)+ 𝕄(ξ.c):+ 𝑛·1·9 := Φ.dataized( target ↦ Φ.v )+ 𝑛·1·10 := ⟦ target ↦ Φ.v, λ ⤍ L_dataized ⟧+ remembered 𝑛·1·10 ≡ 𝑛·1·1( target ↦ Φ.v )+ morphed 𝑛·1·11 := 𝑛·1·10+ 𝑛3·1 := 𝑛·1·10 # 𝕄(ξ.c)+ recalled 𝑛·1·3 ⇒ 𝑛·1·1( target ↦ Φ.u )+ recalled 𝑛·1·1 ⇒ Φ.dataized+ 𝔼(L_dataized): # 𝔼(𝑛1 of L_triple)+ 𝔻(ξ.target):+ 𝕄(ξ.target):+ normalized 𝑛·2·1 := 𝜎1:λ # Φ.u+ morphed 𝑛·2·2 := 𝑛·2·1+ 𝛿·2·1 := 𝔻(𝜎1:λ)+ 𝛿1·2 := 𝛿·2·1 # 𝔻(ξ.target)+ 𝑛·2·3 := 𝜎3:λ # 𝑛 of L_dataized+ 𝕄(𝑛·2·3):+ morphed 𝑛·2·4 := 𝜎3:λ+ 𝑛·2·5 := 𝑛·2·4 # 𝕄(𝑛·2·3)+ memoized 𝑛·1·3 ⇛ 𝜎3:λ+ evaluated 𝑛·2·6 := 𝑛·2·5 # 𝑛·1·3+ 𝑛4·1 := 𝑛·2·5 # 𝔼(𝑛1 of L_triple)+ recalled 𝑛·1·7 ⇒ 𝑛·1·5( target ↦ Φ.v )+ recalled 𝑛·1·5 ⇒ Φ.peek+ 𝔼(L_peek): # 𝔼(𝑛2 of L_triple)+ 𝔻(ξ.target):+ 𝕄(ξ.target):+ normalized 𝑛·3·1 := 𝜎2:λ # Φ.v+ morphed 𝑛·3·2 := 𝑛·3·1+ 𝛿·3·1 := 𝔻(𝜎2:λ)+ 𝛿1·3 := 𝛿·3·1 # 𝔻(ξ.target)+ 𝑛·3·3 := 𝜎4:λ # 𝑛 of L_peek+ 𝕄(𝑛·3·3):+ morphed 𝑛·3·4 := 𝜎4:λ+ 𝑛·3·5 := 𝑛·3·4 # 𝕄(𝑛·3·3)+ memoized 𝑛·1·7 ⇛ 𝜎4:λ+ evaluated 𝑛·3·6 := 𝑛·3·5 # 𝑛·1·7+ 𝑛5·1 := 𝑛·3·5 # 𝔼(𝑛2 of L_triple)+ recalled 𝑛·1·10 ⇒ 𝑛·1·1( target ↦ Φ.v )+ recalled 𝑛·1·1 ⇒ Φ.dataized+ 𝔼(L_dataized): # 𝔼(𝑛3 of L_triple)+ renamed 𝑛·1·10 ⇛ 𝜎5:λ # from 𝑛·1·3, 𝜎1 as 𝜎2, 𝜎3 as 𝜎5+ 𝑛·4·1 := 𝜎5:λ # 𝑛 of L_dataized+ 𝑛·4·2 := 𝜎5:λ # 𝕄(𝑛·4·1)+ evaluated 𝑛·4·3 := 𝑛·4·2 # 𝑛·1·10+ 𝑛6·1 := 𝑛·4·2 # 𝔼(𝑛3 of L_triple)+ 𝑛·1·12 := ⟦ a ↦ 𝜎3:λ, b ↦ 𝜎4:λ, c ↦ 𝜎5:λ ⟧:φ # 𝑛 of L_triple+ 𝕄(𝑛·1·12):+ morphed 𝑛·1·13 := ⟦ a ↦ 𝜎3:λ, b ↦ 𝜎4:λ, c ↦ 𝜎5:λ ⟧:φ+ 𝑛·1·14 := 𝑛·1·13 # 𝕄(𝑛·1·12)+ memoized 𝑛·1·15 ⇛ 𝑛·1·14 # ⟦ a ↦ 𝑛·1·2, b ↦ 𝑛·1·6, c ↦ 𝑛·1·9, λ ⤍ L_triple ⟧+ evaluated 𝑛·1·16 := 𝑛·1·14 # 𝑛·1·15+ normalized 𝑛·0·1 := ⟦ a ↦ 𝜎3:λ, b ↦ 𝜎4:λ, c ↦ 𝜎5:λ ⟧ # 𝑛·1·16.φ+ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/spends-a-step-on-every-firing-of-an-evaluate-line.yaml view
@@ -28,6 +28,6 @@ morphed 𝑛·1·1 := 𝑛·0·1 𝑛1·1 := 𝑛·0·1 # 𝕄(ξ.next🌵) recalled 𝑛·0·1 ⇒ Φ.loop- 𝔼(L_loop): # 𝔼(𝑛1)+ 𝔼(L_loop): # 𝔼(𝑛1 of L_loop) 𝕄(ξ.next🌵): starved 6
test-resources/evaluate-packs/spends-the-step-budget-on-an-entry-answering-itself.yaml view
@@ -16,31 +16,36 @@ protocol: | 𝕄(Φ.x): 𝔼(L_loop):- 𝑛·1·1 := L_loop:λ # 𝑛+ 𝑛·1·1 := L_loop:λ # 𝑛 of L_loop 𝕄(𝑛·1·1): morphed 𝑛·1·2 := L_loop:λ 𝑛·1·3 := L_loop:λ # 𝕄(𝑛·1·1)+ evaluated 𝑛·1·4 := L_loop:λ # L_loop:λ 𝔼(L_loop):- 𝑛·2·1 := L_loop:λ # 𝑛+ 𝑛·2·1 := L_loop:λ # 𝑛 of L_loop 𝕄(𝑛·2·1): morphed 𝑛·2·2 := L_loop:λ 𝑛·2·3 := L_loop:λ # 𝕄(𝑛·2·1)+ evaluated 𝑛·2·4 := L_loop:λ # L_loop:λ 𝔼(L_loop):- 𝑛·3·1 := L_loop:λ # 𝑛+ 𝑛·3·1 := L_loop:λ # 𝑛 of L_loop 𝕄(𝑛·3·1): morphed 𝑛·3·2 := L_loop:λ 𝑛·3·3 := L_loop:λ # 𝕄(𝑛·3·1)+ evaluated 𝑛·3·4 := L_loop:λ # L_loop:λ 𝔼(L_loop):- 𝑛·4·1 := L_loop:λ # 𝑛+ 𝑛·4·1 := L_loop:λ # 𝑛 of L_loop 𝕄(𝑛·4·1): morphed 𝑛·4·2 := L_loop:λ 𝑛·4·3 := L_loop:λ # 𝕄(𝑛·4·1)+ evaluated 𝑛·4·4 := L_loop:λ # L_loop:λ 𝔼(L_loop):- 𝑛·5·1 := L_loop:λ # 𝑛+ 𝑛·5·1 := L_loop:λ # 𝑛 of L_loop 𝕄(𝑛·5·1): morphed 𝑛·5·2 := L_loop:λ 𝑛·5·3 := L_loop:λ # 𝕄(𝑛·5·1)+ evaluated 𝑛·5·4 := L_loop:λ # L_loop:λ 𝔼(L_loop):- 𝑛·6·1 := L_loop:λ # 𝑛+ 𝑛·6·1 := L_loop:λ # 𝑛 of L_loop 𝕄(𝑛·6·1): starved 6
test-resources/evaluate-packs/starts-minting-after-the-symbols-the-program-carries.yaml view
@@ -58,11 +58,12 @@ normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.number( φ ↦ 𝜎4:λ ) # 𝑛+ 𝑛·1·22 := Φ.number( φ ↦ 𝜎4:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·22): 𝑛·1·23 := Φ.number( φ ↦ 𝜎4:λ ) 𝑛·1·24 := ⟦ φ ↦ 𝜎4:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·1·25 := 𝑛·1·24 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := 𝜎4:λ # 𝑛·1·26.φ+ evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·6+ normalized 𝑛·0·7 := 𝜎4:λ # 𝑛·1·27.φ morphed 𝑛·0·8 := 𝑛·0·7
test-resources/evaluate-packs/takes-the-answer-of-a-firing-with-the-same-operands.yaml view
@@ -53,22 +53,23 @@ 𝑛2·1 := 𝑛·1·6 # 𝕄(ξ.b) recalled 𝑛·1·3 ⇒ 𝑛·1·1( target ↦ Φ.x ) recalled 𝑛·1·1 ⇒ Φ.dataized- 𝔼(L_dataized): # 𝔼(𝑛1)+ 𝔼(L_dataized): # 𝔼(𝑛1 of L_pair) 𝔻(ξ.target): 𝕄(ξ.target): normalized 𝑛·2·1 := 01-:Δ # Φ.x morphed 𝑛·2·2 := 01-:Δ 𝛿·2·1 := 01- 𝛿1·2 := 𝛿·2·1 # 𝔻(ξ.target)- 𝑛·2·3 := 𝜎1:λ # 𝑛+ 𝑛·2·3 := 𝜎1:λ # 𝑛 of L_dataized 𝕄(𝑛·2·3): morphed 𝑛·2·4 := 𝜎1:λ 𝑛·2·5 := 𝑛·2·4 # 𝕄(𝑛·2·3) memoized 𝑛·1·3 ⇛ 𝜎1:λ- 𝑛3·1 := 𝑛·2·5 # 𝔼(𝑛1)+ evaluated 𝑛·2·6 := 𝑛·2·5 # 𝑛·1·3+ 𝑛3·1 := 𝑛·2·5 # 𝔼(𝑛1 of L_pair) recalled 𝑛·1·6 ⇒ 𝑛·1·1( target ↦ Φ.y ) recalled 𝑛·1·1 ⇒ Φ.dataized- 𝔼(L_dataized): # 𝔼(𝑛2)+ 𝔼(L_dataized): # 𝔼(𝑛2 of L_pair) 𝔻(ξ.target): 𝕄(ξ.target): normalized 𝑛·3·1 := 01-:Δ # Φ.y@@ -76,14 +77,16 @@ 𝛿·3·1 := 01- 𝛿1·3 := 𝛿·3·1 # 𝔻(ξ.target) recalled 𝑛·1·3 ⇒ 𝜎1:λ- 𝑛·3·3 := 𝑛3·1 # 𝑛+ 𝑛·3·3 := 𝑛3·1 # 𝑛 of L_dataized 𝑛·3·4 := 𝑛3·1 # 𝕄(𝑛·3·3) memoized 𝑛·1·6 ⇛ 𝜎1:λ- 𝑛4·1 := 𝑛·3·4 # 𝔼(𝑛2)- 𝑛·1·8 := ⟦ a ↦ 𝜎1:λ, b ↦ 𝜎1:λ ⟧:φ # 𝑛+ evaluated 𝑛·3·5 := 𝑛·3·4 # 𝑛·1·6+ 𝑛4·1 := 𝑛·3·4 # 𝔼(𝑛2 of L_pair)+ 𝑛·1·8 := ⟦ a ↦ 𝜎1:λ, b ↦ 𝜎1:λ ⟧:φ # 𝑛 of L_pair 𝕄(𝑛·1·8): morphed 𝑛·1·9 := ⟦ a ↦ 𝜎1:λ, b ↦ 𝜎1:λ ⟧:φ 𝑛·1·10 := 𝑛·1·9 # 𝕄(𝑛·1·8) memoized 𝑛·1·11 ⇛ 𝑛·1·10 # ⟦ a ↦ 𝑛·1·2, b ↦ 𝑛·1·5, λ ⤍ L_pair ⟧- normalized 𝑛·0·1 := ⟦ a ↦ 𝜎1:λ, b ↦ 𝜎1:λ ⟧ # 𝑛·1·10.φ+ evaluated 𝑛·1·12 := 𝑛·1·10 # 𝑛·1·11+ normalized 𝑛·0·1 := ⟦ a ↦ 𝜎1:λ, b ↦ 𝜎1:λ ⟧ # 𝑛·1·12.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/takes-the-one-term-both-sides-of-a-join-come-to.yaml view
@@ -71,18 +71,20 @@ normalized 𝑛·1·21 := 00-00-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 00-00-00-00-00-00-00-00 # 0.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_gt 𝕄(𝑛·1·22): normalized 𝑛·1·23 := ⟦ φ ↦ ∅, if(then, else) ↦ L_fork:λ ⟧ # Φ.bool 𝑛·1·24 := Φ.bool( φ ↦ 𝜎1:λ ) 𝑛·1·25 := ⟦ φ ↦ 𝜎1:λ, if(then, else) ↦ L_fork:λ ⟧ morphed 𝑛·1·26 := 𝑛·1·25 𝑛·1·27 := 𝑛·1·26 # 𝕄(𝑛·1·22)- normalized 𝑛·0·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·27.if- 𝑛·0·8 := 𝑛·1·24.if( then ↦ 1.0.plus( 2.0 ) )- 𝑛·0·9 := ⟦ then ↦ 1.0.plus( 2.0 ), else ↦ ∅, λ ⤍ L_fork ⟧- 𝑛·0·10 := 𝑛·0·8( else ↦ 1.0.plus( 2.0 ) )- 𝑛·0·11 := ⟦ then ↦ 1.0.plus( 2.0 ), else ↦ 1.0.plus( 2.0 ), λ ⤍ L_fork ⟧+ evaluated 𝑛·1·28 := 𝑛·1·27 # 𝑛·0·6+ normalized 𝑛·0·7 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·28.if+ shared 𝑛·1 := 1.0.plus( 2.0 )+ 𝑛·0·8 := 𝑛·1·24.if( then ↦ 𝑛·1 )+ 𝑛·0·9 := ⟦ then ↦ 𝑛·1, else ↦ ∅, λ ⤍ L_fork ⟧+ 𝑛·0·10 := 𝑛·0·9( else ↦ 𝑛·1 )+ 𝑛·0·11 := ⟦ then ↦ 𝑛·1, else ↦ 𝑛·1, λ ⤍ L_fork ⟧ 𝔼(L_fork): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -108,6 +110,7 @@ 𝑛·2·16 := ⟦ x ↦ 2.0, λ ⤍ L_number_plus ⟧ morphed 𝑛·2·17 := 𝑛·2·16 𝑛·2·18 := 𝑛·2·16+ evaluated 𝑛·2·19 := 𝑛·2·16 # 𝑛·0·11 𝔼(L_number_plus): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -139,11 +142,12 @@ normalized 𝑛·3·20 := 40-00-00-00-00-00-00-00:Δ # 𝑛·3·19 𝛿·3·2 := 40-00-00-00-00-00-00-00 # 2.0 𝛿2·3 := 𝛿·3·2 # 𝔻(ξ.x)- 𝑛·3·21 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·3·21 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·3·21): 𝑛·3·22 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·3·23 := ⟦ φ ↦ 𝜎2:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·3·24 := 𝑛·3·23 𝑛·3·25 := 𝑛·3·24 # 𝕄(𝑛·3·21)- normalized 𝑛·0·12 := 𝜎2:λ # 𝑛·3·25.φ+ evaluated 𝑛·3·26 := 𝑛·3·25 # 𝑛·2·16+ normalized 𝑛·0·12 := 𝜎2:λ # 𝑛·3·26.φ morphed 𝑛·0·13 := 𝑛·0·12
test-resources/evaluate-packs/tells-two-carried-symbols-apart-in-one-firing.yaml view
@@ -45,11 +45,12 @@ normalized 𝑛·1·10 := 𝜎5:λ # 𝑛·1·9 𝛿·1·2 := 𝔻(𝜎5:λ) 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·11 := Φ.number( φ ↦ 𝜎6:λ ) # 𝑛+ 𝑛·1·11 := Φ.number( φ ↦ 𝜎6:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·1·11): 𝑛·1·12 := Φ.number( φ ↦ 𝜎6:λ ) 𝑛·1·13 := ⟦ φ ↦ 𝜎6:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·1·14 := 𝑛·1·13 𝑛·1·15 := 𝑛·1·14 # 𝕄(𝑛·1·11)- normalized 𝑛·0·7 := 𝜎6:λ # 𝑛·1·15.φ+ evaluated 𝑛·1·16 := 𝑛·1·15 # 𝑛·0·6+ normalized 𝑛·0·7 := 𝜎6:λ # 𝑛·1·16.φ morphed 𝑛·0·8 := 𝑛·0·7
test-resources/evaluate-packs/tells-two-symbols-of-one-datum-apart-between-firings.yaml view
@@ -33,12 +33,14 @@ protocol: | 𝕄(Φ.φ): remembered 𝑛·0·1 ≡ Φ.pair # ⟦ x ↦ ∅, y ↦ ∅, λ ⤍ L_pair ⟧- 𝑛·0·2 := Φ.pair( x ↦ Φ.dataized( Φ.bytes( φ ↦ 𝜎1:λ ) ).φ )- 𝑛·0·3 := ⟦ x ↦ Φ.dataized( Φ.bytes( φ ↦ 𝜎1:λ ) ).φ, y ↦ ∅, λ ⤍ L_pair ⟧- remembered 𝑛·0·3 ≡ 𝑛·0·1( x ↦ Φ.dataized( Φ.bytes( φ ↦ 𝜎1:λ ) ).φ )- 𝑛·0·4 := 𝑛·0·2( y ↦ Φ.dataized( Φ.bytes( φ ↦ 𝜎2:λ ) ).φ )- 𝑛·0·5 := ⟦ x ↦ Φ.dataized( Φ.bytes( φ ↦ 𝜎1:λ ) ).φ, y ↦ Φ.dataized( Φ.bytes( φ ↦ 𝜎2:λ ) ).φ, λ ⤍ L_pair ⟧- remembered 𝑛·0·5 ≡ 𝑛·0·3( y ↦ Φ.dataized( Φ.bytes( φ ↦ 𝜎2:λ ) ).φ )+ shared 𝑛·1 := Φ.dataized( Φ.bytes( φ ↦ 𝜎1:λ ) ).φ+ 𝑛·0·2 := Φ.pair( x ↦ 𝑛·1 )+ 𝑛·0·3 := ⟦ x ↦ 𝑛·1, y ↦ ∅, λ ⤍ L_pair ⟧+ remembered 𝑛·0·3 ≡ 𝑛·0·1( x ↦ 𝑛·1 )+ shared 𝑛·2 := Φ.dataized( Φ.bytes( φ ↦ 𝜎2:λ ) ).φ+ 𝑛·0·4 := 𝑛·0·3( y ↦ 𝑛·2 )+ 𝑛·0·5 := ⟦ x ↦ 𝑛·1, y ↦ 𝑛·2, λ ⤍ L_pair ⟧+ remembered 𝑛·0·5 ≡ 𝑛·0·4 𝔼(L_pair): 𝕄(ξ.x): remembered 𝑛·1·1 ≡ Φ.dataized # ⟦ target ↦ ∅, λ ⤍ L_dataized ⟧@@ -56,7 +58,7 @@ normalized 𝑛·2·6 := 𝜎1:λ # 𝑛·2·5 𝛿·2·1 := 𝔻(𝜎1:λ) 𝛿1·2 := 𝛿·2·1 # 𝔻(ξ.target)- 𝑛·2·7 := Φ.bytes( φ ↦ 𝜎3:λ ) # 𝑛+ 𝑛·2·7 := Φ.bytes( φ ↦ 𝜎3:λ ) # 𝑛 of L_dataized 𝕄(𝑛·2·7): 𝑛·2·8 := Φ.bytes( φ ↦ 𝜎3:λ ) 𝑛·2·9 := 𝜎3:λ:φ@@ -64,7 +66,8 @@ 𝑛·2·11 := 𝑛·2·10 # 𝕄(𝑛·2·7) remembered 𝑛·2·11 ≡ 𝑛·1·3 memoized 𝑛·1·3 ⇛ 𝑛·2·11- normalized 𝑛·1·4 := 𝜎3:λ # 𝑛·2·11.φ+ evaluated 𝑛·2·12 := 𝑛·2·11 # 𝑛·1·3+ normalized 𝑛·1·4 := 𝜎3:λ # 𝑛·2·12.φ morphed 𝑛·1·5 := 𝑛·1·4 𝑛1·1 := 𝑛·1·4 # 𝕄(ξ.x) 𝕄(ξ.y):@@ -81,7 +84,7 @@ normalized 𝑛·3·5 := 𝜎2:λ # 𝑛·3·4 𝛿·3·1 := 𝔻(𝜎2:λ) 𝛿1·3 := 𝛿·3·1 # 𝔻(ξ.target)- 𝑛·3·6 := Φ.bytes( φ ↦ 𝜎4:λ ) # 𝑛+ 𝑛·3·6 := Φ.bytes( φ ↦ 𝜎4:λ ) # 𝑛 of L_dataized 𝕄(𝑛·3·6): 𝑛·3·7 := Φ.bytes( φ ↦ 𝜎4:λ ) 𝑛·3·8 := 𝜎4:λ:φ@@ -89,14 +92,16 @@ 𝑛·3·10 := 𝑛·3·9 # 𝕄(𝑛·3·6) remembered 𝑛·3·10 ≡ 𝑛·1·7 memoized 𝑛·1·7 ⇛ 𝑛·3·10- normalized 𝑛·1·8 := 𝜎4:λ # 𝑛·3·10.φ+ evaluated 𝑛·3·11 := 𝑛·3·10 # 𝑛·1·7+ normalized 𝑛·1·8 := 𝜎4:λ # 𝑛·3·11.φ morphed 𝑛·1·9 := 𝑛·1·8 𝑛2·1 := 𝑛·1·8 # 𝕄(ξ.y)- 𝑛·1·10 := ⟦ x ↦ 𝜎3:λ, y ↦ 𝜎4:λ ⟧:φ # 𝑛+ 𝑛·1·10 := ⟦ x ↦ 𝜎3:λ, y ↦ 𝜎4:λ ⟧:φ # 𝑛 of L_pair 𝕄(𝑛·1·10): morphed 𝑛·1·11 := ⟦ x ↦ 𝜎3:λ, y ↦ 𝜎4:λ ⟧:φ 𝑛·1·12 := 𝑛·1·11 # 𝕄(𝑛·1·10) remembered 𝑛·1·12 ≡ 𝑛·0·5 memoized 𝑛·0·5 ⇛ 𝑛·1·12- normalized 𝑛·0·6 := ⟦ x ↦ 𝜎3:λ, y ↦ 𝜎4:λ ⟧ # 𝑛·1·12.φ+ evaluated 𝑛·1·13 := 𝑛·1·12 # 𝑛·0·5+ normalized 𝑛·0·6 := ⟦ x ↦ 𝜎3:λ, y ↦ 𝜎4:λ ⟧ # 𝑛·1·13.φ morphed 𝑛·0·7 := 𝑛·0·6
test-resources/evaluate-packs/tells-why-a-join-fabricated-nothing-of-a-side-that-is-no-formation.yaml view
@@ -38,5 +38,5 @@ 𝕄(ξ.a): morphed 𝑛·1·1 := Φ.k:φ 𝑛1·1 := 𝑛·1·1 # 𝕄(ξ.a)- 𝑛2·1 := Φ.k # rewrite(𝑛1)+ 𝑛2·1 := Φ.k # rewrite(𝑛1 of L_fork) diverged 𝑛1·1 vs 𝑛2·1 # cannot join: the left side is 𝑛·1·1 and the right side is Φ.k; cannot fabricate: the right side is no formation
test-resources/evaluate-packs/undresses-a-formation-twice-to-reach-what-it-wraps.yaml view
@@ -31,10 +31,11 @@ 𝕄(𝑛·1·4): normalized 𝑛·1·5 := ⟦ t(k) ↦ ⟦⟧ ⟧ # Φ.z morphed 𝑛·1·6 := 𝑛·1·5- 𝑛2·1 := 𝑛·1·6 # undress(𝑛1)- 𝑛·1·7 := 𝑛·1·6 # 𝑛+ 𝑛2·1 := 𝑛·1·6 # undress(𝑛1 of L_peel)+ 𝑛·1·7 := 𝑛·1·6 # 𝑛 of L_peel 𝕄(𝑛·1·7): morphed 𝑛·1·8 := 𝑛·1·6 𝑛·1·9 := 𝑛·1·8 # 𝕄(𝑛·1·7)- normalized 𝑛·0·1 := ∅:k # 𝑛·1·9.t+ evaluated 𝑛·1·10 := 𝑛·1·9 # ⟦ λ ⤍ L_peel, x ↦ 𝑛·1·1 ⟧+ normalized 𝑛·0·1 := ∅:k # 𝑛·1·10.t morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/work-out-an-argument-that-comes-to-a-hanging-object.yaml view
@@ -67,13 +67,15 @@ deferred 𝜎5 := Φ.box( x ↦ 𝜎1:λ, w ↦ 𝑛·2·15 ) # 𝕄(𝑛2.φ) joined 𝜎6 := 𝛿1·2 ? 𝜎3 : 𝜎5 𝑛·2·16 := 𝜎6:λ+ evaluated 𝑛·2·17 := 𝑛·2·16 # ⟦ c ↦ 𝜎2:λ, a ↦ 𝜎3:λ, b ↦ 𝑛·2·5, λ ⤍ L_fork ⟧ 𝛿·1·1 := 𝔻(𝜎6:λ) 𝛿1·1 := 𝛿·1·1 # 𝔻(ξ.x)- 𝑛·1·1 := Φ.num( φ ↦ 𝜎7:λ ) # 𝑛+ 𝑛·1·1 := Φ.num( φ ↦ 𝜎7:λ ) # 𝑛 of L_inc 𝕄(𝑛·1·1): 𝑛·1·2 := Φ.num( φ ↦ 𝜎7:λ ) 𝑛·1·3 := 𝜎7:λ:φ morphed 𝑛·1·4 := 𝑛·1·3 𝑛·1·5 := 𝑛·1·4 # 𝕄(𝑛·1·1)- normalized 𝑛·0·1 := 𝜎7:λ # 𝑛·1·5.φ+ evaluated 𝑛·1·6 := 𝑛·1·5 # ⟦ x ↦ ⟦ c ↦ 𝜎2:λ, a ↦ 𝜎3:λ, b ↦ 𝑛·2·5, λ ⤍ L_fork ⟧, λ ⤍ L_inc ⟧+ normalized 𝑛·0·1 := 𝜎7:λ # 𝑛·1·6.φ morphed 𝑛·0·2 := 𝑛·0·1
test-resources/evaluate-packs/writes-no-joined-line-for-a-join-the-memo-answered.yaml view
@@ -79,7 +79,7 @@ normalized 𝑛·1·21 := 00-00-00-00-00-00-00-00:Δ # 𝑛·1·20 𝛿·1·2 := 00-00-00-00-00-00-00-00 # 0.0 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)- 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛+ 𝑛·1·22 := Φ.bool( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_gt 𝕄(𝑛·1·22): normalized 𝑛·1·23 := ⟦ φ ↦ ∅, if(then, else) ↦ L_fork:λ ⟧ # Φ.bool 𝑛·1·24 := Φ.bool( φ ↦ 𝜎1:λ )@@ -87,11 +87,14 @@ morphed 𝑛·1·26 := 𝑛·1·25 𝑛·1·27 := 𝑛·1·26 # 𝕄(𝑛·1·22) memoized 𝑛·0·7 ⇛ 𝑛·1·27- normalized 𝑛·0·8 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·27.if- 𝑛·0·9 := 𝑛·1·24.if( then ↦ 1.0.plus( 2.0 ).plus( 𝑛·1·12 ) )- 𝑛·0·10 := ⟦ then ↦ 1.0.plus( 2.0 ).plus( 𝑛·1·12 ), else ↦ ∅, λ ⤍ L_fork ⟧- 𝑛·0·11 := 𝑛·0·9( else ↦ 3.0.plus( 4.0 ).plus( 𝑛·1·12 ) )- 𝑛·0·12 := ⟦ then ↦ 1.0.plus( 2.0 ).plus( 𝑛·1·12 ), else ↦ 3.0.plus( 4.0 ).plus( 𝑛·1·12 ), λ ⤍ L_fork ⟧+ evaluated 𝑛·1·28 := 𝑛·1·27 # 𝑛·0·7+ normalized 𝑛·0·8 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·1·28.if+ shared 𝑛·1 := 1.0.plus( 2.0 ).plus( 𝑛·1·12 )+ 𝑛·0·9 := 𝑛·1·24.if( then ↦ 𝑛·1 )+ 𝑛·0·10 := ⟦ then ↦ 𝑛·1, else ↦ ∅, λ ⤍ L_fork ⟧+ shared 𝑛·2 := 3.0.plus( 4.0 ).plus( 𝑛·1·12 )+ 𝑛·0·11 := 𝑛·0·10( else ↦ 𝑛·2 )+ 𝑛·0·12 := ⟦ then ↦ 𝑛·1, else ↦ 𝑛·2, λ ⤍ L_fork ⟧ 𝔼(L_fork): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -139,14 +142,15 @@ normalized 𝑛·3·20 := 40-00-00-00-00-00-00-00:Δ # 𝑛·3·19 𝛿·3·2 := 40-00-00-00-00-00-00-00 # 2.0 𝛿2·3 := 𝛿·3·2 # 𝔻(ξ.x)- 𝑛·3·21 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛+ 𝑛·3·21 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·3·21): 𝑛·3·22 := Φ.number( φ ↦ 𝜎2:λ ) 𝑛·3·23 := ⟦ φ ↦ 𝜎2:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·3·24 := 𝑛·3·23 𝑛·3·25 := 𝑛·3·24 # 𝕄(𝑛·3·21) memoized 𝑛·2·10 ⇛ 𝑛·3·25- normalized 𝑛·2·11 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·3·25.plus+ evaluated 𝑛·3·26 := 𝑛·3·25 # 𝑛·2·10+ normalized 𝑛·2·11 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·3·26.plus 𝑛·2·12 := 𝑛·3·22.plus( x ↦ 𝑛·1·12 ) 𝑛·2·13 := ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧ morphed 𝑛·2·14 := 𝑛·2·13@@ -187,20 +191,22 @@ normalized 𝑛·4·20 := 40-10-00-00-00-00-00-00:Δ # 𝑛·4·19 𝛿·4·2 := 40-10-00-00-00-00-00-00 # 4.0 𝛿2·4 := 𝛿·4·2 # 𝔻(ξ.x)- 𝑛·4·21 := Φ.number( φ ↦ 𝜎3:λ ) # 𝑛+ 𝑛·4·21 := Φ.number( φ ↦ 𝜎3:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·4·21): 𝑛·4·22 := Φ.number( φ ↦ 𝜎3:λ ) 𝑛·4·23 := ⟦ φ ↦ 𝜎3:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·4·24 := 𝑛·4·23 𝑛·4·25 := 𝑛·4·24 # 𝕄(𝑛·4·21) memoized 𝑛·2·19 ⇛ 𝑛·4·25- normalized 𝑛·2·20 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·4·25.plus+ evaluated 𝑛·4·26 := 𝑛·4·25 # 𝑛·2·19+ normalized 𝑛·2·20 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·4·26.plus 𝑛·2·21 := 𝑛·4·22.plus( x ↦ 𝑛·1·12 ) 𝑛·2·22 := ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧ morphed 𝑛·2·23 := 𝑛·2·22 joined 𝜎4 := 𝛿1·2 ? 𝜎2 : 𝜎3 𝑛·2·24 := ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧ memoized 𝑛·0·12 ⇛ ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧+ evaluated 𝑛·2·25 := ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧ # 𝑛·0·12 𝔼(L_number_plus): 𝔻(ξ.ρ): 𝕄(ξ.ρ):@@ -226,14 +232,15 @@ normalized 𝑛·5·15 := 00-00-00-00-00-00-00-00:Δ # 𝑛·5·14 𝛿·5·2 := 00-00-00-00-00-00-00-00 # 0.0 𝛿2·5 := 𝛿·5·2 # 𝔻(ξ.x)- 𝑛·5·16 := Φ.number( φ ↦ 𝜎5:λ ) # 𝑛+ 𝑛·5·16 := Φ.number( φ ↦ 𝜎5:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·5·16): 𝑛·5·17 := Φ.number( φ ↦ 𝜎5:λ ) 𝑛·5·18 := ⟦ φ ↦ 𝜎5:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·5·19 := 𝑛·5·18 𝑛·5·20 := 𝑛·5·19 # 𝕄(𝑛·5·16) memoized 𝑛·5·21 ⇛ 𝑛·5·20 # ⟦ x ↦ 𝑛·5·6, λ ⤍ L_number_plus ⟧- normalized 𝑛·0·13 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·5·20.plus+ evaluated 𝑛·5·22 := 𝑛·5·20 # 𝑛·5·21+ normalized 𝑛·0·13 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·5·22.plus 𝑛·0·14 := 𝑛·5·17.plus( x ↦ Φ.f ) 𝑛·0·15 := ⟦ x ↦ Φ.f, λ ⤍ L_number_plus ⟧ 𝔼(L_number_plus):@@ -256,30 +263,34 @@ 𝑛·6·11 := ⟦ x ↦ 𝑛·5·6, λ ⤍ L_number_gt ⟧ 𝔼(L_number_gt): recalled 𝑛·0·7 ⇒ 𝑛·1·27- 𝑛·7·1 := 𝑛·2·1 # 𝑛+ 𝑛·7·1 := 𝑛·2·1 # 𝑛 of L_number_gt 𝑛·7·2 := 𝑛·1·27 # 𝕄(𝑛·7·1)- normalized 𝑛·6·12 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·7·2.if- 𝑛·6·13 := 𝑛·2·1.if( then ↦ 𝑛·3·1.plus( 𝑛·3·11 ).plus( 𝑛·5·6 ) )- 𝑛·6·14 := ⟦ then ↦ 𝑛·3·1.plus( 𝑛·3·11 ).plus( 𝑛·5·6 ), else ↦ ∅, λ ⤍ L_fork ⟧- 𝑛·6·15 := 𝑛·6·13( else ↦ 𝑛·4·1.plus( 𝑛·4·11 ).plus( 𝑛·5·6 ) )- 𝑛·6·16 := ⟦ then ↦ 𝑛·3·1.plus( 𝑛·3·11 ).plus( 𝑛·5·6 ), else ↦ 𝑛·4·1.plus( 𝑛·4·11 ).plus( 𝑛·5·6 ), λ ⤍ L_fork ⟧+ evaluated 𝑛·7·3 := 𝑛·7·2 # 𝑛·6·11+ normalized 𝑛·6·12 := ⟦ then ↦ ∅, else ↦ ∅, λ ⤍ L_fork ⟧ # 𝑛·7·3.if+ 𝑛·6·13 := 𝑛·2·1.if( then ↦ 𝑛·1 )+ 𝑛·6·14 := ⟦ then ↦ 𝑛·1, else ↦ ∅, λ ⤍ L_fork ⟧+ 𝑛·6·15 := 𝑛·6·14( else ↦ 𝑛·2 )+ 𝑛·6·16 := ⟦ then ↦ 𝑛·1, else ↦ 𝑛·2, λ ⤍ L_fork ⟧ morphed 𝑛·6·17 := 𝑛·6·16 𝔼(L_fork): recalled 𝑛·0·12 ⇒ ⟦ x ↦ 𝑛·1·12, λ ⤍ L_number_plus ⟧ 𝑛·8·1 := 𝑛·5·21+ evaluated 𝑛·8·2 := 𝑛·5·21 # 𝑛·6·16 𝔼(L_number_plus): recalled 𝑛·5·21 ⇒ 𝑛·5·20- 𝑛·9·1 := 𝑛·6·1 # 𝑛+ 𝑛·9·1 := 𝑛·6·1 # 𝑛 of L_number_plus 𝑛·9·2 := 𝑛·5·20 # 𝕄(𝑛·9·1)- boxed 𝑛·6·18 := 𝑛·9·2.φ+ evaluated 𝑛·9·3 := 𝑛·9·2 # 𝑛·5·21+ boxed 𝑛·6·18 := 𝑛·9·3.φ 𝛿·6·2 := 𝔻(𝜎5:λ) 𝛿2·6 := 𝛿·6·2 # 𝔻(ξ.x)- 𝑛·6·19 := Φ.number( φ ↦ 𝜎6:λ ) # 𝑛+ 𝑛·6·19 := Φ.number( φ ↦ 𝜎6:λ ) # 𝑛 of L_number_plus 𝕄(𝑛·6·19): 𝑛·6·20 := Φ.number( φ ↦ 𝜎6:λ ) 𝑛·6·21 := ⟦ φ ↦ 𝜎6:λ, gt(x) ↦ L_number_gt:λ, plus(x) ↦ L_number_plus:λ ⟧ morphed 𝑛·6·22 := 𝑛·6·21 𝑛·6·23 := 𝑛·6·22 # 𝕄(𝑛·6·19) memoized 𝑛·0·15 ⇛ 𝑛·6·23- normalized 𝑛·0·16 := 𝜎6:λ # 𝑛·6·23.φ+ evaluated 𝑛·6·24 := 𝑛·6·23 # 𝑛·0·15+ normalized 𝑛·0·16 := 𝜎6:λ # 𝑛·6·24.φ morphed 𝑛·0·17 := 𝑛·0·16
+ test-resources/latex-packs/empty-string.yaml view
@@ -0,0 +1,10 @@+# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+# SPDX-License-Identifier: MIT+# yamllint disable rule:line-length+---+expression: |+ [[ x -> "", y -> "a" ]]+result: |-+ \begin{phiquation}+ [[ |x| -> |\char34{}\char34{}|, |y| -> "a" ]]{.}+ \end{phiquation}
+ test-resources/latex-packs/string-with-arrow.yaml view
@@ -0,0 +1,10 @@+# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+# SPDX-License-Identifier: MIT+# yamllint disable rule:line-length+---+expression: |+ [[ x -> "a -> b" ]]+result: |-+ \begin{phiquation}+ |\char34{}a\space{}\char45{}\char62{}\space{}b\char34{}| : |x|{.}+ \end{phiquation}
+ test-resources/latex-packs/string-with-lone-letter.yaml view
@@ -0,0 +1,10 @@+# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+# SPDX-License-Identifier: MIT+# yamllint disable rule:line-length+---+expression: |+ [[ x -> "say Q" ]]+result: |-+ \begin{phiquation}+ |\char34{}say\space{}\char81{}\char34{}| : |x|{.}+ \end{phiquation}
+ test-resources/latex-packs/string-with-question-mark.yaml view
@@ -0,0 +1,10 @@+# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com+# SPDX-License-Identifier: MIT+# yamllint disable rule:line-length+---+expression: |+ [[ x -> "why?" ]]+result: |-+ \begin{phiquation}+ |\char34{}why\char63{}\char34{}| : |x|{.}+ \end{phiquation}
test-resources/xmir-parsing-packs/phi-with-application.yaml view
@@ -1,13 +1,13 @@ # SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com # SPDX-License-Identifier: MIT ----failure: true xmir: | <object> <o name="app"> <o name="x" base="Φ"> <o base="Φ.y"/>+ <o as="a" base="ξ"/> </o> </o> </object>-phi: ''+phi: '[[ app -> [[ x -> Q(~0 -> Q.y, a -> $) ]] ]]'
test-resources/xmir-parsing-packs/xi-with-application.yaml view
@@ -1,7 +1,6 @@ # SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com # SPDX-License-Identifier: MIT ----failure: true xmir: | <object> <o name="app">@@ -10,4 +9,4 @@ </o> </o> </object>-phi: ''+phi: '[[ app -> [[ x -> $(~0 -> Q.y) ]] ]]'
test/ASTSpec.hs view
@@ -543,3 +543,22 @@ it "does not touch a term carrying no symbol" $ lifted 0 3 (ExFormation [BiTau (AtLabel "ul") (ExDispatch ExXi (AtLabel "ha")), BiLambda (Function "L_up"), BiDelta (BtOne "1F")]) `shouldBe` ExFormation [BiTau (AtLabel "ul") (ExDispatch ExXi (AtLabel "ha")), BiLambda (Function "L_up"), BiDelta (BtOne "1F")]++ describe "intact" $ do+ it "hands back the whole where the part is the one it had" $+ intact [BiVoid (AtLabel "zu")] (ExDispatch ExXi (AtLabel "old")) ExFormation [BiVoid (AtLabel "zu")]+ `shouldBe` ExDispatch ExXi (AtLabel "old")+ it "makes the whole anew where the part differs" $+ intact [BiVoid (AtLabel "zu")] (ExDispatch ExXi (AtLabel "old")) ExFormation [BiVoid (AtLabel "ri")]+ `shouldBe` ExFormation [BiVoid (AtLabel "ri")]++ describe "suffixed" $ do+ it "changes the items the walk changes and keeps the others" $+ suffixed (\item -> Just (if item == BiVoid (AtLabel "ko") then BiVoid (AtLabel "mu") else item)) [BiVoid (AtLabel "ax"), BiVoid (AtLabel "ko"), BiVoid (AtLabel "ep")]+ `shouldBe` Just [BiVoid (AtLabel "ax"), BiVoid (AtLabel "mu"), BiVoid (AtLabel "ep")]+ it "answers the list it was given where the walk changes nothing" $+ suffixed Just [BiVoid (AtLabel "yi"), BiDelta (BtOne "2D")]+ `shouldBe` Just [BiVoid (AtLabel "yi"), BiDelta (BtOne "2D")]+ it "fails where the walk fails" $+ suffixed (\item -> if item == BiVoid (AtLabel "os") then Nothing else Just item) [BiVoid (AtLabel "ig"), BiVoid (AtLabel "os")]+ `shouldBe` Nothing
test/BuilderSpec.hs view
@@ -209,11 +209,11 @@ buildExpression (ExMeta "e") (substSingle "e" (MvExpression (ExFormation [BiVoid AtRho, BiVoid AtRho]))) `shouldSatisfy` isLeft describe "buildExpression" $- it "does not leave an invalid global application around rho" $+ it "keeps an application of the global object as it is" $ buildExpression (ExApplication ExRoot (ArTau AtRho (ExFormation [BiVoid AtRho]))) substEmpty- `shouldBe` Right ExRoot+ `shouldBe` Right (ExApplication ExRoot (ArTau AtRho (ExFormation [BiVoid AtRho]))) describe "pathOf" $ it "names the world itself as Φ" $
test/CLISpec.hs view
@@ -135,6 +135,50 @@ spec :: Spec spec = do+ describe "regex execution limits" $ do+ forM_+ [ ("matches", [" matches: ['^(a|b)*$', '!e1']"])+ , ("or", [" or:", " - matches: ['^(a|b)*$', '!e1']", " - eq: [1, 1]"])+ ]+ ( \(desc, condition) ->+ it ("fails normally when a " ++ desc ++ " condition exceeds the recursion limit") $+ withTempFileContent+ "regex-limit.yaml"+ ( unlines+ ( [ "name: mt"+ , "pattern: '[[ x -> !e1 ]]'"+ , "result: '[[ y -> !e1 ]]'"+ , "when:"+ ]+ ++ condition+ )+ )+ ( \path ->+ withStdin ("[[ x -> \"" ++ replicate 9000 'a' ++ "\" ]]") $+ testCLIFailed ["rewrite", "--sweet", "--rule=" ++ path] ["Regex execution failed:"]+ )+ )++ forM_ ["(a|b)*", "(ab)+"] $ \pattern ->+ forM_ ["", "g"] $ \flag ->+ it ("fails normally when sed exceeds the recursion limit with " ++ pattern ++ " and flag '" ++ flag ++ "'") $+ withTempFileContent+ "regex-limit.yaml"+ ( unlines+ [ "name: sed-limit"+ , "pattern: '[[ x -> !e1 ]]'"+ , "result: '[[ y -> !e2 ]]'"+ , "where:"+ , " - meta: '!e2'"+ , " function: sed"+ , " args: ['!e1', '\"s/" ++ pattern ++ "/X/" ++ flag ++ "\"']"+ ]+ )+ ( \path ->+ withStdin ("[[ x -> \"" ++ concat (replicate 10000 "ab") ++ "\" ]]") $+ testCLIFailed ["rewrite", "--sweet", "--rule=" ++ path] ["Regex execution failed:"]+ )+ it "prints version" $ testCLISucceeded ["--version"] [showVersion version] @@ -209,6 +253,22 @@ ["--pin=" ++ showVersion version, "--pin-file=" ++ file, "rewrite"] ["[ERROR]: Invalid option `--pin-file=" ++ file ++ "'"] + describe "--cheat" $ do+ it "drops a ρ applied to a term that already ends with one" $+ withStdin "[[ a -> Q.x(^ -> [[ ]]), b -> [[ ]] ]].a" $+ testCLISucceeded ["rewrite", "--normalize", "--flat", "--sweet", "--cheat"] ["Φ.x( ρ ↦ ⟦⟧ )"]+ it "keeps every ρ the rules prescribe without it" $+ withStdin "[[ a -> Q.x(^ -> [[ ]]), b -> [[ ]] ]].a" $+ testCLISucceeded ["rewrite", "--normalize", "--flat", "--sweet"] ["Φ.x( ρ ↦ ⟦⟧, ρ ↦ ⟦ a ↦ Φ.x( ρ ↦ ⟦⟧ ), b ↦ ⟦⟧ ⟧ )"]+ it "keeps the terms of nested forks small while dataizing" $+ withTempFileContent "cheat-atomsXXXXXX.yaml" "- λ: L_eq\n 𝑛: '⟦ if ↦ ⟦ λ ⤍ L_fork, left ↦ ∅, right ↦ ∅, on🌵 ↦ ⟦ λ ⤍ 𝜎 ⟧, left🌵 ↦ ξ.left, right🌵 ↦ ξ.right ⟧ ⟧'\n- λ: L_fork\n morph:\n 𝑛1: $.left🌵\n 𝑛2: $.right🌵\n evaluate:\n 𝑛3: 𝑛1\n 𝑛4: 𝑛2\n join:\n 'on': $.on🌵\n left: 𝑛3\n right: 𝑛4\n otherwise: L_fork\n" $ \atoms ->+ withStdin "[[ eq -> L_eq:λ, false -> [[ if(left, right) -> right:φ ]], entry -> [[ φ -> s.if(s, s), s -> Q.outer ]], outer -> [[ φ -> h.if(Q.good, h), h -> Q.inner ]], good -> [[ φ -> Q.eq, text -> [[ D> 00- ]] ]], inner -> Q.eq.if(Q.false, Q.eq.if(Q.false, Q.good)), e1 -> Q.entry.text ]]" $+ testCLISucceeded ["dataize", "--cheat", "--acyclic=plausible", "--max-loops=1", "--max-nodes=5000", "--locator=Q.e1", "--symbolic=" ++ atoms] ["00-"]+ it "lets the terms of nested forks grow while dataizing without it" $+ withTempFileContent "cheat-atomsXXXXXX.yaml" "- λ: L_eq\n 𝑛: '⟦ if ↦ ⟦ λ ⤍ L_fork, left ↦ ∅, right ↦ ∅, on🌵 ↦ ⟦ λ ⤍ 𝜎 ⟧, left🌵 ↦ ξ.left, right🌵 ↦ ξ.right ⟧ ⟧'\n- λ: L_fork\n morph:\n 𝑛1: $.left🌵\n 𝑛2: $.right🌵\n evaluate:\n 𝑛3: 𝑛1\n 𝑛4: 𝑛2\n join:\n 'on': $.on🌵\n left: 𝑛3\n right: 𝑛4\n otherwise: L_fork\n" $ \atoms ->+ withStdin "[[ eq -> L_eq:λ, false -> [[ if(left, right) -> right:φ ]], entry -> [[ φ -> s.if(s, s), s -> Q.outer ]], outer -> [[ φ -> h.if(Q.good, h), h -> Q.inner ]], good -> [[ φ -> Q.eq, text -> [[ D> 00- ]] ]], inner -> Q.eq.if(Q.false, Q.eq.if(Q.false, Q.good)), e1 -> Q.entry.text ]]" $+ testCLIFailed ["dataize", "--acyclic=plausible", "--max-loops=1", "--max-nodes=5000", "--locator=Q.e1", "--symbolic=" ++ atoms] ["--max-nodes=5000"]+ describe "--hide-rho" $ forM_ [@@ -462,6 +522,16 @@ , ["--label option can stay together with --output=latex only"] ) ,+ ( "with a '%' in --meet-prefix and --output=latex"+ , ["rewrite", "--meet-prefix=a%b", "--output=latex"]+ , ["The --meet-prefix option must contain only letters, numbers, colons, periods, underscores, and hyphens"]+ )+ ,+ ( "with a '}' in --meet-prefix and --output=latex"+ , ["rewrite", "--meet-prefix=a}b", "--output=latex"]+ , ["The --meet-prefix option must contain only letters, numbers, colons, periods, underscores, and hyphens"]+ )+ , ( "with an unsafe --label and --output=latex" , ["rewrite", "--label=eq:bad%tag", "--output=latex"] , ["The --label option must contain only letters, numbers, colons, periods, underscores, and hyphens"]@@ -1380,6 +1450,14 @@ ["rewrite", "--canonize", "--sweet", "--flat"] ["⟦ x ↦ ⟦ y ↦ Fn1:λ.q, z ↦ Φ.x( a ↦ ⟦ w ↦ Fn2:λ, λ ⤍ Fn3 ⟧ ) ⟧, λ ⤍ Package ⟧"] + it "keeps the name of a function across the steps of --sequence under --canonize" $+ withStdin "[[ a -> [[ x -> [[ L> Fa ]], y -> [[ L> Fb ]] ]] ]]" $+ testCLISucceeded+ ["rewrite", rule "drop-x.yaml", "--sequence", "--canonize", "--flat"]+ [ "⟦ a ↦ ⟦ x ↦ ⟦ λ ⤍ Fn1 ⟧, y ↦ ⟦ λ ⤍ Fn2 ⟧ ⟧ ⟧"+ , "⟦ a ↦ ⟦ y ↦ ⟦ λ ⤍ Fn2 ⟧ ⟧ ⟧"+ ]+ it "rewrites by locator" $ withStdin "[[ ex -> [[ x -> [[ y -> 5 ]].y ]], abc -> [[ x -> ? ]](x -> 5) ]]" $ testCLISucceeded@@ -1414,6 +1492,16 @@ ["rewrite", "--flat", "--normalize", "--breakpoint=dot"] ["⟦ a ↦ Φ( ρ ↦ ⟦ b ↦ Φ ⟧ ) ⟧"] + it "reads back an application of ξ as it is" $+ withStdin "[[ a -> [[ x -> ∅ ]], b -> $(x -> [[ ]]) ]]" $+ testCLISucceeded ["rewrite", "--flat"] ["⟦ a ↦ ⟦ x ↦ ∅ ⟧, b ↦ ξ( x ↦ ⟦⟧ ) ⟧"]++ it "keeps the ρ that dot applies to Φ, and reads it back" $ do+ withStdin "[[ x -> [[ y -> Q ]].y ]]" $+ testCLISucceeded ["rewrite", "--normalize", "--flat"] ["⟦ x ↦ Φ( ρ ↦ ⟦ y ↦ Φ ⟧ ) ⟧"]+ withStdin "⟦ x ↦ Φ( ρ ↦ ⟦ y ↦ Φ ⟧ ) ⟧" $+ testCLISucceeded ["rewrite", "--flat"] ["⟦ x ↦ Φ( ρ ↦ ⟦ y ↦ Φ ⟧ ) ⟧"]+ describe "morph --focus under --locator" $ do it "finds the same object for the steps and for the answer" $ withStdin "⟦ t ↦ ⟦ a ↦ ⟦ Δ ⤍ 01- ⟧ ⟧, a ↦ ⟦ Δ ⤍ 02- ⟧ ⟧" $ do@@ -1616,6 +1704,22 @@ ["dataize", "--locator=Q.t", "--acyclic=proven", "--max-loops=1", "--max-steps=4000"] ["40-45-00-00-00-00-00-00"] + describe "over a recursion that takes an attribute off its own call" $ do+ let world = "⟦ num(φ) ↦ ⟦ gt(ρ, b) ↦ L_gt:λ, plus(ρ, b) ↦ L_plus:λ ⟧, seq(i) ↦ ⟦ φ ↦ Φ.num( φ ↦ 𝜎1:λ ).gt( i ).if( Φ.seq( i.plus( Φ.num( φ ↦ 01-:Δ ) ) ).plus( Φ.num( φ ↦ 01-:Δ ) ), i ) ⟧, app ↦ Φ.seq( Φ.num( φ ↦ 00-:Δ ) ) ⟧"+ atoms = T.pack "- λ: L_gt\n dataize: {𝛿1: $.b}\n 𝑛: ⟦ if ↦ ⟦ λ ⤍ L_fork, left ↦ ∅, right ↦ ∅, on🌵 ↦ ⟦ λ ⤍ 𝜎 ⟧, left🌵 ↦ ξ.left, right🌵 ↦ ξ.right ⟧ ⟧\n- λ: L_fork\n morph: {𝑛1: $.left🌵, 𝑛2: $.right🌵}\n evaluate: {𝑛3: 𝑛1, 𝑛4: 𝑛2}\n symbolize: {𝑛5: 𝑛3, 𝑛6: 𝑛4}\n cast: {𝑛7: 𝑛5, 𝑛8: 𝑛6}\n join: {'on': $.on🌵, left: 𝑛7, right: 𝑛8, otherwise: L_fork}\n- λ: L_plus\n dataize: {𝛿1: $.ρ}\n 𝑛: Φ.num( φ ↦ ⟦ λ ⤍ 𝜎 ⟧ )\n"+ it "cuts the recursion by --max-loops, not by --max-steps" $+ withLambdasOf atoms $ \file ->+ withStdin world $+ testCLISucceeded ["dataize", "--symbolic=" ++ file, "--locator=Q.app", "--acyclic=plausible", "--max-loops=1", "--partial", "--cheat", "--max-steps=1000", "--max-firings=50"] ["40-45-00-00-00-00-00-00"]+ it "writes the cut of the dispatch off the copy that repeats one above" $+ withTempFile "protocolXXXXXX.txt" $ \(path, stream) -> do+ hClose stream+ withLambdasOf atoms $ \file ->+ withStdin world $+ testCLISucceeded ["dataize", "--symbolic=" ++ file, "--locator=Q.app", "--acyclic=plausible", "--max-loops=1", "--partial", "--cheat", "--quiet", "--sweet", "--hide-rho", "--minutes=" ++ path] []+ records <- map (dropWhile (== ' ')) . lines <$> readProtocol path+ records `shouldContain` ["looped 𝜎5 := 𝑛·5·1.plus # plausible, repeats 𝑛·0·4"]+ it "refuses a negative count" $ withStdin once $ testCLIFailed ["dataize", "--locator=Q.t", "--acyclic=plausible", "--max-loops=-1"] ["--max-loops must be >= 0"]@@ -1624,6 +1728,31 @@ withStdin once $ testCLIFailed ["dataize", "--locator=Q.t", "--max-loops=1"] ["The option --max-loops requires --acyclic, since only --acyclic cuts a loop"] + describe "--acyclic=plausible over a mutual recursion of four objects" $ do+ let world = "⟦ bit(fork) ↦ ⟦ if ↦ ξ.fork, φ ↦ ξ.fork( FF-:Δ, 00-:Δ ) ⟧, eq(a, b) ↦ ⟦ λ ⤍ L_eq ⟧, byte(data, i) ↦ ⟦ λ ⤍ L_byte ⟧, plus(i) ↦ ⟦ λ ⤍ L_plus ⟧, read(p) ↦ ⟦ at ↦ ξ.p ⟧, f1(i) ↦ ⟦ φ ↦ Φ.eq( Φ.byte( 𝜎1:λ, ξ.i ), 28-:Δ ).if( Φ.read( Φ.f4( Φ.plus( ξ.i ) ).at ), Φ.read( Φ.plus( ξ.i ) ) ) ⟧, " ++ intercalate ", " [printf "f%d(i) ↦ ⟦ φ ↦ Φ.eq( Φ.byte( 𝜎1:λ, ξ.i ), %02X-:Δ ).if( Φ.read( ξ.i ), Φ.f%d( Φ.f%d( ξ.i ).at ) ) ⟧" level (0x28 + level :: Int) level (level - 1) | level <- [2 .. 4 :: Int]] ++ ", t ↦ Φ.f4( 00-:Δ ).at ⟧"+ atoms = T.pack "- λ: L_fork\n dataize: {𝛿1: $.on🌵}\n morph: {𝑛1: $.left🌵, 𝑛2: $.right🌵}\n stay: {𝑛3: 𝑛1, 𝑛4: 𝑛2}\n evaluate: {𝑛5: 𝑛3, 𝑛6: 𝑛4}\n undress: {𝑛15: 𝑛5, 𝑛16: 𝑛6}\n symbolize: {𝑛11: 𝑛15, 𝑛12: 𝑛16}\n defer: {𝑛13: 𝑛11, 𝑛14: 𝑛12}\n cast: {𝑛19: 𝑛13, 𝑛20: 𝑛14}\n join: {'on': 𝛿1, left: 𝑛19, right: 𝑛20, otherwise: L_fork}\n- λ: L_eq\n dataize: {𝛿1: $.a, 𝛿2: $.b}\n 𝑛: Φ.bit( ⟦ λ ⤍ L_fork, left ↦ ∅, right ↦ ∅, on🌵 ↦ ⟦ λ ⤍ 𝜎 ⟧, left🌵 ↦ ξ.left, right🌵 ↦ ξ.right ⟧ )\n- λ: L_byte\n dataize: {𝛿1: $.data, 𝛿2: $.i}\n 𝑛: ⟦ λ ⤍ 𝜎 ⟧\n- λ: L_plus\n dataize: {𝛿1: $.i}\n 𝑛: ⟦ λ ⤍ 𝜎 ⟧\n"+ it "answers the rounds alike an earlier one from memory, within a cap of firings the work of every round runs over" $+ withLambdasOf atoms $ \file ->+ withStdin world $+ testCLISucceeded ["dataize", "--symbolic=" ++ file, "--locator=Q.t", "--acyclic=plausible", "--max-loops=1", "--max-firings=400"] ["40-45-00-00-00-00-00-00"]++ describe "--acyclic=plausible over an accumulator that grows every round" $ do+ let world = "⟦ bit(fork) ↦ ⟦ if ↦ ξ.fork, φ ↦ ξ.fork( FF-:Δ, 00-:Δ ) ⟧, eq(a, b) ↦ ⟦ λ ⤍ L_eq ⟧, byte(data, i) ↦ ⟦ λ ⤍ L_byte ⟧, plus(x) ↦ ⟦ λ ⤍ L_plus ⟧, state(at, groups) ↦ ⟦ φ ↦ ξ.at ⟧, more(acc) ↦ ⟦ φ ↦ Φ.eq( Φ.byte( 𝜎1:λ, ξ.acc.at ), 29-:Δ ).if( ξ.acc, Φ.more( Φ.more( Φ.state( Φ.plus( ξ.acc.at ), ξ.acc.groups ) ) ) ) ⟧, e1 ↦ Φ.byte( 𝜎1:λ, Φ.more( Φ.state( 00-:Δ, 00-:Δ ) ).at ) ⟧"+ atoms = T.pack "- λ: L_fork\n dataize: {𝛿1: $.on🌵}\n morph: {𝑛1: $.left🌵, 𝑛2: $.right🌵}\n stay: {𝑛3: 𝑛1, 𝑛4: 𝑛2}\n evaluate: {𝑛5: 𝑛3, 𝑛6: 𝑛4}\n undress: {𝑛15: 𝑛5, 𝑛16: 𝑛6}\n symbolize: {𝑛11: 𝑛15, 𝑛12: 𝑛16}\n defer: {𝑛13: 𝑛11, 𝑛14: 𝑛12}\n cast: {𝑛19: 𝑛13, 𝑛20: 𝑛14}\n join: {'on': 𝛿1, left: 𝑛19, right: 𝑛20, otherwise: L_fork}\n- λ: L_eq\n dataize: {𝛿1: $.a, 𝛿2: $.b}\n 𝑛: Φ.bit( ⟦ λ ⤍ L_fork, left ↦ ∅, right ↦ ∅, on🌵 ↦ ⟦ λ ⤍ 𝜎 ⟧, left🌵 ↦ ξ.left, right🌵 ↦ ξ.right ⟧ )\n- λ: L_byte\n dataize: {𝛿1: $.data, 𝛿2: $.i}\n 𝑛: ⟦ λ ⤍ 𝜎 ⟧\n- λ: L_plus\n dataize: {𝛿1: $.x}\n 𝑛: ⟦ λ ⤍ 𝜎 ⟧\n"+ it "shares the accumulator by a name, so no line of the minutes grows with the rounds" $+ withTempFile "protocolXXXXXX.txt" $ \(path, stream) -> do+ hClose stream+ withLambdasOf atoms $ \file ->+ withStdin world $+ testCLISucceeded ["dataize", "--symbolic=" ++ file, "--locator=Q.e1", "--acyclic=plausible", "--max-loops=2", "--max-seconds=60", "--minutes=" ++ path, "--sweet", "--hide-rho"] ["40-45-00-00-00-00-00-00"]+ records <- lines <$> readProtocol path+ (any (isPrefixOf "shared " . dropWhile (== ' ')) records, maximum (map length records) < 1000) `shouldBe` (True, True)++ it "gives an argument read off a copy one name, so a chain of recursions stays within a cap of firings" $+ withLambdasOf atoms $ \file ->+ withStdin "⟦ bit(fork) ↦ ⟦ if ↦ ξ.fork, φ ↦ ξ.fork( FF-:Δ, 00-:Δ ) ⟧, eq(a, b) ↦ ⟦ λ ⤍ L_eq ⟧, byte(data, i) ↦ ⟦ λ ⤍ L_byte ⟧, num(v) ↦ ⟦ φ ↦ ξ.v, next ↦ Φ.num( ξ.v ) ⟧, r1(i) ↦ ⟦ φ ↦ Φ.eq( Φ.byte( 𝜎1:λ, ξ.i ), 0A-:Δ ).if( ξ.i, Φ.r1( ξ.i.next ) ) ⟧, r2(i) ↦ ⟦ φ ↦ Φ.eq( Φ.byte( 𝜎1:λ, ξ.i ), 22-:Δ ).if( Φ.r2( Φ.r1( ξ.i.next ) ), ξ.i ) ⟧, r3(i) ↦ ⟦ φ ↦ Φ.eq( Φ.byte( 𝜎1:λ, ξ.i ), 23-:Δ ).if( Φ.r3( Φ.r2( ξ.i.next ) ), ξ.i ) ⟧, r4(i) ↦ ⟦ φ ↦ Φ.eq( Φ.byte( 𝜎1:λ, ξ.i ), 24-:Δ ).if( Φ.r4( Φ.r3( ξ.i.next ) ), ξ.i ) ⟧, e1 ↦ Φ.byte( 𝜎1:λ, Φ.r4( Φ.num( 00-:Δ ) ) ) ⟧" $+ testCLISucceeded ["dataize", "--symbolic=" ++ file, "--locator=Q.e1", "--acyclic=plausible", "--max-loops=1", "--max-firings=600"] ["40-45-00-00-00-00-00-00"]+ describe "--acyclic at a recursive call" $ do let recursive = "⟦ call(a) ↦ ⟦ λ ⤍ L_call ⟧, wrap(v) ↦ ⟦⟧, down(i) ↦ ⟦ φ ↦ Φ.call( a ↦ Φ.down( i ↦ Φ.wrap( v ↦ i ) ) ) ⟧, t ↦ Φ.down( i ↦ ⟦ Δ ⤍ 01- ⟧ ) ⟧" calling = T.pack "- λ: L_call\n morph:\n 𝑛1: $.a\n evaluate:\n 𝑛2: 𝑛1\n 𝑛: 𝑛2\n"@@ -1642,12 +1771,15 @@ withStdin recursive $ testCLISucceeded ["dataize", "--symbolic=" ++ file, "--locator=Q.t", "--acyclic=plausible"] ["40-45-00-00-00-00-00-00"] - it "writes the recursive call it cuts to the protocol as a call of the object" $- recorded "protocolXXXXXX.txt" >>= (`shouldContain` [" looped 𝜎1 := Φ.down( i ↦ 𝑛·1·7 ) # plausible, repeats 𝑛·0·4"])+ it "writes the recursive call an operand comes to to the protocol as passed, as a call of the object" $+ recorded "protocolXXXXXX.txt" >>= (`shouldContain` [" passed 𝑛·1·4 := Φ.down( i ↦ Φ.wrap( v ↦ 01-:Δ ) ) # plausible, repeats 𝑛·0·4"]) - it "writes the recursive call it cuts to the XML protocol with the object and the metas of its arguments" $- recorded "protocolXXXXXX.xml" >>= (`shouldContain` [" <looped symbol=\"𝜎1\" by=\"morph\" match=\"plausible\" at=\"ξ.a\" of=\"𝑛·0·4\" object=\"Φ.down\"><with><meta attr=\"i\">𝑛·1·7</meta></with></looped>"])+ it "writes the recursive call an operand comes to to the XML protocol as passed, with the object and the metas of its arguments" $+ recorded "protocolXXXXXX.xml" >>= (`shouldContain` [" <passed meta=\"𝑛·1·4\" by=\"morph\" match=\"plausible\" at=\"ξ.a\" of=\"𝑛·0·4\" object=\"Φ.down\"><with><meta attr=\"i\">𝑒·0·2</meta></with></passed>"]) + it "cuts the recursive call after the firing that handed it back" $+ recorded "protocolXXXXXX.txt" >>= (`shouldContain` [" looped 𝜎1 := Φ.down( i ↦ Φ.wrap( v ↦ 01-:Δ ) ) # 𝔼(𝑛·0·13.a), plausible, repeats 𝑛·0·13"])+ describe "--acyclic at a recursive call through a fork" $ do let recursive = "⟦ if(c, a, b) ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ ξ.c, left🌵 ↦ ξ.a, right🌵 ↦ ξ.b ⟧, wrap(v) ↦ ⟦⟧, down(i) ↦ ⟦ φ ↦ Φ.if( c ↦ ⟦ λ ⤍ 𝜎1 ⟧, a ↦ Φ.down( i ↦ Φ.wrap( v ↦ i ) ), b ↦ ⟦ φ ↦ ⟦ λ ⤍ 𝜎2 ⟧ ⟧ ) ⟧, t ↦ Φ.down( i ↦ ⟦ Δ ⤍ 01- ⟧ ) ⟧" forking = T.pack "- λ: L_fork\n dataize:\n 𝛿1: $.on🌵\n morph:\n 𝑛1: $.left🌵\n 𝑛2: $.right🌵\n evaluate:\n 𝑛3: 𝑛1\n 𝑛4: 𝑛2\n cast:\n 𝑛5: 𝑛3\n 𝑛6: 𝑛4\n join:\n on: 𝛿1\n left: 𝑛5\n right: 𝑛6\n otherwise: L_fork\n"@@ -1666,15 +1798,40 @@ withStdin recursive $ testCLISucceeded ["dataize", "--symbolic=" ++ file, "--locator=Q.t", "--acyclic=plausible", "--max-loops=1"] ["40-45-00-00-00-00-00-00"] - it "writes the copy it cuts in a side of a fork to the protocol as a call of the object" $- recorded "1" "protocolXXXXXX.txt" >>= (`shouldContain` [" looped 𝜎3 := Φ.down( i ↦ 𝑛·3·7 ) # plausible, repeats 𝑛·0·4"])+ it "writes the copy a side of a fork comes to again to the protocol as passed, as a call of the object" $+ recorded "1" "protocolXXXXXX.txt" >>= (`shouldContain` [" passed 𝑛·3·4 := Φ.down( i ↦ Φ.wrap( v ↦ Φ.wrap( v ↦ 01-:Δ ) ) ) # plausible, repeats 𝑛·0·4"]) - it "writes the copy it cuts in a side of a fork to the XML protocol with the object and the metas of its arguments" $- recorded "1" "protocolXXXXXX.xml" >>= (`shouldContain` [" <looped symbol=\"𝜎3\" by=\"morph\" match=\"plausible\" at=\"ξ.left🌵\" of=\"𝑛·0·4\" object=\"Φ.down\"><with><meta attr=\"i\">𝑛·3·7</meta></with></looped>"])+ it "writes the copy a side of a fork comes to again to the XML protocol as passed, with the object and the metas of its arguments" $+ recorded "1" "protocolXXXXXX.xml" >>= (`shouldContain` [" <passed meta=\"𝑛·3·4\" by=\"morph\" match=\"plausible\" at=\"ξ.left🌵\" of=\"𝑛·0·4\" object=\"Φ.down\"><with><meta attr=\"i\">𝑒·2·3</meta></with></passed>"]) it "counts the copies the sides of earlier rounds of a fork made under --max-loops=2" $- recorded "2" "protocolXXXXXX.txt" >>= (`shouldContain` [" looped 𝜎3 := Φ.down( i ↦ 𝑛·6·7 ) # plausible, repeats 𝑛·0·4"])+ recorded "2" "protocolXXXXXX.txt" >>= (`shouldContain` [" passed 𝑛·6·4 := Φ.down( i ↦ Φ.wrap( v ↦ Φ.wrap( v ↦ Φ.wrap( v ↦ 01-:Δ ) ) ) ) # plausible, repeats 𝑛·0·4"]) + describe "--acyclic at an object an atom only hands back" $ do+ let world = "⟦ call(a) ↦ ⟦ λ ⤍ L_call ⟧, down ↦ ⟦ φ ↦ Φ.call( Φ.down ).at, at ↦ 2A-:Δ ⟧, t ↦ Φ.down ⟧"+ calling = T.pack "- λ: L_call\n morph:\n 𝑛1: $.a\n 𝑛: 𝑛1\n"+ recorded :: String -> IO [String]+ recorded name =+ withTempFile name $ \(path, stream) -> do+ hClose stream+ withLambdasOf calling $ \file ->+ withStdin world $+ testCLISucceeded+ ["dataize", "--symbolic=" ++ file, "--locator=Q.t", "--acyclic=plausible", recording path, "--quiet", "--sweet", "--hide-rho"]+ []+ lines <$> readProtocol path+ forM_ ["plausible", "proven"] $ \mode ->+ it ("hands the object back as it is and takes the attribute off it under --acyclic=" ++ mode) $+ withLambdasOf calling $ \file ->+ withStdin world $+ testCLISucceeded ["dataize", "--symbolic=" ++ file, "--locator=Q.t", "--acyclic=" ++ mode] ["2A-"]++ it "writes the object it hands back to the protocol as passed" $+ recorded "protocolXXXXXX.txt" >>= (`shouldContain` [" passed 𝑛·1·2 := Φ.down # plausible, repeats 𝑛·1·1"])++ it "writes the object it hands back to the XML protocol as passed" $+ recorded "protocolXXXXXX.xml" >>= (`shouldContain` [" <passed meta=\"𝑛·1·2\" by=\"morph\" match=\"plausible\" at=\"ξ.a\" of=\"𝑛·1·1\" object=\"Φ.down\"/>"])+ describe "--acyclic at a copy holding a λ" $ do let recursive = "⟦ dataized(target) ↦ ⟦ λ ⤍ L_dataized ⟧, fork(left, right) ↦ ⟦ λ ⤍ L_fork, on🌵 ↦ ⟦ λ ⤍ 𝜎4 ⟧, left🌵 ↦ ξ.left, right🌵 ↦ ξ.right ⟧, x ↦ Φ.dataized( Φ.fork( Φ.dataized( Φ.x ), ⟦ λ ⤍ 𝜎3 ⟧ ) ) ⟧" forking = T.pack "- λ: L_fork\n dataize:\n 𝛿1: $.on🌵\n morph:\n 𝑛1: $.left🌵\n 𝑛2: $.right🌵\n evaluate:\n 𝑛3: 𝑛1\n 𝑛4: 𝑛2\n join:\n on: 𝛿1\n left: 𝑛3\n right: 𝑛4\n otherwise: L_fork\n- λ: L_dataized\n dataize:\n 𝛿1: $.target\n 𝑛: ⟦ λ ⤍ 𝜎 ⟧\n"@@ -1718,10 +1875,10 @@ [] lines <$> readProtocol path it "writes the copy it cuts to the protocol as a call of the object with the attribute it ends with" $- recorded "protocolXXXXXX.txt" >>= (`shouldSatisfy` any (isInfixOf "looped 𝜎6 := Φ.fork( left ↦ 𝑛·9·9, right ↦ 𝑛·11·1 ).right🌵.φ # plausible"))+ recorded "protocolXXXXXX.txt" >>= (`shouldSatisfy` any (isInfixOf "looped 𝜎6 := Φ.fork( left ↦ 𝑛·9·9, right ↦ 𝑛·11·2 ).right🌵.φ # plausible")) it "writes the copy it cuts to the XML protocol with the object, the metas of its arguments and the attribute it ends with" $- recorded "protocolXXXXXX.xml" >>= (`shouldSatisfy` any (isInfixOf "object=\"Φ.fork\" dispatch=\"right🌵.φ\"><with><meta attr=\"left\">𝑛·9·9</meta><meta attr=\"right\">𝑛·11·1</meta></with></looped>"))+ recorded "protocolXXXXXX.xml" >>= (`shouldSatisfy` any (isInfixOf "object=\"Φ.fork\" dispatch=\"right🌵.φ\"><with><meta attr=\"left\">𝑛·9·9</meta><meta attr=\"right\">𝑛·11·2</meta></with></looped>")) describe "--acyclic at a copy whose argument repeats the same loop" $ do let recursive = "⟦ dataized(target) ↦ ⟦ λ ⤍ L_dataized ⟧, times(b) ↦ ⟦ λ ⤍ L_times ⟧, x ↦ Φ.times( Φ.dataized( Φ.x ) ) ⟧"@@ -2157,13 +2314,14 @@ , " normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20" , " 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0" , " 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)"- , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛"+ , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus" , " 𝕄(𝑛·1·22):" , " 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )" , " 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧" , " morphed 𝑛·1·25 := 𝑛·1·24" , " 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)"- , " boxed 𝑛·0·10 := 𝑛·1·26.φ"+ , " evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·8"+ , " boxed 𝑛·0·10 := 𝑛·1·27.φ" , " normalized 𝑛·0·11 := 𝜎1:λ # 𝑛·0·10" , " 𝛿·0·1 := 𝔻(𝜎1:λ)" ]@@ -2186,12 +2344,13 @@ , " remembered 𝑛·0·5 ≡ Φ.make # L_make:λ" , " morphed 𝑛·0·6 := 𝑛·0·5" , " 𝔼(L_make): # 𝔻(𝑛·0·3)"- , " 𝑛·1·1 := Φ.bytes( φ ↦ 𝜎1:λ ):φ # 𝑛"+ , " 𝑛·1·1 := Φ.bytes( φ ↦ 𝜎1:λ ):φ # 𝑛 of L_make" , " 𝕄(𝑛·1·1):" , " morphed 𝑛·1·2 := Φ.bytes( φ ↦ 𝜎1:λ ):φ" , " 𝑛·1·3 := 𝑛·1·2 # 𝕄(𝑛·1·1)" , " remembered 𝑛·1·3 ≡ 𝑛·0·5"- , " boxed 𝑛·0·7 := 𝑛·1·3.φ"+ , " evaluated 𝑛·1·4 := 𝑛·1·3 # 𝑛·0·5"+ , " boxed 𝑛·0·7 := 𝑛·1·4.φ" , " normalized 𝑛·0·8 := Φ.bytes( φ ↦ 𝜎1:λ ) # 𝑛·0·7" , " 𝕄(𝑛·0·7):" , " normalized 𝑛·0·9 := ∅:φ # Φ.bytes"@@ -2252,13 +2411,14 @@ , " normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20" , " 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0" , " 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)"- , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛"+ , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus" , " 𝕄(𝑛·1·22):" , " 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )" , " 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧" , " morphed 𝑛·1·25 := 𝑛·1·24" , " 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)"- , " normalized 𝑛·0·9 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·26.plus"+ , " evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·8"+ , " normalized 𝑛·0·9 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·27.plus" , " 𝑛·0·10 := 𝑛·1·23.plus( x ↦ 7.0 )" , " 𝑛·0·11 := ⟦ x ↦ 7.0, λ ⤍ L_number_plus ⟧" , " morphed 𝑛·0·12 := 𝑛·0·11"@@ -2287,13 +2447,14 @@ , " normalized 𝑛·2·15 := 40-1C-00-00-00-00-00-00:Δ # 𝑛·2·14" , " 𝛿·2·2 := 40-1C-00-00-00-00-00-00 # 7.0" , " 𝛿2·2 := 𝛿·2·2 # 𝔻(ξ.x)"- , " 𝑛·2·16 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛"+ , " 𝑛·2·16 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus" , " 𝕄(𝑛·2·16):" , " 𝑛·2·17 := Φ.number( φ ↦ 𝜎2:λ )" , " 𝑛·2·18 := ⟦ φ ↦ 𝜎2:λ, plus(x) ↦ L_number_plus:λ ⟧" , " morphed 𝑛·2·19 := 𝑛·2·18" , " 𝑛·2·20 := 𝑛·2·19 # 𝕄(𝑛·2·16)"- , " boxed 𝑛·0·13 := 𝑛·2·20.φ"+ , " evaluated 𝑛·2·21 := 𝑛·2·20 # 𝑛·0·11"+ , " boxed 𝑛·0·13 := 𝑛·2·21.φ" , " normalized 𝑛·0·14 := 𝜎2:λ # 𝑛·0·13" , " 𝛿·0·1 := 𝔻(𝜎2:λ)" ]@@ -2347,13 +2508,14 @@ , " normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20" , " 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0" , " 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)"- , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛"+ , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus" , " 𝕄(𝑛·1·22):" , " 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )" , " 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ, times(x) ↦ L_number_times:λ ⟧" , " morphed 𝑛·1·25 := 𝑛·1·24" , " 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)"- , " normalized 𝑛·0·9 := ⟦ x ↦ ∅, λ ⤍ L_number_times ⟧ # 𝑛·1·26.times"+ , " evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·8"+ , " normalized 𝑛·0·9 := ⟦ x ↦ ∅, λ ⤍ L_number_times ⟧ # 𝑛·1·27.times" , " 𝑛·0·10 := 𝑛·1·23.times( x ↦ 7.0 )" , " 𝑛·0·11 := ⟦ x ↦ 7.0, λ ⤍ L_number_times ⟧" , " morphed 𝑛·0·12 := 𝑛·0·11"@@ -2382,13 +2544,14 @@ , " normalized 𝑛·2·15 := 40-1C-00-00-00-00-00-00:Δ # 𝑛·2·14" , " 𝛿·2·2 := 40-1C-00-00-00-00-00-00 # 7.0" , " 𝛿2·2 := 𝛿·2·2 # 𝔻(ξ.x)"- , " 𝑛·2·16 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛"+ , " 𝑛·2·16 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_times" , " 𝕄(𝑛·2·16):" , " 𝑛·2·17 := Φ.number( φ ↦ 𝜎2:λ )" , " 𝑛·2·18 := ⟦ φ ↦ 𝜎2:λ, plus(x) ↦ L_number_plus:λ, times(x) ↦ L_number_times:λ ⟧" , " morphed 𝑛·2·19 := 𝑛·2·18" , " 𝑛·2·20 := 𝑛·2·19 # 𝕄(𝑛·2·16)"- , " boxed 𝑛·0·13 := 𝑛·2·20.φ"+ , " evaluated 𝑛·2·21 := 𝑛·2·20 # 𝑛·0·11"+ , " boxed 𝑛·0·13 := 𝑛·2·21.φ" , " normalized 𝑛·0·14 := 𝜎2:λ # 𝑛·0·13" , " 𝛿·0·1 := 𝔻(𝜎2:λ)" ]@@ -2408,8 +2571,9 @@ , " 𝑛·0·4 := 5.0" , " 𝑛·0·5 := ⟦ φ ↦ Φ.bytes( φ ↦ 40-14-00-00-00-00-00-00:Δ ), plus(x) ↦ L_number_plus:λ ⟧" , " normalized 𝑛·0·6 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·0·5.plus"- , " 𝑛·0·7 := 𝑛·0·4.plus( x ↦ 6.0.plus( 7.0 ) )"- , " 𝑛·0·8 := ⟦ x ↦ 6.0.plus( 7.0 ), λ ⤍ L_number_plus ⟧"+ , " shared 𝑛·1 := 6.0.plus( 7.0 )"+ , " 𝑛·0·7 := 𝑛·0·4.plus( x ↦ 𝑛·1 )"+ , " 𝑛·0·8 := ⟦ x ↦ 𝑛·1, λ ⤍ L_number_plus ⟧" , " morphed 𝑛·0·9 := 𝑛·0·8" , " 𝔼(L_number_plus): # 𝔻(𝑛·0·1)" , " 𝔻(ξ.ρ):"@@ -2467,23 +2631,25 @@ , " normalized 𝑛·2·20 := 40-1C-00-00-00-00-00-00:Δ # 𝑛·2·19" , " 𝛿·2·2 := 40-1C-00-00-00-00-00-00 # 7.0" , " 𝛿2·2 := 𝛿·2·2 # 𝔻(ξ.x)"- , " 𝑛·2·21 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛"+ , " 𝑛·2·21 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus" , " 𝕄(𝑛·2·21):" , " 𝑛·2·22 := Φ.number( φ ↦ 𝜎1:λ )" , " 𝑛·2·23 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧" , " morphed 𝑛·2·24 := 𝑛·2·23" , " 𝑛·2·25 := 𝑛·2·24 # 𝕄(𝑛·2·21)"- , " boxed 𝑛·1·18 := 𝑛·2·25.φ"+ , " evaluated 𝑛·2·26 := 𝑛·2·25 # 𝑛·1·16"+ , " boxed 𝑛·1·18 := 𝑛·2·26.φ" , " normalized 𝑛·1·19 := 𝜎1:λ # 𝑛·1·18" , " 𝛿·1·2 := 𝔻(𝜎1:λ)" , " 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)"- , " 𝑛·1·20 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛"+ , " 𝑛·1·20 := Φ.number( φ ↦ 𝜎2:λ ) # 𝑛 of L_number_plus" , " 𝕄(𝑛·1·20):" , " 𝑛·1·21 := Φ.number( φ ↦ 𝜎2:λ )" , " 𝑛·1·22 := ⟦ φ ↦ 𝜎2:λ, plus(x) ↦ L_number_plus:λ ⟧" , " morphed 𝑛·1·23 := 𝑛·1·22" , " 𝑛·1·24 := 𝑛·1·23 # 𝕄(𝑛·1·20)"- , " boxed 𝑛·0·10 := 𝑛·1·24.φ"+ , " evaluated 𝑛·1·25 := 𝑛·1·24 # 𝑛·0·8"+ , " boxed 𝑛·0·10 := 𝑛·1·25.φ" , " normalized 𝑛·0·11 := 𝜎2:λ # 𝑛·0·10" , " 𝛿·0·1 := 𝔻(𝜎2:λ)" ]@@ -2603,13 +2769,14 @@ , " normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20" , " 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0" , " 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)"- , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛"+ , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus" , " 𝕄(𝑛·1·22):" , " 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )" , " 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ, nope ↦ L_number_nope:λ ⟧" , " morphed 𝑛·1·25 := 𝑛·1·24" , " 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)"- , " normalized 𝑛·0·9 := L_number_nope:λ # 𝑛·1·26.nope"+ , " evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·8"+ , " normalized 𝑛·0·9 := L_number_nope:λ # 𝑛·1·27.nope" , " morphed 𝑛·0·10 := L_number_nope:λ" , " unanswered L_number_nope # 𝔻(L_number_nope:λ)" ]@@ -2627,7 +2794,7 @@ withStdin sum' $ testCLISucceeded ["dataize", symbolic, "--minutes=" ++ path, "--output=xmir", "--quiet", "--sweet", "--hide-rho"] [] records <- readProtocol path- records `shouldEndWith` " 𝕄(𝑛·1·22):\n 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )\n 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧\n morphed 𝑛·1·25 := 𝑛·1·24\n 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)\n boxed 𝑛·0·10 := 𝑛·1·26.φ\n normalized 𝑛·0·11 := 𝜎1:λ # 𝑛·0·10\n 𝛿·0·1 := 𝔻(𝜎1:λ)\n"+ records `shouldEndWith` " 𝕄(𝑛·1·22):\n 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )\n 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧\n morphed 𝑛·1·25 := 𝑛·1·24\n 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)\n evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·8\n boxed 𝑛·0·10 := 𝑛·1·27.φ\n normalized 𝑛·0·11 := 𝜎1:λ # 𝑛·0·10\n 𝛿·0·1 := 𝔻(𝜎1:λ)\n" it "numbers every step in the text as the XML of the same run numbers it" $ withTempFile "protocolXXXXXX.txt" $ \(text, one) ->@@ -2640,7 +2807,7 @@ testCLISucceeded ["dataize", symbolic, "--protocol=" ++ xml, "--quiet", "--sweet", "--hide-rho"] [] lined <- readProtocol text marked <- readProtocol xml- [meta | meta : ":=" : _ <- map (dropWhile (`elem` ["boxed", "morphed", "normalized", "fabricated"]) . words) (lines lined), "𝑛·" `isPrefixOf` meta]+ [meta | meta : ":=" : _ <- map (dropWhile (`elem` ["boxed", "morphed", "normalized", "fabricated", "evaluated", "shared"]) . words) (lines lined), "𝑛·" `isPrefixOf` meta] `shouldBe` [takeWhile (/= '"') (drop 6 token) | token <- words marked, "meta=\"𝑛·" `isPrefixOf` token] describe "as XML" $ do@@ -2718,8 +2885,9 @@ , " <morphed meta=\"𝑛·1·25\">𝑛·1·24</morphed>" , " </morph>" , " <answered meta=\"𝑛·1·26\">𝑛·1·25</answered>"+ , " <evaluated meta=\"𝑛·1·27\" of=\"𝑛·0·8\">𝑛·1·26</evaluated>" , " </evaluate>"- , " <boxed meta=\"𝑛·0·10\">𝑛·1·26.φ</boxed>"+ , " <boxed meta=\"𝑛·0·10\">𝑛·1·27.φ</boxed>" , " <normalized meta=\"𝑛·0·11\" of=\"𝑛·0·10\">𝜎1</normalized>" , " <manufactured meta=\"𝛿·0·1\">𝜎1</manufactured>" , "</dataize>"@@ -2870,8 +3038,9 @@ , " <morphed meta=\"𝑛·1·25\">𝑛·1·24</morphed>" , " </morph>" , " <answered meta=\"𝑛·1·26\">𝑛·1·25</answered>"+ , " <evaluated meta=\"𝑛·1·27\" of=\"𝑛·0·8\">𝑛·1·26</evaluated>" , " </evaluate>"- , " <normalized meta=\"𝑛·0·9\" of=\"𝑛·1·26.plus\">𝑛·1·23.plus</normalized>"+ , " <normalized meta=\"𝑛·0·9\" of=\"𝑛·1·27.plus\">𝑛·1·23.plus</normalized>" , " <applied meta=\"𝑛·0·10\" by=\"morph\" at=\"𝑛·0·1\" of=\"𝑛·1·23.plus\"><meta attr=\"x\">𝑒·0·7</meta></applied>" , " <formed meta=\"𝑛·0·11\" of=\"𝑛·1·23.plus\"><meta attr=\"x\">𝑒·0·7</meta></formed>" , " <morphed meta=\"𝑛·0·12\">𝑛·0·11</morphed>"@@ -2916,8 +3085,9 @@ , " <morphed meta=\"𝑛·2·19\">𝑛·2·18</morphed>" , " </morph>" , " <answered meta=\"𝑛·2·20\">𝑛·2·19</answered>"+ , " <evaluated meta=\"𝑛·2·21\" of=\"𝑛·0·11\">𝑛·2·20</evaluated>" , " </evaluate>"- , " <boxed meta=\"𝑛·0·13\">𝑛·2·20.φ</boxed>"+ , " <boxed meta=\"𝑛·0·13\">𝑛·2·21.φ</boxed>" , " <normalized meta=\"𝑛·0·14\" of=\"𝑛·0·13\">𝜎2</normalized>" , " <manufactured meta=\"𝛿·0·1\">𝜎2</manufactured>" , "</dataize>"@@ -2977,8 +3147,10 @@ , " <joined symbol=\"𝜎4\" on=\"𝛿1·1\" left=\"𝜎2\" right=\"𝜎3\"/>" , " <formed meta=\"𝑒·1·3\"><symbol attr=\"φ\">𝜎4</symbol></formed>" , " <answered meta=\"𝑛·1·3\">𝑒·1·3</answered>"+ , " <formed meta=\"𝑒·1·4\" λ=\"L_fork\"><symbol attr=\"c\">𝜎1</symbol><meta attr=\"a\">𝑛·1·1</meta><meta attr=\"b\">𝑛·1·2</meta></formed>"+ , " <evaluated meta=\"𝑛·1·4\" of=\"𝑒·1·4\">𝑛·1·3</evaluated>" , " </evaluate>"- , " <normalized meta=\"𝑛·0·1\" of=\"𝑛·1·3.φ\">𝜎4</normalized>"+ , " <normalized meta=\"𝑛·0·1\" of=\"𝑛·1·4.φ\">𝜎4</normalized>" , " <morphed meta=\"𝑛·0·2\">𝜎4</morphed>" , "</morph>" ]@@ -3006,8 +3178,10 @@ , " <morphed meta=\"𝑛·1·3\">𝑒·1·1</morphed>" , " </morph>" , " <answered meta=\"𝑛·1·4\">𝑛·1·3</answered>"+ , " <formed meta=\"𝑒·1·2\" λ=\"L_pair\"><datum attr=\"x\">01-</datum></formed>"+ , " <evaluated meta=\"𝑛·1·5\" of=\"𝑒·1·2\">𝑛·1·4</evaluated>" , " </evaluate>"- , " <normalized meta=\"𝑛·0·1\" of=\"𝑛·1·4.left\">𝜎1</normalized>"+ , " <normalized meta=\"𝑛·0·1\" of=\"𝑛·1·5.left\">𝜎1</normalized>" , " <morphed meta=\"𝑛·0·2\">𝜎1</morphed>" , "</morph>" ]@@ -3033,8 +3207,10 @@ , " <morphed meta=\"𝑛·1·3\">𝑒·1·1</morphed>" , " </morph>" , " <answered meta=\"𝑛·1·4\">𝑛·1·3</answered>"+ , " <formed meta=\"𝑒·1·2\" λ=\"L_keep\"><datum attr=\"x\">01-</datum></formed>"+ , " <evaluated meta=\"𝑛·1·5\" of=\"𝑒·1·2\">𝑛·1·4</evaluated>" , " </evaluate>"- , " <normalized meta=\"𝑛·0·1\" of=\"𝑛·1·4.z\">01-</normalized>"+ , " <normalized meta=\"𝑛·0·1\" of=\"𝑛·1·5.z\">01-</normalized>" , " <morphed meta=\"𝑛·0·2\">01-</morphed>" , "</morph>" ]@@ -3063,8 +3239,10 @@ , " <applied meta=\"𝑛·0·4\" by=\"morph\" at=\"𝑛·0·1\" of=\"Φ.number\"><meta attr=\"φ\">𝑒·0·1</meta></applied>" , " <formed meta=\"𝑛·0·5\" of=\"Φ.number\"><meta attr=\"φ\">𝑒·0·1</meta></formed>" , " <normalized meta=\"𝑛·0·6\" of=\"𝑛·0·5.plus\">𝑛·0·4.plus</normalized>"- , " <applied meta=\"𝑛·0·7\" by=\"morph\" at=\"𝑛·0·1\" of=\"𝑛·0·4.plus\"><meta attr=\"x\">𝑒·0·7</meta></applied>"- , " <formed meta=\"𝑛·0·8\" of=\"𝑛·0·4.plus\"><meta attr=\"x\">𝑒·0·7</meta></formed>"+ , " <applied meta=\"𝑒·0·9\" of=\"𝑒·0·4.plus\"><meta attr=\"α0\">𝑒·0·6</meta></applied>"+ , " <shared meta=\"𝑛·1\">𝑒·0·9</shared>"+ , " <applied meta=\"𝑛·0·7\" by=\"morph\" at=\"𝑛·0·1\" of=\"𝑛·0·4.plus\"><meta attr=\"x\">𝑛·1</meta></applied>"+ , " <formed meta=\"𝑛·0·8\" of=\"𝑛·0·4.plus\"><meta attr=\"x\">𝑛·1</meta></formed>" , " <morphed meta=\"𝑛·0·9\">𝑛·0·8</morphed>" , " </morph>" , " <evaluate λ=\"L_number_plus\" by=\"dataize\" at=\"𝑛·0·1\">"@@ -3145,8 +3323,9 @@ , " <morphed meta=\"𝑛·2·24\">𝑛·2·23</morphed>" , " </morph>" , " <answered meta=\"𝑛·2·25\">𝑛·2·24</answered>"+ , " <evaluated meta=\"𝑛·2·26\" of=\"𝑛·1·16\">𝑛·2·25</evaluated>" , " </evaluate>"- , " <boxed meta=\"𝑛·1·18\">𝑛·2·25.φ</boxed>"+ , " <boxed meta=\"𝑛·1·18\">𝑛·2·26.φ</boxed>" , " <normalized meta=\"𝑛·1·19\" of=\"𝑛·1·18\">𝜎1</normalized>" , " <manufactured meta=\"𝛿·1·2\">𝜎1</manufactured>" , " </dataize>"@@ -3160,8 +3339,9 @@ , " <morphed meta=\"𝑛·1·23\">𝑛·1·22</morphed>" , " </morph>" , " <answered meta=\"𝑛·1·24\">𝑛·1·23</answered>"+ , " <evaluated meta=\"𝑛·1·25\" of=\"𝑛·0·8\">𝑛·1·24</evaluated>" , " </evaluate>"- , " <boxed meta=\"𝑛·0·10\">𝑛·1·24.φ</boxed>"+ , " <boxed meta=\"𝑛·0·10\">𝑛·1·25.φ</boxed>" , " <normalized meta=\"𝑛·0·11\" of=\"𝑛·0·10\">𝜎2</normalized>" , " <manufactured meta=\"𝛿·0·1\">𝜎2</manufactured>" , "</dataize>"@@ -3240,8 +3420,9 @@ , " <morphed meta=\"𝑛·1·25\">𝑛·1·24</morphed>" , " </morph>" , " <answered meta=\"𝑛·1·26\">𝑛·1·25</answered>"+ , " <evaluated meta=\"𝑛·1·27\" of=\"𝑛·0·8\">𝑛·1·26</evaluated>" , " </evaluate>"- , " <normalized meta=\"𝑛·0·9\" of=\"𝑛·1·26.nope\">𝑛·1·23.nope</normalized>"+ , " <normalized meta=\"𝑛·0·9\" of=\"𝑛·1·27.nope\">𝑛·1·23.nope</normalized>" , " <morphed meta=\"𝑛·0·10\">𝑛·1·23.nope</morphed>" , " </morph>" , " <unanswered λ=\"L_number_nope\" by=\"dataize\">𝑛·1·23.nope</unanswered>"@@ -3258,7 +3439,7 @@ `shouldBe` [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" , "<morph at=\"Φ.x\">" , " <formed meta=\"𝑒·0·1\" λ=\"L_number_nope\"/>"- , " <unanswered λ=\"L_number_nope\" by=\"morph\">𝑒·0·1</unanswered>"+ , " <unanswered λ=\"L_number_nope\" by=\"morph\">𝑒·0·1.foo</unanswered>" , "</morph>" ] @@ -3335,8 +3516,9 @@ , " <morphed meta=\"𝑛·1·25\">𝑛·1·24</morphed>" , " </morph>" , " <answered meta=\"𝑛·1·26\">𝑛·1·25</answered>"+ , " <evaluated meta=\"𝑛·1·27\" of=\"𝑛·0·8\">𝑛·1·26</evaluated>" , " </evaluate>"- , " <normalized meta=\"𝑛·0·9\" of=\"𝑛·1·26.nope\">𝑛·1·23.nope</normalized>"+ , " <normalized meta=\"𝑛·0·9\" of=\"𝑛·1·27.nope\">𝑛·1·23.nope</normalized>" , " <morphed meta=\"𝑛·0·10\">𝑛·1·23.nope</morphed>" , " </morph>" , " <unanswered λ=\"L_number_nope\" by=\"dataize\">𝑛·1·23.nope</unanswered>"@@ -3364,8 +3546,11 @@ , " <morphed meta=\"𝑛·1·3\">𝜎1</morphed>" , " </morph>" , " <answered meta=\"𝑛·1·4\">𝜎1</answered>"+ , " <formed meta=\"𝑒·1·1\"/>"+ , " <formed meta=\"𝑒·1·2\" λ=\"L_pick\"><meta attr=\"here\">𝑒·1·1</meta></formed>"+ , " <evaluated meta=\"𝑛·1·5\" of=\"𝑒·1·2\">𝜎1</evaluated>" , " </evaluate>"- , " <unanswered λ=\"𝜎1\" by=\"morph\">𝜎1</unanswered>"+ , " <opaque symbol=\"𝜎1\" by=\"morph\">𝜎1.foo</opaque>" , "</morph>" ] @@ -3492,13 +3677,14 @@ , " normalized 𝑛·1·21 := 40-08-00-00-00-00-00-00:Δ # 𝑛·1·20" , " 𝛿·1·2 := 40-08-00-00-00-00-00-00 # 3.0" , " 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)"- , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛"+ , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_times" , " 𝕄(𝑛·1·22):" , " 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )" , " 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, times(x) ↦ L_number_times:λ, nope ↦ L_number_nope:λ ⟧" , " morphed 𝑛·1·25 := 𝑛·1·24" , " 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)"- , " normalized 𝑛·0·9 := L_number_nope:λ # 𝑛·1·26.nope"+ , " evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·8"+ , " normalized 𝑛·0·9 := L_number_nope:λ # 𝑛·1·27.nope" , " morphed 𝑛·0·10 := L_number_nope:λ" , " unanswered L_number_nope # 𝔻(L_number_nope:λ)" ]@@ -3534,6 +3720,37 @@ withStdin "[[ ]]" $ testCLISucceeded ["dataize", "--partial"] ["⊥"] + describe "--focus under --locator" $ do+ it "finds the same object for the steps and for the answer when --locator has no matching child" $+ withStdin "⟦ t ↦ ⟦ λ ⤍ L_nope ⟧, a ↦ ⟦ Δ ⤍ 02- ⟧ ⟧" $+ testCLISucceeded+ ["dataize", "--partial", "--locator=Q.t", "--focus=Q.a", "--flat"]+ ["⟦ Δ ⤍ 02- ⟧"]+ it "finds the same object for the steps and for the answer even when --locator also binds that attribute" $+ withStdin "⟦ t ↦ ⟦ a ↦ ⟦ Δ ⤍ 01- ⟧, λ ⤍ L_nope ⟧, a ↦ ⟦ Δ ⤍ 02- ⟧ ⟧" $ do+ (out, _) <- withStdout (runCLI ["dataize", "--partial", "--locator=Q.t", "--focus=Q.a", "--flat", "--sequence"])+ filter (not . null) (lines out) `shouldSatisfy` (not . null)+ filter (not . null) (lines out) `shouldSatisfy` all (== "⟦ Δ ⤍ 02- ⟧")+ it "prints the residual when --focus names the object at --locator" $+ withStdin "⟦ t ↦ ⟦ λ ⤍ L_nope ⟧, a ↦ ⟦ Δ ⤍ 02- ⟧ ⟧" $+ testCLISucceeded+ ["dataize", "--partial", "--locator=Q.t", "--focus=Q.t", "--flat"]+ ["⟦ λ ⤍ L_nope ⟧"]+ it "respects --hide together with --focus and --locator" $+ withStdin "⟦ t ↦ ⟦ λ ⤍ L_nope ⟧, a ↦ ⟦ x ↦ ⟦ Δ ⤍ 01- ⟧, y ↦ ⟦ Δ ⤍ 02- ⟧ ⟧ ⟧" $+ testCLISucceeded+ ["dataize", "--partial", "--locator=Q.t", "--focus=Q.a", "--hide=Q.a.x", "--flat"]+ ["⟦ y ↦ ⟦ Δ ⤍ 02- ⟧ ⟧"]+ it "fails on a --focus it cannot find before it prints any step" $+ withStdin "⟦ t ↦ ⟦ λ ⤍ L_nope ⟧ ⟧" $ do+ (out, _) <- withStdout (try (runCLI ["dataize", "--partial", "--locator=Q.t", "--focus=Q.nope", "--flat", "--sequence"]) :: IO (Either ExitCode ()))+ out `shouldNotContain` "⟦ λ ⤍"+ it "prints the answer at --focus in LaTeX format under --locator" $+ withStdin "⟦ t ↦ ⟦ λ ⤍ L_nope ⟧, a ↦ ⟦ Δ ⤍ 02- ⟧ ⟧" $+ testCLISucceeded+ ["dataize", "--partial", "--locator=Q.t", "--focus=Q.a", "--flat", "--output=latex"]+ ["\\begin{phiquation}", "[[ D> |02-| ]]{.}", "\\end{phiquation}"]+ describe "--symbolic" $ do let sum' = "[[ bytes ↦ ⟦ φ ↦ ∅ ⟧, number(φ) -> [[ plus(^, x) -> [[ L> L_number_plus ]] ]], @ -> 5.plus(6) ]]" it "fires the λ function an entry of the file answers" $@@ -3860,13 +4077,14 @@ , " normalized 𝑛·1·21 := 40-18-00-00-00-00-00-00:Δ # 𝑛·1·20" , " 𝛿·1·2 := 40-18-00-00-00-00-00-00 # 6.0" , " 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)"- , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛"+ , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_plus" , " 𝕄(𝑛·1·22):" , " 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )" , " 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, plus(x) ↦ L_number_plus:λ ⟧" , " morphed 𝑛·1·25 := 𝑛·1·24" , " 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)"- , " normalized 𝑛·0·7 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·26.plus"+ , " evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·6"+ , " normalized 𝑛·0·7 := ⟦ x ↦ ∅, λ ⤍ L_number_plus ⟧ # 𝑛·1·27.plus" , " 𝑛·0·8 := 𝑛·1·23.plus( x ↦ 7.0 )" , " 𝑛·0·9 := ⟦ x ↦ 7.0, λ ⤍ L_number_plus ⟧" , " morphed 𝑛·0·10 := 𝑛·0·9"@@ -4042,7 +4260,7 @@ (["morph", "--symbolic=" ++ table, "--max-seconds=1", "--minutes=" ++ path, "--quiet"] ++ opts) outputs records <- readProtocol path- dropWhile (== ' ') (last (lines records)) `shouldBe` "timeout 1"+ take 2 (words (last (lines records))) `shouldBe` ["timeout", "1"] it "writes the timeout once to the XML protocol" $ ladder $ \table ->@@ -4144,7 +4362,7 @@ it "names an argument of a deferred copy by the object its morph answered" $ do records <- recordedWith (joining <> counting) [] "⟦ box(x, w) ↦ ⟦ φ ↦ x.next ⟧, num(φ) ↦ ⟦⟧, inc(x) ↦ ⟦ λ ⤍ L_inc ⟧, items ↦ ⟦ tail ↦ ⟦ λ ⤍ 𝜎1 ⟧ ⟧, y ↦ ⟦ c ↦ ⟦ λ ⤍ 𝜎2 ⟧, a ↦ ⟦ Δ ⤍ 01- ⟧, b ↦ Φ.box( x ↦ Φ.items.tail, w ↦ Φ.inc( ⟦ Δ ⤍ 2A- ⟧ ) ), λ ⤍ L_fork ⟧ ⟧"- filter (isInfixOf "<deferred") records `shouldBe` [" <deferred symbol=\"𝜎4\" by=\"morph\" at=\"𝑛2.φ\" of=\"Φ.box\"><with><symbol attr=\"x\">𝜎1</symbol><meta attr=\"w\">𝑛·2·6</meta></with></deferred>"]+ filter (isInfixOf "<deferred") records `shouldBe` [" <deferred symbol=\"𝜎4\" by=\"morph\" at=\"𝑛2.φ\" of=\"Φ.box\"><with><symbol attr=\"x\">𝜎1</symbol><meta attr=\"w\">𝑛·2·7</meta></with></deferred>"] describe "--acyclic=plausible" $ do let twins = "[[ bytes ↦ ⟦ φ ↦ ∅ ⟧, number(φ) -> [[ plus(^, x) -> [[ L> L_number_plus ]] ]], pair(a, b) -> [[ L> L_pair ]], t -> Φ.pair( 7.plus( 5.plus( 6 ) ), 7.plus( 5.plus( 6 ) ) ).φ ]]"@@ -4190,7 +4408,7 @@ recorded "plausible" >>= (`shouldSatisfy` ((== 3) . length . filter (isInfixOf "𝔼(L_number_plus)"))) it "answers a recalled firing with the line of the first under plausible" $- recorded "plausible" >>= (`shouldContain` [" 𝑛·4·1 := 𝑛·2·21 # 𝑛"])+ recorded "plausible" >>= (`shouldContain` [" 𝑛·4·1 := 𝑛·2·21 # 𝑛 of L_number_plus"]) it "dataizes to the same datum under plausible" $ withStdin chained $
test/CanonizerSpec.hs view
@@ -100,12 +100,21 @@ it "returns an empty list for an empty input" $ canonize [] `shouldBe` [] - it "restarts the counter independently for each Rewritten in the chain" $ do+ it "gives a new function of a later step the next number" $ do let first = ExFormation [BiLambda (Function "X")] second = ExFormation [BiLambda (Function "Y")]- expected = ExFormation [BiLambda (Function "Fn1")] canonize [(first, Just (Morphing, "rule-1")), (second, Just (Dataization, "rule-2"))]- `shouldBe` [(expected, Just (Morphing, "rule-1")), (expected, Just (Dataization, "rule-2"))]+ `shouldBe` [ (ExFormation [BiLambda (Function "Fn1")], Just (Morphing, "rule-1"))+ , (ExFormation [BiLambda (Function "Fn2")], Just (Dataization, "rule-2"))+ ]++ it "keeps the name of a function across the steps of a sequence" $ do+ let first = ExFormation [BiTau (AtLabel "x") (ExFormation [BiLambda (Function "Fa")]), BiTau (AtLabel "y") (ExFormation [BiLambda (Function "Fb")])]+ second = ExFormation [BiTau (AtLabel "y") (ExFormation [BiLambda (Function "Fb")])]+ map fst (canonize [(first, Nothing), (second, Nothing)])+ `shouldBe` [ ExFormation [BiTau (AtLabel "x") (ExFormation [BiLambda (Function "Fn1")]), BiTau (AtLabel "y") (ExFormation [BiLambda (Function "Fn2")])]+ , ExFormation [BiTau (AtLabel "y") (ExFormation [BiLambda (Function "Fn2")])]+ ] it "preserves the rule tag alongside the canonized expression" $ canonize [(ExFormation [BiLambda (Function "Foo")], Nothing)]
test/CompiledSpec.hs view
@@ -26,7 +26,7 @@ import Must (Must (MtDisabled)) import Parser (Form (MONOFORM), parseExpressionThrows') import Rewriter (RewriteContext (RewriteContext), rewrite)-import Rule (RuleContext (RuleContext), matchExpressionWithRule)+import Rule (RuleContext (RuleContext), isNF, matchExpressionWithRule) import System.Random (StdGen, mkStdGen, randomR) import Test.Hspec (Spec, describe, it, shouldBe, shouldReturn) import Yaml qualified as Y@@ -61,6 +61,9 @@ it "tells a normal form of a term holding metas the way the rules of YAML do" $ filter (\seed -> _normal linked (term True seed) /= _normal yaml (term True seed)) [3001 .. 6000] `shouldBe` []+ it "tells a normal form the way a test asking every meta the whole test again does" $+ filter (\seed -> any (\metas -> _normal linked (term metas seed) /= nested (term metas seed)) [False, True]) [1 .. 3000]+ `shouldBe` [] it "contextualizes random terms the way the rules of YAML do, failures included" $ filterM (\seed -> (/=) <$> contextualized linked (term True seed) (term False (seed + 1)) <*> contextualized yaml (term True seed) (term False (seed + 1))) [1 .. 3000] `shouldReturn` []@@ -84,8 +87,10 @@ (_normalization engine) (RewriteContext ExRoot 25 25 False universe (building engine) (_normal engine) (_matching engine) MtDisabled Nothing dontSaveStep dontSaveMade) )+ nested :: Expression -> Bool+ nested expr = isNF expr (RuleContext (building yaml) Nothing nested False) matched :: Expression -> IO (Set.Set Int)- matched expr = Set.fromList . map fst <$> filterM (\(_, rule) -> not . null <$> matchExpressionWithRule expr rule (RuleContext (building yaml) Nothing (_normal yaml))) (zip [0 ..] Y.normalizationRules)+ matched expr = Set.fromList . map fst <$> filterM (\(_, rule) -> not . null <$> matchExpressionWithRule expr rule (RuleContext (building yaml) Nothing (_normal yaml) False)) (zip [0 ..] Y.normalizationRules) morphed :: Lambdas -> Engine -> Expression -> IO (Either String String) morphed lambdas engine world = settled (show . fst <$> (morph' (ExDispatch ExRoot (AtLabel "x"), (world, Nothing) :| []) world emptyState =<< reducing lambdas engine)) dataized :: Lambdas -> Engine -> Expression -> IO (Either String String)
test/DataizeSpec.hs view
@@ -32,6 +32,7 @@ import Parser (Form (MONOFORM), parseBytes, parseExpressionThrows, parseExpressionThrows') import Rewriter (Rewritten) import Rule (RuleContext (RuleContext), matchExpressionWithRule')+import Sides (sides) import System.FilePath (makeRelative) import Tau (seedTaus) import Test.Hspec@@ -94,7 +95,7 @@ describe "dataization 'norm' is disjoint from the specific clauses" $ do ctx <- runIO (defaultReduceContext ExRoot)- let rctx = RuleContext (execBuildTerm ExRoot ctx) Nothing (_normal linked)+ let rctx = RuleContext (execBuildTerm ExRoot ctx) Nothing (_normal linked) False dataizeRule :: String -> Yaml.DataizeRule dataizeRule nm = fromMaybe (error ("no dataization rule named " ++ nm)) (find (\r -> r.name == nm) Yaml.dataizationRules) asRule :: Yaml.DataizeRule -> Yaml.Rule@@ -175,14 +176,16 @@ looping $ \endless -> do expr <- parseExpressionThrows "⟦ @ ↦ ⟦ λ ⤍ L_loop ⟧ ⟧" minted <- newIORef 0- dataize expr emptyState (ReduceContext ExRoot ExRoot Nothing 25 25 Nothing Nothing (Steps 40 0) Nothing minted Nothing Nothing 1 Nothing False True False Nothing 0 Dataization [] Map.empty Nothing endless [] False (building linked) reduction evaluation dontSaveStep dontSaveEval linked)+ named <- sides+ dataize expr emptyState (ReduceContext ExRoot ExRoot Nothing 25 25 Nothing Nothing (Steps 40 0) Nothing minted named Nothing Nothing 1 Nothing False True False Nothing 0 Dataization [] Map.empty Nothing endless [] False Nothing (building linked) reduction evaluation dontSaveStep dontSaveEval linked) `shouldThrow` (\e -> "--max-steps=40" `isInfixOf` show (e :: SomeException)) it "parks the step limit as a residual with --partial" $ looping $ \endless -> do expr <- parseExpressionThrows "⟦ @ ↦ ⟦ λ ⤍ L_loop ⟧ ⟧" minted <- newIORef 0- (outcome, _, _) <- dataize expr emptyState (ReduceContext ExRoot ExRoot Nothing 25 25 Nothing Nothing (Steps 40 0) Nothing minted Nothing Nothing 1 Nothing False True True Nothing 0 Dataization [] Map.empty Nothing endless [] False (building linked) reduction evaluation dontSaveStep dontSaveEval linked)+ named <- sides+ (outcome, _, _) <- dataize expr emptyState (ReduceContext ExRoot ExRoot Nothing 25 25 Nothing Nothing (Steps 40 0) Nothing minted named Nothing Nothing 1 Nothing False True True Nothing 0 Dataization [] Map.empty Nothing endless [] False Nothing (building linked) reduction evaluation dontSaveStep dontSaveEval linked) case outcome of Residual _ -> pure () Dataized bts -> expectationFailure ("expected a residual, dataized to " ++ show bts)@@ -260,13 +263,14 @@ , " normalized 𝑛·1·21 := 40-08-00-00-00-00-00-00:Δ # 𝑛·1·20" , " 𝛿·1·2 := 40-08-00-00-00-00-00-00 # 3.0" , " 𝛿2·1 := 𝛿·1·2 # 𝔻(ξ.x)"- , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛"+ , " 𝑛·1·22 := Φ.number( φ ↦ 𝜎1:λ ) # 𝑛 of L_number_times" , " 𝕄(𝑛·1·22):" , " 𝑛·1·23 := Φ.number( φ ↦ 𝜎1:λ )" , " 𝑛·1·24 := ⟦ φ ↦ 𝜎1:λ, as-bytes ↦ φ, plus(ρ, x) ↦ L_number_plus:λ, times(ρ, x) ↦ L_number_times:λ, div(ρ, x) ↦ L_number_div:λ, gt(ρ, x) ↦ L_number_gt:λ, eq(ρ, x) ↦ ρ.as-bytes.eq( x.as-bytes ):φ, nope(ρ) ↦ L_number_nope:λ ⟧" , " morphed 𝑛·1·25 := 𝑛·1·24" , " 𝑛·1·26 := 𝑛·1·25 # 𝕄(𝑛·1·22)"- , " normalized 𝑛·0·9 := ⟦ ρ ↦ 𝑛·1·23, λ ⤍ L_number_nope ⟧ # 𝑛·1·26.nope"+ , " evaluated 𝑛·1·27 := 𝑛·1·26 # 𝑛·0·8"+ , " normalized 𝑛·0·9 := ⟦ ρ ↦ 𝑛·1·23, λ ⤍ L_number_nope ⟧ # 𝑛·1·27.nope" , " morphed 𝑛·0·10 := ⟦ ρ ↦ 𝑛·1·23, λ ⤍ L_number_nope ⟧" , " unanswered L_number_nope # 𝔻(⟦ ρ ↦ 𝑛·1·23, λ ⤍ L_number_nope ⟧)" ]@@ -311,30 +315,32 @@ forM_ [ ( "--max-cycles"- , \minted -> ReduceContext ExRoot ExRoot Nothing 25 0 Nothing Nothing (Steps 250 0) Nothing minted Nothing Nothing 1 Nothing True True False Nothing 0 Dataization [] Map.empty Nothing emptyLambdas [] False (building linked) reduction evaluation dontSaveStep dontSaveEval linked+ , \minted named -> ReduceContext ExRoot ExRoot Nothing 25 0 Nothing Nothing (Steps 250 0) Nothing minted named Nothing Nothing 1 Nothing True True False Nothing 0 Dataization [] Map.empty Nothing emptyLambdas [] False Nothing (building linked) reduction evaluation dontSaveStep dontSaveEval linked , "--max-cycles=0" ) , ( "--max-depth"- , \minted -> ReduceContext ExRoot ExRoot Nothing 0 25 Nothing Nothing (Steps 250 0) Nothing minted Nothing Nothing 1 Nothing True True False Nothing 0 Dataization [] Map.empty Nothing emptyLambdas [] False (building linked) reduction evaluation dontSaveStep dontSaveEval linked+ , \minted named -> ReduceContext ExRoot ExRoot Nothing 0 25 Nothing Nothing (Steps 250 0) Nothing minted named Nothing Nothing 1 Nothing True True False Nothing 0 Dataization [] Map.empty Nothing emptyLambdas [] False Nothing (building linked) reduction evaluation dontSaveStep dontSaveEval linked , "--max-depth=0" ) ] ( \(flag, reducing, message) -> it ("throws once " ++ flag ++ " is exhausted with --depth-sensitive") $ do expr <- parseExpressionThrows "[[ @ -> $.f(y -> [[ ]]), f -> [[ D> 00-, y -> ? ]] ]]"- ctx <- reducing <$> newIORef 0+ ctx <- reducing <$> newIORef 0 <*> sides dataize expr emptyState ctx `shouldThrow` (\e -> message `isInfixOf` show (e :: SomeException)) ) it "does not throw without --depth-sensitive even once --max-depth is exhausted" $ do expr <- parseExpressionThrows wrapped minted <- newIORef 0- (value, _, _) <- dataize expr emptyState (ReduceContext ExRoot ExRoot Nothing 1 25 Nothing Nothing (Steps 250 0) Nothing minted Nothing Nothing 1 Nothing False True False Nothing 0 Dataization [] Map.empty Nothing emptyLambdas [] False (building linked) reduction evaluation dontSaveStep dontSaveEval linked)+ named <- sides+ (value, _, _) <- dataize expr emptyState (ReduceContext ExRoot ExRoot Nothing 1 25 Nothing Nothing (Steps 250 0) Nothing minted named Nothing Nothing 1 Nothing False True False Nothing 0 Dataization [] Map.empty Nothing emptyLambdas [] False Nothing (building linked) reduction evaluation dontSaveStep dontSaveEval linked) value `shouldBe` Dataized (BtOne "00") it "throws once --max-cycles is exhausted even without --depth-sensitive" $ do expr <- parseExpressionThrows wrapped minted <- newIORef 0- dataize expr emptyState (ReduceContext ExRoot ExRoot Nothing 25 0 Nothing Nothing (Steps 250 0) Nothing minted Nothing Nothing 1 Nothing False True False Nothing 0 Dataization [] Map.empty Nothing emptyLambdas [] False (building linked) reduction evaluation dontSaveStep dontSaveEval linked)+ named <- sides+ dataize expr emptyState (ReduceContext ExRoot ExRoot Nothing 25 0 Nothing Nothing (Steps 250 0) Nothing minted named Nothing Nothing 1 Nothing False True False Nothing 0 Dataization [] Map.empty Nothing emptyLambdas [] False Nothing (building linked) reduction evaluation dontSaveStep dontSaveEval linked) `shouldThrow` (\e -> "--max-cycles=0" `isInfixOf` show (e :: SomeException)) describe "labels every step with a defined rule or operation" $ do
test/DepsSpec.hs view
@@ -12,7 +12,7 @@ import Data.List (isInfixOf, isPrefixOf) import Data.Time (LocalTime (LocalTime), TimeOfDay (TimeOfDay), ZonedTime (ZonedTime), fromGregorian, hoursToTimeZone) import Data.Time.Clock.POSIX (getPOSIXTime)-import Deps (Acyclic (Proven), Evaluation (EvAnswer, EvApplied, EvBound, EvBoxed, EvBuilt, EvCast, EvData, EvDeferred, EvDelta, EvDiverged, EvFabricated, EvFiring, EvGuarded, EvHeader, EvJoined, EvLooped, EvManufactured, EvMemoized, EvMorphed, EvNormalized, EvRecalled, EvRemembered, EvReshaped, EvRun, EvStarted, EvStuck, EvStuckOn, EvSymbolized, EvTaken, EvTerm, EvUndressed, EvUnripe, EvWorld), Header (Header), Judgment (Dataization, Evaluation, Morphing), Nesting (..), Protocol (..), World (World), dontSaveEval, dontSaveStep, emptyNesting, emptyProgress, emptyProtocol, endEval, endEvalXml, perSecond, progressed, resited, saveStep)+import Deps (Acyclic (Proven), Evaluation (EvAnswer, EvApplied, EvBound, EvBoxed, EvBuilt, EvCast, EvData, EvDeferred, EvDelta, EvDiverged, EvEvaluated, EvFabricated, EvFiring, EvGuarded, EvHeader, EvJoined, EvLooped, EvManufactured, EvMemoized, EvMorphed, EvNormalized, EvOpaque, EvPassed, EvRecalled, EvRemembered, EvRenamed, EvReshaped, EvRun, EvShared, EvStarted, EvStuck, EvStuckOn, EvSymbolized, EvTaken, EvTerm, EvUndressed, EvUnripe, EvWorld), Header (Header), Judgment (Dataization, Evaluation, Morphing), Nesting (..), Protocol (..), World (World), dontSaveEval, dontSaveStep, emptyNesting, emptyProgress, emptyProtocol, endEval, endEvalXml, perSecond, progressed, resited, saveStep) import Fixtures (readUtf8, recorded, recordedWhole, recordedXml) import Forks (Refusal (..), Side (..)) import GHC.Clock (getMonotonicTime)@@ -138,6 +138,12 @@ it "writes an application as a line binding its call to a fresh 𝑛" $ do (_, written) <- recorded (\record -> record (EvApplied 1 Morphing (ExApplication (ExDispatch ExRoot (AtLabel "ёж")) (ArTau (AtLabel "q") (ExFormation []))) (ExFormation [BiTau (AtLabel "q") (ExFormation [])]) (ExDispatch ExRoot (AtLabel "w")))) take 1 (lines written) `shouldBe` [" 𝑛·0·1 := Φ.ёж( q ↦ ⟦⟧ ) # 𝕄(Φ.w)"]+ it "writes a symbol nothing can fire as opaque, with the attribute taken off it" $ do+ (_, written) <- recorded (\record -> record (EvOpaque 1 7 Morphing (ExDispatch (ExFormation [BiLambda (FnSymbol 7)]) (AtLabel "ёж"))))+ lines written `shouldBe` [" opaque 𝜎7 # 𝕄(𝜎7:λ.ёж)"]+ it "writes a λ function no entry answers as unanswered, with the attribute taken off it" $ do+ (_, written) <- recorded (\record -> record (EvStuck 1 "L_ёж" Morphing (ExDispatch (ExFormation [BiLambda (Function "L_ёж")]) (AtLabel "уж"))))+ lines written `shouldBe` [" unanswered L_ёж # 𝕄(L_ёж:λ.уж)"] it "writes the formation an application made on a line of its own after the line of the application" $ do (_, written) <- recorded (\record -> record (EvApplied 1 Morphing (ExApplication (ExDispatch ExRoot (AtLabel "сом")) (ArTau (AtLabel "ус") (ExFormation []))) (ExFormation [BiTau (AtLabel "ус") (ExFormation []), BiTau (AtLabel "хвост") (ExFormation [])]) (ExDispatch ExRoot (AtLabel "пруд")))) last (lines written) `shouldBe` " 𝑛·0·2 := ⟦ ус ↦ ⟦⟧, хвост ↦ ⟦⟧ ⟧"@@ -183,6 +189,9 @@ it "writes the term a morphing came to as a line binding it to a fresh 𝑛 under the heading of the morphing" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvStarted 1 Morphing (ExDispatch ExRoot (AtLabel "жук")), EvMorphed 2 (ExDispatch ExRoot (AtLabel "щука"))]) lines written `shouldBe` ["𝕄(Φ):", " 𝕄(Φ.жук):", " morphed 𝑛·0·1 := Φ.щука"]+ it "writes the term a meta was shared for as a line binding that meta" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvStarted 1 Morphing (ExDispatch ExRoot (AtLabel "сом")), EvShared 2 (ExMeta "n·1") (ExApplication (ExDispatch ExRoot (AtLabel "карп")) (ArTau (AtLabel "икра") (ExDispatch ExRoot (AtLabel "линь"))))])+ lines written `shouldBe` ["𝕄(Φ):", " 𝕄(Φ.сом):", " shared 𝑛·1 := Φ.карп( икра ↦ Φ.линь )"] it "writes the term a normalization came to as a line binding it to a fresh 𝑛 and naming what it came from" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvStarted 1 Morphing (ExDispatch ExRoot (AtLabel "лось")), EvNormalized 2 (ExDispatch (ExDispatch ExRoot (AtLabel "кедр")) (AtLabel "шишка")) (ExDispatch ExRoot (AtLabel "выпь"))]) lines written `shouldBe` ["𝕄(Φ):", " 𝕄(Φ.лось):", " normalized 𝑛·0·1 := Φ.выпь # Φ.кедр.шишка"]@@ -279,6 +288,12 @@ it "writes the answer the memo keeps for a formation as a memoized line" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_ёрш" Dataization ExRoot, EvMemoized 2 (ExDispatch ExRoot (AtLabel "налим")) (ExFormation [BiLambda (FnSymbol 8)])]) last (lines written) `shouldBe` " memoized 𝑛·1·1 ⇛ 𝜎8:λ # Φ.налим"+ it "closes a firing that answered with an evaluated line naming the formation fired" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_ёрш" Dataization ExRoot, EvEvaluated 2 (ExDispatch ExRoot (AtLabel "налим")) (ExFormation [BiLambda (FnSymbol 8)])])+ last (lines written) `shouldBe` " evaluated 𝑛·1·1 := 𝜎8:λ # Φ.налим"+ it "writes an answer the memo renamed as a renamed line naming the formation it came from and every symbol it renamed" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_ёрш" Dataization ExRoot, EvRenamed 2 (ExDispatch ExRoot (AtLabel "налим")) (ExFormation [BiLambda (FnSymbol 9)]) (ExDispatch ExRoot (AtLabel "карп")) [(3, 7), (4, 9)]])+ last (lines written) `shouldBe` " renamed 𝑛·1·1 ⇛ 𝜎9:λ # Φ.налим, from Φ.карп, 𝜎3 as 𝜎7, 𝜎4 as 𝜎9" it "recalls an answer the memo kept as its remembered line spelled it" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_ёрш" Dataization ExRoot, EvMemoized 2 (ExFormation [BiTau (AtLabel "лещ") (ExFormation [])]) (ExFormation [BiLambda (FnSymbol 8)]), EvMorphed 2 (ExFormation [BiTau (AtLabel "лещ") (ExFormation [])]), EvRecalled 2 (ExFormation [BiTau (AtLabel "лещ") (ExFormation [])]) (ExFormation [BiLambda (FnSymbol 8)])]) last (lines written) `shouldBe` " recalled 𝑛·1·1 ⇒ 𝜎8:λ"@@ -288,6 +303,15 @@ it "writes a cut that answered a copy as the call of the object it repeats" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvLooped 1 Dataization Proven (ExFormation []) ExRoot (Just (14, Just (ExApplication (ExDispatch ExRoot (AtLabel "клён")) (ArTau (AtLabel "ось") (ExFormation [BiLambda (FnSymbol 3)])))))]) last (lines written) `shouldBe` " looped 𝜎14 := Φ.клён( ось ↦ 𝜎3:λ ) # proven, repeats ⟦⟧"+ it "writes a copy handed back as it is under a name of its own and the call of the object it repeats" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvPassed 1 Dataization Proven (ExFormation []) ExRoot (ExFormation [BiTau (AtLabel "ъ") ExRoot]) (Just (ExApplication (ExDispatch ExRoot (AtLabel "клён")) (ArTau (AtLabel "ось") (ExFormation [BiLambda (FnSymbol 3)]))))])+ last (lines written) `shouldBe` " passed 𝑛·0·1 := Φ.клён( ось ↦ 𝜎3:λ ) # proven, repeats ⟦⟧"+ it "writes a copy handed back as it is that no fact names by the copy itself" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvPassed 1 Dataization Proven (ExFormation []) ExRoot (ExFormation [BiTau (AtLabel "ъ") ExRoot]) Nothing])+ last (lines written) `shouldBe` " passed 𝑛·0·1 := Φ:ъ # proven, repeats ⟦⟧"+ it "names a copy handed back as it is by its name from then on" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvPassed 1 Dataization Proven (ExFormation []) ExRoot (ExFormation [BiTau (AtLabel "ъ") ExRoot]) Nothing, EvBoxed 1 (ExDispatch (ExFormation [BiTau (AtLabel "ъ") ExRoot]) AtPhi)])+ last (lines written) `shouldBe` " boxed 𝑛·0·2 := 𝑛·0·1.φ" it "names the block over an answer by the line that built it" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_ф" Dataization ExRoot, EvBuilt 2 (ExDispatch ExRoot (AtLabel "ю")), EvStarted 2 Morphing (ExDispatch ExRoot (AtLabel "ю")), EvApplied 3 Morphing (ExApplication (ExDispatch ExRoot (AtLabel "ёж")) (ArTau (AtLabel "q") (ExFormation []))) (ExFormation [BiTau (AtLabel "q") (ExFormation [])]) (ExDispatch ExRoot (AtLabel "ю"))]) lines written `shouldContain` [" 𝕄(𝑛·1·1):"]@@ -302,10 +326,19 @@ last (lines written) `shouldBe` " 𝑛·1·1 := 𝜎3:λ" it "writes the term a stay line dropped a ρ from beside the stay of the meta it read" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvReshaped 2 "𝑛3" "stay" (ExMeta "n1") (ExFormation [BiLambda (FnSymbol 3)])])- last (lines written) `shouldBe` " 𝑛3·1 := 𝜎3:λ # stay(𝑛1)"+ last (lines written) `shouldBe` " 𝑛3·1 := 𝜎3:λ # stay(𝑛1 of L_ф)" it "writes the term a symbolize line turned a datum of into a symbol beside the symbolize of the meta it read" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvReshaped 2 "𝑛4" "symbolize" (ExMeta "n2") (ExFormation [BiLambda (FnSymbol 6)])])- last (lines written) `shouldBe` " 𝑛4·1 := 𝜎6:λ # symbolize(𝑛2)"+ last (lines written) `shouldBe` " 𝑛4·1 := 𝜎6:λ # symbolize(𝑛2 of L_ф)"+ it "names the entry a meta belongs to beside the firing an evaluate line made of it" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_вилка" Morphing ExRoot, EvFiring 2 "L_плюс" Evaluation (ExMeta "n3")])+ last (lines written) `shouldBe` " 𝔼(L_плюс): # 𝔼(𝑛3 of L_вилка)"+ it "names the entry beside the answer it built" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_зов" Morphing ExRoot, EvBuilt 2 (ExDispatch ExRoot (AtLabel "ю"))])+ last (lines written) `shouldBe` " 𝑛·1·1 := Φ.ю # 𝑛 of L_зов"+ it "leaves a meta numbered by its firing as it is" $ do+ (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvReshaped 2 "𝑛3" "stay" (ExMeta "n1·1") (ExFormation [BiLambda (FnSymbol 3)])])+ last (lines written) `shouldBe` " 𝑛3·1 := 𝜎3:λ # stay(𝑛1·1)" it "writes the symbol a symbolize line minted beside the datum it stands for" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvSymbolized 2 6 (BtOne "4A")]) last (lines written) `shouldBe` " symbolized 𝜎6 := 4A-"@@ -388,16 +421,16 @@ (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvUnripe 2 (ExDispatch ExXi (AtLabel "a"), ExDispatch ExRoot (AtLabel "уж")) (ExMeta "n5", ExFormation [BiVoid (AtLabel "лис")]) Righthand (AtLabel "лис")]) last (lines written) `shouldBe` " unripe Φ.уж vs 𝑛5·1 # лис is void on the right and attached on the left" it "writes the formation a join fabricated beside the metas of the lines that bound its sides" $ do- (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvFabricated 2 (ExMeta "n1", ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n2", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (ExFormation [BiTau AtPhi (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) AtPhi), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) AtPhi)]), BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])])])+ (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvFabricated 2 (ExMeta "n1", ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n2", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) [] (ExFormation [BiTau AtPhi (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) AtPhi), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) AtPhi)]), BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])])]) last (lines written) `shouldSatisfy` isPrefixOf " fabricated 𝑛·1·1 := 𝑛1·1 and 𝑛2·1 # " it "writes the formation a join fabricated in the comment of its line" $ do- (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvFabricated 2 (ExMeta "n1", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n2", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (ExFormation [BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])])])+ (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvFabricated 2 (ExMeta "n1", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n2", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) [] (ExFormation [BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])])]) last (lines written) `shouldBe` " fabricated 𝑛·1·1 := 𝑛1·1 and 𝑛2·1 # ⟦ λ ⤍ L_ж, on ↦ 05-:Δ, left ↦ Φ.ёж:к.к, right ↦ Φ.щука:к.к ⟧:к" it "spells out in the comment of its line a formation a join fabricated once more" $ do- (_, written) <- recorded (\record -> mapM_ record (EvRun Morphing "Φ" : EvFiring 1 "L_ф" Morphing ExRoot : replicate 2 (EvFabricated 2 (ExMeta "n1", ExFormation [BiTau (AtLabel "ю") (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n2", ExFormation [BiTau (AtLabel "ю") (ExDispatch ExRoot (AtLabel "щука"))]) (ExFormation [BiTau (AtLabel "ю") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "3F")]), BiTau (AtLabel "left") (ExDispatch ExRoot (AtLabel "ёж")), BiTau (AtLabel "right") (ExDispatch ExRoot (AtLabel "щука"))])]))))+ (_, written) <- recorded (\record -> mapM_ record (EvRun Morphing "Φ" : EvFiring 1 "L_ф" Morphing ExRoot : replicate 2 (EvFabricated 2 (ExMeta "n1", ExFormation [BiTau (AtLabel "ю") (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n2", ExFormation [BiTau (AtLabel "ю") (ExDispatch ExRoot (AtLabel "щука"))]) [] (ExFormation [BiTau (AtLabel "ю") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "3F")]), BiTau (AtLabel "left") (ExDispatch ExRoot (AtLabel "ёж")), BiTau (AtLabel "right") (ExDispatch ExRoot (AtLabel "щука"))])])))) last (lines written) `shouldBe` " fabricated 𝑛·1·2 := 𝑛1·1 and 𝑛2·1 # ⟦ λ ⤍ L_ж, on ↦ 3F-:Δ, left ↦ Φ.ёж, right ↦ Φ.щука ⟧:ю" it "writes the formation a join fabricated by its name in a later line" $ do- (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvFabricated 2 (ExMeta "n1", ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n2", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (ExFormation [BiTau AtPhi (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) AtPhi), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) AtPhi)]), BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])]), EvTaken 2 (ExFormation [BiTau AtPhi (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) AtPhi), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) AtPhi)]), BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])])])+ (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvFabricated 2 (ExMeta "n1", ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n2", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) [] (ExFormation [BiTau AtPhi (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) AtPhi), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) AtPhi)]), BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])]), EvTaken 2 (ExFormation [BiTau AtPhi (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) AtPhi), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) AtPhi)]), BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])])]) last (lines written) `shouldBe` " 𝑛·1·2 := 𝑛·1·1" it "opens a heading of its own for every run of the protocol" $ do (_, written) <- recorded (\record -> mapM_ record [EvRun Morphing "Φ", EvDelta 1 (BtOne "0C"), EvRun Morphing "Φ", EvDelta 1 (BtOne "0D")])@@ -571,6 +604,9 @@ it "writes the term a morphing came to as an element with its name" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvMorphed 1 (ExDispatch ExRoot (AtLabel "щука"))]) lines written `shouldContain` [" <morphed meta=\"𝑛·0·1\">Φ.щука</morphed>"]+ it "writes the term a meta was shared for as an element naming that meta" $ do+ (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvShared 1 (ExMeta "n·1") (ExDispatch ExRoot (AtLabel "налим"))])+ lines written `shouldContain` [" <shared meta=\"𝑛·1\">Φ.налим</shared>"] it "writes the term a normalization came to as an element with its name and what it came from" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvNormalized 1 (ExDispatch (ExDispatch ExRoot (AtLabel "бор")) (AtLabel "пень")) (ExDispatch ExRoot (AtLabel "сыч"))]) lines written `shouldContain` [" <normalized meta=\"𝑛·0·1\" of=\"Φ.бор.пень\">Φ.сыч</normalized>"]@@ -676,12 +712,24 @@ it "writes the answer the memo keeps for a formation as a memoized element" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_ёрш" Dataization ExRoot, EvMemoized 2 (ExDispatch ExRoot (AtLabel "налим")) (ExFormation [BiLambda (FnSymbol 8)])]) lines written `shouldContain` [" <memoized meta=\"𝑛·1·1\" as=\"𝜎8\"/>"]+ it "closes a firing that answered with an evaluated element naming the formation fired" $ do+ (_, written) <- recordedXml (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_ёрш" Dataization ExRoot, EvEvaluated 2 (ExDispatch ExRoot (AtLabel "налим")) (ExFormation [BiLambda (FnSymbol 8)])])+ lines written `shouldContain` [" <evaluated meta=\"𝑛·1·1\" of=\"Φ.налим\">𝜎8</evaluated>"]+ it "writes an answer the memo renamed as a renamed element naming the formation it came from and every symbol it renamed" $ do+ (_, written) <- recordedXml (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_ёрш" Dataization ExRoot, EvRenamed 2 (ExDispatch ExRoot (AtLabel "налим")) (ExFormation [BiLambda (FnSymbol 9)]) (ExDispatch ExRoot (AtLabel "карп")) [(3, 7), (4, 9)]])+ lines written `shouldContain` [" <renamed meta=\"𝑛·1·1\" as=\"𝜎9\" from=\"Φ.карп\"><as symbol=\"𝜎3\" by=\"𝜎7\"/><as symbol=\"𝜎4\" by=\"𝜎9\"/></renamed>"] it "writes what the memo mapped a term to as an element naming both" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Dataization "Φ", EvFiring 1 "L_сом" Dataization ExRoot, EvRecalled 2 (ExDispatch ExRoot (AtLabel "окунь")) (ExDispatch ExRoot (AtLabel "щука"))]) lines written `shouldContain` [" <recalled of=\"Φ.окунь\" as=\"Φ.щука\"/>"] it "writes a cut that answered a copy as an element naming the formation it repeats, the object and its arguments" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Dataization "Φ", EvLooped 1 Dataization Proven (ExFormation [BiTau (AtLabel "ъ") ExRoot]) ExRoot (Just (14, Just (ExApplication (ExDispatch ExRoot (AtLabel "клён")) (ArTau (AtLabel "ось") (ExFormation [BiLambda (FnSymbol 3)])))))]) lines written `shouldContain` [" <looped symbol=\"𝜎14\" by=\"dataize\" match=\"proven\" at=\"Φ\" of=\"𝑒·0·1\" object=\"Φ.клён\"><with><symbol attr=\"ось\">𝜎3</symbol></with></looped>"]+ it "writes a copy handed back as it is as an element naming the formation it repeats, the object and its arguments" $ do+ (_, written) <- recordedXml (\record -> mapM_ record [EvRun Dataization "Φ", EvPassed 1 Dataization Proven (ExFormation [BiTau (AtLabel "ъ") ExRoot]) ExRoot (ExFormation [BiTau (AtLabel "ь") ExRoot]) (Just (ExApplication (ExDispatch ExRoot (AtLabel "клён")) (ArTau (AtLabel "ось") (ExFormation [BiLambda (FnSymbol 3)]))))])+ lines written `shouldContain` [" <passed meta=\"𝑛·0·1\" by=\"dataize\" match=\"proven\" at=\"Φ\" of=\"𝑒·0·1\" object=\"Φ.клён\"><with><symbol attr=\"ось\">𝜎3</symbol></with></passed>"]+ it "writes a copy handed back as it is that no fact names as an empty element naming the copy" $ do+ (_, written) <- recordedXml (\record -> mapM_ record [EvRun Dataization "Φ", EvPassed 1 Dataization Proven (ExFormation [BiTau (AtLabel "ъ") ExRoot]) ExRoot (ExFormation [BiTau (AtLabel "ь") ExRoot]) Nothing])+ lines written `shouldContain` [" <passed meta=\"𝑛·0·1\" by=\"dataize\" match=\"proven\" at=\"Φ\" of=\"𝑒·0·1\" object=\"𝑒·0·2\"/>"] it "writes a cut whose call ends with attributes as an element naming the object, its arguments and those attributes" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Dataization "Φ", EvLooped 1 Dataization Proven (ExFormation [BiTau (AtLabel "ъ") ExRoot]) ExRoot (Just (19, Just (ExDispatch (ExDispatch (ExApplication (ExDispatch ExRoot (AtLabel "вяз")) (ArTau (AtLabel "корень") (ExFormation [BiLambda (FnSymbol 5)]))) AtPhi) (AtLabel "ветка"))))]) lines written `shouldContain` [" <looped symbol=\"𝜎19\" by=\"dataize\" match=\"proven\" at=\"Φ\" of=\"𝑒·0·1\" object=\"Φ.вяз\" dispatch=\"φ.ветка\"><with><symbol attr=\"корень\">𝜎5</symbol></with></looped>"]@@ -731,7 +779,7 @@ (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvUnripe 2 (ExMeta "n3", ExFormation [BiTau (AtLabel "щи") (ExFormation [])]) (ExMeta "n4", ExFormation [BiVoid (AtLabel "щи")]) Righthand (AtLabel "щи")]) lines written `shouldContain` [" <unripe left=\"𝑛3·1\" right=\"𝑛4·1\" at=\"щи\"/>"] it "writes the formation a join fabricated as an element naming both sides in the markup" $ do- (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvFabricated 2 (ExMeta "n3", ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n4", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (ExFormation [BiTau AtPhi (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) AtPhi), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) AtPhi)]), BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])])])+ (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvFabricated 2 (ExMeta "n3", ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (ExMeta "n4", ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) [] (ExFormation [BiTau AtPhi (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) AtPhi), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) AtPhi)]), BiTau (AtLabel "к") (ExFormation [BiLambda (Function "L_ж"), BiTau (AtLabel "on") (ExFormation [BiDelta (BtOne "05")]), BiTau (AtLabel "left") (ExDispatch (ExFormation [BiTau AtPhi (ExDispatch ExRoot (AtLabel "ёж"))]) (AtLabel "к")), BiTau (AtLabel "right") (ExDispatch (ExFormation [BiTau (AtLabel "к") (ExDispatch ExRoot (AtLabel "щука"))]) (AtLabel "к"))])])]) lines written `shouldContain` [" <fabricated meta=\"𝑛·1·1\" left=\"𝑛3·1\" right=\"𝑛4·1\">𝑒·1·5</fabricated>"] it "writes the meta a cast bound as an element naming the meta it read and the meta whose shape it took" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_ф" Morphing ExRoot, EvCast 2 "𝑛9" (ExMeta "n2") (ExMeta "n4") (ExFormation [BiTau AtPhi (ExFormation [BiTau AtPhi (ExFormation [BiLambda (FnSymbol 7)])]), BiTau (AtLabel "щ") ExRoot])])@@ -751,6 +799,9 @@ it "writes a firing no entry answered as an element naming the term it got stuck on" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_щ" Morphing ExRoot, EvStuck 2 "L_щ" Morphing (ExFormation [BiLambda (FnSymbol 120)])]) lines written `shouldContain` [" <unanswered λ=\"L_щ\" by=\"morph\">𝜎120</unanswered>"]+ it "writes a symbol nothing can fire as an element of its own, naming the term 𝕄 worked on" $ do+ (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvOpaque 1 120 Morphing (ExDispatch (ExFormation [BiLambda (FnSymbol 120)]) (AtLabel "щ"))])+ lines written `shouldContain` [" <opaque symbol=\"𝜎120\" by=\"morph\">𝜎120.щ</opaque>"] it "writes a stuck firing as an element of the word the text uses" $ do (_, written) <- recordedXml (\record -> mapM_ record [EvRun Morphing "Φ", EvFiring 1 "L_щ" Morphing ExRoot, EvStuckOn 2 "L_жук"]) lines written `shouldContain` [" <stuck λ=\"L_жук\"/>"]
test/EmitSpec.hs view
@@ -26,7 +26,7 @@ `shouldSatisfy` (\source -> all (\rule -> ("R.direct " ++ show rule.name) `isInfixOf` source) Y.normalizationRules) it "asks a built-in rule of normalization in the one walk, told it is a redex" $ fromRight "" (emitted [Y.Rule "kq" Nothing Nothing (ExDispatch ExTermination (AtLabel "wv")) ExTermination Nothing Nothing Nothing] [] [] [] [] [])- `shouldSatisfy` ("(0, True, rewriteKq)" `isInfixOf`)+ `shouldSatisfy` ("(0, True, rewriteKq normal)" `isInfixOf`) it "leaves a rule of '--rule' out of the one walk" $ fromRight "" (emitted [] [Y.Rule "jd" Nothing Nothing (ExDispatch ExXi (AtLabel "pe")) ExRoot Nothing Nothing Nothing] [] [] [] []) `shouldNotSatisfy` ("rewriteJd)" `isInfixOf`)@@ -38,7 +38,7 @@ `shouldSatisfy` (\source -> all (\rule -> ("(" ++ show rule.name ++ ", ") `isInfixOf` source) Y.contextualizationRules) it "writes a rule of '--rule' beside the built-in ones" $ fromRight "" (emitted [] [Y.Rule "kwpr" Nothing Nothing (ExDispatch ExXi (AtLabel "hq")) ExRoot Nothing Nothing Nothing] [] [] [] [])- `shouldSatisfy` ("R.direct \"kwpr\" False rewriteKwpr" `isInfixOf`)+ `shouldSatisfy` ("R.direct \"kwpr\" False (rewriteKwpr nf)" `isInfixOf`) it "imports the texts a label of a rule is spelled with" $ fromRight "" (emitted [] [Y.Rule "lb" Nothing Nothing (ExDispatch ExXi (AtLabel "hq")) ExRoot Nothing Nothing Nothing] [] [] [] []) `shouldSatisfy` ("import qualified Data.Text as T" `isInfixOf`)@@ -83,10 +83,13 @@ `shouldSatisfy` ("x1 == x3" `isInfixOf`) it "asks a normal form of a '𝑛' meta the way the matcher does" $ fromRight "" (emitted [] [Y.Rule "nh" Nothing Nothing (ExDispatch (ExMeta "n4") (AtLabel "wq")) ExRoot Nothing Nothing Nothing] [] [] [] [])- `shouldSatisfy` ("Ru.normalHeld nf x1" `isInfixOf`)+ `shouldSatisfy` ("Ru.normalHeld normal x1" `isInfixOf`) it "asks the condition 'nf' the way the matcher does" $ fromRight "" (emitted [] [Y.Rule "nc" Nothing Nothing (ExDispatch (ExMeta "e3") (AtLabel "jb")) ExRoot (Just (Y.NF (ExMeta "e3"))) Nothing Nothing] [] [] [] [])- `shouldSatisfy` ("Ru.normalHeld nf x1" `isInfixOf`)+ `shouldSatisfy` ("Ru.normalHeld normal x1" `isInfixOf`)+ it "tells a normal form with no test of a normal form inside it" $+ fromRight "" (emitted Y.normalizationRules [] Y.contextualizationRules Y.morphingRules Y.dataizationRules current)+ `shouldSatisfy` ("nf = Ru.normalWith (not . null . matchingBy (const True) Nothing)" `isInfixOf`) it "compiles a rule rewriting a formation into a formation the fast way, when it has a 'when' condition" $ fromRight "" (emitted [] [Y.Rule "fw" Nothing Nothing (ExFormation [BiMeta "B1", BiVoid (AtLabel "x"), BiMeta "B2"]) (ExFormation [BiMeta "B1", BiVoid (AtLabel "y"), BiMeta "B2"]) (Just (Y.In [AtLabel "z"] [BiMeta "B1"])) Nothing Nothing] [] [] [] []) `shouldSatisfy` ("stepFw ::" `isInfixOf`)@@ -119,11 +122,6 @@ ( "a rule rewriting a formation into a formation the fast way" , Y.Rule "fs" Nothing Nothing (ExFormation [BiMeta "B1", BiVoid (AtLabel "x"), BiMeta "B2"]) (ExFormation [BiMeta "B1", BiVoid (AtLabel "y"), BiMeta "B2"]) Nothing Nothing Nothing , "The rule 'fs' cannot be compiled, since it rewrites a formation into a formation the fast way"- )- ,- ( "a pattern applying Φ to a ρ"- , Y.Rule "rt" Nothing Nothing (ExDispatch (ExApplication ExRoot (ArTau AtRho ExXi)) (AtLabel "k")) ExXi Nothing Nothing Nothing- , "The rule 'rt' cannot be compiled, since its pattern applies Φ to a ρ" ) , ( "a function of 'where' other than 'contextualize' and 'named'"
test/EngineSpec.hs view
@@ -9,10 +9,11 @@ import Data.Map.Strict qualified as Map import Data.Set qualified as Set import Deps (Term (TeExpression))-import Engine (Engine (..), building, fresh, stepOf, yaml)+import Engine (Engine (..), building, cheat, fresh, stepOf, yaml)+import Functions (buildTerm) import Matcher (substEmpty)-import Rule (Step (..))-import Test.Hspec (Spec, describe, it, shouldBe)+import Rule (RuleContext (..), Step (..))+import Test.Hspec (Spec, describe, it, shouldBe, shouldReturn) import Yaml qualified as Y spec :: Spec@@ -27,6 +28,16 @@ it "names every rule of normalization as one matching a term" $ _matching yaml (Just (ExFormation [BiVoid (AtLabel "ug")])) (ExDispatch ExRoot (AtLabel "yb")) `shouldBe` Set.fromList [0 .. length Y.normalizationRules - 1]+ describe "cheat" $ do+ it "lets every step of normalization cheat" $+ mapM (\step -> fmap fst <$> _applied step (RuleContext buildTerm Nothing (const True) False) ExXi) (_normalization (cheat yaml{_normalization = [told]}))+ `shouldReturn` [Just ExRoot]+ it "lets every compiled step cheat" $+ mapM (\step -> fmap fst <$> _applied step (RuleContext buildTerm Nothing (const True) False) ExXi) (Map.elems (_rules (cheat yaml{_rules = Map.fromList [("rule", told)]})))+ `shouldReturn` [Just ExRoot]+ it "leaves the engine honest without it" $+ mapM (\step -> fmap fst <$> _applied step (RuleContext buildTerm Nothing (const True) False) ExXi) [told]+ `shouldReturn` [Just ExXi] describe "fresh" $ do it "accepts the engine interpreting the rules phino carries" $ fresh yaml `shouldBe` True@@ -36,3 +47,6 @@ it "hands contextualization to the engine" $ do TeExpression term <- building yaml{_contextualize = \_ _ -> pure (ExDispatch ExRoot (AtLabel "qo"))} "contextualize" [Y.ArgExpression ExXi, Y.ArgExpression (ExFormation [])] substEmpty term `shouldBe` ExDispatch ExRoot (AtLabel "qo")+ where+ told :: Step+ told = Step "told" (\ctx _ -> pure (Just (if _cheat ctx then ExRoot else ExXi, [])))
test/EvaluateSpec.hs view
@@ -108,7 +108,7 @@ where orphans :: [String] -> [(String, String)] -> [String] orphans [] _ = []- orphans (line : rest) facts = case (T.stripPrefix "remembered " (T.pack line) <|> T.stripPrefix "memoized " (T.pack line), T.stripPrefix "recalled " (T.pack line)) of+ orphans (line : rest) facts = case (T.stripPrefix "remembered " (T.pack line) <|> T.stripPrefix "memoized " (T.pack line) <|> T.stripPrefix "renamed " (T.pack line), T.stripPrefix "recalled " (T.pack line)) of (Just fact, _) -> orphans rest ([paired arrow (fst (T.breakOn " # " fact)) | arrow <- [" ≡ ", " ⇛ "], arrow `T.isInfixOf` fact] ++ facts) (_, Just recall) | paired " ⇒ " recall `elem` facts -> orphans rest facts@@ -165,7 +165,7 @@ let stuck = ctx{_saveEval = record} fire = execBuildTerm univ stuck "evaluate" [ArgExpression (ExFormation [BiLambda (FnSymbol 1)]), ArgExpression univ] substEmpty fire `shouldThrow` (\e -> "No entry of --symbolic answers the λ function '𝜎1'" `isInfixOf` show (e :: SomeException))- written `shouldBe` " unanswered 𝜎1 # 𝕄(𝜎1:λ)\n"+ written `shouldBe` " opaque 𝜎1 # 𝕄(𝜎1:λ)\n" it "throws when the formation carries more than one λ binding" $ runEvaluate [ArgExpression (ExFormation [BiLambda (Function "L_one"), BiLambda (Function "L_two")]), ArgExpression univ]@@ -201,3 +201,19 @@ ctx <- withLambdas table <$> defaultReduceContext (ExDispatch ExRoot (AtLabel "y")) timeout 10000000 (morph program emptyState ctx{_deadline = Just (Deadline 37 due)}) `shouldThrow` (\e -> "--max-seconds=37" `isInfixOf` show (e :: SomeException))++ describe "fabricates a formation of two sides of different shapes" $+ it "binds the sides by the names the run gave them, not by the sides themselves" $ do+ let program = "⟦ y ↦ ⟦ c ↦ ⟦ λ ⤍ 𝜎1 ⟧, a ↦ ⟦ φ ↦ Φ.hx, ke ↦ Φ.ty ⟧, b ↦ ⟦ φ ↦ Φ.zu ⟧, λ ⤍ L_fork ⟧.ke ⟧"+ expr <- parseExpressionThrows' MONOFORM program+ table <- withLambdasOf "- λ: L_fork\n dataize:\n 𝛿1: $.c\n join:\n on: 𝛿1\n left: $.a\n right: $.b\n otherwise: L_join\n" readLambdas+ ctx <- withLambdas table <$> defaultReduceContext (ExDispatch ExRoot (AtLabel "y"))+ (morphed, _, _) <- morph expr emptyState ctx+ sides morphed `shouldSatisfy` (\found -> length found == 2 && all named' found)+ where+ sides :: Expression -> [Expression]+ sides (ExFormation bds) = [side | BiTau AtRho (ExFormation fabricated) <- bds, BiTau (AtLabel label) side <- fabricated, label `elem` ["left🌵", "right🌵"]]+ sides _ = []+ named' :: Expression -> Bool+ named' (ExMeta meta) = isName meta+ named' _ = False
test/Fixtures.hs view
@@ -48,6 +48,7 @@ import Lambdas (Lambdas, emptyLambdas, readLambdas) import Lining (LineFormat (MULTILINE)) import Morph (Deadline (..), ReduceContext (..), Steps (..))+import Sides (sides) import Sugar (SugarType (SWEET)) import System.Directory (getTemporaryDirectory, removePathForcibly) import System.FilePath (takeExtension)@@ -57,7 +58,8 @@ defaultReduceContext :: Expression -> IO ReduceContext defaultReduceContext loc = do minted <- newIORef 0- pure (ReduceContext loc loc Nothing 25 25 Nothing Nothing (Steps 250 0) Nothing minted Nothing Nothing 1 Nothing False True False Nothing 0 Morphing [] Map.empty Nothing emptyLambdas [] False (building linked) reduction evaluation dontSaveStep dontSaveEval linked)+ named <- sides+ pure (ReduceContext loc loc Nothing 25 25 Nothing Nothing (Steps 250 0) Nothing minted named Nothing Nothing 1 Nothing False True False Nothing 0 Morphing [] Map.empty Nothing emptyLambdas [] False Nothing (building linked) reduction evaluation dontSaveStep dontSaveEval linked) linked :: Engine linked = fromMaybe yaml compiled
test/ForksSpec.hs view
@@ -81,7 +81,9 @@ describe "forked" $ do let fork :: Text -> Either Int Bytes -> String -> String -> IO (Either Refusal Expression)- fork func condition left right = forked (Function func) condition <$> parseExpressionThrows left <*> parseExpressionThrows right+ fork func condition left right = forked (Function func) condition <$> fmap twice (parseExpressionThrows left) <*> fmap twice (parseExpressionThrows right)+ twice :: Expression -> (Expression, Expression)+ twice side = (side, side) it "asks the copies of both sides for an attribute the λ it is given picks between" $ do expected <- parseExpressionThrows "⟦ left🌵 ↦ ⟦ φ ↦ Φ.hx ⟧, right🌵 ↦ ⟦ φ ↦ Φ.zu( ke ↦ Φ.ty ) ⟧, φ ↦ ⟦ ρ ↦ ∅, λ ⤍ L_qw, on🌵 ↦ ⟦ Δ ⤍ 1C- ⟧, left🌵 ↦ ξ.ρ.left🌵.φ, right🌵 ↦ ξ.ρ.right🌵.φ ⟧ ⟧" fork "L_qw" (Right (BtOne "1C")) "⟦ φ ↦ Φ.hx ⟧" "⟦ φ ↦ Φ.zu( ke ↦ Φ.ty ) ⟧" >>= (`shouldBe` Right expected)
test/FunctionsSpec.hs view
@@ -17,7 +17,7 @@ import Matcher (Meta (Named), MetaValue (MvBindings), Subst (Subst), substEmpty) import Misc (uniqueBindings') import Printer (printExpression)-import Test.Hspec (Expectation, Spec, describe, it, shouldBe, shouldThrow)+import Test.Hspec (Expectation, Spec, describe, it, shouldBe, shouldNotBe, shouldThrow) import Text.Printf (printf) import Yaml (ExtraArgument (ArgAttribute, ArgBinding, ArgBytes, ArgExpression)) @@ -56,6 +56,30 @@ subst = Subst (Map.fromList [first, second]) TeBindings bds <- buildTerm "join" [ArgBinding (BiMeta "B1"), ArgBinding (BiMeta "B2")] subst length bds `shouldBe` 2++ it "renames a reference through rho from a nested formation" $ do+ let first = (Named "B1", MvBindings [BiTau (AtLabel "a") ExRoot])+ second =+ ( Named "B2"+ , MvBindings+ [ BiTau (AtLabel "a") ExXi+ , BiTau (AtLabel "c") (ExFormation [BiTau (AtLabel "d") (ExDispatch (ExDispatch ExXi AtRho) (AtLabel "a"))])+ ]+ )+ subst = Subst (Map.fromList [first, second])+ TeBindings [_, BiTau renamed _, BiTau _ (ExFormation [BiTau _ (ExDispatch _ ref)])] <-+ buildTerm "join" [ArgBinding (BiMeta "B1"), ArgBinding (BiMeta "B2")] subst+ renamed `shouldNotBe` AtLabel "a"+ ref `shouldBe` renamed++ it "keeps a reference to an attribute of the nested formation itself" $ do+ let first = (Named "B1", MvBindings [BiTau (AtLabel "a") ExRoot])+ inner = ExFormation [BiVoid (AtLabel "a"), BiTau (AtLabel "d") (ExDispatch ExXi (AtLabel "a"))]+ second = (Named "B2", MvBindings [BiTau (AtLabel "a") ExXi, BiTau (AtLabel "c") inner])+ subst = Subst (Map.fromList [first, second])+ TeBindings [_, _, BiTau _ result] <-+ buildTerm "join" [ArgBinding (BiMeta "B1"), ArgBinding (BiMeta "B2")] subst+ result `shouldBe` inner it "joins no bindings when given no arguments" $ do TeBindings bds <- buildTerm "join" [] substEmpty
test/Grown.hs view
@@ -39,8 +39,6 @@ ] ) spelled :: Expression -> Bool- spelled (ExApplication ExXi _) = False- spelled (ExApplication ExRoot _) = False spelled (ExApplication (DataNumber _) (ArTau AtRho _)) = False spelled (ExApplication (DataString _) (ArTau AtRho _)) = False spelled _ = True@@ -76,7 +74,7 @@ smaller = \case ExFormation bds -> [inner | BiTau _ inner <- bds] ++ (ExFormation <$> shrinkList binding bds) ExDispatch inner attr -> inner : (ExDispatch <$> smaller inner <*> pure attr)- ExApplication inner arg -> inner : held arg : [ExApplication less arg | less <- smaller inner, less `notElem` [ExXi, ExRoot]] ++ (ExApplication inner <$> argued arg)+ ExApplication inner arg -> inner : held arg : (ExApplication <$> smaller inner <*> pure arg) ++ (ExApplication inner <$> argued arg) _ -> [] binding :: Binding -> [Binding] binding (BiTau attr inner) = BiTau attr <$> smaller inner
test/InferenceSpec.hs view
@@ -89,7 +89,7 @@ isNothing found `shouldBe` True context :: RuleContext-context = RuleContext (building yaml) Nothing yaml._normal+context = RuleContext (building yaml) Nothing yaml._normal False morphingRule :: String -> Y.MorphRule morphingRule name = fromMaybe (error (printf "no morphing rule is named '%s'" name)) (find (\rule -> rule.name == name) Y.morphingRules)
test/LaTeXSpec.hs view
@@ -311,6 +311,23 @@ , "\\end{phiquation}" ] + it "keeps the name of a function across the focused steps of a --sequence under --canonize" $ do+ focus <- parseExpressionThrows "Q.a"+ step1 <- parseExpressionThrows "[[ a -> [[ x -> [[ L> Fa ]], y -> [[ L> Fb ]] ]] ]]"+ step2 <- parseExpressionThrows "[[ a -> [[ y -> [[ L> Fb ]] ]] ]]"+ latex <-+ rewrittensToLatex+ ([(step1, Nothing), (step2, Just (Normalization, "drop"))], False)+ defaultLatexContext{_focus = focus, _canonize = True}+ latex+ `shouldBe` intercalate+ "\n"+ [ "\\begin{phiquation}"+ , "[[ |x| -> |Fn1| : L, |y| -> |Fn2| : L ]]"+ , " \\phiNormalize |Fn2| : L : |y| \\phiNormalize[\\nameref{r:drop}]{.}"+ , "\\end{phiquation}"+ ]+ it "compresses and canonizes a --sequence of focused sub-expressions above the default meet threshold" $ do focus <- parseExpressionThrows "Q.x" step1 <- parseExpressionThrows "[[ x -> [[ w -> Q.a.b.c.d ]] ]]"
test/LambdasSpec.hs view
@@ -82,7 +82,7 @@ rewrote :: [(String, String)] -> String -> IO Expression rewrote rules term = do parsed <- mapM (\(source, target) -> (\from to -> Y.Rule "kq" Nothing Nothing from to Nothing Nothing Nothing) <$> parseExpressionThrows source <*> parseExpressionThrows target) rules- parseExpressionThrows term >>= rewritten (RuleContext buildTerm Nothing normal) parsed+ parseExpressionThrows term >>= rewritten (RuleContext buildTerm Nothing normal False) parsed answers :: Lambdas -> T.Text -> Maybe Expression answers known func = case _ending <$> matched known func of@@ -571,6 +571,11 @@ kept <- parseExpressionThrows "Φ.number( φ ↦ Φ.bytes( φ ↦ ⟦ λ ⤍ 𝜎2 ⟧ ) )" stayed term `shouldBe` kept + it "keeps the bindings beside the one it changed" $ do+ term <- parseExpressionThrows "⟦ ja ↦ ξ.w, ne ↦ Φ.bytes( ρ ↦ ⟦ x ↦ ∅ ⟧ ), ob ↦ Φ.k( z ↦ ξ.w ) ⟧.ne"+ kept <- parseExpressionThrows "⟦ ja ↦ ξ.w, ne ↦ Φ.bytes, ob ↦ Φ.k( z ↦ ξ.w ) ⟧.ne"+ stayed term `shouldBe` kept+ describe "cast" $ do it "casts a bare symbol into a copy of a decorator whose φ is a bare symbol" $ do bare <- parseExpressionThrows "⟦ λ ⤍ 𝜎5 ⟧"@@ -671,7 +676,7 @@ it "hands back the very term no rule matches, so a shared term stays shared" $ do term <- evaluate (iterate (\half -> ExFormation [BiTau (AtLabel "lo") half, BiTau (AtLabel "hi") half]) (ExFormation []) !! 9) rule <- (\from to -> Y.Rule "kq" Nothing Nothing from to Nothing Nothing Nothing) <$> parseExpressionThrows "Φ.true" <*> parseExpressionThrows "Φ.vw"- made <- rewritten (RuleContext buildTerm Nothing normal) [rule] term >>= evaluate+ made <- rewritten (RuleContext buildTerm Nothing normal False) [rule] term >>= evaluate (==) <$> (makeStableName $! made) <*> (makeStableName $! term) `shouldReturn` True describe "symbolized" $ do@@ -687,6 +692,15 @@ it "counts every symbol it minted" $ do term <- parseExpressionThrows "Φ.number( φ ↦ ⟦ Δ ⤍ 0E- ⟧ )" (\(_, _, spent) -> spent) (symbolized term 11) `shouldBe` 12++ it "leaves a term holding no datum as it is" $ do+ term <- parseExpressionThrows "⟦ φ ↦ Φ.wert( φ ↦ ⟦ λ ⤍ 𝜎5 ⟧ ).zahl, λ ⤍ L_kern, tief ↦ ξ.ρ.q( α0 ↦ ξ.w ) ⟧"+ symbolized term 5 `shouldBe` (term, [], 5)++ it "keeps the bindings beside the datum it turned into a symbol" $ do+ term <- parseExpressionThrows "Φ.paar( φ ↦ ⟦ λ ⤍ L_kern, eins ↦ ξ.w.r, zwei ↦ ⟦ Δ ⤍ 7B- ⟧, drei ↦ Φ.k( z ↦ ξ.w ) ⟧ )"+ masked <- parseExpressionThrows "Φ.paar( φ ↦ ⟦ λ ⤍ L_kern, eins ↦ ξ.w.r, zwei ↦ ⟦ λ ⤍ 𝜎4 ⟧, drei ↦ Φ.k( z ↦ ξ.w ) ⟧ )"+ (\(made, _, _) -> made) (symbolized term 3) `shouldBe` masked it "walks the φ an application binds down to the datum" $ do term <- parseExpressionThrows "Φ.number( φ ↦ Φ.bytes( φ ↦ ⟦ Δ ⤍ 3F-F0-00-00-00-00-00-00 ⟧ ) )"
test/MarginSpec.hs view
@@ -8,11 +8,13 @@ import AST import Bytes (numToBts, strToBts) import CST+import Control.Exception (evaluate) import Control.Monad (forM_) import Data.Text qualified as T import Lining (LineFormat (..), toSingleLine) import Margin (withLines, withMargin) import Render (render)+import System.Timeout (timeout) import Test.Hspec (Spec, describe, it, shouldBe, shouldNotBe) import Text.Printf (printf) @@ -95,6 +97,22 @@ spec :: Spec spec = do+ describe "withMargin on deep overflowing subtrees" $ do+ it "lays out nested formations without rendering every overflowing ancestor" $ do+ let leaf = EX_GLOBAL Φ+ nested = iterate nest leaf !! 10000+ nest :: EXPRESSION -> EXPRESSION+ nest inner = EX_FORMATION LSB EOL (TAB 1) (BI_PAIR (PA_TAU (AT_LABEL "x") ARROW inner) (BDS_EMPTY NO_TAB) NO_TAB) EOL (TAB 0) RSB+ result <- timeout 5000000 (evaluate (T.count "⟦" (render (withMargin 80 nested))))+ result `shouldBe` Just 10000+ it "lays out nested callees without rendering their preceding lines again" $ do+ let leaf = EX_GLOBAL Φ+ nested = iterate call leaf !! 10000+ call :: EXPRESSION -> EXPRESSION+ call inner = EX_APPLICATION inner NO_SPACE EOL (TAB 1) (AA_EXPRS (APP_ARG leaf AAS_EMPTY)) EOL (TAB 0) 1+ result <- timeout 5000000 (evaluate (T.count "(" (render (withMargin 80 nested))))+ result `shouldBe` Just 10000+ describe "withMargin on EX_FORMATION" $ do it "leaves an empty formation untouched at any margin" $ withMargin 0 (expressionToCST (ExFormation [])) `shouldBe` expressionToCST (ExFormation [])@@ -302,7 +320,7 @@ , ("a string literal", DataString (strToBts "hello")) ] margins :: [Int]- margins = [0, 1, 40, 80, 1000]+ margins = [-1, 0, 1, 40, 80, 1000, maxBound] commaFormation :: Expression commaFormation =
test/MorphSpec.hs view
@@ -30,7 +30,7 @@ import Inference (Conclusion (Answered), Premises (Concludes, Morphs), direct) import Lambdas (Lambdas, emptyLambdas) import Matcher (substEmpty)-import Morph (Deadline (..), ReduceContext (..), declared, emptyState, enter, execBuildTerm, factual, fired, inferred, insideUniverse, morph, morph', noted, voided)+import Morph (Deadline (..), ReduceContext (..), declared, emptyState, enter, execBuildTerm, factual, fired, inferred, insideUniverse, morph, morph', normalized, noted, voided) import Parser (Form (MONOFORM), parseExpressionThrows, parseExpressionThrows') import Rewriter (Rewritten) import Rule (RuleContext (RuleContext), matchExpressionWithRule')@@ -264,7 +264,7 @@ describe "morphing 'md' is disjoint from 'ml'" $ do ctx <- runIO (defaultReduceContext ExRoot)- let rctx = RuleContext (execBuildTerm ExRoot ctx) Nothing (_normal linked)+ let rctx = RuleContext (execBuildTerm ExRoot ctx) Nothing (_normal linked) False morphRule :: String -> Yaml.MorphRule morphRule nm = fromMaybe (error ("no morphing rule named " ++ nm)) (find (\r -> r.name == nm) Yaml.morphingRules) asRule :: Yaml.MorphRule -> Yaml.Rule@@ -295,6 +295,12 @@ ctx <- defaultReduceContext ExRoot (residue, _, _) <- morph expr emptyState ctx{_deadline = Just deadline, _partial = True} residue `shouldBe` expr+ it "fails a normalization once the deadline has passed" $ do+ expr <- parseExpressionThrows "[[ w -> [[ y -> ? ]]( y -> [[ ]] ) ]]"+ deadline <- overdue 19+ ctx <- defaultReduceContext ExRoot+ normalized expr ((expr, Nothing) :| []) ctx{_deadline = Just deadline}+ `shouldThrow` (\e -> "--max-seconds=19" `isInfixOf` show (e :: SomeException)) describe "stops an entrance by the clock of --max-seconds" $ it "fails a comparison that outlasts the deadline" $ do
test/ParserSpec.hs view
@@ -205,6 +205,10 @@ , "[[ !tfoo -> !e1Some, !t-BAR -> !e_123someW, !Bhi123 ]]" , "[[ !B ]](α𝑖 -> !e)" , "[[ 𝜏 -> !e, 𝐵 ]]"+ , "Q(x -> [[]])"+ , "$(x -> [[]])"+ , "[[ a -> [[ x -> ∅ ]], b -> $(x -> [[ ]]) ]]"+ , "[[ a -> Q(^ -> [[ ]]) ]]" ] (\expr -> it expr (parseExpression expr `shouldSatisfy` isRight)) @@ -216,8 +220,6 @@ [ "Q.x()" , "[[x(^, @, y) -> [[q -> QQ]] ]]" , "Q * !t1 * !t2"- , "Q(x -> [[]])"- , "$(x -> [[]])" , "Q.x(x -> ?)" , "Q.x(L> Func)" , "Q.x(D> --)"@@ -253,6 +255,14 @@ , ("[[ y -> 5, x -> Q.z(} ]]", "expression:1:21:") ] + describe "points at the typo inside a list of named arguments instead of its first arrow" $+ fails+ parseExpression+ [ ("⟦ a ↦ Φ.foo( x ↦ 1, y ↦ ) ⟧", "expression:1:25:")+ , ("⟦ a ↦ Φ.foo( x ↦ 1, 2 ) ⟧", "expression:1:21:")+ , ("⟦\n app ↦ Φ.io.stdout(\n text ↦ Φ.string(\n ⟦ Δ ⤍ 48-65-6C-6C-6F ⟧\n ),\n size ↦ Φ.number( ⟦ Δ ⤍ 40-14-00-00-00-00-00-00 ⟧,\n mode ↦ ⟦⟧\n )\n⟧", "expression:7:10:")+ ]+ describe "tells what a binding prefix may be followed by" $ fails parseExpression@@ -560,6 +570,7 @@ , ("[[]](~!i1 -> $)", Just (ExApplication (ExFormation []) (ArAlpha (AlMeta "i1") ExXi))) , ("[[]](α𝑖1 -> Q)", Just (ExApplication (ExFormation []) (ArAlpha (AlMeta "i1") ExRoot))) , ("Q.foo(a1 -> Q.y)", Just (ExApplication (ExDispatch ExRoot (AtLabel "foo")) (ArTau (AtLabel "a1") (ExDispatch ExRoot (AtLabel "y")))))+ , ("Q.f(b(c), d)", Just (ExApplication (ExApplication (ExDispatch ExRoot (AtLabel "f")) (ArAlpha (Alpha 0) (ExApplication (ExDispatch ExXi (AtLabel "b")) (ArAlpha (Alpha 0) (ExDispatch ExXi (AtLabel "c")))))) (ArAlpha (Alpha 1) (ExDispatch ExXi (AtLabel "d"))))) ] describe "parse meta expressions" $
test/RegexpSpec.hs view
@@ -17,6 +17,35 @@ spec :: Spec spec = do+ describe "execution limits" $ do+ it "rejects a deeply recursive match with a normal error" $+ R.match (utf8 "^(a|b)*$") (utf8 (replicate 9000 'a'))+ `shouldThrow` (isInfixOf "Regex execution failed:" . displayException :: SomeException -> Bool)++ forM_+ [ ("extractGroups", \regex input -> void (R.extractGroups regex input))+ , ("replaceFirst", \regex input -> void (R.replaceFirst regex (utf8 "X") input))+ , ("replaceAll", \regex input -> void (R.replaceAll regex (utf8 "X") input))+ ]+ ( \(desc, execute) ->+ forM_ ["(a|b)*", "(ab)+"] $ \pattern ->+ it ("rejects deep recursion in " ++ desc ++ " with " ++ pattern) $ do+ regex <- R.compile (utf8 pattern)+ execute regex (utf8 (concat (replicate 10000 "ab")))+ `shouldThrow` (isInfixOf "Regex execution failed:" . displayException :: SomeException -> Bool)+ )++ it "does not let a pattern raise the recursion ceiling" $+ R.match (utf8 "(*LIMIT_RECURSION=10000000)^(a|b)*$") (utf8 (replicate 9000 'a'))+ `shouldThrow` (isInfixOf "Regex execution failed:" . displayException :: SomeException -> Bool)++ it "rejects excessive backtracking with a normal error" $+ R.match (utf8 "^(a+)+$") (utf8 (replicate 30 'a' ++ "b"))+ `shouldThrow` (isInfixOf "Regex execution failed:" . displayException :: SomeException -> Bool)++ it "still matches a long string without deep recursion" $+ R.match (utf8 "^a+$") (utf8 (replicate 20000 'a')) `shouldReturn` True+ describe "compile" $ do forM_ [ ("compiles a valid pattern", "foo", "foobar")
test/RenderSpec.hs view
@@ -9,7 +9,8 @@ import CST import Control.Monad (forM_) import Data.Text qualified as T-import Render (Render (render))+import Grown (Grown (..))+import Render (Render (..), displayWidth, lastLineWidthAtMost, widthAtMost) import Test.Hspec import Test.Hspec.QuickCheck (prop) import Test.QuickCheck (chooseInt, forAll)@@ -28,6 +29,36 @@ spec :: Spec spec = do+ describe "widthAtMost" $ do+ prop "agrees with measuring the complete rendering" $ \(Grown expression) ->+ forAll (chooseInt (0, 120)) $ \limit ->+ let node = expressionToCST expression+ in widthAtMost limit node == min (limit + 1) (displayWidth (render node))+ it "stops at the limit without rendering the preceding subtree" $+ let node = EX_DISPATCH (error "callee rendered") NO_SPACE (AT_LABEL (T.replicate 100 "x"))+ in widthAtMost 80 node `shouldBe` 81++ describe "lastLineWidthAtMost" $ do+ prop "agrees with measuring the rendered last line" $ \(Grown expression) ->+ forAll (chooseInt (0, 120)) $ \limit ->+ let node = expressionToCST expression+ expected = case T.lines (render node) of+ [] -> 0+ lines' -> displayWidth (last lines')+ in lastLineWidthAtMost limit node == min (limit + 1) expected+ it "stops at a newline without rendering the preceding subtrees" $+ let node = EX_APPLICATION (error "callee rendered") NO_SPACE EOL (TAB 1) (error "argument rendered") EOL (TAB 0) 1+ in lastLineWidthAtMost 80 node `shouldBe` 1+ it "stops at the width limit without rendering the preceding subtree" $+ let node = EX_DISPATCH (error "callee rendered") NO_SPACE (AT_LABEL (T.replicate 100 "x"))+ in lastLineWidthAtMost 80 node `shouldBe` 81+ forM_ ["", "\n", "x\n", "x\n\n", "x\n大家e\769", "\n大家e\769\n"] $ \value ->+ it ("measures the final line of " ++ show value) $+ let expected = case T.lines value of+ [] -> 0+ lines' -> displayWidth (last lines')+ in lastLineWidthAtMost 80 value `shouldBe` expected+ describe "render primitive wrapper instances" $ forM_ [ ("String", render ("hi" :: String), "hi")
test/RewriterSpec.hs view
@@ -28,8 +28,8 @@ import Must (Must (..)) import Parser (Form (MONOFORM), parseExpressionThrows, parseExpressionThrows') import Printer (printExpression)-import Rewriter (RewriteContext (RewriteContext), direct, every, fast, rewrite)-import Rule (RuleContext (RuleContext), Step (Step, _applied))+import Rewriter (RewriteContext (RewriteContext), cheating, direct, every, fast, rewrite)+import Rule (RuleContext (RuleContext), Step (Step, _applied, _name)) import System.FilePath (makeRelative, replaceExtension, (</>)) import Tau (seedTaus) import Test.Hspec (Spec, describe, expectationFailure, it, pending, runIO, shouldBe, shouldReturn, shouldSatisfy, shouldThrow)@@ -321,17 +321,34 @@ `shouldBe` Set.fromList [0, 1, 2] describe "direct" $ do it "rewrites every place the function matches at" $- fmap fst <$> _applied (direct "tx" False (\_ expr -> [ExRoot | ExXi <- [expr]])) (RuleContext buildTerm Nothing (const True)) (ExDispatch (ExApplication ExXi (ArTau (AtLabel "o") ExXi)) (AtLabel "m"))+ fmap fst <$> _applied (direct "tx" False (\_ expr -> [ExRoot | ExXi <- [expr]])) (RuleContext buildTerm Nothing (const True) False) (ExDispatch (ExApplication ExXi (ArTau (AtLabel "o") ExXi)) (AtLabel "m")) `shouldReturn` Just (ExDispatch (ExApplication ExRoot (ArTau (AtLabel "o") ExRoot)) (AtLabel "m")) it "tells every place it rewrote, beside what it rewrote it to" $- fmap snd <$> _applied (direct "tq" False (\_ expr -> [ExRoot | ExXi <- [expr]])) (RuleContext buildTerm Nothing (const True)) (ExApplication ExXi (ArTau (AtLabel "ё") ExXi))+ fmap snd <$> _applied (direct "tq" False (\_ expr -> [ExRoot | ExXi <- [expr]])) (RuleContext buildTerm Nothing (const True) False) (ExApplication ExXi (ArTau (AtLabel "ё") ExXi)) `shouldReturn` Just [(ExXi, ExRoot), (ExXi, ExRoot)] it "tells it matched nowhere" $- _applied (direct "tx" False (\_ expr -> [ExRoot | ExXi <- [expr]])) (RuleContext buildTerm Nothing (const True)) (ExDispatch ExTermination (AtLabel "m"))+ _applied (direct "tx" False (\_ expr -> [ExRoot | ExXi <- [expr]])) (RuleContext buildTerm Nothing (const True) False) (ExDispatch ExTermination (AtLabel "m")) `shouldReturn` Nothing it "hands the world to the function" $- fmap fst <$> _applied (direct "tw" False (\universe expr -> [world | ExXi <- [expr], Just world <- [universe]])) (RuleContext buildTerm (Just ExTermination) (const True)) ExXi+ fmap fst <$> _applied (direct "tw" False (\universe expr -> [world | ExXi <- [expr], Just world <- [universe]])) (RuleContext buildTerm (Just ExTermination) (const True) False) ExXi `shouldReturn` Just ExTermination+ describe "cheating" $ do+ it "drops the ρ a rule applies to a term that already ends with one" $ do+ dot <- maybe (fail "no rule dot") pure (lookup "dot" [(_name step, step) | step <- map (stepOf linked) normalizationRules])+ term <- parseExpressionThrows "⟦ a ↦ Φ.x( ρ ↦ ⟦⟧ ), b ↦ ⟦⟧ ⟧.a"+ fmap fst <$> _applied (cheating dot) (RuleContext buildTerm Nothing (const True) False) term+ `shouldReturn` Just (ExApplication (ExDispatch ExRoot (AtLabel "x")) (ArTau AtRho (ExFormation [])))+ it "keeps both ρ when it is not asked to cheat" $ do+ dot <- maybe (fail "no rule dot") pure (lookup "dot" [(_name step, step) | step <- map (stepOf linked) normalizationRules])+ term <- parseExpressionThrows "⟦ a ↦ Φ.x( ρ ↦ ⟦⟧ ), b ↦ ⟦⟧ ⟧.a"+ fmap fst <$> _applied dot (RuleContext buildTerm Nothing (const True) False) term+ `shouldReturn` Just (ExApplication (ExApplication (ExDispatch ExRoot (AtLabel "x")) (ArTau AtRho (ExFormation []))) (ArTau AtRho (ExFormation [BiTau (AtLabel "a") (ExApplication (ExDispatch ExRoot (AtLabel "x")) (ArTau AtRho (ExFormation []))), BiTau (AtLabel "b") (ExFormation [])])))+ it "drops the ρ a compiled step applies to a term that already ends with one" $+ fmap snd <$> _applied (cheating (direct "rr" False (\_ expr -> [ExApplication (ExApplication ExRoot (ArTau AtRho ExXi)) (ArTau AtRho ExRoot) | ExXi <- [expr]]))) (RuleContext buildTerm Nothing (const True) False) ExXi+ `shouldReturn` Just [(ExXi, ExApplication ExRoot (ArTau AtRho ExXi))]+ it "keeps a ρ applied to a term ending with another argument" $+ fmap fst <$> _applied (cheating (direct "ro" False (\_ expr -> [ExApplication (ExApplication ExRoot (ArTau (AtLabel "o") ExXi)) (ArTau AtRho ExRoot) | ExXi <- [expr]]))) (RuleContext buildTerm Nothing (const True) False) ExXi+ `shouldReturn` Just (ExApplication (ExApplication ExRoot (ArTau (AtLabel "o") ExXi)) (ArTau AtRho ExRoot)) describe "fast" $ do it "holds for a formation rewritten between the same two meta bindings" $ fast (ExFormation [BiMeta "B1", BiVoid (AtLabel "j"), BiMeta "B2"]) (ExFormation [BiMeta "B1", BiVoid (AtLabel "k"), BiMeta "B2"])
test/RuleSpec.hs view
@@ -10,6 +10,7 @@ import AST (Argument (..), Attribute (..), Binding (..), Bytes (..), Expression (..), Function (..), Slot (..), inert) import Builder (buildExpressionThrows)+import Control.Exception (evaluate) import Control.Monad import Data.Aeson import Data.List (isInfixOf)@@ -23,10 +24,11 @@ import Matcher import Parser (Form (MONOFORM), parseExpressionThrows, parseExpressionThrows') import Printer (printSubsts)-import Rule (RuleContext (RuleContext), isNF, matchExpressionWithRule, meetCondition, normalHeld, redex)+import Rule (RuleContext (RuleContext), isNF, matchExpressionWithRule, meetCondition, normal, normalHeld, redex) import System.FilePath import System.IO (stderr) import System.IO.Silently (hCapture)+import System.Timeout (timeout) import Test.Hspec (Spec, after_, describe, expectationFailure, it, runIO, shouldBe, shouldReturn, shouldSatisfy) import Yaml qualified @@ -50,7 +52,7 @@ expr <- parseExpressionThrows' MONOFORM (expression pack) let matched = matchExpression (pattern pack) expr unless (matched /= []) (expectationFailure "List of matched substitutions is empty which is not expected")- met <- meetCondition (condition pack) matched (RuleContext buildTerm Nothing (_normal linked))+ met <- meetCondition (condition pack) matched (RuleContext buildTerm Nothing (_normal linked) False) case failure pack of Just True -> unless@@ -68,7 +70,7 @@ ) ) describe "an 'or' condition does not depend on the order of its items" $ do- let ctx = RuleContext buildTerm Nothing (_normal linked)+ let ctx = RuleContext buildTerm Nothing (_normal linked) False rule :: Yaml.Condition -> Yaml.Rule rule cond = Yaml.Rule@@ -98,7 +100,7 @@ buildE1 (Yaml.Not (Yaml.Or [raising, unmatched])) `shouldReturn` [] describe "isNF determines normal form" $ do- let ctx = RuleContext buildTerm Nothing (_normal linked)+ let ctx = RuleContext buildTerm Nothing (_normal linked) False forM_ [ ("returns true for ExXi", ExXi, True) , ("returns true for ExRoot", ExRoot, True)@@ -119,9 +121,16 @@ ] (\(desc, expr, expected) -> it desc $ isNF expr ctx `shouldBe` expected) + describe "tells a normal form of a chain of nested copies in time" $ do+ let chain :: Int -> Expression+ chain depth = iterate (ExApplication (ExFormation [BiVoid (AtLabel "x"), BiTau (AtLabel "y") (ExDispatch ExXi (AtLabel "x"))]) . ArTau (AtLabel "x")) (ExFormation [BiDelta (BtOne "00")]) !! depth+ forM_ [("the rules of YAML", normal), ("the engine linked", _normal linked)] $ \(name, test) ->+ it ("by " ++ name) $+ timeout 10000000 (evaluate (test (chain 40))) `shouldReturn` Just False+ describe "matchExpressionWithRule via a 'where' extension or a φ-marker meta" $ do let ctx :: RuleContext- ctx = RuleContext buildTerm Nothing (_normal linked)+ ctx = RuleContext buildTerm Nothing (_normal linked) False joinRule :: Yaml.Rule joinRule =@@ -218,10 +227,10 @@ world :: Expression world = ExFormation [BiTau (AtLabel "qwj") (ExFormation [BiDelta (BtOne "7C")]), BiVoid AtRho] it "writes Φ for the whole program the context stands in" $ do- (mapM (buildExpressionThrows (ExMeta "e2")) =<< matchExpressionWithRule world namingRule (RuleContext buildTerm (Just world) (_normal linked)))+ (mapM (buildExpressionThrows (ExMeta "e2")) =<< matchExpressionWithRule world namingRule (RuleContext buildTerm (Just world) (_normal linked) False)) `shouldReturn` [ExRoot] it "writes the formation itself where the context knows no universe" $ do- (mapM (buildExpressionThrows (ExMeta "e2")) =<< matchExpressionWithRule world namingRule (RuleContext buildTerm Nothing (_normal linked)))+ (mapM (buildExpressionThrows (ExMeta "e2")) =<< matchExpressionWithRule world namingRule (RuleContext buildTerm Nothing (_normal linked) False)) `shouldReturn` [world] describe "normalHeld" $ do@@ -250,7 +259,7 @@ , "⟦ x ↦ ∅, dd ↦ ⟦ λ ⤍ L_dd, ρ ↦ ∅ ⟧, m1 ↦ ⟦ b ↦ ∅, φ ↦ ξ.ρ.dd( b ↦ ξ.b ), ρ ↦ ∅ ⟧ ⟧" ] context :: RuleContext- context = RuleContext buildTerm Nothing (_normal linked)+ context = RuleContext buildTerm Nothing (_normal linked) False matches :: Expression -> Yaml.Rule -> IO [Subst] matches term rule = maybe pure (\cond substs -> meetCondition cond substs context) rule.when (matchExpressionDeep rule.pattern term) it "takes every sample for inert" $ do@@ -264,7 +273,7 @@ describe "a condition that cannot be built" $ do after_ (setLogConfig ERROR 25) $ do let context :: RuleContext- context = RuleContext buildTerm Nothing (_normal linked)+ context = RuleContext buildTerm Nothing (_normal linked) False it "logs an unbound meta in 'part-of' and treats the condition as not met" $ do expr <- parseExpressionThrows "[[ x -> Q.y ]]" let substs = matchExpressionDeep (ExFormation [BiTau (AtLabel "x") (ExMeta "e1")]) expr
test/XMIRSpec.hs view
@@ -369,6 +369,20 @@ , ["XMIR does not support such expression", "a ↦ Φ.y"] ) ,+ ( "refuses a meta attribute of an application argument"+ , do+ expr <- parseExpressionThrows "[[ a -> Q.f(!t -> $) ]]"+ try (void (expressionToXMIR expr defaultXmirContext)) :: IO (Either SomeException ())+ , ["XMIR does not support such expression", "𝜏 ↦ ξ"]+ )+ ,+ ( "refuses a dispatch of a meta attribute"+ , do+ expr <- parseExpressionThrows "[[ a -> Q.f.!t1 ]]"+ try (void (expressionToXMIR expr defaultXmirContext)) :: IO (Either SomeException ())+ , ["XMIR does not support such expression", "Φ.f.𝜏1"]+ )+ , ( "names the attribute that is empty" , try (void (parseXMIRThrows "<object><o name=\"a\" base=\"\"/></object>" >>= xmirToPhi)) :: IO (Either SomeException ()) , ["The attribute 'base' is not expected to be empty"]