diff --git a/all_defs.exh b/all_defs.exh new file mode 100644 index 0000000..0c216ac --- /dev/null +++ b/all_defs.exh @@ -0,0 +1,13 @@ +add: ((number number) number (define add (lambda (a b) (if a (add (pred a) (succ b)) b)))) +mul: ((number number) number (define mul (lambda (a b) (if a (add (mul (pred a) b) b) 0)))) +logical_not: ((number) number (define logical_not (lambda (a) (if a 0 (succ a))))) +logical_or: ((number number) number (define logical_or (lambda (a b) (if a a b)))) +logical_and: ((number number) number (define logical_and (lambda (a b) (if a b 0)))) +logical_nand: ((number number) number (define logical_nand (lambda (a b) (logical_not (logical_and b a))))) +logical_xor: ((number number) number (define logical_xor (lambda (a b) (if a (logical_not b) b)))) +logical_parity: ((list) number (define logical_parity (lambda (l) (if l (logical_xor (logical_parity (cdr l)) (car l)) 0)))) +index: ((list number) S-expression (define index (lambda (l a) (if a (index (cdr l) (pred a)) (car l))))) +length: ((list) number (define length (lambda (l) (if l (succ (length (cdr l))) 0)))) +sum: ((list) number (define sum (lambda (l) (if l (add (sum (cdr l)) (car l)) 0)))) +power: ((number number) number (define power (lambda (a b) (if b (mul (power a (pred b)) a) 1)))) +factorial: ((number) number (define factorial (lambda (n) (if n (mul (factorial (pred n)) n) 1)))) diff --git a/defs.exh b/defs.exh index 0c216ac..3791fb4 100644 --- a/defs.exh +++ b/defs.exh @@ -1,13 +1 @@ -add: ((number number) number (define add (lambda (a b) (if a (add (pred a) (succ b)) b)))) -mul: ((number number) number (define mul (lambda (a b) (if a (add (mul (pred a) b) b) 0)))) -logical_not: ((number) number (define logical_not (lambda (a) (if a 0 (succ a))))) -logical_or: ((number number) number (define logical_or (lambda (a b) (if a a b)))) -logical_and: ((number number) number (define logical_and (lambda (a b) (if a b 0)))) -logical_nand: ((number number) number (define logical_nand (lambda (a b) (logical_not (logical_and b a))))) -logical_xor: ((number number) number (define logical_xor (lambda (a b) (if a (logical_not b) b)))) -logical_parity: ((list) number (define logical_parity (lambda (l) (if l (logical_xor (logical_parity (cdr l)) (car l)) 0)))) -index: ((list number) S-expression (define index (lambda (l a) (if a (index (cdr l) (pred a)) (car l))))) length: ((list) number (define length (lambda (l) (if l (succ (length (cdr l))) 0)))) -sum: ((list) number (define sum (lambda (l) (if l (add (sum (cdr l)) (car l)) 0)))) -power: ((number number) number (define power (lambda (a b) (if b (mul (power a (pred b)) a) 1)))) -factorial: ((number) number (define factorial (lambda (n) (if n (mul (factorial (pred n)) n) 1)))) diff --git a/doc/2014-12-18_python-meetup/main.tex b/doc/2014-12-18_python-meetup/main.tex index 1d9e99d..a3aa0c8 100644 --- a/doc/2014-12-18_python-meetup/main.tex +++ b/doc/2014-12-18_python-meetup/main.tex @@ -114,7 +114,38 @@ \end{pythoncode*} } +\defverbatim[colored]\codeLengthExampleA{ +\begin{pythoncode*}{fontsize=\scriptsize} +@UTBP +def length(l): +""" +length(()) == 0 +""" +\end{pythoncode*} +} +\defverbatim[colored]\codeLengthExampleB{ +\begin{pythoncode*}{fontsize=\scriptsize} +@UTBP +def length(l): +""" +length(()) == 0 +length((2,)) == 1 +""" +\end{pythoncode*} +} + +\defverbatim[colored]\codeLengthExampleC{ +\begin{pythoncode*}{fontsize=\scriptsize} +@UTBP +def length(l): +""" +length(()) == 0 +length((2,)) == 1 +length((2, 3)) == 2 +""" +\end{pythoncode*} +} @@ -211,7 +242,7 @@ \subsection{Pero\ldots ¿cómo?} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{\scshape Discusión sesuda} +\section{\scshape Premisas} \subsection{Toda función se puede escribir de forma recursiva} \begin{frame}{Funciones: todas recursivas} @@ -277,68 +308,138 @@ \subsection{Toda función recursiva puede representarse mediante un árbol} ) │ └── l else: return 0 └── 0 \end{Verbatim} - \end{frame} -\subsection{Brain-body-niche} -\begin{frame}{Brain-body-niche} +\subsection{Los árboles se pueden enumerar en order creciente de complejidad \pause} +\begin{frame}[fragile] + \frametitle{Árboles: enumerables} +\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`$=3\catcode`_=8}] + [\textbf{1}] [ \textbf{2} ] [ \textbf{3} ] + r r r r + └── l └── b ├── l0 + └── l └── l1 +\end{Verbatim} + +\pause + +\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`$=3\catcode`_=8}] + [ \textbf{4} ] + r r r + └── b0 └── b0 ├── b0 + └── b1 ├── l0 │ └── l0 + └── l0 └── l1 └── l1 + r r + ├── b0 ├── l0 + └── b1 ├── l1 + └── l0 └── l2 +\end{Verbatim} -\begin{itemize} - \item \emph{No need to dissociate brain from body or body from environment} - \item \emph{Who needs internal representations when you're part of the system you're trying to represent?} - \item \emph{No computation} -\end{itemize} -\end{frame} -\subsection{Multifractal fractality} -\begin{frame}{Multifractal fractality} -\begin{itemize} - \item \emph{Power-laws imply complexity. Exponents, exponents!} - \item \emph{Forget about computation. Let's talk about energy flow.} - \item \emph{No computation} -\end{itemize} \end{frame} -\section{\scshape Criticism} -\subsection{Criticism} -\begin{frame}{Criticism} - Approach taken by three of the articles +\section{\scshape Ingredientes} +\subsection{Ingredientes} +\begin{frame}{Ingredientes} \begin{itemize} - \item \emph{Detect 1/f noise in time series of human performance} + \item Árboles \pause \emph{(déjà vu)} \pause \textcolor{gray}{\scriptsize(de jabugo)} \pause + \item Tipos: \pause \begin{itemize} - \item Competing models? - \item Frailty of the measure + \item Números naturales no negativos \pause + \item Listas, posiblemente anidadas \end{itemize} - \item \emph{The presence of 1/f noise implies an interaction dominant system} + \item Operaciones \begin{itemize} - \item Other systems can also generate 1/f noise - \item Generation of 1/f noise in complex systems depends on specific circumstances + \item Funciones aritméticas (e.g. \texttt{succ}) + \item Manipulación de listas (e.g. \texttt{cdr}) + \item Formas especiales (\texttt{if}) \end{itemize} - \item \emph{Cognition is interaction-dominant and traditional approaches should be abandoned} + \item Constantes \begin{itemize} - \item The complex systems approach should explain something that traditional approaches cannot explain. - \item Model instead of ``solving'' by dropping terms like self-organized criticality + \item \texttt{0} + \item \texttt{()} \end{itemize} \end{itemize} \end{frame} -\subsection{Piles of rice and salt} -\begin{frame}{Piles of rice and salt} +\section{\scshape Ejemplo de uso} +\subsection{Ejemplo} +\begin{frame}[fragile] + \frametitle{Ejemplo de uso -- Longitud de una lista} + \begin{columns} + \begin{column}{.50\linewidth} + \begin{block} + \codeLengthExampleA + \end{block} + \end{column}\pause + \begin{column}{.50\linewidth} + \begin{verbatim} +define +├── length +└── lambda + ├── l + └── 0 + \end{verbatim} + \end{column} + \end{columns}\pause + + \begin{columns} + \begin{column}{.50\linewidth} + \begin{block} + \codeLengthExampleB + \end{block} + \end{column}\pause + \begin{column}{.50\linewidth} + \begin{verbatim} +define +├── length +└── lambda + ├── l + └── if + ├── l + ├── list? + │ └── l + └── 0 + \end{verbatim} + \end{column} + \end{columns} \end{frame} -\subsection{Does this apply to us?} -\begin{frame}{Does this apply to us?} - I don't think much of the discussion applies to us (the original Frontiers article should not have confronted Wagenmakers and Friston and we \emph{do} talk about components as well as their interactions), however\ldots - \begin{itemize} - \item Do we make our best effort to disprove criticality? Competing hypotheses. - \item Do we try to model something other than 1/f? - \end{itemize} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\subsection{Ejemplo} +\begin{frame}[fragile] + \frametitle{Ejemplo de uso -- Longitud de una lista} + \begin{columns} + \begin{column}{.50\linewidth} + \begin{block} + \codeLengthExampleC + \end{block} + \end{column}\pause + \begin{column}{.50\linewidth} + \begin{verbatim} +define +├── length +└── lambda + ├── l + └── if + ├── l + ├── succ + │ └── length + │ └── cdr + │ └── l + └── 0 + \end{verbatim} + \end{column} + \end{columns} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + \section{\scshape Doubts} \subsection{Doubts} \begin{frame}{Doubts} diff --git a/ex_presentacion.py b/ex_presentacion.py new file mode 100644 index 0000000..4c5d505 --- /dev/null +++ b/ex_presentacion.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from utbp import UTBP + +@UTBP +def length(l): + """ + length(()) == 0 + """ + +if __name__ == '__main__': + l = (4, 4, 4) + n = length(l) + print 'La longitud de la lista l es', n, 'porque el código de length es:' + print length