File: unfold_fold_polyuniv.v

package info (click to toggle)
coq-doc 8.16.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm
  • size: 42,788 kB
  • sloc: ml: 219,673; sh: 4,035; python: 3,372; ansic: 2,529; makefile: 728; lisp: 279; javascript: 87; xml: 24; sed: 2
file content (40 lines) | stat: -rw-r--r-- 1,018 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Require Import ssreflect ssrbool.

Set Universe Polymorphism.

Cumulative Variant paths {A} (x:A) : A -> Type
  := idpath : paths x x.

Register paths as core.eq.type.
Register idpath as core.eq.refl.

Structure type := Pack {sort; op : rel sort}.

Example unfold_fold (T : type) (x : sort T) (a : op T x x) : op T x x.
Proof.
  rewrite /op. rewrite -/(op _ _ _). assumption.
Qed.

Example pattern_unfold_fold (b:bool) (a := b) : paths a b.
Proof.
  rewrite [in X in paths X _]/a.
  rewrite -[in X in paths X _]/a.
  constructor.
Qed.

Example unfold_in_hyp (b:bool) (a := b) : unit.
Proof.
  assert (paths a a) as A by reflexivity.
  rewrite [in X in paths X _]/a in A.
  rewrite /a in (B := idpath a).
  rewrite [in X in paths _ X]/a in (C := idpath a).
  constructor.
Qed.

Example fold_in_hyp (b:bool) (p := idpath b) : unit.
Proof.
  assert (paths (idpath b) (idpath b)) as A by reflexivity.
  rewrite -[in X in paths X _]/p in A.
  rewrite -[in X in paths _ X]/p in (C := idpath (idpath b)).
  constructor.
Qed.