Skip to content

Commit

Permalink
Generate an axiom for each function signature
Browse files Browse the repository at this point in the history
  • Loading branch information
tothtamas28 committed Jan 17, 2025
1 parent 86fe32e commit afcc15b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pyk/src/pyk/k2lean4/k2lean4.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
from .model import (
Alt,
AltsFieldVal,
Axiom,
Ctor,
ExplBinder,
ImplBinder,
Inductive,
Instance,
InstField,
Expand Down Expand Up @@ -207,6 +209,23 @@ def inj(subsort: str, supersort: str, x: str) -> Term:

return res

def func_module(self) -> Module:
commands = [self._transform_func(func) for func in self.defn.functions]
return Module(commands=commands)

def _transform_func(self, func: str) -> Axiom:
ident = self._symbol_ident(func)
decl = self.defn.symbols[func]
sort_params = [var.name for var in decl.symbol.vars]
param_sorts = [sort.name for sort in decl.param_sorts]
sort = decl.sort.name

binders = []
if sort_params:
binders.append(ImplBinder(sort_params, Term('Type')))
binders.extend(ExplBinder((f'x{i}',), Term(sort)) for i, sort in enumerate(param_sorts))
return Axiom(ident, Signature(binders, Term(f'Option {sort}')))


def _param_sorts(decl: SymbolDecl) -> list[str]:
from ..utils import check_type
Expand Down

0 comments on commit afcc15b

Please sign in to comment.