natural-number-game

Solututions to the Natural Number Game

NameSizeMode
..
advanced-proposition.lean 2104B -rw-r--r--
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
example (P Q : Prop) (p : P) (q : Q) : P ∧ Q :=
begin
  split,
  exact p,
  exact q,
end

lemma and_symm (P Q : Prop) : P ∧ Q → Q ∧ P :=
begin
  intro h,
  cases h with p q,
  split,
  exact q,
  exact p,
end

lemma and_trans (P Q R : Prop) : P ∧ Q → Q ∧ R → P ∧ R :=
begin
  intro h1,
  cases h1 with p _,
  intro h2,
  cases h2 with _ r,
  split,
  exact p,
  exact r,
end

lemma iff_trans (P Q R : Prop) : (P ↔ Q) → (Q ↔ R) → (P ↔ R) :=
begin
  intro p_iff_q,
  cases p_iff_q with hpq hqp,
  intro q_iff_r,
  cases q_iff_r with hqr hrq,
  split,
  intro p,
  apply hqr,
  apply hpq,
  exact p,
  intro r,
  apply hqp,
  apply hrq,
  exact r,
end

lemma iff_trans (P Q R : Prop) : (P ↔ Q) → (Q ↔ R) → (P ↔ R) :=
begin
  intro p_iff_q,
  cases p_iff_q with hpq hqp,
  intro q_iff_r,
  cases q_iff_r with hqr hrq,
  split,
  intro p,
  apply hqr,
  apply hpq,
  exact p,
  intro r,
  apply hqp,
  apply hrq,
  exact r,
end

example (P Q : Prop) : Q → (P ∨ Q) :=
  begin
  intro q,
  right,
  exact q,
end

lemma or_symm (P Q : Prop) : P ∨ Q → Q ∨ P :=
begin
  intro h,
  cases h with p q,
  right,
  exact p,
  left,
  exact q,
end

lemma and_or_distrib_left (P Q R : Prop) : P ∧ (Q ∨ R) ↔ (P ∧ Q) ∨ (P ∧ R) :=
begin
  split,
  intro h,
  have p := h.1,
  cases h.2 with q r,
  left,
  split,
  exact p,
  exact q,
  right,
  split,
  exact p,
  exact r,
  intro h,
  cases h with p_and_q p_and_r,
  cases p_and_q with p q,
  split,
  exact p,
  left,
  exact q,
  cases p_and_r with p r,
  split,
  exact p,
  right,
  exact r,
end

lemma contra (P Q : Prop) : (P ∧ ¬ P) → Q :=
begin
  intro h,
  rw not_iff_imp_false at h,
  exfalso,
  apply h.2,
  exact h.1,
end

lemma contrapositive2 (P Q : Prop) : (¬ Q → ¬ P) → (P → Q) :=
begin
  by_cases p : P; by_cases q : Q,
  intros _ _,
  exact q,
  intro h,
  have not_p := h q,
  exfalso,
  rw not_iff_imp_false at not_p,
  apply not_p,
  exact p,
  intros _ _,
  exact q,
  intros h p,
  have not_p := h q,
  rw not_iff_imp_false at not_p,
  exfalso,
  apply not_p,
  exact p,
end