Skip to content

Commit 908e886

Browse files
committed
Starting Intro pattern
1 parent 2003cbc commit 908e886

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

src/IntroPatternsTutorials.v

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
(** * (Default) Intro Patterns Tutorials
2+
3+
*** Summary
4+
5+
This tutorial is about (default) intro patterns we can use in a proof
6+
with default Coq tactics. Intro Patterns help gain a lot of time during
7+
proofs writing and make the proofs more natural to read and write.
8+
Once used to intro patterns, you can't live without it!
9+
10+
*** Prerequisites
11+
12+
Needed:
13+
- The user should already have some very minimal Coq experience with proof
14+
writing.
15+
16+
Installation:
17+
This tutorial should work for Coq V8.17 or later.
18+
*)
19+
20+
Lemma disjunctive_pattern (A B : Prop) : A \/ B -> B \/ A.
21+
Proof.
22+
(* disjunctive pattern *)
23+
intros [H | H'].
24+
- right; exact H.
25+
- left; exact H'.
26+
Qed.
27+
28+
Lemma cunjunctive_pattern (A B : Prop) : A /\ B -> B /\ A.
29+
Proof.
30+
(* conjunctive pattern *)
31+
intros [H H'].
32+
split.
33+
- exact H'.
34+
- exact H.
35+
Qed.
36+
37+
Lemma throwing_away (A B : Prop) : A /\ B -> A.
38+
Proof.
39+
(* useless parts can be thrown away *)
40+
intros [H _].
41+
exact H.
42+
Qed.
43+
44+
Lemma nested_intro_pat (A B C : Prop) : A /\ (B \/ C) -> (A /\ B) \/ (A /\ C).
45+
Proof.
46+
(* intro patterns can be nested *)
47+
intros [HA [HB | HC]].
48+
- left. split.
49+
+ exact HA.
50+
+ exact HB.
51+
- right. split.
52+
+ exact HA.
53+
+ exact HC.
54+
Qed.
55+
56+
Lemma arrow_intro_pat (x : nat) : x = 0 -> x + x = x.
57+
Proof.
58+
(* the -> intro pattern acts like "rewrite name; clear name" *)
59+
intros ->. reflexivity.
60+
Qed.
61+
62+
Lemma apply_in_intro_pat (x : nat) : x = 0 -> x = x + x.
63+
Proof.
64+
(* the hyp%term intro pattern acts like "intros hyp; apply term in hyp" *)
65+
intros Hx%exple5. symmetry. exact Hx.
66+
Qed.
67+
68+
Lemma composition_of_apply_in (x : nat) : x = 0 -> x = x + x.
69+
Proof.
70+
(* % intro patterns can be composed *)
71+
intros Hx%exple5%eq_sym. exact Hx.
72+
Qed.
73+
74+
Lemma intro_pat_following_as (A B : Prop) : A -> B -> A /\ B.
75+
Proof.
76+
intros H1 H2.
77+
(* intro patterns can occur (almost) every time you name a term.
78+
assert ([H H']: A /\ B) fails but this works: *)
79+
assert (A /\ B) as [H H'].
80+
(* this was an artificial example *)
81+
easy. easy.
82+
Qed.
83+

0 commit comments

Comments
 (0)