Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Bool.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Library on booleans. */
// booleans

require open Stdlib.FOL Stdlib.Eq;

Expand Down
4 changes: 1 addition & 3 deletions Comp.lp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* Comparison datatype

By Quentin Garchery (May 2021). */
// comparison datatype

require open Stdlib.Bool;

Expand Down
7 changes: 3 additions & 4 deletions Conj.lp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* Library on Meta-Theorems for Conjunctions

-------------------
// varyadic conjunction

/*
The library proves the following meta-theorems:

** n-ary Natural Deduction rules:
Expand Down Expand Up @@ -122,4 +121,4 @@ begin
have ConjImpCl : π (conj cnf ⇒ clause cnf id)
{refine h0 cnf (indexes_decrement id x cnf h2)};
refine clause_ext cnf x id (ConjImpCl (conj_tail x cnf h3))}}
end;
end;
2 changes: 1 addition & 1 deletion Coprod.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Co-Cartesian product (disjoint sum)
// disjoint sum

require open Stdlib.FOL Stdlib.Eq;

Expand Down
12 changes: 5 additions & 7 deletions DepProd.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Dependent product: a dependent pair of an element and an element in Set
// dependent pairs

require open Stdlib.Eq;

Expand All @@ -9,11 +9,11 @@ constant symbol dprod [a: Set] : (τ a → Set) → Set;

rule τ (@dprod $a $p) ↪ @DProd $a $p;

symbol proj₁ [a] [p] (e: @DProd a p) : τ a;
symbol proj₁ [a p] (e: @DProd a p) : τ a;

rule proj₁ (dpair $x _) ↪ $x;

symbol proj₂ [a] [p] (e: @DProd a p) : τ (p (proj₁ e));
symbol proj₂ [a p] (e: @DProd a p) : τ (p (proj₁ e));

rule proj₂ (dpair _ $u) ↪ $u;

Expand All @@ -23,13 +23,11 @@ begin assume a p; induction; reflexivity end;

opaque symbol eq_proj₁ [a] [p] (x y: @DProd a p) :
π (x = y) → π (proj₁ x = proj₁ y) ≔
begin assume a p x y h; refine feq (λ e, proj₁ e) h end;
begin assume a p x y h; refine feq proj₁ h end;

opaque symbol eq_dpair_refl [a] [p] (x: τ a) (u v: τ (p x)) :
π (u = v) → π (@dpair a p x u = dpair x v) ≔
begin
assume a p x u v h; refine feq (λ w, @dpair a p x w) h
end;
begin assume a p x u v h; refine feq (dpair x) h end;

symbol transport [a] (p: τ a → Set) [x y: τ a] : π (x = y) → τ (p x) → τ (p y);
rule transport _ (eq_refl _) $u ↪ $u;
Expand Down
7 changes: 3 additions & 4 deletions Disj.lp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* Library on Meta-Theorems for Disjunctions

-------------------
// varyadic disjunction

/*
The library proves the following meta-theorems:

** n-ary Natural Deduction rules:
Expand Down Expand Up @@ -400,4 +399,4 @@ begin
end;

assert l0 l1 l2 l2' ⊢ transform [l2'] (l0 ⸬ l1 ⸬ l2 ⸬ l1 ⸬ □) 2 :
(π l2 → π l2') → π (l0 ∨ l1 ∨ l2 ∨ l1) → π (l0 ∨ l1 ∨ l2' ∨ l1);
(π l2 → π l2') → π (l0 ∨ l1 ∨ l2 ∨ l1) → π (l0 ∨ l1 ∨ l2' ∨ l1);
2 changes: 2 additions & 0 deletions Epsilon.lp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Hilbert choice operator

require open Stdlib.FOL;

symbol ε [a:Set] : (τ a → Prop) → τ a;
Expand Down
2 changes: 1 addition & 1 deletion ExtraRules.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This module turns proved equalities to rewrite rules
// additional rewrite rules derived from proved equalities

// Bool

Expand Down
2 changes: 1 addition & 1 deletion FOL.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (multi-sorted) First-order logic
// polymorphic first-order logic

require open Stdlib.Set Stdlib.Prop;

Expand Down
2 changes: 2 additions & 0 deletions HOL.lp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// higher-order logic

require open Stdlib.Set;

constant symbol ⤳ : Set → Set → Set; // \leadsto
Expand Down
2 changes: 2 additions & 0 deletions Impred.lp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// impredicativity (quantification on propositions)

require open Stdlib.Set Stdlib.Prop;

symbol o : Set;
Expand Down
3 changes: 2 additions & 1 deletion List.lp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Library on polymorphic lists
// polymorphic lists

/*
following https://github.com/math-comp/math-comp/blob/master/mathcomp/ssreflect/seq.v

seq.v documentation
Expand Down
3 changes: 2 additions & 1 deletion NaryFun.lp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* n-ary functions and relations
// n-ary functions and relations

/*
following "Generic Level Polymorphic N-ary Functions" by Guillaume
Allais (TyDe 2019). */

