Zulip Chat Archive

Stream: new members

Topic: quantification in iffs


Yakov Pechersky (Feb 05 2021 at 01:02):

A question on how to write implications. I have the following lemma:

import data.buffer.parser.basic

namespace parser

open parse_result
variables {β α : Type} {cb : char_buffer} {n' n : } {a' a : α} {b : β} {c : char} (hn : n < buffer.size cb)
include hn

lemma any_char_eq_done : any_char cb n = done n' c  n' = n + 1  cb.read n, hn = c :=
by simp [any_char, hn, eq_comm]

end parser

Yakov Pechersky (Feb 05 2021 at 01:03):

How can I rephrase it to put the hn : n < buffer.size cb on the right side of the \iff? I only need it to construct the cb.read ⟨n, hn⟩. Is that even possible?

Yakov Pechersky (Feb 05 2021 at 01:03):

These proofs would suggest that, yes:

lemma any_char_eq_done_imp_lt (h : any_char cb n = done n' c) : n < cb.size :=
begin
  contrapose! h,
  simp [any_char, h]
end

lemma any_char_eq_done_imp (h : any_char cb n = done n' c) :
  n + 1 = n'  cb.read n, any_char_eq_done_imp_lt h = c :=
begin
  simp [any_char] at h,
  split_ifs at h with hn,
  { assumption },
  { contradiction }
end

lemma imp_any_char_eq_done (hn : n + 1 = n') (hle : n < cb.size) (h : cb.read n, hle = c) :
  any_char cb n = done n' c :=
by simp [any_char, hn, hle, h]

Yakov Pechersky (Feb 05 2021 at 01:03):

Since the LHS implies the constraint for the RHS

Floris van Doorn (Feb 05 2021 at 01:08):

You could write

any_char cb n = done n' c   (hn : n < buffer.size cb), n' = n + 1  cb.read n, hn = c

Last updated: Dec 20 2023 at 11:08 UTC