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()
|
|
|
|
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)")
|