Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try normalization with user-defined rules only #415

Open
2 tasks
deemp opened this issue Jun 13, 2024 · 2 comments
Open
2 tasks

Try normalization with user-defined rules only #415

deemp opened this issue Jun 13, 2024 · 2 comments
Assignees
Labels
(eo-phi-normalizer) Related to the eo-phi-normalizer priority 1

Comments

@deemp
Copy link
Member

deemp commented Jun 13, 2024

We need to show that not normalizing inside atoms won't improve metrics.

  1. Use the multiplication table example (link) (blocked on Can't convert EO example in the README to PHI eo#3228)

  2. Run normalizer dataize like in the pipeline (link), but without --minimize-stuck-terms.

Blocked on:

@deemp deemp self-assigned this Jun 13, 2024
@deemp
Copy link
Member Author

deemp commented Jun 14, 2024

Commands (using the correct program - see objectionary/eo#3228 (comment)):

mkdir try-phi

cd try-phi

cat <<EOF > example.eo
# Some comment here.
[] > app
  malloc.for > @
    2
    [m]
      while > @
        m.as-int.lt 6 > [i] >>
        [i] >>
          seq > @
            *
              QQ.io.stdout
                QQ.txt.sprintf
                  *
                    "%d x %d = %d\n"
                    m.as-int > num
                    num
                    num.times num
              m.write
                0
                num.plus 1
EOF

npx eoc --parser=0.38.0 phi

PHI file

example.phi:

{
  ⟦
    app ↦ ⟦
      φ ↦ Φ.org.eolang.malloc.for(
        α0 ↦ Φ.org.eolang.int(
          α0 ↦ Φ.org.eolang.bytes(
            Δ ⤍ 00-00-00-00-00-00-00-02
          )
        ),
        α1 ↦ ⟦
          m ↦ ∅,
          φ ↦ Φ.org.eolang.while(
            α0 ↦ ξ.auto-named-attr-at-7-27,
            α1 ↦ ξ.auto-named-attr-at-8-11
          ),
          auto-named-attr-at-7-27 ↦ ⟦
            φ ↦ ξ.ρ.m.as-int.lt(
              α0 ↦ Φ.org.eolang.int(
                α0 ↦ Φ.org.eolang.bytes(
                  Δ ⤍ 00-00-00-00-00-00-00-06
                )
              )
            ),
            i ↦ ∅
          ⟧,
          auto-named-attr-at-8-11 ↦ ⟦
            i ↦ ∅,
            φ ↦ Φ.org.eolang.seq(
              α0 ↦ Φ.org.eolang.tuple(
                α0 ↦ Φ.org.eolang.tuple(
                  α0 ↦ Φ.org.eolang.tuple.empty,
                  α1 ↦ Φ.org.eolang.io.stdout(
                    α0 ↦ Φ.org.eolang.txt.sprintf(
                      α0 ↦ Φ.org.eolang.tuple(
                        α0 ↦ Φ.org.eolang.tuple(
                          α0 ↦ Φ.org.eolang.tuple(
                            α0 ↦ Φ.org.eolang.tuple(
                              α0 ↦ Φ.org.eolang.tuple.empty,
                              α1 ↦ Φ.org.eolang.string(
                                α0 ↦ Φ.org.eolang.bytes(
                                  Δ ⤍ 25-64-20-78-20-25-64-20-3D-20-25-64-0A
                                )
                              )
                            ),
                            α1 ↦ ξ.num
                          ),
                          α1 ↦ ξ.num
                        ),
                        α1 ↦ ξ.num.times(
                          α0 ↦ ξ.num
                        )
                      )
                    )
                  )
                ),
                α1 ↦ ξ.ρ.m.write(
                  α0 ↦ Φ.org.eolang.int(
                    α0 ↦ Φ.org.eolang.bytes(
                      Δ ⤍ 00-00-00-00-00-00-00-00
                    )
                  ),
                  α1 ↦ ξ.num.plus(
                    α0 ↦ Φ.org.eolang.int(
                      α0 ↦ Φ.org.eolang.bytes(
                        Δ ⤍ 00-00-00-00-00-00-00-01
                      )
                    )
                  )
                )
              )
            ),
            num ↦ ξ.ρ.m.as-int
          ⟧
        ⟧
      )
    ⟧
  ⟧
}

--minimize-stuck-terms disabled

Program ran too long. I didn't wait for the termination.

--minimize-stuck-terms enabled

normalizer dataize \
--minimize-stuck-terms \
--as-package \
--recursive \
--dependency-file .eoc/phi/org/eolang/string.phi --dependency-file .eoc/phi/org/eolang/dataized.phi --dependency-file .eoc/phi/org/eolang/nan.phi --dependency-file .eoc/phi/org/eolang/as-phi.phi --dependency-file .eoc/phi/org/eolang/positive-infinity.phi --dependency-file .eoc/phi/org/eolang/switch.phi --dependency-file .eoc/phi/org/eolang/go.phi --dependency-file .eoc/phi/org/eolang/true.phi --dependency-file .eoc/phi/org/eolang/cage.phi --dependency-file .eoc/phi/org/eolang/rust.phi --dependency-file .eoc/phi/org/eolang/cti.phi --dependency-file .eoc/phi/org/eolang/negative-infinity.phi --dependency-file .eoc/phi/org/eolang/bytes.phi --dependency-file .eoc/phi/org/eolang/seq.phi --dependency-file .eoc/phi/org/eolang/io/stdin.phi --dependency-file .eoc/phi/org/eolang/io/stdout.phi --dependency-file .eoc/phi/org/eolang/malloc.phi --dependency-file .eoc/phi/org/eolang/float.phi --dependency-file .eoc/phi/org/eolang/while.phi --dependency-file .eoc/phi/org/eolang/error.phi --dependency-file .eoc/phi/org/eolang/tuple.phi --dependency-file .eoc/phi/org/eolang/try.phi --dependency-file .eoc/phi/org/eolang/int.phi --dependency-file .eoc/phi/org/eolang/false.phi \
.eoc/phi/example.phi
{⟦
  app ↦ ⟦
    φ ↦ Φ.org.eolang.malloc.for (α0 ↦ Φ.org.eolang.int (α0 ↦ Φ.org.eolang.bytes (Δ ⤍ 00-00-00-00-00-00-00-02)),
    α1 ↦ ⟦
      m ↦ ∅, φ ↦ Φ.org.eolang.while (α0 ↦ ξ.auto-named-attr-at-7-27, α1 ↦ ξ.auto-named-attr-at-8-11),
      auto-named-attr-at-7-27 ↦ ⟦
        φ ↦ ξ.ρ.m.as-int.lt (α0 ↦ Φ.org.eolang.int (α0 ↦ Φ.org.eolang.bytes (Δ ⤍ 00-00-00-00-00-00-00-06))),
        i ↦ ∅
      ⟧,
      auto-named-attr-at-8-11 ↦ ⟦
        i ↦ ∅, φ ↦ Φ.org.eolang.seq (α0 ↦ Φ.org.eolang.tuple (α0 ↦ Φ.org.eolang.tuple (α0 ↦ Φ.org.eolang.tuple.empty, α1 ↦ Φ.org.eolang.io.stdout (α0 ↦ Φ.org.eolang.txt.sprintf (α0 ↦ Φ.org.eolang.tuple (α0 ↦ Φ.org.eolang.tuple (α0 ↦ Φ.org.eolang.tuple (α0 ↦ Φ.org.eolang.tuple (α0 ↦ Φ.org.eolang.tuple.empty, α1 ↦ Φ.org.eolang.string (α0 ↦ Φ.org.eolang.bytes (Δ ⤍ 25-64-20-78-20-25-64-20-3D-20-25-64-0A))),
        α1 ↦ ξ.num),
        α1 ↦ ξ.num),
        α1 ↦ ξ.num.times (α0 ↦ ξ.num))))),
        α1 ↦ ξ.ρ.m.write (α0 ↦ Φ.org.eolang.int (α0 ↦ Φ.org.eolang.bytes (Δ ⤍ 00-00-00-00-00-00-00-00)),
        α1 ↦ ξ.num.plus (α0 ↦ Φ.org.eolang.int (α0 ↦ Φ.org.eolang.bytes (Δ ⤍ 00-00-00-00-00-00-00-01)))))),
        num ↦ ξ.ρ.m.as-int
      ⟧
    ⟧
    )
  ⟧
⟧}

@deemp
Copy link
Member Author

deemp commented Jun 18, 2024

@fizruk, normalizer hangs.

many-wrappers.eo

# Input.
[] > input /?

# Pass.
[x] > pass
  x.gt 18 > @

# Rject.
[] > reject
  QQ.io.stdout > @
    "Sorry, no"

# Accept.
[] > accept
  QQ.io.stdout > @
    "You are welcome!"

# Gate.
[p left right] > gate
  p.if > @
    left
    right

# App.
[] > app
  gate > @
    pass input
    accept
    reject

command (see #404 (comment))

npx eoc phi --parser=0.38.4 --home-tag=0.38.2

.eoc/phi/many-wrappers.phi

{
  ⟦
    input ↦ ⟦
      λ ⤍ Linput
    ⟧,
    pass ↦ ⟦
      x ↦ ∅,
      φ ↦ ξ.x.gt(
        α0 ↦ Φ.org.eolang.int(
          α0 ↦ Φ.org.eolang.bytes(
            Δ ⤍ 00-00-00-00-00-00-00-12
          )
        )
      )
    ⟧,
    reject ↦ ⟦
      φ ↦ Φ.org.eolang.io.stdout(
        α0 ↦ Φ.org.eolang.string(
          α0 ↦ Φ.org.eolang.bytes(
            Δ ⤍ 53-6F-72-72-79-2C-20-6E-6F
          )
        )
      )
    ⟧,
    accept ↦ ⟦
      φ ↦ Φ.org.eolang.io.stdout(
        α0 ↦ Φ.org.eolang.string(
          α0 ↦ Φ.org.eolang.bytes(
            Δ ⤍ 59-6F-75-20-61-72-65-20-77-65-6C-63-6F-6D-65-21
          )
        )
      )
    ⟧,
    gate ↦ ⟦
      p ↦ ∅,
      left ↦ ∅,
      right ↦ ∅,
      φ ↦ ξ.p.if(
        α0 ↦ ξ.left,
        α1 ↦ ξ.right
      )
    ⟧,
    app ↦ ⟦
      φ ↦ ξ.ρ.gate(
        α0 ↦ ξ.ρ.pass(
          α0 ↦ ξ.ρ.input
        ),
        α1 ↦ ξ.ρ.accept,
        α2 ↦ ξ.ρ.reject
      )
    ⟧
  ⟧
}

command to normalize

normalizer dataize --minimize-stuck-terms --as-package --recursive --dependency-file .eoc/phi/org/eolang/string.phi --dependency-file .eoc/phi/org/eolang/dataized.phi --dependency-file .eoc/phi/org/eolang/nan.phi --dependency-file .eoc/phi/org/eolang/as-phi.phi --dependency-file .eoc/phi/org/eolang/positive-infinity.phi --dependency-file .eoc/phi/org/eolang/switch.phi --dependency-file .eoc/phi/org/eolang/go.phi --dependency-file .eoc/phi/org/eolang/true.phi --dependency-file .eoc/phi/org/eolang/cage.phi --dependency-file .eoc/phi/org/eolang/rust.phi --dependency-file .eoc/phi/org/eolang/cti.phi --dependency-file .eoc/phi/org/eolang/negative-infinity.phi --dependency-file .eoc/phi/org/eolang/bytes.phi --dependency-file .eoc/phi/org/eolang/seq.phi --dependency-file .eoc/phi/org/eolang/io/stdin.phi --dependency-file .eoc/phi/org/eolang/io/stdout.phi --dependency-file .eoc/phi/org/eolang/malloc.phi --dependency-file .eoc/phi/org/eolang/float.phi --dependency-file .eoc/phi/org/eolang/while.phi --dependency-file .eoc/phi/org/eolang/error.phi --dependency-file .eoc/phi/org/eolang/tuple.phi --dependency-file .eoc/phi/org/eolang/try.phi --dependency-file .eoc/phi/org/eolang/int.phi --dependency-file .eoc/phi/org/eolang/false.phi .eoc/phi/many-wrappers.phi

Result: requires a lot of memory and hangs

@fizruk fizruk added this to the [S14] Polish version 1.x milestone Jul 25, 2024
@deemp deemp added the (eo-phi-normalizer) Related to the eo-phi-normalizer label Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(eo-phi-normalizer) Related to the eo-phi-normalizer priority 1
Projects
None yet
Development

No branches or pull requests

2 participants