import term from term import Term as T import fields import termtypes pair_type = termtypes.new_type("the type of pairs") termtypes.set_type(pair_type, T.pair) def to_pair(asker, p): return (fields.get(asker, first(), p), fields.get(asker, second(), p)) first = fields.named_binding( "the function that maps a pair to its first element", T.pair.head, 'a' ) second = fields.named_binding( "the function that maps a pair to its second element", T.pair.head, 'b' )
import fields from frozendict import frozendict import askers import termtypes #Representing terms-------------------------------- #TODO I could probably make Representation a function, #then make a decorator that turns any such function into a "held" #version... quoted_term = term.simple("a term with head [head] head and bindings [bindings]", 'head', 'bindings') term_type = termtypes.new_type("the type of terms") termtypes.set_type(term_type, quoted_term) head = fields.named_binding( "the function that maps a term to its head", quoted_term.head, 'head' ) bindings = fields.named_binding( "the function that maps a term to its bindings", quoted_term.head, 'bindings' ) #referent_of = term.simple("the function that maps a term to the referent of [s] in that term's head", "s") #FIXME this is a dumb hack to cut down on computational time