Comments (6)
First thing I tried is writing mutual induction schemes, as described in https://coq.inria.fr/refman/user-extensions/proof-schemes.html
However I was unable to get it to work, but maybe it is possible to fix this by diving deeper into writing custom schemes.
from quotedpatternmatchingproof.
In the end I just refactored the definitions and proofs to the following form
Inductive Term :=
| Lit : nat -> Term
| Lam : label -> TType -> Term -> Term
| Var : label -> Term
| App : Term -> Term -> Term
which in general seems much better suited for proofs.
(The original form was slightly inspired by how I would go about writing an interpreter for STLC and wanting to have a separate type for values, that for example would be held in an environment etc. But for proofs it seems to have more drawbacks than advantages)
from quotedpatternmatchingproof.
As we need mutually recursive types to correctly handle #15 we need to revisit this issue.
from quotedpatternmatchingproof.
Careful analysis of Coq's manual leads to:
Scheme typedterm_mutualind := Induction for typedterm Sort Prop
with term_mutualind := Induction for term Sort Prop.
Which indeed yields a mutually inductive scheme.
At first I didn't know how to use it however, finally I figured out I need to do induction term using SchemeName
.
from quotedpatternmatchingproof.
This was still not enough, as this scheme has 2 predicates: one for terms and one for typed terms. This predicates are independent and the proof has to somehow 'connect' them.
This is however difficult inside a complex proof, and just using the scheme directly always lead to one of the predicates being left as an existential variable and very hard to instantiate with something reasonable.
from quotedpatternmatchingproof.
I carefully inspected the form of the generated scheme:
typedterm_mutualind
: forall (P : typedterm -> Prop) (P0 : term -> Prop),
(forall u : term, P0 u -> forall t : type, P (u : t)) ->
(forall n : nat, P0 (Nat n)) ->
(forall x : DeBruijnIndex, P0 (VAR x)) ->
(forall (argT : type) (ebody : typedterm),
P ebody -> P0 (Lam argT ebody)) ->
(forall e1 : typedterm,
P e1 -> forall e2 : typedterm, P e2 -> P0 (App e1 e2)) ->
(forall e : typedterm, P e -> P0 (Lift e)) ->
(forall e : typedterm, P e -> P0 (Quote e)) ->
(forall e : typedterm, P e -> P0 (Splice e)) ->
forall t : typedterm, P t
I thought that it may be reasonable to replace the predicate P in such a way that we have forall u T, P0 u -> P (u : T)
(so that if P0 holds for all untyped terms, we prove that P holds for all typed terms, ignoring their type).
This led to manually writing the following induction scheme:
Lemma syntactic :
forall (P : typedterm -> Prop),
(forall n : nat, forall T : type, P (Nat n : T)) ->
(forall x : DeBruijnIndex, forall T : type, P (VAR x : T)) ->
(forall (argT : type)
(ebody : typedterm),
P ebody -> forall T : type, P (Lam argT ebody : T)) ->
(forall e1 : typedterm,
P e1 ->
forall e2 : typedterm,
P e2 -> forall T : type, P (App e1 e2 : T)) ->
(forall e : typedterm,
P e -> forall T : type, P (Lift e : T)) ->
(forall e : typedterm,
P e -> forall T : type, P (Quote e : T)) ->
(forall e : typedterm,
P e -> forall T : type, P (Splice e : T)) ->
forall t : typedterm, P t.
Which now has only one predicate so it can be automatically instantiated correctly by Coq with induction term using syntactic
.
I have proved this scheme using the automatically generated one.
I was concerned that 'ignoring' the types in the predicate may be an issue, but for now it works well in the proofs. I think it should be enough, as we can get the type information from 'other places'.
For example we have a lemma:
Lemma AscribedTypeIsCorrect : forall G L t T T',
G ⊢(L) (t : T) ∈ T' -> T = T'.
which allows us to narrow down the ascribed type to the actual type, so that having the forall
in the induction scheme is not an issue.
from quotedpatternmatchingproof.
Related Issues (17)
- Non-trivially recursive functions termination HOT 1
- Extend STLC with a boxed type and lift
- Add quotes and splices HOT 2
- Add pattern matching HOT 2
- Add fix operator HOT 1
- Extend STLC with explicit type annotations HOT 1
- Ids instance for explicitly typed terms HOT 5
- Multiple binders in patterns HOT 3
- Inductive predicates vs Fixpoints
- Notation
- Hints for tactics HOT 2
- Case analysis of equality HOT 3
- Handling names / binders HOT 14
- Order of quantifiers in theorems proven by induction
- Quickly applying a hypothesis with a quantifier. HOT 1
- STLC with autosubst
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quotedpatternmatchingproof.