@@ -99,29 +99,28 @@ theorem compExactValue_correctness_of_stream_eq_some :
99
99
induction n with
100
100
| zero =>
101
101
intro ifp_zero stream_zero_eq
102
- -- Nat.zero
103
- have : IntFractPair.of v = ifp_zero := by
102
+ obtain rfl : IntFractPair.of v = ifp_zero := by
104
103
have : IntFractPair.stream v 0 = some (IntFractPair.of v) := rfl
105
104
simpa only [this, Option.some.injEq] using stream_zero_eq
106
- cases this
107
- cases' Decidable.em (Int.fract v = 0 ) with fract_eq_zero fract_ne_zero
108
- -- Int.fract v = 0; we must then have `v = ⌊v⌋`
109
- · suffices v = ⌊v⌋ by
105
+ cases eq_or_ne (Int.fract v) 0 with
106
+ | inl fract_eq_zero =>
107
+ -- Int.fract v = 0; we must then have `v = ⌊v⌋`
108
+ suffices v = ⌊v⌋ by
110
109
-- Porting note: was `simpa [contsAux, fract_eq_zero, compExactValue]`
111
110
field_simp [nextConts, nextNum, nextDen, compExactValue]
112
111
have : (IntFractPair.of v).fr = Int.fract v := rfl
113
112
rwa [this, if_pos fract_eq_zero]
114
113
calc
115
114
v = Int.fract v + ⌊v⌋ := by rw [Int.fract_add_floor]
116
115
_ = ⌊v⌋ := by simp [fract_eq_zero]
117
- -- Int.fract v ≠ 0; the claim then easily follows by unfolding a single computation step
118
- · field_simp [contsAux, nextConts, nextNum, nextDen, of_h_eq_floor, compExactValue]
116
+ | inr fract_ne_zero =>
117
+ -- Int.fract v ≠ 0; the claim then easily follows by unfolding a single computation step
118
+ field_simp [contsAux, nextConts, nextNum, nextDen, of_h_eq_floor, compExactValue]
119
119
-- Porting note: this and the if_neg rewrite are needed
120
120
have : (IntFractPair.of v).fr = Int.fract v := rfl
121
121
rw [this, if_neg fract_ne_zero, Int.floor_add_fract]
122
122
| succ n IH =>
123
123
intro ifp_succ_n succ_nth_stream_eq
124
- -- Nat.succ
125
124
obtain ⟨ifp_n, nth_stream_eq, nth_fract_ne_zero, -⟩ :
126
125
∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧
127
126
ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n :=
@@ -130,9 +129,10 @@ theorem compExactValue_correctness_of_stream_eq_some :
130
129
let conts := g.contsAux (n + 2 )
131
130
set pconts := g.contsAux (n + 1 ) with pconts_eq
132
131
set ppconts := g.contsAux n with ppconts_eq
133
- cases' Decidable.em (ifp_succ_n.fr = 0 ) with ifp_succ_n_fr_eq_zero ifp_succ_n_fr_ne_zero
134
- -- ifp_succ_n.fr = 0
135
- · suffices v = conts.a / conts.b by simpa [compExactValue, ifp_succ_n_fr_eq_zero]
132
+ cases eq_or_ne ifp_succ_n.fr 0 with
133
+ | inl ifp_succ_n_fr_eq_zero =>
134
+ -- ifp_succ_n.fr = 0
135
+ suffices v = conts.a / conts.b by simpa [compExactValue, ifp_succ_n_fr_eq_zero]
136
136
-- use the IH and the fact that ifp_n.fr⁻¹ = ⌊ifp_n.fr⁻¹⌋ to prove this case
137
137
obtain ⟨ifp_n', nth_stream_eq', ifp_n_fract_inv_eq_floor⟩ :
138
138
∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr⁻¹ = ⌊ifp_n.fr⁻¹⌋ :=
@@ -145,8 +145,9 @@ theorem compExactValue_correctness_of_stream_eq_some :
145
145
suffices v = compExactValue ppconts pconts ifp_n.fr by
146
146
simpa [conts, contsAux, s_nth_eq, compExactValue, nth_fract_ne_zero] using this
147
147
exact IH nth_stream_eq
148
- -- ifp_succ_n.fr ≠ 0
149
- · -- use the IH to show that the following equality suffices
148
+ | inr ifp_succ_n_fr_ne_zero =>
149
+ -- ifp_succ_n.fr ≠ 0
150
+ -- use the IH to show that the following equality suffices
150
151
suffices
151
152
compExactValue ppconts pconts ifp_n.fr = compExactValue pconts conts ifp_succ_n.fr by
152
153
have : v = compExactValue ppconts pconts ifp_n.fr := IH nth_stream_eq
@@ -214,14 +215,14 @@ theorem of_correctness_of_nth_stream_eq_none (nth_stream_eq_none : IntFractPair.
214
215
| succ n IH =>
215
216
let g := of v
216
217
change v = g.convs n
217
- have :
218
+ obtain ⟨nth_stream_eq_none⟩ | ⟨ifp_n, nth_stream_eq, nth_stream_fr_eq_zero⟩ :
218
219
IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0 :=
219
220
IntFractPair.succ_nth_stream_eq_none_iff.1 nth_stream_eq_none
220
- rcases this with (⟨nth_stream_eq_none⟩ | ⟨ifp_n, nth_stream_eq, nth_stream_fr_eq_zero⟩)
221
- · cases' n with n'
222
- · contradiction
223
- -- IntFractPair.stream v 0 ≠ none
224
- · have : g.TerminatedAt n' :=
221
+ · cases n with
222
+ | zero => contradiction
223
+ | succ n' =>
224
+ -- IntFractPair.stream v 0 ≠ none
225
+ have : g.TerminatedAt n' :=
225
226
of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none.2
226
227
nth_stream_eq_none
227
228
have : g.convs (n' + 1 ) = g.convs n' :=
0 commit comments