Skip to content
This repository has been archived by the owner on May 20, 2018. It is now read-only.

Embedded terms #174

Merged
merged 51 commits into from
Dec 20, 2015
Merged

Embedded terms #174

merged 51 commits into from
Dec 20, 2015

Conversation

robrix
Copy link
Contributor

@robrix robrix commented Dec 13, 2015

  • Implements the embedding of Swift values into Manifold terms.
  • Adds a String module which embeds Swift’s strings into Manifold.
  • Embed functions producing terms?
  • Evaluate functions at runtime.
  • Test that the String.toList function behaves correctly.
  • Add a String.fromList function.
  • Test that the String.fromList function behaves correctly.
  • Fixes Evaluation (& substitution?) produces ill-typed normal forms #175.

type: String.ref --> List[Character.ref],
value: () => { (string: Term) -> Term in
guard case let .Embedded(value as Swift.String, _, _) = string.out else { return ("toList" as Term)[string] }
return toTerm(value.characters)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect.

We evaluate this function when the value term is constructed, not when the defined toList term is evaluated. Therefore, it always fails the guard clause, produces itself in neutral form, and diverges during evaluation.

@robrix
Copy link
Contributor Author

robrix commented Dec 18, 2015

String.fromList introduces some difficulty:

  1. Embedded terms can close over variables without making them visible to maxBoundVariable. This means that Embedded terms can hide their operands when used within constructed lambdas.
  2. As a partial workaround, substitution of a variable i can be skipped inside the body of a lambda binding the same variable, i.e. the addition of shadowing semantics. (This is only a partial workaround because Embedded terms can be applied to both the inner and outer bound variables which might incorrectly be assigned the same binding.)
  3. The partial workaround described above causes Sigma.second to be judged to be ill-typed. Evidently it depends on shadowing.

@robrix robrix changed the title [WIP] Embedded terms Embedded terms Dec 20, 2015
@robrix
Copy link
Contributor Author

robrix commented Dec 20, 2015

This branch exposes (but does not introduce) #178 by means of its fix to #175. We can resolve this by means of unification, but that will be done on another branch.

robrix added a commit that referenced this pull request Dec 20, 2015
@robrix robrix merged commit 77e7c6d into master Dec 20, 2015
@robrix robrix deleted the embedded-terms branch December 20, 2015 02:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant