test(tests/lean/extra): add test for "show goal" feature

This commit is contained in:
Leonardo de Moura 2015-07-27 20:59:29 -07:00
parent e61a61da8b
commit 08b23d8b4f
18 changed files with 167 additions and 1 deletions

View file

@ -52,8 +52,11 @@ add_test(NAME "issue_597"
add_test(NAME "issue_616"
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra"
COMMAND bash "./issue_616.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean")
add_test(NAME "show_goal"
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra"
COMMAND bash "./show_goal.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean")
if (NOT(${CMAKE_SYSTEM_NAME} MATCHES "Windows"))
# The following test cannot be executed on Windows because of the
# The following test cannot be executed on Windows because of the
# bash script timeout.sh
add_test(NAME "normalizer_perf"
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra"

View file

@ -0,0 +1,9 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0,
aeq0 : a = 0,
h₃ : c + 1 + a = 1,
h₄ : d = c - 1
⊢ c = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,9 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0,
aeq0 : a = 0,
h₃ : c + 1 + 0 = 1,
h₄ : d = c - 1
⊢ c = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,10 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0,
aeq0 : a = 0,
h₃ : succ c = 1,
h₄ : d = c - 1,
a_eq : c = 0
⊢ c = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,3 @@
LEAN_INFORMATION
no goals
END_LEAN_INFORMATION

View file

@ -0,0 +1,9 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0,
aeq0 : a = 0,
h₃ : succ c = 1,
h₄ : d = c - 1
⊢ c = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,10 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0,
aeq0 : a = 0,
h₃ : c + 1 + a = 1,
h₄ : d = c - 1,
ceq : c = 0
⊢ d = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,10 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0,
aeq0 : a = 0,
h₃ : c + 1 + a = 1,
h₄ : d = c - 1,
deq0 : d = 0
⊢ d = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,10 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0,
aeq0 : a = 0,
h₃ : c + 1 + a = 1,
h₄ : d = c - 1,
deq0 : d = 0
⊢ d = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,3 @@
LEAN_INFORMATION
no goals
END_LEAN_INFORMATION

View file

@ -0,0 +1,4 @@
LEAN_INFORMATION
a b c d :
⊢ a + b = 0 → b = 0 → c + 1 + a = 1 → d = c - 1 → d = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,6 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0
⊢ c + 1 + a = 1 → d = c - 1 → d = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,6 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + b = 0,
h₂ : b = 0
⊢ a = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,6 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + 0 = 0,
h₂ : b = 0
⊢ a = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,3 @@
LEAN_INFORMATION
no goals
END_LEAN_INFORMATION

View file

@ -0,0 +1,6 @@
LEAN_INFORMATION
a b c d : ,
h₁ : a + 0 = 0,
h₂ : b = 0
⊢ a = 0
END_LEAN_INFORMATION

View file

@ -0,0 +1,25 @@
import data.nat
open nat
example (a b c d : nat) : a + b = 0 → b = 0 → c + 1 + a = 1 → d = c - 1 → d = 0 :=
begin
intro h₁ h₂,
have aeq0 : a = 0, begin
rewrite h₂ at h₁,
exact h₁
end,
intro h₃ h₄,
have deq0 : d = 0, begin
have ceq : c = 0, begin
rewrite aeq0 at h₃,
rewrite add_zero at h₃,
rewrite add_succ at h₃,
rewrite add_zero at h₃,
injection h₃, assumption
end,
rewrite ceq at h₄,
repeat (esimp [sub, pred] at h₄),
assumption
end,
exact deq0
end

34
tests/lean/extra/show_goal.sh Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
set -e
if [ $# -ne 1 ]; then
echo "Usage: show_goal.sh [lean-executable-path]"
exit 1
fi
LEAN=$1
export LEAN_PATH=../../../library:.
lines=('6' '6' '8' '8' '9' '9' '14' '15' '18' '18' '18' '20' '23' '24' '24');
cols=('0' '14' '4' '5' '4' '12' '6' '6' '20' '21' '6' '4' '6' '2' '3');
size=${#lines[@]}
i=0
while [ $i -lt $size ]; do
line=${lines[$i]}
col=${cols[$i]}
let i=i+1
produced=show_goal.$line.$col.produced.out
expected=show_goal.$line.$col.expected.out
$LEAN --line=$line --col=$col --goal show_goal.lean &> $produced
if test -f $expected; then
if diff --ignore-all-space -I "executing external script" "$produced" "$expected"; then
echo "-- checked"
else
echo "ERROR: file $produced does not match $expected"
exit 1
fi
else
echo "ERROR: file $expected does not exist"
exit 1
fi
done
echo "done"