packages feed

phino-0.0.152: test-resources/evaluate-packs/cuts-a-recursion-that-differs-by-symbols-only.yaml

# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
# yamllint disable rule:line-length
# A factorial over a symbolic argument, under '--acyclic=proven'. Every round
# of the recursion mints fresh symbols, so the deep walk fires 'mul' with
# a ↦ 𝜎1 and b ↦ Ξ¦.fact( n ↦ 𝜎3 ) on the first round and with a ↦ 𝜎3 and
# b ↦ Ξ¦.fact( n ↦ 𝜎5 ) on the second, and no two rounds are ever the same term.
# They are the same formation up to a renaming of symbols, which is what the
# guard compares by (#1420), and the walk enters the formation it fires (#1451),
# so the second firing is cut before it opens and writes a 'looped' line where
# its block would have stood, carrying the term of the round that was kept
# (#1434). The budget is generous here, so what ends the run is the cut and not
# the limit. The argument 'n' and every symbol 'dec' answers stand in a
# carrier '⟦ Ο† ↦ 𝜎 ⟧', since the walk defers a copy one of whose arguments is
# a bare symbol instead of entering it (#1729). The first 'L_if' gets stuck,
# yet the symbols it minted stay taken, so the second one mints from 𝜎7 (#1738).
symbolic: |
  - Ξ»: L_zero
    dataize:
      𝛿1: $.x
    𝑛: ⟦ Ξ» ‍ 𝜎 ⟧
  - Ξ»: L_dec
    dataize:
      𝛿1: $.x
    𝑛: ⟦ Ο† ↦ ⟦ Ξ» ‍ 𝜎 ⟧ ⟧
  - Ξ»: L_mul
    dataize:
      𝛿1: $.a
      𝛿2: $.b
    𝑛: ⟦ Ξ» ‍ 𝜎 ⟧
  - Ξ»: L_if
    dataize:
      𝛿1: $.c
    morph:
      𝑛1: $.left
      𝑛2: $.right
    symbolize:
      𝑛3: 𝑛1
      𝑛4: 𝑛2
    join:
      𝑛5: [𝑛3, 𝑛4]
    𝑛: 𝑛5
location: 'Q.x'
deep: true
acyclic: proven
partial: true
steps: 250
input: >
  ⟦ if ↦ ⟦ c ↦ βˆ…, left ↦ βˆ…, right ↦ βˆ…, Ξ» ‍ L_if ⟧,
    zero ↦ ⟦ x ↦ βˆ…, Ξ» ‍ L_zero ⟧,
    dec ↦ ⟦ x ↦ βˆ…, Ξ» ‍ L_dec ⟧,
    mul ↦ ⟦ a ↦ βˆ…, b ↦ βˆ…, Ξ» ‍ L_mul ⟧,
    fact ↦ ⟦ n ↦ βˆ…, Ο† ↦ Ξ¦.if( c ↦ Ξ¦.zero( x ↦ ΞΎ.n ), left ↦ ⟦ Ξ” ‍ 01- ⟧, right ↦ Ξ¦.mul( a ↦ ΞΎ.n, b ↦ Ξ¦.fact( n ↦ Ξ¦.dec( x ↦ ΞΎ.n ) ) ) ) ⟧,
    x ↦ Ξ¦.fact( n ↦ ⟦ Ο† ↦ ⟦ Ξ» ‍ 𝜎1 ⟧ ⟧ ) ⟧
result: |-
  ⟦
    n ↦ 𝜎1:Ξ»:Ο†,
    Ο† ↦ Ξ¦.if(
      c ↦ 𝜎2:Ξ»,
      left ↦ 01-:Ξ”,
      right ↦ Ξ¦.mul( a ↦ n, b ↦ Ξ¦.fact( n ↦ 𝜎3:Ξ»:Ο† ) )
    )
  ⟧
