import MyNat.Definition
namespace MyNat
open MyNat
Advanced proposition world.
Level 5: iff_trans
easter eggs.
Let's try iff_trans
again. Try proving it in other ways.
A trick.
Instead of using cases
on h : P ↔ Q
you can just access the proofs of P → Q
and Q → P
directly with h.mp
and h.mpr
.
Lemma
If P
, Q
and R
are true/false statements, then P ↔ Q
and Q ↔ R
together imply P ↔ R
.
lemmaiff_trans₂ (iff_trans₂: ∀ (P Q R : Prop), (P ↔ Q) → (Q ↔ R) → (P ↔ R)PP: PropQQ: PropR :R: PropProp) : (Prop: TypeP ↔P: PropQ) → (Q: PropQ ↔Q: PropR) → (R: PropP ↔P: PropR) :=R: PropP, Q, R: Prop(P ↔ Q) → (Q ↔ R) → (P ↔ R)P, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RP ↔ RP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ R
mpP → RP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RR → PP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ R
p: P
mpRP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RR → PP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ R
p: P
mpQP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RR → PP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ R
p: P
mpPP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RR → PP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ R
mprR → PP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ R
r: R
mprPP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ R
r: R
mprQP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ R
r: R
mprRGoals accomplished! 🐙
Another trick
Instead of using cases
on h : P ↔ Q
, you can just rw [h]
, and this will change all P
s to Q
s
in the goal. You can use this to create a much shorter proof. Note that
this is an argument for not running the cases
tactic on an iff statement;
you cannot rewrite one-way implications, but you can rewrite two-way implications.
lemmaiff_trans₃ (iff_trans₃: ∀ (P Q R : Prop), (P ↔ Q) → (Q ↔ R) → (P ↔ R)PP: PropQQ: PropR :R: PropProp) : (Prop: TypeP ↔P: PropQ) → (Q: PropQ ↔Q: PropR) → (R: PropP ↔P: PropR) :=R: PropP, Q, R: Prop(P ↔ Q) → (Q ↔ R) → (P ↔ R)P, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RP ↔ RP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RP ↔ RP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RQ ↔ RP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RQ ↔ RP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RQ ↔ RP, Q, R: Prop
hpq: P ↔ Q
hqr: Q ↔ RR ↔ RGoals accomplished! 🐙
Next up Level 6