lean2/tests/lua/template1.lua
Leonardo de Moura 08718e33dc refactor(builtin): only load the kernel and natural numbers by default
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-30 13:35:37 -08:00

18 lines
954 B
Lua

import("util.lua")
import("template.lua")
local env = environment()
env:import("int")
parse_lean_cmds([[
Variables a b c : Int
Variables f : Int -> Int
]], env)
local a, b, c = Consts("a, b, c")
print(parse_template("%1 + f %2 + %1 + %1", {a, b}, env))
assert(tostring(parse_template("%1 + f %2 + %1 + %1", {a, b}, env)) == "Int::add (Int::add (Int::add a (f b)) a) a")
assert(not pcall(function() print(parse_template("%1 + f %2 + %1 + %1", {a}, env)) end))
print(parse_template("%1 + f %2 + %3 + f (f %1)", {a, b, c}, env))
print(parse_template("%1 + f %2 + 10 + f (f %1)", {a, b, c}, env))
assert(tostring(parse_template("%1 + f %2 + 10 + f (f %1)", {a, b, c}, env)) == "Int::add (Int::add (Int::add a (f b)) (nat_to_int 10)) (f (f a))")
set_formatter(lean_formatter(env))
print(parse_template("%1 + f %2 + %3 + f (f %1)", {a, b, c}, env))
assert(tostring(parse_template("%1 + f %2 + %3 + f (f %1)", {a, b, c}, env)) == "a + f b + c + f (f a)")