Pyramid Scheme Negation

Pyramid Scheme,
31655 bytes, non-competing (obviously...)
16989 12901 8465 bytes, somewhat-competing

So, I thought this would be a funny thing to try.

Edits:

  • -14666 bytes by finally getting around to adding some compiler optimisation to psll
  • -4088 bytes by using different optimisation technique
  • -4436 bytes by implementing automatic variable name shortening into psll (I really wanted the Explanation psll code to compile into the answer without any modifications)
      ^    ^  ^          ^             ^  ^        ^          ^        ^      ^  ^          ^          ^                ^       ^                 ^          ^
     ^-   / \ -^        / \           ^- / \       -^        / \      ^-     / \ -^        / \        / \              ^-      / \               / \        / \
    ^-   /set\ -^      /set\         ^- /set\       -^      /set\    ^-     /set\ -^      /set\      /set\            / \     /set\             /   \      /out\
   ^-   ^-----^ -^    ^-----^       ^- ^-----^       -^    ^-----^   -^    ^-----^ -^    ^-----^    ^-----^          ^---^   ^-----^           /     \    ^-----^
  ^-   /f\   / \ -^  /t\   /f\     ^- /r\   /+\       -^  /r\   /+\   -^  /r\   /+\ -^  /r\   /+\  /r\   /+\        ^-  / \ /l\   /0\         / loop  \  /s\   /d\
  -^   ---  /chr\ -^ ---   ---    ^-  ---  ^---^       -^ ---  ^---^   -^ ---  ^---^ -^ ---  ^---^ ---  ^---^      ^-  /   \---   ---        ^---------^ ---   ---
   -^      ^----- / \            / \      /r\ /e\       -^    /r\ /f\   -^    /r\ /c\ -^    /r\ /d\    /r\ /e\    ^-  /     \               /!\       / \
    -^    / \    ^---^          ^---^     --- ---       / \   --- ---    -^   --- --- / \   --- ---    --- ---   ^-  /       \             ^---      /   \
     -^  /47 \  / \  -^        / \  -^                 /   \              -^         /   \                      ^-  /         \           /!\       /     \
      -^ ----- /set\  -^      /set\  -^               /     \              -^       /     \                    ^-  /           \         ^---      /       \
       -^     ^-----^  -^    ^-----^  -^             /       \              -^     /       \                  ^-  /      ?      \       / \       ^---------^
        -^   /a\   / \  -^  /t\   /+\  -^           /         \              -^   /         \                ^-  ^---------------^     /<=>\     / \       / \
         -^  ---  /chr\  -^ ---  ^---^  -^         ^-----------^             ^-  ^-----------^              ^-  /!\             / \   ^-----^   /   \     /set\
         / \     ^-----  / \    /t\ /a\  -^       / \         / \           ^-  / \         / \            ^-  ^---            /   \ /l\   /n\ /     \   ^-----^
        /   \   / \     /   \   --- ---   -^     /set\       /set\         ^-  /set\       /set\          ^-  /?\             /     \---   ---/       \ /l\   /+\
       /     \ /33 \   /     \             -^   ^-----^     ^-----^       ^-  ^-----^     ^-----^        ^-  ^---^           /       \       /         \---  ^---^
      /       \-----  /       \             -^ /r\   /+\   /r\   /+\     ^-  /r\   /+\   /r\   /+\      ^-  /m\ / \         ^---------^     /           \   /l\ /1\
     /         \     ^---------^            / \---  ^---^  ---  ^---^   ^-   ---  ^---^  ---  ^---^    ^-   ---/   \       / \       / \   /             \  --- ---
    ^-----------^   / \       / \          /   \   /r\ /s\     /r\ /s\ ^-        /r\ /d\     /r\ /d\  ^-      /     \     /out\     /out\ /               \
   / \         ^-  /set\     /set\        /     \  --- ---     --- ---/ \        --- ---     --- --- ^-      /       \   ^-----^   ^-----/                 \
  /set\       ^-  ^-----^   ^-----^      ^-------^                   /   \                          ^-      ^---------^ /s\   /c\ /e\   /                   \
 ^-----^     ^-  /b\   / \ /d\   / \    ^-      ^-                  /     \                        ^-      / \       / \---   --- ---  /                     \
