Zulip Chat Archive

Stream: new members

Topic: evaluating expressions within proofs


Arthur Paulino (Oct 25 2021 at 03:02):

Is there a way to evaluate (and print) the value of a variable within the scope of a proof?

Jason Rute (Oct 25 2021 at 23:22):

Can you give a #mwe?

Jason Rute (Oct 25 2021 at 23:23):

And do you mean tactic proof or term proof?

Scott Morrison (Oct 25 2021 at 23:26):

Perhaps you mean doing the equivalent of #eval, but mid-way through a proof?

Jason Rute (Oct 25 2021 at 23:28):

Here are two examples. You may need to turn widgets off to see this. IIRC, there is a bug in widgets which doesn't show the := 1 in the examples below.

example (m n : ) : m + n = n + m :=
let a := 1 in _  -- use _ to find the value of `a` in the local context of a term proof:
-- m n : ℕ,
-- a : ℕ := 1
-- ⊢ m + n = n + m

example (m n : ) : let a := 1 in m + n = n + m :=
begin
  intro a,
  -- The goal should show you the value of `a` in the local context of a tactic proof.
  -- m n : ℕ,
  -- a : ℕ := 1
  -- ⊢ m + n = n + m
end

Jason Rute (Oct 25 2021 at 23:38):

This doesn't show you the values of assigned metavariables though. (Honestly, I'm not exactly sure what you're asking for.)


Last updated: Dec 20 2023 at 11:08 UTC