Zulip Chat Archive

Stream: new members

Topic: distributive law


bumby bumby (May 11 2021 at 17:01):

hi someone can help me please to finish a prove of distributive law with natural deduction? only I ahve problem in the final part

bumby bumby (May 11 2021 at 17:01):

example (p q r : Prop) : p ∨ (q ∧ r) ↔ (p ∨ q) ∧ (p ∨ r) :=
begin
apply iff.intro,
intro h,
apply or.elim h,
intro hp,
apply and.intro,
apply or.inl,
exact hp,
apply or.inl,
exact hp,
intro hqr,
apply and.intro,
apply or.inr,
exact and.left hqr,
apply or.inr,
exact and.right hqr,

intro h,
apply or.elim(and.elim_left h),
intro hp,
apply or.inl,
exact hp,

intro hq,
apply or.inl,
end

Mario Carneiro (May 11 2021 at 17:01):

#backticks

bumby bumby (May 11 2021 at 17:04):

imagen.png

Mario Carneiro (May 11 2021 at 17:05):

Post code as text, not pictures

Mario Carneiro (May 11 2021 at 17:05):

Also let me introduce you to block structuring. It is a good way to make the structure of a proof clearer

example (p q r : Prop) : p  (q  r)  (p  q)  (p  r) :=
begin
  apply iff.intro,
  { intro h,
    apply or.elim h,
    { intro hp,
      apply and.intro,
      { apply or.inl,
        exact hp },
      { apply or.inl,
        exact hp } },
    { intro hqr,
      apply and.intro,
      { apply or.inr,
        exact and.left hqr },
      { apply or.inr,
        exact and.right hqr } } },
  { intro h,
    apply or.elim (and.elim_left h),
    { intro hp,
      apply or.inl,
      exact hp },
    { intro hq,
      apply or.inl,
      sorry } }
end

Eric Wieser (May 11 2021 at 17:06):

Perhaps #backticks should gain a sentence on not posting code as an image unless you're actually reporting a vscode bug

Mario Carneiro (May 11 2021 at 17:07):

Regarding the actual question: this proof requires classical logic for the reverse implication, so you will need to use proof by contradiction, and by_contra hp is a good step at the point of the sorry

bumby bumby (May 11 2021 at 17:08):


bumby bumby (May 11 2021 at 17:09):

sorry i have problems with backticks

Mario Carneiro (May 11 2021 at 17:09):

```
your code here
```

Mario Carneiro (May 11 2021 at 17:10):

You have to use shift-enter to put newlines if "press enter to send" is enabled

bumby bumby (May 11 2021 at 17:10):

begin
  apply iff.intro,
  intro h,
  apply or.elim h,
  intro hp,
  apply and.intro,
  apply or.inl,
  exact hp,
  apply or.inl,
  exact hp,
  intro hqr,
  apply and.intro,
  apply or.inr,
  exact and.left hqr,
  apply or.inr,
  exact and.right hqr,

  intro h,
  apply or.elim(and.elim_left h),
  intro hp,
  apply or.inl,
  exact hp,

  intro hq,
  apply or.inl,
end ```

Eric Wieser (May 11 2021 at 17:13):

Note that if you have already posted code without backticks, you can edit your message to add them.

There is no need to post a new message, you can fix the formatting in your top message

Mario Carneiro (May 11 2021 at 17:13):

you need a newline between the ``` and the example... line

bumby bumby (May 11 2021 at 17:13):

example (p q r : Prop) : p  (q  r)  (p  q)  (p  r) :=
begin
  apply iff.intro,
  intro h,
  apply or.elim h,
  intro hp,
  apply and.intro,
  apply or.inl,
  exact hp,
  apply or.inl,
  exact hp,
  intro hqr,
  apply and.intro,
  apply or.inr,
  exact and.left hqr,
  apply or.inr,
  exact and.right hqr,

  intro h,
  apply or.elim(and.elim_left h),
  intro hp,
  apply or.inl,
  exact hp,

  intro hq,
  apply or.inl,
end

bumby bumby (May 11 2021 at 17:19):

is that, the second part i would have to proof by contradiction?

bumby bumby (May 11 2021 at 17:25):

ok and how could i prove it via contradiction?

Mario Carneiro (May 11 2021 at 17:33):

Actually I lied, you need to do cases on p ∨ ¬ p. If p is true then it is the left part of the goal, otherwise you can case on p ∨ q and p ∨ r to obtain q and r, and then prove the right part

