Dear Hans,

I tested your code.

   local tf = { true, false }

   function document.truthTable(a)
       document.MakeHead(a)

       end
       document.MakeFooter()
   end

This part produces the right logical value.
But, the next part doesn’t produce the correct value. 
While the value of each variable is printed correctly,
the values of outputs are  all 0.

   local tf = { "1", "0" }

   function document.truthTable(a)
       document.MakeHead(a)
       for i,s in ipairs(tf) do
           for j,t in ipairs(tf) do
               for k,u in ipairs(tf) do
                   context.NC()
                   context(s)
                   context.NC()
                   context(t)
                   context.NC()
...
              end
           end
       end
       document.MakeFooter()
   end

I think that the logical function “document.logicF()"is not working for the array tf={“1”,”0”}.
In python, 1 and 0 are treated as true and false. But, I read that only “false” and “nil” are treated as false in Lua, that is,  “0” is also treated as true! 
I checked it using the following simple code:

\starttext
\startluacode
if 0 then context("True")
else context("False")
end
\stopluacode
\stoptext

The output
The output is “True”.

Best regards,

Dalyoung