Skip to content

Commit c028877

Browse files
only use simp only in Regex proofs
1 parent d5b6375 commit c028877

File tree

3 files changed

+68
-54
lines changed

3 files changed

+68
-54
lines changed

Katydid/Regex/Language.lean

+47-35
Original file line numberDiff line numberDiff line change
@@ -96,35 +96,36 @@ theorem derives_strings {α: Type} (R: Lang α) (xs ys: List α):
9696

9797
theorem derives_step {α: Type} (R: Lang α) (x: α) (xs: List α):
9898
derives R (x :: xs) = derives (derive R x) xs := by
99-
simp
99+
simp only [derive]
100100
rw [<- derives_strings]
101101
congr
102102

103103
theorem null_derives {α: Type} (R: Lang α) (xs: List α):
104104
(null ∘ derives R) xs = R xs := by
105105
unfold derives
106106
unfold null
107-
simp
107+
simp only [Function.comp_apply]
108+
simp only [append_nil]
108109

109110
theorem validate {α: Type} (R: Lang α) (xs: List α):
110111
null (derives R xs) = R xs := by
111112
unfold derives
112113
unfold null
113-
simp
114+
simp only [append_nil]
114115

115116
theorem derives_foldl (R: Lang α) (xs: List α):
116117
(derives R) xs = (List.foldl derive R) xs := by
117118
revert R
118119
induction xs with
119120
| nil =>
120121
unfold derives
121-
simp
122+
simp only [nil_append, foldl_nil, implies_true]
122123
| cons x xs ih =>
123124
simp
124125
intro R
125126
rw [derives_step]
126127
rw [ih (derive R x)]
127-
simp
128+
simp only [derive]
128129

129130
-- Theorems: null
130131

@@ -199,8 +200,8 @@ theorem null_iff_concat {α: Type} {P Q: Lang α}:
199200
refine Iff.intro ?toFun ?invFun
200201
case toFun =>
201202
intro ⟨x, y, hx, hy, hxy⟩
202-
simp at hxy
203-
simp [hxy] at hx hy
203+
simp only [nil_eq, append_eq_nil] at hxy
204+
simp only [hxy] at hx hy
204205
exact ⟨hx, hy⟩
205206
case invFun =>
206207
exact fun ⟨x, y⟩ => ⟨[], [], x, y, rfl⟩
@@ -386,7 +387,7 @@ theorem derive_iff_star {α: Type} {x: α} {R: Lang α} {xs: List α}:
386387
unfold concat
387388
exists xs1
388389
exists xs2
389-
simp at hxs
390+
simp only [singleton_append, cons_append, cons.injEq] at hxs
390391
cases hxs with
391392
| intro hxs1 hxs2 =>
392393
rw [hxs1]
@@ -409,7 +410,7 @@ theorem derive_iff_star {α: Type} {x: α} {R: Lang α} {xs: List α}:
409410
unfold derives
410411
refine star.more x xs1 xs2 ?hxs ?e ?f ?g
411412
· rw [hxs]
412-
simp
413+
simp only [singleton_append, cons_append, nil_append]
413414
· apply deriveRxxs1
414415
· exact starRxs2
415416

@@ -529,10 +530,10 @@ theorem simp_or_null_l_emptystr_is_l
529530
(nullr: null r):
530531
or r emptystr = r := by
531532
unfold or
532-
simp
533+
simp only [emptystr]
533534
unfold null at nullr
534535
funext xs
535-
simp
536+
simp only [eq_iff_iff, or_iff_left_iff_imp]
536537
intro hxs
537538
rw [hxs]
538539
exact nullr
@@ -542,10 +543,10 @@ theorem simp_or_emptystr_null_r_is_r
542543
(nullr: null r):
543544
or emptystr r = r := by
544545
unfold or
545-
simp
546+
simp only [emptystr]
546547
unfold null at nullr
547548
funext xs
548-
simp
549+
simp only [eq_iff_iff, or_iff_right_iff_imp]
549550
intro hxs
550551
rw [hxs]
551552
exact nullr
@@ -560,7 +561,7 @@ theorem simp_or_comm (r s: Lang α):
560561
or r s = or s r := by
561562
unfold or
562563
funext xs
563-
simp
564+
simp only [eq_iff_iff]
564565
apply Iff.intro
565566
case mp =>
566567
intro h
@@ -619,31 +620,31 @@ theorem simp_or_assoc (r s t: Lang α):
619620
theorem simp_and_emptyset_l_is_emptyset (r: Lang α):
620621
and emptyset r = emptyset := by
621622
unfold and
622-
simp
623+
simp only [emptyset, false_and]
623624
rfl
624625

