lean2/tests/lean/interactive
Leonardo de Moura 015bff8283 fix(library/tactic/goal): to_goal way of handling context_entries of the form (name, domain, body) where domain is null, and body is a proof term
This commit fixes a problem exposed by t13.lean.
It has a theorem of the form:

Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
     fun assumption : A /\ B,
          let lemma1 := (show A by auto),
              lemma2 := (show B by auto)
          in (show B /\ A by auto)

When to_goal creates a goal for the metavariable associated with (show B /\ A by auto) it receives a context and proposition of the form

 [ A : Bool, B : Bool, assumption : A /\ B, lemma1 := Conjunct1 assumption, lemma2 := Conjunct2 assumption ] |- B /\ A

The context_entries "lemma1 := Conjunct1 assumption" and "lemma2 := Conjunct2 assumption" do not have a domain (aka type).
Before this commit, to_goal would simply replace and references to "lemma1" and "lemma2" in "B /\ A" with their definitions.
Note that, "B /\ A" does not contain references to "lemma1" and "lemma2". Then, the following goal is created
     A : Bool, B : Bool, assumption : A /\ B |- B /\ A
That is, the lemmas are not available when solving B /\ A.
Thus, the tactic auto produced the following (weird) proof for T1, where the lemmas are computed but not used.

    Theorem T1 (A B : Bool) (assumption : A ∧ B) : B ∧ A :=
            let lemma1 := Conjunct1 assumption,
                lemma2 := Conjunct2 assumption
            in Conj (Conjunct2 assumption) (Conjunct1 assumption)

This commit fixed that. It computes the types of "Conjunct1 assumption" and "Conjunct2 assumption", and creates the goal
     A : Bool, B : Bool, assumption : A /\ B, lemma1 : A, lemma2 : B |- B /\ A

After this commit, the proof for theorem T1 is

Theorem T1 (A B : Bool) (assumption : A ∧ B) : B ∧ A :=
    let lemma1 := Conjunct1 assumption,
        lemma2 := Conjunct2 assumption
    in Conj lemma2 lemma1

as expected.

Finally, this example suggests that the encoding

Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
     fun assumption : A /\ B,
          let lemma1 : A := (by auto),
              lemma2 : B := (by auto)
          in (show B /\ A by auto)

is more efficient than

Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
     fun assumption : A /\ B,
          let lemma1 := (show A by auto),
              lemma2 := (show B by auto)
          in (show B /\ A by auto)

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-06 16:14:25 -08:00
..
config.lean feat(tests/lean/interactive): add interactive mode test script 2013-12-05 16:56:20 -08:00
config.lean.expected.out feat(tests/lean/interactive): add interactive mode test script 2013-12-05 16:56:20 -08:00
t1.lean feat(library/tactic): use _tac suffix instead of _tactic like Isabelle 2013-12-05 20:06:32 -08:00
t1.lean.expected.out feat(frontends/lean): allow 'tactic hints' to be associated with 'holes' 2013-12-06 14:49:39 -08:00
t2.lean feat(library/tactic): use _tac suffix instead of _tactic like Isabelle 2013-12-05 20:06:32 -08:00
t2.lean.expected.out feat(frontends/lean): allow 'tactic hints' to be associated with 'holes' 2013-12-06 14:49:39 -08:00
t3.lean feat(library/tactic): use _tac suffix instead of _tactic like Isabelle 2013-12-05 20:06:32 -08:00
t3.lean.expected.out test(tests/lean/interactive): add back command test 2013-12-05 17:19:53 -08:00
t4.lean fix(frontends/lean/parser): remove unnecessary '#' after error 2013-12-05 17:27:08 -08:00
t4.lean.expected.out fix(frontends/lean/parser): remove unnecessary '#' after error 2013-12-05 17:27:08 -08:00
t5.lean feat(library/tactic): use _tac suffix instead of _tactic like Isabelle 2013-12-05 20:06:32 -08:00
t5.lean.expected.out fix(frontends/lean/parser): bug in parse_tactic 2013-12-05 17:40:55 -08:00
t6.lean feat(library/tactic): use _tac suffix instead of _tactic like Isabelle 2013-12-05 20:06:32 -08:00
t6.lean.expected.out feat(frontends/lean/parser): allow the user to use a theorem/axiom name as an argument for the apply tactic command 2013-12-05 19:03:12 -08:00
t7.lean feat(frontends/lean/parser): add assumption command, and allow Lean expressions (proof terms) to be used with apply tactic command 2013-12-05 20:08:51 -08:00
t7.lean.expected.out feat(frontends/lean/parser): add assumption command, and allow Lean expressions (proof terms) to be used with apply tactic command 2013-12-05 20:08:51 -08:00
t8.lean feat(library/tactic/proof_state): add option tactic::proof_state::goal_names 2013-12-05 21:18:22 -08:00
t8.lean.expected.out feat(library/tactic/proof_state): add option tactic::proof_state::goal_names 2013-12-05 21:18:22 -08:00
t9.lean fix(frontends/lean/parser): display failed state in noninteractive mode, stop processing tactic commands when a Lean command is found 2013-12-06 05:13:29 -08:00
t9.lean.expected.out fix(frontends/lean/parser): display failed state in noninteractive mode, stop processing tactic commands when a Lean command is found 2013-12-06 05:13:29 -08:00
t10.lean fix(frontends/lean/parser): display failed state in noninteractive mode, stop processing tactic commands when a Lean command is found 2013-12-06 05:13:29 -08:00
t10.lean.expected.out feat(frontends/lean): allow 'tactic hints' to be associated with 'holes' 2013-12-06 14:49:39 -08:00
t11.lean fix(frontends/lean/notation): change the precedence of '->' 2013-12-06 13:23:24 -08:00
t11.lean.expected.out fix(frontends/lean/notation): change the precedence of '->' 2013-12-06 13:23:24 -08:00
t12.lean feat(library/tactic/boolean_tactics): avoid unnecessary Let expression in proof terms 2013-12-06 15:01:54 -08:00
t12.lean.expected.out feat(library/tactic/boolean_tactics): avoid unnecessary Let expression in proof terms 2013-12-06 15:01:54 -08:00
t13.lean fix(library/tactic/goal): to_goal way of handling context_entries of the form (name, domain, body) where domain is null, and body is a proof term 2013-12-06 16:14:25 -08:00
t13.lean.expected.out fix(library/tactic/goal): to_goal way of handling context_entries of the form (name, domain, body) where domain is null, and body is a proof term 2013-12-06 16:14:25 -08:00
test.sh feat(tests/lean/interactive): add interactive mode test script 2013-12-05 16:56:20 -08:00
test_single.sh feat(tests/lean/interactive): add interactive mode test script 2013-12-05 16:56:20 -08:00