jaccokrijnen / plutus-cert

0 stars 2 forks source link

Can we avoid neutral terms for built-ins? #9

Open jaccokrijnen opened 1 year ago

jaccokrijnen commented 1 year ago

This would simplify the dynamic semantics. Neutral terms are necessary because of built-in functions. Perhaps we could hypothesize that all built-ins have a valid implementation:

⟦⋅⟧ : Builtin τ -> Term τ

And add:

  ⟦B⟧ =[j]=> v
  ------------- E-Builtin
   B  =[j]=> v

Question is: is it a sensible axiom/assumption? Can all built-ins be expressed within Fωμ? Consider

jaccokrijnen commented 1 year ago

Manuel suggested that

⟦⋅⟧ : Builtin τ -> Term τ

Can be implemented with η-expansion, i.e.:

⟦b⟧ = (\x ... z -> b x ... z)

I think this would still require an evaluation rule for fully-applied built-ins

jaccokrijnen commented 1 year ago

Currently, we have BuiltinMeanings.compute_defaultfun, which interprets (most but not all) fully-applied built-ins, and

  | E_NeutralApplyFull: forall nv1 v2 v,
      fully_applied (Apply nv1 v2) -> 
      compute_defaultfun (Apply nv1 v2) = Datatypes.Some v ->
      Apply nv1 v2 =[1]=> v
  | E_NeutralTyInstFull: forall nv1 v T,
      fully_applied (TyInst nv1 T) -> 
      compute_defaultfun (TyInst nv1 T) = Datatypes.Some v ->                                                                                                                                                      
      TyInst nv1 T =[1]=> v
jaccokrijnen commented 11 months ago

A simpler way would be to represent built-ins as always fully applied, and eta expand when converting haskell AST to coq AST.

For example:

BuiltIn AddInteger ======> \x. \y. BuiltIn AddInteger [x, y]

Michael didn't see any problems with representing built-ins in Coq this way. Except if we are interesting in costing, which we are not.