From 0c476e92e1807928ffb30864126076ef4c6a0821 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Tue, 13 Feb 2024 20:00:02 -0700 Subject: add all the stuff --- src/scenes/boolean_algebra_lambda.meta | 5 + src/scenes/boolean_algebra_lambda.tsx | 49 ++++++++++ src/scenes/boolean_encoding.meta | 5 + src/scenes/boolean_encoding.tsx | 42 +++++++++ src/scenes/church_encoding.meta | 5 + src/scenes/church_encoding.tsx | 41 ++++++++ src/scenes/currying.meta | 5 + src/scenes/currying.tsx | 114 +++++++++++++++++++++++ src/scenes/currying_detail.meta | 5 + src/scenes/currying_detail.tsx | 155 +++++++++++++++++++++++++++++++ src/scenes/dna.meta | 5 + src/scenes/dna.tsx | 22 +++++ src/scenes/function_dna.meta | 5 + src/scenes/function_dna.tsx | 91 ++++++++++++++++++ src/scenes/further.meta | 5 + src/scenes/further.tsx | 43 +++++++++ src/scenes/generalized.tsx | 6 +- src/scenes/impostor.meta | 5 + src/scenes/impostor.tsx | 134 ++++++++++++++++++++++++++ src/scenes/index.ts | 58 +++++++++--- src/scenes/lambda_recursion.meta | 5 + src/scenes/lambda_recursion.tsx | 45 +++++++++ src/scenes/lambda_reduction_example.meta | 5 + src/scenes/lambda_reduction_example.tsx | 47 ++++++++++ src/scenes/me.tsx | 8 +- src/scenes/parttwo.meta | 5 + src/scenes/parttwo.tsx | 16 ++++ src/scenes/pros_cons.meta | 5 + src/scenes/pros_cons.tsx | 61 ++++++++++++ src/scenes/questions.meta | 5 + src/scenes/questions.tsx | 16 ++++ src/scenes/recursion.meta | 5 + src/scenes/recursion.tsx | 36 +++++++ src/scenes/reductions.meta | 5 + src/scenes/reductions.tsx | 40 ++++++++ src/scenes/substitution.meta | 5 + src/scenes/substitution.tsx | 45 +++++++++ src/scenes/the_lambda_calculus.meta | 5 + src/scenes/the_lambda_calculus.tsx | 40 ++++++++ 39 files changed, 1181 insertions(+), 18 deletions(-) create mode 100644 src/scenes/boolean_algebra_lambda.meta create mode 100644 src/scenes/boolean_algebra_lambda.tsx create mode 100644 src/scenes/boolean_encoding.meta create mode 100644 src/scenes/boolean_encoding.tsx create mode 100644 src/scenes/church_encoding.meta create mode 100644 src/scenes/church_encoding.tsx create mode 100644 src/scenes/currying.meta create mode 100644 src/scenes/currying.tsx create mode 100644 src/scenes/currying_detail.meta create mode 100644 src/scenes/currying_detail.tsx create mode 100644 src/scenes/dna.meta create mode 100644 src/scenes/dna.tsx create mode 100644 src/scenes/function_dna.meta create mode 100644 src/scenes/function_dna.tsx create mode 100644 src/scenes/further.meta create mode 100644 src/scenes/further.tsx create mode 100644 src/scenes/impostor.meta create mode 100644 src/scenes/impostor.tsx create mode 100644 src/scenes/lambda_recursion.meta create mode 100644 src/scenes/lambda_recursion.tsx create mode 100644 src/scenes/lambda_reduction_example.meta create mode 100644 src/scenes/lambda_reduction_example.tsx create mode 100644 src/scenes/parttwo.meta create mode 100644 src/scenes/parttwo.tsx create mode 100644 src/scenes/pros_cons.meta create mode 100644 src/scenes/pros_cons.tsx create mode 100644 src/scenes/questions.meta create mode 100644 src/scenes/questions.tsx create mode 100644 src/scenes/recursion.meta create mode 100644 src/scenes/recursion.tsx create mode 100644 src/scenes/reductions.meta create mode 100644 src/scenes/reductions.tsx create mode 100644 src/scenes/substitution.meta create mode 100644 src/scenes/substitution.tsx create mode 100644 src/scenes/the_lambda_calculus.meta create mode 100644 src/scenes/the_lambda_calculus.tsx (limited to 'src/scenes') diff --git a/src/scenes/boolean_algebra_lambda.meta b/src/scenes/boolean_algebra_lambda.meta new file mode 100644 index 0000000..385a68c --- /dev/null +++ b/src/scenes/boolean_algebra_lambda.meta @@ -0,0 +1,5 @@ +{ + "version": 0, + "timeEvents": [], + "seed": 2667185663 +} \ No newline at end of file diff --git a/src/scenes/boolean_algebra_lambda.tsx b/src/scenes/boolean_algebra_lambda.tsx new file mode 100644 index 0000000..2639461 --- /dev/null +++ b/src/scenes/boolean_algebra_lambda.tsx @@ -0,0 +1,49 @@ +import { Layout, makeScene2D } from "@motion-canvas/2d"; +import { + Direction, + beginSlide, + createRef, + slideTransition, +} from "@motion-canvas/core"; +import { LambdaReducer } from "../components/lambda_reducer"; +import { baseDefinitions } from "../utils/lambdas"; + +export default makeScene2D(function* (view) { + const lambdaReducer = createRef(); + const layout = createRef(); + + view.add( + + ); + yield* slideTransition(Direction.Right); + yield* beginSlide("Boolean Reductions"); + + for (const term of [ + "((false one) zero)", + "((true one) zero)", + "(((if true) one) zero)", + ]) { + yield* layout().opacity(0, 0.5); + layout().add( + + ); + yield* layout().opacity(1, 0.5); + + yield* beginSlide("Next Reduction " + term); + for (let i = 0; !lambdaReducer().isDone(); i++) { + yield* lambdaReducer().step(0.5); + yield* beginSlide(term + " Next Step " + i); + } + layout().removeChildren(); + } +}); diff --git a/src/scenes/boolean_encoding.meta b/src/scenes/boolean_encoding.meta new file mode 100644 index 0000000..8f4d744 --- /dev/null +++ b/src/scenes/boolean_encoding.meta @@ -0,0 +1,5 @@ +{ + "version": 0, + "timeEvents": [], + "seed": 2394701117 +} \ No newline at end of file diff --git a/src/scenes/boolean_encoding.tsx b/src/scenes/boolean_encoding.tsx new file mode 100644 index 0000000..60a0ea9 --- /dev/null +++ b/src/scenes/boolean_encoding.tsx @@ -0,0 +1,42 @@ +import { Layout, Txt, makeScene2D } from "@motion-canvas/2d"; +import { + Direction, + beginSlide, + createRef, + slideTransition, +} from "@motion-canvas/core"; +import { theme } from "../theme"; + +const boolE = [ + "true = λ t . λ f . t", + "false = λ t . λ f . f", + "if = λ b . λ x . λ y . b x y", + "not = λ b . b false true", + "and = λ b . λ c . b c false", +]; + +export default makeScene2D(function* (view) { + const numerals = createRef(); + + view.add( + + + Boolean Encoding + + + + ); + + yield* slideTransition(Direction.Right); + yield* beginSlide("The Lambda Calculus - Boolean Encoding"); + + for (const bool of boolE) { + yield* numerals().text(numerals().text() + "\n\n" + bool, 1); + yield* beginSlide("boolean - " + bool); + } +}); diff --git a/src/scenes/church_encoding.meta b/src/scenes/church_encoding.meta new file mode 100644 index 0000000..638e825 --- /dev/null +++ b/src/scenes/church_encoding.meta @@ -0,0 +1,5 @@ +{ + "version": 0, + "timeEvents": [], + "seed": 533121975 +} \ No newline at end of file diff --git a/src/scenes/church_encoding.tsx b/src/scenes/church_encoding.tsx new file mode 100644 index 0000000..70bafe4 --- /dev/null +++ b/src/scenes/church_encoding.tsx @@ -0,0 +1,41 @@ +import { Layout, Txt, makeScene2D } from "@motion-canvas/2d"; +import { + Direction, + beginSlide, + createRef, + slideTransition, +} from "@motion-canvas/core"; +import { theme } from "../theme"; + +const churchNumerals = [ + "0 = λ f . λ x . x (no application of f)", + "1 = λ f . λ x . f x (one application of f)", + "2 = λ f . λ x . f (f x) (two applications of f)", + "succ = λ n . λ f . λ x . f ((n f) x)", +]; + +export default makeScene2D(function* (view) { + const numerals = createRef(); + + view.add( + + + Church Encoding + + + + ); + + yield* slideTransition(Direction.Right); + yield* beginSlide("The Lambda Calculus - Church Encoding"); + + for (const numeral of churchNumerals) { + yield* numerals().text(numerals().text() + "\n\n" + numeral, 1); + yield* beginSlide("substitution - " + numeral); + } +}); diff --git a/src/scenes/currying.meta b/src/scenes/currying.meta new file mode 100644 index 0000000..1dd71f1 --- /dev/null +++ b/src/scenes/currying.meta @@ -0,0 +1,5 @@ +{ + "version": 0, + "timeEvents": [], + "seed": 2262306570 +} \ No newline at end of file diff --git a/src/scenes/currying.tsx b/src/scenes/currying.tsx new file mode 100644 index 0000000..01ce24a --- /dev/null +++ b/src/scenes/currying.tsx @@ -0,0 +1,114 @@ +import { Video, Layout, makeScene2D } from "@motion-canvas/2d"; +import { + Direction, + all, + beginSlide, + createRef, + slideTransition, +} from "@motion-canvas/core"; +import { PEOPLE, Person, PersonI } from "../components/person"; +import { birthdayCardFn, valentineCardFn } from "./generalized"; +import { CardI } from "./birthday_letters"; +import { FunctionBox } from "../components/function_box"; +import curry from "../../public/img/curry.mp4"; + +export const cardGeneratorsFor = ( + person: PersonI, +): ((type: string) => () => CardI) => { + const birthdayCardGenerator = () => birthdayCardFn(person); + const valentineCardGenerator = () => valentineCardFn(person); + + const messageType = (type: string) => { + switch (type) { + case "valentine": + return valentineCardGenerator; + case "birthday": + return birthdayCardGenerator; + } + throw new Error(type + " not implemented"); + }; + + return messageType; +}; + +export const cardGeneratorsForSource = `const cardGeneratorsFor = (person: PersonI): ((type: string) => () => CardI) => { + const birthdayCardGenerator = () => birthdayCardFn(person); + const valentineCardGenerator = () => valentineCardFn(person); + + const generatorForType = (type: string) => { + switch (type) { + case "valentine": + return valentineCardGenerator; + case "birthday": + return birthdayCardGenerator; + } + + throw new Error(type + " not implemented"); + }; + + return generatorForType; +};`; + +export default makeScene2D(function* (view) { + const box = createRef(); + const vid = createRef