example (p q r : Prop) : p  (q  r)  (p  q)  (p  r) :=
begin
  apply iff.intro,
  { intro h,
    apply or.elim h,
    { intro hp,
      apply and.intro,
      { apply or.inl,
        exact hp },
      { apply or.inl,
        exact hp } },
    { intro hqr,
      apply and.intro,
      { apply or.inr,
        exact and.left hqr },
      { apply or.inr,
        exact and.right hqr } } },
  { intro h,
    by_cases hp : p,
    { exact or.inl hp },
    { apply or.elim (and.left h),
      { intro hp',
        apply false.elim,
        exact hp hp' },
      intro hq,
      apply or.elim (and.right h),
      { intro hp',
        apply false.elim,
        exact hp hp' },
      intro hr,
      exact or.inr (and.intro hq hr) } }
end

Thomas Browning (May 11 2021 at 17:54):

@Mario Carneiro Does this use classical logic somewhere?

example (p q r : Prop) : p  (q  r)  (p  q)  (p  r) :=
begin
  apply iff.intro,
  { intro h,
    apply or.elim h,
    { intro hp,
      apply and.intro,
      { exact or.inl hp },
      { exact or.inl hp } },
    { intro hqr,
      apply and.intro,
      { apply or.inr,
        exact and.left hqr },
      { apply or.inr,
        exact and.right hqr } } },
  { intro h,
    apply or.elim h.1,
    { exact or.inl },
    { intro hq,
      apply or.elim h.2,
      { exact or.inl },
      { intro hr,
        apply or.inr,
        exact and.intro hq hr } } },
end

Johan Commelin (May 11 2021 at 17:54):

print axioms <example>

Eric Rodriguez (May 11 2021 at 17:56):

a question I've had for a while; is it only classical.choice that counts as classical logic? or do propext, funext, quot.sound also stop computation?

Mario Carneiro (May 11 2021 at 17:56):

Ah, you are right, this one is intuitionistically true

Mario Carneiro (May 11 2021 at 17:56):

Those statements are both true and not in opposition

Eric Rodriguez (May 11 2021 at 17:57):

so quot.sound is noncomputable? that's weird to me

Mario Carneiro (May 11 2021 at 17:57):

It's not noncomputable

Eric Wieser (May 11 2021 at 17:58):

Just not #reduceible, right?

Mario Carneiro (May 11 2021 at 17:58):

@Thomas Browning I should have asked my own tactic:

import tactic.itauto

example (p q r : Prop) : p  (q  r)  (p  q)  (p  r) :=
by itauto -- ok!

Mario Carneiro (May 11 2021 at 17:59):

It's not #reduceible and also blocks computations using well founded recursion in rfl/dec_trivial

Mario Carneiro (May 11 2021 at 17:59):

although with a recent change to lean that is now true of all proofs, not just those using axioms

Eric Rodriguez (May 11 2021 at 17:59):

is it because those are in some way "type-theoretically intrinsic"? or am i just not getting the idea

Mario Carneiro (May 11 2021 at 18:01):

Basically an axiom has no "computation rule", meaning that there is no way to know how to #reduce it. In simple applications of propext you can kind of figure it out but a general solution requires essentially cubical type theory

Mario Carneiro (May 11 2021 at 18:02):

In the VM, proofs are ignored so it doesn't matter whether they use axioms or not. This is why all the listed axioms are not noncomputable, because this marker determines whether lean will be generating code for it

Mario Carneiro (May 11 2021 at 18:02):

Note that classical.choice is noncomputable, but classical.em, which uses classical.choice, is computable trivially, because it has type Prop

Mario Carneiro (May 11 2021 at 18:03):

theorems are always vacuously computable because lean doesn't do anything with them, it just registers their existence

bumby bumby (May 11 2021 at 18:14):

thank you Mario

Shadman Sakib (Jun 04 2021 at 21:20):

What is the distribution command on lean vs?
For something like (a+b) * (a-b)

Adam Topaz (Jun 04 2021 at 21:23):

Shadman Sakib said:

What is the distribution command on lean vs?
For something like (a+b) * (a-b)

This question should be its own thread, probably in the #new members stream...

Eric Wieser (Jun 04 2021 at 21:39):

A zulip admin should be able to move this comment and the two above it to the correct stream Thanks!

Notification Bot (Jun 04 2021 at 21:53):

This topic was moved by Bryan Gin-ge Chen to #general > Schemes in Arend?

Kevin Buzzard (Jun 04 2021 at 22:01):

You want to use mul_add and add_mul. Have you played the natural number game?

Ruben Van de Velde (Jun 05 2021 at 18:03):

Shadman Sakib said:

What is the distribution command on lean vs?
For something like (a+b) * (a-b)

Is docs#sq_sub_sq what you're looking for?


Last updated: Dec 20 2023 at 11:08 UTC