| 1 |
(************************************************************************) |
| 2 |
(* * The Rocq Prover / The Rocq Development Team *) |
| 3 |
(* v * Copyright INRIA, CNRS and contributors *) |
| 4 |
(* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 |
(* \VV/ **************************************************************) |
| 6 |
(* // * This file is distributed under the terms of the *) |
| 7 |
(* * GNU Lesser General Public License Version 2.1 *) |
| 8 |
(* * (see LICENSE file for the text of the license) *) |
| 9 |
(************************************************************************) |
| 10 |
|
| 11 |
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) |
| 12 |
|
| 13 |
Require Import ssreflect ssrbool ssrfun. |
| 14 |
Require Import TestSuite.ssr_mini_mathcomp. |
| 15 |
|
| 16 |
Lemma test15: forall (y : nat) (x : 'I_2), y < 1 -> val x = y -> Some x = insub y. |
| 17 |
move=> y x le_1 defx; rewrite insubT ?(leq_trans le_1) // => ?. |
| 18 |
by congr (Some _); apply: val_inj=> /=; exact: defx. |
| 19 |
Qed. |
| 20 |
|
| 21 |
Axiom P : nat -> Prop. |
| 22 |
Axiom Q : forall n, P n -> Prop. |
| 23 |
Definition R := fun (x : nat) (p : P x) m (q : P (x+1)) => m > 0. |
| 24 |
|
| 25 |
Inductive myEx : Type := ExI : forall n (pn : P n) pn', Q n pn -> R n pn n pn' -> myEx. |
| 26 |
|
| 27 |
Parameter P1 : P 1. |
| 28 |
Parameter P11 : P (1 + 1). |
| 29 |
Parameter Q1 : forall P1, Q 1 P1. |
| 30 |
|
| 31 |
Lemma testmE1 : myEx. |
| 32 |
Proof. |
| 33 |
apply: ExI 1 _ _ _ _. |
| 34 |
match goal with |- P 1 => exact: P1 | _ => fail end. |
| 35 |
match goal with |- P (1+1) => exact: P11 | _ => fail end. |
| 36 |
match goal with |- forall p : P 1, Q 1 p => move=> *; exact: Q1 | _ => fail end. |
| 37 |
match goal with |- forall (p : P 1) (q : P (1+1)), is_true (R 1 p 1 q) => done | _ => fail end. |
| 38 |
Qed. |
| 39 |
|
| 40 |
Lemma testE2 : exists y : { x | P x }, sval y = 1. |
| 41 |
Proof. |
| 42 |
apply: ex_intro (exist _ 1 _) _. |
| 43 |
match goal with |- P 1 => exact: P1 | _ => fail end. |
| 44 |
match goal with |- forall p : P 1, @sval _ _ (@exist _ _ 1 p) = 1 => done | _ => fail end. |
| 45 |
Qed. |
| 46 |
|
| 47 |
Lemma testE3 : exists y : { x | P x }, sval y = 1. |
| 48 |
Proof. |
| 49 |
have := (ex_intro _ (exist _ 1 _) _); apply. |
| 50 |
match goal with |- P 1 => exact: P1 | _ => fail end. |
| 51 |
match goal with |- forall p : P 1, @sval _ _ (@exist _ _ 1 p) = 1 => done | _ => fail end. |
| 52 |
Qed. |
| 53 |
|
| 54 |
Lemma testE4 : P 2 -> exists y : { x | P x }, sval y = 2. |
| 55 |
Proof. |
| 56 |
move=> P2; apply: ex_intro (exist _ 2 _) _. |
| 57 |
match goal with |- @sval _ _ (@exist _ _ 2 P2) = 2 => done | _ => fail end. |
| 58 |
Qed. |
| 59 |
|
| 60 |
#[export] Hint Resolve P1. |
| 61 |
|
| 62 |
Lemma testmE12 : myEx. |
| 63 |
Proof. |
| 64 |
apply: ExI 1 _ _ _ _. |
| 65 |
match goal with |- P (1+1) => exact: P11 | _ => fail end. |
| 66 |
match goal with |- Q 1 P1 => exact: Q1 | _ => fail end. |
| 67 |
match goal with |- forall (q : P (1+1)), is_true (R 1 P1 1 q) => done | _ => fail end. |
| 68 |
Qed. |
| 69 |
|
| 70 |
Create HintDb SSR. |
| 71 |
|
| 72 |
#[export] Hint Resolve P11 : SSR. |
| 73 |
|
| 74 |
Ltac ssrautoprop := trivial with SSR. |
| 75 |
|
| 76 |
Lemma testmE13 : myEx. |
| 77 |
Proof. |
| 78 |
apply: ExI 1 _ _ _ _. |
| 79 |
match goal with |- Q 1 P1 => exact: Q1 | _ => fail end. |
| 80 |
match goal with |- is_true (R 1 P1 1 P11) => done | _ => fail end. |
| 81 |
Qed. |
| 82 |
|
| 83 |
Definition R1 := fun (x : nat) (p : P x) m (q : P (x+1)) (r : Q x p) => m > 0. |
| 84 |
|
| 85 |
Inductive myEx1 : Type := |
| 86 |
ExI1 : forall n (pn : P n) pn' (q : Q n pn), R1 n pn n pn' q -> myEx1. |
| 87 |
|
| 88 |
#[export] Hint Extern 0 (Q 1 P1) => apply (Q1 P1) : SSR. |
| 89 |
|
| 90 |
(* tests that goals in prop are solved in the right order, propagating instantiations, |
| 91 |
thus the goal Q 1 ?p1 is faced by trivial after ?p1, and is thus evar free *) |
| 92 |
Lemma testmE14 : myEx1. |
| 93 |
Proof. |
| 94 |
apply: ExI1 1 _ _ _ _. |
| 95 |
match goal with |- is_true (R1 1 P1 1 P11 (Q1 P1)) => done | _ => fail end. |
| 96 |
Qed. |