lean2/tests/lua/goal1.lua
Leonardo de Moura 3e1fd06903 refactor(kernel/expr): remove 'null' expression, and operator bool for expression
After this commit, a value of type 'expr' cannot be a reference to nullptr.
This commit also fixes several bugs due to the use of 'null' expressions.

TODO: do the same for kernel objects, sexprs, etc.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-07 23:21:10 -08:00

30 lines
805 B
Lua

local hs = hypotheses()
assert(is_hypotheses(hs))
assert(hs:empty())
assert(hs:is_nil())
local hs = hypotheses("H1", Const("q"), hs)
local hs = hypotheses("H2", Const("p"), hs)
local n, p = hs:head()
assert(n == name("H2"))
assert(p == Const("p"))
assert(not hs:empty())
assert(hs:tail():tail():empty())
for n, p in hs:pairs() do
print(n, p)
end
assert(not pcall(function() hypotheses("H1", Const("q"), "H2", Const("p"), hs) end))
assert(#hs == 2)
assert(hs:size() == 2)
local g = goal(hs, Const("p1"))
assert(is_goal(g))
print(g)
assert(#(g:hypotheses()) == 2)
assert(g:conclusion() == Const("p1"))
assert(g:unique_name("H") == name("H"))
assert(g:unique_name("H1") == name("H1", 1))
print(g:pp())
local opts = options()
opts = opts:update(name("pp", "unicode"), false)
print(opts)
print(g:pp(opts))