Expand Down
3 changes: 2 additions & 1 deletion Nat.lp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Library on natural numbers
// unary natural numbers

/*
following https://github.com/math-comp/math-comp/blob/master/mathcomp/ssreflect/ssrnat.v

Documentation of ssrnat.v
Expand Down
3 changes: 2 additions & 1 deletion Pos.lp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Positive binary integers following Rocq stdlib
// positive binary integers

// following Rocq stdlib
require open Stdlib.Nat Stdlib.Comp;

inductive ℙ : TYPE ≔
Expand Down
2 changes: 1 addition & 1 deletion Prod.lp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ begin reflexivity end;

symbol prodExt [a b] (x: τ (a × b)) : π (x = (x ₁) ‚ (x ₂)) ≔
begin
assume a; refine ind_Prod a (λ b x, x = (x ₁) ‚ (x ₂)) _; reflexivity
assume a b; refine ind_Prod (λ x, x = (x ₁) ‚ (x ₂)) _; reflexivity
end;

opaque symbol eq_pair [a b] (x y: τ (a × b)) :
Expand Down
2 changes: 1 addition & 1 deletion Prop.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Propositional logic
// propositional logic

constant symbol Prop : TYPE;

Expand Down
2 changes: 2 additions & 0 deletions PropExt.lp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// propositional extensionality

/***************************************************************************
This file provides an axiom and various theorems for propositional equality.
The theorems are grouped into sections by theme:
Expand Down
5 changes: 2 additions & 3 deletions Quotient.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Quotient types
// quotient types

require open Stdlib.Eq;

Expand All @@ -12,7 +12,6 @@ notation ⫽ infix 30;
rule τ (_ ⫽ $R) ↪ Quot $R;

symbol class [a] r ≔ @cl a r;
symbol ind_quot [a] ≔ ind_Quot a;

symbol sound [a] (r:Rel a) x y: π(r x y) → π (class r x = class r y);

Expand All @@ -31,7 +30,7 @@ begin
{ assume x x' xx'; set p ≔ λ x y y' yy', hf x x (hr x) y y' yy';
change π(lift r (f x) (p x) d = lift r (f x') (p x') d);
set q ≔ λ d, lift r (f x) (p x) d = lift r (f x') (p x') d;
change π(q d); apply ind_quot r q _ d;
change π(q d); apply ind_Quot q _ d;
assume y; simplify; apply hf {apply xx'} {apply hr} }
end;

Expand Down
6 changes: 3 additions & 3 deletions QuotientExample.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// example of quotient: integers
// example of quotient type

require open Stdlib.Nat Stdlib.Prod Stdlib.Quotient;

Expand Down Expand Up @@ -38,7 +38,7 @@ require open Stdlib.FOL;

opaque symbol +_com a b: π (+ a b = + b a) ≔
begin
refine ind_quot intrel (λ a, `∀ b, + a b = + b a) _; assume x;
refine ind_quot intrel (λ b, + (class intrel x) b = + b (class intrel x)) _; assume y;
refine ind_Quot (λ a, `∀ b, + a b = + b a) _; assume x;
refine ind_Quot (λ b, + (class intrel x) b = + b (class intrel x)) _; assume y;
apply sound; simplify; rewrite addnC (x ₁); rewrite addnC (y ₂); reflexivity
end;
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
Standard library of [Lambdapi](https://github.com/Deducteam/lambdapi)
=====================================================================

- `Prop`: propositional logic
- `Eq`: equality
- `Set`: set codes for polymorphism
- `FOL`: typed first-order logic
- `Bool`: booleans
- `Nat`: natural numbers
- `List`: polymorphic lists
- `Classic`: classical logic
- `Comp`: comparison datatype
- `Conj`: varyadic conjunction
- `Coprod`: disjoint sum
- `DepProd`: dependent pairs
- `Disj`: varyadic disjunction
- `Epsilon`: Hilbert choice operator
- `Eq`: polymorphic Leibniz equality
- `ExtraRules`: additional rewrite rules derived from proved equalities
- `FOL`: polymorphic first-order logic
- `FunExt`: require open Stdlib.Eq Stdlib.HOL;
- `HOL`: higher-order logic
- `Impred`: impredicativity (quantification on propositions)
- `List`: polymorphic lists
- `NaryFun`: n-ary functions and relations
- `Nat`: unary natural numbers
- `Option`: option type
- `Pos`: positive binary integers
- `Prod`: Cartesian product
- `PropExt`: propositional extensionality
- `Prop`: propositional logic
- `QuotientExample`: example of quotient type
- `Quotient`: quotient types
- `Set`: type of type codes
- `String`: builtin string type
- `Subset`: subset types
- `Tactic`: tactic type
- `Univ`: universes
- `Z`: binary integers

The libraries on natural numbers and polymorphic lists follow the
corresponding Coq SSReflect libraries:

- [ssrnat.v](https://github.com/math-comp/math-comp/blob/master/mathcomp/ssreflect/ssrnat.v)

- [seq.v](https://github.com/math-comp/math-comp/blob/master/mathcomp/ssreflect/seq.v)
corresponding Rocq SSReflect libraries [ssrnat.v](https://github.com/math-comp/math-comp/blob/master/mathcomp/ssreflect/ssrnat.v)
and [seq.v](https://github.com/math-comp/math-comp/blob/master/mathcomp/ssreflect/seq.v). The library on integers follow the one of the Rocq standard library.

Installation with Opam
----------------------

```
opam repository -a --set-default add lambdapi https://github.com/deducteam/opam-lambdapi-repos
itory.git # once
opam repository -a --set-default add lambdapi https://github.com/deducteam/opam-lambdapi-repository.git # once
opam install lambdapi-stdlib
```

Usage in Lambdapi
-----------------

```
require open Stdlib.Prop Stdlib.Set Stdlib.FOL Stdlib.Nat /* ... */;
require open Stdlib.Nat;
```

Compilation from the sources
Expand Down
2 changes: 1 addition & 1 deletion Set.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type of set codes for quantifying over sets (polymorphism)
// type of type codes

constant symbol Set : TYPE;

Expand Down
2 changes: 1 addition & 1 deletion String.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// builtin type of strings
// builtin string type

require open Stdlib.Set;

Expand Down
2 changes: 1 addition & 1 deletion Subset.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Subset types: a dependent pair of an element and a proof
// subset types

require open Stdlib.FOL Stdlib.Eq;

Expand Down
2 changes: 1 addition & 1 deletion Tactic.lp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// define a type representing Lambdapi tactics
// tactic type

require open Stdlib.String Stdlib.Univ;

Expand Down
2 changes: 2 additions & 0 deletions Univ.lp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// universes

require open Stdlib.Set Stdlib.Prop;

constant symbol L:TYPE;
Expand Down
3 changes: 2 additions & 1 deletion Z.lp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Binary integers (following Rocq stdlib)
// binary integers

// following Rocq stdlib
require open Stdlib.Pos;

inductive ℤ : TYPE ≔ // \BbbZ
Expand Down
6 changes: 6 additions & 0 deletions summary
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

for f in `ls *.lp`
do
echo "- \`${f%.lp}\`: `head -n1 $f | sed -e 's/^\/\/ //'`"
done
Loading