Forgot password?
 Create new account
View 92|Reply 0

Penrose - 通过纯文本键入数学符号来创建图表

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2023-4-3 10:59:11 |Read mode
penrose.cs.cmu.edu/
一个集合论的例子:

它由以下 Domain, Substance, Style programs 指定
setTheory.domain:
  1. type Set
  2. predicate Not(Prop p1)
  3. predicate Intersecting(Set s1, Set s2)
  4. predicate IsSubset(Set s1, Set s2)
Copy the Code

tree.substance:
  1. Set A, B, C, D, E, F, G
  2. IsSubset(B, A)
  3. IsSubset(C, A)
  4. IsSubset(D, B)
  5. IsSubset(E, B)
  6. IsSubset(F, C)
  7. IsSubset(G, C)
  8. Not(Intersecting(E, D))
  9. Not(Intersecting(F, G))
  10. Not(Intersecting(B, C))
  11. AutoLabel All
Copy the Code

venn.style:
  1. canvas {
  2.   width = 800
  3.   height = 700
  4. }
  5. forall Set x {
  6.   x.icon = Circle {
  7.     strokeWidth : 0
  8.   }
  9.   x.text = Equation {
  10.     string : x.label
  11.     fontSize : "25px"
  12.   }
  13.   ensure contains(x.icon, x.text)
  14.   encourage sameCenter(x.text, x.icon)
  15.   x.textLayering = x.text above x.icon
  16. }
  17. forall Set x; Set y
  18. where IsSubset(x, y) {
  19.   ensure smallerThan(x.icon, y.icon)
  20.   ensure disjoint(y.text, x.icon, 10)
  21.   ensure contains(y.icon, x.icon, 5)
  22.   x.icon above y.icon
  23. }
  24. forall Set x; Set y
  25. where Not(Intersecting(x, y)) {
  26.   ensure disjoint(x.icon, y.icon)
  27. }
  28. forall Set x; Set y
  29. where Intersecting(x, y) {
  30.   ensure overlapping(x.icon, y.icon)
  31.   ensure disjoint(y.text, x.icon)
  32.   ensure disjoint(x.text, y.icon)
  33. }
Copy the Code

手机版Mobile version|Leisure Math Forum

2025-4-20 22:16 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list