Zulip Chat Archive
Stream: general
Topic: Need Help with Demorgan's Law and Law of Excluded Middle
Kevin Ikeland (Nov 08 2023 at 03:49):
example (A B : Prop) : ¬(A ∧ B) → ¬A ∨ ¬B :=
λ nab =>
let proof_of_aornota := em A
let proof_of_bornotb := em B
match proof_of_aornota, proof_of_bornotb with
| Or.inl pa, Or.inl pb => _
| Or.inl pa, Or.inr nb => _
| Or.inr na, Or.inl pb => _
| Or.inr na, Or.inr nb => _
I am stuck on this problem.
Mario Carneiro (Nov 08 2023 at 03:49):
Mario Carneiro (Nov 08 2023 at 03:50):
what is the trouble?
Kevin Ikeland (Nov 08 2023 at 03:50):
I do not know how to complete the proof.
Mario Carneiro (Nov 08 2023 at 03:51):
in three of the cases, you have either not-A or not-B, and can apply Or.inl
or Or.inr
to the hypothesis to fill in the blank
Kevin Ikeland (Nov 08 2023 at 03:55):
example (A B : Prop) : ¬(A ∧ B) → ¬A ∨ ¬B :=
λ nab =>
let proof_of_aornota := em A
let proof_of_bornotb := em B
match proof_of_aornota, proof_of_bornotb with
| Or.inl pa, Or.inl pb => _
| Or.inl pa, Or.inr nb => Or.inr nb
| Or.inr na, Or.inl pb => Or.inl na
| Or.inr na, Or.inr nb => Or.inl na Like this? But what should i do for the first case?
Mario Carneiro (Nov 08 2023 at 03:59):
#backticks = use triple backticks around your code to format it as code
like this
Mario Carneiro (Nov 08 2023 at 04:00):
for the first case, you have A and B, and not (A and B), so you get a contradiction
Mario Carneiro (Nov 08 2023 at 04:02):
And.intro
makes a proof ofA /\ B
fromA
andB
False.elim
makes a proof of any proposition given a proof ofFalse
- a negation like
¬(A ∧ B)
is really just syntax for(A ∧ B) -> False
Kevin Ikeland (Nov 08 2023 at 04:11):
Is it possible to do it without using And.intro? This is the complete code
axiom em (P : Prop): P ∨ ¬ P
example (A B : Prop) : ¬(A ∧ B) → ¬A ∨ ¬B :=
λ nab =>
let proof_of_aornota := em A
let proof_of_bornotb := em B
match proof_of_aornota, proof_of_bornotb with
| Or.inl pa, Or.inl pb => _
| Or.inl pa, Or.inr nb => Or.inr nb
| Or.inr na, Or.inl pb => Or.inl na
| Or.inr na, Or.inr nb => Or.inl na
Eric Rodriguez (Nov 08 2023 at 10:18):
it's the right tool for the job, I'm not sure why you don't want to use it
Riccardo Brasca (Nov 08 2023 at 10:32):
Also, do you really want to avoid tactic mode ?
axiom em (P : Prop): P ∨ ¬ P
example (A B : Prop) : ¬(A ∧ B) → ¬A ∨ ¬B := by
intro h
rcases em A, em B with ⟨(h1 | h2), (h3 | h4)⟩
· exfalso
apply h
constructor <;> assumption
· right; assumption
· left; assumption
· left; assumption
is pretty readable
Riccardo Brasca (Nov 08 2023 at 10:32):
You can avoid the various ;
and <;>
if you want, it just becomes longer.
Riccardo Brasca (Nov 08 2023 at 10:33):
Of course in tactic mode one can cheat and just use tauto
, but I understand it's not very good for learning.
Kevin Ikeland (Nov 08 2023 at 18:11):
Can someone show me what a finished code using And.intro and False.elim looks like?
Eric Wieser (Nov 08 2023 at 18:12):
Have you tried using them one at a time?
Eric Wieser (Nov 08 2023 at 18:13):
Do you know know how to iteratively replace _
s in a term mode proof?
Kevin Ikeland (Nov 08 2023 at 18:15):
No, I do not. I was told it was possible to prove this using a few nested binary case analyses.
Kevin Ikeland (Nov 08 2023 at 18:15):
Sorry, I am kind of new to lean.
Eric Wieser (Nov 08 2023 at 19:44):
The intent of my question was really "do you know how to have Lean help you with the proof as you write it". Doing this in term mode is less taught than tactic mode; so if you haven't already been taught how to do it, you will have an easier time using tactics
Eric Wieser (Nov 08 2023 at 19:46):
Eric Wieser said:
Do you know know how to iteratively replace
_
s in a term mode proof?
The answer to this is:
- put your cursor at the
_
with a red underline, and see what your goal is in the info view - Pick a declaration or local hypothesis to apply, in this case
False.elim
, and write it - Add suitably many underscores (here, 1), until the red underline is no longer under
False.elim
- Repeat until you have no
_
s left
Eric Wieser (Nov 08 2023 at 19:47):
Tactic mode essentially plays this game in a more ergonomic way, at the expense of slighly more verbosity
Last updated: Dec 20 2023 at 11:08 UTC