625626
theorem simp_and_emptyset_r_is_emptyset (r: Lang α):
626627
and r emptyset = emptyset := by
627628
unfold and
628-
simp
629+
simp only [emptyset, and_false]
629630
rfl
630631

631632
theorem simp_and_universal_l_is_r (r: Lang α):
632633
and universal r = r := by
633634
unfold and
634-
simp
635+
simp only [universal, true_and]
635636

636637
theorem simp_and_universal_r_is_l (r: Lang α):
637638
and r universal = r := by
638639
unfold and
639-
simp
640+
simp only [universal, and_true]
640641

641642
theorem simp_and_null_l_emptystr_is_emptystr
642643
(r: Lang α)
643644
(nullr: null r):
644645
and r emptystr = emptystr := by
645646
funext xs
646-
simp at *
647+
simp only [null, and, emptystr, eq_iff_iff, and_iff_right_iff_imp]
647648
intro hxs
648649
rw [hxs]
649650
exact nullr
@@ -653,7 +654,8 @@ theorem simp_and_emptystr_null_r_is_emptystr
653654
(nullr: null r):
654655
and emptystr r = emptystr := by
655656
funext xs
656-
simp at *
657+
simp only [null] at nullr
658+
simp only [and, emptystr, eq_iff_iff, and_iff_left_iff_imp]
657659
intro hxs
658660
rw [hxs]
659661
exact nullr
@@ -663,7 +665,7 @@ theorem simp_and_not_null_l_emptystr_is_emptyset
663665
(notnullr: Not (null r)):
664666
and r emptystr = emptyset := by
665667
funext xs
666-
simp at *
668+
simp only [null, and, emptystr, emptyset, eq_iff_iff, iff_false, not_and]
667669
intro hr hxs
668670
rw [hxs] at hr
669671
contradiction
@@ -673,21 +675,30 @@ theorem simp_and_emptystr_not_null_r_is_emptyset
673675
(notnullr: Not (null r)):
674676
and emptystr r = emptyset := by
675677
funext xs
676-
simp at *
678+
simp only [null, and, emptystr, emptyset, eq_iff_iff, iff_false, not_and]
677679
intro hxs
678680
rw [hxs]
679681
exact notnullr
680682

681683
theorem simp_and_idemp (r: Lang α):
682684
and r r = r := by
683685
unfold and
684-
simp
686+
funext xs
687+
simp only [eq_iff_iff]
688+
apply Iff.intro
689+
case mp =>
690+
intro h
691+
cases h
692+
assumption
693+
case mpr =>
694+
intro h
695+
exact And.intro h h
685696

686697
theorem simp_and_comm (r s: Lang α):
687698
and r s = and s r := by
688699
unfold and
689700
funext xs
690-
simp
701+
simp only [eq_iff_iff]
691702
apply Iff.intro
692703
case mp =>
693704
intro h
@@ -720,7 +731,7 @@ theorem simp_and_assoc (r s t: Lang α):
720731
theorem simp_not_not_is_double_negation (r: Lang α):
721732
not (not r) = r := by
722733
unfold not
723-
simp
734+
simp only [not_not]
724735

