Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
-- 2D ascii notation for the Begriffsschrift
-- (find-books "__frege/__frege.el")
-- (find-books "__frege/__frege.el" "heijenoort")

-- I will include this into dednat4 at some point.
-- (find-TH "dednat4" "quick-start")

-- (find-fline "/usr/share/doc/texlive-doc/latex/begriff/README")
-- (code-xpdf      "begriffex" "/usr/share/doc/texlive-doc/latex/begriff/examples.pdf")
-- (code-pdftotext "begriffex" "/usr/share/doc/texlive-doc/latex/begriff/examples.pdf")
-- (find-begriffexpage      1  "Contents")
-- (find-begriffexpage (+ 1 1) "Index")
-- (find-begriffextext "")
-- (find-fline "/usr/share/doc/texlive-doc/latex/begriff/examples.tex")

-- (find-angg ".emacs" "eedn4a")
-- (find-dn4ex "edrxmain41a.tex")
-- (find-dn4exfile "edrxmain41a.tex" "begriff")

nl1 = "\n  "
nl  = nl1     -- nl="" is useful for some tests
BGassert = function (body) return "\\BGassert "..body end
BGnot    = function (body) return "\\BGnot "..body end
BGquant  = function (v, body) return "\\BGquant{"..v.."}"..body end
BGcond   = function (antec, conseq)
    return  "\\BGconditional{"..nl..antec..nl.."}{"..conseq..nl.."}"
  end
BGterm   = function (body) return "\\BGterm{"..body.."}" end
BGstem   = function (body) return "\\BGstem{"..body.."}" end
BGbracket = function (body) return "\\BGbracket{"..body.."}" end
BGlinewidth = function (len) return "\\setlength{\\BGlinewidth}{"..len.."}" end
BGbeforelen = function (len) return "\\setlength{\\BGbeforelen}{"..len.."}" end
BGafterlen  = function (len) return "\\setlength{\\BGafterlen}{" ..len.."}" end

-- For tests.
dprint = function (body)
    print("%\015\n% (eedn4a-bounded)\n"..
          BGlinewidth("8em")..nl..
          "MMMMMMMM\n\n"..
          body..
          "\n\n"..
          BGbeforelen("0.5em")..nl..
          body..
          "\n\n"..
          BGafterlen("0.5em")..nl..
          body..
          "\n%\015")
  end

-- A metatable hack to make (for example)
-- str[3] return the third char of str (when str is a string).
getmetatable("foo").__index = function (self, k)
    if type(k) == "number" then return string.sub(self, k, k) end
    return string[k]
  end

-- The basic 2D functions.
BGL = function (x, y)
    if BGlines[y][x] == "|" then return BGassert(BGH(x+1, y))
    else return BGH(x, y)
    end
  end
BGH = function (x, y)
    if BGlines[y][x] == "-" then return BGH(x+1, y)
    elseif BGlines[y][x] == "~" then return BGnot(BGH(x+1, y))
    elseif BGlines[y][x] == "." then return BGcond(BGV(x, y+1), BGH(x+1, y))
    elseif BGlines[y][x] == "(" then
      local _, newx = string.match(BGlines[y], "^(%b())()", x)
      if not _ then return "(?)" end
      local pstuff = string.sub(BGlines[y], x+1, newx-2)
      return BGquant(pstuff, BGH(newx, y))
    else return BGterm(BGlines[y]:sub(x))
    end
  end
BGV = function (x, y)
    if BGlines[y][x] == "|" then return BGV(x, y+1)
    elseif BGlines[y][x] == "\\" then return BGH(x+1, y)
    else return "?"
    end
  end


--[==[

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
ee_dofile "~/LUA/begriff.lua"

-- A 2D example:
--
bigstr = [[
|-.-~--.- a
  |    \- b
  \-(o).- c
       \-(\mathit{foo})- food
]]

BGlines = splitlines(untabify(bigstr))
print(BGlines)
= BGlines[1][1]

dprint(BGL(1, 1))



-- Some older tests:
dprint(BGcond("a", "b"))
dprint(BGcond("a", BGcond("b", "c")))
dprint(BGcond("a", BGterm("b")))
dprint(BGcond(BGterm("a"), BGterm("b")))
dprint(BGassert(BGcond(BGcond(BGterm("a"), BGterm("b")), "c")))
dprint(BGassert(BGcond(BGcond(BGterm("a"), BGterm("b")), BGnot("c"))))
dprint(BGassert(BGcond(BGcond(BGterm("a"), BGterm("b")), BGnot(BGquant("x", "c")))))
dprint(BGassert(BGcond(BGcond(BGterm("a"), BGterm("b")), BGnot(BGquant("\\mathit{x}", "foock")))))

PP(getmetatable("foo"))
print(getmetatable("foo").__index)
-- getmetatable("foo").__index = string
= str[4]



-- From the README of the begriff package:
-- (find-fline "/usr/share/doc/texlive-doc/latex/begriff/README")

-- \BGassert            - generates an assertion sign
-- \BGcontent           - generates an assertion sign
-- \BGnot               - generates a negation sign
-- \BGquant{v}          - generates a universal quantifier with variable v
-- \BGconditional{a}{c} - generates a conditional with antecendent
--                        a and consequent c. Note that in the Begriffsschrift, 
--                        the antecendent is placed below the consequent.
-- 
-- (the following three commands were introduced in version 1.5)
-- 
-- \BGterm{x}           - creates a right-justified terminal node x 
-- \BGstem{x}           - inserts arbitrary LaTeX maths x into a non-terminal node
-- \BGbracket{x}        - places the expression x inside brackets
-- 
-- You also have the normal resources of LaTeX math mode, and (if you
-- have the amssymb package, AMS symbols) at your disposal; so, you can
-- use \mathfrak{v} to get a fraktur character, \acute{v} to get a
-- character with a slanting hat, and \alpha (etc.) to get greek letters.
-- 
-- You can also tweak the appearance of the resulting material by
-- modifying the values of the following lengths:
-- 
-- \BGthickness - the thickness of lines (by default 0.4pt, 
--                bigger numbers = bolder)
-- \BGbeforelen - the length of line inserted before a begriffsschrift symbol
-- \BGafterlen  - the length of line inserted after a begriffsschrift symbol
-- \BGspace     - the length of space inserted between begriffsschrift and 
--                normal maths
-- 
-- (and, since version 1.5)
-- 
-- \BGlinewidth - the total width of the diagram

--]==]






-- Local Variables:
-- coding:               raw-text-unix
-- ee-anchor-format:     "«%s»"
-- End: