2013-12-27 03:49:04 +00:00
|
|
|
import("util.lua")
|
2013-12-27 03:28:02 +00:00
|
|
|
import("template.lua")
|
|
|
|
local env = environment()
|
2014-01-01 21:52:25 +00:00
|
|
|
env:import("Int")
|
2013-12-27 03:28:02 +00:00
|
|
|
parse_lean_cmds([[
|
2014-01-05 20:05:08 +00:00
|
|
|
variables a b c : Int
|
|
|
|
variables f : Int -> Int
|
2013-12-27 03:28:02 +00:00
|
|
|
]], 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)")
|