725736
theorem simp_not_and_demorgen (r s: Lang α):
726737
not (and r s) = or (not r) (not s) := by
@@ -744,7 +755,7 @@ theorem simp_not_and_demorgen (r s: Lang α):
744755
intro hrs
745756
cases hrs with
746757
| intro hr hs =>
747-
simp at h
758+
simp only [imp_false] at h
748759
cases h with
749760
| inl h =>
750761
contradiction
@@ -763,7 +774,7 @@ theorem simp_and_not_emptystr_l_not_null_r_is_r
763774
(notnullr: Not (null r)):
764775
and (not emptystr) r = r := by
765776
funext xs
766-
simp [not, emptystr] at *
777+
simp only [null, and, not, emptystr, eq_iff_iff, and_iff_right_iff_imp]
767778
intro hr hxs
768779
rw [hxs] at hr
769780
contradiction
@@ -773,7 +784,8 @@ theorem simp_and_not_null_l_not_emptystr_r_is_l
773784
(notnullr: Not (null r)):
774785
and r (not emptystr) = r := by
775786
funext xs
776-
simp [not, emptystr] at *
787+
simp only [null] at notnullr
788+
simp only [and, not, emptystr, eq_iff_iff, and_iff_left_iff_imp]
777789
intro hr hxs
778790
rw [hxs] at hr
779791
contradiction
@@ -785,7 +797,7 @@ theorem simp_one_r_implies_star_r (r: Lang α) (xs: List α):
785797
· exact star.zero
786798
· case cons x xs =>
787799
apply star.more x xs []
788-
· simp
800+
· simp only [append_nil]
789801
· exact h
790802
· exact star.zero
791803

@@ -804,13 +816,13 @@ theorem simp_star_concat_star_implies_star (r: Lang α) (xs: List α):
804816
clear xssplit
805817
induction starrxs1 with
806818
| zero =>
807-
simp
819+
simp only [nil_append]
808820
exact starrxs2
809821
| more x xs11 xs12 _ xs1split rxxs11 starrxs12 ih =>
810822
rename_i xs1
811823
rw [xs1split]
812824
apply star.more x xs11 (xs12 ++ xs2)
813-
simp
825+
simp only [cons_append, append_assoc]
814826
exact rxxs11
815827
exact ih
816828

@@ -825,14 +837,14 @@ theorem simp_star_implies_star_concat_star (r: Lang α) (xs: List α):
825837
split_ands
826838
· exact star.zero
827839
· exact star.zero
828-
· simp
840+
· simp only [append_nil]
829841
| more x xs1 xs2 _ xssplit rxxs1 starrxs2 =>
830842
unfold concat
831843
exists (x::xs1)
832844
exists xs2
833845
split_ands
834846
· refine star.more x xs1 [] _ ?_ ?_ ?_
835-
· simp
847+
· simp only [append_nil]
836848
· exact rxxs1
837849
· exact star.zero
838850
· exact starrxs2
@@ -882,7 +894,7 @@ theorem simp_star_star_is_star (r: Lang α):
882894
theorem simp_star_emptystr_is_emptystr {α: Type}:
883895
star (@emptystr α) = (@emptystr α) := by
884896
funext xs
885-
simp
897+
simp only [emptystr, eq_iff_iff]
886898
apply Iff.intro
887899
case mp =>
888900
intro h
@@ -899,7 +911,7 @@ theorem simp_star_emptystr_is_emptystr {α: Type}:
899911
theorem simp_star_emptyset_is_emptystr {α: Type}:
900912
star (@emptyset α) = (@emptystr α) := by
901913
funext xs
902-
simp
914+
simp only [emptystr, eq_iff_iff]
903915
apply Iff.intro
904916
case mp =>
905917
intro h

Katydid/Regex/SimpleRegex.lean

