Skip to content

Instantly share code, notes, and snippets.

View jorendorff's full-sized avatar

Jason Orendorff jorendorff

View GitHub Profile

Wolf, Goat, and Cabbage In Two Styles!!

Introduction (1'09")

There's a classic story. Once upon a time there was a farmer named "you", (slide: farmer) and this farmer went to a fair and bought some cabbages (slide: cabbages "SCORE!") and a goat

@jorendorff
jorendorff / cabbages.als
Last active November 15, 2022 17:52
Alloy code for a talk, "Wolf, Goat, & Cabbages In Two Styles!!", at !!Con West 2020
open util/ordering[Snapshot]
abstract sig Object {
eats: set Object
}
one sig Wolf extends Object {}
one sig Goat extends Object {}
one sig Cabbages extends Object {}
one sig Boat extends Object {}
from jsparagus import runtime
from jsparagus.runtime import Nt, ErrorToken
actions = [
# 0. <empty>
# InitNt(goal=Nt('Script')) ::= · Script
{'var': 2, ';': 3, 'if': 4, 'continue': 5, 'break': 6, 'return': 7, 'with': 8, 'throw': 9, 'try': 10, 'debugger': 11, 'class': 12, '{': 13, 'do': 14, 'while': 15, 'for': 16, 'switch': 17, 'Name': 18, 'NameWithEscape': 18, 'let': 19, 'static': 18, 'implements': 18, 'interface': 18, 'package': 18, 'private': 18, 'protected': 18, 'public': 18, 'as': 18, 'async': 20, 'from': 18, 'get': 18, 'of': 18, 'set': 18, 'target': 18, 'function': 21, 'const': 22, 'yield': 23, 'new': 24, 'await': 25, '(': 26, 'super': 27, 'import': 28, 'this': 29, 'RegularExpressionLiteral': 30, 'NullLiteral': 31, 'BooleanLiteral': 32, 'NumericLiteral': 33, 'BigIntLiteral': 34, 'StringLiteral': 35, '[': 36, 'NoSubstitutionTemplate': 37, 'TemplateHead': 38, 'delete': 39, 'void': 40, 'typeof': 41, '+': 42, '-': 43, '~': 44, '!': 45, '++': 46, '--': 47, None: -1},
# 1. <empty>
#
from jsparagus import runtime
from jsparagus.runtime import Nt, ErrorToken
actions = [
# 0. <empty>
# InitNt(goal=Nt('expr')) ::= · expr
{'-': 1, 'NUM': 2, 'VAR': 3, '(': 4},
# 1. "-"
# unary ::= "-" · unary

This was written in response to: https://twitter.com/hillelogram/status/1227118562373963776


People mix the predicate "If a directed graph is a tree, it's a DAG" with the proposition "For all directed graphs, if a directed graph is a tree, it's a DAG".

First, for simplification: let's assume we're talking here about all graphs in the world with up to 10 nodes to be able to enumerate them. Also, note that we're talking about directed, not undirected, graphs.

To prove the proposition "For all..." is true, which is "(For graph G1, if it's a tree, it's a DAG) AND (For graph G2, if it's a tree, it's a DAG) AND...", since it's ANDs, we need to prove (For graph G1, if...) is true and we need to prove (For graph G2, if...) is true, ... etc.

// ================================================================================================
// Types that describe stack slots
struct Value;
struct NewObjectValue;
struct PackedArrayValue;
struct FunctionValue;
struct StringValue;
struct UninitializedMagic;
diff --git a/js/src/vm/Opcodes.h b/js/src/vm/Opcodes.h
--- a/js/src/vm/Opcodes.h
+++ b/js/src/vm/Opcodes.h
@@ -10,38 +10,199 @@
#include "mozilla/Attributes.h"
#include <stddef.h>
/*

Wolf, Goat, and Cabbage In Two Styles!!

Abstract

What is the abstract for your talk? This should be a short, engaging blurb that advertises what your talk will be about. For some examples of good !!Con abstracts, you could look at the accepted talks from previous !!Cons (http://bangbangcon.com/speakers.html, http://bangbangcon.com/west/2019/speakers). Of course, you need not feel limited to what's been done in the past; these examples are just to get you started. If your talk is accepted, you'll have a chance to edit your abstract before we make it public.

Would you like to learn two new programming languages, both delightfully strange but for good reasons? What if the comparison sheds light on how different programming languages think about time and data?

Inform 7 is an unusual programming language that looks a bit like English prose. Alloy is a model specification language that looks kind of like advanced math. They are languages from two different worlds, but both are about objects and t

if input.is_some() {
let tx = tx.clone();
let mut input = BufReader::new(input.unwrap());
::std::thread::spawn(
move || {
let mut buf = String::new();
// TODO read_until pegs CPU at 100% without a sleep there
while let Ok(len) = ::std::io::BufRead::read_line(&mut input, &mut buf) {
if len == 0 {
break;
Script :
StatementList?
Module :
StatementList?
StatementList :
Statement
StatementList Statement