(************************************************************************) (* * The Rocq Prover / The Rocq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* The same but only the second occ *) Lemma testO2: forall (b : bool), b = b. Proof.
move=> b; case: {2}(b) / idP. matchgoalwith |- is_true b -> b = true => done | _ => fail end. matchgoalwith |- ~ is_true b -> b = false => move/(introF idP) => // | _ => fail end. Qed.
(* The same but with eq generation *) Lemma testO3: forall (b : bool), b = b. Proof.
move=> b; case E: {2}(b) / idP. matchgoalwith _ : is_true b, _ : b = true |- b = true => move: E => _; done | _ => fail end. matchgoalwith H : ~ is_true b, _ : b = false |- b = false => move: E => _; move/(introF idP): H => // | _ => fail end. Qed.
(* Views *) Lemma testV1 : forall A (s : seq A), s = s. Proof.
move=> A s; case/lastP E: {1}s => [| x xs]. matchgoalwith _ : s = [::] |- [::] = s => symmetry; exact E | _ => fail end. matchgoalwith _ : s = rcons x xs |- rcons _ _ = s => symmetry; exact E | _ => fail end. Qed.
Lemma testV2 : forall A (s : seq A), s = s. Proof.
move=> A s; case/lastP E: s => [| x xs]. matchgoalwith _ : s = [::] |- [::] = [::] => done | _ => fail end. matchgoalwith _ : s = rcons x xs |- rcons _ _ = rcons _ _ => done | _ => fail end. Qed.
Lemma testV3 : forall A (s : seq A), s = s. Proof.
move=> A s; case/lastP: s => [| x xs]. matchgoalwith |- [::] = [::] => done | _ => fail end. matchgoalwith |- rcons _ _ = rcons _ _ => done | _ => fail end. Qed.
(* The same but with an implicit pattern *) Lemma testP2 : forall (x y : nat), (y == x) && (y == x) -> y == x.
move=> x y; elim: {2}_ / eqP. matchgoalwith |- (y = x -> is_true ((y == x) && true) -> is_true (y == x)) => move=> -> // | _ => fail end. matchgoalwith |- (y <> x -> is_true ((y == x) && false) -> is_true (y == x)) => move=> _; rewrite andbC // | _ => fail end. Qed.
(* The same but with an eq generation switch *) Lemma testP3 : forall (x y : nat), (y == x) && (y == x) -> y == x.
move=> x y; elim E: {2}_ / eqP. matchgoalwith _ : y = x |- (is_true ((y == x) && true) -> is_true (y == x)) => rewrite E; reflexivity | _ => fail end. matchgoalwith _ : y <> x |- (is_true ((y == x) && false) -> is_true (y == x)) => rewrite E => /= H; exact H | _ => fail end. Qed.
Inductive spec : nat -> nat -> nat -> Prop :=
| specK : forall a b c, a = 0 -> b = 2 -> c = 4 -> spec a b c. Lemma specP : spec 0 2 4. Proof. by constructor. Qed.
Lemma testP4 : (1+1) * 4 = 2 + (1+1) + (2 + 2). Proof. case: specP => a b c defa defb defc. matchgoalwith |- (a.+1 + a.+1) * c = b + (a.+1 + a.+1) + (b + b) => subst; done | _ => fail end. Qed.
Lemma testP5 : (1+1) * 4 = 2 + (1+1) + (2 + 2). Proof. case: (1 + 1) _ / specP => a b c defa defb defc. matchgoalwith |- b * c = a.+2 + b + (a.+2 + a.+2) => subst; done | _ => fail end. Qed.
Lemma testP6 : (1+1) * 4 = 2 + (1+1) + (2 + 2). Proof. case: {2}(1 + 1) _ / specP => a b c defa defb defc. matchgoalwith |- (a.+1 + a.+1) * c = a.+2 + b + (a.+2 + a.+2) => subst; done | _ => fail end. Qed.
Lemma testP7 : (1+1) * 4 = 2 + (1+1) + (2 + 2). Proof. case: _ (1 + 1) (2 + _) / specP => a b c defa defb defc. matchgoalwith |- b * a.+4 = c + c => subst; done | _ => fail end. Qed.
Lemma testP8 : (1+1) * 4 = 2 + (1+1) + (2 + 2). Proof. case E: (1 + 1) (2 + _) / specP=> [a b c defa defb defc]. matchgoalwith |- b * a.+4 = c + c => subst; done | _ => fail end. Qed.
Fixpoint plus (m n : nat) {struct n} : nat := match n with
| 0 => m
| S p => S (plus m p) end.
Definition plus_equation : forall m n : nat,
plus m n = match n with
| 0 => m
| p.+1 => (plus m p).+1 end
:= fun m n : nat => match
n as n0 return
(forall m0 : nat,
plus m0 n0 = match n0 with
| 0 => m0
| p.+1 => (plus m0 p).+1 end) with
| 0 => @erefl nat
| n0.+1 => fun m0 : nat => erefl (plus m0 n0).+1 end m.
Definition plus_rect : forall (m : nat) (P : nat -> nat -> Type),
(forall n : nat, n = 0 -> P 0 m) ->
(forall n p : nat,
n = p.+1 -> P p (plus m p) -> P p.+1 (plus m p).+1) -> forall n : nat, P n (plus m n)
:= fun (m : nat) (P : nat -> nat -> Type)
(f0 : forall n : nat, n = 0 -> P 0 m)
(f : forall n p : nat,
n = p.+1 -> P p (plus m p) -> P p.+1 (plus m p).+1) => fix plus0 (n : nat) : P n (plus m n) :=
eq_rect_r [eta P n]
(let f1 := f0 n in let f2 := f n in match
n as n0 return
(n = n0 ->
(forall p : nat,
n0 = p.+1 -> P p (plus m p) -> P p.+1 (plus m p).+1) ->
(n0 = 0 -> P 0 m) ->
P n0 match n0 with
| 0 => m
| p.+1 => (plus m p).+1 end) with
| 0 => fun (_ : n = 0)
(_ : forall p : nat,
0 = p.+1 ->
P p (plus m p) -> P p.+1 (plus m p).+1)
(f4 : 0 = 0 -> P 0 m) => unkeyed (f4 (erefl 0))
| n0.+1 => fun (_ : n = n0.+1)
(f3 : forall p : nat,
n0.+1 = p.+1 ->
P p (plus m p) -> P p.+1 (plus m p).+1)
(_ : n0.+1 = 0 -> P 0 m) => let f5 := let p := n0 in let H := erefl n0.+1 : n0.+1 = p.+1 in f3 p H in
unkeyed (let Hrec := plus0 n0 in f5 Hrec) end (erefl n) f2 f1) (plus_equation m n).
Definition plus_ind := plus_rect.
Lemma exF x y z: plus (plus x y) z = plus x (plus y z). elim/plus_ind: z / (plus _ z). matchgoalwith |- forall n : nat, n = 0 -> plus x y = plus x (plus y 0) => idtacend.
Undo 2. elim/plus_ind: (plus _ z). matchgoalwith |- forall n : nat, n = 0 -> plus x y = plus x (plus y 0) => idtacend.
Undo 2. elim/plus_ind: {z}(plus _ z). matchgoalwith |- forall n : nat, n = 0 -> plus x y = plus x (plus y 0) => idtacend.
Undo 2. elim/plus_ind: {z}_. matchgoalwith |- forall n : nat, n = 0 -> plus x y = plus x (plus y 0) => idtacend.
Undo 2. elim/plus_ind: z / _. matchgoalwith |- forall n : nat, n = 0 -> plus x y = plus x (plus y 0) => idtacend.
done. by move=> _ p _ ->. Qed.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.