Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b4d6b43
[core] generalize context from term |-> type to term |-> 'a
gares Jun 9, 2020
0c56e85
[opam] depend on Elpi
gares Jun 9, 2020
32bb531
[elpi] minimalistic integration
gares Jun 9, 2020
c58aef2
xxx
gares Jan 27, 2023
2f8e741
Generate lp files with requires automatically
sacerdot Jan 27, 2023
dc51dfe
zip everything
sacerdot Jan 27, 2023
5d965df
fix
sacerdot Jan 27, 2023
6f28826
all rewriting rules generate typed abstractions
sacerdot Jan 27, 2023
f7a1559
print unfinished goals
gares Jan 27, 2023
bc1a626
existing instance in coq/dk/lp
gares Jan 27, 2023
be3dba1
[ctx] unbind option to keep non dependent entries in ctx
gares Jan 28, 2023
8fe5dbe
keep all ctx entries
gares Jan 28, 2023
09de08a
run elpi tc on all metas
gares Jan 28, 2023
6a62980
[open] open "tc" modules; to enable only TC from modules
gares Jan 28, 2023
27f40ce
example
gares Jan 28, 2023
ffa5809
no more need for filtering out #directives
sacerdot Jan 28, 2023
a805895
Use sequential to make Leq-checking more complete with or rules
sacerdot Jan 28, 2023
aadb90b
fixup open tc
gares Jan 28, 2023
67e852a
bind some stuff
gares Jan 28, 2023
483a789
skip non-tc-instantiation problems
sacerdot Jan 28, 2023
e884094
slightly more interesting example
sacerdot Jan 28, 2023
b597256
use coercions to itnroduce cast from Type[1] to Type[2] in test
sacerdot Jan 28, 2023
b03c354
Bugs fixed on meta instantiation + second example working
sacerdot Jan 28, 2023
9917bf2
a sort of lp.unif branched, but it does not work as the one of Coq
sacerdot Jan 28, 2023
37c1730
added (but commented) dubious injective symbols for lambdapi unification
sacerdot Jan 29, 2023
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
Empty file added dune-workspace
Empty file.
1,307 changes: 1,307 additions & 0 deletions lambdap.elpi

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lambdapi.opam
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ depends: [
"cmdliner" {>= "1.1.0"}
"stdlib-shims" {>= "0.1.0"}
"odoc" {with-doc}
"elpi" { >= "1.16.6" & < "1.17.0" }
]
build: [
["dune" "subst"] {dev}
Expand Down
Binary file added out/Coq__Arith__Arith__base.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Between.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Compare__dec.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__EqNat.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Factorial.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Gt.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Le.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Lt.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Minus.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Mult.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__PeanoNat.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Peano__dec.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Plus.dk.gz
Binary file not shown.
Binary file added out/Coq__Arith__Wf__nat.dk.gz
Binary file not shown.
Binary file added out/Coq__Bool__Bool.dk.gz
Binary file not shown.
Binary file added out/Coq__Bool__BoolEq.dk.gz
Binary file not shown.
Binary file added out/Coq__Bool__DecBool.dk.gz
Binary file not shown.
Binary file added out/Coq__Bool__IfProp.dk.gz
Binary file not shown.
Binary file added out/Coq__Classes__CMorphisms.dk.gz
Binary file not shown.
Binary file added out/Coq__Classes__CRelationClasses.dk.gz
Binary file not shown.
Binary file added out/Coq__Classes__Equivalence.dk.gz
Binary file not shown.
Binary file added out/Coq__Classes__Init.dk.gz
Binary file not shown.
Binary file added out/Coq__Classes__Morphisms.dk.gz
Binary file not shown.
Binary file added out/Coq__Classes__Morphisms__Prop.dk.gz
Binary file not shown.
Binary file added out/Coq__Classes__RelationClasses.dk.gz
Binary file not shown.
Binary file added out/Coq__Classes__SetoidTactics.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Datatypes.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Decimal.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Logic.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Logic__Type.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Nat.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Notations.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Peano.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Prelude.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Specif.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Tactics.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Tauto.dk.gz
Binary file not shown.
Binary file added out/Coq__Init__Wf.dk.gz
Binary file not shown.
Binary file added out/Coq__Logic__Decidable.dk.gz
Binary file not shown.
Binary file added out/Coq__Logic__EqdepFacts.dk.gz
Binary file not shown.
Binary file added out/Coq__Logic__Eqdep__dec.dk.gz
Binary file not shown.
Binary file added out/Coq__Logic__ProofIrrelevanceFacts.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZAdd.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZAddOrder.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZAxioms.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZBase.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZBits.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZDiv.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZGcd.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZLog.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZMul.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZMulOrder.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZOrder.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZParity.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZPow.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZProperties.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NatInt__NZSqrt.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NAdd.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NAddOrder.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NAxioms.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NBase.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NBits.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NDiv.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NGcd.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NLcm.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NLog.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NMaxMin.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NMulOrder.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NOrder.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NParity.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NPow.dk.gz
Binary file not shown.
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NSqrt.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__Natural__Abstract__NSub.dk.gz
Binary file not shown.
Binary file added out/Coq__Numbers__NumPrelude.dk.gz
Binary file not shown.
Binary file added out/Coq__Program__Basics.dk.gz
Binary file not shown.
Binary file added out/Coq__Program__Tactics.dk.gz
Binary file not shown.
Binary file added out/Coq__Relations__Operators__Properties.dk.gz
Binary file not shown.
Binary file added out/Coq__Relations__Relation__Definitions.dk.gz
Binary file not shown.
Binary file added out/Coq__Relations__Relation__Operators.dk.gz
Binary file not shown.
Binary file added out/Coq__Relations__Relations.dk.gz
Binary file not shown.
Binary file added out/Coq__Setoids__Setoid.dk.gz
Binary file not shown.
Binary file added out/Coq__Structures__Equalities.dk.gz
Binary file not shown.
Binary file added out/Coq__Structures__GenericMinMax.dk.gz
Binary file not shown.
Binary file added out/Coq__Structures__Orders.dk.gz
Binary file not shown.
Binary file added out/Coq__Structures__OrdersFacts.dk.gz
Binary file not shown.
Binary file added out/Coq__Structures__OrdersTac.dk.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions out/add_requires.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

dk dep $@ | cut -d ":" -f 2 | sed "s/ /\n/g" | grep ".dko$" | sed "s/\(.*\)\.dko$/require coq.\\1 as \\1;/g"
22 changes: 22 additions & 0 deletions out/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#set -e
#set -x

#export PATH=$PWD/_build/install/default/bin:$PATH

for i in *.dk.gz; do rm -f `basename $i .gz`; gunzip -k $i; done
touch cupicef.dk

for i in *.dk; do
LPFILE=`basename $i .dk`.lp
# add the flags
cat header > $LPFILE
# add the exports
./add_requires.sh $i >> $LPFILE
lambdapi export -o lp $i >> $LPFILE ;
done
cp cupicef.lp.handmade cupicef.lp

rm *.dk

lambdapi check -c Coq__Init__Peano.lp
373 changes: 373 additions & 0 deletions out/cupicef.lp.handmade

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions out/header
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flag "eta_equality" on;
2 changes: 2 additions & 0 deletions out/lambdapi.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package_name=coq
root_path=coq
53 changes: 53 additions & 0 deletions out/test.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require coq.cupicef as bios;
require coq.Coq__Relations__Relation__Definitions;
require coq.Coq__Classes__RelationClasses as x;
require coq.Coq__Init__Logic as y;

open "tc" coq.Coq__Classes__RelationClasses;

flag "print_implicits" on; // default is off
flag "print_contexts" on; // default is off
flag "print_domains" on; // default is off
flag "print_meta_types" on; // default is

type y.eq;
type x.reflexivity;

// ENRICO: bug in readback of terms in the query,the context is empty
// We hack it with a section variable
symbol A : bios.Univ (bios.type (bios.s bios.z));

// cast from Type[1] to Type[2]
coerce_rule coerce (bios.Univ (bios.{|type|} (bios.s bios.z))) (bios.Univ (bios.{|type|} (bios.s (bios.s bios.z)))) $X ↪ (bios.cast (bios.axiom (bios.{|type|} (bios.s bios.z)))
(bios.axiom (bios.{|type|} (bios.s (bios.s bios.z))))
(bios.univ (bios.{|type|} (bios.s bios.z))
(bios.axiom (bios.{|type|} (bios.s bios.z))) bios.I)
(bios.univ (bios.{|type|} (bios.s (bios.s bios.z)))
(bios.axiom (bios.{|type|} (bios.s (bios.s bios.z)))) bios.I)
bios.I
$X);

//debug +i;
//debug +e;
//debug +u;

type x.reflexivity A (y.eq A) _ _;
type x.match____RewriteRelation _ A (y.eq A) _ _ _;

/*
type
x.reflexivity A (y.eq
(

bios.cast
(bios.axiom (bios.{|type|} (bios.s bios.z)))
(bios.axiom (bios.{|type|} (bios.s (bios.s bios.z))))
(bios.univ (bios.{|type|} (bios.s bios.z))
(bios.axiom (bios.{|type|} (bios.s bios.z))) bios.I)
(bios.univ (bios.{|type|} (bios.s (bios.s bios.z)))
(bios.axiom (bios.{|type|} (bios.s (bios.s bios.z))))
bios.I)
_

A)) _ _;
*/
1 change: 1 addition & 0 deletions src/cli/lambdapi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let check_cmd : Config.t -> int option -> string list -> unit =
let run _ =
let open Timed in
Config.init cfg;
Elpi_handle.init ();
(* We save time to run each file in the same environment. *)
let time = Time.save () in
let handle file =
Expand Down
2 changes: 2 additions & 0 deletions src/common/error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ let handle_exceptions : (unit -> unit) -> unit = fun f ->
try f () with
| Fatal(None, msg) -> exit_with "%s" msg
| Fatal(Some(p), msg) -> exit_with "[%a] %s" Pos.pp p msg
(*
| e -> exit_with "Uncaught [%s]." (Printexc.to_string e)
*)
14 changes: 13 additions & 1 deletion src/core/ctxt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ open Term
open Lplib
open Timed

(** [unbind ctx a def b] returns a triple [(x,t,new_ctx)] such that [(x,t)] is
an unbinding of [b] (in the sense of [Bindlib.unbind]) and [new_ctx] is an
extension of context [ctx] with the assumption that [x] has type [a] (only
if [x] occurs in [t], or [~keep:true]).
If [def] is of the form [Some(u)], the context also
registers the term [u] as the definition of variable [x]. *)
let unbind : ?keep:bool -> 'a actxt -> 'a -> term option -> tbinder ->
tvar * term * 'a actxt =
fun ?(keep=false) ctx a def b ->
let (x, t) = Bindlib.unbind b in
(x, t, if keep || Bindlib.binder_occur b then (x, a, def) :: ctx else ctx)

(** [type_of x ctx] returns the type of [x] in the context [ctx] when it
appears in it, and
@raise [Not_found] otherwise. *)
let type_of : tvar -> ctxt -> term = fun x ctx ->
let type_of : tvar -> 'a actxt -> 'a = fun x ctx ->
let (_,a,_) = List.find (fun (y,_,_) -> Bindlib.eq_vars x y) ctx in a

(** [def_of x ctx] returns the definition of [x] in the context [ctx] if it
Expand Down
2 changes: 1 addition & 1 deletion src/core/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
(public_name lambdapi.core)
(synopsis "LambdaPi interactive theorem prover [core]")
(modules :standard)
(libraries lambdapi.common lambdapi.lplib pratter bindlib why3))
(libraries lambdapi.common lambdapi.lplib pratter bindlib why3 elpi))
Loading