Open rudynicolop opened 2 years ago
I think my original proposal to correctly deal with type nesting was not faithful to the spec.
A better definition of Expr.t
to enforce type nesting would be:
Inductive t : bool -> Set :=
| TBool : t true
| TBit : N -> t true
| TError : t false
| TStruct : forall b, list (string * t b) -> t b
| THeader : list (string * t true) -> t false
Semantics
p4cub
should be usingTarget.v
. This relates to #324 .Syntax
tags_t
should be removed fromp4cub
.list
data-type: structs, headers, & tuples which generate multiple proof goals that are nearly identical There should only be one constructor for this with a flag or witness to distinguish them.Scope
based notation system.p4cub
, for both type & expression variables.Dependently-typed Syntax??
It may be preferable to enforce some properties of
p4cub
programs in their construction.For example, there is a
proper_nesting
forp4cub
expression typesExpr.t
predicate inP4cub/Syntax/Auxilary.v
to enforce which types may enclose others, mainly to prevent headers from being nested too deeply. It's possible to enforce this in the definition ofExpr.t
as:Another issue with
p4cub
proofs is the need to defined induction principles for them & any predicate or relation defined for them. This is becausep4cub
terms are defined in terms of lists. To avoid this it's possible to redefineExpr.t
as:But this allows one to form ill-formed terms such as
TTupleCons TBool TBool
.To prevent this
Expr.t
may depend upon abool
indicating whether or not the constructor is atuple
/list
constructor:Furthermore it is possible to define
p4cub
terms as well-typed by construction. The signature forp4cub
expressionsExpr.e
would be adjusted to:Constructing proofs of
gamma x = Some t
may be annoying, so a de Bruijn style may better suit this change:p4cub
programs well-typed by construction would ensure type preservation by the definition of their dynamic semantics.This approach will complicate any
p4cub
functions, particularly those that must construct them. The most difficult will be thep4light -> p4cub
compiler, which by definition must be a verified type checker forp4light
.I think combining many of these changes would overall help the
P4cub
code. There would be no need to manually defined boilerplate induction principles and other predicates. While including propositions in the definitions ofp4cub
terms entails more overhead, ideally these subgoals may solved viarefine
& automation, & likely will not be extracted to OCaml.Refactoring
p4cub
may be guided by this framework by @ericthewry & @jnfoster.