def option_printer(state: State, s: SortDecl, elt: str, args: List[str]) -> str: assert len(args) == 2 is_none_name, value_name = args is_none = get_relation(is_none_name) value = get_function(value_name) option_sort = UninterpretedSort(None, s.name) assert not is_none.mutable and not value.mutable and \ is_none.arity == [option_sort] and value.arity == [option_sort] elt_sort = syntax.get_decl_from_sort(value.sort) none: Optional[str] = None for tup, b in state.rel_interp[is_none]: if b: assert none is None and len(tup) == 1 none = tup[0] assert none is not None if elt == none: return 'None' else: the_value: Optional[str] = None for tup, res in state.func_interp[value]: assert len(tup) == 1 if tup[0] == elt: assert the_value is None the_value = res assert the_value is not None return 'Some(%s)' % (logic.print_element(state, elt_sort, the_value))
def entry_to_str(e: LogEntry, wf: bool) -> str: entry_strs = [ value_to_str(e.values[idx], sort) for idx, sort in enumerate(value_sorts) ] if not wf: entry_strs.insert( 0, 'index |-> %s' % logic.print_element(state, index_sort, e.index)) return '[%s]' % (', '.join(entry_strs))
def set_printer(state: State, s: SortDecl, elt: str, args: List[str]) -> str: assert len(args) == 1 member_name = args[0] member = get_relation(member_name) assert len(member.arity) == 2 and not member.mutable set_sort = UninterpretedSort(None, s.name) assert member.arity[1] == set_sort item_sort = member.arity[0] item_sort_decl = syntax.get_decl_from_sort(item_sort) items: Set[str] = set() for tup, b in state.rel_interp[member]: assert len(tup) == 2 item, set_id = tup if b and set_id == elt: items.add(item) return '{%s}' % (','.join(sorted(logic.print_element(state, item_sort_decl, x) for x in items)),)
def value_to_str(vs: List[str], sort: SortDecl) -> str: return '%s |-> %s' % ( sort.name, logic.print_element(state, sort, vs[0]) if len(vs) == 1 else '[%s]' % (', '.join(logic.print_element(state, sort, v) for v in vs)))