protocol: |
  𝕄(Ξ¦.x):
    𝑛·0Β·1 := Ξ¦.fact( n ↦ 𝜎1:Ξ»:Ο† )
    𝕄(Ξ¦.x.Ο†):
      𝑛·0Β·2 := Ξ¦.zero( x ↦ 𝜎1:Ξ»:Ο† )
      𝔼(L_zero):
        𝛿1Β·1 := 𝔻(𝜎1:Ξ»)  # 𝔻(ΞΎ.x)
        𝑛·1Β·1 := 𝜎2:Ξ»  # 𝑛
        𝑛·1Β·2 := 𝜎2:Ξ»  # 𝕄(𝑛·1Β·1)
      𝑛·0Β·3 := Ξ¦.if( c ↦ 𝜎2:Ξ» )
      𝑛·0Β·4 := Ξ¦.if( c ↦ 𝜎2:Ξ» )
      𝑛·0Β·5 := 𝑛·0Β·4( left ↦ 01-:Ξ” )
      𝑛·0Β·6 := Ξ¦.mul( a ↦ 𝜎1:Ξ»:Ο† )
      𝑛·0Β·7 := Ξ¦.dec( x ↦ 𝜎1:Ξ»:Ο† )
      𝔼(L_dec):
        𝛿1Β·2 := 𝔻(𝜎1:Ξ»)  # 𝔻(ΞΎ.x)
        𝑛·2Β·1 := 𝜎3:Ξ»:Ο†  # 𝑛
        𝑛·2Β·2 := 𝜎3:Ξ»:Ο†  # 𝕄(𝑛·2Β·1)
      𝑛·0Β·8 := Ξ¦.fact( n ↦ 𝜎3:Ξ»:Ο† )
      𝑛·0Β·9 := Ξ¦.mul( a ↦ 𝜎1:Ξ»:Ο† )
      𝑛·0Β·10 := 𝑛·0Β·9( b ↦ 𝑛·0Β·8 )
      𝔼(L_mul):
        𝛿1Β·3 := 𝔻(𝜎1:Ξ»)  # 𝔻(ΞΎ.a)
        𝔻(Ξ¦.a🌡3):
          𝕄(Ξ¦.a🌡3):
            𝑛·3Β·1 := Ξ¦.fact( n ↦ 𝜎3:Ξ»:Ο† )
            𝑛·3Β·2 := Ξ¦.if( c ↦ Ξ¦.zero( x ↦ 𝜎3:Ξ»:Ο† ) )
            𝑛·3Β·3 := 𝑛·3Β·2( left ↦ 01-:Ξ” )
            𝑛·3Β·4 := 𝑛·3Β·3( right ↦ Ξ¦.mul( a ↦ 𝜎3:Ξ»:Ο†, b ↦ Ξ¦.fact( n ↦ Ξ¦.dec( x ↦ 𝜎3:Ξ»:Ο† ) ) ) )
          𝔼(L_if):
            𝔻(Ξ¦.a🌡4):
              𝕄(Ξ¦.a🌡4):
                𝑛·4Β·1 := Ξ¦.zero( x ↦ 𝜎3:Ξ»:Ο† )
              𝔼(L_zero):
                𝛿1Β·5 := 𝔻(𝜎3:Ξ»)  # 𝔻(ΞΎ.x)
                𝑛·5Β·1 := 𝜎4:Ξ»  # 𝑛
                𝑛·5Β·2 := 𝜎4:Ξ»  # 𝕄(𝑛·5Β·1)
            𝛿1Β·4 := 𝔻(𝜎4:Ξ»)  # 𝔻(ΞΎ.c)
            𝑛1Β·4 := 01-:Ξ”  # 𝕄(ΞΎ.left)
            𝕄(Ξ¦.a🌡7):
              𝑛·4Β·2 := Ξ¦.mul( a ↦ 𝜎3:Ξ»:Ο† )
              𝑛·4Β·3 := 𝑛·4Β·2( b ↦ Ξ¦.fact( n ↦ Ξ¦.dec( x ↦ 𝜎3:Ξ»:Ο† ) ) )
              𝕄(Ξ¦.a🌡7.b):
                𝑛·4Β·4 := Ξ¦.dec( x ↦ 𝜎3:Ξ»:Ο† )
                𝔼(L_dec):
                  𝛿1Β·6 := 𝔻(𝜎3:Ξ»)  # 𝔻(ΞΎ.x)
                  𝑛·6Β·1 := 𝜎5:Ξ»:Ο†  # 𝑛
                  𝑛·6Β·2 := 𝜎5:Ξ»:Ο†  # 𝕄(𝑛·6Β·1)
                𝑛·4Β·5 := Ξ¦.fact( n ↦ 𝜎5:Ξ»:Ο† )
              looped(𝑛·0Β·10)  # proven
            𝑛2Β·4 := 𝑛·4Β·3  # 𝕄(ΞΎ.right)
            𝔻(𝜎6:Ξ») == 01-
            𝑛3Β·4 := 𝜎6:Ξ»  # 𝑛1
            𝑛4Β·4 := 𝑛·4Β·3  # 𝑛2
            stuck(L_if)
        stuck(L_if)
      𝑛·0Β·11 := Ξ¦.if( c ↦ 𝜎2:Ξ» )
      𝑛·0Β·12 := 𝑛·0Β·11( left ↦ 01-:Ξ” )
      𝑛·0Β·13 := 𝑛·0Β·12( right ↦ 𝑛·0Β·10 )
      𝔼(L_if):
        𝛿1Β·7 := 𝔻(𝜎2:Ξ»)  # 𝔻(ΞΎ.c)
        𝑛1Β·7 := 01-:Ξ”  # 𝕄(ΞΎ.left)
        𝕄(Ξ¦.a🌡11):
          𝑛·7Β·1 := Ξ¦.mul( a ↦ 𝜎1:Ξ»:Ο† )
          𝑛·7Β·2 := 𝑛·7Β·1( b ↦ 𝑛·3Β·1 )
          𝕄(Ξ¦.a🌡11.b):
            𝑛·7Β·3 := Ξ¦.fact( n ↦ 𝜎3:Ξ»:Ο† )
          𝔼(L_mul):
            𝛿1Β·8 := 𝔻(𝜎1:Ξ»)  # 𝔻(ΞΎ.a)
            𝔻(Ξ¦.a🌡13):
              𝕄(Ξ¦.a🌡13):
                𝑛·8Β·1 := Ξ¦.fact( n ↦ 𝜎3:Ξ»:Ο† )
                𝑛·8Β·2 := Ξ¦.if( c ↦ 𝑛·4Β·1 )
                𝑛·8Β·3 := 𝑛·8Β·2( left ↦ 01-:Ξ” )
                𝑛·8Β·4 := 𝑛·8Β·3( right ↦ 𝑛·4Β·3 )
              𝔼(L_if):
                𝔻(Ξ¦.a🌡14):
                  𝕄(Ξ¦.a🌡14):
                    𝑛·9Β·1 := Ξ¦.zero( x ↦ 𝜎3:Ξ»:Ο† )
                  𝔼(L_zero):
                    𝛿1Β·10 := 𝔻(𝜎3:Ξ»)  # 𝔻(ΞΎ.x)
                    𝑛·10Β·1 := 𝜎7:Ξ»  # 𝑛
                    𝑛·10Β·2 := 𝜎7:Ξ»  # 𝕄(𝑛·10Β·1)
                𝛿1Β·9 := 𝔻(𝜎7:Ξ»)  # 𝔻(ΞΎ.c)
                𝑛1Β·9 := 01-:Ξ”  # 𝕄(ΞΎ.left)
                𝕄(Ξ¦.a🌡17):
                  𝑛·9Β·2 := Ξ¦.mul( a ↦ 𝜎3:Ξ»:Ο† )
                  𝑛·9Β·3 := 𝑛·9Β·2( b ↦ Ξ¦.fact( n ↦ 𝑛·4Β·4 ) )
                  𝕄(Ξ¦.a🌡17.b):
                    𝑛·9Β·4 := Ξ¦.dec( x ↦ 𝜎3:Ξ»:Ο† )
                    𝔼(L_dec):
                      𝛿1Β·11 := 𝔻(𝜎3:Ξ»)  # 𝔻(ΞΎ.x)
                      𝑛·11Β·1 := 𝜎8:Ξ»:Ο†  # 𝑛
                      𝑛·11Β·2 := 𝜎8:Ξ»:Ο†  # 𝕄(𝑛·11Β·1)
                    𝑛·9Β·5 := Ξ¦.fact( n ↦ 𝜎8:Ξ»:Ο† )
                  looped(𝑛·7Β·2)  # proven
                𝑛2Β·9 := 𝑛·9Β·3  # 𝕄(ΞΎ.right)
                𝔻(𝜎9:Ξ») == 01-
                𝑛3Β·9 := 𝜎9:Ξ»  # 𝑛1
                𝑛4Β·9 := 𝑛·9Β·3  # 𝑛2
                stuck(L_if)
            stuck(L_if)
        𝑛2Β·7 := 𝑛·7Β·2  # 𝕄(ΞΎ.right)
        𝔻(𝜎10:Ξ») == 01-
        𝑛3Β·7 := 𝜎10:Ξ»  # 𝑛1
        𝑛4Β·7 := 𝑛·7Β·2  # 𝑛2
        stuck(L_if)