Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coq lang #38

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cb093c7
begin support for coq in ML
lucaspena Dec 12, 2019
a721d74
more support for coq in ML. inductive defs parse
lucaspena Dec 13, 2019
7bb9ed5
coq: Fix parsing of underscores
nishantjr Dec 14, 2019
1a294cc
add more parsing rules and Logic examples
Dec 14, 2019
e9245c3
minor
Dec 14, 2019
13c1df5
coq-lang: parsing more logic, can parse exists and AndComm
lucaspena Dec 16, 2019
7155865
coq-lang: format sentences (newline)
lucaspena Dec 16, 2019
2413968
t/Logic.v: added eq inductive type
lucaspena Dec 17, 2019
2d5da27
coq-driver: begin translating inductive defs to ml
lucaspena Dec 18, 2019
40317e2
coq-driver: begin translating Definitions
lucaspena Dec 19, 2019
2dd0fac
coq-driver: translating some definitions/terms
lucaspena Dec 19, 2019
8e88b50
coq-driver: more translating coq term to pattern. AndComm mostly tran…
lucaspena Jan 10, 2020
93bb94e
add mu, translating fix
lucaspena Jan 13, 2020
ba95017
coq-driver: translate binders from match clauses
lucaspena Jan 13, 2020
54749f9
translating ind defs
lucaspena Jan 15, 2020
12b53bc
parsing Logic.v
lucaspena Jan 27, 2020
0c60745
kore-lang: for aml: application is Pattern(Patterns)
lucaspena Jan 27, 2020
46b712b
cleanup
lucaspena Feb 5, 2020
b802ed3
remove coq tests besides Logic and nat_ind, add expeted output for those
lucaspena Feb 5, 2020
8585a5d
coq tests in own directory
lucaspena Feb 11, 2020
74f3c0b
use named axioms
lucaspena Feb 11, 2020
968a224
set variables no longer sorted
lucaspena Feb 11, 2020
5c2e2ce
create goals for typing coq defs. add result type to definitions
lucaspena Feb 12, 2020
b2bd250
change format for terms having type in v files
lucaspena Feb 14, 2020
3090652
coq-driver: translate forall to pi
lucaspena Feb 17, 2020
61881a2
change type-check to typecheck
lucaspena Feb 17, 2020
85e8229
placeholder for typecheck strategy
lucaspena Feb 17, 2020
33e7f10
encode output type in coq syntax rather than comment
lucaspena Feb 24, 2020
2eb94c1
begin typecheck strategy
lucaspena Feb 24, 2020
974aac4
typecheck works for simple examples
lucaspena Feb 27, 2020
182db6b
typecheck: minor change
lucaspena Mar 5, 2020
5b13db3
add coq rules
Mar 10, 2020
724644b
global environments, begin well-typing defs
lucaspena Mar 11, 2020
7011393
add basic Coq typing rules
Mar 26, 2020
477dde5
add authors
Mar 26, 2020
895d236
wording of comment in W-Local-Assum
lucaspena Mar 26, 2020
1de1820
parsing more terms in coq translation
lucaspena Mar 30, 2020
07675a4
coq-lang, coq-driver: handling more constructs for generated verbose …
lucaspena Apr 13, 2020
3deae83
more parsing
lucaspena Apr 19, 2020
10c7863
coq rules: conversion rules
lucaspena Apr 21, 2020
74f3359
coq_rules: more on conversion rules
lucaspena Apr 24, 2020
7331f17
coq_rules: subtyping rules
lucaspena May 20, 2020
e93c40e
coq_rules: Inductive Definitions
lucaspena May 22, 2020
bff2495
coq_rules: correctness rules
lucaspena Jun 3, 2020
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
1 change: 1 addition & 0 deletions prover/build
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ other_md_files = [ 'lang/coq-lang.md'
, 'strategies/replace-evar-with-func-constant.md'
, 'strategies/simplification.md'
, 'strategies/search-bound.md'
, 'strategies/typecheck.md'
, 'strategies/smt.md'
, 'strategies/unfolding.md'
, 'utils/load-named.md'
Expand Down
1 change: 1 addition & 0 deletions prover/drivers/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module DRIVER-BASE
imports STRATEGY-UNFOLDING
imports STRATEGY-KNASTER-TARSKI
imports STRATEGY-REPLACE-EVAR-WITH-FUNC-CONSTANT
imports STRATEGY-TYPECHECK
imports SYNTACTIC-MATCH-RULES
imports VISITOR
imports PATTERN-LENGTH
Expand Down
7 changes: 3 additions & 4 deletions prover/drivers/coq-driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ module DRIVER-COQ
</declarations>

// Add symbol (of sort Term) and equality axiom corresponding to each definition
rule Definition ID BINDERs : TYPE1 := TERM (* hasType TYPE2 *) . => Definition ID := TERM (* hasType TYPE2 *) .
rule <k> Definition ID := TERM (* hasType TYPE *) .
rule <k> Definition ID : TYPE := TERM .
=> .K
...
</k>
Expand All @@ -53,7 +52,7 @@ module DRIVER-COQ
<active> true:Bool </active>
<parent> .K </parent>
<claim> \type(CoqIdentToSymbol(ID), CoqTermToPattern(TYPE)) </claim>
<strategy> type-check </strategy>
<strategy> typecheck </strategy>
<expected> success </expected>
<local-context> .Bag </local-context>
<trace> .K </trace>
Expand Down Expand Up @@ -89,7 +88,7 @@ module DRIVER-COQ
rule CoqTermToPattern(LN:LowerName) => CoqIdentToSymbol(LN)
rule CoqTermToPattern(#token("Prop", "CoqSort")) => StringToSort("Term")
rule CoqTermToPattern(fun BINDERs => TERM) => \lambda { CoqBindersToPatterns(BINDERs) } CoqTermToPattern(TERM)
rule CoqTermToPattern(forall BINDERs, TERM) => \forall { CoqBindersToPatterns(BINDERs) } CoqTermToPattern(TERM)
rule CoqTermToPattern(forall BINDERs, TERM) => \pi { CoqBindersToPatterns(BINDERs) } CoqTermToPattern(TERM)
rule CoqTermToPattern(match Ts with .CoqEquations end) => \bottom()
rule CoqTermToPattern(match Ts with (MP:CoqMultPattern => TM:CoqTerm) | EQs end) =>
\or( #flattenOrs(
Expand Down
4 changes: 2 additions & 2 deletions prover/lang/coq-lang.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ module COQ
| CoqInductive
// | CoqCoInductive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to keep these commented lines?

syntax CoqSentences ::= List{CoqSentence, ""} [klabel(CoqSentences), format(%1%n%2 %3)]
syntax CoqDefinition ::= "Definition" CoqIdent ":=" CoqTerm "(*" "hasType" CoqTerm "*)" "."
| "Definition" CoqIdent CoqBinders ":" CoqTerm ":=" CoqTerm "(*" "hasType" CoqTerm "*)" "."
syntax CoqDefinition ::= "Definition" CoqIdent ":" CoqTerm ":=" CoqTerm "."
// | "Definition" CoqIdent CoqBinders ":" CoqTerm ":=" CoqTerm "."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here?


syntax CoqInductive ::= "Inductive" CoqIndBody "."
syntax CoqIndBody ::= CoqIdent CoqBinders ":" CoqTerm ":=" CoqIndCases
Expand Down
3 changes: 2 additions & 1 deletion prover/prover.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ requires "strategies/intros.k"
requires "strategies/knaster-tarski.k"
requires "strategies/matching.k"
requires "strategies/search-bound.k"
requires "strategies/typecheck.k"
requires "strategies/simplification.k"
requires "strategies/smt.k"
requires "strategies/reflexivity.k"
Expand Down Expand Up @@ -70,7 +71,7 @@ module STRATEGIES-EXPORTED-SYNTAX
"in:" AxiomName ","
"vars:" VariableNames ","
"with:" Patterns ")"
| "type-check"
| "typecheck"

syntax RewriteDirection ::= "->" | "<-"

Expand Down
12 changes: 12 additions & 0 deletions prover/strategies/typecheck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# typecheck - for Coq terms

```k
module STRATEGY-TYPECHECK
imports PROVER-CORE
imports STRATEGIES-EXPORTED-SYNTAX

rule <strategy> typecheck => noop ...
</strategy>

endmodule
```
15 changes: 8 additions & 7 deletions prover/t/coq-tests/Logic.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ Inductive nat : Prop :=
Z : nat
| S : (forall (x : nat), nat) .

Definition not := fun (A: Prop) => (forall (x : A), False) (* hasType (forall (x : Prop), Prop) *) .
Definition not : (forall (x : Prop), Prop) b :=
fun (A: Prop) => (forall (x : A), False) .

Definition iff (A B : Prop) : Prop :=
(and (forall (x : A), B)) (forall (y : B), A) (* hasType (forall (x : Prop), (forall (y : Prop), Prop)) *) .
Definition iff : (forall (x : Prop), (forall (y : Prop), Prop)) :=
(and (forall (x : A), B)) (forall (y : B), A) .

Definition IF_then_else (P Q R : Prop) : Prop :=
(or (and P Q)) (and (not P) R) (* hasType (forall (x : Prop), (forall (y : Prop), (forall (z : Prop), Prop))) *) .
Definition IF_then_else : (forall (x : Prop), (forall (y : Prop), (forall (z : Prop), Prop))) :=
(or (and P Q)) (and (not P) R) .

Inductive ex1 (A : Type) (P : forall (x : A), Prop) : Prop :=
ex_intro1 : forall (x : A), forall (y : (P x)), ex1 A P .
Expand All @@ -27,12 +28,12 @@ Inductive ex2 (A : Type) (P : forall (x : A), Prop) : Prop :=
Inductive ex4 (A : Type) (P : forall (x : A), Prop) : Prop :=
ex_intro4 : forall (x : A), forall (y : (P x)), @ ex4 A P .

Definition AndComm :=
Definition AndComm : (forall (A B : Prop), (forall (c : and A B), and B A)) :=
fun (A B : Prop) (H : and A B) =>
match H with
conj H0 H1 => conj H1 H0
end
(* hasType (forall (A B : Prop), (forall (c : and A B), and B A)) *) .
.

// Inductive and (A B : Prop) : Prop :=
// conj : forall (x : A), forall (y : B), and A B .
Expand Down
10 changes: 5 additions & 5 deletions prover/t/coq-tests/nat_ind.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Inductive nat : Type := Z : nat | S : forall (x : nat), nat .

// axiom \type(Z(), nat())

Definition nat_ind :=
Definition nat_ind : (forall (P : (forall (x : nat), Prop)),
(forall (y : P 0),
(forall (l : (forall (n : nat),
(forall (y : P n), P (S n)))),
(forall (n : nat), P n)))) :=
fun (P : (forall (n : nat), Prop)) (f : P 0) (f0 : forall (n : nat), (forall (x : P n), P (S n))) =>
fix F (n : nat) := match n with
Z => f
| S n0 => f0 n0 (F n0)
end
(*
hasType (forall (P : (forall (x : nat), Prop)),
(forall (y : P 0), (forall (l : (forall (n : nat), (forall (y : P n), P (S n)))), (forall (n : nat), P n))))
*)
.

// forall P : nat -> Prop, P 0 -> (forall n : nat, P n -> P (S n)) -> forall n : nat, P n
Expand Down