+4-2
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ def denote_onlyif {α: Type} (condition: Prop) [dcond: Decidable condition] (r:
137137
split_ifs
138138
case pos hc' =>
139139
rw [ctrue]
140-
simp
140+
simp only [true_and]
141141
case neg hc' =>
142142
rw [ctrue] at hc'
143143
contradiction
144144
| inr cfalse =>
145145
split_ifs
146146
case neg hc' =>
147147
rw [cfalse]
148-
simp [denote]
148+
simp only [denote, Language.emptyset, false_and]
149149
case pos hc' =>
150150
rw [cfalse] at hc'
151151
contradiction
@@ -270,3 +270,5 @@ def decidableDenote (r: Regex α): DecidablePred (denote r) := by
270270
· simp only
271271
apply Decidable.isTrue
272272
exact True.intro
273+
274+
#print axioms decidableDenote

Katydid/Regex/SmartRegex.lean

+17-17
Original file line numberDiff line numberDiff line change
@@ -232,22 +232,22 @@ theorem smartStar_is_star (x: Regex α):
232232
denote (Regex.star x) = denote (smartStar x) := by
233233
cases x with
234234
| emptyset =>
235-
simp [smartStar]
236-
simp [denote]
235+
simp only [smartStar]
236+
simp only [denote]
237237
rw [Language.simp_star_emptyset_is_emptystr]
238238
| emptystr =>
239-
simp [smartStar]
240-
simp [denote]
239+
simp only [smartStar]
240+
simp only [denote]
241241
rw [Language.simp_star_emptystr_is_emptystr]
242242
| pred p =>
243-
simp [smartStar]
243+
simp only [smartStar]
244244
| concat x1 x2 =>
245-
simp [smartStar]
245+
simp only [smartStar]
246246
| or x1 x2 =>
247-
simp [smartStar]
247+
simp only [smartStar]
248248
| star x' =>
249-
simp [smartStar]
250-
simp [denote]
249+
simp only [smartStar]
250+
simp only [denote]
251251
rw [Language.simp_star_star_is_star]
252252

253253
-- smartConcat is a smart constructor for Regex.concat that includes the following simplification rules:
@@ -273,32 +273,32 @@ theorem smartConcat_is_concat {α: Type} (x y: Regex α):
273273
cases x with
274274
| emptyset =>
275275
unfold smartConcat
276-
simp [denote]
276+
simp only [denote]
277277
exact Language.simp_concat_emptyset_l_is_emptyset (denote y)
278278
| emptystr =>
279279
unfold smartConcat
280-
simp [denote]
280+
simp only [denote]
281281
exact Language.simp_concat_emptystr_l_is_r (denote y)
282282
| pred p =>
283-
cases y <;> simp [denote]
283+
cases y <;> simp only [denote]
284284
· case emptyset =>
285285
apply Language.simp_concat_emptyset_r_is_emptyset
286286
· case emptystr =>
287287
apply Language.simp_concat_emptystr_r_is_l
288288
| or x1 x2 =>
289-
cases y <;> simp [denote]
289+
cases y <;> simp only [denote]
290290
· case emptyset =>
291291
apply Language.simp_concat_emptyset_r_is_emptyset
292292
· case emptystr =>
293293
apply Language.simp_concat_emptystr_r_is_l
294294
| concat x1 x2 =>
295295
unfold smartConcat
296-
simp [denote]
296+
simp only [denote]
297297
rw [<- smartConcat_is_concat x2 y]
298-
simp [denote]
298+
simp only [denote]
299299
rw [Language.simp_concat_assoc]
300300
| star x1 =>
301-
cases y <;> simp [denote]
301+
cases y <;> simp only [denote]
302302
· case emptyset =>
303303
apply Language.simp_concat_emptyset_r_is_emptyset
304304
· case emptystr =>
@@ -321,7 +321,7 @@ def orFromList (xs: NonEmptyList (Regex α)): Regex α :=
321321

322322
theorem orToList_is_orFromList (x: Regex α):
323323
orFromList (orToList x) = x := by
324-
induction x <;> (try simp [orToList, orFromList])
324+
induction x <;> (try simp only [orToList, orFromList])
325325
· case or x1 x2 ih1 ih2 =>
326326
-- TODO
327327
sorry

0 commit comments

Comments
 (0)