/pyttr

Python implementation of TTR

Primary LanguageJupyter Notebook

This is the beginnings of a TTR implementation in Python 3.4.3.  Run
the examples in the files example-records.py and example-types.py

This implementation covers a core of TTR, including:
     Basic types
     Ptypes (types constructed with predicates and their arguments)
     Meet (intersection) types
     Join (union) types
     Function types
     List types
     Record types
     String types
     Judging (assigning objects to types)
     Querying (asking whether an object is of a type)
     Adding witness conditions to types
     Creating objects of types
     Subtyping
     Type merging (including asymmetric type merging)
     Possibilities (types may have different witnesses in different
     		   possibilities)
     
  
7th April 2017

The query method in ttrtypes will now add an object to the witness_cache that it
computes as a witness on the basis of the witness conditions.

Rudimentary support for projections from ttr variables in ttrtypes: lazy objects
like LazyObj(['r','.','x'])

Added in_poss method to functions in ttrtypes to restrict the domain type to a
given possibility

Judging an object to be of a meet type (ttrtypes) will now judge that object to
be of the two component types of the meet type. 

A preliminary implementation of neural TTR has been added (neurons, nu, example-neurons, example-nu) together with a Jupiter notebook which is partially developed corresponding to example-nu (nu.ipynb). 
     

2nd June 2017

Fixed bug with Possibility in ttrtypes.py
Improved show-method for possibilities

Changed subst and eval methods for LazyObj so that left recursive lazy
objects will be correctly evaluated.

A preliminary jupyter notebook (lspc.ipynb) has been added with
examples from the paper Interfacing Language, Spatial Perception and
Cognition in Type Theory with Records by Simon Dobnik and Robin Cooper
(to appear in Journal of Language Modelling).


9th June 2017

Added animat.ipynb -- a very simple sheep that learns to associate
types of the environment with types of actions

Added switch neurons to neural TTR
Added query_last_n to Type_n -- queries whether the end segment of the
history matches the activity pattern associated with the type.
(query_n queries whether any segment of the history matches.)


9th August 2017

Improved the display of network histories for neural ttr (nu.ipynb) as
defined in neurons.py.  Neurons which are not present at a time step
are now represented with '*' (rather than '2').

27th February 2018

Introduced a preliminary 'show_latex' facility. (Thanks to Mehdi
Ghanimifard.)

Changed the witness condition for singleton types so that the equality
required is not Python equality but equality of the show-string.

Added notebooks (preliminary) corresponding to the old example files:
example-records.py and example-types.py.  The new files are
records.ipynb and types.ipynb.

6th September 2018

Improvements to the handling of possibilities.

Added a facility for adding witness conditions for ptypes which are
associate with the predicate used to construct the ptype.  See the
notebook 'ptype_learn.ipynb' for some examples.

12th September 2018

Fixed minor bugs in ttr-overview.ipynb


13th September 2018

Fixed minor bug in types.ipynb


7th October 2018

Minor improvements to utils.py (substitute, show_latex)

24th November 2018

Improvements to lspc.ipynb using the new treatment of possibilities
and the facility for learning witness functions for predicates (see
6th September 2018).

Improvements to the treatment of subscripts and labels in the LaTeX
display.

Adjustments to ttr-overview.ipynb.


6th Aug 2019

Slight change to the way strings are displayed by show and show_latex.

Added notebook ttr-overview-esslli2019.ipynb


9th Nov 2019

Added notebook ttr-overview-aics2019.ipynb

Corrected KPlusStringType so that witnesses of such types are concatenations of strings of their base type (rather than strings of strings of their base type).

Added methods startswith and startswith_recursive to TTRString


5th July 2020

Added notebook ttr-overview-wesslli2020.ipynb

KPlusStringType.show() now adds parentheses to show the scope of the
'+' when needed.  Similarly for the LaTeX display.

In record types, path lists in dependent fields are displayed in the
LaTeX rendering with '<...>' rather than '[...]', thus following the
standard written notation.

6th Nov 2020

Notebook ttr-overview-aics2020.ipynb


17 February 2021

Corrected a bug in the querying of hypothetical objects.


9 March 2021

Improved the handling of non-well founded witness conditions.  See the
notebook NWFwitconds.ipynb

Corrected some bugs relating to string types.


1 April 2021

Initial partial implementation of probabilistic TTR including basic
types, meet types, join types and record types with conditional
probabilities.  See the notebook probttr.ipynb.


17 May 2021

Added sampling for non-specific querying of record types.  See the
notebook probttr.ipynb.


6 June 2021

Corrected an error in the computation of conjoint and disjoint probabilities.

Added "double-stroke" probabilities.  See the notebook probttr.ipynb.


8 June 2021

Added negation to probttr.  See the notebook probttr.ipynb.


6 Nov 2021

Added ttr-overview-aics2021.ipynb and probttr-overview-aics2021.ipynb

Corrected a problem in the treatment of possibilities

Modified probttr.ipynb to eliminate warnings


24 Apr 2024
Fixed a bug in probttrtypes.py pointed out by Bill Noble