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

Preevaluate constant terms, even the ones under abstraction #667

Open
SeungheonOh opened this issue Apr 10, 2024 · 3 comments
Open

Preevaluate constant terms, even the ones under abstraction #667

SeungheonOh opened this issue Apr 10, 2024 · 3 comments

Comments

@SeungheonOh
Copy link
Collaborator

evalTerms pre-evaluates a given terms, but anything that is behind a lambda abstraction will not get evaluated. So, for example,

> l = plam $ \_-> plength # (pconstant $ [1, 2,3:: Integer] :: Term s (PBuiltinList PInteger))

> (Right (Right es, _, _)) = evalTerm def l

> (Right esc) = compile def es

> esc
Script {unScript = Program {_progAnn = (), _progVer = Version () 1 0 0, _progTerm = LamAbs () (DeBruijn {dbnIndex = 0}) (Apply () (Apply () (Apply () (LamAbs () (DeBruijn {dbnIndex = 0}) (Apply () (LamAbs () (DeBruijn {dbnIndex = 0}) (Apply () (Var () (DeBruijn {dbnIndex = 2})) (LamAbs () (DeBruijn {dbnIndex = 0}) (Apply () (Apply () (Var () (DeBruijn {dbnIndex = 2})) (Var () (DeBruijn {dbnIndex = 2}))) (Var () (DeBruijn {dbnIndex = 1})))))) (LamAbs () (DeBruijn {dbnIndex = 0}) (Apply () (Var () (DeBruijn {dbnIndex = 2})) (LamAbs () (DeBruijn {dbnIndex = 0}) (Apply () (Apply () (Var () (DeBruijn {dbnIndex = 2})) (Var () (DeBruijn {dbnIndex = 2}))) (Var () (DeBruijn {dbnIndex = 1})))))))) (LamAbs () (DeBruijn {dbnIndex = 0}) (LamAbs () (DeBruijn {dbnIndex = 0}) (LamAbs () (DeBruijn {dbnIndex = 0}) (Force () (Apply () (Apply () (Apply () (Force () (Force () (Builtin () ChooseList))) (Var () (DeBruijn {dbnIndex = 1}))) (Delay () (Var () (DeBruijn {dbnIndex = 2})))) (Delay () (Apply () (Apply () (Var () (DeBruijn {dbnIndex = 3})) (Apply () (Apply () (Builtin () AddInteger) (Var () (DeBruijn {dbnIndex = 2}))) (Constant () (Some (ValueOf DefaultUniInteger 1))))) (Apply () (Force () (Builtin () TailList)) (Var () (DeBruijn {dbnIndex = 1}))))))))))) (Constant () (Some (ValueOf DefaultUniInteger 0)))) (Constant () (Some (ValueOf (DefaultUniApply DefaultUniProtoList DefaultUniInteger) [1,2,3]))))}}

Need either some function that can evaluate constant terms behind lambda abstractions or some mechanism to keep constant terms always evaluated structurally

@SeungheonOh
Copy link
Collaborator Author

Some idea:

Add plamEval that will evaluate body before constructing actual abstraction.

@L-as
Copy link
Member

L-as commented Apr 14, 2024

You want to make this issue on the Plutus repository.

@SeungheonOh
Copy link
Collaborator Author

Ideally, they make some option in CEK machine so that it can evaluate UPLC with some unbound variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants