Skip to content

Instantly share code, notes, and snippets.

  • collective predicate x \in P
  • applicative predicate P x
Set Printing Coercions.
Require Import Omega.
Inductive hoge (n:nat) : Type :=
| fuga (m:nat) : m < n -> hoge n.
Coercion nat_of_hoge {n:nat} (h : hoge n) :=
match h with
| fuga _ n _ => n
end.
Set Printing Coercions.

utils

let pattern match

Inductive hoge :=
| fuga : forall (n:nat), hoge.

Eval simpl in let: fuga n := fuga 10 in n.

sigma type

Require Import Omega.

Print sig. (* Σx:A B(x) *)
(* Inductive sig (A : Type) (P : A -> Prop) : Type := *)
(* exist : forall x : A, P x -> {x : A | P x}         *)
(* For sig: Argument A is implicit                    *)
(* For exist: Argument A is implicit                  *)
Definition set (M : Type) := M -> Prop.
Definition belongs {M : Type} (x : M) (P : set M) : Prop := P x.
Arguments belongs {M} x P /.
Definition map {M M' : Type} f (A : set M) (B : set M') :=
forall x, belongs x A -> belongs (f x) B.
Arguments map {M M'} f A B /.
Class group (M : Type) := {
cset : set M;
Definition gen_rel (X Y : Type) := X -> Y -> Prop.
Definition map_rel {X Y : Type} (R : gen_rel X Y) :=
forall x x', x = x' -> forall y y', R x y -> R x' y' -> y = y'.
Arguments map_rel {X Y} R/.
Definition map_rel' {X Y : Type} (R : gen_rel X Y) :=
forall x, exists! y, R x y.
Arguments map_rel' {X Y} R/.
Definition relation (X Y : Type) := X -> Y -> Prop.
Structure map X Y := {
R : relation X Y;
map_law : forall x, exists! y, R x y
}.
Definition is_map {X Y : Type} (R : relation X Y) :=
forall x, exists! y, R x y.
Structure group M := {
id : M;
bin : M -> M -> M;
inverse : M -> M;
assoc : forall x y z, bin x (bin y z) = bin (bin x y) z;
idR : forall g, bin g id = g;
idL : forall g, bin id g = g;
invR : forall g, bin g (inverse g) = id;
invL : forall g, bin (inverse g) g = id
}.
Definition set (M : Type) := M -> Prop.
Definition belongs {M : Type} (x : M) (P : set M) : Prop := P x.
Definition subset {M : Type} (S T : set M) :=
forall s, belongs s S -> belongs s T.
Definition id {M : Type} (S : set M) (id : M) (bin : M -> M -> M) :=
forall s, belongs s S -> bin s id = s /\ bin id s = s.
Definition identity {M : Type} (S : set M) (bin : M -> M -> M) :=
exists e, id S e bin.
Definition set (M : Type) := M -> Prop.
Definition belongs {M : Type} (x : M) (P : set M) : Prop := P x.
Definition subset {M : Type} (S T : set M) :=
forall s, belongs s S -> belongs s T.
Definition id {M : Type} (S : set M) (id : M) (bin : M -> M -> M) :=
forall s, belongs s S -> bin s id = s /\ bin id s = s.
Axiom id_belongs : forall {M : Type} (S : set M) (id_ : M) bin,
id S id_ bin -> belongs id_ S.