Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,4 @@
Fixpoint Arity (A B: Set) (n: nat): Set := match n with
|O => B
|S n' => A -> (Arity A B n')
end.

View file

@ -0,0 +1 @@
Definition nat_twobools (n: nat) := Arity nat (Arity bool nat (2*n)) n.

View file

@ -0,0 +1,5 @@
Require Import List.
Fixpoint build_list_aux {A: Set} (acc: list A) (n : nat): Arity A (list A) n := match n with
|O => acc
|S n' => fun (val: A) => build_list_aux (acc ++ (val :: nil)) n'
end.

View file

@ -0,0 +1 @@
Definition build_list {A: Set} := build_list_aux (@nil A).

View file

@ -0,0 +1 @@
Check build_list 5 1 2 5 90 42.

View file

@ -0,0 +1,11 @@
Lemma transparent_plus_zero: forall n, n + O = n.
intros n; induction n.
- reflexivity.
- simpl; rewrite IHn; trivial.
Defined.
Lemma transparent_plus_S: forall n m, n + S m = S n + m .
intros n; induction n; intros m.
- reflexivity.
- simpl; f_equal; rewrite IHn; reflexivity.
Defined.

View file

@ -0,0 +1,7 @@
Require Import Vector.
Definition build_vector_aux {A: Set} (n: nat): forall (size_acc : nat) (acc: t A size_acc), Arity A (t A (size_acc + n)) n.
induction n; intros size_acc acc.
- rewrite transparent_plus_zero; apply acc. (*Just one argument, return the accumulator*)
- intros val. rewrite transparent_plus_S. apply IHn. (*Here we use the induction hypothesis. We just have to build the new accumulator*)
apply shiftin; [apply val | apply acc]. (*Shiftin adds a term at the end of a vector*)

View file

@ -0,0 +1 @@
Definition build_vector {A: Set} (n: nat) := build_vector_aux n O (@nil A).

View file

@ -0,0 +1,2 @@
Require Import String.
Eval compute in build_vector 4 "Hello" "how" "are" "you".