/n\   /#\   ^-   ---  /chr\---  /chr\  ^-      ^-                  /       \                      / \     /out\     /out\             /                       \
---  ^---  ^-        ^-----    ^----- ^-      / \                 /         \                    /   \   ^-----^   ^-----            /                         \
    /l\   / \       / \       / \    ^-      /   \               ^-----------^                  /     \ /s\   /s\ /s\               /                           \
   /ine\ /   \     /92 \     /45 \  ^-      /     \              -^         / \                /       \---   --- ---              /                             \
   -----/     \    -----     ----- ^-      /       \              -^       /set\              /         \                         /                               \
       /       \                  ^-      /         \              -^     ^-----^            ^-----------^                       /                                 \
      /         \                ^-      ^-----------^              -^   /r\   /+\          / \         / \                     /                                   \
     ^-----------^              ^-       -^         / \              -^  ---  ^---^        /set\       /   \                   ^-------------------------------------^
    / \         ^-             / \        -^       /set\              -^     /r\ /s\      ^-----^     /     \                 / \                                   / \
   /set\       ^-             /   \        -^     ^-----^             / \    --- ---     /m\   /n\   / loop  \               /   \                                 /   \
  ^-----^     ^-             /     \        -^   /r\   /c\           ^---^               ---   ---  ^---------^             /     \                               /     \
 /s\   / \   ^-             /       \        -^  ---   ---          / \  -^                        / \       / \           /       \                             /   ?   \
 ---  /chr\ ^-             /         \        -^                   /set\  -^                      /   \     /set\         /         \                           ^---------^
     ^-----/ \            ^-----------^        -^                 ^-----^  -^                    / <=> \   ^-----^       ^-----------^                         /!\       ^-
    / \   /   \           -^         / \        -^               /r\   /+\  -^                  ^-------^ /m\   /-\     / \         / \                       ^---      / \
   /32 \ /     \           -^       /set\        -^              ---  ^---^  -^                / \     / \---  ^---^   /set\       /   \                     / \       /out\
   -----/       \           -^     ^-----^       / \                 /r\ /a\  -^              /<=>\   /-1 \   /m\ /2\ ^-----^     /     \                   /   \     ^-----
       ^---------^           -^   /t\   /+\     /   \                --- ---  / \            ^-----^  -----   --- ---/k\   /l\   / loop  \                 /  ?  \   /t\
      / \       / \           -^  ---  ^---^   /     \                       /   \          /m\   /2\                ---   ---  ^---------^               ^-------^  ---
     /set\     /set\           -^     /t\ /d\ /       \                     /     \         ---   ---                          / \       / \             /!\     ^-
    ^-----^   ^-----^          / \    --- ---/         \                   /       \                                          /   \     /set\           ^---    / \
   /e\   / \ /c\   / \        /   \         ^-----------^                 /         \                                        / <=> \   ^-----^         / \     /out\
   ---  /chr\---  /chr\      /     \       / \         / \               ^-----------^                                      ^-------^ /k\   /-\       /<=>\   ^-----
       ^-----    ^-----     /       \     /set\       /set\             / \         / \                                    / \     / \---  ^---^     ^-----^ /r\
      / \       / \        /         \   ^-----^     ^-----^           /set\       /set\                                  /<=>\   /-1 \   /k\ /2\   /+\   /1\---
     /10 \     /94 \      ^-----------^ /t\   /+\   /t\   /+\         ^-----^     ^-----^                                ^-----^  -----   --- ---  ^---^  ---
     -----     -----     / \         / \---  ^---^  ---  ^---^       /r\   /+\   /r\   /+\                              /k\   /2\                 /k\ /m\
                        /set\       /set\   /t\ /d\     /t\ /d\      ---  ^---^  ---  ^---^                             ---   ---                 --- ---
                       ^-----^     ^-----^  --- ---     --- ---          /r\ /b\     /r\ /e\
                      /t\   /+\   /t\   /+\                              --- ---     --- ---
                      ---  ^---^  ---  ^---^
                          /t\ /b\     /t\ /e\
                          --- ---     --- ---

Try it online!

Explanation

(set n (# line)) // Set n to line input

(set space (chr 32))
(set newline (chr 10))
(set caret (chr 94))
(set fslash (chr 47))
(set bang (chr 33))
(set bslash (chr 92))
(set dash (chr 45))

// Left triangle
(set lt fslash)
(set lt (+ lt bang)) (set lt (+ lt bslash)) (set lt (+ lt newline))
(set lt (+ lt dash)) (set lt (+ lt dash)) (set lt (+ lt dash))

// Right triangle
(set rt caret) (set rt (+ rt newline))
(set rt (+ rt space)) (set rt (+ rt space))
(set rt (+ rt fslash)) (set rt (+ rt bang)) (set rt (+ rt bslash))
(set rt (+ rt newline))
(set rt (+ rt space)) (set rt (+ rt caret))
(set rt (+ rt dash)) (set rt (+ rt dash)) (set rt (+ rt dash))
(set rt (+ rt newline))

// n = mod(m,2)
((set m n) (loop (<=> (<=> m 2) -1) (set m (- m 2))))

// Print the top and the first triangle
(? (! (? m ( // If m
    (out space space) (out space)
))) ( // Else
    (out space caret) (out newline)
))

(set l 0)
(loop (! (! (<=> l n))) ( // While l < n
    ((set k l) (loop (<=> (<=> k 2) -1) (set k (- k 2)))) // k = mod(l,2)
    (? (! (? (! (<=> (+ k m) 1)) ( // If xor(k,m)
        (out rt)
    ))) ( // Else
        (out lt)
    ))
(set l (+ l 1))
))
(out space dash) // Final triangle

Charcoal, 17 bytes

FN«↙^→/!\¶³‖T»↓^-

Try it online! Link is to verbose version of code. Explanation:

FN«

Loop for the appropriate number of negations.

↙^→/!\¶³

Print a negation function. (The ³ expands to ---.)

‖T

Reflect the canvas.

»↓^-

At the end of the loop, print the empty triangle.


Python 2, 94 bytes

i=input();print i%2*2*" "+" ^"
while i:print['/!\\\n---^','  /!\\\n ^---'][i%2];i-=1
print" -"

Try it online!

Trying to golf this... 3 print statements seem awfully redundant.